diff --git a/demo/egretProperties.json b/demo/egretProperties.json deleted file mode 100644 index f630de52..00000000 --- a/demo/egretProperties.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "engineVersion": "5.2.33", - "compilerVersion": "5.2.33", - "template": {}, - "target": { - "current": "web" - }, - "modules": [ - { - "name": "egret" - }, - { - "name": "eui" - }, - { - "name": "assetsmanager" - }, - { - "name": "game" - }, - { - "name": "tween" - }, - { - "name": "promise" - }, - { - "name": "dragonBones" - }, - { - "name": "fairygui", - "path": "./libs/fairygui" - }, - { - "name": "framework", - "path": "./libs/framework" - }, - { - "name": "framework_tiled", - "path": "./libs/framework_tiled" - } - ] -} \ No newline at end of file diff --git a/demo/favicon.ico b/demo/favicon.ico deleted file mode 100644 index e4ec42cb..00000000 Binary files a/demo/favicon.ico and /dev/null differ diff --git a/demo/index.html b/demo/index.html deleted file mode 100644 index 3f4f4d67..00000000 --- a/demo/index.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - Egret - - - - - - - - - - -
-
- - - - \ No newline at end of file diff --git a/demo/libs/exml.e.d.ts b/demo/libs/exml.e.d.ts deleted file mode 100644 index 7849d520..00000000 --- a/demo/libs/exml.e.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -declare module skins{ - class ButtonSkin extends eui.Skin{ - } -} -declare module skins{ - class CheckBoxSkin extends eui.Skin{ - } -} -declare module skins{ - class HScrollBarSkin extends eui.Skin{ - } -} -declare module skins{ - class HSliderSkin extends eui.Skin{ - } -} -declare module skins{ - class ItemRendererSkin extends eui.Skin{ - } -} -declare module skins{ - class PanelSkin extends eui.Skin{ - } -} -declare module skins{ - class ProgressBarSkin extends eui.Skin{ - } -} -declare module skins{ - class RadioButtonSkin extends eui.Skin{ - } -} -declare module skins{ - class ScrollerSkin extends eui.Skin{ - } -} -declare module skins{ - class TextInputSkin extends eui.Skin{ - } -} -declare module skins{ - class ToggleSwitchSkin extends eui.Skin{ - } -} -declare module skins{ - class VScrollBarSkin extends eui.Skin{ - } -} -declare module skins{ - class VSliderSkin extends eui.Skin{ - } -} diff --git a/demo/libs/fairygui/fairygui.d.ts b/demo/libs/fairygui/fairygui.d.ts deleted file mode 100644 index a92150a9..00000000 --- a/demo/libs/fairygui/fairygui.d.ts +++ /dev/null @@ -1,2444 +0,0 @@ -declare module fgui { - class AsyncOperation { - callback: (obj: GObject) => void; - callbackObj: any; - private _itemList; - private _objectPool; - private _index; - constructor(); - createObject(pkgName: string, resName: string): void; - createObjectFromURL(url: string): void; - cancel(): void; - private internalCreateObject; - private collectComponentChildren; - private collectListChildren; - private run; - } -} -declare module fgui { - class Controller extends egret.EventDispatcher { - private _selectedIndex; - private _previousIndex; - private _pageIds; - private _pageNames; - private _actions?; - name: string; - parent: GComponent; - autoRadioGroupDepth?: boolean; - changing: boolean; - constructor(); - dispose(): void; - selectedIndex: number; - setSelectedIndex(value: number): void; - readonly previsousIndex: number; - selectedPage: string; - setSelectedPage(value: string): void; - readonly previousPage: string; - readonly pageCount: number; - getPageName(index: number): string; - addPage(name?: string): void; - addPageAt(name: string, index: number): void; - removePage(name: string): void; - removePageAt(index?: number): void; - clearPages(): void; - hasPage(aName: string): boolean; - getPageIndexById(aId: string): number; - getPageIdByName(aName: string): string; - getPageNameById(aId: string): string; - getPageId(index?: number): string; - selectedPageId: string; - oppositePageId: string; - readonly previousPageId: string; - runActions(): void; - setup(buffer: ByteBuffer): void; - } -} -declare module fgui { - class DragDropManager { - private _agent; - private _sourceData; - private static _inst; - static readonly inst: DragDropManager; - constructor(); - readonly dragAgent: GObject; - readonly dragging: boolean; - startDrag(source: GObject, icon: string, sourceData?: any, touchPointID?: number): void; - cancel(): void; - private __dragEnd; - } -} -declare module fgui { - enum ButtonMode { - Common = 0, - Check = 1, - Radio = 2 - } - enum AutoSizeType { - None = 0, - Both = 1, - Height = 2 - } - enum AlignType { - Left = 0, - Center = 1, - Right = 2 - } - enum VertAlignType { - Top = 0, - Middle = 1, - Bottom = 2 - } - enum LoaderFillType { - None = 0, - Scale = 1, - ScaleMatchHeight = 2, - ScaleMatchWidth = 3, - ScaleFree = 4, - ScaleNoBorder = 5 - } - enum ListLayoutType { - SingleColumn = 0, - SingleRow = 1, - FlowHorizontal = 2, - FlowVertical = 3, - Pagination = 4 - } - enum ListSelectionMode { - Single = 0, - Multiple = 1, - Multiple_SingleClick = 2, - None = 3 - } - enum OverflowType { - Visible = 0, - Hidden = 1, - Scroll = 2 - } - enum PackageItemType { - Image = 0, - MovieClip = 1, - Sound = 2, - Component = 3, - Atlas = 4, - Font = 5, - Swf = 6, - Misc = 7, - Unknown = 8, - Spine = 9, - DragonBones = 10 - } - enum ObjectType { - Image = 0, - MovieClip = 1, - Swf = 2, - Graph = 3, - Loader = 4, - Group = 5, - Text = 6, - RichText = 7, - InputText = 8, - Component = 9, - List = 10, - Label = 11, - Button = 12, - ComboBox = 13, - ProgressBar = 14, - Slider = 15, - ScrollBar = 16, - Tree = 17, - Loader3D = 18 - } - enum ProgressTitleType { - Percent = 0, - ValueAndMax = 1, - Value = 2, - Max = 3 - } - enum ScrollBarDisplayType { - Default = 0, - Visible = 1, - Auto = 2, - Hidden = 3 - } - enum ScrollType { - Horizontal = 0, - Vertical = 1, - Both = 2 - } - enum FlipType { - None = 0, - Horizontal = 1, - Vertical = 2, - Both = 3 - } - enum ChildrenRenderOrder { - Ascent = 0, - Descent = 1, - Arch = 2 - } - enum GroupLayoutType { - None = 0, - Horizontal = 1, - Vertical = 2 - } - enum PopupDirection { - Auto = 0, - Up = 1, - Down = 2 - } - enum RelationType { - Left_Left = 0, - Left_Center = 1, - Left_Right = 2, - Center_Center = 3, - Right_Left = 4, - Right_Center = 5, - Right_Right = 6, - Top_Top = 7, - Top_Middle = 8, - Top_Bottom = 9, - Middle_Middle = 10, - Bottom_Top = 11, - Bottom_Middle = 12, - Bottom_Bottom = 13, - Width = 14, - Height = 15, - LeftExt_Left = 16, - LeftExt_Right = 17, - RightExt_Left = 18, - RightExt_Right = 19, - TopExt_Top = 20, - TopExt_Bottom = 21, - BottomExt_Top = 22, - BottomExt_Bottom = 23, - Size = 24 - } - enum FillMethod { - None = 0, - Horizontal = 1, - Vertical = 2, - Radial90 = 3, - Radial180 = 4, - Radial360 = 5 - } - enum FillOrigin { - Top = 0, - Bottom = 1, - Left = 2, - Right = 3, - TopLeft = 0, - TopRight = 1, - BottomLeft = 2, - BottomRight = 3 - } - enum FillOrigin90 { - TopLeft = 0, - TopRight = 1, - BottomLeft = 2, - BottomRight = 3 - } - enum ObjectPropID { - Text = 0, - Icon = 1, - Color = 2, - OutlineColor = 3, - Playing = 4, - Frame = 5, - DeltaTime = 6, - TimeScale = 7, - FontSize = 8, - Selected = 9 - } -} -declare module fgui { - class GObject extends egret.EventDispatcher { - data: any; - packageItem: PackageItem; - static draggingObject: GObject; - private _x; - private _y; - private _alpha; - private _rotation; - private _visible; - private _touchable; - private _grayed; - private _draggable; - private _scaleX; - private _scaleY; - private _skewX; - private _skewY; - private _pivotX; - private _pivotY; - private _pivotAsAnchor; - private _pivotOffsetX; - private _pivotOffsetY; - private _sortingOrder; - private _internalVisible; - private _handlingController?; - private _tooltips?; - private _pixelSnapping?; - private _disposed?; - private _dragTesting?; - private _dragStartPos?; - private _relations; - private _group?; - private _gears; - private _displayObject; - private _dragBounds?; - sourceWidth: number; - sourceHeight: number; - initWidth: number; - initHeight: number; - minWidth: number; - minHeight: number; - maxWidth: number; - maxHeight: number; - _parent: GComponent; - _width: number; - _height: number; - _rawWidth: number; - _rawHeight: number; - _id: string; - _name: string; - _underConstruct: boolean; - _gearLocked?: boolean; - _sizePercentInGroup: number; - _treeNode?: GTreeNode; - static XY_CHANGED: string; - static SIZE_CHANGED: string; - static SIZE_DELAY_CHANGE: string; - static GEAR_STOP: string; - constructor(); - readonly id: string; - name: string; - x: number; - y: number; - setXY(xv: number, yv: number): void; - xMin: number; - yMin: number; - pixelSnapping: boolean; - center(restraint?: boolean): void; - width: number; - height: number; - setSize(wv: number, hv: number, ignorePivot?: boolean): void; - makeFullScreen(): void; - ensureSizeCorrect(): void; - readonly actualWidth: number; - readonly actualHeight: number; - scaleX: number; - scaleY: number; - setScale(sx: number, sy: number): void; - skewX: number; - skewY: number; - setSkew(xv: number, yv: number): void; - pivotX: number; - pivotY: number; - setPivot(xv: number, yv: number, asAnchor?: boolean): void; - readonly pivotAsAnchor: boolean; - protected internalSetPivot(xv: number, yv: number, asAnchor: boolean): void; - private updatePivotOffset; - private applyPivot; - touchable: boolean; - grayed: boolean; - enabled: boolean; - rotation: number; - readonly normalizeRotation: number; - alpha: number; - visible: boolean; - readonly internalVisible: boolean; - readonly internalVisible2: boolean; - readonly internalVisible3: boolean; - sortingOrder: number; - readonly focused: boolean; - requestFocus(): void; - tooltips: string; - blendMode: string; - filters: egret.Filter[]; - readonly inContainer: boolean; - readonly onStage: boolean; - readonly resourceURL: string; - group: GGroup; - getGear(index: number): GearBase; - protected updateGear(index: number): void; - checkGearController(index: number, c: Controller): boolean; - updateGearFromRelations(index: number, dx: number, dy: number): void; - addDisplayLock(): number; - releaseDisplayLock(token: number): void; - private checkGearDisplay; - readonly gearXY: GearXY; - readonly gearSize: GearSize; - readonly gearLook: GearLook; - readonly relations: Relations; - addRelation(target: GObject, relationType: number, usePercent?: boolean): void; - removeRelation(target: GObject, relationType?: number): void; - readonly displayObject: egret.DisplayObject; - protected setDisplayObject(value: egret.DisplayObject): void; - parent: GComponent; - removeFromParent(): void; - readonly root: GRoot; - readonly asCom: GComponent; - readonly asButton: GButton; - readonly asLabel: GLabel; - readonly asProgress: GProgressBar; - readonly asTextField: GTextField; - readonly asRichTextField: GRichTextField; - readonly asTextInput: GTextInput; - readonly asLoader: GLoader; - readonly asList: GList; - readonly asTree: GTree; - readonly asGraph: GGraph; - readonly asGroup: GGroup; - readonly asSlider: GSlider; - readonly asComboBox: GComboBox; - readonly asImage: GImage; - readonly asMovieClip: GMovieClip; - static cast(obj: egret.DisplayObject): GObject; - text: string; - icon: string; - readonly isDisposed: boolean; - readonly treeNode: GTreeNode; - dispose(): void; - addClickListener(listener: Function, thisObj?: any): void; - removeClickListener(listener: Function, thisObj?: any): void; - hasClickListener(): boolean; - addEventListener(type: string, listener: Function, thisObject?: any): void; - removeEventListener(type: string, listener: Function, thisObject?: any): void; - private _reDispatch; - draggable: boolean; - dragBounds: egret.Rectangle; - startDrag(touchPointID?: number, stageX?: number, stageY?: number): void; - stopDrag(): void; - readonly dragging: boolean; - localToGlobal(ax?: number, ay?: number, result?: egret.Point): egret.Point; - globalToLocal(ax?: number, ay?: number, result?: egret.Point): egret.Point; - localToRoot(ax?: number, ay?: number, result?: egret.Point): egret.Point; - rootToLocal(ax?: number, ay?: number, resultPoint?: egret.Point): egret.Point; - localToGlobalRect(ax?: number, ay?: number, aw?: number, ah?: number, result?: egret.Rectangle): egret.Rectangle; - globalToLocalRect(ax?: number, ay?: number, aw?: number, ah?: number, result?: egret.Rectangle): egret.Rectangle; - handleControllerChanged(c: Controller): void; - protected createDisplayObject(): void; - protected switchDisplayObject(newObj: egret.DisplayObject): void; - protected handleXYChanged(): void; - protected handleSizeChanged(): void; - protected handleScaleChanged(): void; - protected handleGrayedChanged(): void; - protected handleAlphaChanged(): void; - handleVisibleChanged(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - constructFromResource(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - private initDrag; - private dragBegin; - private dragEnd; - private reset; - private __begin; - private __moving; - private __end; - } -} -declare module fgui { - class GComponent extends GObject { - private _sortingChildCount; - private _applyingController?; - protected _margin: Margin; - protected _trackBounds: boolean; - protected _boundsChanged: boolean; - protected _childrenRenderOrder: ChildrenRenderOrder; - protected _apexIndex: number; - _buildingDisplayList: boolean; - _children: Array; - _controllers: Array; - _transitions: Array; - _rootContainer: UIContainer; - _container: egret.DisplayObjectContainer; - _scrollPane?: ScrollPane; - _alignOffset: egret.Point; - constructor(); - protected createDisplayObject(): void; - dispose(): void; - readonly displayListContainer: egret.DisplayObjectContainer; - addChild(child: GObject): GObject; - addChildAt(child: GObject, index?: number): GObject; - private getInsertPosForSortingChild; - removeChild(child: GObject, dispose?: boolean): GObject; - removeChildAt(index: number, dispose?: boolean): GObject; - removeChildren(beginIndex?: number, endIndex?: number, dispose?: boolean): void; - getChildAt(index: number): GObject; - getChild(name: string): GObject; - getChildByPath(path: String): GObject; - getVisibleChild(name: string): GObject; - getChildInGroup(name: string, group: GGroup): GObject; - getChildById(id: string): GObject; - getChildIndex(child: GObject): number; - setChildIndex(child: GObject, index: number): void; - setChildIndexBefore(child: GObject, index: number): number; - private _setChildIndex; - swapChildren(child1: GObject, child2: GObject): void; - swapChildrenAt(index1: number, index2: number): void; - readonly numChildren: number; - isAncestorOf(child: GObject): boolean; - addController(controller: Controller): void; - getControllerAt(index: number): Controller; - getController(name: string): Controller; - removeController(c: Controller): void; - readonly controllers: Array; - childStateChanged(child: GObject): void; - private buildNativeDisplayList; - applyController(c: Controller): void; - applyAllControllers(): void; - adjustRadioGroupDepth(obj: GObject, c: Controller): void; - getTransitionAt(index: number): Transition; - getTransition(transName: string): Transition; - isChildInView(child: GObject): boolean; - getFirstChildInView(): number; - readonly scrollPane: ScrollPane; - opaque: boolean; - margin: Margin; - childrenRenderOrder: ChildrenRenderOrder; - apexIndex: number; - mask: egret.DisplayObject | egret.Rectangle; - readonly baseUserData: string; - protected updateScrollRect(): void; - protected setupScroll(buffer: ByteBuffer): void; - protected setupOverflow(overflow: OverflowType): void; - protected handleSizeChanged(): void; - protected handleGrayedChanged(): void; - handleControllerChanged(c: Controller): void; - setBoundsChangedFlag(): void; - private __render; - ensureBoundsCorrect(): void; - protected updateBounds(): void; - setBounds(ax: number, ay: number, aw: number, ah?: number): void; - viewWidth: number; - viewHeight: number; - getSnappingPosition(xValue: number, yValue: number, resultPoint?: egret.Point): egret.Point; - childSortingOrderChanged(child: GObject, oldValue: number, newValue?: number): void; - constructFromResource(): void; - constructFromResource2(objectPool: Array, poolIndex: number): void; - protected onConstruct(): void; - protected constructExtension(buffer: ByteBuffer): void; - protected constructFromXML(xml: any): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - private ___added; - private ___removed; - } -} -declare module fgui { - class GButton extends GComponent { - protected _titleObject: GObject; - protected _iconObject: GObject; - private _mode; - private _selected; - private _title; - private _selectedTitle; - private _icon; - private _selectedIcon; - private _sound; - private _soundVolumeScale; - private _buttonController; - private _relatedController?; - private _relatedPageId; - private _changeStateOnClick; - private _linkedPopup?; - private _downEffect; - private _downEffectValue; - private _downScaled?; - private _down; - private _over; - static UP: string; - static DOWN: string; - static OVER: string; - static SELECTED_OVER: string; - static DISABLED: string; - static SELECTED_DISABLED: string; - constructor(); - icon: string; - selectedIcon: string; - title: string; - text: string; - selectedTitle: string; - titleColor: number; - titleFontSize: number; - sound: string; - soundVolumeScale: number; - selected: boolean; - mode: ButtonMode; - relatedController: Controller; - relatedPageId: string; - changeStateOnClick: boolean; - linkedPopup: GObject; - getTextField(): GTextField; - addStateListener(listener: Function, thisObj: any): void; - removeStateListener(listener: Function, thisObj: any): void; - fireClick(downEffect?: boolean): void; - protected setState(val: string): void; - handleControllerChanged(c: Controller): void; - protected handleGrayedChanged(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - protected constructExtension(buffer: ByteBuffer): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - private __mousedown; - private __mouseup; - private __click; - } -} -declare module fgui { - class GComboBox extends GComponent { - dropdown: GComponent; - protected _titleObject: GObject; - protected _iconObject: GObject; - protected _list: GList; - private _items; - private _values; - private _icons?; - private _visibleItemCount; - private _itemsUpdated; - private _selectedIndex; - private _buttonController; - private _popupDirection; - private _selectionController?; - private _over; - private _down; - constructor(); - text: string; - icon: string; - titleColor: number; - titleFontSize: number; - visibleItemCount: number; - popupDirection: PopupDirection; - items: Array; - icons: Array; - values: Array; - selectedIndex: number; - value: string; - selectionController: Controller; - getTextField(): GTextField; - protected setState(val: string): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - protected constructExtension(buffer: ByteBuffer): void; - handleControllerChanged(c: Controller): void; - private updateSelectionController; - dispose(): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - protected showDropdown(): void; - private __popupWinClosed; - private __clickItem; - private __clickItem2; - private __mousedown; - private __mouseup; - } -} -declare module fgui { - class GGraph extends GObject { - private _graphics; - private _type; - private _lineSize; - private _lineColor; - private _lineAlpha; - private _fillColor; - private _fillAlpha; - private _cornerRadius?; - private _sides?; - private _startAngle?; - private _polygonPoints?; - private _distances?; - constructor(); - readonly graphics: egret.Graphics; - drawRect(lineSize: number, lineColor: number, lineAlpha: number, fillColor: number, fillAlpha: number, corner?: Array): void; - drawEllipse(lineSize: number, lineColor: number, lineAlpha: number, fillColor: number, fillAlpha: number): void; - drawRegularPolygon(lineSize: number, lineColor: number, lineAlpha: number, fillColor: number, fillAlpha: number, sides: number, startAngle?: number, distances?: number[]): void; - drawPolygon(lineSize: number, lineColor: number, lineAlpha: number, fillColor: number, fillAlpha: number, points: number[]): void; - distances: number[]; - clearGraphics(): void; - color: number; - private updateGraph; - replaceMe(target: GObject): void; - addBeforeMe(target: GObject): void; - addAfterMe(target: GObject): void; - setNativeObject(obj: egret.DisplayObject): void; - protected createDisplayObject(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - protected handleSizeChanged(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare namespace fgui { - class GGroup extends GObject { - private _layout; - private _lineGap; - private _columnGap; - private _excludeInvisibles?; - private _autoSizeDisabled?; - private _mainGridIndex; - private _mainGridMinSize; - private _boundsChanged; - private _percentReady; - private _mainChildIndex; - private _totalSize; - private _numChildren; - _updating: number; - constructor(); - dispose(): void; - layout: number; - lineGap: number; - columnGap: number; - excludeInvisibles: boolean; - autoSizeDisabled: boolean; - mainGridMinSize: number; - mainGridIndex: number; - setBoundsChangedFlag(positionChangedOnly?: boolean): void; - ensureSizeCorrect(): void; - ensureBoundsCorrect(): void; - private updateBounds; - private handleLayout; - moveChildren(dx: number, dy: number): void; - resizeChildren(dw: number, dh: number): void; - handleAlphaChanged(): void; - handleVisibleChanged(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GImage extends GObject { - private _content; - private _flip; - constructor(); - color: number; - flip: FlipType; - fillMethod: number; - fillOrigin: number; - fillClockwise: boolean; - fillAmount: number; - texture: egret.Texture; - protected createDisplayObject(): void; - constructFromResource(): void; - protected handleXYChanged(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GLabel extends GComponent { - protected _titleObject: GObject; - protected _iconObject: GObject; - constructor(); - icon: string; - title: string; - text: string; - titleColor: number; - titleFontSize: number; - editable: boolean; - getTextField(): GTextField; - getProp(index: number): any; - setProp(index: number, value: any): void; - protected constructExtension(buffer: ByteBuffer): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GList extends GComponent { - itemRenderer: (index: number, item: GObject) => void; - itemProvider: (index: number) => string; - callbackThisObj: any; - scrollItemToViewOnClick: boolean; - foldInvisibleItems: boolean; - private _layout; - private _lineCount; - private _columnCount; - private _lineGap; - private _columnGap; - private _defaultItem; - private _autoResizeItem; - private _selectionMode; - private _align; - private _verticalAlign; - private _selectionController?; - private _lastSelectedIndex; - private _pool; - private _virtual?; - private _loop?; - private _numItems; - private _realNumItems; - private _firstIndex; - private _curLineItemCount; - private _curLineItemCount2; - private _itemSize?; - private _virtualListChanged; - private _virtualItems?; - private _eventLocked?; - private itemInfoVer; - constructor(); - dispose(): void; - layout: ListLayoutType; - lineCount: number; - columnCount: number; - lineGap: number; - columnGap: number; - align: AlignType; - verticalAlign: VertAlignType; - virtualItemSize: egret.Point; - defaultItem: string; - autoResizeItem: boolean; - selectionMode: ListSelectionMode; - selectionController: Controller; - readonly itemPool: GObjectPool; - getFromPool(url?: string): GObject; - returnToPool(obj: GObject): void; - addChildAt(child: GObject, index: number): GObject; - addItem(url?: string): GObject; - addItemFromPool(url?: string): GObject; - removeChildAt(index: number, dispose?: boolean): GObject; - removeChildToPoolAt(index: number): void; - removeChildToPool(child: GObject): void; - removeChildrenToPool(beginIndex?: number, endIndex?: number): void; - selectedIndex: number; - getSelection(result?: number[]): number[]; - addSelection(index: number, scrollItToView?: boolean): void; - removeSelection(index: number): void; - clearSelection(): void; - private clearSelectionExcept; - selectAll(): void; - selectNone(): void; - selectReverse(): void; - handleArrowKey(dir: number): void; - private __clickItem; - protected dispatchItemEvent(evt: ItemEvent): void; - private setSelectionOnEvent; - resizeToFit(itemCount?: number, minSize?: number): void; - getMaxItemWidth(): number; - protected handleSizeChanged(): void; - handleControllerChanged(c: Controller): void; - private updateSelectionController; - getSnappingPosition(xValue: number, yValue: number, result?: egret.Point): egret.Point; - scrollToView(index: number, ani?: boolean, setFirst?: boolean): void; - getFirstChildInView(): number; - childIndexToItemIndex(index: number): number; - itemIndexToChildIndex(index: number): number; - setVirtual(): void; - setVirtualAndLoop(): void; - private _setVirtual; - numItems: number; - refreshVirtualList(): void; - private checkVirtualList; - private setVirtualListChangedFlag; - private _refreshVirtualList; - private __scrolled; - private getIndexOnPos1; - private getIndexOnPos2; - private getIndexOnPos3; - private handleScroll; - private handleScroll1; - private handleScroll2; - private handleScroll3; - private handleArchOrder1; - private handleArchOrder2; - private handleAlign; - protected updateBounds(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - protected readItems(buffer: ByteBuffer): void; - protected setupItem(buffer: ByteBuffer, obj: GObject): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GObjectPool { - private _pool; - private _count; - constructor(); - clear(): void; - readonly count: number; - getObject(url: string): GObject; - returnObject(obj: GObject): void; - } -} -declare module fgui { - class GLoader extends GObject { - private _url; - private _align; - private _verticalAlign; - private _autoSize; - private _fill; - private _shrinkOnly; - private _showErrorSign; - private _contentItem; - private _container; - private _content; - private _errorSign?; - private _content2?; - private _updatingLayout; - private static _errorSignPool; - constructor(); - protected createDisplayObject(): void; - dispose(): void; - url: string; - icon: string; - align: AlignType; - verticalAlign: VertAlignType; - fill: LoaderFillType; - shrinkOnly: boolean; - autoSize: boolean; - playing: boolean; - frame: number; - color: number; - showErrorSign: boolean; - readonly content: MovieClip; - readonly component: GComponent; - texture: egret.Texture; - fillMethod: number; - fillOrigin: number; - fillClockwise: boolean; - fillAmount: number; - protected loadContent(): void; - protected loadFromPackage(itemURL: string): void; - protected loadExternal(): void; - protected freeExternal(texture: egret.Texture): void; - protected onExternalLoadSuccess(texture: egret.Texture): void; - protected onExternalLoadFailed(): void; - private __getResCompleted; - private setErrorState; - private clearErrorState; - private updateLayout; - private clearContent; - protected handleSizeChanged(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare namespace fgui { - class GLoader3D extends GObject { - private _url; - private _align; - private _verticalAlign; - private _autoSize; - private _fill; - private _shrinkOnly; - private _playing; - private _frame; - private _loop; - private _animationName; - private _skinName; - private _color; - private _contentItem; - private _container; - private _content; - private _updatingLayout; - constructor(); - protected createDisplayObject(): void; - dispose(): void; - url: string; - icon: string; - align: AlignType; - verticalAlign: VertAlignType; - fill: LoaderFillType; - shrinkOnly: boolean; - autoSize: boolean; - playing: boolean; - frame: number; - animationName: string; - skinName: string; - loop: boolean; - color: number; - readonly content: dragonBones.EgretArmatureDisplay; - protected loadContent(): void; - protected loadFromPackage(itemURL: string): void; - private onLoaded; - setDragonBones(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string, anchor?: egret.Point): void; - private onChange; - private onChangeDragonBones; - protected loadExternal(): void; - private updateLayout; - private clearContent; - protected handleSizeChanged(): void; - protected handleGrayedChanged(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GMovieClip extends GObject { - private _content; - constructor(); - color: number; - protected createDisplayObject(): void; - playing: boolean; - frame: number; - timeScale: number; - rewind(): void; - syncStatus(anotherMc: GMovieClip): void; - advance(timeInMiniseconds: number): void; - setPlaySettings(start?: number, end?: number, times?: number, endAt?: number, endCallback?: Function, callbackObj?: any): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - constructFromResource(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GProgressBar extends GComponent { - private _min; - private _max; - private _value; - private _titleType; - private _reverse; - private _titleObject; - private _aniObject; - private _barObjectH; - private _barObjectV; - private _barMaxWidth; - private _barMaxHeight; - private _barMaxWidthDelta; - private _barMaxHeightDelta; - private _barStartX; - private _barStartY; - constructor(); - titleType: ProgressTitleType; - min: number; - max: number; - value: number; - tweenValue(value: number, duration: number): GTweener; - update(newValue: number): void; - private setFillAmount; - protected constructExtension(buffer: ByteBuffer): void; - protected handleSizeChanged(): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GTextField extends GObject { - protected _textField: egret.TextField; - protected _bitmapContainer?: egret.DisplayObjectContainer; - protected _font: string; - protected _fontSize: number; - protected _align: AlignType; - protected _verticalAlign: VertAlignType; - protected _color: number; - protected _leading: number; - protected _letterSpacing: number; - protected _underline: boolean; - protected _text: string; - protected _ubbEnabled: boolean; - protected _templateVars?: { - [index: string]: string; - }; - protected _autoSize: AutoSizeType; - protected _widthAutoSize: boolean; - protected _heightAutoSize: boolean; - protected _updatingSize: boolean; - protected _sizeDirty: boolean; - protected _textWidth: number; - protected _textHeight: number; - protected _requireRender: boolean; - protected _bitmapFont?: BitmapFont; - protected _lines?: Array; - protected _bitmapPool?: Array; - protected static _htmlParser: egret.HtmlTextParser; - constructor(); - protected createDisplayObject(): void; - private switchBitmapMode; - dispose(): void; - text: string; - protected updateTextFieldText(): void; - font: string; - fontSize: number; - color: number; - align: AlignType; - verticalAlign: VertAlignType; - private getAlignTypeString; - private getVertAlignTypeString; - leading: number; - letterSpacing: number; - underline: boolean; - bold: boolean; - italic: boolean; - singleLine: boolean; - stroke: number; - strokeColor: number; - ubbEnabled: boolean; - autoSize: AutoSizeType; - readonly textWidth: number; - ensureSizeCorrect(): void; - protected updateTextFormat(): void; - protected render(): void; - private __render; - protected renderNow(updateBounds?: boolean): void; - private renderWithBitmapFont; - protected handleSizeChanged(): void; - protected parseTemplate(template: string): string; - templateVars: { - [index: string]: string; - }; - setVar(name: string, value: string): GTextField; - flushVars(): void; - protected handleGrayedChanged(): void; - private doAlign; - getProp(index: number): any; - setProp(index: number, value: any): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - } - interface LineInfo { - width: number; - height: number; - textHeight: number; - text: string; - y: number; - } -} -declare module fgui { - class GRichTextField extends GTextField { - constructor(); - protected updateTextFieldText(): void; - } -} -declare module fgui { - class GRoot extends GComponent { - static contentScaleLevel: number; - private _nativeStage; - private _modalLayer; - private _popupStack; - private _justClosedPopups; - private _modalWaitPane; - private _tooltipWin; - private _defaultTooltipWin; - private _volumeScale; - private static _inst; - static touchScreen: boolean; - static contentScaleFactor: number; - static touchDown: boolean; - static ctrlKeyDown: boolean; - static shiftKeyDown: boolean; - static mouseX: number; - static mouseY: number; - static readonly inst: GRoot; - constructor(); - readonly nativeStage: egret.Stage; - showWindow(win: Window): void; - hideWindow(win: Window): void; - hideWindowImmediately(win: Window): void; - bringToFront(win: Window): void; - showModalWait(msg?: string): void; - closeModalWait(): void; - closeAllExceptModals(): void; - closeAllWindows(): void; - getTopWindow(): Window; - readonly modalLayer: GGraph; - readonly hasModalWindow: boolean; - readonly modalWaiting: boolean; - showPopup(popup: GObject, target?: GObject, dir?: PopupDirection | boolean): void; - togglePopup(popup: GObject, target?: GObject, dir?: PopupDirection | boolean): void; - hidePopup(popup?: GObject): void; - readonly hasAnyPopup: boolean; - private closePopup; - showTooltips(msg: string): void; - showTooltipsWin(tooltipWin: GObject, position?: egret.Point): void; - hideTooltips(): void; - getObjectUnderPoint(globalX: number, globalY: number): GObject; - focus: GObject; - private setFocus; - volumeScale: number; - playOneShotSound(sound: egret.Sound, volumeScale?: number): void; - private adjustModalLayer; - private __addedToStage; - private __stageMouseDownCapture; - private __stageMouseMoveCapture; - private __stageMouseUpCapture; - private __winResize; - private updateContentScaleLevel; - } -} -declare module fgui { - class GScrollBar extends GComponent { - private _grip; - private _arrowButton1; - private _arrowButton2; - private _bar; - private _target; - private _vertical; - private _scrollPerc; - private _fixedGripSize; - private _dragOffset; - private _gripDragging; - constructor(); - setScrollPane(target: ScrollPane, vertical: boolean): void; - setDisplayPerc(value: number): void; - setScrollPerc(val: number): void; - readonly minSize: number; - readonly gripDragging: boolean; - protected constructExtension(buffer: ByteBuffer): void; - private __gripMouseDown; - private __gripMouseMove; - private __gripMouseUp; - private __arrowButton1Click; - private __arrowButton2Click; - private __barMouseDown; - } -} -declare module fgui { - class GSlider extends GComponent { - private _min; - private _max; - private _value; - private _titleType; - private _reverse; - private _wholeNumbers; - private _titleObject; - private _barObjectH; - private _barObjectV; - private _barMaxWidth; - private _barMaxHeight; - private _barMaxWidthDelta; - private _barMaxHeightDelta; - private _gripObject; - private _clickPos; - private _clickPercent; - private _barStartX; - private _barStartY; - changeOnClick: boolean; - canDrag: boolean; - constructor(); - titleType: ProgressTitleType; - wholeNumbers: boolean; - min: number; - max: number; - value: number; - update(): void; - private updateWithPercent; - protected constructExtension(buffer: ByteBuffer): void; - protected handleSizeChanged(): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - private __gripMouseDown; - private __gripMouseMove; - private __gripMouseUp; - private __barMouseDown; - } -} -declare module fgui { - class GTextInput extends GTextField { - private _promptText; - private _password; - constructor(); - dispose(): void; - editable: boolean; - maxLength: number; - promptText: string; - restrict: string; - password: boolean; - verticalAlign: VertAlignType; - private updateVertAlign; - protected updateTextFieldText(): void; - protected handleSizeChanged(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - private __textChanged; - private __focusIn; - private __focusOut; - } -} -declare namespace fgui { - class GTree extends GList { - treeNodeRender: (node: GTreeNode, obj: GComponent) => void; - treeNodeWillExpand: (node: GTreeNode, expanded: boolean) => void; - private _indent; - private _clickToExpand; - private _rootNode; - private _expandedStatusInEvt; - constructor(); - readonly rootNode: GTreeNode; - indent: number; - clickToExpand: number; - getSelectedNode(): GTreeNode; - getSelectedNodes(result?: Array): Array; - selectNode(node: GTreeNode, scrollItToView?: boolean): void; - unselectNode(node: GTreeNode): void; - expandAll(folderNode?: GTreeNode): void; - collapseAll(folderNode?: GTreeNode): void; - private createCell; - _afterInserted(node: GTreeNode): void; - private getInsertIndexForNode; - _afterRemoved(node: GTreeNode): void; - _afterExpanded(node: GTreeNode): void; - _afterCollapsed(node: GTreeNode): void; - _afterMoved(node: GTreeNode): void; - private getFolderEndIndex; - private checkChildren; - private hideFolderNode; - private removeNode; - private __cellMouseDown; - private __expandedStateChanged; - protected dispatchItemEvent(evt: ItemEvent): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - protected readItems(buffer: ByteBuffer): void; - } -} -declare namespace fgui { - class GTreeNode { - data: any; - private _parent; - private _children; - private _expanded; - private _level; - private _tree; - _cell: GComponent; - _resURL?: string; - constructor(hasChild: boolean, resURL?: string); - expanded: boolean; - readonly isFolder: boolean; - readonly parent: GTreeNode; - text: string; - icon: string; - readonly cell: GComponent; - readonly level: number; - _setLevel(value: number): void; - addChild(child: GTreeNode): GTreeNode; - addChildAt(child: GTreeNode, index: number): GTreeNode; - removeChild(child: GTreeNode): GTreeNode; - removeChildAt(index: number): GTreeNode; - removeChildren(beginIndex?: number, endIndex?: number): void; - getChildAt(index: number): GTreeNode; - getChildIndex(child: GTreeNode): number; - getPrevSibling(): GTreeNode; - getNextSibling(): GTreeNode; - setChildIndex(child: GTreeNode, index: number): void; - swapChildren(child1: GTreeNode, child2: GTreeNode): void; - swapChildrenAt(index1: number, index2: number): void; - readonly numChildren: number; - expandToRoot(): void; - readonly tree: GTree; - _setTree(value: GTree): void; - } -} -declare module fgui { - interface IUISource { - fileName: string; - loaded: boolean; - load(callback: Function, thisObj: any): void; - } -} -declare module fgui { - class Margin { - left: number; - right: number; - top: number; - bottom: number; - constructor(); - copy(source: Margin): void; - } -} -declare namespace fgui { - class PixelHitTest { - private _data; - offsetX: number; - offsetY: number; - scaleX: number; - scaleY: number; - constructor(data: PixelHitTestData, offsetX: number, offsetY: number); - contains(x: number, y: number): boolean; - } - class PixelHitTestData { - pixelWidth: number; - scale: number; - pixels: number[]; - constructor(); - load(ba: ByteBuffer): void; - } -} -declare module fgui { - class PackageItem { - owner: UIPackage; - type: PackageItemType; - objectType?: ObjectType; - id: string; - name: string; - width: number; - height: number; - file: string; - decoded?: boolean; - loading?: Array; - rawData?: ByteBuffer; - asset?: egret.Texture | egret.Sound | dragonBones.DragonBonesData; - highResolution?: Array; - branches?: Array; - scale9Grid?: egret.Rectangle; - scaleByTile?: boolean; - tileGridIndice?: number; - smoothing?: boolean; - pixelHitTestData?: PixelHitTestData; - interval?: number; - repeatDelay?: number; - swing?: boolean; - frames?: Array; - extensionType?: any; - bitmapFont?: BitmapFont; - skeletonAnchor?: egret.Point; - armatureName?: string; - atlasAsset?: dragonBones.TextureAtlasData; - constructor(); - load(): Object; - getBranch(): PackageItem; - getHighResolution(): PackageItem; - toString(): string; - } -} -declare module fgui { - class PopupMenu { - protected _contentPane: GComponent; - protected _list: GList; - constructor(resourceURL?: string); - dispose(): void; - addItem(caption: string, callback?: (item?: ItemEvent) => void): GButton; - addItemAt(caption: string, index: number, callback?: (item?: ItemEvent) => void): GButton; - addSeperator(): void; - getItemName(index: number): string; - setItemText(name: string, caption: string): void; - setItemVisible(name: string, visible: boolean): void; - setItemGrayed(name: string, grayed: boolean): void; - setItemCheckable(name: string, checkable: boolean): void; - setItemChecked(name: string, checked: boolean): void; - isItemChecked(name: string): boolean; - removeItem(name: string): boolean; - clearItems(): void; - readonly itemCount: number; - readonly contentPane: GComponent; - readonly list: GList; - show(target?: GObject, dir?: PopupDirection | boolean): void; - private __clickItem; - private __clickItem2; - private __addedToStage; - } -} -declare module fgui { - class RelationItem { - private _owner; - private _target; - private _defs; - private _targetX; - private _targetY; - private _targetWidth; - private _targetHeight; - constructor(owner: GObject); - readonly owner: GObject; - target: GObject; - add(relationType: number, usePercent: boolean): void; - internalAdd(relationType: number, usePercent: boolean): void; - remove(relationType?: number): void; - copyFrom(source: RelationItem): void; - dispose(): void; - readonly isEmpty: boolean; - applyOnSelfResized(dWidth: number, dHeight: number, applyPivot: boolean): void; - private applyOnXYChanged; - private applyOnSizeChanged; - private addRefTarget; - private releaseRefTarget; - private __targetXYChanged; - private __targetSizeChanged; - private __targetSizeWillChange; - } - class RelationDef { - percent: boolean; - type: number; - axis: number; - constructor(); - copyFrom(source: RelationDef): void; - } -} -declare module fgui { - class Relations { - private _owner; - private _items; - handling: GObject; - sizeDirty: boolean; - constructor(owner: GObject); - add(target: GObject, relationType: number, usePercent?: boolean): void; - remove(target: GObject, relationType?: number): void; - contains(target: GObject): boolean; - clearFor(target: GObject): void; - clearAll(): void; - copyFrom(source: Relations): void; - dispose(): void; - onOwnerSizeChanged(dWidth: number, dHeight: number, applyPivot: boolean): void; - ensureRelationsSizeCorrect(): void; - readonly empty: boolean; - setup(buffer: ByteBuffer, parentToChild: boolean): void; - } -} -declare module fgui { - class ScrollPane extends egret.EventDispatcher { - private _owner; - private _container; - private _maskContainer; - private _alignContainer?; - private _scrollType; - private _scrollStep; - private _decelerationRate; - private _scrollBarMargin; - private _bouncebackEffect; - private _touchEffect; - private _scrollBarDisplayAuto?; - private _vScrollNone; - private _hScrollNone; - private _needRefresh; - private _refreshBarAxis; - private _displayOnLeft?; - private _snapToItem?; - _displayInDemand?: boolean; - private _pageMode?; - private _inertiaDisabled?; - private _floating?; - private _dontClipMargin?; - private _xPos; - private _yPos; - private _viewSize; - private _contentSize; - private _overlapSize; - private _pageSize; - private _containerPos; - private _beginTouchPos; - private _lastTouchPos; - private _lastTouchGlobalPos; - private _velocity; - private _velocityScale; - private _lastMoveTime; - private _isHoldAreaDone; - private _aniFlag; - _loop: number; - private _headerLockedSize; - private _footerLockedSize; - private _refreshEventDispatching; - private _dragged; - private _tweening; - private _tweenTime; - private _tweenDuration; - private _tweenStart; - private _tweenChange; - private _pageController?; - private _hzScrollBar?; - private _vtScrollBar?; - private _header?; - private _footer?; - static draggingPane: ScrollPane; - static SCROLL: string; - static SCROLL_END: string; - static PULL_DOWN_RELEASE: string; - static PULL_UP_RELEASE: string; - constructor(owner: GComponent); - setup(buffer: ByteBuffer): void; - dispose(): void; - readonly owner: GComponent; - readonly hzScrollBar: GScrollBar; - readonly vtScrollBar: GScrollBar; - readonly header: GComponent; - readonly footer: GComponent; - bouncebackEffect: boolean; - touchEffect: boolean; - scrollStep: number; - decelerationRate: number; - snapToItem: boolean; - readonly isDragged: boolean; - percX: number; - setPercX(value: number, ani?: boolean): void; - percY: number; - setPercY(value: number, ani?: boolean): void; - posX: number; - setPosX(value: number, ani?: boolean): void; - posY: number; - setPosY(value: number, ani?: boolean): void; - readonly contentWidth: number; - readonly contentHeight: number; - viewWidth: number; - viewHeight: number; - currentPageX: number; - currentPageY: number; - setCurrentPageX(value: number, ani?: boolean): void; - setCurrentPageY(value: number, ani?: boolean): void; - readonly isBottomMost: boolean; - readonly isRightMost: boolean; - pageController: Controller; - readonly scrollingPosX: number; - readonly scrollingPosY: number; - scrollTop(ani?: boolean): void; - scrollBottom(ani?: boolean): void; - scrollUp(ratio?: number, ani?: boolean): void; - scrollDown(ratio?: number, ani?: boolean): void; - scrollLeft(ratio?: number, ani?: boolean): void; - scrollRight(ratio?: number, ani?: boolean): void; - scrollToView(target: egret.Rectangle | GObject, ani?: boolean, setFirst?: boolean): void; - isChildInView(obj: GObject): boolean; - cancelDragging(): void; - lockHeader(size: number): void; - lockFooter(size: number): void; - onOwnerSizeChanged(): void; - handleControllerChanged(c: Controller): void; - private updatePageController; - adjustMaskContainer(): void; - setSize(aWidth: number, aHeight: number): void; - setContentSize(aWidth: number, aHeight: number): void; - changeContentSizeOnScrolling(deltaWidth: number, deltaHeight: number, deltaPosX: number, deltaPosY: number): void; - private handleSizeChanged; - private posChanged; - private refresh; - private refresh2; - private __touchBegin; - private __touchMove; - private __touchEnd; - private __touchTap; - private updateScrollBarPos; - updateScrollBarVisible(): void; - private updateScrollBarVisible2; - private __barTweenComplete; - private getLoopPartSize; - private loopCheckingCurrent; - private loopCheckingTarget; - private loopCheckingTarget2; - private loopCheckingNewPos; - private alignPosition; - private alignByPage; - private updateTargetAndDuration; - private updateTargetAndDuration2; - private fixDuration; - private startTween; - private killTween; - private checkRefreshBar; - private tweenUpdate; - private runTween; - } -} -declare module fgui { - class Transition { - name: string; - private _owner; - private _ownerBaseX; - private _ownerBaseY; - private _items; - private _totalTimes; - private _totalTasks; - private _playing; - private _paused; - private _onComplete; - private _onCompleteCaller; - private _onCompleteParam; - private _options; - private _reversed; - private _totalDuration; - private _autoPlay; - private _autoPlayTimes; - private _autoPlayDelay; - private _timeScale; - private _startTime; - private _endTime; - constructor(owner: GComponent); - play(onComplete?: () => void, onCompleteObj?: any, onCompleteParam?: any, times?: number, delay?: number, startTime?: number, endTime?: number): void; - playReverse(onComplete?: () => void, onCompleteObj?: any, onCompleteParam?: any, times?: number, delay?: number): void; - changePlayTimes(value: number): void; - setAutoPlay(value: boolean, times?: number, delay?: number): void; - private _play; - stop(setToComplete?: boolean, processCallback?: boolean): void; - private stopItem; - setPaused(paused: boolean): void; - dispose(): void; - readonly playing: boolean; - setValue(label: string, ...args: any[]): void; - setHook(label: string, callback: Function, caller?: any): void; - clearHooks(): void; - setTarget(label: string, newTarget: GObject): void; - setDuration(label: string, value: number): void; - getLabelTime(label: string): number; - timeScale: number; - updateFromRelations(targetId: string, dx: number, dy: number): void; - onOwnerAddedToStage(): void; - onOwnerRemovedFromStage(): void; - private onDelayedPlay; - private internalPlay; - private playItem; - private skipAnimations; - private onDelayedPlayItem; - private onTweenStart; - private onTweenUpdate; - private onTweenComplete; - private onPlayTransCompleted; - private callHook; - private checkAllComplete; - private applyValue; - setup(buffer: ByteBuffer): void; - private decodeValue; - } -} -declare module fgui { - class TranslationHelper { - static strings: { - [index: string]: { - [index: string]: string; - }; - }; - static loadFromXML(source: string): void; - static translateComponent(item: PackageItem): void; - } -} -declare module fgui { - class UIConfig { - constructor(); - static defaultFont: string; - static windowModalWaiting: string; - static globalModalWaiting: string; - static modalLayerColor: number; - static modalLayerAlpha: number; - static buttonSound: string; - static buttonSoundVolumeScale: number; - static horizontalScrollBar: string; - static verticalScrollBar: string; - static defaultScrollStep: number; - static defaultScrollDecelerationRate: number; - static defaultScrollBarDisplay: number; - static defaultScrollTouchEffect: boolean; - static defaultScrollBounceEffect: boolean; - static popupMenu: string; - static popupMenu_seperator: string; - static loaderErrorSign: string; - static tooltipsWin: string; - static defaultComboBoxVisibleItemCount: number; - static touchScrollSensitivity: number; - static touchDragSensitivity: number; - static clickDragSensitivity: number; - static bringWindowToFrontOnClick: boolean; - static frameTimeForAsyncUIConstruction: number; - } -} -declare module fgui { - class UIObjectFactory { - static extensions: { - [index: string]: new () => GComponent; - }; - static loaderType: new () => GLoader; - constructor(); - static setExtension(url: string, type: new () => GComponent): void; - static setPackageItemExtension(url: string, type: new () => GComponent): void; - static setLoaderExtension(type: new () => GLoader): void; - static resolvePackageItemExtension(pi: PackageItem): void; - static newObject(type: number | PackageItem, userClass?: new () => GObject): GObject; - } -} -declare module fgui { - class UIPackage { - private _id; - private _name; - private _items; - private _itemsById; - private _itemsByName; - private _resKey; - private _customId; - private _sprites; - private _dependencies; - private _branches; - _branchIndex: number; - static _constructing: number; - private static _instById; - private static _instByName; - private static _branch; - private static _vars; - constructor(); - static branch: string; - static getVar(key: string): string; - static setVar(key: string, value: string): void; - static getById(id: string): UIPackage; - static getByName(name: string): UIPackage; - static loadPackage(resKey: string): Promise; - static addPackage(resKey: string, descData?: ArrayBuffer): UIPackage; - static removePackage(packageIdOrName: string): void; - static createObject(pkgName: string, resName: string, userClass?: new () => GObject): GObject; - static createObjectFromURL(url: string, userClass?: new () => GObject): GObject; - static getItemURL(pkgName: string, resName: string): string; - static getItemByURL(url: string): PackageItem; - static normalizeURL(url: string): string; - static setStringsSource(source: string): void; - private loadPackage; - dispose(): void; - readonly id: string; - readonly name: string; - customId: string; - createObject(resName: string, userClass?: new () => GObject): GObject; - internalCreateObject(item: PackageItem, userClass?: new () => GObject): GObject; - getItemById(itemId: string): PackageItem; - getItemByName(resName: string): PackageItem; - getItemAssetByName(resName: string): Object; - getItemAsset(item: PackageItem): Object; - getItemAssetAsync(item: PackageItem, onComplete?: (err: any, item: PackageItem) => void): void; - private loadMovieClip; - private loadFont; - private loadDragonBones; - } -} -declare module fgui { - class Window extends GComponent { - private _contentPane; - private _modalWaitPane; - private _closeButton; - private _dragArea; - private _contentArea; - private _frame; - private _modal; - private _uiSources?; - private _inited?; - private _loading?; - protected _requestingCmd: number; - bringToFontOnClick: boolean; - constructor(); - addUISource(source: IUISource): void; - contentPane: GComponent; - readonly frame: GComponent; - closeButton: GObject; - dragArea: GObject; - contentArea: GObject; - show(): void; - showOn(root: GRoot): void; - hide(): void; - hideImmediately(): void; - centerOn(r: GRoot, restraint?: boolean): void; - toggleStatus(): void; - readonly isShowing: boolean; - readonly isTop: boolean; - modal: boolean; - bringToFront(): void; - showModalWait(requestingCmd?: number): void; - protected layoutModalWaitPane(): void; - closeModalWait(requestingCmd?: number): boolean; - readonly modalWaiting: boolean; - init(): void; - protected onInit(): void; - protected onShown(): void; - protected onHide(): void; - protected doShowAnimation(): void; - protected doHideAnimation(): void; - private __uiLoadComplete; - private _init; - dispose(): void; - protected closeEventHandler(evt: egret.Event): void; - private __onShown; - private __onHidden; - private __mouseDown; - private __dragStart; - } -} -declare module fgui { - class ControllerAction { - fromPage: string[]; - toPage: string[]; - static createAction(type: number): ControllerAction; - constructor(); - run(controller: Controller, prevPage: string, curPage: string): void; - protected enter(controller: Controller): void; - protected leave(controller: Controller): void; - setup(buffer: ByteBuffer): void; - } -} -declare module fgui { - class ChangePageAction extends ControllerAction { - objectId: string; - controllerName: string; - targetPage: string; - constructor(); - protected enter(controller: Controller): void; - setup(buffer: ByteBuffer): void; - } -} -declare module fgui { - class PlayTransitionAction extends ControllerAction { - transitionName: string; - playTimes: number; - delay: number; - stopOnExit: boolean; - private _currentTransition; - constructor(); - protected enter(controller: Controller): void; - protected leave(controller: Controller): void; - setup(buffer: ByteBuffer): void; - } -} -declare module fgui { - class BitmapFont { - id: string; - size: number; - ttf: boolean; - glyphs: { - [index: string]: BMGlyph; - }; - resizable: boolean; - tint: boolean; - constructor(); - } - interface BMGlyph { - x?: number; - y?: number; - width?: number; - height?: number; - advance?: number; - lineHeight?: number; - channel?: number; - texture?: egret.Texture; - } -} -declare namespace fgui { - function fillImage(w: number, h: number, method: number, origin: number, clockwise: boolean, amount: number): Array; -} -declare module fgui { - class Image extends egret.Bitmap { - private _fillMethod; - private _fillOrigin; - private _fillAmount; - private _fillClockwise?; - private _mask?; - private _maskDirtyFlag?; - private _color; - constructor(); - color: number; - $setX(value: number): boolean; - $setY(value: number): boolean; - fillMethod: FillMethod; - fillOrigin: number; - fillClockwise: boolean; - fillAmount: number; - private markChanged; - private doFill; - } -} -declare module fgui { - interface Frame { - addDelay?: number; - texture?: egret.Texture; - } - class MovieClip extends Image { - interval: number; - swing: boolean; - repeatDelay: number; - timeScale: number; - private _playing; - private _frameCount; - private _frames; - private _frame; - private _start; - private _end; - private _times; - private _endAt; - private _status; - private _callback; - private _callbackObj; - private _smoothing; - private _frameElapsed; - private _reversed; - private _repeatedCount; - constructor(); - frames: Array; - readonly frameCount: number; - frame: number; - playing: boolean; - smoothing: boolean; - rewind(): void; - syncStatus(anotherMc: MovieClip): void; - advance(timeInMiniseconds: number): void; - setPlaySettings(start?: number, end?: number, times?: number, endAt?: number, endCallback?: Function, callbackObj?: any): void; - private update; - private drawFrame; - private checkTimer; - $onAddToStage(stage: egret.Stage, nestLevel: number): void; - $onRemoveFromStage(): void; - } -} -declare module fgui { - class UIContainer extends egret.DisplayObjectContainer { - private _hitArea?; - private _cachedMatrix?; - private _cachedHitArea?; - private _opaque?; - constructor(); - cacheHitArea(value: boolean): void; - hitArea: PixelHitTest | egret.DisplayObject; - opaque: boolean; - $hitTest(stageX: number, stageY: number): egret.DisplayObject; - } -} -declare module fgui { - class DragEvent extends egret.Event { - stageX: number; - stageY: number; - touchPointID: number; - private _prevented; - static DRAG_START: string; - static DRAG_END: string; - static DRAG_MOVING: string; - constructor(type: string, stageX?: number, stageY?: number, touchPointID?: number); - preventDefault(): void; - isDefaultPrevented(): boolean; - } -} -declare module fgui { - class DropEvent extends egret.Event { - source: any; - static DROP: string; - constructor(type: string, source?: any); - } -} -declare module fgui { - class ItemEvent extends egret.Event { - itemObject: GObject; - stageX: number; - stageY: number; - static CLICK: string; - constructor(type: string, itemObject?: GObject, stageX?: number, stageY?: number); - } -} -declare module fgui { - class StateChangeEvent extends egret.Event { - static CHANGED: string; - constructor(type: string); - } -} -declare namespace fgui { - class GearBase { - static disableAllTweenEffect: boolean; - protected _owner: GObject; - protected _controller: Controller; - protected _tweenConfig?: GearTweenConfig; - static create(owner: GObject, index: number): GearBase; - constructor(owner: GObject); - dispose(): void; - controller: Controller; - readonly tweenConfig: GearTweenConfig; - setup(buffer: ByteBuffer): void; - updateFromRelations(dx: number, dy: number): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - protected init(): void; - apply(): void; - updateState(): void; - } - class GearTweenConfig { - tween: boolean; - easeType: number; - duration: number; - delay: number; - _displayLockToken: number; - _tweener: GTweener; - constructor(); - } -} -declare namespace fgui { - class GearAnimation extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - updateState(): void; - } -} -declare namespace fgui { - class GearColor extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - updateState(): void; - } -} -declare namespace fgui { - class GearDisplay extends GearBase { - pages: string[]; - private _visible; - private _displayLockToken; - constructor(owner: GObject); - protected init(): void; - apply(): void; - addLock(): number; - releaseLock(token: number): void; - readonly connected: boolean; - } -} -declare namespace fgui { - class GearDisplay2 extends GearBase { - pages: string[]; - condition: number; - private _visible; - constructor(owner: GObject); - protected init(): void; - apply(): void; - evaluate(connected: boolean): boolean; - } -} -declare namespace fgui { - class GearFontSize extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - updateState(): void; - } -} -declare namespace fgui { - class GearIcon extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - updateState(): void; - } -} -declare namespace fgui { - class GearLook extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - private __tweenUpdate; - private __tweenComplete; - updateState(): void; - } -} -declare namespace fgui { - class GearSize extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - private __tweenUpdate; - private __tweenComplete; - updateState(): void; - updateFromRelations(dx: number, dy: number): void; - } -} -declare namespace fgui { - class GearText extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - updateState(): void; - } -} -declare namespace fgui { - class GearXY extends GearBase { - positionsInPercent: boolean; - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - addExtStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - private __tweenUpdate; - private __tweenComplete; - updateState(): void; - updateFromRelations(dx: number, dy: number): void; - } -} -declare namespace fgui { - function evaluateEase(easeType: number, time: number, duration: number, overshootOrAmplitude: number, period: number): number; -} -declare namespace fgui { - class EaseType { - static Linear: number; - static SineIn: number; - static SineOut: number; - static SineInOut: number; - static QuadIn: number; - static QuadOut: number; - static QuadInOut: number; - static CubicIn: number; - static CubicOut: number; - static CubicInOut: number; - static QuartIn: number; - static QuartOut: number; - static QuartInOut: number; - static QuintIn: number; - static QuintOut: number; - static QuintInOut: number; - static ExpoIn: number; - static ExpoOut: number; - static ExpoInOut: number; - static CircIn: number; - static CircOut: number; - static CircInOut: number; - static ElasticIn: number; - static ElasticOut: number; - static ElasticInOut: number; - static BackIn: number; - static BackOut: number; - static BackInOut: number; - static BounceIn: number; - static BounceOut: number; - static BounceInOut: number; - static Custom: number; - } -} -declare namespace fgui { - class GPath { - private _segments; - private _points; - private _fullLength; - constructor(); - readonly length: number; - create(pt1: Array | GPathPoint, pt2?: GPathPoint, pt3?: GPathPoint, pt4?: GPathPoint): void; - private createSplineSegment; - clear(): void; - getPointAt(t: number, result?: egret.Point): egret.Point; - readonly segmentCount: number; - getAnchorsInSegment(segmentIndex: number, points?: Array): Array; - getPointsInSegment(segmentIndex: number, t0: number, t1: number, points?: Array, ts?: Array, pointDensity?: number): Array; - getAllPoints(points?: Array, ts?: Array, pointDensity?: number): Array; - private onCRSplineCurve; - private onBezierCurve; - } -} -declare namespace fgui { - enum CurveType { - CRSpline = 0, - Bezier = 1, - CubicBezier = 2, - Straight = 3 - } - class GPathPoint { - x: number; - y: number; - control1_x: number; - control1_y: number; - control2_x: number; - control2_y: number; - curveType: number; - constructor(); - static newPoint(x?: number, y?: number, curveType?: number): GPathPoint; - static newBezierPoint(x?: number, y?: number, control1_x?: number, control1_y?: number): GPathPoint; - static newCubicBezierPoint(x?: number, y?: number, control1_x?: number, control1_y?: number, control2_x?: number, control2_y?: number): GPathPoint; - clone(): GPathPoint; - } -} -declare namespace fgui { - class GTween { - static catchCallbackExceptions: boolean; - static to(start: number, end: number, duration: number): GTweener; - static to2(start: number, start2: number, end: number, end2: number, duration: number): GTweener; - static to3(start: number, start2: number, start3: number, end: number, end2: number, end3: number, duration: number): GTweener; - static to4(start: number, start2: number, start3: number, start4: number, end: number, end2: number, end3: number, end4: number, duration: number): GTweener; - static toColor(start: number, end: number, duration: number): GTweener; - static delayedCall(delay: number): GTweener; - static shake(startX: number, startY: number, amplitude: number, duration: number): GTweener; - static isTweening(target: any, propType?: any): Boolean; - static kill(target: any, complete?: boolean, propType?: any): void; - static getTween(target: any, propType?: any): GTweener; - } -} -declare module fgui { - class GTweener { - _target: any; - _propType: any; - _killed: boolean; - _paused: boolean; - private _delay; - private _duration; - private _breakpoint; - private _easeType; - private _easeOvershootOrAmplitude; - private _easePeriod; - private _repeat; - private _yoyo; - private _timeScale; - private _snapping; - private _userData; - private _path; - private _onUpdate; - private _onStart; - private _onComplete; - private _onUpdateCaller; - private _onStartCaller; - private _onCompleteCaller; - private _startValue; - private _endValue; - private _value; - private _deltaValue; - private _valueSize; - private _started; - private _ended; - private _elapsedTime; - private _normalizedTime; - constructor(); - setDelay(value: number): GTweener; - readonly delay: number; - setDuration(value: number): GTweener; - readonly duration: number; - setBreakpoint(value: number): GTweener; - setEase(value: number): GTweener; - setEasePeriod(value: number): GTweener; - setEaseOvershootOrAmplitude(value: number): GTweener; - setRepeat(repeat: number, yoyo?: boolean): GTweener; - readonly repeat: number; - setTimeScale(value: number): GTweener; - setSnapping(value: boolean): GTweener; - setTarget(value: any, propType?: any): GTweener; - readonly target: any; - setUserData(value: any): GTweener; - readonly userData: any; - setPath(value: GPath): GTweener; - onUpdate(callback: Function, caller?: any): GTweener; - onStart(callback: Function, caller?: any): GTweener; - onComplete(callback: Function, caller?: any): GTweener; - readonly startValue: TweenValue; - readonly endValue: TweenValue; - readonly value: TweenValue; - readonly deltaValue: TweenValue; - readonly normalizedTime: number; - readonly completed: boolean; - readonly allCompleted: boolean; - setPaused(paused: boolean): GTweener; - seek(time: number): void; - kill(complete?: boolean): void; - _to(start: number, end: number, duration: number): GTweener; - _to2(start: number, start2: number, end: number, end2: number, duration: number): GTweener; - _to3(start: number, start2: number, start3: number, end: number, end2: number, end3: number, duration: number): GTweener; - _to4(start: number, start2: number, start3: number, start4: number, end: number, end2: number, end3: number, end4: number, duration: number): GTweener; - _toColor(start: number, end: number, duration: number): GTweener; - _shake(startX: number, startY: number, amplitude: number, duration: number): GTweener; - _init(): void; - _reset(): void; - _update(dt: number): void; - private update; - private callStartCallback; - private callUpdateCallback; - private callCompleteCallback; - } -} -declare module fgui { - class TweenManager { - static createTween(): GTweener; - static isTweening(target: any, propType?: any): boolean; - static killTweens(target: any, completed?: boolean, propType?: any): boolean; - static getTween(target: any, propType?: any): GTweener; - private static update; - } -} -declare namespace fgui { - class TweenValue { - x: number; - y: number; - z: number; - w: number; - constructor(); - color: number; - getField(index: number): number; - setField(index: number, value: number): void; - setZero(): void; - } -} -declare module fgui { - class ByteBuffer extends egret.ByteArray { - stringTable?: Array; - version: number; - constructor(buffer?: ArrayBuffer | Uint8Array, bufferExtSize?: number); - skip(count: number): void; - readBool(): boolean; - readS(): string; - readSArray(cnt: number): Array; - writeS(value: string): void; - readColor(hasAlpha?: boolean): number; - readChar(): string; - readBuffer(): ByteBuffer; - seek(indexTablePos: number, blockIndex: number): boolean; - } -} -declare namespace fgui { - class ColorMatrix { - readonly matrix: Array; - constructor(p_brightness?: number, p_contrast?: number, p_saturation?: number, p_hue?: number); - reset(): void; - invert(): void; - adjustColor(p_brightness: number, p_contrast: number, p_saturation: number, p_hue: number): void; - adjustBrightness(p_val: number): void; - adjustContrast(p_val: number): void; - adjustSaturation(p_val: number): void; - adjustHue(p_val: number): void; - concat(p_matrix: Array): void; - clone(): ColorMatrix; - protected copyMatrix(p_matrix: Array): void; - protected multiplyMatrix(p_matrix: Array): void; - protected cleanValue(p_val: number, p_limit: number): number; - } -} -declare module fgui { - class GTimers { - private _items; - private _itemPool; - private _enumI; - private _enumCount; - private _lastTime; - static deltaTime: number; - static time: number; - static readonly inst: GTimers; - constructor(); - private getItem; - private findItem; - add(delayInMiniseconds: number, repeat: number, callback: Function, thisObj?: any, callbackParam?: any): void; - callLater(callback: Function, thisObj?: any, callbackParam?: any): void; - callDelay(delay: number, callback: Function, thisObj?: any, callbackParam?: any): void; - exists(callback: Function, thisObj?: any): boolean; - remove(callback: Function, thisObj?: any): void; - private __timer; - } -} -declare module fgui { - class UBBParser { - private _text; - private _readPos; - protected _handlers: { - [index: string]: (tagName: string, end: boolean, attr: string) => string; - }; - smallFontSize: number; - normalFontSize: number; - largeFontSize: number; - defaultImgWidth: number; - defaultImgHeight: number; - static inst: UBBParser; - constructor(); - protected onTag_URL(tagName: string, end: boolean, attr: string): string; - protected onTag_IMG(tagName: string, end: boolean, attr: string): string; - protected onTag_Simple(tagName: string, end: boolean, attr: string): string; - protected onTag_COLOR(tagName: string, end: boolean, attr: string): string; - protected onTag_FONT(tagName: string, end: boolean, attr: string): string; - protected onTag_SIZE(tagName: string, end: boolean, attr: string): string; - protected getTagText(remove?: boolean): string; - parse(text: string, remove?: boolean): string; - } -} -declare module fgui { - class ToolSet { - static startsWith(source: string, str: string, ignoreCase?: boolean): boolean; - static trimRight(targetString: string): string; - static convertToHtmlColor(argb: number, hasAlpha?: boolean): string; - static convertFromHtmlColor(str: string, hasAlpha?: boolean): number; - static displayObjectToGObject(obj: egret.DisplayObject): GObject; - static encodeHTML(str: string): string; - static clamp(value: number, min: number, max: number): number; - static clamp01(value: number): number; - static lerp(start: number, end: number, percent: number): number; - static repeat(t: number, length: number): number; - static distance(x1: number, y1: number, x2: number, y2: number): number; - static fillPath(ctx: egret.Graphics, points: number[], px: number, py: number): void; - static setColorFilter(obj: egret.DisplayObject, color?: number | number[] | boolean): void; - } -} -import fairygui = fgui; \ No newline at end of file diff --git a/demo/libs/fairygui/fairygui.js b/demo/libs/fairygui/fairygui.js deleted file mode 100644 index 49b99782..00000000 --- a/demo/libs/fairygui/fairygui.js +++ /dev/null @@ -1,19026 +0,0 @@ -window.fgui = {}; -window.fairygui = window.fgui; -window.__extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; - -(function (fgui) { - var AsyncOperation = (function () { - function AsyncOperation() { - this._itemList = new Array(); - this._objectPool = new Array(); - } - AsyncOperation.prototype.createObject = function (pkgName, resName) { - var pkg = fgui.UIPackage.getByName(pkgName); - if (pkg) { - var pi = pkg.getItemByName(resName); - if (!pi) - throw new Error("resource not found: " + resName); - this.internalCreateObject(pi); - } - else - throw new Error("package not found: " + pkgName); - }; - AsyncOperation.prototype.createObjectFromURL = function (url) { - var pi = fgui.UIPackage.getItemByURL(url); - if (pi) - this.internalCreateObject(pi); - else - throw new Error("resource not found: " + url); - }; - AsyncOperation.prototype.cancel = function () { - fgui.GTimers.inst.remove(this.run, this); - this._itemList.length = 0; - var cnt = this._objectPool.length; - if (cnt > 0) { - for (var i = 0; i < cnt; i++) - this._objectPool[i].dispose(); - this._objectPool.length = 0; - } - }; - AsyncOperation.prototype.internalCreateObject = function (item) { - this._itemList.length = 0; - this._objectPool.length = 0; - var di = { pi: item, type: item.objectType }; - di.childCount = this.collectComponentChildren(item); - this._itemList.push(di); - this._index = 0; - fgui.GTimers.inst.add(1, 0, this.run, this); - }; - AsyncOperation.prototype.collectComponentChildren = function (item) { - var buffer = item.rawData; - buffer.seek(0, 2); - var di; - var pi; - var i; - var dataLen; - var curPos; - var pkg; - var dcnt = buffer.readShort(); - for (i = 0; i < dcnt; i++) { - dataLen = buffer.readShort(); - curPos = buffer.position; - buffer.seek(curPos, 0); - var type = buffer.readByte(); - var src = buffer.readS(); - var pkgId = buffer.readS(); - buffer.position = curPos; - if (src != null) { - if (pkgId != null) - pkg = fgui.UIPackage.getById(pkgId); - else - pkg = item.owner; - pi = pkg != null ? pkg.getItemById(src) : null; - di = { pi: pi, type: type }; - if (pi != null && pi.type == fgui.PackageItemType.Component) - di.childCount = this.collectComponentChildren(pi); - } - else { - di = { type: type }; - if (type == fgui.ObjectType.List) - di.listItemCount = this.collectListChildren(buffer); - } - this._itemList.push(di); - buffer.position = curPos + dataLen; - } - return dcnt; - }; - AsyncOperation.prototype.collectListChildren = function (buffer) { - buffer.seek(buffer.position, 8); - var listItemCount = 0; - var i; - var nextPos; - var url; - var pi; - var di; - var defaultItem = buffer.readS(); - var itemCount = buffer.readShort(); - for (i = 0; i < itemCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - url = buffer.readS(); - if (url == null) - url = defaultItem; - if (url) { - pi = fgui.UIPackage.getItemByURL(url); - if (pi) { - di = { pi: pi, type: pi.objectType }; - if (pi.type == fgui.PackageItemType.Component) - di.childCount = this.collectComponentChildren(pi); - this._itemList.push(di); - listItemCount++; - } - } - buffer.position = nextPos; - } - return listItemCount; - }; - AsyncOperation.prototype.run = function () { - var obj; - var di; - var poolStart; - var k; - var t = egret.getTimer(); - var frameTime = fgui.UIConfig.frameTimeForAsyncUIConstruction; - var totalItems = this._itemList.length; - while (this._index < totalItems) { - di = this._itemList[this._index]; - if (di.pi) { - obj = fgui.UIObjectFactory.newObject(di.pi); - this._objectPool.push(obj); - fgui.UIPackage._constructing++; - if (di.pi.type == fgui.PackageItemType.Component) { - poolStart = this._objectPool.length - di.childCount - 1; - obj.constructFromResource2(this._objectPool, poolStart); - this._objectPool.splice(poolStart, di.childCount); - } - else { - obj.constructFromResource(); - } - fgui.UIPackage._constructing--; - } - else { - obj = fgui.UIObjectFactory.newObject(di.type); - this._objectPool.push(obj); - if (di.type == fgui.ObjectType.List && di.listItemCount > 0) { - poolStart = this._objectPool.length - di.listItemCount - 1; - for (k = 0; k < di.listItemCount; k++) - obj.itemPool.returnObject(this._objectPool[k + poolStart]); - this._objectPool.splice(poolStart, di.listItemCount); - } - } - this._index++; - if ((this._index % 5 == 0) && egret.getTimer() - t >= frameTime) - return; - } - fgui.GTimers.inst.remove(this.run, this); - var result = this._objectPool[0]; - this._itemList.length = 0; - this._objectPool.length = 0; - if (this.callback != null) - this.callback.call(this.callbackObj, result); - }; - return AsyncOperation; - }()); - fgui.AsyncOperation = AsyncOperation; -})(fgui || (fgui = {})); - -(function (fgui) { - var _nextPageId = 0; - var Controller = (function (_super_1) { - __extends(Controller, _super_1); - function Controller() { - var _this = _super_1.call(this) || this; - _this._pageIds = []; - _this._pageNames = []; - _this._selectedIndex = -1; - _this._previousIndex = -1; - return _this; - } - Controller.prototype.dispose = function () { - }; - Object.defineProperty(Controller.prototype, "selectedIndex", { - get: function () { - return this._selectedIndex; - }, - set: function (value) { - if (this._selectedIndex != value) { - if (value > this._pageIds.length - 1) - throw "index out of bounds: " + value; - this.changing = true; - this._previousIndex = this._selectedIndex; - this._selectedIndex = value; - this.parent.applyController(this); - this.dispatchEvent(new fgui.StateChangeEvent(fgui.StateChangeEvent.CHANGED)); - this.changing = false; - } - }, - enumerable: true, - configurable: true - }); - Controller.prototype.setSelectedIndex = function (value) { - if (this._selectedIndex != value) { - if (value > this._pageIds.length - 1) - throw "index out of bounds: " + value; - this.changing = true; - this._previousIndex = this._selectedIndex; - this._selectedIndex = value; - this.parent.applyController(this); - this.changing = false; - } - }; - Object.defineProperty(Controller.prototype, "previsousIndex", { - get: function () { - return this._previousIndex; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Controller.prototype, "selectedPage", { - get: function () { - if (this._selectedIndex == -1) - return null; - else - return this._pageNames[this._selectedIndex]; - }, - set: function (val) { - var i = this._pageNames.indexOf(val); - if (i == -1) - i = 0; - this.selectedIndex = i; - }, - enumerable: true, - configurable: true - }); - Controller.prototype.setSelectedPage = function (value) { - var i = this._pageNames.indexOf(value); - if (i == -1) - i = 0; - this.setSelectedIndex(i); - }; - Object.defineProperty(Controller.prototype, "previousPage", { - get: function () { - if (this._previousIndex == -1) - return null; - else - return this._pageNames[this._previousIndex]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Controller.prototype, "pageCount", { - get: function () { - return this._pageIds.length; - }, - enumerable: true, - configurable: true - }); - Controller.prototype.getPageName = function (index) { - return this._pageNames[index]; - }; - Controller.prototype.addPage = function (name) { - this.addPageAt(name || "", this._pageIds.length); - }; - Controller.prototype.addPageAt = function (name, index) { - var nid = "" + (_nextPageId++); - if (index == this._pageIds.length) { - this._pageIds.push(nid); - this._pageNames.push(name); - } - else { - this._pageIds.splice(index, 0, nid); - this._pageNames.splice(index, 0, name); - } - }; - Controller.prototype.removePage = function (name) { - var i = this._pageNames.indexOf(name); - if (i != -1) { - this._pageIds.splice(i, 1); - this._pageNames.splice(i, 1); - if (this._selectedIndex >= this._pageIds.length) - this.selectedIndex = this._selectedIndex - 1; - else - this.parent.applyController(this); - } - }; - Controller.prototype.removePageAt = function (index) { - if (index === void 0) { index = 0; } - this._pageIds.splice(index, 1); - this._pageNames.splice(index, 1); - if (this._selectedIndex >= this._pageIds.length) - this.selectedIndex = this._selectedIndex - 1; - else - this.parent.applyController(this); - }; - Controller.prototype.clearPages = function () { - this._pageIds.length = 0; - this._pageNames.length = 0; - if (this._selectedIndex != -1) - this.selectedIndex = -1; - else - this.parent.applyController(this); - }; - Controller.prototype.hasPage = function (aName) { - return this._pageNames.indexOf(aName) != -1; - }; - Controller.prototype.getPageIndexById = function (aId) { - return this._pageIds.indexOf(aId); - }; - Controller.prototype.getPageIdByName = function (aName) { - var i = this._pageNames.indexOf(aName); - if (i != -1) - return this._pageIds[i]; - else - return null; - }; - Controller.prototype.getPageNameById = function (aId) { - var i = this._pageIds.indexOf(aId); - if (i != -1) - return this._pageNames[i]; - else - return null; - }; - Controller.prototype.getPageId = function (index) { - if (index === void 0) { index = 0; } - return this._pageIds[index]; - }; - Object.defineProperty(Controller.prototype, "selectedPageId", { - get: function () { - if (this._selectedIndex == -1) - return null; - else - return this._pageIds[this._selectedIndex]; - }, - set: function (val) { - var i = this._pageIds.indexOf(val); - this.selectedIndex = i; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Controller.prototype, "oppositePageId", { - set: function (val) { - var i = this._pageIds.indexOf(val); - if (i > 0) - this.selectedIndex = 0; - else if (this._pageIds.length > 1) - this.selectedIndex = 1; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Controller.prototype, "previousPageId", { - get: function () { - if (this._previousIndex == -1) - return null; - else - return this._pageIds[this._previousIndex]; - }, - enumerable: true, - configurable: true - }); - Controller.prototype.runActions = function () { - if (this._actions) { - var cnt = this._actions.length; - for (var i = 0; i < cnt; i++) - this._actions[i].run(this, this.previousPageId, this.selectedPageId); - } - }; - Controller.prototype.setup = function (buffer) { - var beginPos = buffer.position; - buffer.seek(beginPos, 0); - this.name = buffer.readS(); - if (buffer.readBool()) - this.autoRadioGroupDepth = true; - buffer.seek(beginPos, 1); - var i; - var nextPos; - var cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - this._pageIds.push(buffer.readS()); - this._pageNames.push(buffer.readS()); - } - var homePageIndex = 0; - if (buffer.version >= 2) { - var homePageType = buffer.readByte(); - switch (homePageType) { - case 1: - homePageIndex = buffer.readShort(); - break; - case 2: - homePageIndex = this._pageNames.indexOf(fgui.UIPackage.branch); - if (homePageIndex == -1) - homePageIndex = 0; - break; - case 3: - homePageIndex = this._pageNames.indexOf(fgui.UIPackage.getVar(buffer.readS())); - if (homePageIndex == -1) - homePageIndex = 0; - break; - } - } - buffer.seek(beginPos, 2); - cnt = buffer.readShort(); - if (cnt > 0) { - if (!this._actions) - this._actions = new Array(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - var action = fgui.ControllerAction.createAction(buffer.readByte()); - action.setup(buffer); - this._actions.push(action); - buffer.position = nextPos; - } - } - if (this.parent && this._pageIds.length > 0) - this._selectedIndex = homePageIndex; - else - this._selectedIndex = -1; - }; - return Controller; - }(egret.EventDispatcher)); - fgui.Controller = Controller; -})(fgui || (fgui = {})); - -(function (fgui) { - var DragDropManager = (function () { - function DragDropManager() { - this._agent = new fgui.GLoader(); - this._agent.draggable = true; - this._agent.touchable = false; - this._agent.setSize(100, 100); - this._agent.setPivot(0.5, 0.5, true); - this._agent.align = fgui.AlignType.Center; - this._agent.verticalAlign = fgui.VertAlignType.Middle; - this._agent.sortingOrder = 1000000; - this._agent.addEventListener(fgui.DragEvent.DRAG_END, this.__dragEnd, this); - } - Object.defineProperty(DragDropManager, "inst", { - get: function () { - if (DragDropManager._inst == null) - DragDropManager._inst = new DragDropManager(); - return DragDropManager._inst; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DragDropManager.prototype, "dragAgent", { - get: function () { - return this._agent; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DragDropManager.prototype, "dragging", { - get: function () { - return this._agent.parent != null; - }, - enumerable: true, - configurable: true - }); - DragDropManager.prototype.startDrag = function (source, icon, sourceData, touchPointID) { - if (this._agent.parent) - return; - this._sourceData = sourceData; - this._agent.url = icon; - fgui.GRoot.inst.addChild(this._agent); - var pt = fgui.GRoot.inst.globalToLocal(fgui.GRoot.mouseX, fgui.GRoot.mouseY); - this._agent.setXY(pt.x, pt.y); - this._agent.startDrag(touchPointID); - }; - DragDropManager.prototype.cancel = function () { - if (this._agent.parent) { - this._agent.stopDrag(); - fgui.GRoot.inst.removeChild(this._agent); - this._sourceData = null; - } - }; - DragDropManager.prototype.__dragEnd = function (evt) { - if (this._agent.parent == null) - return; - fgui.GRoot.inst.removeChild(this._agent); - var sourceData = this._sourceData; - this._sourceData = null; - var obj = fgui.GRoot.inst.getObjectUnderPoint(evt.stageX, evt.stageY); - while (obj) { - if (obj.hasEventListener(fgui.DropEvent.DROP)) { - var dropEvt = new fgui.DropEvent(fgui.DropEvent.DROP, sourceData); - obj.requestFocus(); - obj.dispatchEvent(dropEvt); - return; - } - obj = obj.parent; - } - }; - return DragDropManager; - }()); - fgui.DragDropManager = DragDropManager; -})(fgui || (fgui = {})); - -(function (fgui) { - var ButtonMode; - (function (ButtonMode) { - ButtonMode[ButtonMode["Common"] = 0] = "Common"; - ButtonMode[ButtonMode["Check"] = 1] = "Check"; - ButtonMode[ButtonMode["Radio"] = 2] = "Radio"; - })(ButtonMode = fgui.ButtonMode || (fgui.ButtonMode = {})); - var AutoSizeType; - (function (AutoSizeType) { - AutoSizeType[AutoSizeType["None"] = 0] = "None"; - AutoSizeType[AutoSizeType["Both"] = 1] = "Both"; - AutoSizeType[AutoSizeType["Height"] = 2] = "Height"; - })(AutoSizeType = fgui.AutoSizeType || (fgui.AutoSizeType = {})); - var AlignType; - (function (AlignType) { - AlignType[AlignType["Left"] = 0] = "Left"; - AlignType[AlignType["Center"] = 1] = "Center"; - AlignType[AlignType["Right"] = 2] = "Right"; - })(AlignType = fgui.AlignType || (fgui.AlignType = {})); - var VertAlignType; - (function (VertAlignType) { - VertAlignType[VertAlignType["Top"] = 0] = "Top"; - VertAlignType[VertAlignType["Middle"] = 1] = "Middle"; - VertAlignType[VertAlignType["Bottom"] = 2] = "Bottom"; - })(VertAlignType = fgui.VertAlignType || (fgui.VertAlignType = {})); - var LoaderFillType; - (function (LoaderFillType) { - LoaderFillType[LoaderFillType["None"] = 0] = "None"; - LoaderFillType[LoaderFillType["Scale"] = 1] = "Scale"; - LoaderFillType[LoaderFillType["ScaleMatchHeight"] = 2] = "ScaleMatchHeight"; - LoaderFillType[LoaderFillType["ScaleMatchWidth"] = 3] = "ScaleMatchWidth"; - LoaderFillType[LoaderFillType["ScaleFree"] = 4] = "ScaleFree"; - LoaderFillType[LoaderFillType["ScaleNoBorder"] = 5] = "ScaleNoBorder"; - })(LoaderFillType = fgui.LoaderFillType || (fgui.LoaderFillType = {})); - var ListLayoutType; - (function (ListLayoutType) { - ListLayoutType[ListLayoutType["SingleColumn"] = 0] = "SingleColumn"; - ListLayoutType[ListLayoutType["SingleRow"] = 1] = "SingleRow"; - ListLayoutType[ListLayoutType["FlowHorizontal"] = 2] = "FlowHorizontal"; - ListLayoutType[ListLayoutType["FlowVertical"] = 3] = "FlowVertical"; - ListLayoutType[ListLayoutType["Pagination"] = 4] = "Pagination"; - })(ListLayoutType = fgui.ListLayoutType || (fgui.ListLayoutType = {})); - var ListSelectionMode; - (function (ListSelectionMode) { - ListSelectionMode[ListSelectionMode["Single"] = 0] = "Single"; - ListSelectionMode[ListSelectionMode["Multiple"] = 1] = "Multiple"; - ListSelectionMode[ListSelectionMode["Multiple_SingleClick"] = 2] = "Multiple_SingleClick"; - ListSelectionMode[ListSelectionMode["None"] = 3] = "None"; - })(ListSelectionMode = fgui.ListSelectionMode || (fgui.ListSelectionMode = {})); - var OverflowType; - (function (OverflowType) { - OverflowType[OverflowType["Visible"] = 0] = "Visible"; - OverflowType[OverflowType["Hidden"] = 1] = "Hidden"; - OverflowType[OverflowType["Scroll"] = 2] = "Scroll"; - })(OverflowType = fgui.OverflowType || (fgui.OverflowType = {})); - var PackageItemType; - (function (PackageItemType) { - PackageItemType[PackageItemType["Image"] = 0] = "Image"; - PackageItemType[PackageItemType["MovieClip"] = 1] = "MovieClip"; - PackageItemType[PackageItemType["Sound"] = 2] = "Sound"; - PackageItemType[PackageItemType["Component"] = 3] = "Component"; - PackageItemType[PackageItemType["Atlas"] = 4] = "Atlas"; - PackageItemType[PackageItemType["Font"] = 5] = "Font"; - PackageItemType[PackageItemType["Swf"] = 6] = "Swf"; - PackageItemType[PackageItemType["Misc"] = 7] = "Misc"; - PackageItemType[PackageItemType["Unknown"] = 8] = "Unknown"; - PackageItemType[PackageItemType["Spine"] = 9] = "Spine"; - PackageItemType[PackageItemType["DragonBones"] = 10] = "DragonBones"; - })(PackageItemType = fgui.PackageItemType || (fgui.PackageItemType = {})); - ; - var ObjectType; - (function (ObjectType) { - ObjectType[ObjectType["Image"] = 0] = "Image"; - ObjectType[ObjectType["MovieClip"] = 1] = "MovieClip"; - ObjectType[ObjectType["Swf"] = 2] = "Swf"; - ObjectType[ObjectType["Graph"] = 3] = "Graph"; - ObjectType[ObjectType["Loader"] = 4] = "Loader"; - ObjectType[ObjectType["Group"] = 5] = "Group"; - ObjectType[ObjectType["Text"] = 6] = "Text"; - ObjectType[ObjectType["RichText"] = 7] = "RichText"; - ObjectType[ObjectType["InputText"] = 8] = "InputText"; - ObjectType[ObjectType["Component"] = 9] = "Component"; - ObjectType[ObjectType["List"] = 10] = "List"; - ObjectType[ObjectType["Label"] = 11] = "Label"; - ObjectType[ObjectType["Button"] = 12] = "Button"; - ObjectType[ObjectType["ComboBox"] = 13] = "ComboBox"; - ObjectType[ObjectType["ProgressBar"] = 14] = "ProgressBar"; - ObjectType[ObjectType["Slider"] = 15] = "Slider"; - ObjectType[ObjectType["ScrollBar"] = 16] = "ScrollBar"; - ObjectType[ObjectType["Tree"] = 17] = "Tree"; - ObjectType[ObjectType["Loader3D"] = 18] = "Loader3D"; - })(ObjectType = fgui.ObjectType || (fgui.ObjectType = {})); - var ProgressTitleType; - (function (ProgressTitleType) { - ProgressTitleType[ProgressTitleType["Percent"] = 0] = "Percent"; - ProgressTitleType[ProgressTitleType["ValueAndMax"] = 1] = "ValueAndMax"; - ProgressTitleType[ProgressTitleType["Value"] = 2] = "Value"; - ProgressTitleType[ProgressTitleType["Max"] = 3] = "Max"; - })(ProgressTitleType = fgui.ProgressTitleType || (fgui.ProgressTitleType = {})); - var ScrollBarDisplayType; - (function (ScrollBarDisplayType) { - ScrollBarDisplayType[ScrollBarDisplayType["Default"] = 0] = "Default"; - ScrollBarDisplayType[ScrollBarDisplayType["Visible"] = 1] = "Visible"; - ScrollBarDisplayType[ScrollBarDisplayType["Auto"] = 2] = "Auto"; - ScrollBarDisplayType[ScrollBarDisplayType["Hidden"] = 3] = "Hidden"; - })(ScrollBarDisplayType = fgui.ScrollBarDisplayType || (fgui.ScrollBarDisplayType = {})); - ; - var ScrollType; - (function (ScrollType) { - ScrollType[ScrollType["Horizontal"] = 0] = "Horizontal"; - ScrollType[ScrollType["Vertical"] = 1] = "Vertical"; - ScrollType[ScrollType["Both"] = 2] = "Both"; - })(ScrollType = fgui.ScrollType || (fgui.ScrollType = {})); - ; - var FlipType; - (function (FlipType) { - FlipType[FlipType["None"] = 0] = "None"; - FlipType[FlipType["Horizontal"] = 1] = "Horizontal"; - FlipType[FlipType["Vertical"] = 2] = "Vertical"; - FlipType[FlipType["Both"] = 3] = "Both"; - })(FlipType = fgui.FlipType || (fgui.FlipType = {})); - var ChildrenRenderOrder; - (function (ChildrenRenderOrder) { - ChildrenRenderOrder[ChildrenRenderOrder["Ascent"] = 0] = "Ascent"; - ChildrenRenderOrder[ChildrenRenderOrder["Descent"] = 1] = "Descent"; - ChildrenRenderOrder[ChildrenRenderOrder["Arch"] = 2] = "Arch"; - })(ChildrenRenderOrder = fgui.ChildrenRenderOrder || (fgui.ChildrenRenderOrder = {})); - var GroupLayoutType; - (function (GroupLayoutType) { - GroupLayoutType[GroupLayoutType["None"] = 0] = "None"; - GroupLayoutType[GroupLayoutType["Horizontal"] = 1] = "Horizontal"; - GroupLayoutType[GroupLayoutType["Vertical"] = 2] = "Vertical"; - })(GroupLayoutType = fgui.GroupLayoutType || (fgui.GroupLayoutType = {})); - var PopupDirection; - (function (PopupDirection) { - PopupDirection[PopupDirection["Auto"] = 0] = "Auto"; - PopupDirection[PopupDirection["Up"] = 1] = "Up"; - PopupDirection[PopupDirection["Down"] = 2] = "Down"; - })(PopupDirection = fgui.PopupDirection || (fgui.PopupDirection = {})); - var RelationType; - (function (RelationType) { - RelationType[RelationType["Left_Left"] = 0] = "Left_Left"; - RelationType[RelationType["Left_Center"] = 1] = "Left_Center"; - RelationType[RelationType["Left_Right"] = 2] = "Left_Right"; - RelationType[RelationType["Center_Center"] = 3] = "Center_Center"; - RelationType[RelationType["Right_Left"] = 4] = "Right_Left"; - RelationType[RelationType["Right_Center"] = 5] = "Right_Center"; - RelationType[RelationType["Right_Right"] = 6] = "Right_Right"; - RelationType[RelationType["Top_Top"] = 7] = "Top_Top"; - RelationType[RelationType["Top_Middle"] = 8] = "Top_Middle"; - RelationType[RelationType["Top_Bottom"] = 9] = "Top_Bottom"; - RelationType[RelationType["Middle_Middle"] = 10] = "Middle_Middle"; - RelationType[RelationType["Bottom_Top"] = 11] = "Bottom_Top"; - RelationType[RelationType["Bottom_Middle"] = 12] = "Bottom_Middle"; - RelationType[RelationType["Bottom_Bottom"] = 13] = "Bottom_Bottom"; - RelationType[RelationType["Width"] = 14] = "Width"; - RelationType[RelationType["Height"] = 15] = "Height"; - RelationType[RelationType["LeftExt_Left"] = 16] = "LeftExt_Left"; - RelationType[RelationType["LeftExt_Right"] = 17] = "LeftExt_Right"; - RelationType[RelationType["RightExt_Left"] = 18] = "RightExt_Left"; - RelationType[RelationType["RightExt_Right"] = 19] = "RightExt_Right"; - RelationType[RelationType["TopExt_Top"] = 20] = "TopExt_Top"; - RelationType[RelationType["TopExt_Bottom"] = 21] = "TopExt_Bottom"; - RelationType[RelationType["BottomExt_Top"] = 22] = "BottomExt_Top"; - RelationType[RelationType["BottomExt_Bottom"] = 23] = "BottomExt_Bottom"; - RelationType[RelationType["Size"] = 24] = "Size"; - })(RelationType = fgui.RelationType || (fgui.RelationType = {})); - var FillMethod; - (function (FillMethod) { - FillMethod[FillMethod["None"] = 0] = "None"; - FillMethod[FillMethod["Horizontal"] = 1] = "Horizontal"; - FillMethod[FillMethod["Vertical"] = 2] = "Vertical"; - FillMethod[FillMethod["Radial90"] = 3] = "Radial90"; - FillMethod[FillMethod["Radial180"] = 4] = "Radial180"; - FillMethod[FillMethod["Radial360"] = 5] = "Radial360"; - })(FillMethod = fgui.FillMethod || (fgui.FillMethod = {})); - var FillOrigin; - (function (FillOrigin) { - FillOrigin[FillOrigin["Top"] = 0] = "Top"; - FillOrigin[FillOrigin["Bottom"] = 1] = "Bottom"; - FillOrigin[FillOrigin["Left"] = 2] = "Left"; - FillOrigin[FillOrigin["Right"] = 3] = "Right"; - FillOrigin[FillOrigin["TopLeft"] = 0] = "TopLeft"; - FillOrigin[FillOrigin["TopRight"] = 1] = "TopRight"; - FillOrigin[FillOrigin["BottomLeft"] = 2] = "BottomLeft"; - FillOrigin[FillOrigin["BottomRight"] = 3] = "BottomRight"; - })(FillOrigin = fgui.FillOrigin || (fgui.FillOrigin = {})); - var FillOrigin90; - (function (FillOrigin90) { - FillOrigin90[FillOrigin90["TopLeft"] = 0] = "TopLeft"; - FillOrigin90[FillOrigin90["TopRight"] = 1] = "TopRight"; - FillOrigin90[FillOrigin90["BottomLeft"] = 2] = "BottomLeft"; - FillOrigin90[FillOrigin90["BottomRight"] = 3] = "BottomRight"; - })(FillOrigin90 = fgui.FillOrigin90 || (fgui.FillOrigin90 = {})); - var ObjectPropID; - (function (ObjectPropID) { - ObjectPropID[ObjectPropID["Text"] = 0] = "Text"; - ObjectPropID[ObjectPropID["Icon"] = 1] = "Icon"; - ObjectPropID[ObjectPropID["Color"] = 2] = "Color"; - ObjectPropID[ObjectPropID["OutlineColor"] = 3] = "OutlineColor"; - ObjectPropID[ObjectPropID["Playing"] = 4] = "Playing"; - ObjectPropID[ObjectPropID["Frame"] = 5] = "Frame"; - ObjectPropID[ObjectPropID["DeltaTime"] = 6] = "DeltaTime"; - ObjectPropID[ObjectPropID["TimeScale"] = 7] = "TimeScale"; - ObjectPropID[ObjectPropID["FontSize"] = 8] = "FontSize"; - ObjectPropID[ObjectPropID["Selected"] = 9] = "Selected"; - })(ObjectPropID = fgui.ObjectPropID || (fgui.ObjectPropID = {})); -})(fgui || (fgui = {})); - -(function (fgui) { - var GObject = (function (_super_1) { - __extends(GObject, _super_1); - function GObject() { - var _this = _super_1.call(this) || this; - _this._x = 0; - _this._y = 0; - _this._alpha = 1; - _this._rotation = 0; - _this._visible = true; - _this._touchable = true; - _this._scaleX = 1; - _this._scaleY = 1; - _this._skewX = 0; - _this._skewY = 0; - _this._pivotX = 0; - _this._pivotY = 0; - _this._pivotOffsetX = 0; - _this._pivotOffsetY = 0; - _this._sortingOrder = 0; - _this._internalVisible = true; - _this._disposed = false; - _this.sourceWidth = 0; - _this.sourceHeight = 0; - _this.initWidth = 0; - _this.initHeight = 0; - _this.minWidth = 0; - _this.minHeight = 0; - _this.maxWidth = 0; - _this.maxHeight = 0; - _this._width = 0; - _this._height = 0; - _this._rawWidth = 0; - _this._rawHeight = 0; - _this._sizePercentInGroup = 0; - _this._id = "" + _gInstanceCounter++; - _this._name = ""; - _this.createDisplayObject(); - _this._relations = new fgui.Relations(_this); - _this._gears = new Array(10); - return _this; - } - Object.defineProperty(GObject.prototype, "id", { - get: function () { - return this._id; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "name", { - get: function () { - return this._name; - }, - set: function (value) { - this._name = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "x", { - get: function () { - return this._x; - }, - set: function (value) { - this.setXY(value, this._y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "y", { - get: function () { - return this._y; - }, - set: function (value) { - this.setXY(this._x, value); - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setXY = function (xv, yv) { - if (this._x != xv || this._y != yv) { - var dx = xv - this._x; - var dy = yv - this._y; - this._x = xv; - this._y = yv; - this.handleXYChanged(); - if (this instanceof fgui.GGroup) - this.moveChildren(dx, dy); - this.updateGear(1); - if (this._parent && !(this._parent instanceof fgui.GList)) { - this._parent.setBoundsChangedFlag(); - if (this._group) - this._group.setBoundsChangedFlag(true); - this.dispatchEventWith(GObject.XY_CHANGED); - } - if (GObject.draggingObject == this && !sUpdateInDragging) - this.localToGlobalRect(0, 0, this._width, this._height, sGlobalRect); - } - }; - Object.defineProperty(GObject.prototype, "xMin", { - get: function () { - return this._pivotAsAnchor ? (this._x - this._width * this._pivotX) : this._x; - }, - set: function (value) { - if (this._pivotAsAnchor) - this.setXY(value + this._width * this._pivotX, this._y); - else - this.setXY(value, this._y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "yMin", { - get: function () { - return this._pivotAsAnchor ? (this._y - this._height * this._pivotY) : this._y; - }, - set: function (value) { - if (this._pivotAsAnchor) - this.setXY(this._x, value + this._height * this._pivotY); - else - this.setXY(this._x, value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "pixelSnapping", { - get: function () { - return this._pixelSnapping; - }, - set: function (value) { - if (this._pixelSnapping != value) { - this._pixelSnapping = value; - this.handleXYChanged(); - } - }, - enumerable: true, - configurable: true - }); - GObject.prototype.center = function (restraint) { - var r; - if (this._parent) - r = this.parent; - else - r = this.root; - this.setXY((r.width - this._width) / 2, (r.height - this._height) / 2); - if (restraint) { - this.addRelation(r, fgui.RelationType.Center_Center); - this.addRelation(r, fgui.RelationType.Middle_Middle); - } - }; - Object.defineProperty(GObject.prototype, "width", { - get: function () { - this.ensureSizeCorrect(); - if (this._relations.sizeDirty) - this._relations.ensureRelationsSizeCorrect(); - return this._width; - }, - set: function (value) { - this.setSize(value, this._rawHeight); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "height", { - get: function () { - this.ensureSizeCorrect(); - if (this._relations.sizeDirty) - this._relations.ensureRelationsSizeCorrect(); - return this._height; - }, - set: function (value) { - this.setSize(this._rawWidth, value); - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setSize = function (wv, hv, ignorePivot) { - if (this._rawWidth != wv || this._rawHeight != hv) { - this._rawWidth = wv; - this._rawHeight = hv; - if (wv < this.minWidth) - wv = this.minWidth; - if (hv < this.minHeight) - hv = this.minHeight; - if (this.maxWidth > 0 && wv > this.maxWidth) - wv = this.maxWidth; - if (this.maxHeight > 0 && hv > this.maxHeight) - hv = this.maxHeight; - var dWidth = wv - this._width; - var dHeight = hv - this._height; - this._width = wv; - this._height = hv; - this.handleSizeChanged(); - if (this._pivotX != 0 || this._pivotY != 0) { - if (!this._pivotAsAnchor) { - if (!ignorePivot) - this.setXY(this.x - this._pivotX * dWidth, this.y - this._pivotY * dHeight); - this.updatePivotOffset(); - } - else { - this.applyPivot(); - } - } - if (this instanceof fgui.GGroup) - this.resizeChildren(dWidth, dHeight); - this.updateGear(2); - if (this._parent) { - this._relations.onOwnerSizeChanged(dWidth, dHeight, this._pivotAsAnchor || !ignorePivot); - this._parent.setBoundsChangedFlag(); - if (this._group) - this._group.setBoundsChangedFlag(); - } - this.dispatchEventWith(GObject.SIZE_CHANGED); - } - }; - GObject.prototype.makeFullScreen = function () { - this.setSize(fgui.GRoot.inst.width, fgui.GRoot.inst.height); - }; - GObject.prototype.ensureSizeCorrect = function () { - }; - Object.defineProperty(GObject.prototype, "actualWidth", { - get: function () { - return this.width * Math.abs(this._scaleX); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "actualHeight", { - get: function () { - return this.height * Math.abs(this._scaleY); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "scaleX", { - get: function () { - return this._scaleX; - }, - set: function (value) { - this.setScale(value, this._scaleY); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "scaleY", { - get: function () { - return this._scaleY; - }, - set: function (value) { - this.setScale(this._scaleX, value); - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setScale = function (sx, sy) { - if (this._scaleX != sx || this._scaleY != sy) { - this._scaleX = sx; - this._scaleY = sy; - this.handleScaleChanged(); - this.applyPivot(); - this.updateGear(2); - } - }; - Object.defineProperty(GObject.prototype, "skewX", { - get: function () { - return this._skewX; - }, - set: function (value) { - this.setSkew(value, this._skewY); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "skewY", { - get: function () { - return this._skewY; - }, - set: function (value) { - this.setSkew(this._skewX, value); - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setSkew = function (xv, yv) { - if (this._skewX != xv || this._skewY != yv) { - this._skewX = xv; - this._skewY = yv; - if (this._displayObject) { - this._displayObject.skewX = xv; - this._displayObject.skewY = yv; - } - this.applyPivot(); - } - }; - Object.defineProperty(GObject.prototype, "pivotX", { - get: function () { - return this._pivotX; - }, - set: function (value) { - this.setPivot(value, this._pivotY); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "pivotY", { - get: function () { - return this._pivotY; - }, - set: function (value) { - this.setPivot(this._pivotX, value); - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setPivot = function (xv, yv, asAnchor) { - if (this._pivotX != xv || this._pivotY != yv || this._pivotAsAnchor != asAnchor) { - this._pivotX = xv; - this._pivotY = yv; - this._pivotAsAnchor = asAnchor; - this.updatePivotOffset(); - this.handleXYChanged(); - } - }; - Object.defineProperty(GObject.prototype, "pivotAsAnchor", { - get: function () { - return this._pivotAsAnchor; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.internalSetPivot = function (xv, yv, asAnchor) { - this._pivotX = xv; - this._pivotY = yv; - this._pivotAsAnchor = asAnchor; - if (asAnchor) - this.handleXYChanged(); - }; - GObject.prototype.updatePivotOffset = function () { - if (this._displayObject) { - if (this._pivotX != 0 || this._pivotY != 0) { - var px = this._pivotX * this._width; - var py = this._pivotY * this._height; - var pt = this._displayObject.matrix.transformPoint(px, py, sHelperPoint); - this._pivotOffsetX = this._pivotX * this._width - (pt.x - this._displayObject.x); - this._pivotOffsetY = this._pivotY * this._height - (pt.y - this._displayObject.y); - } - else { - this._pivotOffsetX = 0; - this._pivotOffsetY = 0; - } - } - }; - GObject.prototype.applyPivot = function () { - if (this._pivotX != 0 || this._pivotY != 0) { - this.updatePivotOffset(); - this.handleXYChanged(); - } - }; - Object.defineProperty(GObject.prototype, "touchable", { - get: function () { - return this._touchable; - }, - set: function (value) { - if (this._touchable != value) { - this._touchable = value; - this.updateGear(3); - if ((this instanceof fgui.GImage) || (this instanceof fgui.GMovieClip) - || (this instanceof fgui.GTextField) && !(this instanceof fgui.GTextInput) && !(this instanceof fgui.GRichTextField)) - return; - if (this._displayObject) { - this._displayObject.touchEnabled = this._touchable; - if (this._displayObject instanceof egret.DisplayObjectContainer) - this._displayObject.touchChildren = this._touchable; - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "grayed", { - get: function () { - return this._grayed; - }, - set: function (value) { - if (this._grayed != value) { - this._grayed = value; - this.handleGrayedChanged(); - this.updateGear(3); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "enabled", { - get: function () { - return !this._grayed && this._touchable; - }, - set: function (value) { - this.grayed = !value; - this.touchable = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "rotation", { - get: function () { - return this._rotation; - }, - set: function (value) { - if (this._rotation != value) { - this._rotation = value; - if (this._displayObject) - this._displayObject.rotation = this.normalizeRotation; - this.applyPivot(); - this.updateGear(3); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "normalizeRotation", { - get: function () { - var rot = this._rotation % 360; - if (rot > 180) - rot -= 360; - else if (rot < -180) - rot += 360; - return rot; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "alpha", { - get: function () { - return this._alpha; - }, - set: function (value) { - if (this._alpha != value) { - this._alpha = value; - this.handleAlphaChanged(); - this.updateGear(3); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "visible", { - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible != value) { - this._visible = value; - this.handleVisibleChanged(); - if (this._parent) - this._parent.setBoundsChangedFlag(); - if (this._group && this._group.excludeInvisibles) - this._group.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "internalVisible", { - get: function () { - return this._internalVisible && (!this._group || this._group.internalVisible); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "internalVisible2", { - get: function () { - return this._visible && (!this._group || this._group.internalVisible2); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "internalVisible3", { - get: function () { - return this._visible && this._internalVisible; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "sortingOrder", { - get: function () { - return this._sortingOrder; - }, - set: function (value) { - if (value < 0) - value = 0; - if (this._sortingOrder != value) { - var old = this._sortingOrder; - this._sortingOrder = value; - if (this._parent) - this._parent.childSortingOrderChanged(this, old, this._sortingOrder); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "focused", { - get: function () { - return this.root.focus == this; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.requestFocus = function () { - this.root.focus = this; - }; - Object.defineProperty(GObject.prototype, "tooltips", { - get: function () { - return this._tooltips; - }, - set: function (value) { - this._tooltips = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "blendMode", { - get: function () { - return this._displayObject.blendMode; - }, - set: function (value) { - this._displayObject.blendMode = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "filters", { - get: function () { - return this._displayObject.filters; - }, - set: function (value) { - this._displayObject.filters = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "inContainer", { - get: function () { - return this._displayObject != null && this._displayObject.parent != null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "onStage", { - get: function () { - return this._displayObject != null && this._displayObject.stage != null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "resourceURL", { - get: function () { - if (this.packageItem) - return "ui://" + this.packageItem.owner.id + this.packageItem.id; - else - return null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "group", { - get: function () { - return this._group; - }, - set: function (value) { - if (this._group != value) { - if (this._group) - this._group.setBoundsChangedFlag(); - this._group = value; - if (this._group) - this._group.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - GObject.prototype.getGear = function (index) { - var gear = this._gears[index]; - if (gear == null) - this._gears[index] = gear = fgui.GearBase.create(this, index); - return gear; - }; - GObject.prototype.updateGear = function (index) { - if (this._underConstruct || this._gearLocked) - return; - var gear = this._gears[index]; - if (gear && gear.controller) - gear.updateState(); - }; - GObject.prototype.checkGearController = function (index, c) { - return this._gears[index] != null && this._gears[index].controller == c; - }; - GObject.prototype.updateGearFromRelations = function (index, dx, dy) { - if (this._gears[index]) - this._gears[index].updateFromRelations(dx, dy); - }; - GObject.prototype.addDisplayLock = function () { - var gearDisplay = this._gears[0]; - if (gearDisplay && gearDisplay.controller) { - var ret = gearDisplay.addLock(); - this.checkGearDisplay(); - return ret; - } - else - return 0; - }; - GObject.prototype.releaseDisplayLock = function (token) { - var gearDisplay = this._gears[0]; - if (gearDisplay && gearDisplay.controller) { - gearDisplay.releaseLock(token); - this.checkGearDisplay(); - } - }; - GObject.prototype.checkGearDisplay = function () { - if (this._handlingController) - return; - var connected = this._gears[0] == null || this._gears[0].connected; - if (this._gears[8]) - connected = this._gears[8].evaluate(connected); - if (connected != this._internalVisible) { - this._internalVisible = connected; - if (this._parent) - this._parent.childStateChanged(this); - if (this._group && this._group.excludeInvisibles) - this._group.setBoundsChangedFlag(); - } - }; - Object.defineProperty(GObject.prototype, "gearXY", { - get: function () { - return this.getGear(1); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "gearSize", { - get: function () { - return this.getGear(2); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "gearLook", { - get: function () { - return this.getGear(3); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "relations", { - get: function () { - return this._relations; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.addRelation = function (target, relationType, usePercent) { - this._relations.add(target, relationType, usePercent); - }; - GObject.prototype.removeRelation = function (target, relationType) { - this._relations.remove(target, relationType || 0); - }; - Object.defineProperty(GObject.prototype, "displayObject", { - get: function () { - return this._displayObject; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setDisplayObject = function (value) { - if (this._displayObject != value) { - if (this._displayObject) - delete this._displayObject["$owner"]; - this._displayObject = value; - this._displayObject["$owner"] = this; - } - }; - Object.defineProperty(GObject.prototype, "parent", { - get: function () { - return this._parent; - }, - set: function (val) { - this._parent = val; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.removeFromParent = function () { - if (this._parent) - this._parent.removeChild(this); - }; - Object.defineProperty(GObject.prototype, "root", { - get: function () { - if (this instanceof fgui.GRoot) - return this; - var p = this._parent; - while (p) { - if (p instanceof fgui.GRoot) - return p; - p = p.parent; - } - return fgui.GRoot.inst; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asCom", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asButton", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asLabel", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asProgress", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asTextField", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asRichTextField", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asTextInput", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asLoader", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asList", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asTree", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asGraph", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asGroup", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asSlider", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asComboBox", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asImage", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asMovieClip", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - GObject.cast = function (obj) { - return obj["$owner"]; - }; - Object.defineProperty(GObject.prototype, "text", { - get: function () { - return null; - }, - set: function (value) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "icon", { - get: function () { - return null; - }, - set: function (value) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "isDisposed", { - get: function () { - return this._disposed; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "treeNode", { - get: function () { - return this._treeNode; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.dispose = function () { - if (this._disposed) - return; - this._disposed = true; - this.removeFromParent(); - this._relations.dispose(); - this._displayObject = null; - for (var i = 0; i < 10; i++) { - var gear = this._gears[i]; - if (gear) - gear.dispose(); - } - }; - GObject.prototype.addClickListener = function (listener, thisObj) { - this.addEventListener(egret.TouchEvent.TOUCH_TAP, listener, thisObj); - }; - GObject.prototype.removeClickListener = function (listener, thisObj) { - this.removeEventListener(egret.TouchEvent.TOUCH_TAP, listener, thisObj); - }; - GObject.prototype.hasClickListener = function () { - return this.hasEventListener(egret.TouchEvent.TOUCH_TAP); - }; - GObject.prototype.addEventListener = function (type, listener, thisObject) { - _super_1.prototype.addEventListener.call(this, type, listener, thisObject); - if (this._displayObject) { - this._displayObject.addEventListener(type, this._reDispatch, this); - } - }; - GObject.prototype.removeEventListener = function (type, listener, thisObject) { - _super_1.prototype.removeEventListener.call(this, type, listener, thisObject); - if (this._displayObject && !this.hasEventListener(type)) { - this._displayObject.removeEventListener(type, this._reDispatch, this); - } - }; - GObject.prototype._reDispatch = function (evt) { - this.dispatchEvent(evt); - }; - Object.defineProperty(GObject.prototype, "draggable", { - get: function () { - return this._draggable; - }, - set: function (value) { - if (this._draggable != value) { - this._draggable = value; - this.initDrag(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "dragBounds", { - get: function () { - return this._dragBounds; - }, - set: function (value) { - this._dragBounds = value; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.startDrag = function (touchPointID, stageX, stageY) { - if (this._displayObject.stage == null) - return; - this.dragBegin(touchPointID, stageX, stageY); - }; - GObject.prototype.stopDrag = function () { - this.dragEnd(); - }; - Object.defineProperty(GObject.prototype, "dragging", { - get: function () { - return GObject.draggingObject == this; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.localToGlobal = function (ax, ay, result) { - ax = ax || 0; - ay = ay || 0; - if (this._pivotAsAnchor) { - ax += this._pivotX * this._width; - ay += this._pivotY * this._height; - } - return this._displayObject.localToGlobal(ax, ay, result); - }; - GObject.prototype.globalToLocal = function (ax, ay, result) { - ax = ax || 0; - ay = ay || 0; - var pt = this._displayObject.globalToLocal(ax, ay, result); - if (this._pivotAsAnchor) { - pt.x -= this._pivotX * this._width; - pt.y -= this._pivotY * this._height; - } - return pt; - }; - GObject.prototype.localToRoot = function (ax, ay, result) { - ax = ax || 0; - ay = ay || 0; - var pt = this._displayObject.localToGlobal(ax, ay, result); - pt.x /= fgui.GRoot.contentScaleFactor; - pt.y /= fgui.GRoot.contentScaleFactor; - return pt; - }; - GObject.prototype.rootToLocal = function (ax, ay, resultPoint) { - ax = ax || 0; - ay = ay || 0; - ax *= fgui.GRoot.contentScaleFactor; - ay *= fgui.GRoot.contentScaleFactor; - return this._displayObject.globalToLocal(ax, ay, resultPoint); - }; - GObject.prototype.localToGlobalRect = function (ax, ay, aw, ah, result) { - ax = ax || 0; - ay = ay || 0; - aw = aw || 0; - ah = ah || 0; - result = result || new egret.Rectangle(); - var pt = this.localToGlobal(ax, ay); - result.x = pt.x; - result.y = pt.y; - pt = this.localToGlobal(ax + aw, ay + ah); - result.right = pt.x; - result.bottom = pt.y; - return result; - }; - GObject.prototype.globalToLocalRect = function (ax, ay, aw, ah, result) { - ax = ax || 0; - ay = ay || 0; - aw = aw || 0; - ah = ah || 0; - result = result || new egret.Rectangle(); - var pt = this.globalToLocal(ax, ay); - result.x = pt.x; - result.y = pt.y; - pt = this.globalToLocal(ax + aw, ay + ah); - result.right = pt.x; - result.bottom = pt.y; - return result; - }; - GObject.prototype.handleControllerChanged = function (c) { - this._handlingController = true; - for (var i = 0; i < 10; i++) { - var gear = this._gears[i]; - if (gear && gear.controller == c) - gear.apply(); - } - this._handlingController = false; - this.checkGearDisplay(); - }; - GObject.prototype.createDisplayObject = function () { - }; - GObject.prototype.switchDisplayObject = function (newObj) { - if (newObj == this._displayObject) - return; - var old = this._displayObject; - if (this._displayObject && this._displayObject.parent) { - var i = this._displayObject.parent.getChildIndex(this._displayObject); - this._displayObject.parent.addChildAt(newObj, i); - this._displayObject.parent.removeChild(this._displayObject); - } - this._displayObject = newObj; - this._displayObject.x = old.x; - this._displayObject.y = old.y; - this._displayObject.rotation = old.rotation; - this._displayObject.alpha = old.alpha; - this._displayObject.visible = old.visible; - this._displayObject.touchEnabled = old.touchEnabled; - this._displayObject.scaleX = old.scaleX; - this._displayObject.scaleY = old.scaleY; - fgui.ToolSet.setColorFilter(this._displayObject, this._grayed); - if (this._displayObject instanceof egret.DisplayObjectContainer) - this._displayObject.touchChildren = this._touchable; - }; - GObject.prototype.handleXYChanged = function () { - if (this._displayObject) { - var xv = this._x; - var yv = this._y; - if (this._pivotAsAnchor) { - xv -= this._pivotX * this._width; - yv -= this._pivotY * this._height; - } - if (this._pixelSnapping) { - xv = Math.round(xv); - yv = Math.round(yv); - } - this._displayObject.x = xv + this._pivotOffsetX; - this._displayObject.y = yv + this._pivotOffsetY; - } - }; - GObject.prototype.handleSizeChanged = function () { - if (this._displayObject) { - this._displayObject.width = this._width; - this._displayObject.height = this._height; - } - }; - GObject.prototype.handleScaleChanged = function () { - if (this._displayObject) { - this._displayObject.scaleX = this._scaleX; - this._displayObject.scaleY = this._scaleY; - } - }; - GObject.prototype.handleGrayedChanged = function () { - if (this._displayObject) { - fgui.ToolSet.setColorFilter(this._displayObject, this._grayed); - } - }; - GObject.prototype.handleAlphaChanged = function () { - if (this._displayObject) - this._displayObject.alpha = this._alpha; - }; - GObject.prototype.handleVisibleChanged = function () { - if (this._displayObject) - this._displayObject.visible = this.internalVisible2; - if (this instanceof fgui.GGroup) - this.handleVisibleChanged(); - }; - GObject.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Text: - return this.text; - case fgui.ObjectPropID.Icon: - return this.icon; - case fgui.ObjectPropID.Color: - return NaN; - case fgui.ObjectPropID.OutlineColor: - return NaN; - case fgui.ObjectPropID.Playing: - return false; - case fgui.ObjectPropID.Frame: - return 0; - case fgui.ObjectPropID.DeltaTime: - return 0; - case fgui.ObjectPropID.TimeScale: - return 1; - case fgui.ObjectPropID.FontSize: - return 0; - case fgui.ObjectPropID.Selected: - return false; - default: - return undefined; - } - }; - GObject.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Text: - this.text = value; - break; - case fgui.ObjectPropID.Icon: - this.icon = value; - break; - } - }; - GObject.prototype.constructFromResource = function () { - }; - GObject.prototype.setup_beforeAdd = function (buffer, beginPos) { - buffer.seek(beginPos, 0); - buffer.skip(5); - var f1; - var f2; - this._id = buffer.readS(); - this._name = buffer.readS(); - f1 = buffer.readInt(); - f2 = buffer.readInt(); - this.setXY(f1, f2); - if (buffer.readBool()) { - this.initWidth = buffer.readInt(); - this.initHeight = buffer.readInt(); - this.setSize(this.initWidth, this.initHeight, true); - } - if (buffer.readBool()) { - this.minWidth = buffer.readInt(); - this.maxWidth = buffer.readInt(); - this.minHeight = buffer.readInt(); - this.maxHeight = buffer.readInt(); - } - if (buffer.readBool()) { - f1 = buffer.readFloat(); - f2 = buffer.readFloat(); - this.setScale(f1, f2); - } - if (buffer.readBool()) { - f1 = buffer.readFloat(); - f2 = buffer.readFloat(); - this.setSkew(f1, f2); - } - if (buffer.readBool()) { - f1 = buffer.readFloat(); - f2 = buffer.readFloat(); - this.setPivot(f1, f2, buffer.readBool()); - } - f1 = buffer.readFloat(); - if (f1 != 1) - this.alpha = f1; - f1 = buffer.readFloat(); - if (f1 != 0) - this.rotation = f1; - if (!buffer.readBool()) - this.visible = false; - if (!buffer.readBool()) - this.touchable = false; - if (buffer.readBool()) - this.grayed = true; - var bm = buffer.readByte(); - if (bm == 2) - this.blendMode = egret.BlendMode.ADD; - else if (bm == 5) - this.blendMode = egret.BlendMode.ERASE; - var filter = buffer.readByte(); - if (filter == 1 && this._displayObject) - fgui.ToolSet.setColorFilter(this._displayObject, [buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat()]); - var str = buffer.readS(); - if (str != null) - this.data = str; - }; - GObject.prototype.setup_afterAdd = function (buffer, beginPos) { - buffer.seek(beginPos, 1); - var str = buffer.readS(); - if (str != null) - this.tooltips = str; - var groupId = buffer.readShort(); - if (groupId >= 0) - this.group = this.parent.getChildAt(groupId); - buffer.seek(beginPos, 2); - var cnt = buffer.readShort(); - for (var i = 0; i < cnt; i++) { - var nextPos = buffer.readShort(); - nextPos += buffer.position; - var gear = this.getGear(buffer.readByte()); - gear.setup(buffer); - buffer.position = nextPos; - } - }; - GObject.prototype.initDrag = function () { - if (this._draggable) - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__begin, this); - else - this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__begin, this); - }; - GObject.prototype.dragBegin = function (touchPointID, stageX, stageY) { - if (GObject.draggingObject) { - var tmp = GObject.draggingObject; - tmp.stopDrag(); - GObject.draggingObject = null; - var dragEvent = new fgui.DragEvent(fgui.DragEvent.DRAG_END); - dragEvent.stageX = stageX || fgui.GRoot.mouseX; - dragEvent.stageY = stageY || fgui.GRoot.mouseY; - dragEvent.touchPointID = touchPointID || 0; - tmp.dispatchEvent(dragEvent); - } - sGlobalDragStart.x = stageX || fgui.GRoot.mouseX; - sGlobalDragStart.y = stageY || fgui.GRoot.mouseY; - this.localToGlobalRect(0, 0, this._width, this._height, sGlobalRect); - this._dragTesting = true; - GObject.draggingObject = this; - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__moving, this); - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_END, this.__end, this); - }; - GObject.prototype.dragEnd = function () { - if (GObject.draggingObject == this) { - this.reset(); - this._dragTesting = false; - GObject.draggingObject = null; - } - }; - GObject.prototype.reset = function () { - fgui.GRoot.inst.nativeStage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.__moving, this); - fgui.GRoot.inst.nativeStage.removeEventListener(egret.TouchEvent.TOUCH_END, this.__end, this); - }; - GObject.prototype.__begin = function (evt) { - if (this._dragStartPos == null) - this._dragStartPos = new egret.Point(); - this._dragStartPos.x = evt.stageX; - this._dragStartPos.y = evt.stageY; - this._dragTesting = true; - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__moving, this); - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_END, this.__end, this); - }; - GObject.prototype.__moving = function (evt) { - if (GObject.draggingObject != this && this._draggable && this._dragTesting) { - var sensitivity = fgui.UIConfig.touchDragSensitivity; - if (this._dragStartPos - && Math.abs(this._dragStartPos.x - evt.stageX) < sensitivity - && Math.abs(this._dragStartPos.y - evt.stageY) < sensitivity) - return; - this._dragTesting = false; - var dragEvent = new fgui.DragEvent(fgui.DragEvent.DRAG_START); - dragEvent.stageX = evt.stageX; - dragEvent.stageY = evt.stageY; - dragEvent.touchPointID = evt.touchPointID; - this.dispatchEvent(dragEvent); - if (!dragEvent.isDefaultPrevented()) - this.dragBegin(evt.touchPointID, evt.stageX, evt.stageY); - } - if (GObject.draggingObject == this) { - var xx = evt.stageX - sGlobalDragStart.x + sGlobalRect.x; - var yy = evt.stageY - sGlobalDragStart.y + sGlobalRect.y; - if (this._dragBounds) { - var rect = fgui.GRoot.inst.localToGlobalRect(this._dragBounds.x, this._dragBounds.y, this._dragBounds.width, this._dragBounds.height, sDragHelperRect); - if (xx < rect.x) - xx = rect.x; - else if (xx + sGlobalRect.width > rect.right) { - xx = rect.right - sGlobalRect.width; - if (xx < rect.x) - xx = rect.x; - } - if (yy < rect.y) - yy = rect.y; - else if (yy + sGlobalRect.height > rect.bottom) { - yy = rect.bottom - sGlobalRect.height; - if (yy < rect.y) - yy = rect.y; - } - } - sUpdateInDragging = true; - var pt = this.parent.globalToLocal(xx, yy, sHelperPoint); - this.setXY(Math.round(pt.x), Math.round(pt.y)); - sUpdateInDragging = false; - var dragEvent = new fgui.DragEvent(fgui.DragEvent.DRAG_MOVING); - dragEvent.stageX = evt.stageX; - dragEvent.stageY = evt.stageY; - dragEvent.touchPointID = evt.touchPointID; - this.dispatchEvent(dragEvent); - } - }; - GObject.prototype.__end = function (evt) { - if (GObject.draggingObject == this) { - GObject.draggingObject = null; - this.reset(); - var dragEvent = new fgui.DragEvent(fgui.DragEvent.DRAG_END); - dragEvent.stageX = evt.stageX; - dragEvent.stageY = evt.stageY; - dragEvent.touchPointID = evt.touchPointID; - this.dispatchEvent(dragEvent); - } - else if (this._dragTesting) { - this._dragTesting = false; - this.reset(); - } - }; - GObject.XY_CHANGED = "__xyChanged"; - GObject.SIZE_CHANGED = "__sizeChanged"; - GObject.SIZE_DELAY_CHANGE = "__sizeDelayChange"; - GObject.GEAR_STOP = "gearStop"; - return GObject; - }(egret.EventDispatcher)); - fgui.GObject = GObject; - var _gInstanceCounter = 0; - var sGlobalDragStart = new egret.Point(); - var sGlobalRect = new egret.Rectangle(); - var sHelperPoint = new egret.Point(); - var sDragHelperRect = new egret.Rectangle(); - var sUpdateInDragging; -})(fgui || (fgui = {})); - -(function (fgui) { - var GComponent = (function (_super_1) { - __extends(GComponent, _super_1); - function GComponent() { - var _this = _super_1.call(this) || this; - _this._sortingChildCount = 0; - _this._childrenRenderOrder = fgui.ChildrenRenderOrder.Ascent; - _this._apexIndex = 0; - _this._children = new Array(); - _this._controllers = new Array(); - _this._transitions = new Array(); - _this._margin = new fgui.Margin(); - _this._alignOffset = new egret.Point(); - return _this; - } - GComponent.prototype.createDisplayObject = function () { - this._rootContainer = new fgui.UIContainer(); - this.setDisplayObject(this._rootContainer); - this._container = this._rootContainer; - }; - GComponent.prototype.dispose = function () { - var i; - var cnt; - cnt = this._transitions.length; - for (i = 0; i < cnt; ++i) { - var trans = this._transitions[i]; - trans.dispose(); - } - cnt = this._controllers.length; - for (i = 0; i < cnt; ++i) { - var cc = this._controllers[i]; - cc.dispose(); - } - if (this._scrollPane) - this._scrollPane.dispose(); - cnt = this._children.length; - for (i = cnt - 1; i >= 0; --i) { - var obj = this._children[i]; - obj.parent = null; - obj.dispose(); - } - this._boundsChanged = false; - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GComponent.prototype, "displayListContainer", { - get: function () { - return this._container; - }, - enumerable: true, - configurable: true - }); - GComponent.prototype.addChild = function (child) { - this.addChildAt(child, this._children.length); - return child; - }; - GComponent.prototype.addChildAt = function (child, index) { - if (index === void 0) { index = 0; } - if (!child) - throw "child is null"; - var numChildren = this._children.length; - if (index >= 0 && index <= numChildren) { - if (child.parent == this) { - this.setChildIndex(child, index); - } - else { - child.removeFromParent(); - child.parent = this; - var cnt = this._children.length; - if (child.sortingOrder != 0) { - this._sortingChildCount++; - index = this.getInsertPosForSortingChild(child); - } - else if (this._sortingChildCount > 0) { - if (index > (cnt - this._sortingChildCount)) - index = cnt - this._sortingChildCount; - } - if (index == cnt) - this._children.push(child); - else - this._children.splice(index, 0, child); - this.childStateChanged(child); - this.setBoundsChangedFlag(); - } - return child; - } - else { - throw "Invalid child index"; - } - }; - GComponent.prototype.getInsertPosForSortingChild = function (target) { - var cnt = this._children.length; - var i = 0; - for (i = 0; i < cnt; i++) { - var child = this._children[i]; - if (child == target) - continue; - if (target.sortingOrder < child.sortingOrder) - break; - } - return i; - }; - GComponent.prototype.removeChild = function (child, dispose) { - var childIndex = this._children.indexOf(child); - if (childIndex != -1) { - this.removeChildAt(childIndex, dispose); - } - return child; - }; - GComponent.prototype.removeChildAt = function (index, dispose) { - if (index >= 0 && index < this.numChildren) { - var child = this._children[index]; - child.parent = null; - if (child.sortingOrder != 0) - this._sortingChildCount--; - this._children.splice(index, 1); - child.group = null; - if (child.inContainer) { - this._container.removeChild(child.displayObject); - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Arch) - fgui.GTimers.inst.callLater(this.buildNativeDisplayList, this); - } - if (dispose) - child.dispose(); - this.setBoundsChangedFlag(); - return child; - } - else { - throw "Invalid child index"; - } - }; - GComponent.prototype.removeChildren = function (beginIndex, endIndex, dispose) { - if (beginIndex == undefined) - beginIndex = 0; - if (endIndex == undefined) - endIndex = -1; - if (endIndex < 0 || endIndex >= this.numChildren) - endIndex = this.numChildren - 1; - for (var i = beginIndex; i <= endIndex; ++i) - this.removeChildAt(beginIndex, dispose); - }; - GComponent.prototype.getChildAt = function (index) { - if (index >= 0 && index < this.numChildren) - return this._children[index]; - else - throw "Invalid child index"; - }; - GComponent.prototype.getChild = function (name) { - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - if (this._children[i].name == name) - return this._children[i]; - } - return null; - }; - GComponent.prototype.getChildByPath = function (path) { - var arr = path.split("."); - var cnt = arr.length; - var gcom = this; - var obj; - for (var i = 0; i < cnt; ++i) { - obj = gcom.getChild(arr[i]); - if (!obj) - break; - if (i != cnt - 1) { - if (!(obj instanceof GComponent)) { - obj = null; - break; - } - else - gcom = obj; - } - } - return obj; - }; - GComponent.prototype.getVisibleChild = function (name) { - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - var child = this._children[i]; - if (child.internalVisible && child.internalVisible && child.name == name) - return child; - } - return null; - }; - GComponent.prototype.getChildInGroup = function (name, group) { - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - var child = this._children[i]; - if (child.group == group && child.name == name) - return child; - } - return null; - }; - GComponent.prototype.getChildById = function (id) { - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - if (this._children[i]._id == id) - return this._children[i]; - } - return null; - }; - GComponent.prototype.getChildIndex = function (child) { - return this._children.indexOf(child); - }; - GComponent.prototype.setChildIndex = function (child, index) { - var oldIndex = this._children.indexOf(child); - if (oldIndex == -1) - throw "Not a child of this container"; - if (child.sortingOrder != 0) - return; - var cnt = this._children.length; - if (this._sortingChildCount > 0) { - if (index > (cnt - this._sortingChildCount - 1)) - index = cnt - this._sortingChildCount - 1; - } - this._setChildIndex(child, oldIndex, index); - }; - GComponent.prototype.setChildIndexBefore = function (child, index) { - var oldIndex = this._children.indexOf(child); - if (oldIndex == -1) - throw "Not a child of this container"; - if (child.sortingOrder != 0) - return oldIndex; - var cnt = this._children.length; - if (this._sortingChildCount > 0) { - if (index > (cnt - this._sortingChildCount - 1)) - index = cnt - this._sortingChildCount - 1; - } - if (oldIndex < index) - return this._setChildIndex(child, oldIndex, index - 1); - else - return this._setChildIndex(child, oldIndex, index); - }; - GComponent.prototype._setChildIndex = function (child, oldIndex, index) { - var cnt = this._children.length; - if (index > cnt) - index = cnt; - if (oldIndex == index) - return oldIndex; - this._children.splice(oldIndex, 1); - this._children.splice(index, 0, child); - if (child.inContainer) { - var displayIndex = 0; - var g; - var i; - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Ascent) { - for (i = 0; i < index; i++) { - g = this._children[i]; - if (g.inContainer) - displayIndex++; - } - if (displayIndex == this._container.numChildren) - displayIndex--; - this._container.setChildIndex(child.displayObject, displayIndex); - } - else if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Descent) { - for (i = cnt - 1; i > index; i--) { - g = this._children[i]; - if (g.inContainer) - displayIndex++; - } - if (displayIndex == this._container.numChildren) - displayIndex--; - this._container.setChildIndex(child.displayObject, displayIndex); - } - else { - fgui.GTimers.inst.callLater(this.buildNativeDisplayList, this); - } - this.setBoundsChangedFlag(); - } - return index; - }; - GComponent.prototype.swapChildren = function (child1, child2) { - var index1 = this._children.indexOf(child1); - var index2 = this._children.indexOf(child2); - if (index1 == -1 || index2 == -1) - throw "Not a child of this container"; - this.swapChildrenAt(index1, index2); - }; - GComponent.prototype.swapChildrenAt = function (index1, index2) { - var child1 = this._children[index1]; - var child2 = this._children[index2]; - this.setChildIndex(child1, index2); - this.setChildIndex(child2, index1); - }; - Object.defineProperty(GComponent.prototype, "numChildren", { - get: function () { - return this._children.length; - }, - enumerable: true, - configurable: true - }); - GComponent.prototype.isAncestorOf = function (child) { - if (!child) - return false; - var p = child.parent; - while (p) { - if (p == this) - return true; - p = p.parent; - } - return false; - }; - GComponent.prototype.addController = function (controller) { - this._controllers.push(controller); - controller.parent = this; - this.applyController(controller); - }; - GComponent.prototype.getControllerAt = function (index) { - return this._controllers[index]; - }; - GComponent.prototype.getController = function (name) { - var cnt = this._controllers.length; - for (var i = 0; i < cnt; ++i) { - var c = this._controllers[i]; - if (c.name == name) - return c; - } - return null; - }; - GComponent.prototype.removeController = function (c) { - var index = this._controllers.indexOf(c); - if (index == -1) - throw "controller not exists"; - c.parent = null; - this._controllers.splice(index, 1); - var length = this._children.length; - for (var i = 0; i < length; i++) { - var child = this._children[i]; - child.handleControllerChanged(c); - } - }; - Object.defineProperty(GComponent.prototype, "controllers", { - get: function () { - return this._controllers; - }, - enumerable: true, - configurable: true - }); - GComponent.prototype.childStateChanged = function (child) { - if (this._buildingDisplayList) - return; - var cnt = this._children.length; - var g; - var i; - if (child instanceof fgui.GGroup) { - for (i = 0; i < cnt; i++) { - g = this._children[i]; - if (g.group == child) - this.childStateChanged(g); - } - return; - } - if (!child.displayObject) - return; - if (child.internalVisible) { - if (!child.displayObject.parent) { - var index = 0; - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Ascent) { - for (i = 0; i < cnt; i++) { - g = this._children[i]; - if (g == child) - break; - if (g.displayObject && g.displayObject.parent) - index++; - } - this._container.addChildAt(child.displayObject, index); - } - else if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Descent) { - for (i = cnt - 1; i >= 0; i--) { - g = this._children[i]; - if (g == child) - break; - if (g.displayObject && g.displayObject.parent) - index++; - } - this._container.addChildAt(child.displayObject, index); - } - else { - this._container.addChild(child.displayObject); - fgui.GTimers.inst.callLater(this.buildNativeDisplayList, this); - } - } - } - else { - if (child.displayObject.parent) - this._container.removeChild(child.displayObject); - } - }; - GComponent.prototype.buildNativeDisplayList = function () { - var cnt = this._children.length; - if (cnt == 0) - return; - var i; - var child; - switch (this._childrenRenderOrder) { - case fgui.ChildrenRenderOrder.Ascent: - { - for (i = 0; i < cnt; i++) { - child = this._children[i]; - if (child.displayObject && child.internalVisible) - this._container.addChild(child.displayObject); - } - } - break; - case fgui.ChildrenRenderOrder.Descent: - { - for (i = cnt - 1; i >= 0; i--) { - child = this._children[i]; - if (child.displayObject && child.internalVisible) - this._container.addChild(child.displayObject); - } - } - break; - case fgui.ChildrenRenderOrder.Arch: - { - var apex = fgui.ToolSet.clamp(this._apexIndex, 0, cnt); - for (i = 0; i < apex; i++) { - child = this._children[i]; - if (child.displayObject && child.internalVisible) - this._container.addChild(child.displayObject); - } - for (i = cnt - 1; i >= apex; i--) { - child = this._children[i]; - if (child.displayObject && child.internalVisible) - this._container.addChild(child.displayObject); - } - } - break; - } - }; - GComponent.prototype.applyController = function (c) { - this._applyingController = c; - var child; - var length = this._children.length; - for (var i = 0; i < length; i++) { - child = this._children[i]; - child.handleControllerChanged(c); - } - this._applyingController = null; - c.runActions(); - }; - GComponent.prototype.applyAllControllers = function () { - var cnt = this._controllers.length; - for (var i = 0; i < cnt; ++i) { - this.applyController(this._controllers[i]); - } - }; - GComponent.prototype.adjustRadioGroupDepth = function (obj, c) { - var cnt = this._children.length; - var i; - var child; - var myIndex = -1, maxIndex = -1; - for (i = 0; i < cnt; i++) { - child = this._children[i]; - if (child == obj) { - myIndex = i; - } - else if ((child instanceof fgui.GButton) && child.relatedController == c) { - if (i > maxIndex) - maxIndex = i; - } - } - if (myIndex < maxIndex) { - if (this._applyingController) - this._children[maxIndex].handleControllerChanged(this._applyingController); - this.swapChildrenAt(myIndex, maxIndex); - } - }; - GComponent.prototype.getTransitionAt = function (index) { - return this._transitions[index]; - }; - GComponent.prototype.getTransition = function (transName) { - var cnt = this._transitions.length; - for (var i = 0; i < cnt; ++i) { - var trans = this._transitions[i]; - if (trans.name == transName) - return trans; - } - return null; - }; - GComponent.prototype.isChildInView = function (child) { - if (this._rootContainer.scrollRect) { - return child.x + child.width >= 0 && child.x <= this.width - && child.y + child.height >= 0 && child.y <= this.height; - } - else if (this._scrollPane) { - return this._scrollPane.isChildInView(child); - } - else - return true; - }; - GComponent.prototype.getFirstChildInView = function () { - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - var child = this._children[i]; - if (this.isChildInView(child)) - return i; - } - return -1; - }; - Object.defineProperty(GComponent.prototype, "scrollPane", { - get: function () { - return this._scrollPane; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "opaque", { - get: function () { - return this._rootContainer.opaque; - }, - set: function (value) { - this._rootContainer.opaque = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "margin", { - get: function () { - return this._margin; - }, - set: function (value) { - this._margin.copy(value); - if (this._rootContainer.scrollRect) { - this._container.x = this._margin.left + this._alignOffset.x; - this._container.y = this._margin.top + this._alignOffset.y; - } - this.handleSizeChanged(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "childrenRenderOrder", { - get: function () { - return this._childrenRenderOrder; - }, - set: function (value) { - if (this._childrenRenderOrder != value) { - this._childrenRenderOrder = value; - this.buildNativeDisplayList(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "apexIndex", { - get: function () { - return this._apexIndex; - }, - set: function (value) { - if (this._apexIndex != value) { - this._apexIndex = value; - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Arch) - this.buildNativeDisplayList(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "mask", { - get: function () { - return this._rootContainer.mask; - }, - set: function (value) { - this._rootContainer.mask = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "baseUserData", { - get: function () { - var buffer = this.packageItem.rawData; - buffer.seek(0, 4); - return buffer.readS(); - }, - enumerable: true, - configurable: true - }); - GComponent.prototype.updateScrollRect = function () { - var rect = this._rootContainer.scrollRect; - if (rect == null) - rect = new egret.Rectangle(); - var w = this.width - this._margin.right; - var h = this.height - this._margin.bottom; - rect.setTo(0, 0, w, h); - this._rootContainer.scrollRect = rect; - }; - GComponent.prototype.setupScroll = function (buffer) { - if (this._rootContainer == this._container) { - this._container = new egret.DisplayObjectContainer(); - this._rootContainer.addChild(this._container); - } - this._scrollPane = new fgui.ScrollPane(this); - this._scrollPane.setup(buffer); - this.setBoundsChangedFlag(); - }; - GComponent.prototype.setupOverflow = function (overflow) { - if (overflow == fgui.OverflowType.Hidden) { - if (this._rootContainer == this._container) { - this._container = new egret.DisplayObjectContainer(); - this._rootContainer.addChild(this._container); - } - this.updateScrollRect(); - this._container.x = this._margin.left; - this._container.y = this._margin.top; - } - else if (this._margin.left != 0 || this._margin.top != 0) { - if (this._rootContainer == this._container) { - this._container = new egret.DisplayObjectContainer(); - this._rootContainer.addChild(this._container); - } - this._container.x = this._margin.left; - this._container.y = this._margin.top; - } - this.setBoundsChangedFlag(); - }; - GComponent.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (this._scrollPane) - this._scrollPane.onOwnerSizeChanged(); - else if (this._rootContainer.scrollRect) - this.updateScrollRect(); - if (this._rootContainer.hitArea instanceof fgui.PixelHitTest) { - var hitTest = (this._rootContainer.hitArea); - if (this.sourceWidth != 0) - hitTest.scaleX = this._width / this.sourceWidth; - if (this.sourceHeight != 0) - hitTest.scaleY = this._height / this.sourceHeight; - } - }; - GComponent.prototype.handleGrayedChanged = function () { - var c = this.getController("grayed"); - if (c) { - c.selectedIndex = this.grayed ? 1 : 0; - return; - } - var v = this.grayed; - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - this._children[i].grayed = v; - } - }; - GComponent.prototype.handleControllerChanged = function (c) { - _super_1.prototype.handleControllerChanged.call(this, c); - if (this._scrollPane) - this._scrollPane.handleControllerChanged(c); - }; - GComponent.prototype.setBoundsChangedFlag = function () { - if (!this._scrollPane && !this._trackBounds) - return; - if (!this._boundsChanged) { - this._boundsChanged = true; - egret.callLater(this.__render, this); - } - }; - GComponent.prototype.__render = function () { - if (this._boundsChanged) { - var len = this._children.length; - if (len > 0) { - for (var i = 0; i < len; i++) { - var child = this._children[i]; - child.ensureSizeCorrect(); - } - } - this.updateBounds(); - } - }; - GComponent.prototype.ensureBoundsCorrect = function () { - var len = this._children.length; - if (len > 0) { - for (var i = 0; i < len; i++) { - var child = this._children[i]; - child.ensureSizeCorrect(); - } - } - if (this._boundsChanged) - this.updateBounds(); - }; - GComponent.prototype.updateBounds = function () { - var ax = 0, ay = 0, aw = 0, ah = 0; - var len = this._children.length; - if (len > 0) { - ax = Number.POSITIVE_INFINITY, ay = Number.POSITIVE_INFINITY; - var ar = Number.NEGATIVE_INFINITY, ab = Number.NEGATIVE_INFINITY; - var tmp = 0; - var i = 0; - for (var i = 0; i < len; i++) { - var child = this._children[i]; - tmp = child.x; - if (tmp < ax) - ax = tmp; - tmp = child.y; - if (tmp < ay) - ay = tmp; - tmp = child.x + child.actualWidth; - if (tmp > ar) - ar = tmp; - tmp = child.y + child.actualHeight; - if (tmp > ab) - ab = tmp; - } - aw = ar - ax; - ah = ab - ay; - } - this.setBounds(ax, ay, aw, ah); - }; - GComponent.prototype.setBounds = function (ax, ay, aw, ah) { - if (ah === void 0) { ah = 0; } - this._boundsChanged = false; - if (this._scrollPane) - this._scrollPane.setContentSize(Math.round(ax + aw), Math.round(ay + ah)); - }; - Object.defineProperty(GComponent.prototype, "viewWidth", { - get: function () { - if (this._scrollPane) - return this._scrollPane.viewWidth; - else - return this.width - this._margin.left - this._margin.right; - }, - set: function (value) { - if (this._scrollPane) - this._scrollPane.viewWidth = value; - else - this.width = value + this._margin.left + this._margin.right; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "viewHeight", { - get: function () { - if (this._scrollPane) - return this._scrollPane.viewHeight; - else - return this.height - this._margin.top - this._margin.bottom; - }, - set: function (value) { - if (this._scrollPane) - this._scrollPane.viewHeight = value; - else - this.height = value + this._margin.top + this._margin.bottom; - }, - enumerable: true, - configurable: true - }); - GComponent.prototype.getSnappingPosition = function (xValue, yValue, resultPoint) { - if (!resultPoint) - resultPoint = new egret.Point(); - var cnt = this._children.length; - if (cnt == 0) { - resultPoint.x = 0; - resultPoint.y = 0; - return resultPoint; - } - this.ensureBoundsCorrect(); - var obj = null; - var prev = null; - var i = 0; - if (yValue != 0) { - for (; i < cnt; i++) { - obj = this._children[i]; - if (yValue < obj.y) { - if (i == 0) { - yValue = 0; - break; - } - else { - prev = this._children[i - 1]; - if (yValue < prev.y + prev.actualHeight / 2) - yValue = prev.y; - else - yValue = obj.y; - break; - } - } - } - if (i == cnt) - yValue = obj.y; - } - if (xValue != 0) { - if (i > 0) - i--; - for (; i < cnt; i++) { - obj = this._children[i]; - if (xValue < obj.x) { - if (i == 0) { - xValue = 0; - break; - } - else { - prev = this._children[i - 1]; - if (xValue < prev.x + prev.actualWidth / 2) - xValue = prev.x; - else - xValue = obj.x; - break; - } - } - } - if (i == cnt) - xValue = obj.x; - } - resultPoint.x = xValue; - resultPoint.y = yValue; - return resultPoint; - }; - GComponent.prototype.childSortingOrderChanged = function (child, oldValue, newValue) { - if (newValue === void 0) { newValue = 0; } - if (newValue == 0) { - this._sortingChildCount--; - this.setChildIndex(child, this._children.length); - } - else { - if (oldValue == 0) - this._sortingChildCount++; - var oldIndex = this._children.indexOf(child); - var index = this.getInsertPosForSortingChild(child); - if (oldIndex < index) - this._setChildIndex(child, oldIndex, index - 1); - else - this._setChildIndex(child, oldIndex, index); - } - }; - GComponent.prototype.constructFromResource = function () { - this.constructFromResource2(null, 0); - }; - GComponent.prototype.constructFromResource2 = function (objectPool, poolIndex) { - var contentItem = this.packageItem.getBranch(); - if (!contentItem.decoded) { - contentItem.decoded = true; - fgui.TranslationHelper.translateComponent(contentItem); - } - var i; - var dataLen; - var curPos; - var nextPos; - var f1; - var f2; - var i1; - var i2; - var buffer = contentItem.rawData; - buffer.seek(0, 0); - this._underConstruct = true; - this.sourceWidth = buffer.readInt(); - this.sourceHeight = buffer.readInt(); - this.initWidth = this.sourceWidth; - this.initHeight = this.sourceHeight; - this.setSize(this.sourceWidth, this.sourceHeight); - if (buffer.readBool()) { - this.minWidth = buffer.readInt(); - this.maxWidth = buffer.readInt(); - this.minHeight = buffer.readInt(); - this.maxHeight = buffer.readInt(); - } - if (buffer.readBool()) { - f1 = buffer.readFloat(); - f2 = buffer.readFloat(); - this.internalSetPivot(f1, f2, buffer.readBool()); - } - if (buffer.readBool()) { - this._margin.top = buffer.readInt(); - this._margin.bottom = buffer.readInt(); - this._margin.left = buffer.readInt(); - this._margin.right = buffer.readInt(); - } - var overflow = buffer.readByte(); - if (overflow == fgui.OverflowType.Scroll) { - var savedPos = buffer.position; - buffer.seek(0, 7); - this.setupScroll(buffer); - buffer.position = savedPos; - } - else - this.setupOverflow(overflow); - if (buffer.readBool()) - buffer.skip(8); - this._buildingDisplayList = true; - buffer.seek(0, 1); - var controllerCount = buffer.readShort(); - for (i = 0; i < controllerCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - var controller = new fgui.Controller(); - this._controllers.push(controller); - controller.parent = this; - controller.setup(buffer); - buffer.position = nextPos; - } - buffer.seek(0, 2); - var child; - var childCount = buffer.readShort(); - for (i = 0; i < childCount; i++) { - dataLen = buffer.readShort(); - curPos = buffer.position; - if (objectPool) - child = objectPool[poolIndex + i]; - else { - buffer.seek(curPos, 0); - var type = buffer.readByte(); - var src = buffer.readS(); - var pkgId = buffer.readS(); - var pi = null; - if (src != null) { - var pkg; - if (pkgId != null) - pkg = fgui.UIPackage.getById(pkgId); - else - pkg = contentItem.owner; - pi = pkg ? pkg.getItemById(src) : null; - } - if (pi) { - child = fgui.UIObjectFactory.newObject(pi); - child.constructFromResource(); - } - else - child = fgui.UIObjectFactory.newObject(type); - } - child._underConstruct = true; - child.setup_beforeAdd(buffer, curPos); - child.parent = this; - this._children.push(child); - buffer.position = curPos + dataLen; - } - buffer.seek(0, 3); - this.relations.setup(buffer, true); - buffer.seek(0, 2); - buffer.skip(2); - for (i = 0; i < childCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - buffer.seek(buffer.position, 3); - this._children[i].relations.setup(buffer, false); - buffer.position = nextPos; - } - buffer.seek(0, 2); - buffer.skip(2); - for (i = 0; i < childCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - child = this._children[i]; - child.setup_afterAdd(buffer, buffer.position); - child._underConstruct = false; - buffer.position = nextPos; - } - buffer.seek(0, 4); - buffer.skip(2); - this.opaque = buffer.readBool(); - var maskId = buffer.readShort(); - if (maskId != -1) { - this.mask = this.getChildAt(maskId).displayObject; - buffer.readBool(); - } - var hitTestId = buffer.readS(); - i1 = buffer.readInt(); - i2 = buffer.readInt(); - if (hitTestId != null) { - pi = contentItem.owner.getItemById(hitTestId); - if (pi && pi.pixelHitTestData) - this._rootContainer.hitArea = new fgui.PixelHitTest(pi.pixelHitTestData, i1, i2); - } - else if (i1 != 0 && i2 != -1) { - this._rootContainer.hitArea = this.getChildAt(i2).displayObject; - } - buffer.seek(0, 5); - var transitionCount = buffer.readShort(); - for (i = 0; i < transitionCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - var trans = new fgui.Transition(this); - trans.setup(buffer); - this._transitions.push(trans); - buffer.position = nextPos; - } - if (this._transitions.length > 0) { - this.displayObject.addEventListener(egret.Event.ADDED_TO_STAGE, this.___added, this); - this.displayObject.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.___removed, this); - } - this.applyAllControllers(); - this._buildingDisplayList = false; - this._underConstruct = false; - this.buildNativeDisplayList(); - this.setBoundsChangedFlag(); - if (contentItem.objectType != fgui.ObjectType.Component) - this.constructExtension(buffer); - this.onConstruct(); - }; - GComponent.prototype.onConstruct = function () { - this.constructFromXML(null); - }; - GComponent.prototype.constructExtension = function (buffer) { - }; - GComponent.prototype.constructFromXML = function (xml) { - }; - GComponent.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 4); - var pageController = buffer.readShort(); - if (pageController != -1 && this._scrollPane) - this._scrollPane.pageController = this._parent.getControllerAt(pageController); - var cnt = buffer.readShort(); - for (var i = 0; i < cnt; i++) { - var cc = this.getController(buffer.readS()); - var pageId = buffer.readS(); - if (cc) - cc.selectedPageId = pageId; - } - if (buffer.version >= 2) { - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - var target = buffer.readS(); - var propertyId = buffer.readShort(); - var value = buffer.readS(); - var obj = this.getChildByPath(target); - if (obj) - obj.setProp(propertyId, value); - } - } - }; - GComponent.prototype.___added = function (evt) { - var cnt = this._transitions.length; - for (var i = 0; i < cnt; ++i) { - this._transitions[i].onOwnerAddedToStage(); - } - }; - GComponent.prototype.___removed = function (evt) { - var cnt = this._transitions.length; - for (var i = 0; i < cnt; ++i) { - this._transitions[i].onOwnerRemovedFromStage(); - } - }; - return GComponent; - }(fgui.GObject)); - fgui.GComponent = GComponent; -})(fgui || (fgui = {})); - -(function (fgui) { - var GButton = (function (_super_1) { - __extends(GButton, _super_1); - function GButton() { - var _this = _super_1.call(this) || this; - _this._mode = fgui.ButtonMode.Common; - _this._title = ""; - _this._icon = ""; - _this._sound = fgui.UIConfig.buttonSound; - _this._soundVolumeScale = fgui.UIConfig.buttonSoundVolumeScale; - _this._changeStateOnClick = true; - _this._downEffect = 0; - _this._downEffectValue = 0.8; - return _this; - } - Object.defineProperty(GButton.prototype, "icon", { - get: function () { - return this._icon; - }, - set: function (value) { - this._icon = value; - value = (this._selected && this._selectedIcon) ? this._selectedIcon : this._icon; - if (this._iconObject) - this._iconObject.icon = value; - this.updateGear(7); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "selectedIcon", { - get: function () { - return this._selectedIcon; - }, - set: function (value) { - this._selectedIcon = value; - value = (this._selected && this._selectedIcon) ? this._selectedIcon : this._icon; - if (this._iconObject) - this._iconObject.icon = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "title", { - get: function () { - return this._title; - }, - set: function (value) { - this._title = value; - if (this._titleObject) - this._titleObject.text = (this._selected && this._selectedTitle) ? this._selectedTitle : this._title; - this.updateGear(6); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "text", { - get: function () { - return this.title; - }, - set: function (value) { - this.title = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "selectedTitle", { - get: function () { - return this._selectedTitle; - }, - set: function (value) { - this._selectedTitle = value; - if (this._titleObject) - this._titleObject.text = (this._selected && this._selectedTitle) ? this._selectedTitle : this._title; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "titleColor", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.color; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.color = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "titleFontSize", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.fontSize; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.fontSize = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "sound", { - get: function () { - return this._sound; - }, - set: function (val) { - this._sound = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "soundVolumeScale", { - get: function () { - return this._soundVolumeScale; - }, - set: function (value) { - this._soundVolumeScale = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "selected", { - get: function () { - return this._selected; - }, - set: function (val) { - if (this._mode == fgui.ButtonMode.Common) - return; - if (this._selected != val) { - this._selected = val; - if (this.grayed && this._buttonController && this._buttonController.hasPage(GButton.DISABLED)) { - if (this._selected) - this.setState(GButton.SELECTED_DISABLED); - else - this.setState(GButton.DISABLED); - } - else { - if (this._selected) - this.setState(this._over ? GButton.SELECTED_OVER : GButton.DOWN); - else - this.setState(this._over ? GButton.OVER : GButton.UP); - } - if (this._selectedTitle && this._titleObject) - this._titleObject.text = this._selected ? this._selectedTitle : this._title; - if (this._selectedIcon) { - var str = this._selected ? this._selectedIcon : this._icon; - if (this._iconObject) - this._iconObject.icon = str; - } - if (this._relatedController - && this._parent - && !this._parent._buildingDisplayList) { - if (this._selected) { - this._relatedController.selectedPageId = this._relatedPageId; - if (this._relatedController.autoRadioGroupDepth) - this._parent.adjustRadioGroupDepth(this, this._relatedController); - } - else if (this._mode == fgui.ButtonMode.Check && this._relatedController.selectedPageId == this._relatedPageId) - this._relatedController.oppositePageId = this._relatedPageId; - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "mode", { - get: function () { - return this._mode; - }, - set: function (value) { - if (this._mode != value) { - if (value == fgui.ButtonMode.Common) - this.selected = false; - this._mode = value; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "relatedController", { - get: function () { - return this._relatedController; - }, - set: function (val) { - this._relatedController = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "relatedPageId", { - get: function () { - return this._relatedPageId; - }, - set: function (val) { - this._relatedPageId = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "changeStateOnClick", { - get: function () { - return this._changeStateOnClick; - }, - set: function (value) { - this._changeStateOnClick = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "linkedPopup", { - get: function () { - return this._linkedPopup; - }, - set: function (value) { - this._linkedPopup = value; - }, - enumerable: true, - configurable: true - }); - GButton.prototype.getTextField = function () { - if (this._titleObject instanceof fgui.GTextField) - return this._titleObject; - else if ((this._titleObject instanceof fgui.GLabel) || (this._titleObject instanceof GButton)) - return this._titleObject.getTextField(); - else - return null; - }; - GButton.prototype.addStateListener = function (listener, thisObj) { - this.addEventListener(fgui.StateChangeEvent.CHANGED, listener, thisObj); - }; - GButton.prototype.removeStateListener = function (listener, thisObj) { - this.removeEventListener(fgui.StateChangeEvent.CHANGED, listener, thisObj); - }; - GButton.prototype.fireClick = function (downEffect) { - if (downEffect && this._mode == fgui.ButtonMode.Common) { - this.setState(GButton.OVER); - fgui.GTimers.inst.add(100, 1, function () { this.setState(GButton.DOWN); }, this); - fgui.GTimers.inst.add(200, 1, function () { this.setState(GButton.UP); }, this); - } - this.__click(null); - }; - GButton.prototype.setState = function (val) { - if (this._buttonController) - this._buttonController.selectedPage = val; - if (this._downEffect == 1) { - var cnt = this.numChildren; - if (val == GButton.DOWN || val == GButton.SELECTED_OVER || val == GButton.SELECTED_DISABLED) { - var r = this._downEffectValue * 255; - var color = (r << 16) + (r << 8) + r; - for (var i = 0; i < cnt; i++) { - var obj = this.getChildAt(i); - if (obj["color"] != undefined && !(obj instanceof fgui.GTextField)) - obj.color = color; - } - } - else { - for (var i = 0; i < cnt; i++) { - var obj = this.getChildAt(i); - if (obj["color"] != undefined && !(obj instanceof fgui.GTextField)) - obj.color = 0xFFFFFF; - } - } - } - else if (this._downEffect == 2) { - if (val == GButton.DOWN || val == GButton.SELECTED_OVER || val == GButton.SELECTED_DISABLED) { - if (!this._downScaled) { - this._downScaled = true; - this._rootContainer.cacheHitArea(true); - this.setScale(this.scaleX * this._downEffectValue, this.scaleY * this._downEffectValue); - } - } - else { - if (this._downScaled) { - this._downScaled = false; - this._rootContainer.cacheHitArea(false); - this.setScale(this.scaleX / this._downEffectValue, this.scaleY / this._downEffectValue); - } - } - } - }; - GButton.prototype.handleControllerChanged = function (c) { - _super_1.prototype.handleControllerChanged.call(this, c); - if (this._relatedController == c) - this.selected = this._relatedPageId == c.selectedPageId; - }; - GButton.prototype.handleGrayedChanged = function () { - if (this._buttonController && this._buttonController.hasPage(GButton.DISABLED)) { - if (this.grayed) { - if (this._selected && this._buttonController.hasPage(GButton.SELECTED_DISABLED)) - this.setState(GButton.SELECTED_DISABLED); - else - this.setState(GButton.DISABLED); - } - else if (this._selected) - this.setState(GButton.DOWN); - else - this.setState(GButton.UP); - } - else - _super_1.prototype.handleGrayedChanged.call(this); - }; - GButton.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.titleColor; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - return tf.strokeColor; - else - return 0; - } - case fgui.ObjectPropID.FontSize: - return this.titleFontSize; - case fgui.ObjectPropID.Selected: - return this.selected; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GButton.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.titleColor = value; - break; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - tf.strokeColor = value; - } - break; - case fgui.ObjectPropID.FontSize: - this.titleFontSize = value; - break; - case fgui.ObjectPropID.Selected: - this.selected = value; - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GButton.prototype.constructExtension = function (buffer) { - buffer.seek(0, 6); - this._mode = buffer.readByte(); - var str = buffer.readS(); - if (str) - this._sound = str; - this._soundVolumeScale = buffer.readFloat(); - this._downEffect = buffer.readByte(); - this._downEffectValue = buffer.readFloat(); - if (this._downEffect == 2) - this.setPivot(0.5, 0.5, this.pivotAsAnchor); - this._buttonController = this.getController("button"); - this._titleObject = this.getChild("title"); - this._iconObject = this.getChild("icon"); - if (this._titleObject) - this._title = this._titleObject.text; - if (this._iconObject) - this._icon = this._iconObject.icon; - if (this._mode == fgui.ButtonMode.Common) - this.setState(GButton.UP); - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__mousedown, this); - this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.__click, this); - }; - GButton.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!buffer.seek(beginPos, 6)) - return; - if (buffer.readByte() != this.packageItem.objectType) - return; - var str; - var iv; - str = buffer.readS(); - if (str != null) - this.title = str; - str = buffer.readS(); - if (str != null) - this.selectedTitle = str; - str = buffer.readS(); - if (str != null) - this.icon = str; - str = buffer.readS(); - if (str != null) - this.selectedIcon = str; - if (buffer.readBool()) - this.titleColor = buffer.readColor(); - iv = buffer.readInt(); - if (iv != 0) - this.titleFontSize = iv; - iv = buffer.readShort(); - if (iv >= 0) - this._relatedController = this.parent.getControllerAt(iv); - this._relatedPageId = buffer.readS(); - str = buffer.readS(); - if (str != null) - this._sound = str; - if (buffer.readBool()) - this._soundVolumeScale = buffer.readFloat(); - this.selected = buffer.readBool(); - }; - GButton.prototype.__mousedown = function (evt) { - this._down = true; - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_END, this.__mouseup, this); - if (this._mode == fgui.ButtonMode.Common) { - if (this.grayed && this._buttonController && this._buttonController.hasPage(GButton.DISABLED)) - this.setState(GButton.SELECTED_DISABLED); - else - this.setState(GButton.DOWN); - } - if (this._linkedPopup) { - if (this._linkedPopup instanceof fgui.Window) - this._linkedPopup.toggleStatus(); - else - this.root.togglePopup(this._linkedPopup, this); - } - }; - GButton.prototype.__mouseup = function (evt) { - if (this._down) { - fgui.GRoot.inst.nativeStage.removeEventListener(egret.TouchEvent.TOUCH_END, this.__mouseup, this); - this._down = false; - if (!this.displayObject) - return; - if (this._mode == fgui.ButtonMode.Common) { - if (this.grayed && this._buttonController && this._buttonController.hasPage(GButton.DISABLED)) - this.setState(GButton.DISABLED); - else if (this._over) - this.setState(GButton.OVER); - else - this.setState(GButton.UP); - } - } - }; - GButton.prototype.__click = function (evt) { - if (this._sound) { - var pi = fgui.UIPackage.getItemByURL(this._sound); - if (pi) { - var sound = pi.owner.getItemAsset(pi); - if (sound) - fgui.GRoot.inst.playOneShotSound(sound, this._soundVolumeScale); - } - } - if (this._mode == fgui.ButtonMode.Check) { - if (this._changeStateOnClick) { - this.selected = !this._selected; - this.dispatchEvent(new fgui.StateChangeEvent(fgui.StateChangeEvent.CHANGED)); - } - } - else if (this._mode == fgui.ButtonMode.Radio) { - if (this._changeStateOnClick && !this._selected) { - this.selected = true; - this.dispatchEvent(new fgui.StateChangeEvent(fgui.StateChangeEvent.CHANGED)); - } - } - else { - if (this._relatedController) - this._relatedController.selectedPageId = this._relatedPageId; - } - }; - GButton.UP = "up"; - GButton.DOWN = "down"; - GButton.OVER = "over"; - GButton.SELECTED_OVER = "selectedOver"; - GButton.DISABLED = "disabled"; - GButton.SELECTED_DISABLED = "selectedDisabled"; - return GButton; - }(fgui.GComponent)); - fgui.GButton = GButton; -})(fgui || (fgui = {})); - -(function (fgui) { - var GComboBox = (function (_super_1) { - __extends(GComboBox, _super_1); - function GComboBox() { - var _this = _super_1.call(this) || this; - _this._visibleItemCount = 0; - _this._selectedIndex = 0; - _this._popupDirection = fgui.PopupDirection.Auto; - _this._visibleItemCount = fgui.UIConfig.defaultComboBoxVisibleItemCount; - _this._itemsUpdated = true; - _this._selectedIndex = -1; - _this._items = []; - _this._values = []; - return _this; - } - Object.defineProperty(GComboBox.prototype, "text", { - get: function () { - if (this._titleObject) - return this._titleObject.text; - else - return null; - }, - set: function (value) { - if (this._titleObject) - this._titleObject.text = value; - this.updateGear(6); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "icon", { - get: function () { - if (this._iconObject) - return this._iconObject.icon; - else - return null; - }, - set: function (value) { - if (this._iconObject) - this._iconObject.icon = value; - this.updateGear(7); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "titleColor", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.color; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.color = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "titleFontSize", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.fontSize; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.fontSize = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "visibleItemCount", { - get: function () { - return this._visibleItemCount; - }, - set: function (value) { - this._visibleItemCount = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "popupDirection", { - get: function () { - return this._popupDirection; - }, - set: function (value) { - this._popupDirection = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "items", { - get: function () { - return this._items; - }, - set: function (value) { - if (!value) - this._items.length = 0; - else - this._items = value.concat(); - if (this._items.length > 0) { - if (this._selectedIndex >= this._items.length) - this._selectedIndex = this._items.length - 1; - else if (this._selectedIndex == -1) - this._selectedIndex = 0; - this.text = this._items[this._selectedIndex]; - if (this._icons && this._selectedIndex < this._icons.length) - this.icon = this._icons[this._selectedIndex]; - } - else { - this.text = ""; - if (this._icons) - this.icon = null; - this._selectedIndex = -1; - } - this._itemsUpdated = true; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "icons", { - get: function () { - return this._icons; - }, - set: function (value) { - this._icons = value; - if (this._icons && this._selectedIndex != -1 && this._selectedIndex < this._icons.length) - this.icon = this._icons[this._selectedIndex]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "values", { - get: function () { - return this._values; - }, - set: function (value) { - if (!value) - this._values.length = 0; - else - this._values = value.concat(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "selectedIndex", { - get: function () { - return this._selectedIndex; - }, - set: function (val) { - if (this._selectedIndex == val) - return; - this._selectedIndex = val; - if (this._selectedIndex >= 0 && this._selectedIndex < this._items.length) { - this.text = this._items[this._selectedIndex]; - if (this._icons && this._selectedIndex < this._icons.length) - this.icon = this._icons[this._selectedIndex]; - } - else { - this.text = ""; - if (this._icons) - this.icon = null; - } - this.updateSelectionController(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "value", { - get: function () { - return this._values[this._selectedIndex]; - }, - set: function (val) { - var index = this._values.indexOf(val); - if (index == -1 && val == null) - index = this._values.indexOf(""); - this.selectedIndex = index; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "selectionController", { - get: function () { - return this._selectionController; - }, - set: function (value) { - this._selectionController = value; - }, - enumerable: true, - configurable: true - }); - GComboBox.prototype.getTextField = function () { - if (this._titleObject instanceof fgui.GTextField) - return this._titleObject; - else if ((this._titleObject instanceof fgui.GLabel) || (this._titleObject instanceof fgui.GButton)) - return this._titleObject.getTextField(); - else - return null; - }; - GComboBox.prototype.setState = function (val) { - if (this._buttonController) - this._buttonController.selectedPage = val; - }; - GComboBox.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.titleColor; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - return tf.strokeColor; - else - return 0; - } - case fgui.ObjectPropID.FontSize: - { - tf = this.getTextField(); - if (tf) - return tf.fontSize; - else - return 0; - } - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GComboBox.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.titleColor = value; - break; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - tf.strokeColor = value; - } - break; - case fgui.ObjectPropID.FontSize: - { - tf = this.getTextField(); - if (tf) - tf.fontSize = value; - } - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GComboBox.prototype.constructExtension = function (buffer) { - var str; - this._buttonController = this.getController("button"); - this._titleObject = this.getChild("title"); - this._iconObject = this.getChild("icon"); - str = buffer.readS(); - if (str) { - this.dropdown = (fgui.UIPackage.createObjectFromURL(str)); - if (!this.dropdown) { - console.error("下拉框必须为元件"); - return; - } - this.dropdown.name = "this.dropdown"; - this._list = this.dropdown.getChild("list").asList; - if (this._list == null) { - console.error(this.resourceURL + ": 下拉框的弹出元件里必须包含名为list的列表"); - return; - } - this._list.addEventListener(fgui.ItemEvent.CLICK, this.__clickItem, this); - this._list.addRelation(this.dropdown, fgui.RelationType.Width); - this._list.removeRelation(this.dropdown, fgui.RelationType.Height); - this.dropdown.addRelation(this._list, fgui.RelationType.Height); - this.dropdown.removeRelation(this._list, fgui.RelationType.Width); - this.dropdown.displayObject.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.__popupWinClosed, this); - } - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__mousedown, this); - }; - GComboBox.prototype.handleControllerChanged = function (c) { - _super_1.prototype.handleControllerChanged.call(this, c); - if (this._selectionController == c) - this.selectedIndex = c.selectedIndex; - }; - GComboBox.prototype.updateSelectionController = function () { - if (this._selectionController && !this._selectionController.changing - && this._selectedIndex < this._selectionController.pageCount) { - var c = this._selectionController; - this._selectionController = null; - c.selectedIndex = this._selectedIndex; - this._selectionController = c; - } - }; - GComboBox.prototype.dispose = function () { - if (this.dropdown) { - this.dropdown.dispose(); - this.dropdown = null; - } - _super_1.prototype.dispose.call(this); - }; - GComboBox.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!buffer.seek(beginPos, 6)) - return; - if (buffer.readByte() != this.packageItem.objectType) - return; - var i; - var iv; - var nextPos; - var str; - var itemCount = buffer.readShort(); - for (i = 0; i < itemCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - this._items[i] = buffer.readS(); - this._values[i] = buffer.readS(); - str = buffer.readS(); - if (str != null) { - if (this._icons == null) - this._icons = new Array(); - this._icons[i] = str; - } - buffer.position = nextPos; - } - str = buffer.readS(); - if (str != null) { - this.text = str; - this._selectedIndex = this._items.indexOf(str); - } - else if (this._items.length > 0) { - this._selectedIndex = 0; - this.text = this._items[0]; - } - else - this._selectedIndex = -1; - str = buffer.readS(); - if (str != null) - this.icon = str; - if (buffer.readBool()) - this.titleColor = buffer.readColor(); - iv = buffer.readInt(); - if (iv > 0) - this._visibleItemCount = iv; - this._popupDirection = buffer.readByte(); - iv = buffer.readShort(); - if (iv >= 0) - this._selectionController = this.parent.getControllerAt(iv); - }; - GComboBox.prototype.showDropdown = function () { - if (this._itemsUpdated) { - this._itemsUpdated = false; - this._list.removeChildrenToPool(); - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._list.addItemFromPool(); - item.name = i < this._values.length ? this._values[i] : ""; - item.text = this._items[i]; - item.icon = (this._icons && i < this._icons.length) ? this._icons[i] : null; - } - this._list.resizeToFit(this._visibleItemCount); - } - this._list.selectedIndex = -1; - this.dropdown.width = this.width; - this._list.ensureBoundsCorrect(); - this.root.togglePopup(this.dropdown, this, this._popupDirection); - if (this.dropdown.parent) - this.setState(fgui.GButton.DOWN); - }; - GComboBox.prototype.__popupWinClosed = function (evt) { - if (this._over) - this.setState(fgui.GButton.OVER); - else - this.setState(fgui.GButton.UP); - }; - GComboBox.prototype.__clickItem = function (evt) { - fgui.GTimers.inst.add(100, 1, this.__clickItem2, this, this._list.getChildIndex(evt.itemObject)); - }; - GComboBox.prototype.__clickItem2 = function (index) { - if (this.dropdown.parent instanceof fgui.GRoot) - this.dropdown.parent.hidePopup(); - this._selectedIndex = -1; - this.selectedIndex = index; - this.dispatchEvent(new fgui.StateChangeEvent(fgui.StateChangeEvent.CHANGED)); - }; - GComboBox.prototype.__mousedown = function (evt) { - if ((evt.target instanceof egret.TextField) && evt.target.type == egret.TextFieldType.INPUT) - return; - this._down = true; - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_END, this.__mouseup, this); - if (this.dropdown) - this.showDropdown(); - }; - GComboBox.prototype.__mouseup = function (evt) { - if (this._down) { - this._down = false; - fgui.GRoot.inst.nativeStage.removeEventListener(egret.TouchEvent.TOUCH_END, this.__mouseup, this); - if (this.dropdown && !this.dropdown.parent) { - if (this._over) - this.setState(fgui.GButton.OVER); - else - this.setState(fgui.GButton.UP); - } - } - }; - return GComboBox; - }(fgui.GComponent)); - fgui.GComboBox = GComboBox; -})(fgui || (fgui = {})); - -(function (fgui) { - var GGraph = (function (_super_1) { - __extends(GGraph, _super_1); - function GGraph() { - var _this = _super_1.call(this) || this; - _this._type = 0; - _this._lineSize = 0; - _this._lineColor = 0; - _this._fillColor = 0; - _this._lineSize = 1; - _this._lineAlpha = 1; - _this._fillAlpha = 1; - _this._fillColor = 0xFFFFFF; - return _this; - } - Object.defineProperty(GGraph.prototype, "graphics", { - get: function () { - return this._graphics; - }, - enumerable: true, - configurable: true - }); - GGraph.prototype.drawRect = function (lineSize, lineColor, lineAlpha, fillColor, fillAlpha, corner) { - this._type = 1; - this._lineSize = lineSize; - this._lineColor = lineColor; - this._lineAlpha = lineAlpha; - this._fillColor = fillColor; - this._fillAlpha = fillAlpha; - this._cornerRadius = corner; - this.updateGraph(); - }; - GGraph.prototype.drawEllipse = function (lineSize, lineColor, lineAlpha, fillColor, fillAlpha) { - this._type = 2; - this._lineSize = lineSize; - this._lineColor = lineColor; - this._lineAlpha = lineAlpha; - this._fillColor = fillColor; - this._fillAlpha = fillAlpha; - this._cornerRadius = null; - this.updateGraph(); - }; - GGraph.prototype.drawRegularPolygon = function (lineSize, lineColor, lineAlpha, fillColor, fillAlpha, sides, startAngle, distances) { - this._type = 4; - this._lineSize = lineSize; - this._lineColor = lineColor; - this._lineAlpha = lineAlpha; - this._fillColor = fillColor; - this._fillAlpha = fillAlpha; - this._sides = sides; - this._startAngle = startAngle || 0; - this._distances = distances; - this.updateGraph(); - }; - GGraph.prototype.drawPolygon = function (lineSize, lineColor, lineAlpha, fillColor, fillAlpha, points) { - this._type = 3; - this._lineSize = lineSize; - this._lineColor = lineColor; - this._lineAlpha = lineAlpha; - this._fillColor = fillColor; - this._fillAlpha = fillAlpha; - this._polygonPoints = points; - this.updateGraph(); - }; - Object.defineProperty(GGraph.prototype, "distances", { - get: function () { - return this._distances; - }, - set: function (value) { - this._distances = value; - if (this._type == 3) - this.updateGraph(); - }, - enumerable: true, - configurable: true - }); - GGraph.prototype.clearGraphics = function () { - if (this._graphics) { - this._type = 0; - this._graphics.clear(); - } - }; - Object.defineProperty(GGraph.prototype, "color", { - get: function () { - return this._fillColor; - }, - set: function (value) { - this._fillColor = value; - if (this._type != 0) - this.updateGraph(); - }, - enumerable: true, - configurable: true - }); - GGraph.prototype.updateGraph = function () { - var ctx = this.graphics; - ctx.clear(); - var w = this.width; - var h = this.height; - if (w == 0 || h == 0) - return; - if (this._lineSize == 0) - ctx.lineStyle(0, 0, 0); - else - ctx.lineStyle(this._lineSize, this._lineColor, this._lineAlpha); - ctx.beginFill(this._fillColor, this._fillAlpha); - if (this._type == 1) { - if (this._cornerRadius) { - if (this._cornerRadius.length == 1) - ctx.drawRoundRect(0, 0, w, h, this._cornerRadius[0] * 2, this._cornerRadius[0] * 2); - else - ctx.drawRoundRect(0, 0, w, h, this._cornerRadius[0] * 2, this._cornerRadius[1] * 2); - } - else - ctx.drawRect(0, 0, w, h); - } - else if (this._type == 2) - ctx.drawEllipse(0, 0, w, h); - else if (this._type == 3) { - fgui.ToolSet.fillPath(ctx, this._polygonPoints, 0, 0); - } - else if (this._type == 4) { - if (!this._polygonPoints) - this._polygonPoints = []; - var radius = Math.min(this._width, this._height) / 2; - this._polygonPoints.length = 0; - var angle = this._startAngle * Math.PI / 180; - var deltaAngle = 2 * Math.PI / this._sides; - var dist; - for (var i = 0; i < this._sides; i++) { - if (this._distances) { - dist = this._distances[i]; - if (isNaN(dist)) - dist = 1; - } - else - dist = 1; - var xv = radius + radius * dist * Math.cos(angle); - var yv = radius + radius * dist * Math.sin(angle); - this._polygonPoints.push(xv, yv); - angle += deltaAngle; - } - fgui.ToolSet.fillPath(ctx, this._polygonPoints, 0, 0); - } - ctx.endFill(); - }; - GGraph.prototype.replaceMe = function (target) { - if (!this._parent) - throw "parent not set"; - target.name = this.name; - target.alpha = this.alpha; - target.rotation = this.rotation; - target.visible = this.visible; - target.touchable = this.touchable; - target.grayed = this.grayed; - target.setXY(this.x, this.y); - target.setSize(this.width, this.height); - var index = this._parent.getChildIndex(this); - this._parent.addChildAt(target, index); - target.relations.copyFrom(this.relations); - this._parent.removeChild(this, true); - }; - GGraph.prototype.addBeforeMe = function (target) { - if (this._parent == null) - throw "parent not set"; - var index = this._parent.getChildIndex(this); - this._parent.addChildAt(target, index); - }; - GGraph.prototype.addAfterMe = function (target) { - if (this._parent == null) - throw "parent not set"; - var index = this._parent.getChildIndex(this); - index++; - this._parent.addChildAt(target, index); - }; - GGraph.prototype.setNativeObject = function (obj) { - var sprite = new egret.Sprite(); - this.setDisplayObject(sprite); - if (this._parent) - this._parent.childStateChanged(this); - this.handleXYChanged(); - sprite.alpha = this.alpha; - sprite.rotation = this.rotation; - sprite.visible = this.visible; - sprite.touchEnabled = this.touchable; - sprite.touchChildren = this.touchable; - sprite.addChild(obj); - }; - GGraph.prototype.createDisplayObject = function () { - var sprite = new egret.Sprite(); - sprite.touchEnabled = true; - this._graphics = sprite.graphics; - this.setDisplayObject(sprite); - }; - GGraph.prototype.getProp = function (index) { - if (index == fgui.ObjectPropID.Color) - return this.color; - else - return _super_1.prototype.getProp.call(this, index); - }; - GGraph.prototype.setProp = function (index, value) { - if (index == fgui.ObjectPropID.Color) - this.color = value; - else - _super_1.prototype.setProp.call(this, index, value); - }; - GGraph.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (this._type != 0) - this.updateGraph(); - }; - GGraph.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._type = buffer.readByte(); - if (this._type != 0) { - var i; - var cnt; - this._lineSize = buffer.readInt(); - var c = buffer.readColor(true); - this._lineColor = c & 0xFFFFFF; - this._lineAlpha = ((c >> 24) & 0xFF) / 0xFF; - c = buffer.readColor(true); - this._fillColor = c & 0xFFFFFF; - this._fillAlpha = ((c >> 24) & 0xFF) / 0xFF; - if (buffer.readBool()) { - this._cornerRadius = new Array(4); - for (i = 0; i < 4; i++) - this._cornerRadius[i] = buffer.readFloat(); - } - if (this._type == 3) { - cnt = buffer.readShort(); - this._polygonPoints = []; - this._polygonPoints.length = cnt; - for (i = 0; i < cnt; i++) - this._polygonPoints[i] = buffer.readFloat(); - } - else if (this._type == 4) { - this._sides = buffer.readShort(); - this._startAngle = buffer.readFloat(); - cnt = buffer.readShort(); - if (cnt > 0) { - this._distances = []; - for (i = 0; i < cnt; i++) - this._distances[i] = buffer.readFloat(); - } - } - this.updateGraph(); - } - }; - return GGraph; - }(fgui.GObject)); - fgui.GGraph = GGraph; -})(fgui || (fgui = {})); - -(function (fgui) { - var GGroup = (function (_super_1) { - __extends(GGroup, _super_1); - function GGroup() { - var _this = _super_1.call(this) || this; - _this._layout = 0; - _this._lineGap = 0; - _this._columnGap = 0; - _this._mainGridIndex = -1; - _this._mainGridMinSize = 50; - _this._mainChildIndex = -1; - _this._totalSize = 0; - _this._numChildren = 0; - _this._updating = 0; - return _this; - } - GGroup.prototype.dispose = function () { - this._boundsChanged = false; - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GGroup.prototype, "layout", { - get: function () { - return this._layout; - }, - set: function (value) { - if (this._layout != value) { - this._layout = value; - this.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "lineGap", { - get: function () { - return this._lineGap; - }, - set: function (value) { - if (this._lineGap != value) { - this._lineGap = value; - this.setBoundsChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "columnGap", { - get: function () { - return this._columnGap; - }, - set: function (value) { - if (this._columnGap != value) { - this._columnGap = value; - this.setBoundsChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "excludeInvisibles", { - get: function () { - return this._excludeInvisibles; - }, - set: function (value) { - if (this._excludeInvisibles != value) { - this._excludeInvisibles = value; - this.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "autoSizeDisabled", { - get: function () { - return this._autoSizeDisabled; - }, - set: function (value) { - this._autoSizeDisabled = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "mainGridMinSize", { - get: function () { - return this._mainGridMinSize; - }, - set: function (value) { - if (this._mainGridMinSize != value) { - this._mainGridMinSize = value; - this.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "mainGridIndex", { - get: function () { - return this._mainGridIndex; - }, - set: function (value) { - if (this._mainGridIndex != value) { - this._mainGridIndex = value; - this.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - GGroup.prototype.setBoundsChangedFlag = function (positionChangedOnly) { - if (this._updating == 0 && this._parent) { - if (!positionChangedOnly) - this._percentReady = false; - if (!this._boundsChanged) { - this._boundsChanged = true; - if (this._layout != fgui.GroupLayoutType.None) - fgui.GTimers.inst.callLater(this.ensureBoundsCorrect, this); - } - } - }; - GGroup.prototype.ensureSizeCorrect = function () { - if (this._parent == null || !this._boundsChanged || this._layout == 0) - return; - this._boundsChanged = false; - if (this._autoSizeDisabled) - this.resizeChildren(0, 0); - else { - this.handleLayout(); - this.updateBounds(); - } - }; - GGroup.prototype.ensureBoundsCorrect = function () { - if (this._parent == null || !this._boundsChanged) - return; - this._boundsChanged = false; - if (this._layout == 0) - this.updateBounds(); - else { - if (this._autoSizeDisabled) - this.resizeChildren(0, 0); - else { - this.handleLayout(); - this.updateBounds(); - } - } - }; - GGroup.prototype.updateBounds = function () { - fgui.GTimers.inst.remove(this.ensureBoundsCorrect, this); - var cnt = this._parent.numChildren; - var i; - var child; - var ax = Number.POSITIVE_INFINITY, ay = Number.POSITIVE_INFINITY; - var ar = Number.NEGATIVE_INFINITY, ab = Number.NEGATIVE_INFINITY; - var tmp; - var empty = true; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this || this._excludeInvisibles && !child.internalVisible3) - continue; - tmp = child.xMin; - if (tmp < ax) - ax = tmp; - tmp = child.yMin; - if (tmp < ay) - ay = tmp; - tmp = child.xMin + child.width; - if (tmp > ar) - ar = tmp; - tmp = child.yMin + child.height; - if (tmp > ab) - ab = tmp; - empty = false; - } - var w = 0, h = 0; - if (!empty) { - this._updating |= 1; - this.setXY(ax, ay); - this._updating &= 2; - w = ar - ax; - h = ab - ay; - } - if ((this._updating & 2) == 0) { - this._updating |= 2; - this.setSize(w, h); - this._updating &= 1; - } - else { - this._updating &= 1; - this.resizeChildren(this._width - w, this._height - h); - } - }; - GGroup.prototype.handleLayout = function () { - this._updating |= 1; - var child; - var i; - var cnt; - if (this._layout == fgui.GroupLayoutType.Horizontal) { - var curX = this.x; - cnt = this._parent.numChildren; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (this._excludeInvisibles && !child.internalVisible3) - continue; - child.xMin = curX; - if (child.width != 0) - curX += child.width + this._columnGap; - } - } - else if (this._layout == fgui.GroupLayoutType.Vertical) { - var curY = this.y; - cnt = this._parent.numChildren; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (this._excludeInvisibles && !child.internalVisible3) - continue; - child.yMin = curY; - if (child.height != 0) - curY += child.height + this._lineGap; - } - } - this._updating &= 2; - }; - GGroup.prototype.moveChildren = function (dx, dy) { - if ((this._updating & 1) != 0 || this._parent == null) - return; - this._updating |= 1; - var cnt = this._parent.numChildren; - var i; - var child; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group == this) { - child.setXY(child.x + dx, child.y + dy); - } - } - this._updating &= 2; - }; - GGroup.prototype.resizeChildren = function (dw, dh) { - if (this._layout == fgui.GroupLayoutType.None || (this._updating & 2) != 0 || this._parent == null) - return; - this._updating |= 2; - if (this._boundsChanged) { - this._boundsChanged = false; - if (!this._autoSizeDisabled) { - this.updateBounds(); - return; - } - } - var cnt = this._parent.numChildren; - var i; - var child; - if (!this._percentReady) { - this._percentReady = true; - this._numChildren = 0; - this._totalSize = 0; - this._mainChildIndex = -1; - var j = 0; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (!this._excludeInvisibles || child.internalVisible3) { - if (j == this._mainGridIndex) - this._mainChildIndex = i; - this._numChildren++; - if (this._layout == 1) - this._totalSize += child.width; - else - this._totalSize += child.height; - } - j++; - } - if (this._mainChildIndex != -1) { - if (this._layout == 1) { - child = this._parent.getChildAt(this._mainChildIndex); - this._totalSize += this._mainGridMinSize - child.width; - child._sizePercentInGroup = this._mainGridMinSize / this._totalSize; - } - else { - child = this._parent.getChildAt(this._mainChildIndex); - this._totalSize += this._mainGridMinSize - child.height; - child._sizePercentInGroup = this._mainGridMinSize / this._totalSize; - } - } - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (i == this._mainChildIndex) - continue; - if (this._totalSize > 0) - child._sizePercentInGroup = (this._layout == 1 ? child.width : child.height) / this._totalSize; - else - child._sizePercentInGroup = 0; - } - } - var remainSize = 0; - var remainPercent = 1; - var priorHandled = false; - if (this._layout == 1) { - remainSize = this.width - (this._numChildren - 1) * this._columnGap; - if (this._mainChildIndex != -1 && remainSize >= this._totalSize) { - child = this._parent.getChildAt(this._mainChildIndex); - child.setSize(remainSize - (this._totalSize - this._mainGridMinSize), child._rawHeight + dh, true); - remainSize -= child.width; - remainPercent -= child._sizePercentInGroup; - priorHandled = true; - } - var curX = this.x; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (this._excludeInvisibles && !child.internalVisible3) { - child.setSize(child._rawWidth, child._rawHeight + dh, true); - continue; - } - if (!priorHandled || i != this._mainChildIndex) { - child.setSize(Math.round(child._sizePercentInGroup / remainPercent * remainSize), child._rawHeight + dh, true); - remainPercent -= child._sizePercentInGroup; - remainSize -= child.width; - } - child.xMin = curX; - if (child.width != 0) - curX += child.width + this._columnGap; - } - } - else { - remainSize = this.height - (this._numChildren - 1) * this._lineGap; - if (this._mainChildIndex != -1 && remainSize >= this._totalSize) { - child = this._parent.getChildAt(this._mainChildIndex); - child.setSize(child._rawWidth + dw, remainSize - (this._totalSize - this._mainGridMinSize), true); - remainSize -= child.height; - remainPercent -= child._sizePercentInGroup; - priorHandled = true; - } - var curY = this.y; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (this._excludeInvisibles && !child.internalVisible3) { - child.setSize(child._rawWidth + dw, child._rawHeight, true); - continue; - } - if (!priorHandled || i != this._mainChildIndex) { - child.setSize(child._rawWidth + dw, Math.round(child._sizePercentInGroup / remainPercent * remainSize), true); - remainPercent -= child._sizePercentInGroup; - remainSize -= child.height; - } - child.yMin = curY; - if (child.height != 0) - curY += child.height + this._lineGap; - } - } - this._updating &= 1; - }; - GGroup.prototype.handleAlphaChanged = function () { - if (this._underConstruct) - return; - var cnt = this._parent.numChildren; - for (var i = 0; i < cnt; i++) { - var child = this._parent.getChildAt(i); - if (child.group == this) - child.alpha = this.alpha; - } - }; - GGroup.prototype.handleVisibleChanged = function () { - if (!this._parent) - return; - var cnt = this._parent.numChildren; - for (var i = 0; i < cnt; i++) { - var child = this._parent.getChildAt(i); - if (child.group == this) - child.handleVisibleChanged(); - } - }; - GGroup.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._layout = buffer.readByte(); - this._lineGap = buffer.readInt(); - this._columnGap = buffer.readInt(); - if (buffer.version >= 2) { - this._excludeInvisibles = buffer.readBool(); - this._autoSizeDisabled = buffer.readBool(); - this._mainChildIndex = buffer.readInt(); - } - }; - GGroup.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!this.visible) - this.handleVisibleChanged(); - }; - return GGroup; - }(fgui.GObject)); - fgui.GGroup = GGroup; -})(fgui || (fgui = {})); - -(function (fgui) { - var GImage = (function (_super_1) { - __extends(GImage, _super_1); - function GImage() { - var _this = _super_1.call(this) || this; - _this._flip = fgui.FlipType.None; - return _this; - } - Object.defineProperty(GImage.prototype, "color", { - get: function () { - return this._content.color; - }, - set: function (value) { - if (this._content.color != value) { - this._content.color = value; - this.updateGear(4); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "flip", { - get: function () { - return this._flip; - }, - set: function (value) { - if (this._flip != value) { - this._flip = value; - var sx = 1, sy = 1; - if (this._flip == fgui.FlipType.Horizontal || this._flip == fgui.FlipType.Both) - sx = -1; - if (this._flip == fgui.FlipType.Vertical || this._flip == fgui.FlipType.Both) - sy = -1; - this._content.scaleX = sx; - this._content.scaleY = sy; - this.handleXYChanged(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "fillMethod", { - get: function () { - return this._content.fillMethod; - }, - set: function (value) { - this._content.fillMethod = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "fillOrigin", { - get: function () { - return this._content.fillOrigin; - }, - set: function (value) { - this._content.fillOrigin = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "fillClockwise", { - get: function () { - return this._content.fillClockwise; - }, - set: function (value) { - this._content.fillClockwise = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "fillAmount", { - get: function () { - return this._content.fillAmount; - }, - set: function (value) { - this._content.fillAmount = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "texture", { - get: function () { - return this._content.texture; - }, - set: function (value) { - if (value) { - this.sourceWidth = value.textureWidth; - this.sourceHeight = value.textureHeight; - } - else { - this.sourceWidth = 0; - this.sourceHeight = 0; - } - this.initWidth = this.sourceWidth; - this.initHeight = this.sourceHeight; - this._content.scale9Grid = null; - this._content.fillMode = egret.BitmapFillMode.SCALE; - this._content.texture = value; - }, - enumerable: true, - configurable: true - }); - GImage.prototype.createDisplayObject = function () { - this._content = new fgui.Image(); - this._content.touchEnabled = false; - this.setDisplayObject(this._content); - }; - GImage.prototype.constructFromResource = function () { - var contentItem = this.packageItem.getBranch(); - this.sourceWidth = contentItem.width; - this.sourceHeight = contentItem.height; - this.initWidth = this.sourceWidth; - this.initHeight = this.sourceHeight; - this.setSize(this.sourceWidth, this.sourceHeight); - contentItem = contentItem.getHighResolution(); - contentItem.load(); - this._content.scale9Grid = contentItem.scale9Grid; - this._content.smoothing = contentItem.smoothing; - if (contentItem.scaleByTile) - this._content.fillMode = egret.BitmapFillMode.REPEAT; - this.setSize(this.sourceWidth, this.sourceHeight); - this._content.texture = contentItem.asset; - }; - GImage.prototype.handleXYChanged = function () { - _super_1.prototype.handleXYChanged.call(this); - if (this._flip != fgui.FlipType.None) { - if (this._content.scaleX == -1) - this._content.x += this.width; - if (this._content.scaleY == -1) - this._content.y += this.height; - } - }; - GImage.prototype.getProp = function (index) { - if (index == fgui.ObjectPropID.Color) - return this.color; - else - return _super_1.prototype.getProp.call(this, index); - }; - GImage.prototype.setProp = function (index, value) { - if (index == fgui.ObjectPropID.Color) - this.color = value; - else - _super_1.prototype.setProp.call(this, index, value); - }; - GImage.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - if (buffer.readBool()) - this.color = buffer.readColor(); - this.flip = buffer.readByte(); - this._content.fillMethod = buffer.readByte(); - if (this._content.fillMethod != 0) { - this._content.fillOrigin = buffer.readByte(); - this._content.fillClockwise = buffer.readBool(); - this._content.fillAmount = buffer.readFloat(); - } - }; - return GImage; - }(fgui.GObject)); - fgui.GImage = GImage; -})(fgui || (fgui = {})); - -(function (fgui) { - var GLabel = (function (_super_1) { - __extends(GLabel, _super_1); - function GLabel() { - return _super_1.call(this) || this; - } - Object.defineProperty(GLabel.prototype, "icon", { - get: function () { - if (this._iconObject) - return this._iconObject.icon; - }, - set: function (value) { - if (this._iconObject) - this._iconObject.icon = value; - this.updateGear(7); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLabel.prototype, "title", { - get: function () { - if (this._titleObject) - return this._titleObject.text; - else - return null; - }, - set: function (value) { - if (this._titleObject) - this._titleObject.text = value; - this.updateGear(6); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLabel.prototype, "text", { - get: function () { - return this.title; - }, - set: function (value) { - this.title = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLabel.prototype, "titleColor", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.color; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.color = value; - this.updateGear(4); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLabel.prototype, "titleFontSize", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.fontSize; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.fontSize = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLabel.prototype, "editable", { - get: function () { - if (this._titleObject && (this._titleObject instanceof fgui.GTextInput)) - return this._titleObject.asTextInput.editable; - else - return false; - }, - set: function (val) { - if (this._titleObject) - this._titleObject.asTextInput.editable = val; - }, - enumerable: true, - configurable: true - }); - GLabel.prototype.getTextField = function () { - if (this._titleObject instanceof fgui.GTextField) - return this._titleObject; - else if ((this._titleObject instanceof GLabel) || (this._titleObject instanceof fgui.GButton)) - return this._titleObject.getTextField(); - else - return null; - }; - GLabel.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.titleColor; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - return tf.strokeColor; - else - return 0; - } - case fgui.ObjectPropID.FontSize: - return this.titleFontSize; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GLabel.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.titleColor = value; - break; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - tf.strokeColor = value; - } - break; - case fgui.ObjectPropID.FontSize: - this.titleFontSize = value; - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GLabel.prototype.constructExtension = function (buffer) { - this._titleObject = this.getChild("title"); - this._iconObject = this.getChild("icon"); - }; - GLabel.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!buffer.seek(beginPos, 6)) - return; - if (buffer.readByte() != this.packageItem.objectType) - return; - var str; - str = buffer.readS(); - if (str != null) - this.title = str; - str = buffer.readS(); - if (str != null) - this.icon = str; - if (buffer.readBool()) - this.titleColor = buffer.readColor(); - var iv = buffer.readInt(); - if (iv != 0) - this.titleFontSize = iv; - if (buffer.readBool()) { - var input = this.getTextField(); - if (input instanceof fgui.GTextInput) { - str = buffer.readS(); - if (str != null) - input.promptText = str; - str = buffer.readS(); - if (str != null) - input.restrict = str; - iv = buffer.readInt(); - if (iv != 0) - input.maxLength = iv; - iv = buffer.readInt(); - if (iv != 0) { - } - if (buffer.readBool()) - input.password = true; - } - else - buffer.skip(13); - } - }; - return GLabel; - }(fgui.GComponent)); - fgui.GLabel = GLabel; -})(fgui || (fgui = {})); - -(function (fgui) { - var GList = (function (_super_1) { - __extends(GList, _super_1); - function GList() { - var _this = _super_1.call(this) || this; - _this.scrollItemToViewOnClick = true; - _this.foldInvisibleItems = false; - _this._lineCount = 0; - _this._columnCount = 0; - _this._lineGap = 0; - _this._columnGap = 0; - _this._lastSelectedIndex = 0; - _this._numItems = 0; - _this._realNumItems = 0; - _this._firstIndex = 0; - _this._curLineItemCount = 0; - _this._curLineItemCount2 = 0; - _this._virtualListChanged = 0; - _this.itemInfoVer = 0; - _this._trackBounds = true; - _this._pool = new fgui.GObjectPool(); - _this._layout = fgui.ListLayoutType.SingleColumn; - _this._autoResizeItem = true; - _this._lastSelectedIndex = -1; - _this._selectionMode = fgui.ListSelectionMode.Single; - _this.opaque = true; - _this._align = fgui.AlignType.Left; - _this._verticalAlign = fgui.VertAlignType.Top; - _this._container = new egret.DisplayObjectContainer(); - _this._rootContainer.addChild(_this._container); - return _this; - } - GList.prototype.dispose = function () { - this._pool.clear(); - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GList.prototype, "layout", { - get: function () { - return this._layout; - }, - set: function (value) { - if (this._layout != value) { - this._layout = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "lineCount", { - get: function () { - return this._lineCount; - }, - set: function (value) { - if (this._lineCount != value) { - this._lineCount = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "columnCount", { - get: function () { - return this._columnCount; - }, - set: function (value) { - if (this._columnCount != value) { - this._columnCount = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "lineGap", { - get: function () { - return this._lineGap; - }, - set: function (value) { - if (this._lineGap != value) { - this._lineGap = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "columnGap", { - get: function () { - return this._columnGap; - }, - set: function (value) { - if (this._columnGap != value) { - this._columnGap = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "align", { - get: function () { - return this._align; - }, - set: function (value) { - if (this._align != value) { - this._align = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "verticalAlign", { - get: function () { - return this._verticalAlign; - }, - set: function (value) { - if (this._verticalAlign != value) { - this._verticalAlign = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "virtualItemSize", { - get: function () { - return this._itemSize; - }, - set: function (value) { - if (this._virtual) { - if (!this._itemSize) - this._itemSize = new egret.Point(); - this._itemSize.copyFrom(value); - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "defaultItem", { - get: function () { - return this._defaultItem; - }, - set: function (val) { - this._defaultItem = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "autoResizeItem", { - get: function () { - return this._autoResizeItem; - }, - set: function (value) { - if (this._autoResizeItem != value) { - this._autoResizeItem = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "selectionMode", { - get: function () { - return this._selectionMode; - }, - set: function (value) { - this._selectionMode = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "selectionController", { - get: function () { - return this._selectionController; - }, - set: function (value) { - this._selectionController = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "itemPool", { - get: function () { - return this._pool; - }, - enumerable: true, - configurable: true - }); - GList.prototype.getFromPool = function (url) { - if (!url) - url = this._defaultItem; - var obj = this._pool.getObject(url); - if (obj) - obj.visible = true; - return obj; - }; - GList.prototype.returnToPool = function (obj) { - obj.displayObject.cacheAsBitmap = false; - this._pool.returnObject(obj); - }; - GList.prototype.addChildAt = function (child, index) { - _super_1.prototype.addChildAt.call(this, child, index); - if (child instanceof fgui.GButton) { - child.selected = false; - child.changeStateOnClick = false; - } - child.addEventListener(egret.TouchEvent.TOUCH_TAP, this.__clickItem, this); - return child; - }; - GList.prototype.addItem = function (url) { - if (!url) - url = this._defaultItem; - return this.addChild(fgui.UIPackage.createObjectFromURL(url)); - }; - GList.prototype.addItemFromPool = function (url) { - return this.addChild(this.getFromPool(url)); - }; - GList.prototype.removeChildAt = function (index, dispose) { - var child = _super_1.prototype.removeChildAt.call(this, index, dispose); - child.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.__clickItem, this); - return child; - }; - GList.prototype.removeChildToPoolAt = function (index) { - var child = _super_1.prototype.removeChildAt.call(this, index); - this.returnToPool(child); - }; - GList.prototype.removeChildToPool = function (child) { - _super_1.prototype.removeChild.call(this, child); - this.returnToPool(child); - }; - GList.prototype.removeChildrenToPool = function (beginIndex, endIndex) { - if (beginIndex == undefined) - beginIndex = 0; - if (endIndex == undefined) - endIndex = -1; - if (endIndex < 0 || endIndex >= this._children.length) - endIndex = this._children.length - 1; - for (var i = beginIndex; i <= endIndex; ++i) - this.removeChildToPoolAt(beginIndex); - }; - Object.defineProperty(GList.prototype, "selectedIndex", { - get: function () { - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if ((ii.obj instanceof fgui.GButton) && ii.obj.selected - || ii.obj == null && ii.selected) { - if (this._loop) - return i % this._numItems; - else - return i; - } - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if ((obj instanceof fgui.GButton) && obj.selected) - return i; - } - } - return -1; - }, - set: function (value) { - if (value >= 0 && value < this.numItems) { - if (this._selectionMode != fgui.ListSelectionMode.Single) - this.clearSelection(); - this.addSelection(value); - } - else - this.clearSelection(); - }, - enumerable: true, - configurable: true - }); - GList.prototype.getSelection = function (result) { - if (!result) - result = new Array(); - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if ((ii.obj instanceof fgui.GButton) && ii.obj.selected - || ii.obj == null && ii.selected) { - var j = i; - if (this._loop) { - j = i % this._numItems; - if (result.indexOf(j) != -1) - continue; - } - result.push(j); - } - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if ((obj instanceof fgui.GButton) && obj.selected) - result.push(i); - } - } - return result; - }; - GList.prototype.addSelection = function (index, scrollItToView) { - if (this._selectionMode == fgui.ListSelectionMode.None) - return; - this.checkVirtualList(); - if (this._selectionMode == fgui.ListSelectionMode.Single) - this.clearSelection(); - if (scrollItToView) - this.scrollToView(index); - this._lastSelectedIndex = index; - var obj; - if (this._virtual) { - var ii = this._virtualItems[index]; - if (ii.obj) - obj = ii.obj; - ii.selected = true; - } - else - obj = this.getChildAt(index); - if ((obj instanceof fgui.GButton) && !obj.selected) { - obj.selected = true; - this.updateSelectionController(index); - } - }; - GList.prototype.removeSelection = function (index) { - if (this._selectionMode == fgui.ListSelectionMode.None) - return; - var obj; - if (this._virtual) { - var ii = this._virtualItems[index]; - if (ii.obj) - obj = ii.obj; - ii.selected = false; - } - else - obj = this.getChildAt(index); - if (obj instanceof fgui.GButton) - obj.selected = false; - }; - GList.prototype.clearSelection = function () { - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if (ii.obj instanceof fgui.GButton) - ii.obj.selected = false; - ii.selected = false; - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if (obj instanceof fgui.GButton) - obj.selected = false; - } - } - }; - GList.prototype.clearSelectionExcept = function (g) { - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if (ii.obj != g) { - if ((ii.obj instanceof fgui.GButton)) - ii.obj.selected = false; - ii.selected = false; - } - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if ((obj instanceof fgui.GButton) && obj != g) - obj.selected = false; - } - } - }; - GList.prototype.selectAll = function () { - this.checkVirtualList(); - var last = -1; - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if ((ii.obj instanceof fgui.GButton) && !ii.obj.selected) { - ii.obj.selected = true; - last = i; - } - ii.selected = true; - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if ((obj instanceof fgui.GButton) && !obj.selected) { - obj.selected = true; - last = i; - } - } - } - if (last != -1) - this.updateSelectionController(last); - }; - GList.prototype.selectNone = function () { - this.clearSelection(); - }; - GList.prototype.selectReverse = function () { - this.checkVirtualList(); - var last = -1; - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if (ii.obj instanceof fgui.GButton) { - ii.obj.selected = !ii.obj.selected; - if (ii.obj.selected) - last = i; - } - ii.selected = !ii.selected; - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if (obj instanceof fgui.GButton) { - obj.selected = !obj.selected; - if (obj.selected) - last = i; - } - } - } - if (last != -1) - this.updateSelectionController(last); - }; - GList.prototype.handleArrowKey = function (dir) { - var index = this.selectedIndex; - if (index == -1) - return; - switch (dir) { - case 1: - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowVertical) { - index--; - if (index >= 0) { - this.clearSelection(); - this.addSelection(index, true); - } - } - else if (this._layout == fgui.ListLayoutType.FlowHorizontal || this._layout == fgui.ListLayoutType.Pagination) { - var current = this._children[index]; - var k = 0; - for (var i = index - 1; i >= 0; i--) { - var obj = this._children[i]; - if (obj.y != current.y) { - current = obj; - break; - } - k++; - } - for (; i >= 0; i--) { - obj = this._children[i]; - if (obj.y != current.y) { - this.clearSelection(); - this.addSelection(i + k + 1, true); - break; - } - } - } - break; - case 3: - if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowHorizontal || this._layout == fgui.ListLayoutType.Pagination) { - index++; - if (index < this._children.length) { - this.clearSelection(); - this.addSelection(index, true); - } - } - else if (this._layout == fgui.ListLayoutType.FlowVertical) { - current = this._children[index]; - k = 0; - var cnt = this._children.length; - for (i = index + 1; i < cnt; i++) { - obj = this._children[i]; - if (obj.x != current.x) { - current = obj; - break; - } - k++; - } - for (; i < cnt; i++) { - obj = this._children[i]; - if (obj.x != current.x) { - this.clearSelection(); - this.addSelection(i - k - 1, true); - break; - } - } - } - break; - case 5: - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowVertical) { - index++; - if (index < this._children.length) { - this.clearSelection(); - this.addSelection(index, true); - } - } - else if (this._layout == fgui.ListLayoutType.FlowHorizontal || this._layout == fgui.ListLayoutType.Pagination) { - current = this._children[index]; - k = 0; - cnt = this._children.length; - for (i = index + 1; i < cnt; i++) { - obj = this._children[i]; - if (obj.y != current.y) { - current = obj; - break; - } - k++; - } - for (; i < cnt; i++) { - obj = this._children[i]; - if (obj.y != current.y) { - this.clearSelection(); - this.addSelection(i - k - 1, true); - break; - } - } - } - break; - case 7: - if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowHorizontal || this._layout == fgui.ListLayoutType.Pagination) { - index--; - if (index >= 0) { - this.clearSelection(); - this.addSelection(index, true); - } - } - else if (this._layout == fgui.ListLayoutType.FlowVertical) { - current = this._children[index]; - k = 0; - for (i = index - 1; i >= 0; i--) { - obj = this._children[i]; - if (obj.x != current.x) { - current = obj; - break; - } - k++; - } - for (; i >= 0; i--) { - obj = this._children[i]; - if (obj.x != current.x) { - this.clearSelection(); - this.addSelection(i + k + 1, true); - break; - } - } - } - break; - } - }; - GList.prototype.__clickItem = function (evt) { - if (this._scrollPane && this._scrollPane.isDragged) - return; - var item = (evt.currentTarget); - this.setSelectionOnEvent(item); - if (this._scrollPane && this.scrollItemToViewOnClick) - this._scrollPane.scrollToView(item, true); - var ie = new fgui.ItemEvent(fgui.ItemEvent.CLICK, item); - ie.stageX = evt.stageX; - ie.stageY = evt.stageY; - this.dispatchItemEvent(ie); - }; - GList.prototype.dispatchItemEvent = function (evt) { - this.dispatchEvent(evt); - }; - GList.prototype.setSelectionOnEvent = function (item) { - if (!(item instanceof fgui.GButton) || this._selectionMode == fgui.ListSelectionMode.None) - return; - var dontChangeLastIndex = false; - var index = this.childIndexToItemIndex(this.getChildIndex(item)); - if (this._selectionMode == fgui.ListSelectionMode.Single) { - if (!item.selected) { - this.clearSelectionExcept(item); - item.selected = true; - } - } - else { - if (fgui.GRoot.shiftKeyDown) { - if (!item.selected) { - if (this._lastSelectedIndex != -1) { - var min = Math.min(this._lastSelectedIndex, index); - var max = Math.max(this._lastSelectedIndex, index); - max = Math.min(max, this.numItems - 1); - var i; - if (this._virtual) { - for (i = min; i <= max; i++) { - var ii = this._virtualItems[i]; - if (ii.obj instanceof fgui.GButton) - ii.obj.selected = true; - ii.selected = true; - } - } - else { - for (i = min; i <= max; i++) { - var obj = this.getChildAt(i); - if (obj instanceof fgui.GButton) - obj.selected = true; - } - } - dontChangeLastIndex = true; - } - else { - item.selected = true; - } - } - } - else if (fgui.GRoot.ctrlKeyDown || this._selectionMode == fgui.ListSelectionMode.Multiple_SingleClick) { - item.selected = !item.selected; - } - else { - if (!item.selected) { - this.clearSelectionExcept(item); - item.selected = true; - } - else - this.clearSelectionExcept(item); - } - } - if (!dontChangeLastIndex) - this._lastSelectedIndex = index; - if (item.selected) - this.updateSelectionController(index); - }; - GList.prototype.resizeToFit = function (itemCount, minSize) { - if (itemCount === void 0) { itemCount = Number.POSITIVE_INFINITY; } - if (minSize === void 0) { minSize = 0; } - this.ensureBoundsCorrect(); - var curCount = this.numItems; - if (itemCount > curCount) - itemCount = curCount; - if (this._virtual) { - var lineCount = Math.ceil(itemCount / this._curLineItemCount); - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) - this.viewHeight = lineCount * this._itemSize.y + Math.max(0, lineCount - 1) * this._lineGap; - else - this.viewWidth = lineCount * this._itemSize.x + Math.max(0, lineCount - 1) * this._columnGap; - } - else if (itemCount == 0) { - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) - this.viewHeight = minSize; - else - this.viewWidth = minSize; - } - else { - var i = itemCount - 1; - var obj; - while (i >= 0) { - obj = this.getChildAt(i); - if (!this.foldInvisibleItems || obj.visible) - break; - i--; - } - if (i < 0) { - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) - this.viewHeight = minSize; - else - this.viewWidth = minSize; - } - else { - var size = 0; - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - size = obj.y + obj.height; - if (size < minSize) - size = minSize; - this.viewHeight = size; - } - else { - size = obj.x + obj.width; - if (size < minSize) - size = minSize; - this.viewWidth = size; - } - } - } - }; - GList.prototype.getMaxItemWidth = function () { - var cnt = this._children.length; - var max = 0; - for (var i = 0; i < cnt; i++) { - var child = this.getChildAt(i); - if (child.width > max) - max = child.width; - } - return max; - }; - GList.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - }; - GList.prototype.handleControllerChanged = function (c) { - _super_1.prototype.handleControllerChanged.call(this, c); - if (this._selectionController == c) - this.selectedIndex = c.selectedIndex; - }; - GList.prototype.updateSelectionController = function (index) { - if (this._selectionController && !this._selectionController.changing - && index < this._selectionController.pageCount) { - var c = this._selectionController; - this._selectionController = null; - c.selectedIndex = index; - this._selectionController = c; - } - }; - GList.prototype.getSnappingPosition = function (xValue, yValue, result) { - if (this._virtual) { - if (!result) - result = new egret.Point(); - var saved; - var index; - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - saved = yValue; - s_n = yValue; - index = this.getIndexOnPos1(false); - yValue = s_n; - if (index < this._virtualItems.length && saved - yValue > this._virtualItems[index].height / 2 && index < this._realNumItems) - yValue += this._virtualItems[index].height + this._lineGap; - } - else if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowVertical) { - saved = xValue; - s_n = xValue; - index = this.getIndexOnPos2(false); - xValue = s_n; - if (index < this._virtualItems.length && saved - xValue > this._virtualItems[index].width / 2 && index < this._realNumItems) - xValue += this._virtualItems[index].width + this._columnGap; - } - else { - saved = xValue; - s_n = xValue; - index = this.getIndexOnPos3(false); - xValue = s_n; - if (index < this._virtualItems.length && saved - xValue > this._virtualItems[index].width / 2 && index < this._realNumItems) - xValue += this._virtualItems[index].width + this._columnGap; - } - result.x = xValue; - result.y = yValue; - return result; - } - else { - return _super_1.prototype.getSnappingPosition.call(this, xValue, yValue, result); - } - }; - GList.prototype.scrollToView = function (index, ani, setFirst) { - if (this._virtual) { - if (this._numItems == 0) - return; - this.checkVirtualList(); - if (index >= this._virtualItems.length) - throw "Invalid child index: " + index + ">" + this._virtualItems.length; - if (this._loop) - index = Math.floor(this._firstIndex / this._numItems) * this._numItems + index; - var rect; - var ii = this._virtualItems[index]; - var pos = 0; - var i; - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - for (i = this._curLineItemCount - 1; i < index; i += this._curLineItemCount) - pos += this._virtualItems[i].height + this._lineGap; - rect = new egret.Rectangle(0, pos, this._itemSize.x, ii.height); - } - else if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowVertical) { - for (i = this._curLineItemCount - 1; i < index; i += this._curLineItemCount) - pos += this._virtualItems[i].width + this._columnGap; - rect = new egret.Rectangle(pos, 0, ii.width, this._itemSize.y); - } - else { - var page = index / (this._curLineItemCount * this._curLineItemCount2); - rect = new egret.Rectangle(page * this.viewWidth + (index % this._curLineItemCount) * (ii.width + this._columnGap), (index / this._curLineItemCount) % this._curLineItemCount2 * (ii.height + this._lineGap), ii.width, ii.height); - } - if (this._scrollPane) - this._scrollPane.scrollToView(rect, ani, setFirst); - } - else { - var obj = this.getChildAt(index); - if (obj) { - if (this._scrollPane) - this._scrollPane.scrollToView(obj, ani, setFirst); - else if (this.parent && this.parent.scrollPane) - this.parent.scrollPane.scrollToView(obj, ani, setFirst); - } - } - }; - GList.prototype.getFirstChildInView = function () { - return this.childIndexToItemIndex(_super_1.prototype.getFirstChildInView.call(this)); - }; - GList.prototype.childIndexToItemIndex = function (index) { - if (!this._virtual) - return index; - if (this._layout == fgui.ListLayoutType.Pagination) { - for (var i = this._firstIndex; i < this._realNumItems; i++) { - if (this._virtualItems[i].obj) { - index--; - if (index < 0) - return i; - } - } - return index; - } - else { - index += this._firstIndex; - if (this._loop && this._numItems > 0) - index = index % this._numItems; - return index; - } - }; - GList.prototype.itemIndexToChildIndex = function (index) { - if (!this._virtual) - return index; - if (this._layout == fgui.ListLayoutType.Pagination) { - return this.getChildIndex(this._virtualItems[index].obj); - } - else { - if (this._loop && this._numItems > 0) { - var j = this._firstIndex % this._numItems; - if (index >= j) - index = index - j; - else - index = this._numItems - j + index; - } - else - index -= this._firstIndex; - return index; - } - }; - GList.prototype.setVirtual = function () { - this._setVirtual(false); - }; - GList.prototype.setVirtualAndLoop = function () { - this._setVirtual(true); - }; - GList.prototype._setVirtual = function (loop) { - if (!this._virtual) { - if (this._scrollPane == null) - throw "Virtual list must be scrollable!"; - if (loop) { - if (this._layout == fgui.ListLayoutType.FlowHorizontal || this._layout == fgui.ListLayoutType.FlowVertical) - throw "Loop list is not supported for FlowHorizontal or FlowVertical layout!"; - this._scrollPane.bouncebackEffect = false; - } - this._virtual = true; - this._loop = loop; - this._virtualItems = new Array(); - this.removeChildrenToPool(); - if (this._itemSize == null) { - this._itemSize = new egret.Point(); - var obj = this.getFromPool(null); - if (obj == null) { - throw "Virtual List must have a default list item resource."; - } - else { - this._itemSize.x = obj.width; - this._itemSize.y = obj.height; - } - this.returnToPool(obj); - } - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - this._scrollPane.scrollStep = this._itemSize.y; - if (this._loop) - this._scrollPane._loop = 2; - } - else { - this._scrollPane.scrollStep = this._itemSize.x; - if (this._loop) - this._scrollPane._loop = 1; - } - this._scrollPane.addEventListener(fgui.ScrollPane.SCROLL, this.__scrolled, this); - this.setVirtualListChangedFlag(true); - } - }; - Object.defineProperty(GList.prototype, "numItems", { - get: function () { - if (this._virtual) - return this._numItems; - else - return this._children.length; - }, - set: function (value) { - if (this._virtual) { - if (this.itemRenderer == null) - throw "Set itemRenderer first!"; - this._numItems = value; - if (this._loop) - this._realNumItems = this._numItems * 6; - else - this._realNumItems = this._numItems; - var oldCount = this._virtualItems.length; - if (this._realNumItems > oldCount) { - for (i = oldCount; i < this._realNumItems; i++) { - var ii = { - width: this._itemSize.x, - height: this._itemSize.y, - updateFlag: 0 - }; - this._virtualItems.push(ii); - } - } - else { - for (i = this._realNumItems; i < oldCount; i++) - this._virtualItems[i].selected = false; - } - if (this._virtualListChanged != 0) - fgui.GTimers.inst.remove(this._refreshVirtualList, this); - this._refreshVirtualList(); - } - else { - var cnt = this._children.length; - if (value > cnt) { - for (var i = cnt; i < value; i++) { - if (this.itemProvider == null) - this.addItemFromPool(); - else - this.addItemFromPool(this.itemProvider.call(this.callbackThisObj, i)); - } - } - else { - this.removeChildrenToPool(value, cnt); - } - if (this.itemRenderer != null) { - for (i = 0; i < value; i++) - this.itemRenderer.call(this.callbackThisObj, i, this.getChildAt(i)); - } - } - }, - enumerable: true, - configurable: true - }); - GList.prototype.refreshVirtualList = function () { - this.setVirtualListChangedFlag(false); - }; - GList.prototype.checkVirtualList = function () { - if (this._virtualListChanged != 0) { - this._refreshVirtualList(); - fgui.GTimers.inst.remove(this._refreshVirtualList, this); - } - }; - GList.prototype.setVirtualListChangedFlag = function (layoutChanged) { - if (layoutChanged) - this._virtualListChanged = 2; - else if (this._virtualListChanged == 0) - this._virtualListChanged = 1; - fgui.GTimers.inst.callLater(this._refreshVirtualList, this); - }; - GList.prototype._refreshVirtualList = function () { - var layoutChanged = this._virtualListChanged == 2; - this._virtualListChanged = 0; - this._eventLocked = true; - if (layoutChanged) { - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.SingleRow) - this._curLineItemCount = 1; - else if (this._layout == fgui.ListLayoutType.FlowHorizontal) { - if (this._columnCount > 0) - this._curLineItemCount = this._columnCount; - else { - this._curLineItemCount = Math.floor((this._scrollPane.viewWidth + this._columnGap) / (this._itemSize.x + this._columnGap)); - if (this._curLineItemCount <= 0) - this._curLineItemCount = 1; - } - } - else if (this._layout == fgui.ListLayoutType.FlowVertical) { - if (this._lineCount > 0) - this._curLineItemCount = this._lineCount; - else { - this._curLineItemCount = Math.floor((this._scrollPane.viewHeight + this._lineGap) / (this._itemSize.y + this._lineGap)); - if (this._curLineItemCount <= 0) - this._curLineItemCount = 1; - } - } - else { - if (this._columnCount > 0) - this._curLineItemCount = this._columnCount; - else { - this._curLineItemCount = Math.floor((this._scrollPane.viewWidth + this._columnGap) / (this._itemSize.x + this._columnGap)); - if (this._curLineItemCount <= 0) - this._curLineItemCount = 1; - } - if (this._lineCount > 0) - this._curLineItemCount2 = this._lineCount; - else { - this._curLineItemCount2 = Math.floor((this._scrollPane.viewHeight + this._lineGap) / (this._itemSize.y + this._lineGap)); - if (this._curLineItemCount2 <= 0) - this._curLineItemCount2 = 1; - } - } - } - var ch = 0, cw = 0; - if (this._realNumItems > 0) { - var i; - var len = Math.ceil(this._realNumItems / this._curLineItemCount) * this._curLineItemCount; - var len2 = Math.min(this._curLineItemCount, this._realNumItems); - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - for (i = 0; i < len; i += this._curLineItemCount) - ch += this._virtualItems[i].height + this._lineGap; - if (ch > 0) - ch -= this._lineGap; - if (this._autoResizeItem) - cw = this._scrollPane.viewWidth; - else { - for (i = 0; i < len2; i++) - cw += this._virtualItems[i].width + this._columnGap; - if (cw > 0) - cw -= this._columnGap; - } - } - else if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowVertical) { - for (i = 0; i < len; i += this._curLineItemCount) - cw += this._virtualItems[i].width + this._columnGap; - if (cw > 0) - cw -= this._columnGap; - if (this._autoResizeItem) - ch = this._scrollPane.viewHeight; - else { - for (i = 0; i < len2; i++) - ch += this._virtualItems[i].height + this._lineGap; - if (ch > 0) - ch -= this._lineGap; - } - } - else { - var pageCount = Math.ceil(len / (this._curLineItemCount * this._curLineItemCount2)); - cw = pageCount * this.viewWidth; - ch = this.viewHeight; - } - } - this.handleAlign(cw, ch); - this._scrollPane.setContentSize(cw, ch); - this._eventLocked = false; - this.handleScroll(true); - }; - GList.prototype.__scrolled = function (evt) { - this.handleScroll(false); - }; - GList.prototype.getIndexOnPos1 = function (forceUpdate) { - if (this._realNumItems < this._curLineItemCount) { - s_n = 0; - return 0; - } - var i; - var pos2; - var pos3; - if (this.numChildren > 0 && !forceUpdate) { - pos2 = this.getChildAt(0).y; - if (pos2 > s_n) { - for (i = this._firstIndex - this._curLineItemCount; i >= 0; i -= this._curLineItemCount) { - pos2 -= (this._virtualItems[i].height + this._lineGap); - if (pos2 <= s_n) { - s_n = pos2; - return i; - } - } - s_n = 0; - return 0; - } - else { - for (i = this._firstIndex; i < this._realNumItems; i += this._curLineItemCount) { - pos3 = pos2 + this._virtualItems[i].height + this._lineGap; - if (pos3 > s_n) { - s_n = pos2; - return i; - } - pos2 = pos3; - } - s_n = pos2; - return this._realNumItems - this._curLineItemCount; - } - } - else { - pos2 = 0; - for (i = 0; i < this._realNumItems; i += this._curLineItemCount) { - pos3 = pos2 + this._virtualItems[i].height + this._lineGap; - if (pos3 > s_n) { - s_n = pos2; - return i; - } - pos2 = pos3; - } - s_n = pos2; - return this._realNumItems - this._curLineItemCount; - } - }; - GList.prototype.getIndexOnPos2 = function (forceUpdate) { - if (this._realNumItems < this._curLineItemCount) { - s_n = 0; - return 0; - } - var i; - var pos2; - var pos3; - if (this.numChildren > 0 && !forceUpdate) { - pos2 = this.getChildAt(0).x; - if (pos2 > s_n) { - for (i = this._firstIndex - this._curLineItemCount; i >= 0; i -= this._curLineItemCount) { - pos2 -= (this._virtualItems[i].width + this._columnGap); - if (pos2 <= s_n) { - s_n = pos2; - return i; - } - } - s_n = 0; - return 0; - } - else { - for (i = this._firstIndex; i < this._realNumItems; i += this._curLineItemCount) { - pos3 = pos2 + this._virtualItems[i].width + this._columnGap; - if (pos3 > s_n) { - s_n = pos2; - return i; - } - pos2 = pos3; - } - s_n = pos2; - return this._realNumItems - this._curLineItemCount; - } - } - else { - pos2 = 0; - for (i = 0; i < this._realNumItems; i += this._curLineItemCount) { - pos3 = pos2 + this._virtualItems[i].width + this._columnGap; - if (pos3 > s_n) { - s_n = pos2; - return i; - } - pos2 = pos3; - } - s_n = pos2; - return this._realNumItems - this._curLineItemCount; - } - }; - GList.prototype.getIndexOnPos3 = function (forceUpdate) { - if (this._realNumItems < this._curLineItemCount) { - s_n = 0; - return 0; - } - var viewWidth = this.viewWidth; - var page = Math.floor(s_n / viewWidth); - var startIndex = page * (this._curLineItemCount * this._curLineItemCount2); - var pos2 = page * viewWidth; - var i; - var pos3; - for (i = 0; i < this._curLineItemCount; i++) { - pos3 = pos2 + this._virtualItems[startIndex + i].width + this._columnGap; - if (pos3 > s_n) { - s_n = pos2; - return startIndex + i; - } - pos2 = pos3; - } - s_n = pos2; - return startIndex + this._curLineItemCount - 1; - }; - GList.prototype.handleScroll = function (forceUpdate) { - if (this._eventLocked) - return; - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - var enterCounter = 0; - while (this.handleScroll1(forceUpdate)) { - enterCounter++; - forceUpdate = false; - if (enterCounter > 20) { - console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size."); - break; - } - } - this.handleArchOrder1(); - } - else if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowVertical) { - enterCounter = 0; - while (this.handleScroll2(forceUpdate)) { - enterCounter++; - forceUpdate = false; - if (enterCounter > 20) { - console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size."); - break; - } - } - this.handleArchOrder2(); - } - else { - this.handleScroll3(forceUpdate); - } - this._boundsChanged = false; - }; - GList.prototype.handleScroll1 = function (forceUpdate) { - var pos = this._scrollPane.scrollingPosY; - var max = pos + this._scrollPane.viewHeight; - var end = max == this._scrollPane.contentHeight; - s_n = pos; - var newFirstIndex = this.getIndexOnPos1(forceUpdate); - pos = s_n; - if (newFirstIndex == this._firstIndex && !forceUpdate) { - return false; - } - var oldFirstIndex = this._firstIndex; - this._firstIndex = newFirstIndex; - var curIndex = newFirstIndex; - var forward = oldFirstIndex > newFirstIndex; - var childCount = this.numChildren; - var lastIndex = oldFirstIndex + childCount - 1; - var reuseIndex = forward ? lastIndex : oldFirstIndex; - var curX = 0, curY = pos; - var needRender; - var deltaSize = 0; - var firstItemDeltaSize = 0; - var url = this.defaultItem; - var ii, ii2; - var i, j; - var partSize = (this._scrollPane.viewWidth - this._columnGap * (this._curLineItemCount - 1)) / this._curLineItemCount; - this.itemInfoVer++; - while (curIndex < this._realNumItems && (end || curY < max)) { - ii = this._virtualItems[curIndex]; - if (ii.obj == null || forceUpdate) { - if (this.itemProvider != null) { - url = this.itemProvider.call(this.callbackThisObj, curIndex % this._numItems); - if (url == null) - url = this._defaultItem; - url = fgui.UIPackage.normalizeURL(url); - } - if (ii.obj && ii.obj.resourceURL != url) { - if (ii.obj instanceof fgui.GButton) - ii.selected = ii.obj.selected; - this.removeChildToPool(ii.obj); - ii.obj = null; - } - } - if (ii.obj == null) { - if (forward) { - for (j = reuseIndex; j >= oldFirstIndex; j--) { - ii2 = this._virtualItems[j]; - if (ii2.obj && ii2.updateFlag != this.itemInfoVer && ii2.obj.resourceURL == url) { - if (ii2.obj instanceof fgui.GButton) - ii2.selected = ii2.obj.selected; - ii.obj = ii2.obj; - ii2.obj = null; - if (j == reuseIndex) - reuseIndex--; - break; - } - } - } - else { - for (j = reuseIndex; j <= lastIndex; j++) { - ii2 = this._virtualItems[j]; - if (ii2.obj && ii2.updateFlag != this.itemInfoVer && ii2.obj.resourceURL == url) { - if (ii2.obj instanceof fgui.GButton) - ii2.selected = ii2.obj.selected; - ii.obj = ii2.obj; - ii2.obj = null; - if (j == reuseIndex) - reuseIndex++; - break; - } - } - } - if (ii.obj) { - this.setChildIndex(ii.obj, forward ? curIndex - newFirstIndex : this.numChildren); - } - else { - ii.obj = this._pool.getObject(url); - if (forward) - this.addChildAt(ii.obj, curIndex - newFirstIndex); - else - this.addChild(ii.obj); - } - if (ii.obj instanceof fgui.GButton) - ii.obj.selected = ii.selected; - needRender = true; - } - else - needRender = forceUpdate; - if (needRender) { - if (this._autoResizeItem && (this._layout == fgui.ListLayoutType.SingleColumn || this._columnCount > 0)) - ii.obj.setSize(partSize, ii.obj.height, true); - this.itemRenderer.call(this.callbackThisObj, curIndex % this._numItems, ii.obj); - if (curIndex % this._curLineItemCount == 0) { - deltaSize += Math.ceil(ii.obj.height) - ii.height; - if (curIndex == newFirstIndex && oldFirstIndex > newFirstIndex) { - firstItemDeltaSize = Math.ceil(ii.obj.height) - ii.height; - } - } - ii.width = Math.ceil(ii.obj.width); - ii.height = Math.ceil(ii.obj.height); - } - ii.updateFlag = this.itemInfoVer; - ii.obj.setXY(curX, curY); - if (curIndex == newFirstIndex) - max += ii.height; - curX += ii.width + this._columnGap; - if (curIndex % this._curLineItemCount == this._curLineItemCount - 1) { - curX = 0; - curY += ii.height + this._lineGap; - } - curIndex++; - } - for (i = 0; i < childCount; i++) { - ii = this._virtualItems[oldFirstIndex + i]; - if (ii.updateFlag != this.itemInfoVer && ii.obj) { - if (ii.obj instanceof fgui.GButton) - ii.selected = ii.obj.selected; - this.removeChildToPool(ii.obj); - ii.obj = null; - } - } - childCount = this._children.length; - for (i = 0; i < childCount; i++) { - var obj = this._virtualItems[newFirstIndex + i].obj; - if (this._children[i] != obj) - this.setChildIndex(obj, i); - } - if (deltaSize != 0 || firstItemDeltaSize != 0) - this._scrollPane.changeContentSizeOnScrolling(0, deltaSize, 0, firstItemDeltaSize); - if (curIndex > 0 && this.numChildren > 0 && this._container.y <= 0 && this.getChildAt(0).y > -this._container.y) - return true; - else - return false; - }; - GList.prototype.handleScroll2 = function (forceUpdate) { - var pos = this._scrollPane.scrollingPosX; - var max = pos + this._scrollPane.viewWidth; - var end = pos == this._scrollPane.contentWidth; - s_n = pos; - var newFirstIndex = this.getIndexOnPos2(forceUpdate); - pos = s_n; - if (newFirstIndex == this._firstIndex && !forceUpdate) { - return false; - } - var oldFirstIndex = this._firstIndex; - this._firstIndex = newFirstIndex; - var curIndex = newFirstIndex; - var forward = oldFirstIndex > newFirstIndex; - var childCount = this.numChildren; - var lastIndex = oldFirstIndex + childCount - 1; - var reuseIndex = forward ? lastIndex : oldFirstIndex; - var curX = pos, curY = 0; - var needRender; - var deltaSize = 0; - var firstItemDeltaSize = 0; - var url = this.defaultItem; - var ii, ii2; - var i, j; - var partSize = (this._scrollPane.viewHeight - this._lineGap * (this._curLineItemCount - 1)) / this._curLineItemCount; - this.itemInfoVer++; - while (curIndex < this._realNumItems && (end || curX < max)) { - ii = this._virtualItems[curIndex]; - if (ii.obj == null || forceUpdate) { - if (this.itemProvider != null) { - url = this.itemProvider.call(this.callbackThisObj, curIndex % this._numItems); - if (url == null) - url = this._defaultItem; - url = fgui.UIPackage.normalizeURL(url); - } - if (ii.obj && ii.obj.resourceURL != url) { - if (ii.obj instanceof fgui.GButton) - ii.selected = ii.obj.selected; - this.removeChildToPool(ii.obj); - ii.obj = null; - } - } - if (ii.obj == null) { - if (forward) { - for (j = reuseIndex; j >= oldFirstIndex; j--) { - ii2 = this._virtualItems[j]; - if (ii2.obj && ii2.updateFlag != this.itemInfoVer && ii2.obj.resourceURL == url) { - if (ii2.obj instanceof fgui.GButton) - ii2.selected = ii2.obj.selected; - ii.obj = ii2.obj; - ii2.obj = null; - if (j == reuseIndex) - reuseIndex--; - break; - } - } - } - else { - for (j = reuseIndex; j <= lastIndex; j++) { - ii2 = this._virtualItems[j]; - if (ii2.obj && ii2.updateFlag != this.itemInfoVer && ii2.obj.resourceURL == url) { - if (ii2.obj instanceof fgui.GButton) - ii2.selected = ii2.obj.selected; - ii.obj = ii2.obj; - ii2.obj = null; - if (j == reuseIndex) - reuseIndex++; - break; - } - } - } - if (ii.obj) { - this.setChildIndex(ii.obj, forward ? curIndex - newFirstIndex : this.numChildren); - } - else { - ii.obj = this._pool.getObject(url); - if (forward) - this.addChildAt(ii.obj, curIndex - newFirstIndex); - else - this.addChild(ii.obj); - } - if (ii.obj instanceof fgui.GButton) - ii.obj.selected = ii.selected; - needRender = true; - } - else - needRender = forceUpdate; - if (needRender) { - if (this._autoResizeItem && (this._layout == fgui.ListLayoutType.SingleRow || this._lineCount > 0)) - ii.obj.setSize(ii.obj.width, partSize, true); - this.itemRenderer.call(this.callbackThisObj, curIndex % this._numItems, ii.obj); - if (curIndex % this._curLineItemCount == 0) { - deltaSize += Math.ceil(ii.obj.width) - ii.width; - if (curIndex == newFirstIndex && oldFirstIndex > newFirstIndex) { - firstItemDeltaSize = Math.ceil(ii.obj.width) - ii.width; - } - } - ii.width = Math.ceil(ii.obj.width); - ii.height = Math.ceil(ii.obj.height); - } - ii.updateFlag = this.itemInfoVer; - ii.obj.setXY(curX, curY); - if (curIndex == newFirstIndex) - max += ii.width; - curY += ii.height + this._lineGap; - if (curIndex % this._curLineItemCount == this._curLineItemCount - 1) { - curY = 0; - curX += ii.width + this._columnGap; - } - curIndex++; - } - for (i = 0; i < childCount; i++) { - ii = this._virtualItems[oldFirstIndex + i]; - if (ii.updateFlag != this.itemInfoVer && ii.obj) { - if (ii.obj instanceof fgui.GButton) - ii.selected = ii.obj.selected; - this.removeChildToPool(ii.obj); - ii.obj = null; - } - } - childCount = this._children.length; - for (i = 0; i < childCount; i++) { - var obj = this._virtualItems[newFirstIndex + i].obj; - if (this._children[i] != obj) - this.setChildIndex(obj, i); - } - if (deltaSize != 0 || firstItemDeltaSize != 0) - this._scrollPane.changeContentSizeOnScrolling(deltaSize, 0, firstItemDeltaSize, 0); - if (curIndex > 0 && this.numChildren > 0 && this._container.x <= 0 && this.getChildAt(0).x > -this._container.x) - return true; - else - return false; - }; - GList.prototype.handleScroll3 = function (forceUpdate) { - var pos = this._scrollPane.scrollingPosX; - s_n = pos; - var newFirstIndex = this.getIndexOnPos3(forceUpdate); - pos = s_n; - if (newFirstIndex == this._firstIndex && !forceUpdate) - return; - var oldFirstIndex = this._firstIndex; - this._firstIndex = newFirstIndex; - var reuseIndex = oldFirstIndex; - var virtualItemCount = this._virtualItems.length; - var pageSize = this._curLineItemCount * this._curLineItemCount2; - var startCol = newFirstIndex % this._curLineItemCount; - var viewWidth = this.viewWidth; - var page = Math.floor(newFirstIndex / pageSize); - var startIndex = page * pageSize; - var lastIndex = startIndex + pageSize * 2; - var needRender; - var i; - var ii, ii2; - var col; - var url = this._defaultItem; - var partWidth = (this._scrollPane.viewWidth - this._columnGap * (this._curLineItemCount - 1)) / this._curLineItemCount; - var partHeight = (this._scrollPane.viewHeight - this._lineGap * (this._curLineItemCount2 - 1)) / this._curLineItemCount2; - this.itemInfoVer++; - for (i = startIndex; i < lastIndex; i++) { - if (i >= this._realNumItems) - continue; - col = i % this._curLineItemCount; - if (i - startIndex < pageSize) { - if (col < startCol) - continue; - } - else { - if (col > startCol) - continue; - } - ii = this._virtualItems[i]; - ii.updateFlag = this.itemInfoVer; - } - var lastObj; - var insertIndex = 0; - for (i = startIndex; i < lastIndex; i++) { - if (i >= this._realNumItems) - continue; - ii = this._virtualItems[i]; - if (ii.updateFlag != this.itemInfoVer) - continue; - if (ii.obj == null) { - while (reuseIndex < virtualItemCount) { - ii2 = this._virtualItems[reuseIndex]; - if (ii2.obj && ii2.updateFlag != this.itemInfoVer) { - if (ii2.obj instanceof fgui.GButton) - ii2.selected = ii2.obj.selected; - ii.obj = ii2.obj; - ii2.obj = null; - break; - } - reuseIndex++; - } - if (insertIndex == -1) - insertIndex = this.getChildIndex(lastObj) + 1; - if (ii.obj == null) { - if (this.itemProvider != null) { - url = this.itemProvider.call(this.callbackThisObj, i % this._numItems); - if (url == null) - url = this._defaultItem; - url = fgui.UIPackage.normalizeURL(url); - } - ii.obj = this._pool.getObject(url); - this.addChildAt(ii.obj, insertIndex); - } - else { - insertIndex = this.setChildIndexBefore(ii.obj, insertIndex); - } - insertIndex++; - if (ii.obj instanceof fgui.GButton) - ii.obj.selected = ii.selected; - needRender = true; - } - else { - needRender = forceUpdate; - insertIndex = -1; - lastObj = ii.obj; - } - if (needRender) { - if (this._autoResizeItem) { - if (this._curLineItemCount == this._columnCount && this._curLineItemCount2 == this._lineCount) - ii.obj.setSize(partWidth, partHeight, true); - else if (this._curLineItemCount == this._columnCount) - ii.obj.setSize(partWidth, ii.obj.height, true); - else if (this._curLineItemCount2 == this._lineCount) - ii.obj.setSize(ii.obj.width, partHeight, true); - } - this.itemRenderer.call(this.callbackThisObj, i % this._numItems, ii.obj); - ii.width = Math.ceil(ii.obj.width); - ii.height = Math.ceil(ii.obj.height); - } - } - var borderX = (startIndex / pageSize) * viewWidth; - var xx = borderX; - var yy = 0; - var lineHeight = 0; - for (i = startIndex; i < lastIndex; i++) { - if (i >= this._realNumItems) - continue; - ii = this._virtualItems[i]; - if (ii.updateFlag == this.itemInfoVer) - ii.obj.setXY(xx, yy); - if (ii.height > lineHeight) - lineHeight = ii.height; - if (i % this._curLineItemCount == this._curLineItemCount - 1) { - xx = borderX; - yy += lineHeight + this._lineGap; - lineHeight = 0; - if (i == startIndex + pageSize - 1) { - borderX += viewWidth; - xx = borderX; - yy = 0; - } - } - else - xx += ii.width + this._columnGap; - } - for (i = reuseIndex; i < virtualItemCount; i++) { - ii = this._virtualItems[i]; - if (ii.updateFlag != this.itemInfoVer && ii.obj) { - if (ii.obj instanceof fgui.GButton) - ii.selected = ii.obj.selected; - this.removeChildToPool(ii.obj); - ii.obj = null; - } - } - }; - GList.prototype.handleArchOrder1 = function () { - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Arch) { - var mid = this._scrollPane.posY + this.viewHeight / 2; - var minDist = Number.POSITIVE_INFINITY; - var dist = 0; - var apexIndex = 0; - var cnt = this.numChildren; - for (var i = 0; i < cnt; i++) { - var obj = this.getChildAt(i); - if (!this.foldInvisibleItems || obj.visible) { - dist = Math.abs(mid - obj.y - obj.height / 2); - if (dist < minDist) { - minDist = dist; - apexIndex = i; - } - } - } - this.apexIndex = apexIndex; - } - }; - GList.prototype.handleArchOrder2 = function () { - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Arch) { - var mid = this._scrollPane.posX + this.viewWidth / 2; - var minDist = Number.POSITIVE_INFINITY; - var dist = 0; - var apexIndex = 0; - var cnt = this.numChildren; - for (var i = 0; i < cnt; i++) { - var obj = this.getChildAt(i); - if (!this.foldInvisibleItems || obj.visible) { - dist = Math.abs(mid - obj.x - obj.width / 2); - if (dist < minDist) { - minDist = dist; - apexIndex = i; - } - } - } - this.apexIndex = apexIndex; - } - }; - GList.prototype.handleAlign = function (contentWidth, contentHeight) { - var newOffsetX = 0; - var newOffsetY = 0; - if (contentHeight < this.viewHeight) { - if (this._verticalAlign == fgui.VertAlignType.Middle) - newOffsetY = Math.floor((this.viewHeight - contentHeight) / 2); - else if (this._verticalAlign == fgui.VertAlignType.Bottom) - newOffsetY = this.viewHeight - contentHeight; - } - if (contentWidth < this.viewWidth) { - if (this._align == fgui.AlignType.Center) - newOffsetX = Math.floor((this.viewWidth - contentWidth) / 2); - else if (this._align == fgui.AlignType.Right) - newOffsetX = this.viewWidth - contentWidth; - } - if (newOffsetX != this._alignOffset.x || newOffsetY != this._alignOffset.y) { - this._alignOffset.setTo(newOffsetX, newOffsetY); - if (this._scrollPane) - this._scrollPane.adjustMaskContainer(); - else { - this._container.x = this._margin.left + this._alignOffset.x; - this._container.y = this._margin.top + this._alignOffset.y; - } - } - }; - GList.prototype.updateBounds = function () { - if (this._virtual) - return; - var i; - var child; - var curX = 0; - var curY = 0; - var maxWidth = 0; - var maxHeight = 0; - var cw = 0, ch = 0; - var j = 0; - var page = 0; - var k = 0; - var cnt = this._children.length; - var viewWidth = this.viewWidth; - var viewHeight = this.viewHeight; - var lineSize = 0; - var lineStart = 0; - var ratio = 0; - if (this._layout == fgui.ListLayoutType.SingleColumn) { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (curY != 0) - curY += this._lineGap; - child.y = curY; - if (this._autoResizeItem) - child.setSize(viewWidth, child.height, true); - curY += Math.ceil(child.height); - if (child.width > maxWidth) - maxWidth = child.width; - } - ch = curY; - if (ch <= viewHeight && this._autoResizeItem && this._scrollPane && this._scrollPane._displayInDemand && this._scrollPane.vtScrollBar) { - viewWidth += this._scrollPane.vtScrollBar.width; - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - child.setSize(viewWidth, child.height, true); - if (child.width > maxWidth) - maxWidth = child.width; - } - } - cw = Math.ceil(maxWidth); - } - else if (this._layout == fgui.ListLayoutType.SingleRow) { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (curX != 0) - curX += this._columnGap; - child.x = curX; - if (this._autoResizeItem) - child.setSize(child.width, viewHeight, true); - curX += Math.ceil(child.width); - if (child.height > maxHeight) - maxHeight = child.height; - } - cw = curX; - if (cw <= viewWidth && this._autoResizeItem && this._scrollPane && this._scrollPane._displayInDemand && this._scrollPane.hzScrollBar) { - viewHeight += this._scrollPane.hzScrollBar.height; - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - child.setSize(child.width, viewHeight, true); - if (child.height > maxHeight) - maxHeight = child.height; - } - } - ch = Math.ceil(maxHeight); - } - else if (this._layout == fgui.ListLayoutType.FlowHorizontal) { - if (this._autoResizeItem && this._columnCount > 0) { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - lineSize += child.sourceWidth; - j++; - if (j == this._columnCount || i == cnt - 1) { - ratio = (viewWidth - lineSize - (j - 1) * this._columnGap) / lineSize; - curX = 0; - for (j = lineStart; j <= i; j++) { - child = this.getChildAt(j); - if (this.foldInvisibleItems && !child.visible) - continue; - child.setXY(curX, curY); - if (j < i) { - child.setSize(child.sourceWidth + Math.round(child.sourceWidth * ratio), child.height, true); - curX += Math.ceil(child.width) + this._columnGap; - } - else { - child.setSize(viewWidth - curX, child.height, true); - } - if (child.height > maxHeight) - maxHeight = child.height; - } - curY += Math.ceil(maxHeight) + this._lineGap; - maxHeight = 0; - j = 0; - lineStart = i + 1; - lineSize = 0; - } - } - ch = curY + Math.ceil(maxHeight); - cw = viewWidth; - } - else { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (curX != 0) - curX += this._columnGap; - if (this._columnCount != 0 && j >= this._columnCount - || this._columnCount == 0 && curX + child.width > viewWidth && maxHeight != 0) { - curX = 0; - curY += Math.ceil(maxHeight) + this._lineGap; - maxHeight = 0; - j = 0; - } - child.setXY(curX, curY); - curX += Math.ceil(child.width); - if (curX > maxWidth) - maxWidth = curX; - if (child.height > maxHeight) - maxHeight = child.height; - j++; - } - ch = curY + Math.ceil(maxHeight); - cw = Math.ceil(maxWidth); - } - } - else if (this._layout == fgui.ListLayoutType.FlowVertical) { - if (this._autoResizeItem && this._lineCount > 0) { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - lineSize += child.sourceHeight; - j++; - if (j == this._lineCount || i == cnt - 1) { - ratio = (viewHeight - lineSize - (j - 1) * this._lineGap) / lineSize; - curY = 0; - for (j = lineStart; j <= i; j++) { - child = this.getChildAt(j); - if (this.foldInvisibleItems && !child.visible) - continue; - child.setXY(curX, curY); - if (j < i) { - child.setSize(child.width, child.sourceHeight + Math.round(child.sourceHeight * ratio), true); - curY += Math.ceil(child.height) + this._lineGap; - } - else { - child.setSize(child.width, viewHeight - curY, true); - } - if (child.width > maxWidth) - maxWidth = child.width; - } - curX += Math.ceil(maxWidth) + this._columnGap; - maxWidth = 0; - j = 0; - lineStart = i + 1; - lineSize = 0; - } - } - cw = curX + Math.ceil(maxWidth); - ch = viewHeight; - } - else { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (curY != 0) - curY += this._lineGap; - if (this._lineCount != 0 && j >= this._lineCount - || this._lineCount == 0 && curY + child.height > viewHeight && maxWidth != 0) { - curY = 0; - curX += Math.ceil(maxWidth) + this._columnGap; - maxWidth = 0; - j = 0; - } - child.setXY(curX, curY); - curY += Math.ceil(child.height); - if (curY > maxHeight) - maxHeight = curY; - if (child.width > maxWidth) - maxWidth = child.width; - j++; - } - cw = curX + Math.ceil(maxWidth); - ch = Math.ceil(maxHeight); - } - } - else { - var eachHeight; - if (this._autoResizeItem && this._lineCount > 0) - eachHeight = Math.floor((viewHeight - (this._lineCount - 1) * this._lineGap) / this._lineCount); - if (this._autoResizeItem && this._columnCount > 0) { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (j == 0 && (this._lineCount != 0 && k >= this._lineCount - || this._lineCount == 0 && curY + (this._lineCount > 0 ? eachHeight : child.height) > viewHeight)) { - page++; - curY = 0; - k = 0; - } - lineSize += child.sourceWidth; - j++; - if (j == this._columnCount || i == cnt - 1) { - ratio = (viewWidth - lineSize - (j - 1) * this._columnGap) / lineSize; - curX = 0; - for (j = lineStart; j <= i; j++) { - child = this.getChildAt(j); - if (this.foldInvisibleItems && !child.visible) - continue; - child.setXY(page * viewWidth + curX, curY); - if (j < i) { - child.setSize(child.sourceWidth + Math.round(child.sourceWidth * ratio), this._lineCount > 0 ? eachHeight : child.height, true); - curX += Math.ceil(child.width) + this._columnGap; - } - else { - child.setSize(viewWidth - curX, this._lineCount > 0 ? eachHeight : child.height, true); - } - if (child.height > maxHeight) - maxHeight = child.height; - } - curY += Math.ceil(maxHeight) + this._lineGap; - maxHeight = 0; - j = 0; - lineStart = i + 1; - lineSize = 0; - k++; - } - } - } - else { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (curX != 0) - curX += this._columnGap; - if (this._autoResizeItem && this._lineCount > 0) - child.setSize(child.width, eachHeight, true); - if (this._columnCount != 0 && j >= this._columnCount - || this._columnCount == 0 && curX + child.width > viewWidth && maxHeight != 0) { - curX = 0; - curY += Math.ceil(maxHeight) + this._lineGap; - maxHeight = 0; - j = 0; - k++; - if (this._lineCount != 0 && k >= this._lineCount - || this._lineCount == 0 && curY + child.height > viewHeight && maxWidth != 0) { - page++; - curY = 0; - k = 0; - } - } - child.setXY(page * viewWidth + curX, curY); - curX += Math.ceil(child.width); - if (curX > maxWidth) - maxWidth = curX; - if (child.height > maxHeight) - maxHeight = child.height; - j++; - } - } - ch = page > 0 ? viewHeight : curY + Math.ceil(maxHeight); - cw = (page + 1) * viewWidth; - } - this.handleAlign(cw, ch); - this.setBounds(0, 0, cw, ch); - }; - GList.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._layout = buffer.readByte(); - this._selectionMode = buffer.readByte(); - this._align = buffer.readByte(); - this._verticalAlign = buffer.readByte(); - this._lineGap = buffer.readShort(); - this._columnGap = buffer.readShort(); - this._lineCount = buffer.readShort(); - this._columnCount = buffer.readShort(); - this._autoResizeItem = buffer.readBool(); - this._childrenRenderOrder = buffer.readByte(); - this._apexIndex = buffer.readShort(); - if (buffer.readBool()) { - this._margin.top = buffer.readInt(); - this._margin.bottom = buffer.readInt(); - this._margin.left = buffer.readInt(); - this._margin.right = buffer.readInt(); - } - var overflow = buffer.readByte(); - if (overflow == fgui.OverflowType.Scroll) { - var savedPos = buffer.position; - buffer.seek(beginPos, 7); - this.setupScroll(buffer); - buffer.position = savedPos; - } - else - this.setupOverflow(overflow); - if (buffer.readBool()) - buffer.skip(8); - if (buffer.version >= 2) { - this.scrollItemToViewOnClick = buffer.readBool(); - this.foldInvisibleItems = buffer.readBool(); - } - buffer.seek(beginPos, 8); - this._defaultItem = buffer.readS(); - this.readItems(buffer); - }; - GList.prototype.readItems = function (buffer) { - var cnt; - var i; - var nextPos; - var str; - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - str = buffer.readS(); - if (str == null) { - str = this.defaultItem; - if (!str) { - buffer.position = nextPos; - continue; - } - } - var obj = this.getFromPool(str); - if (obj != null) { - this.addChild(obj); - this.setupItem(buffer, obj); - } - buffer.position = nextPos; - } - }; - GList.prototype.setupItem = function (buffer, obj) { - var str; - str = buffer.readS(); - if (str != null) - obj.text = str; - str = buffer.readS(); - if (str != null && (obj instanceof fgui.GButton)) - obj.selectedTitle = str; - str = buffer.readS(); - if (str != null) - obj.icon = str; - str = buffer.readS(); - if (str != null && (obj instanceof fgui.GButton)) - obj.selectedIcon = str; - str = buffer.readS(); - if (str != null) - obj.name = str; - var cnt; - var i; - if (obj instanceof fgui.GComponent) { - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - var cc = obj.getController(buffer.readS()); - str = buffer.readS(); - if (cc) - cc.selectedPageId = str; - } - if (buffer.version >= 2) { - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - var target = buffer.readS(); - var propertyId = buffer.readShort(); - var value = buffer.readS(); - var obj2 = obj.getChildByPath(target); - if (obj2) - obj2.setProp(propertyId, value); - } - } - } - }; - GList.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 6); - var i = buffer.readShort(); - if (i != -1) - this._selectionController = this.parent.getControllerAt(i); - }; - return GList; - }(fgui.GComponent)); - fgui.GList = GList; - var s_n = 0; -})(fgui || (fgui = {})); - -(function (fgui) { - var GObjectPool = (function () { - function GObjectPool() { - this._count = 0; - this._pool = {}; - } - GObjectPool.prototype.clear = function () { - for (var i1 in this._pool) { - var arr = this._pool[i1]; - var cnt = arr.length; - for (var i = 0; i < cnt; i++) - arr[i].dispose(); - } - this._pool = {}; - this._count = 0; - }; - Object.defineProperty(GObjectPool.prototype, "count", { - get: function () { - return this._count; - }, - enumerable: true, - configurable: true - }); - GObjectPool.prototype.getObject = function (url) { - url = fgui.UIPackage.normalizeURL(url); - if (url == null) - return null; - var arr = this._pool[url]; - if (arr && arr.length) { - this._count--; - return arr.shift(); - } - var child = fgui.UIPackage.createObjectFromURL(url); - return child; - }; - GObjectPool.prototype.returnObject = function (obj) { - var url = obj.resourceURL; - if (!url) - return; - var arr = this._pool[url]; - if (arr == null) { - arr = new Array(); - this._pool[url] = arr; - } - this._count++; - arr.push(obj); - }; - return GObjectPool; - }()); - fgui.GObjectPool = GObjectPool; -})(fgui || (fgui = {})); - -(function (fgui) { - var GLoader = (function (_super_1) { - __extends(GLoader, _super_1); - function GLoader() { - var _this = _super_1.call(this) || this; - _this._url = ""; - _this._fill = fgui.LoaderFillType.None; - _this._align = fgui.AlignType.Left; - _this._verticalAlign = fgui.VertAlignType.Top; - _this._showErrorSign = true; - return _this; - } - GLoader.prototype.createDisplayObject = function () { - this._container = new fgui.UIContainer(); - this._container.opaque = true; - this.setDisplayObject(this._container); - this._content = new fgui.MovieClip(); - this._container.addChild(this._content); - }; - GLoader.prototype.dispose = function () { - if (!this._contentItem) { - var texture = this._content.texture; - if (texture) - this.freeExternal(texture); - } - if (this._content2) - this._content2.dispose(); - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GLoader.prototype, "url", { - get: function () { - return this._url; - }, - set: function (value) { - if (this._url == value) - return; - this.clearContent(); - this._url = value; - this.loadContent(); - this.updateGear(7); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "icon", { - get: function () { - return this._url; - }, - set: function (value) { - this.url = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "align", { - get: function () { - return this._align; - }, - set: function (value) { - if (this._align != value) { - this._align = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "verticalAlign", { - get: function () { - return this._verticalAlign; - }, - set: function (value) { - if (this._verticalAlign != value) { - this._verticalAlign = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "fill", { - get: function () { - return this._fill; - }, - set: function (value) { - if (this._fill != value) { - this._fill = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "shrinkOnly", { - get: function () { - return this._shrinkOnly; - }, - set: function (value) { - if (this._shrinkOnly != value) { - this._shrinkOnly = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "autoSize", { - get: function () { - return this._autoSize; - }, - set: function (value) { - if (this._autoSize != value) { - this._autoSize = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "playing", { - get: function () { - return this._content.playing; - }, - set: function (value) { - if (this._content.playing != value) { - this._content.playing = value; - this.updateGear(5); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "frame", { - get: function () { - return this._content.frame; - }, - set: function (value) { - if (this._content.frame != value) { - this._content.frame = value; - this.updateGear(5); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "color", { - get: function () { - return this._content.color; - }, - set: function (value) { - if (this._content.color != value) { - this._content.color = value; - this.updateGear(4); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "showErrorSign", { - get: function () { - return this._showErrorSign; - }, - set: function (value) { - this._showErrorSign = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "content", { - get: function () { - return this._content; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "component", { - get: function () { - return this._content2; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "texture", { - get: function () { - return this._content.texture; - }, - set: function (value) { - this.url = null; - this._content.frames = null; - this._content.texture = value; - if (value) { - this.sourceWidth = value.textureWidth; - this.sourceHeight = value.textureHeight; - } - else { - this.sourceWidth = this.sourceHeight = 0; - } - this.updateLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "fillMethod", { - get: function () { - return this._content.fillMethod; - }, - set: function (value) { - this._content.fillMethod = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "fillOrigin", { - get: function () { - return this._content.fillOrigin; - }, - set: function (value) { - this._content.fillOrigin = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "fillClockwise", { - get: function () { - return this._content.fillClockwise; - }, - set: function (value) { - this._content.fillClockwise = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "fillAmount", { - get: function () { - return this._content.fillAmount; - }, - set: function (value) { - this._content.fillAmount = value; - }, - enumerable: true, - configurable: true - }); - GLoader.prototype.loadContent = function () { - if (!this._url) - return; - if (fgui.ToolSet.startsWith(this._url, "ui://")) - this.loadFromPackage(this._url); - else - this.loadExternal(); - }; - GLoader.prototype.loadFromPackage = function (itemURL) { - this._contentItem = fgui.UIPackage.getItemByURL(itemURL); - if (this._contentItem) { - this._contentItem = this._contentItem.getBranch(); - this.sourceWidth = this._contentItem.width; - this.sourceHeight = this._contentItem.height; - this._contentItem = this._contentItem.getHighResolution(); - this._contentItem.load(); - if (this._autoSize) - this.setSize(this.sourceWidth, this.sourceHeight); - if (this._contentItem.type == fgui.PackageItemType.Image) { - if (this._contentItem.asset == null) { - this.setErrorState(); - } - else { - this._content.texture = this._contentItem.asset; - this._content.scale9Grid = this._contentItem.scale9Grid; - if (this._contentItem.scaleByTile) - this._content.fillMode = egret.BitmapFillMode.REPEAT; - else - this._content.fillMode = egret.BitmapFillMode.SCALE; - this.updateLayout(); - } - } - else if (this._contentItem.type == fgui.PackageItemType.MovieClip) { - this._content.interval = this._contentItem.interval; - this._content.swing = this._contentItem.swing; - this._content.repeatDelay = this._contentItem.repeatDelay; - this._content.frames = this._contentItem.frames; - this.updateLayout(); - } - else if (this._contentItem.type == fgui.PackageItemType.Component) { - var obj = fgui.UIPackage.createObjectFromURL(itemURL); - if (!obj) - this.setErrorState(); - else if (!(obj instanceof fgui.GComponent)) { - obj.dispose(); - this.setErrorState(); - } - else { - this._content2 = obj.asCom; - this._container.addChild(this._content2.displayObject); - this.updateLayout(); - } - } - else - this.setErrorState(); - } - else - this.setErrorState(); - }; - GLoader.prototype.loadExternal = function () { - RES.getResByUrl(this._url, this.__getResCompleted, this); - }; - GLoader.prototype.freeExternal = function (texture) { - }; - GLoader.prototype.onExternalLoadSuccess = function (texture) { - this._content.texture = texture; - this._content.scale9Grid = null; - this._content.fillMode = egret.BitmapFillMode.SCALE; - this.sourceWidth = texture.textureWidth; - this.sourceHeight = texture.textureHeight; - this.updateLayout(); - }; - GLoader.prototype.onExternalLoadFailed = function () { - this.setErrorState(); - }; - GLoader.prototype.__getResCompleted = function (res, key) { - if (res instanceof egret.Texture) - this.onExternalLoadSuccess(res); - else - this.onExternalLoadFailed(); - }; - GLoader.prototype.setErrorState = function () { - if (!this._showErrorSign) - return; - if (this._errorSign == null) { - if (fgui.UIConfig.loaderErrorSign != null) { - this._errorSign = GLoader._errorSignPool.getObject(fgui.UIConfig.loaderErrorSign); - } - } - if (this._errorSign) { - this._errorSign.setSize(this.width, this.height); - this._container.addChild(this._errorSign.displayObject); - } - }; - GLoader.prototype.clearErrorState = function () { - if (this._errorSign) { - this._container.removeChild(this._errorSign.displayObject); - GLoader._errorSignPool.returnObject(this._errorSign); - this._errorSign = null; - } - }; - GLoader.prototype.updateLayout = function () { - if (!this._content2 && !this._content) { - if (this._autoSize) { - this._updatingLayout = true; - this.setSize(50, 30); - this._updatingLayout = false; - } - return; - } - var cw = this.sourceWidth; - var ch = this.sourceHeight; - if (this._autoSize) { - this._updatingLayout = true; - if (cw == 0) - cw = 50; - if (ch == 0) - ch = 30; - this.setSize(cw, ch); - this._updatingLayout = false; - if (cw == this._width && ch == this._height) { - if (this._content2) { - this._content2.setXY(0, 0); - this._content2.setScale(1, 1); - } - else { - this._content.x = 0; - this._content.y = 0; - this._content.width = cw; - this._content.height = ch; - } - return; - } - } - var sx = 1, sy = 1; - if (this._fill != fgui.LoaderFillType.None) { - sx = this.width / this.sourceWidth; - sy = this.height / this.sourceHeight; - if (sx != 1 || sy != 1) { - if (this._fill == fgui.LoaderFillType.ScaleMatchHeight) - sx = sy; - else if (this._fill == fgui.LoaderFillType.ScaleMatchWidth) - sy = sx; - else if (this._fill == fgui.LoaderFillType.Scale) { - if (sx > sy) - sx = sy; - else - sy = sx; - } - else if (this._fill == fgui.LoaderFillType.ScaleNoBorder) { - if (sx > sy) - sy = sx; - else - sx = sy; - } - if (this._shrinkOnly) { - if (sx > 1) - sx = 1; - if (sy > 1) - sy = 1; - } - cw = this.sourceWidth * sx; - ch = this.sourceHeight * sy; - } - } - if (this._content2) { - this._content2.setScale(sx, sy); - } - else { - this._content.width = cw; - this._content.height = ch; - } - var nx, ny; - if (this._align == fgui.AlignType.Center) - nx = Math.floor((this.width - cw) / 2); - else if (this._align == fgui.AlignType.Right) - nx = this.width - cw; - else - nx = 0; - if (this._verticalAlign == fgui.VertAlignType.Middle) - ny = Math.floor((this.height - ch) / 2); - else if (this._verticalAlign == fgui.VertAlignType.Bottom) - ny = this.height - ch; - else - ny = 0; - if (this._content2) - this._content2.setXY(nx, ny); - else { - this._content.x = nx; - this._content.y = ny; - } - }; - GLoader.prototype.clearContent = function () { - this.clearErrorState(); - if (!this._contentItem && this._content.texture) { - this.freeExternal(this._content.texture); - } - this._content.texture = null; - this._content.frames = null; - if (this._content2) { - this._container.removeChild(this._content2.displayObject); - this._content2.dispose(); - this._content2 = null; - } - this._contentItem = null; - }; - GLoader.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (!this._updatingLayout) - this.updateLayout(); - }; - GLoader.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.color; - case fgui.ObjectPropID.Playing: - return this.playing; - case fgui.ObjectPropID.Frame: - return this.frame; - case fgui.ObjectPropID.TimeScale: - return this._content.timeScale; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GLoader.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.color = value; - break; - case fgui.ObjectPropID.Playing: - this.playing = value; - break; - case fgui.ObjectPropID.Frame: - this.frame = value; - break; - case fgui.ObjectPropID.TimeScale: - this._content.timeScale = value; - break; - case fgui.ObjectPropID.DeltaTime: - this._content.advance(value); - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GLoader.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._url = buffer.readS(); - this._align = buffer.readByte(); - this._verticalAlign = buffer.readByte(); - this._fill = buffer.readByte(); - this._shrinkOnly = buffer.readBool(); - this._autoSize = buffer.readBool(); - this._showErrorSign = buffer.readBool(); - this._content.playing = buffer.readBool(); - this._content.frame = buffer.readInt(); - if (buffer.readBool()) - this.color = buffer.readColor(); - this._content.fillMethod = buffer.readByte(); - if (this._content.fillMethod != 0) { - this._content.fillOrigin = buffer.readByte(); - this._content.fillClockwise = buffer.readBool(); - this._content.fillAmount = buffer.readFloat(); - } - if (this._url) - this.loadContent(); - }; - GLoader._errorSignPool = new fgui.GObjectPool(); - return GLoader; - }(fgui.GObject)); - fgui.GLoader = GLoader; -})(fgui || (fgui = {})); - -(function (fgui) { - var GLoader3D = (function (_super_1) { - __extends(GLoader3D, _super_1); - function GLoader3D() { - var _this = _super_1.call(this) || this; - _this._frame = 0; - _this._playing = true; - _this._url = ""; - _this._fill = fgui.LoaderFillType.None; - _this._align = fgui.AlignType.Left; - _this._verticalAlign = fgui.VertAlignType.Top; - _this._color = 0xFFFFFF; - return _this; - } - GLoader3D.prototype.createDisplayObject = function () { - var d = new fgui.UIContainer(); - d.opaque = true; - this.setDisplayObject(d); - this._container = new egret.DisplayObjectContainer(); - d.addChild(this._container); - }; - GLoader3D.prototype.dispose = function () { - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GLoader3D.prototype, "url", { - get: function () { - return this._url; - }, - set: function (value) { - if (this._url == value) - return; - this._url = value; - this.loadContent(); - this.updateGear(7); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "icon", { - get: function () { - return this._url; - }, - set: function (value) { - this.url = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "align", { - get: function () { - return this._align; - }, - set: function (value) { - if (this._align != value) { - this._align = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "verticalAlign", { - get: function () { - return this._verticalAlign; - }, - set: function (value) { - if (this._verticalAlign != value) { - this._verticalAlign = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "fill", { - get: function () { - return this._fill; - }, - set: function (value) { - if (this._fill != value) { - this._fill = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "shrinkOnly", { - get: function () { - return this._shrinkOnly; - }, - set: function (value) { - if (this._shrinkOnly != value) { - this._shrinkOnly = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "autoSize", { - get: function () { - return this._autoSize; - }, - set: function (value) { - if (this._autoSize != value) { - this._autoSize = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "playing", { - get: function () { - return this._playing; - }, - set: function (value) { - if (this._playing != value) { - this._playing = value; - this.updateGear(5); - this.onChange(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "frame", { - get: function () { - return this._frame; - }, - set: function (value) { - if (this._frame != value) { - this._frame = value; - this.updateGear(5); - this.onChange(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "animationName", { - get: function () { - return this._animationName; - }, - set: function (value) { - if (this._animationName != value) { - this._animationName = value; - this.onChange(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "skinName", { - get: function () { - return this._skinName; - }, - set: function (value) { - if (this._skinName != value) { - this._skinName = value; - this.onChange(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "loop", { - get: function () { - return this._loop; - }, - set: function (value) { - if (this._loop != value) { - this._loop = value; - this.onChange(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "color", { - get: function () { - return this._color; - }, - set: function (value) { - if (this._color != value) { - this._color = value; - this.updateGear(4); - if (this._content) - this._content.tint = value; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "content", { - get: function () { - return; - }, - enumerable: true, - configurable: true - }); - GLoader3D.prototype.loadContent = function () { - this.clearContent(); - if (!this._url) - return; - if (fgui.ToolSet.startsWith(this._url, "ui://")) - this.loadFromPackage(this._url); - else - this.loadExternal(); - }; - GLoader3D.prototype.loadFromPackage = function (itemURL) { - this._contentItem = fgui.UIPackage.getItemByURL(itemURL); - if (this._contentItem) { - this._contentItem = this._contentItem.getBranch(); - this.sourceWidth = this._contentItem.width; - this.sourceHeight = this._contentItem.height; - this._contentItem = this._contentItem.getHighResolution(); - if (this._autoSize) - this.setSize(this.sourceWidth, this.sourceHeight); - if (this._contentItem.type == fgui.PackageItemType.Spine || this._contentItem.type == fgui.PackageItemType.DragonBones) - this._contentItem.owner.getItemAssetAsync(this._contentItem, this.onLoaded.bind(this)); - } - }; - GLoader3D.prototype.onLoaded = function (err, item) { - if (this._contentItem != item) - return; - if (err) - console.warn(err); - if (!this._contentItem.asset) - return; - if (this._contentItem.type == fgui.PackageItemType.DragonBones) - this.setDragonBones(this._contentItem.armatureName, this._contentItem.asset.name, this._contentItem.atlasAsset.name, this._skinName, this._contentItem.skeletonAnchor); - }; - GLoader3D.prototype.setDragonBones = function (armatureName, dragonBonesName, skinName, textureAtlasName, anchor) { - this.url = null; - var egretFactory = dragonBones.EgretFactory.factory; - this._content = egretFactory.buildArmatureDisplay(armatureName, dragonBonesName, skinName, textureAtlasName); - this._container.addChild(this._content); - this._content.x = anchor.x; - this._content.y = anchor.y; - this._content.tint = this._color; - this.onChangeDragonBones(); - this.updateLayout(); - }; - GLoader3D.prototype.onChange = function () { - this.onChangeDragonBones(); - }; - GLoader3D.prototype.onChangeDragonBones = function () { - if (!(this._content instanceof dragonBones.EgretArmatureDisplay)) - return; - if (this._animationName) { - if (this._playing) - this._content.animation.play(this._animationName, this._loop ? 0 : 1); - else - this._content.animation.gotoAndStopByFrame(this._animationName, this._frame); - } - else - this._content.animation.reset(); - }; - GLoader3D.prototype.loadExternal = function () { - }; - GLoader3D.prototype.updateLayout = function () { - var cw = this.sourceWidth; - var ch = this.sourceHeight; - if (this._autoSize) { - this._updatingLayout = true; - if (cw == 0) - cw = 50; - if (ch == 0) - ch = 30; - this.setSize(cw, ch); - this._updatingLayout = false; - if (cw == this._width && ch == this._height) { - this._container.scaleX = this._container.scaleY = 1; - this._container.x = this._container.y = 0; - return; - } - } - var sx = 1, sy = 1; - if (this._fill != fgui.LoaderFillType.None) { - sx = this.width / this.sourceWidth; - sy = this.height / this.sourceHeight; - if (sx != 1 || sy != 1) { - if (this._fill == fgui.LoaderFillType.ScaleMatchHeight) - sx = sy; - else if (this._fill == fgui.LoaderFillType.ScaleMatchWidth) - sy = sx; - else if (this._fill == fgui.LoaderFillType.Scale) { - if (sx > sy) - sx = sy; - else - sy = sx; - } - else if (this._fill == fgui.LoaderFillType.ScaleNoBorder) { - if (sx > sy) - sy = sx; - else - sx = sy; - } - if (this._shrinkOnly) { - if (sx > 1) - sx = 1; - if (sy > 1) - sy = 1; - } - cw = this.sourceWidth * sx; - ch = this.sourceHeight * sy; - } - } - this._container.scaleX = sx; - this._container.scaleY = sy; - var nx, ny; - if (this._align == fgui.AlignType.Center) - nx = Math.floor((this.width - cw) / 2); - else if (this._align == fgui.AlignType.Right) - nx = this.width - cw; - else - nx = 0; - if (this._verticalAlign == fgui.VertAlignType.Middle) - ny = Math.floor((this.height - ch) / 2); - else if (this._verticalAlign == fgui.VertAlignType.Bottom) - ny = this.height - ch; - else - ny = 0; - this._container.x = nx; - this._container.y = ny; - }; - GLoader3D.prototype.clearContent = function () { - this._contentItem = null; - if (this._content) { - this._container.removeChild(this._content); - if ('dispose' in this._content) - this._content.dispose(); - this._content = null; - } - }; - GLoader3D.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (!this._updatingLayout) - this.updateLayout(); - }; - GLoader3D.prototype.handleGrayedChanged = function () { - }; - GLoader3D.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.color; - case fgui.ObjectPropID.Playing: - return this.playing; - case fgui.ObjectPropID.Frame: - return this.frame; - case fgui.ObjectPropID.TimeScale: - return 1; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GLoader3D.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.color = value; - break; - case fgui.ObjectPropID.Playing: - this.playing = value; - break; - case fgui.ObjectPropID.Frame: - this.frame = value; - break; - case fgui.ObjectPropID.TimeScale: - break; - case fgui.ObjectPropID.DeltaTime: - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GLoader3D.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._url = buffer.readS(); - this._align = buffer.readByte(); - this._verticalAlign = buffer.readByte(); - this._fill = buffer.readByte(); - this._shrinkOnly = buffer.readBool(); - this._autoSize = buffer.readBool(); - this._animationName = buffer.readS(); - this._skinName = buffer.readS(); - this._playing = buffer.readBool(); - this._frame = buffer.readInt(); - this._loop = buffer.readBool(); - if (buffer.readBool()) - this.color = buffer.readColor(); - if (this._url) - this.loadContent(); - }; - return GLoader3D; - }(fgui.GObject)); - fgui.GLoader3D = GLoader3D; -})(fgui || (fgui = {})); - -(function (fgui) { - var GMovieClip = (function (_super_1) { - __extends(GMovieClip, _super_1); - function GMovieClip() { - return _super_1.call(this) || this; - } - Object.defineProperty(GMovieClip.prototype, "color", { - get: function () { - return this._content.color; - }, - set: function (value) { - if (this._content.color != value) { - this._content.color = value; - this.updateGear(4); - } - }, - enumerable: true, - configurable: true - }); - GMovieClip.prototype.createDisplayObject = function () { - this._content = new fgui.MovieClip(); - this._content.touchEnabled = false; - this.setDisplayObject(this._content); - }; - Object.defineProperty(GMovieClip.prototype, "playing", { - get: function () { - return this._content.playing; - }, - set: function (value) { - if (this._content.playing != value) { - this._content.playing = value; - this.updateGear(5); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GMovieClip.prototype, "frame", { - get: function () { - return this._content.frame; - }, - set: function (value) { - if (this._content.frame != value) { - this._content.frame = value; - this.updateGear(5); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GMovieClip.prototype, "timeScale", { - get: function () { - return this._content.timeScale; - }, - set: function (value) { - this._content.timeScale = value; - }, - enumerable: true, - configurable: true - }); - GMovieClip.prototype.rewind = function () { - this._content.rewind(); - }; - GMovieClip.prototype.syncStatus = function (anotherMc) { - this._content.syncStatus(anotherMc._content); - }; - GMovieClip.prototype.advance = function (timeInMiniseconds) { - this._content.advance(timeInMiniseconds); - }; - GMovieClip.prototype.setPlaySettings = function (start, end, times, endAt, endCallback, callbackObj) { - this._content.setPlaySettings(start, end, times, endAt, endCallback, callbackObj); - }; - GMovieClip.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.color; - case fgui.ObjectPropID.Playing: - return this.playing; - case fgui.ObjectPropID.Frame: - return this.frame; - case fgui.ObjectPropID.TimeScale: - return this.timeScale; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GMovieClip.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.color = value; - break; - case fgui.ObjectPropID.Playing: - this.playing = value; - break; - case fgui.ObjectPropID.Frame: - this.frame = value; - break; - case fgui.ObjectPropID.TimeScale: - this.timeScale = value; - break; - case fgui.ObjectPropID.DeltaTime: - this.advance(value); - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GMovieClip.prototype.constructFromResource = function () { - var contentItem = this.packageItem.getBranch(); - this.sourceWidth = contentItem.width; - this.sourceHeight = contentItem.height; - this.initWidth = this.sourceWidth; - this.initHeight = this.sourceHeight; - this.setSize(this.sourceWidth, this.sourceHeight); - contentItem = contentItem.getHighResolution(); - contentItem.load(); - this._content.interval = contentItem.interval; - this._content.swing = contentItem.swing; - this._content.repeatDelay = contentItem.repeatDelay; - this._content.frames = contentItem.frames; - this._content.smoothing = contentItem.smoothing; - }; - GMovieClip.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - if (buffer.readBool()) - this.color = buffer.readColor(); - buffer.readByte(); - this._content.frame = buffer.readInt(); - this._content.playing = buffer.readBool(); - }; - return GMovieClip; - }(fgui.GObject)); - fgui.GMovieClip = GMovieClip; -})(fgui || (fgui = {})); - -(function (fgui) { - var GProgressBar = (function (_super_1) { - __extends(GProgressBar, _super_1); - function GProgressBar() { - var _this = _super_1.call(this) || this; - _this._min = 0; - _this._max = 0; - _this._value = 0; - _this._barMaxWidth = 0; - _this._barMaxHeight = 0; - _this._barMaxWidthDelta = 0; - _this._barMaxHeightDelta = 0; - _this._barStartX = 0; - _this._barStartY = 0; - _this._titleType = fgui.ProgressTitleType.Percent; - _this._value = 50; - _this._max = 100; - return _this; - } - Object.defineProperty(GProgressBar.prototype, "titleType", { - get: function () { - return this._titleType; - }, - set: function (value) { - if (this._titleType != value) { - this._titleType = value; - this.update(this._value); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GProgressBar.prototype, "min", { - get: function () { - return this._min; - }, - set: function (value) { - if (this._min != value) { - this._min = value; - this.update(this._value); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GProgressBar.prototype, "max", { - get: function () { - return this._max; - }, - set: function (value) { - if (this._max != value) { - this._max = value; - this.update(this._value); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GProgressBar.prototype, "value", { - get: function () { - return this._value; - }, - set: function (value) { - if (this._value != value) { - fgui.GTween.kill(this, false, this.update); - this._value = value; - this.update(value); - } - }, - enumerable: true, - configurable: true - }); - GProgressBar.prototype.tweenValue = function (value, duration) { - var oldValule; - var tweener = fgui.GTween.getTween(this, this.update); - if (tweener) { - oldValule = tweener.value.x; - tweener.kill(); - } - else - oldValule = this._value; - this._value = value; - return fgui.GTween.to(oldValule, this._value, duration).setTarget(this, this.update).setEase(fgui.EaseType.Linear); - }; - GProgressBar.prototype.update = function (newValue) { - var percent = fgui.ToolSet.clamp01((newValue - this._min) / (this._max - this._min)); - if (this._titleObject) { - switch (this._titleType) { - case fgui.ProgressTitleType.Percent: - this._titleObject.text = Math.floor(percent * 100) + "%"; - break; - case fgui.ProgressTitleType.ValueAndMax: - this._titleObject.text = Math.floor(newValue) + "/" + Math.floor(this._max); - break; - case fgui.ProgressTitleType.Value: - this._titleObject.text = "" + Math.floor(newValue); - break; - case fgui.ProgressTitleType.Max: - this._titleObject.text = "" + Math.floor(this._max); - break; - } - } - var fullWidth = this.width - this._barMaxWidthDelta; - var fullHeight = this.height - this._barMaxHeightDelta; - if (!this._reverse) { - if (this._barObjectH) { - if (!this.setFillAmount(this._barObjectH, percent)) - this._barObjectH.width = Math.round(fullWidth * percent); - } - if (this._barObjectV) { - if (!this.setFillAmount(this._barObjectV, percent)) - this._barObjectV.height = Math.round(fullHeight * percent); - } - } - else { - if (this._barObjectH) { - if (!this.setFillAmount(this._barObjectH, 1 - percent)) { - this._barObjectH.width = Math.round(fullWidth * percent); - this._barObjectH.x = this._barStartX + (fullWidth - this._barObjectH.width); - } - } - if (this._barObjectV) { - if (!this.setFillAmount(this._barObjectV, 1 - percent)) { - this._barObjectV.height = Math.round(fullHeight * percent); - this._barObjectV.y = this._barStartY + (fullHeight - this._barObjectV.height); - } - } - } - if (this._aniObject) - this._aniObject.setProp(fgui.ObjectPropID.Frame, Math.floor(percent * 100)); - }; - GProgressBar.prototype.setFillAmount = function (bar, percent) { - if (((bar instanceof fgui.GImage) || (bar instanceof fgui.GLoader)) && bar.fillMethod != fgui.FillMethod.None) { - bar.fillAmount = percent; - return true; - } - else - return false; - }; - GProgressBar.prototype.constructExtension = function (buffer) { - buffer.seek(0, 6); - this._titleType = buffer.readByte(); - this._reverse = buffer.readBool(); - this._titleObject = this.getChild("title"); - this._barObjectH = this.getChild("bar"); - this._barObjectV = this.getChild("bar_v"); - this._aniObject = this.getChild("ani"); - if (this._barObjectH) { - this._barMaxWidth = this._barObjectH.width; - this._barMaxWidthDelta = this.width - this._barMaxWidth; - this._barStartX = this._barObjectH.x; - } - if (this._barObjectV) { - this._barMaxHeight = this._barObjectV.height; - this._barMaxHeightDelta = this.height - this._barMaxHeight; - this._barStartY = this._barObjectV.y; - } - }; - GProgressBar.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (this._barObjectH) - this._barMaxWidth = this.width - this._barMaxWidthDelta; - if (this._barObjectV) - this._barMaxHeight = this.height - this._barMaxHeightDelta; - if (!this._underConstruct) - this.update(this._value); - }; - GProgressBar.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!buffer.seek(beginPos, 6)) { - this.update(this._value); - return; - } - if (buffer.readByte() != this.packageItem.objectType) { - this.update(this._value); - return; - } - this._value = buffer.readInt(); - this._max = buffer.readInt(); - if (buffer.version >= 2) - this._min = buffer.readInt(); - this.update(this._value); - }; - return GProgressBar; - }(fgui.GComponent)); - fgui.GProgressBar = GProgressBar; -})(fgui || (fgui = {})); - -(function (fgui) { - var GTextField = (function (_super_1) { - __extends(GTextField, _super_1); - function GTextField() { - var _this = _super_1.call(this) || this; - _this._fontSize = 0; - _this._leading = 0; - _this._letterSpacing = 0; - _this._textWidth = 0; - _this._textHeight = 0; - _this._fontSize = 12; - _this._align = fgui.AlignType.Left; - _this._verticalAlign = fgui.VertAlignType.Top; - _this._text = ""; - _this._leading = 3; - _this._color = 0; - _this._autoSize = fgui.AutoSizeType.Both; - _this._widthAutoSize = true; - _this._heightAutoSize = true; - return _this; - } - GTextField.prototype.createDisplayObject = function () { - this._textField = new egret.TextField(); - this._textField.touchEnabled = false; - this.setDisplayObject(this._textField); - }; - GTextField.prototype.switchBitmapMode = function (val) { - if (val && this.displayObject == this._textField) { - if (this._bitmapContainer == null) - this._bitmapContainer = new egret.Sprite(); - this.switchDisplayObject(this._bitmapContainer); - } - else if (!val && this.displayObject == this._bitmapContainer) - this.switchDisplayObject(this._textField); - }; - GTextField.prototype.dispose = function () { - _super_1.prototype.dispose.call(this); - this._bitmapFont = null; - this._requireRender = false; - }; - Object.defineProperty(GTextField.prototype, "text", { - get: function () { - return this._text; - }, - set: function (value) { - this._text = value; - if (this._text == null) - this._text = ""; - this.updateGear(6); - if (this.parent && this.parent._underConstruct) - this.renderNow(); - else - this.render(); - }, - enumerable: true, - configurable: true - }); - GTextField.prototype.updateTextFieldText = function () { - var text2 = this._text; - if (this._templateVars) - text2 = this.parseTemplate(text2); - if (this._ubbEnabled) { - var arr = GTextField._htmlParser.parser(fgui.UBBParser.inst.parse(fgui.ToolSet.encodeHTML(text2))); - if (this._underline) { - for (var i = 0; i < arr.length; i++) { - var element = arr[i]; - if (element.style) - element.style.underline = true; - else - element.style = { underline: true }; - } - } - this._textField.textFlow = arr; - } - else if (this._underline) { - var arr = new Array(1); - arr[0] = { text: text2, style: { underline: true } }; - this._textField.textFlow = arr; - } - else - this._textField.text = text2; - }; - Object.defineProperty(GTextField.prototype, "font", { - get: function () { - return this._font; - }, - set: function (value) { - if (this._font != value) { - this._font = value; - this.updateTextFormat(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "fontSize", { - get: function () { - return this._fontSize; - }, - set: function (value) { - if (value < 0) - return; - if (this._fontSize != value) { - this._fontSize = value; - this.updateTextFormat(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "color", { - get: function () { - return this._color; - }, - set: function (value) { - if (this._color != value) { - this._color = value; - this.updateGear(4); - this.updateTextFormat(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "align", { - get: function () { - return this._align; - }, - set: function (value) { - if (this._align != value) { - this._align = value; - this._textField.textAlign = this.getAlignTypeString(this._align); - if (this._bitmapFont && !this._underConstruct) - this.render(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "verticalAlign", { - get: function () { - return this._verticalAlign; - }, - set: function (value) { - if (this._verticalAlign != value) { - this._verticalAlign = value; - this._textField.verticalAlign = this.getVertAlignTypeString(this._verticalAlign); - if (this._bitmapFont && !this._underConstruct) - this.render(); - } - }, - enumerable: true, - configurable: true - }); - GTextField.prototype.getAlignTypeString = function (type) { - return type == fgui.AlignType.Left ? egret.HorizontalAlign.LEFT : - (type == fgui.AlignType.Center ? egret.HorizontalAlign.CENTER : egret.HorizontalAlign.RIGHT); - }; - GTextField.prototype.getVertAlignTypeString = function (type) { - return type == fgui.VertAlignType.Top ? egret.VerticalAlign.TOP : - (type == fgui.VertAlignType.Middle ? egret.VerticalAlign.MIDDLE : egret.VerticalAlign.BOTTOM); - }; - Object.defineProperty(GTextField.prototype, "leading", { - get: function () { - return this._leading; - }, - set: function (value) { - if (this._leading != value) { - this._leading = value; - this.updateTextFormat(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "letterSpacing", { - get: function () { - return this._letterSpacing; - }, - set: function (value) { - if (this._letterSpacing != value) { - this._letterSpacing = value; - this.updateTextFormat(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "underline", { - get: function () { - return this._underline; - }, - set: function (value) { - this._underline = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "bold", { - get: function () { - return this._textField.bold; - }, - set: function (value) { - this._textField.bold = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "italic", { - get: function () { - return this._textField.italic; - }, - set: function (value) { - this._textField.italic = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "singleLine", { - get: function () { - return !this._textField.multiline; - }, - set: function (value) { - value = !value; - if (this._textField.multiline != value) { - this._textField.multiline = value; - this.render(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "stroke", { - get: function () { - return this._textField.stroke; - }, - set: function (value) { - this._textField.stroke = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "strokeColor", { - get: function () { - return this._textField.strokeColor; - }, - set: function (value) { - this._textField.strokeColor = value; - this.updateGear(4); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "ubbEnabled", { - get: function () { - return this._ubbEnabled; - }, - set: function (value) { - if (this._ubbEnabled != value) { - this._ubbEnabled = value; - this.render(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "autoSize", { - get: function () { - return this._autoSize; - }, - set: function (value) { - if (this._autoSize != value) { - this._autoSize = value; - this._widthAutoSize = value == fgui.AutoSizeType.Both; - this._heightAutoSize = value == fgui.AutoSizeType.Both || value == fgui.AutoSizeType.Height; - this.render(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "textWidth", { - get: function () { - if (this._requireRender) - this.renderNow(); - return this._textWidth; - }, - enumerable: true, - configurable: true - }); - GTextField.prototype.ensureSizeCorrect = function () { - if (this._sizeDirty && this._requireRender) - this.renderNow(); - }; - GTextField.prototype.updateTextFormat = function () { - this._textField.size = this._fontSize; - this._bitmapFont = null; - if (fgui.ToolSet.startsWith(this._font, "ui://")) { - var pi = fgui.UIPackage.getItemByURL(this._font); - if (pi) - this._bitmapFont = pi.owner.getItemAsset(pi); - } - if (this._bitmapFont == null) { - if (this._font) - this._textField.fontFamily = this._font; - else - this._textField.fontFamily = fgui.UIConfig.defaultFont; - } - if (this.grayed) - this._textField.textColor = 0xAAAAAA; - else - this._textField.textColor = this._color; - this._textField.lineSpacing = this._leading; - if (!this._underConstruct) - this.render(); - }; - GTextField.prototype.render = function () { - if (!this._requireRender) { - this._requireRender = true; - egret.callLater(this.__render, this); - } - if (!this._sizeDirty && (this._widthAutoSize || this._heightAutoSize)) { - this._sizeDirty = true; - this.dispatchEventWith(fgui.GObject.SIZE_DELAY_CHANGE); - } - }; - GTextField.prototype.__render = function () { - if (this._requireRender) - this.renderNow(); - }; - GTextField.prototype.renderNow = function (updateBounds) { - if (updateBounds === void 0) { updateBounds = true; } - this._requireRender = false; - this._sizeDirty = false; - if (this._bitmapFont) { - this.renderWithBitmapFont(updateBounds); - return; - } - this.switchBitmapMode(false); - this._textField.width = this._widthAutoSize ? (this.maxWidth <= 0 ? 10000 : this.maxWidth) : Math.ceil(this.width); - this.updateTextFieldText(); - this._textWidth = Math.ceil(this._textField.textWidth); - if (this._textWidth > 0) - this._textWidth += 4; - this._textHeight = Math.ceil(this._textField.textHeight); - if (this._textHeight > 0) - this._textHeight += 4; - var w, h = 0; - if (this._widthAutoSize) { - w = this._textWidth; - this._textField.width = w; - } - else - w = this.width; - if (this._heightAutoSize) { - h = this._textHeight; - if (this._textField.height != this._textHeight) - this._textField.height = this._textHeight; - } - else { - h = this.height; - if (this._textHeight > h) - this._textHeight = h; - } - if (updateBounds) { - this._updatingSize = true; - this.setSize(w, h); - this._updatingSize = false; - } - }; - GTextField.prototype.renderWithBitmapFont = function (updateBounds) { - this.switchBitmapMode(true); - if (!this._bitmapPool) - this._bitmapPool = []; - var cnt = this._bitmapContainer.numChildren; - for (var i = 0; i < cnt; i++) { - var obj = this._bitmapContainer.getChildAt(i); - this._bitmapPool.push(obj); - } - this._bitmapContainer.removeChildren(); - if (!this._lines) - this._lines = new Array(); - else - returnList(this._lines); - var letterSpacing = this._letterSpacing; - var lineSpacing = this._leading - 1; - var rectWidth = this.width - GUTTER_X * 2; - var lineWidth = 0, lineHeight = 0, lineTextHeight = 0; - var glyphWidth = 0, glyphHeight = 0; - var wordChars = 0, wordStart = 0, wordEnd = 0; - var lastLineHeight = 0; - var lineBuffer = ""; - var lineY = GUTTER_Y; - var line; - var wordWrap = !this._widthAutoSize && this._textField.multiline; - var fontScale = this._bitmapFont.resizable ? this._fontSize / this._bitmapFont.size : 1; - var tint = this._bitmapFont.tint; - this._textWidth = 0; - this._textHeight = 0; - var text2 = this._text; - if (this._templateVars) - text2 = this.parseTemplate(text2); - var textLength = text2.length; - for (var offset = 0; offset < textLength; ++offset) { - var ch = text2.charAt(offset); - var cc = ch.charCodeAt(0); - if (cc == 10) { - lineBuffer += ch; - line = borrow(); - line.width = lineWidth; - if (lineTextHeight == 0) { - if (lastLineHeight == 0) - lastLineHeight = this._fontSize; - if (lineHeight == 0) - lineHeight = lastLineHeight; - lineTextHeight = lineHeight; - } - line.height = lineHeight; - lastLineHeight = lineHeight; - line.textHeight = lineTextHeight; - line.text = lineBuffer; - line.y = lineY; - lineY += (line.height + lineSpacing); - if (line.width > this._textWidth) - this._textWidth = line.width; - this._lines.push(line); - lineBuffer = ""; - lineWidth = 0; - lineHeight = 0; - lineTextHeight = 0; - wordChars = 0; - wordStart = 0; - wordEnd = 0; - continue; - } - if (cc >= 65 && cc <= 90 || cc >= 97 && cc <= 122) { - if (wordChars == 0) - wordStart = lineWidth; - wordChars++; - } - else { - if (wordChars > 0) - wordEnd = lineWidth; - wordChars = 0; - } - if (cc == 32) { - glyphWidth = Math.ceil(this._fontSize / 2); - glyphHeight = this._fontSize; - } - else { - var glyph = this._bitmapFont.glyphs[ch]; - if (glyph) { - glyphWidth = Math.ceil(glyph.advance * fontScale); - glyphHeight = Math.ceil(glyph.lineHeight * fontScale); - } - else { - glyphWidth = 0; - glyphHeight = 0; - } - } - if (glyphHeight > lineTextHeight) - lineTextHeight = glyphHeight; - if (glyphHeight > lineHeight) - lineHeight = glyphHeight; - if (lineWidth != 0) - lineWidth += letterSpacing; - lineWidth += glyphWidth; - if (!wordWrap || lineWidth <= rectWidth) { - lineBuffer += ch; - } - else { - line = borrow(); - line.height = lineHeight; - line.textHeight = lineTextHeight; - if (lineBuffer.length == 0) { - line.text = ch; - } - else if (wordChars > 0 && wordEnd > 0) { - lineBuffer += ch; - var len = lineBuffer.length - wordChars; - line.text = fgui.ToolSet.trimRight(lineBuffer.substr(0, len)); - line.width = wordEnd; - lineBuffer = lineBuffer.substr(len); - lineWidth -= wordStart; - } - else { - line.text = lineBuffer; - line.width = lineWidth - (glyphWidth + letterSpacing); - lineBuffer = ch; - lineWidth = glyphWidth; - lineHeight = glyphHeight; - lineTextHeight = glyphHeight; - } - line.y = lineY; - lineY += (line.height + lineSpacing); - if (line.width > this._textWidth) - this._textWidth = line.width; - wordChars = 0; - wordStart = 0; - wordEnd = 0; - this._lines.push(line); - } - } - if (lineBuffer.length > 0) { - line = borrow(); - line.width = lineWidth; - if (lineHeight == 0) - lineHeight = lastLineHeight; - if (lineTextHeight == 0) - lineTextHeight = lineHeight; - line.height = lineHeight; - line.textHeight = lineTextHeight; - line.text = lineBuffer; - line.y = lineY; - if (line.width > this._textWidth) - this._textWidth = line.width; - this._lines.push(line); - } - if (this._textWidth > 0) - this._textWidth += GUTTER_X * 2; - var count = this._lines.length; - if (count == 0) { - this._textHeight = 0; - } - else { - line = this._lines[this._lines.length - 1]; - this._textHeight = line.y + line.height + GUTTER_Y; - } - var w, h = 0; - if (this._widthAutoSize) { - if (this._textWidth == 0) - w = 0; - else - w = this._textWidth; - } - else - w = this.width; - if (this._heightAutoSize) { - if (this._textHeight == 0) - h = 0; - else - h = this._textHeight; - } - else - h = this.height; - if (updateBounds) { - this._updatingSize = true; - this.setSize(w, h); - this._updatingSize = false; - } - if (w == 0 || h == 0) - return; - var charX = GUTTER_X; - var lineIndent = 0; - var charIndent = 0; - rectWidth = this.width - GUTTER_X * 2; - var lineCount = this._lines.length; - for (var i = 0; i < lineCount; i++) { - line = this._lines[i]; - charX = GUTTER_X; - if (this._align == fgui.AlignType.Center) - lineIndent = (rectWidth - line.width) / 2; - else if (this._align == fgui.AlignType.Right) - lineIndent = rectWidth - line.width; - else - lineIndent = 0; - textLength = line.text.length; - for (var j = 0; j < textLength; j++) { - ch = line.text.charAt(j); - cc = ch.charCodeAt(0); - if (cc == 10) - continue; - if (cc == 32) { - charX += letterSpacing + Math.ceil(this._fontSize / 2); - continue; - } - glyph = this._bitmapFont.glyphs[ch]; - if (glyph) { - charIndent = (line.height + line.textHeight) / 2 - Math.ceil(glyph.lineHeight * fontScale); - var bm; - if (this._bitmapPool.length) - bm = this._bitmapPool.pop(); - else { - bm = new egret.Bitmap(); - bm.smoothing = true; - } - bm.x = charX + lineIndent + Math.ceil(glyph.x * fontScale); - bm.y = line.y + charIndent + Math.ceil(glyph.y * fontScale); - bm["$backupY"] = bm.y; - bm.texture = glyph.texture; - bm.scaleX = fontScale; - bm.scaleY = fontScale; - if (tint) - bm.tint = this._color; - else - bm.tint = 0xFFFFFF; - this._bitmapContainer.addChild(bm); - charX += letterSpacing + Math.ceil(glyph.advance * fontScale); - } - else { - charX += letterSpacing; - } - } - } - this.doAlign(); - }; - GTextField.prototype.handleSizeChanged = function () { - if (this._updatingSize) - return; - if (this._bitmapFont) { - if (!this._widthAutoSize) - this.render(); - else - this.doAlign(); - } - else { - if (this._underConstruct) { - this._textField.width = this.width; - this._textField.height = this.height; - } - else { - if (!this._widthAutoSize) { - if (!this._heightAutoSize) { - this._textField.width = this.width; - this._textField.height = this.height; - } - else - this._textField.width = this.width; - } - } - } - }; - GTextField.prototype.parseTemplate = function (template) { - var pos1 = 0, pos2, pos3; - var tag; - var value; - var result = ""; - while ((pos2 = template.indexOf("{", pos1)) != -1) { - if (pos2 > 0 && template.charCodeAt(pos2 - 1) == 92) { - result += template.substring(pos1, pos2 - 1); - result += "{"; - pos1 = pos2 + 1; - continue; - } - result += template.substring(pos1, pos2); - pos1 = pos2; - pos2 = template.indexOf("}", pos1); - if (pos2 == -1) - break; - if (pos2 == pos1 + 1) { - result += template.substr(pos1, 2); - pos1 = pos2 + 1; - continue; - } - tag = template.substring(pos1 + 1, pos2); - pos3 = tag.indexOf("="); - if (pos3 != -1) { - value = this._templateVars[tag.substring(0, pos3)]; - if (value == null) - result += tag.substring(pos3 + 1); - else - result += value; - } - else { - value = this._templateVars[tag]; - if (value != null) - result += value; - } - pos1 = pos2 + 1; - } - if (pos1 < template.length) - result += template.substr(pos1); - return result; - }; - Object.defineProperty(GTextField.prototype, "templateVars", { - get: function () { - return this._templateVars; - }, - set: function (value) { - if (!this._templateVars && !value) - return; - this._templateVars = value; - this.flushVars(); - }, - enumerable: true, - configurable: true - }); - GTextField.prototype.setVar = function (name, value) { - if (!this._templateVars) - this._templateVars = {}; - this._templateVars[name] = value; - return this; - }; - GTextField.prototype.flushVars = function () { - this.render(); - }; - GTextField.prototype.handleGrayedChanged = function () { - _super_1.prototype.handleGrayedChanged.call(this); - this.updateTextFormat(); - }; - GTextField.prototype.doAlign = function () { - var yOffset; - if (this._verticalAlign == fgui.VertAlignType.Top || this._textHeight == 0) - yOffset = GUTTER_Y; - else { - var dh = this.height - this._textHeight; - if (dh < 0) - dh = 0; - if (this._verticalAlign == fgui.VertAlignType.Middle) - yOffset = Math.floor(dh / 2); - else - yOffset = Math.floor(dh); - } - var cnt = this._bitmapContainer.numChildren; - for (var i = 0; i < cnt; i++) { - var obj = this._bitmapContainer.getChildAt(i); - obj.y = obj["$backupY"] + yOffset; - } - }; - GTextField.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.color; - case fgui.ObjectPropID.OutlineColor: - return this.strokeColor; - case fgui.ObjectPropID.FontSize: - return this.fontSize; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GTextField.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.color = value; - break; - case fgui.ObjectPropID.OutlineColor: - this.strokeColor = value; - break; - case fgui.ObjectPropID.FontSize: - this.fontSize = value; - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GTextField.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._font = buffer.readS(); - this._fontSize = buffer.readShort(); - this._color = buffer.readColor(); - this.align = buffer.readByte(); - this.verticalAlign = buffer.readByte(); - this._leading = buffer.readShort(); - this._letterSpacing = buffer.readShort(); - this._ubbEnabled = buffer.readBool(); - this._autoSize = buffer.readByte(); - this._widthAutoSize = this._autoSize == fgui.AutoSizeType.Both; - this._heightAutoSize = this._autoSize == fgui.AutoSizeType.Both || this._autoSize == fgui.AutoSizeType.Height; - this._underline = buffer.readBool(); - this._textField.italic = buffer.readBool(); - this._textField.bold = buffer.readBool(); - this._textField.multiline = !buffer.readBool(); - if (buffer.readBool()) { - this._textField.strokeColor = buffer.readColor(); - this.stroke = buffer.readFloat() + 1; - } - if (buffer.readBool()) - buffer.skip(12); - if (buffer.readBool()) - this._templateVars = {}; - }; - GTextField.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - this.updateTextFormat(); - buffer.seek(beginPos, 6); - var str = buffer.readS(); - if (str != null) - this.text = str; - this._sizeDirty = false; - }; - GTextField._htmlParser = new egret.HtmlTextParser(); - return GTextField; - }(fgui.GObject)); - fgui.GTextField = GTextField; - var pool = []; - function borrow() { - if (pool.length) { - var ret = pool.pop(); - ret.width = 0; - ret.height = 0; - ret.textHeight = 0; - ret.text = null; - ret.y = 0; - return ret; - } - else - return { - width: 0, - height: 0, - textHeight: 0, - text: null, - y: 0 - }; - } - function returnList(value) { - var length = value.length; - for (var i = 0; i < length; i++) { - var li = value[i]; - pool.push(li); - } - value.length = 0; - } - var GUTTER_X = 2; - var GUTTER_Y = 2; -})(fgui || (fgui = {})); - -(function (fgui) { - var GRichTextField = (function (_super_1) { - __extends(GRichTextField, _super_1); - function GRichTextField() { - var _this = _super_1.call(this) || this; - _this._textField.touchEnabled = true; - return _this; - } - GRichTextField.prototype.updateTextFieldText = function () { - var text2 = this._text; - if (this._templateVars) - text2 = this.parseTemplate(text2); - var arr; - if (this._ubbEnabled) - arr = fgui.GTextField._htmlParser.parser(fgui.UBBParser.inst.parse(text2)); - else - arr = fgui.GTextField._htmlParser.parser(text2); - if (this._underline) { - for (var i = 0; i < arr.length; i++) { - var element = arr[i]; - if (element.style) - element.style.underline = true; - else - element.style = { underline: true }; - } - } - this._textField.textFlow = arr; - }; - return GRichTextField; - }(fgui.GTextField)); - fgui.GRichTextField = GRichTextField; -})(fgui || (fgui = {})); - -(function (fgui) { - var GRoot = (function (_super_1) { - __extends(GRoot, _super_1); - function GRoot() { - var _this = _super_1.call(this) || this; - if (GRoot._inst == null) - GRoot._inst = _this; - _this.opaque = false; - _this._volumeScale = 1; - _this._popupStack = new Array(); - _this._justClosedPopups = new Array(); - _this.displayObject.addEventListener(egret.Event.ADDED_TO_STAGE, _this.__addedToStage, _this); - return _this; - } - Object.defineProperty(GRoot, "inst", { - get: function () { - if (GRoot._inst == null) - new GRoot(); - return GRoot._inst; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GRoot.prototype, "nativeStage", { - get: function () { - return this._nativeStage; - }, - enumerable: true, - configurable: true - }); - GRoot.prototype.showWindow = function (win) { - this.addChild(win); - win.requestFocus(); - if (win.x > this.width) - win.x = this.width - win.width; - else if (win.x + win.width < 0) - win.x = 0; - if (win.y > this.height) - win.y = this.height - win.height; - else if (win.y + win.height < 0) - win.y = 0; - this.adjustModalLayer(); - }; - GRoot.prototype.hideWindow = function (win) { - win.hide(); - }; - GRoot.prototype.hideWindowImmediately = function (win) { - if (win.parent == this) - this.removeChild(win); - this.adjustModalLayer(); - }; - GRoot.prototype.bringToFront = function (win) { - var cnt = this.numChildren; - var i; - if (this._modalLayer.parent != null && !win.modal) - i = this.getChildIndex(this._modalLayer) - 1; - else - i = cnt - 1; - for (; i >= 0; i--) { - var g = this.getChildAt(i); - if (g == win) - return; - if (g instanceof fgui.Window) - break; - } - if (i >= 0) - this.setChildIndex(win, i); - }; - GRoot.prototype.showModalWait = function (msg) { - if (fgui.UIConfig.globalModalWaiting != null) { - if (this._modalWaitPane == null) - this._modalWaitPane = fgui.UIPackage.createObjectFromURL(fgui.UIConfig.globalModalWaiting); - this._modalWaitPane.setSize(this.width, this.height); - this._modalWaitPane.addRelation(this, fgui.RelationType.Size); - this.addChild(this._modalWaitPane); - this._modalWaitPane.text = msg; - } - }; - GRoot.prototype.closeModalWait = function () { - if (this._modalWaitPane != null && this._modalWaitPane.parent != null) - this.removeChild(this._modalWaitPane); - }; - GRoot.prototype.closeAllExceptModals = function () { - var arr = this._children.slice(); - var cnt = arr.length; - for (var i = 0; i < cnt; i++) { - var g = arr[i]; - if ((g instanceof fgui.Window) && !g.modal) - g.hide(); - } - }; - GRoot.prototype.closeAllWindows = function () { - var arr = this._children.slice(); - var cnt = arr.length; - for (var i = 0; i < cnt; i++) { - var g = arr[i]; - if (g instanceof fgui.Window) - g.hide(); - } - }; - GRoot.prototype.getTopWindow = function () { - var cnt = this.numChildren; - for (var i = cnt - 1; i >= 0; i--) { - var g = this.getChildAt(i); - if (g instanceof fgui.Window) { - return g; - } - } - return null; - }; - Object.defineProperty(GRoot.prototype, "modalLayer", { - get: function () { - return this._modalLayer; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GRoot.prototype, "hasModalWindow", { - get: function () { - return this._modalLayer.parent != null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GRoot.prototype, "modalWaiting", { - get: function () { - return this._modalWaitPane && this._modalWaitPane.inContainer; - }, - enumerable: true, - configurable: true - }); - GRoot.prototype.showPopup = function (popup, target, dir) { - if (this._popupStack.length > 0) { - var k = this._popupStack.indexOf(popup); - if (k != -1) { - for (var i = this._popupStack.length - 1; i >= k; i--) - this.removeChild(this._popupStack.pop()); - } - } - this._popupStack.push(popup); - if (target) { - var p = target; - while (p) { - if (p.parent == this) { - if (popup.sortingOrder < p.sortingOrder) { - popup.sortingOrder = p.sortingOrder; - } - break; - } - p = p.parent; - } - } - this.addChild(popup); - this.adjustModalLayer(); - var pos; - var sizeW = 0, sizeH = 0; - if (target) { - pos = target.localToRoot(); - sizeW = target.width; - sizeH = target.height; - } - else { - pos = this.globalToLocal(GRoot.mouseX, GRoot.mouseY); - } - var xx, yy; - xx = pos.x; - if (xx + popup.width > this.width) - xx = xx + sizeW - popup.width; - yy = pos.y + sizeH; - if (((dir === undefined || dir === fgui.PopupDirection.Auto) && pos.y + popup.height > this.height) - || dir === false || dir === fgui.PopupDirection.Up) { - yy = pos.y - popup.height - 1; - if (yy < 0) { - yy = 0; - xx += sizeW / 2; - } - } - popup.x = xx; - popup.y = yy; - }; - GRoot.prototype.togglePopup = function (popup, target, dir) { - if (this._justClosedPopups.indexOf(popup) != -1) - return; - this.showPopup(popup, target, dir); - }; - GRoot.prototype.hidePopup = function (popup) { - if (popup) { - var k = this._popupStack.indexOf(popup); - if (k != -1) { - for (var i = this._popupStack.length - 1; i >= k; i--) - this.closePopup(this._popupStack.pop()); - } - } - else { - var cnt = this._popupStack.length; - for (i = cnt - 1; i >= 0; i--) - this.closePopup(this._popupStack[i]); - this._popupStack.length = 0; - } - }; - Object.defineProperty(GRoot.prototype, "hasAnyPopup", { - get: function () { - return this._popupStack.length != 0; - }, - enumerable: true, - configurable: true - }); - GRoot.prototype.closePopup = function (target) { - if (target.parent) { - if (target instanceof fgui.Window) - target.hide(); - else - this.removeChild(target); - } - }; - GRoot.prototype.showTooltips = function (msg) { - if (this._defaultTooltipWin == null) { - var resourceURL = fgui.UIConfig.tooltipsWin; - if (!resourceURL) { - console.error("UIConfig.tooltipsWin not defined"); - return; - } - this._defaultTooltipWin = fgui.UIPackage.createObjectFromURL(resourceURL); - } - this._defaultTooltipWin.text = msg; - this.showTooltipsWin(this._defaultTooltipWin); - }; - GRoot.prototype.showTooltipsWin = function (tooltipWin, position) { - this.hideTooltips(); - this._tooltipWin = tooltipWin; - var xx = 0; - var yy = 0; - if (!position) { - xx = GRoot.mouseX + 10; - yy = GRoot.mouseY + 20; - } - else { - xx = position.x; - yy = position.y; - } - var pt = this.globalToLocal(xx, yy); - xx = pt.x; - yy = pt.y; - if (xx + this._tooltipWin.width > this.width) { - xx = xx - this._tooltipWin.width - 1; - if (xx < 0) - xx = 10; - } - if (yy + this._tooltipWin.height > this.height) { - yy = yy - this._tooltipWin.height - 1; - if (xx - this._tooltipWin.width - 1 > 0) - xx = xx - this._tooltipWin.width - 1; - if (yy < 0) - yy = 10; - } - this._tooltipWin.x = xx; - this._tooltipWin.y = yy; - this.addChild(this._tooltipWin); - }; - GRoot.prototype.hideTooltips = function () { - if (this._tooltipWin) { - if (this._tooltipWin.parent) - this.removeChild(this._tooltipWin); - this._tooltipWin = null; - } - }; - GRoot.prototype.getObjectUnderPoint = function (globalX, globalY) { - var ret = this._nativeStage.$hitTest(globalX, globalY); - if (ret) - return fgui.ToolSet.displayObjectToGObject(ret); - else - return null; - }; - Object.defineProperty(GRoot.prototype, "focus", { - get: function () { - return null; - }, - set: function (value) { - }, - enumerable: true, - configurable: true - }); - GRoot.prototype.setFocus = function (value) { - }; - Object.defineProperty(GRoot.prototype, "volumeScale", { - get: function () { - return this._volumeScale; - }, - set: function (value) { - this._volumeScale = value; - }, - enumerable: true, - configurable: true - }); - GRoot.prototype.playOneShotSound = function (sound, volumeScale) { - volumeScale = volumeScale || 1; - var vs = this._volumeScale * volumeScale; - var channel = sound.play(0, 1); - channel.volume = vs; - }; - GRoot.prototype.adjustModalLayer = function () { - var cnt = this.numChildren; - if (this._modalWaitPane && this._modalWaitPane.parent) - this.setChildIndex(this._modalWaitPane, cnt - 1); - for (var i = cnt - 1; i >= 0; i--) { - var g = this.getChildAt(i); - if ((g instanceof fgui.Window) && g.modal) { - if (this._modalLayer.parent == null) - this.addChildAt(this._modalLayer, i); - else - this.setChildIndexBefore(this._modalLayer, i); - return; - } - } - if (this._modalLayer.parent) - this.removeChild(this._modalLayer); - }; - GRoot.prototype.__addedToStage = function (evt) { - this.displayObject.removeEventListener(egret.Event.ADDED_TO_STAGE, this.__addedToStage, this); - this._nativeStage = this.displayObject.stage; - this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__stageMouseDownCapture, this, true); - this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_END, this.__stageMouseUpCapture, this, true); - this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__stageMouseMoveCapture, this, true); - this._modalLayer = new fgui.GGraph(); - this._modalLayer.setSize(this.width, this.height); - this._modalLayer.drawRect(0, 0, 0, fgui.UIConfig.modalLayerColor, fgui.UIConfig.modalLayerAlpha); - this._modalLayer.addRelation(this, fgui.RelationType.Size); - this.displayObject.stage.addEventListener(egret.Event.RESIZE, this.__winResize, this); - this.__winResize(null); - }; - GRoot.prototype.__stageMouseDownCapture = function (evt) { - GRoot.mouseX = evt.stageX; - GRoot.mouseY = evt.stageY; - GRoot.touchDown = true; - if (this._tooltipWin) - this.hideTooltips(); - this._justClosedPopups.length = 0; - if (this._popupStack.length > 0) { - var mc = (evt.target); - while (mc != this.displayObject.stage && mc) { - if (mc["$owner"]) { - var pindex = this._popupStack.indexOf(mc["$owner"]); - if (pindex != -1) { - for (var i = this._popupStack.length - 1; i > pindex; i--) { - var popup = this._popupStack.pop(); - this.closePopup(popup); - this._justClosedPopups.push(popup); - } - return; - } - } - mc = mc.parent; - } - var cnt = this._popupStack.length; - for (i = cnt - 1; i >= 0; i--) { - popup = this._popupStack[i]; - this.closePopup(popup); - this._justClosedPopups.push(popup); - } - this._popupStack.length = 0; - } - }; - GRoot.prototype.__stageMouseMoveCapture = function (evt) { - GRoot.mouseX = evt.stageX; - GRoot.mouseY = evt.stageY; - }; - GRoot.prototype.__stageMouseUpCapture = function (evt) { - GRoot.touchDown = false; - }; - GRoot.prototype.__winResize = function (evt) { - this.setSize(this._nativeStage.stageWidth, this._nativeStage.stageHeight); - }; - GRoot.prototype.updateContentScaleLevel = function () { - var ss = 1; - if (ss >= 3.5) - GRoot.contentScaleLevel = 3; - else if (ss >= 2.5) - GRoot.contentScaleLevel = 2; - else if (ss >= 1.5) - GRoot.contentScaleLevel = 1; - else - GRoot.contentScaleLevel = 0; - }; - GRoot.contentScaleLevel = 0; - GRoot.contentScaleFactor = 1; - return GRoot; - }(fgui.GComponent)); - fgui.GRoot = GRoot; -})(fgui || (fgui = {})); - -(function (fgui) { - var GScrollBar = (function (_super_1) { - __extends(GScrollBar, _super_1); - function GScrollBar() { - var _this = _super_1.call(this) || this; - _this._dragOffset = new egret.Point(); - _this._scrollPerc = 0; - return _this; - } - GScrollBar.prototype.setScrollPane = function (target, vertical) { - this._target = target; - this._vertical = vertical; - }; - GScrollBar.prototype.setDisplayPerc = function (value) { - if (this._vertical) { - if (!this._fixedGripSize) - this._grip.height = Math.floor(value * this._bar.height); - this._grip.y = this._bar.y + (this._bar.height - this._grip.height) * this._scrollPerc; - } - else { - if (!this._fixedGripSize) - this._grip.width = Math.floor(value * this._bar.width); - this._grip.x = this._bar.x + (this._bar.width - this._grip.width) * this._scrollPerc; - } - this._grip.visible = value != 0 && value != 1; - }; - GScrollBar.prototype.setScrollPerc = function (val) { - this._scrollPerc = val; - if (this._vertical) - this._grip.y = this._bar.y + (this._bar.height - this._grip.height) * this._scrollPerc; - else - this._grip.x = this._bar.x + (this._bar.width - this._grip.width) * this._scrollPerc; - }; - Object.defineProperty(GScrollBar.prototype, "minSize", { - get: function () { - if (this._vertical) - return (this._arrowButton1 ? this._arrowButton1.height : 0) + (this._arrowButton2 ? this._arrowButton2.height : 0); - else - return (this._arrowButton1 ? this._arrowButton1.width : 0) + (this._arrowButton2 ? this._arrowButton2.width : 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GScrollBar.prototype, "gripDragging", { - get: function () { - return this._gripDragging; - }, - enumerable: true, - configurable: true - }); - GScrollBar.prototype.constructExtension = function (buffer) { - buffer.seek(0, 6); - this._fixedGripSize = buffer.readBool(); - this._grip = this.getChild("grip"); - if (!this._grip) { - console.error("需要定义grip"); - return; - } - this._bar = this.getChild("bar"); - if (!this._bar) { - console.error("需要定义bar"); - return; - } - this._arrowButton1 = this.getChild("arrow1"); - this._arrowButton2 = this.getChild("arrow2"); - this._grip.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__gripMouseDown, this); - if (this._arrowButton1) - this._arrowButton1.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__arrowButton1Click, this); - if (this._arrowButton2) - this._arrowButton2.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__arrowButton2Click, this); - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__barMouseDown, this); - }; - GScrollBar.prototype.__gripMouseDown = function (evt) { - this._gripDragging = true; - this._target.updateScrollBarVisible(); - evt.stopPropagation(); - this.globalToLocal(evt.stageX, evt.stageY, this._dragOffset); - this._dragOffset.x -= this._grip.x; - this._dragOffset.y -= this._grip.y; - this._grip.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__gripMouseMove, this); - this._grip.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.__gripMouseUp, this); - }; - GScrollBar.prototype.__gripMouseMove = function (evt) { - if (!this.onStage) - return; - var pt = this.globalToLocal(evt.stageX, evt.stageY, s_vec2); - if (this._vertical) { - var curY = pt.y - this._dragOffset.y; - this._target.setPercY((curY - this._bar.y) / (this._bar.height - this._grip.height), false); - } - else { - var curX = pt.x - this._dragOffset.x; - this._target.setPercX((curX - this._bar.x) / (this._bar.width - this._grip.width), false); - } - }; - GScrollBar.prototype.__gripMouseUp = function (evt) { - var st = evt.currentTarget; - st.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.__gripMouseMove, this); - st.removeEventListener(egret.TouchEvent.TOUCH_END, this.__gripMouseUp, this); - if (this.onStage) - return; - this._gripDragging = false; - this._target.updateScrollBarVisible(); - }; - GScrollBar.prototype.__arrowButton1Click = function (evt) { - evt.stopPropagation(); - if (this._vertical) - this._target.scrollUp(); - else - this._target.scrollLeft(); - }; - GScrollBar.prototype.__arrowButton2Click = function (evt) { - evt.stopPropagation(); - if (this._vertical) - this._target.scrollDown(); - else - this._target.scrollRight(); - }; - GScrollBar.prototype.__barMouseDown = function (evt) { - var pt = this._grip.globalToLocal(evt.stageX, evt.stageY, s_vec2); - if (this._vertical) { - if (pt.y < 0) - this._target.scrollUp(4); - else - this._target.scrollDown(4); - } - else { - if (pt.x < 0) - this._target.scrollLeft(4); - else - this._target.scrollRight(4); - } - }; - return GScrollBar; - }(fgui.GComponent)); - fgui.GScrollBar = GScrollBar; - var s_vec2 = new egret.Point(); -})(fgui || (fgui = {})); - -(function (fgui) { - var GSlider = (function (_super_1) { - __extends(GSlider, _super_1); - function GSlider() { - var _this = _super_1.call(this) || this; - _this._min = 0; - _this._max = 0; - _this._value = 0; - _this._barMaxWidth = 0; - _this._barMaxHeight = 0; - _this._barMaxWidthDelta = 0; - _this._barMaxHeightDelta = 0; - _this._clickPercent = 0; - _this._barStartX = 0; - _this._barStartY = 0; - _this.changeOnClick = true; - _this.canDrag = true; - _this._titleType = fgui.ProgressTitleType.Percent; - _this._value = 50; - _this._max = 100; - _this._clickPos = new egret.Point(); - return _this; - } - Object.defineProperty(GSlider.prototype, "titleType", { - get: function () { - return this._titleType; - }, - set: function (value) { - this._titleType = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GSlider.prototype, "wholeNumbers", { - get: function () { - return this._wholeNumbers; - }, - set: function (value) { - if (this._wholeNumbers != value) { - this._wholeNumbers = value; - this.update(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GSlider.prototype, "min", { - get: function () { - return this._min; - }, - set: function (value) { - if (this._min != value) { - this._min = value; - this.update(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GSlider.prototype, "max", { - get: function () { - return this._max; - }, - set: function (value) { - if (this._max != value) { - this._max = value; - this.update(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GSlider.prototype, "value", { - get: function () { - return this._value; - }, - set: function (value) { - if (this._value != value) { - this._value = value; - this.update(); - } - }, - enumerable: true, - configurable: true - }); - GSlider.prototype.update = function () { - this.updateWithPercent((this._value - this._min) / (this._max - this._min)); - }; - GSlider.prototype.updateWithPercent = function (percent, manual) { - percent = fgui.ToolSet.clamp01(percent); - if (manual) { - var newValue = fgui.ToolSet.clamp(this._min + (this._max - this._min) * percent, this._min, this._max); - if (this._wholeNumbers) { - newValue = Math.round(newValue); - percent = fgui.ToolSet.clamp01((newValue - this._min) / (this._max - this._min)); - } - if (newValue != this._value) { - this._value = newValue; - this.dispatchEvent(new fgui.StateChangeEvent(fgui.StateChangeEvent.CHANGED)); - } - } - if (this._titleObject) { - switch (this._titleType) { - case fgui.ProgressTitleType.Percent: - this._titleObject.text = Math.floor(percent * 100) + "%"; - break; - case fgui.ProgressTitleType.ValueAndMax: - this._titleObject.text = this._value + "/" + this._max; - break; - case fgui.ProgressTitleType.Value: - this._titleObject.text = "" + this._value; - break; - case fgui.ProgressTitleType.Max: - this._titleObject.text = "" + this._max; - break; - } - } - var fullWidth = this.width - this._barMaxWidthDelta; - var fullHeight = this.height - this._barMaxHeightDelta; - if (!this._reverse) { - if (this._barObjectH) - this._barObjectH.width = Math.round(fullWidth * percent); - if (this._barObjectV) - this._barObjectV.height = Math.round(fullHeight * percent); - } - else { - if (this._barObjectH) { - this._barObjectH.width = Math.round(fullWidth * percent); - this._barObjectH.x = this._barStartX + (fullWidth - this._barObjectH.width); - } - if (this._barObjectV) { - this._barObjectV.height = Math.round(fullHeight * percent); - this._barObjectV.y = this._barStartY + (fullHeight - this._barObjectV.height); - } - } - }; - GSlider.prototype.constructExtension = function (buffer) { - buffer.seek(0, 6); - this._titleType = buffer.readByte(); - this._reverse = buffer.readBool(); - if (buffer.version >= 2) { - this._wholeNumbers = buffer.readBool(); - this.changeOnClick = buffer.readBool(); - } - this._titleObject = (this.getChild("title")); - this._barObjectH = this.getChild("bar"); - this._barObjectV = this.getChild("bar_v"); - this._gripObject = this.getChild("grip"); - if (this._barObjectH) { - this._barMaxWidth = this._barObjectH.width; - this._barMaxWidthDelta = this.width - this._barMaxWidth; - this._barStartX = this._barObjectH.x; - } - if (this._barObjectV) { - this._barMaxHeight = this._barObjectV.height; - this._barMaxHeightDelta = this.height - this._barMaxHeight; - this._barStartY = this._barObjectV.y; - } - if (this._gripObject) { - this._gripObject.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__gripMouseDown, this); - } - this.displayObject.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__barMouseDown, this); - }; - GSlider.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (this._barObjectH) - this._barMaxWidth = this.width - this._barMaxWidthDelta; - if (this._barObjectV) - this._barMaxHeight = this.height - this._barMaxHeightDelta; - if (!this._underConstruct) - this.update(); - }; - GSlider.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!buffer.seek(beginPos, 6)) { - this.update(); - return; - } - if (buffer.readByte() != this.packageItem.objectType) { - this.update(); - return; - } - this._value = buffer.readInt(); - this._max = buffer.readInt(); - if (buffer.version >= 2) - this._min = buffer.readInt(); - this.update(); - }; - GSlider.prototype.__gripMouseDown = function (evt) { - this.canDrag = true; - evt.stopPropagation(); - this._clickPos = this.globalToLocal(evt.stageX, evt.stageY); - this._clickPercent = fgui.ToolSet.clamp01((this._value - this._min) / (this._max - this._min)); - this._gripObject.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__gripMouseMove, this); - this._gripObject.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.__gripMouseUp, this); - }; - GSlider.prototype.__gripMouseMove = function (evt) { - if (!this.canDrag) { - return; - } - var pt = this.globalToLocal(evt.stageX, evt.stageY, s_vec2); - var deltaX = pt.x - this._clickPos.x; - var deltaY = pt.y - this._clickPos.y; - if (this._reverse) { - deltaX = -deltaX; - deltaY = -deltaY; - } - var percent; - if (this._barObjectH) - percent = this._clickPercent + deltaX / this._barMaxWidth; - else - percent = this._clickPercent + deltaY / this._barMaxHeight; - this.updateWithPercent(percent, true); - }; - GSlider.prototype.__gripMouseUp = function (evt) { - evt.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.__gripMouseMove, this); - evt.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END, this.__gripMouseUp, this); - }; - GSlider.prototype.__barMouseDown = function (evt) { - if (!this.changeOnClick) - return; - var pt = this._gripObject.globalToLocal(evt.stageX, evt.stageY, s_vec2); - var percent = fgui.ToolSet.clamp01((this._value - this._min) / (this._max - this._min)); - var delta; - if (this._barObjectH) - delta = pt.x / this._barMaxWidth; - if (this._barObjectV) - delta = pt.y / this._barMaxHeight; - if (this._reverse) - percent -= delta; - else - percent += delta; - this.updateWithPercent(percent, true); - }; - return GSlider; - }(fgui.GComponent)); - fgui.GSlider = GSlider; - var s_vec2 = new egret.Point(); -})(fgui || (fgui = {})); - -(function (fgui) { - var GTextInput = (function (_super_1) { - __extends(GTextInput, _super_1); - function GTextInput() { - var _this = _super_1.call(this) || this; - _this._widthAutoSize = false; - _this._heightAutoSize = false; - _this.displayObject.touchChildren = true; - _this._textField.type = egret.TextFieldType.INPUT; - _this._textField.addEventListener(egret.Event.CHANGE, _this.__textChanged, _this); - _this._textField.addEventListener(egret.FocusEvent.FOCUS_IN, _this.__focusIn, _this); - _this._textField.addEventListener(egret.FocusEvent.FOCUS_OUT, _this.__focusOut, _this); - return _this; - } - GTextInput.prototype.dispose = function () { - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GTextInput.prototype, "editable", { - get: function () { - return this._textField.type == egret.TextFieldType.INPUT; - }, - set: function (val) { - if (val) - this._textField.type = egret.TextFieldType.INPUT; - else - this._textField.type = egret.TextFieldType.DYNAMIC; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextInput.prototype, "maxLength", { - get: function () { - return this._textField.maxChars; - }, - set: function (val) { - this._textField.maxChars = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextInput.prototype, "promptText", { - get: function () { - return this._promptText; - }, - set: function (val) { - this._promptText = val; - this.updateTextFieldText(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextInput.prototype, "restrict", { - get: function () { - return this._textField.restrict; - }, - set: function (value) { - this._textField.restrict = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextInput.prototype, "password", { - get: function () { - return this._password; - }, - set: function (val) { - if (this._password != val) { - this._password = val; - this._textField.displayAsPassword = this._password; - if (val) - this._textField.inputType = egret.TextFieldInputType.PASSWORD; - else - this._textField.inputType = egret.TextFieldInputType.TEXT; - this.render(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextInput.prototype, "verticalAlign", { - get: function () { - return this._verticalAlign; - }, - set: function (value) { - if (this._verticalAlign != value) { - this._verticalAlign = value; - this.updateVertAlign(); - } - }, - enumerable: true, - configurable: true - }); - GTextInput.prototype.updateVertAlign = function () { - switch (this._verticalAlign) { - case fgui.VertAlignType.Top: - this._textField.verticalAlign = egret.VerticalAlign.TOP; - break; - case fgui.VertAlignType.Middle: - this._textField.verticalAlign = egret.VerticalAlign.MIDDLE; - break; - case fgui.VertAlignType.Bottom: - this._textField.verticalAlign = egret.VerticalAlign.BOTTOM; - break; - } - }; - GTextInput.prototype.updateTextFieldText = function () { - if (!this._text && this._promptText) { - this._textField.displayAsPassword = false; - this._textField.textFlow = (new egret.HtmlTextParser).parser(fgui.UBBParser.inst.parse(this._promptText)); - } - else { - this._textField.displayAsPassword = this._password; - if (this._ubbEnabled) - this._textField.textFlow = (new egret.HtmlTextParser).parser(fgui.UBBParser.inst.parse(fgui.ToolSet.encodeHTML(this._text))); - else - this._textField.text = this._text; - } - }; - GTextInput.prototype.handleSizeChanged = function () { - if (!this._updatingSize) { - this._textField.width = Math.ceil(this.width); - this._textField.height = Math.ceil(this.height); - } - }; - GTextInput.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 4); - var str = buffer.readS(); - if (str != null) - this._promptText = str; - str = buffer.readS(); - if (str != null) - this._textField.restrict = str; - var iv = buffer.readInt(); - if (iv != 0) - this._textField.maxChars = iv; - iv = buffer.readInt(); - if (iv != 0) { - } - if (buffer.readBool()) - this.password = true; - this.updateVertAlign(); - }; - GTextInput.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!this._text && this._promptText) { - this._textField.displayAsPassword = false; - this._textField.textFlow = (new egret.HtmlTextParser).parser(fgui.UBBParser.inst.parse(fgui.ToolSet.encodeHTML(this._promptText))); - } - }; - GTextInput.prototype.__textChanged = function (evt) { - this._text = this._textField.text; - }; - GTextInput.prototype.__focusIn = function (evt) { - if (!this._text && this._promptText) { - this._textField.displayAsPassword = this._password; - this._textField.text = ""; - } - }; - GTextInput.prototype.__focusOut = function (evt) { - this._text = this._textField.text; - if (!this._text && this._promptText) { - this._textField.displayAsPassword = false; - this._textField.textFlow = (new egret.HtmlTextParser).parser(fgui.UBBParser.inst.parse(fgui.ToolSet.encodeHTML(this._promptText))); - } - }; - return GTextInput; - }(fgui.GTextField)); - fgui.GTextInput = GTextInput; -})(fgui || (fgui = {})); - -(function (fgui) { - var GTree = (function (_super_1) { - __extends(GTree, _super_1); - function GTree() { - var _this = _super_1.call(this) || this; - _this._indent = 15; - _this._rootNode = new fgui.GTreeNode(true); - _this._rootNode._setTree(_this); - _this._rootNode.expanded = true; - return _this; - } - Object.defineProperty(GTree.prototype, "rootNode", { - get: function () { - return this._rootNode; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTree.prototype, "indent", { - get: function () { - return this._indent; - }, - set: function (value) { - this._indent = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTree.prototype, "clickToExpand", { - get: function () { - return this._clickToExpand; - }, - set: function (value) { - this._clickToExpand = value; - }, - enumerable: true, - configurable: true - }); - GTree.prototype.getSelectedNode = function () { - if (this.selectedIndex != -1) - return this.getChildAt(this.selectedIndex)._treeNode; - else - return null; - }; - GTree.prototype.getSelectedNodes = function (result) { - if (!result) - result = new Array(); - s_list.length = 0; - _super_1.prototype.getSelection.call(this, s_list); - var cnt = s_list.length; - var ret = new Array(); - for (var i = 0; i < cnt; i++) { - var node = this.getChildAt(s_list[i])._treeNode; - ret.push(node); - } - return ret; - }; - GTree.prototype.selectNode = function (node, scrollItToView) { - var parentNode = node.parent; - while (parentNode && parentNode != this._rootNode) { - parentNode.expanded = true; - parentNode = parentNode.parent; - } - if (!node._cell) - return; - this.addSelection(this.getChildIndex(node._cell), scrollItToView); - }; - GTree.prototype.unselectNode = function (node) { - if (!node._cell) - return; - this.removeSelection(this.getChildIndex(node._cell)); - }; - GTree.prototype.expandAll = function (folderNode) { - if (!folderNode) - folderNode = this._rootNode; - folderNode.expanded = true; - var cnt = folderNode.numChildren; - for (var i = 0; i < cnt; i++) { - var node = folderNode.getChildAt(i); - if (node.isFolder) - this.expandAll(node); - } - }; - GTree.prototype.collapseAll = function (folderNode) { - if (!folderNode) - folderNode = this._rootNode; - if (folderNode != this._rootNode) - folderNode.expanded = false; - var cnt = folderNode.numChildren; - for (var i = 0; i < cnt; i++) { - var node = folderNode.getChildAt(i); - if (node.isFolder) - this.collapseAll(node); - } - }; - GTree.prototype.createCell = function (node) { - var child = this.getFromPool(node._resURL ? node._resURL : this.defaultItem); - if (!(child instanceof fgui.GComponent)) - throw new Error("cannot create tree node object."); - child._treeNode = node; - node._cell = child; - var indentObj = child.getChild("indent"); - if (indentObj != null) - indentObj.width = (node.level - 1) * this._indent; - var cc; - cc = child.getController("expanded"); - if (cc) { - cc.addEventListener(fgui.StateChangeEvent.CHANGED, this.__expandedStateChanged, this); - cc.selectedIndex = node.expanded ? 1 : 0; - } - cc = child.getController("leaf"); - if (cc) - cc.selectedIndex = node.isFolder ? 0 : 1; - if (node.isFolder) - child.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__cellMouseDown, this); - if (this.treeNodeRender) - this.treeNodeRender.call(this.callbackThisObj, node, child); - }; - GTree.prototype._afterInserted = function (node) { - if (!node._cell) - this.createCell(node); - var index = this.getInsertIndexForNode(node); - this.addChildAt(node._cell, index); - if (this.treeNodeRender) - this.treeNodeRender.call(this.callbackThisObj, node, node._cell); - if (node.isFolder && node.expanded) - this.checkChildren(node, index); - }; - GTree.prototype.getInsertIndexForNode = function (node) { - var prevNode = node.getPrevSibling(); - if (prevNode == null) - prevNode = node.parent; - var insertIndex = this.getChildIndex(prevNode._cell) + 1; - var myLevel = node.level; - var cnt = this.numChildren; - for (var i = insertIndex; i < cnt; i++) { - var testNode = this.getChildAt(i)._treeNode; - if (testNode.level <= myLevel) - break; - insertIndex++; - } - return insertIndex; - }; - GTree.prototype._afterRemoved = function (node) { - this.removeNode(node); - }; - GTree.prototype._afterExpanded = function (node) { - if (node == this._rootNode) { - this.checkChildren(this._rootNode, 0); - return; - } - if (this.treeNodeWillExpand != null) - this.treeNodeWillExpand.call(this.callbackThisObj, node, true); - if (node._cell == null) - return; - if (this.treeNodeRender) - this.treeNodeRender.call(this.callbackThisObj, node, node._cell); - var cc = node._cell.getController("expanded"); - if (cc) - cc.selectedIndex = 1; - if (node._cell.parent) - this.checkChildren(node, this.getChildIndex(node._cell)); - }; - GTree.prototype._afterCollapsed = function (node) { - if (node == this._rootNode) { - this.checkChildren(this._rootNode, 0); - return; - } - if (this.treeNodeWillExpand) - this.treeNodeWillExpand.call(this.callbackThisObj, node, false); - if (node._cell == null) - return; - if (this.treeNodeRender) - this.treeNodeRender.call(this.callbackThisObj, node, node._cell); - var cc = node._cell.getController("expanded"); - if (cc) - cc.selectedIndex = 0; - if (node._cell.parent) - this.hideFolderNode(node); - }; - GTree.prototype._afterMoved = function (node) { - var startIndex = this.getChildIndex(node._cell); - var endIndex; - if (node.isFolder) - endIndex = this.getFolderEndIndex(startIndex, node.level); - else - endIndex = startIndex + 1; - var insertIndex = this.getInsertIndexForNode(node); - var i; - var cnt = endIndex - startIndex; - var obj; - if (insertIndex < startIndex) { - for (i = 0; i < cnt; i++) { - obj = this.getChildAt(startIndex + i); - this.setChildIndex(obj, insertIndex + i); - } - } - else { - for (i = 0; i < cnt; i++) { - obj = this.getChildAt(startIndex); - this.setChildIndex(obj, insertIndex); - } - } - }; - GTree.prototype.getFolderEndIndex = function (startIndex, level) { - var cnt = this.numChildren; - for (var i = startIndex + 1; i < cnt; i++) { - var node = this.getChildAt(i)._treeNode; - if (node.level <= level) - return i; - } - return cnt; - }; - GTree.prototype.checkChildren = function (folderNode, index) { - var cnt = folderNode.numChildren; - for (var i = 0; i < cnt; i++) { - index++; - var node = folderNode.getChildAt(i); - if (node._cell == null) - this.createCell(node); - if (!node._cell.parent) - this.addChildAt(node._cell, index); - if (node.isFolder && node.expanded) - index = this.checkChildren(node, index); - } - return index; - }; - GTree.prototype.hideFolderNode = function (folderNode) { - var cnt = folderNode.numChildren; - for (var i = 0; i < cnt; i++) { - var node = folderNode.getChildAt(i); - if (node._cell) - this.removeChild(node._cell); - if (node.isFolder && node.expanded) - this.hideFolderNode(node); - } - }; - GTree.prototype.removeNode = function (node) { - if (node._cell) { - if (node._cell.parent) - this.removeChild(node._cell); - this.returnToPool(node._cell); - node._cell._treeNode = null; - node._cell = null; - } - if (node.isFolder) { - var cnt = node.numChildren; - for (var i = 0; i < cnt; i++) { - var node2 = node.getChildAt(i); - this.removeNode(node2); - } - } - }; - GTree.prototype.__cellMouseDown = function (evt) { - var node = evt.currentTarget._treeNode; - this._expandedStatusInEvt = node.expanded; - }; - GTree.prototype.__expandedStateChanged = function (evt) { - var cc = evt.currentTarget; - var node = cc.parent._treeNode; - node.expanded = cc.selectedIndex == 1; - }; - GTree.prototype.dispatchItemEvent = function (evt) { - if (this._clickToExpand != 0) { - var node = evt.itemObject._treeNode; - if (node && node.isFolder && this._expandedStatusInEvt == node.expanded) { - if (this._clickToExpand == 2) { - } - else - node.expanded = !node.expanded; - } - } - _super_1.prototype.dispatchItemEvent.call(this, evt); - }; - GTree.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 9); - this._indent = buffer.readInt(); - this._clickToExpand = buffer.readByte(); - }; - GTree.prototype.readItems = function (buffer) { - var cnt; - var i; - var nextPos; - var str; - var isFolder; - var lastNode; - var level; - var prevLevel = 0; - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - str = buffer.readS(); - if (str == null) { - str = this.defaultItem; - if (!str) { - buffer.position = nextPos; - continue; - } - } - isFolder = buffer.readBool(); - level = buffer.readByte(); - var node = new fgui.GTreeNode(isFolder, str); - node.expanded = true; - if (i == 0) - this._rootNode.addChild(node); - else { - if (level > prevLevel) - lastNode.addChild(node); - else if (level < prevLevel) { - for (var j = level; j <= prevLevel; j++) - lastNode = lastNode.parent; - lastNode.addChild(node); - } - else - lastNode.parent.addChild(node); - } - lastNode = node; - prevLevel = level; - this.setupItem(buffer, node.cell); - buffer.position = nextPos; - } - }; - return GTree; - }(fgui.GList)); - fgui.GTree = GTree; - var s_list = new Array(); -})(fgui || (fgui = {})); - -(function (fgui) { - var GTreeNode = (function () { - function GTreeNode(hasChild, resURL) { - this._level = 0; - this._resURL = resURL; - if (hasChild) - this._children = new Array(); - } - Object.defineProperty(GTreeNode.prototype, "expanded", { - get: function () { - return this._expanded; - }, - set: function (value) { - if (!this._children) - return; - if (this._expanded != value) { - this._expanded = value; - if (this._tree) { - if (this._expanded) - this._tree._afterExpanded(this); - else - this._tree._afterCollapsed(this); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "isFolder", { - get: function () { - return this._children != null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "parent", { - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "text", { - get: function () { - if (this._cell) - return this._cell.text; - else - return null; - }, - set: function (value) { - if (this._cell) - this._cell.text = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "icon", { - get: function () { - if (this._cell) - return this._cell.icon; - else - return null; - }, - set: function (value) { - if (this._cell) - this._cell.icon = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "cell", { - get: function () { - return this._cell; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "level", { - get: function () { - return this._level; - }, - enumerable: true, - configurable: true - }); - GTreeNode.prototype._setLevel = function (value) { - this._level = value; - }; - GTreeNode.prototype.addChild = function (child) { - this.addChildAt(child, this._children.length); - return child; - }; - GTreeNode.prototype.addChildAt = function (child, index) { - if (!child) - throw new Error("child is null"); - var numChildren = this._children.length; - if (index >= 0 && index <= numChildren) { - if (child._parent == this) { - this.setChildIndex(child, index); - } - else { - if (child._parent) - child._parent.removeChild(child); - var cnt = this._children.length; - if (index == cnt) - this._children.push(child); - else - this._children.splice(index, 0, child); - child._parent = this; - child._level = this._level + 1; - child._setTree(this._tree); - if (this._tree && this == this._tree.rootNode || this._cell && this._cell.parent && this._expanded) - this._tree._afterInserted(child); - } - return child; - } - else { - throw new RangeError("Invalid child index"); - } - }; - GTreeNode.prototype.removeChild = function (child) { - var childIndex = this._children.indexOf(child); - if (childIndex != -1) { - this.removeChildAt(childIndex); - } - return child; - }; - GTreeNode.prototype.removeChildAt = function (index) { - if (index >= 0 && index < this.numChildren) { - var child = this._children[index]; - this._children.splice(index, 1); - child._parent = null; - if (this._tree) { - child._setTree(null); - this._tree._afterRemoved(child); - } - return child; - } - else { - throw "Invalid child index"; - } - }; - GTreeNode.prototype.removeChildren = function (beginIndex, endIndex) { - beginIndex = beginIndex || 0; - if (endIndex == null) - endIndex = -1; - if (endIndex < 0 || endIndex >= this.numChildren) - endIndex = this.numChildren - 1; - for (var i = beginIndex; i <= endIndex; ++i) - this.removeChildAt(beginIndex); - }; - GTreeNode.prototype.getChildAt = function (index) { - if (index >= 0 && index < this.numChildren) - return this._children[index]; - else - throw "Invalid child index"; - }; - GTreeNode.prototype.getChildIndex = function (child) { - return this._children.indexOf(child); - }; - GTreeNode.prototype.getPrevSibling = function () { - if (this._parent == null) - return null; - var i = this._parent._children.indexOf(this); - if (i <= 0) - return null; - return this._parent._children[i - 1]; - }; - GTreeNode.prototype.getNextSibling = function () { - if (this._parent == null) - return null; - var i = this._parent._children.indexOf(this); - if (i < 0 || i >= this._parent._children.length - 1) - return null; - return this._parent._children[i + 1]; - }; - GTreeNode.prototype.setChildIndex = function (child, index) { - var oldIndex = this._children.indexOf(child); - if (oldIndex == -1) - throw "Not a child of this container"; - var cnt = this._children.length; - if (index < 0) - index = 0; - else if (index > cnt) - index = cnt; - if (oldIndex == index) - return; - this._children.splice(oldIndex, 1); - this._children.splice(index, 0, child); - if (this._tree && this == this._tree.rootNode || this._cell && this._cell.parent && this._expanded) - this._tree._afterMoved(child); - }; - GTreeNode.prototype.swapChildren = function (child1, child2) { - var index1 = this._children.indexOf(child1); - var index2 = this._children.indexOf(child2); - if (index1 == -1 || index2 == -1) - throw "Not a child of this container"; - this.swapChildrenAt(index1, index2); - }; - GTreeNode.prototype.swapChildrenAt = function (index1, index2) { - var child1 = this._children[index1]; - var child2 = this._children[index2]; - this.setChildIndex(child1, index2); - this.setChildIndex(child2, index1); - }; - Object.defineProperty(GTreeNode.prototype, "numChildren", { - get: function () { - return this._children.length; - }, - enumerable: true, - configurable: true - }); - GTreeNode.prototype.expandToRoot = function () { - var p = this; - while (p) { - p.expanded = true; - p = p.parent; - } - }; - Object.defineProperty(GTreeNode.prototype, "tree", { - get: function () { - return this._tree; - }, - enumerable: true, - configurable: true - }); - GTreeNode.prototype._setTree = function (value) { - this._tree = value; - if (this._tree && this._tree.treeNodeWillExpand && this._expanded) - this._tree.treeNodeWillExpand(this, true); - if (this._children) { - var cnt = this._children.length; - for (var i = 0; i < cnt; i++) { - var node = this._children[i]; - node._level = this._level + 1; - node._setTree(value); - } - } - }; - return GTreeNode; - }()); - fgui.GTreeNode = GTreeNode; -})(fgui || (fgui = {})); - -(function (fgui) { - var Margin = (function () { - function Margin() { - this.left = 0; - this.right = 0; - this.top = 0; - this.bottom = 0; - } - Margin.prototype.copy = function (source) { - this.top = source.top; - this.bottom = source.bottom; - this.left = source.left; - this.right = source.right; - }; - return Margin; - }()); - fgui.Margin = Margin; -})(fgui || (fgui = {})); - -(function (fgui) { - var PixelHitTest = (function () { - function PixelHitTest(data, offsetX, offsetY) { - this._data = data; - this.offsetX = offsetX; - this.offsetY = offsetY; - this.scaleX = 1; - this.scaleY = 1; - } - PixelHitTest.prototype.contains = function (x, y) { - x = Math.floor((x / this.scaleX - this.offsetX) * this._data.scale); - y = Math.floor((y / this.scaleY - this.offsetY) * this._data.scale); - if (x < 0 || y < 0 || x >= this._data.pixelWidth) - return false; - var pos = y * this._data.pixelWidth + x; - var pos2 = Math.floor(pos / 8); - var pos3 = pos % 8; - if (pos2 >= 0 && pos2 < this._data.pixels.length) - return ((this._data.pixels[pos2] >> pos3) & 0x1) == 1; - else - return false; - }; - return PixelHitTest; - }()); - fgui.PixelHitTest = PixelHitTest; - var PixelHitTestData = (function () { - function PixelHitTestData() { - } - PixelHitTestData.prototype.load = function (ba) { - ba.readInt(); - this.pixelWidth = ba.readInt(); - this.scale = 1 / ba.readByte(); - var len = ba.readInt(); - this.pixels = []; - for (var i = 0; i < len; i++) { - var j = ba.readByte(); - if (j < 0) - j += 256; - this.pixels[i] = j; - } - }; - return PixelHitTestData; - }()); - fgui.PixelHitTestData = PixelHitTestData; -})(fgui || (fgui = {})); - -(function (fgui) { - var PackageItem = (function () { - function PackageItem() { - this.width = 0; - this.height = 0; - } - PackageItem.prototype.load = function () { - return this.owner.getItemAsset(this); - }; - PackageItem.prototype.getBranch = function () { - if (this.branches && this.owner._branchIndex != -1) { - var itemId = this.branches[this.owner._branchIndex]; - if (itemId) - return this.owner.getItemById(itemId); - } - return this; - }; - PackageItem.prototype.getHighResolution = function () { - if (this.highResolution && fgui.GRoot.contentScaleLevel > 0) { - var itemId = this.highResolution[fgui.GRoot.contentScaleLevel - 1]; - if (itemId) - return this.owner.getItemById(itemId); - } - return this; - }; - PackageItem.prototype.toString = function () { - return this.name; - }; - return PackageItem; - }()); - fgui.PackageItem = PackageItem; -})(fgui || (fgui = {})); - -(function (fgui) { - var PopupMenu = (function () { - function PopupMenu(resourceURL) { - if (!resourceURL) { - resourceURL = fgui.UIConfig.popupMenu; - if (!resourceURL) - throw "UIConfig.popupMenu not defined"; - } - this._contentPane = fgui.UIPackage.createObjectFromURL(resourceURL).asCom; - this._contentPane.addEventListener(egret.Event.ADDED_TO_STAGE, this.__addedToStage, this); - this._list = (this._contentPane.getChild("list")); - this._list.removeChildrenToPool(); - this._list.addRelation(this._contentPane, fgui.RelationType.Width); - this._list.removeRelation(this._contentPane, fgui.RelationType.Height); - this._contentPane.addRelation(this._list, fgui.RelationType.Height); - this._list.addEventListener(fgui.ItemEvent.CLICK, this.__clickItem, this); - } - PopupMenu.prototype.dispose = function () { - this._contentPane.dispose(); - }; - PopupMenu.prototype.addItem = function (caption, callback) { - var item = this._list.addItemFromPool().asButton; - item.title = caption; - item.data = callback; - item.grayed = false; - var c = item.getController("checked"); - if (c) - c.selectedIndex = 0; - return item; - }; - PopupMenu.prototype.addItemAt = function (caption, index, callback) { - var item = this._list.getFromPool().asButton; - this._list.addChildAt(item, index); - item.title = caption; - item.data = callback; - item.grayed = false; - var c = item.getController("checked"); - if (c) - c.selectedIndex = 0; - return item; - }; - PopupMenu.prototype.addSeperator = function () { - if (fgui.UIConfig.popupMenu_seperator == null) - throw "UIConfig.popupMenu_seperator not defined"; - this.list.addItemFromPool(fgui.UIConfig.popupMenu_seperator); - }; - PopupMenu.prototype.getItemName = function (index) { - var item = this._list.getChildAt(index); - return item.name; - }; - PopupMenu.prototype.setItemText = function (name, caption) { - var item = this._list.getChild(name).asButton; - item.title = caption; - }; - PopupMenu.prototype.setItemVisible = function (name, visible) { - var item = this._list.getChild(name).asButton; - if (item.visible != visible) { - item.visible = visible; - this._list.setBoundsChangedFlag(); - } - }; - PopupMenu.prototype.setItemGrayed = function (name, grayed) { - var item = this._list.getChild(name).asButton; - item.grayed = grayed; - }; - PopupMenu.prototype.setItemCheckable = function (name, checkable) { - var item = this._list.getChild(name).asButton; - var c = item.getController("checked"); - if (c) { - if (checkable) { - if (c.selectedIndex == 0) - c.selectedIndex = 1; - } - else - c.selectedIndex = 0; - } - }; - PopupMenu.prototype.setItemChecked = function (name, checked) { - var item = this._list.getChild(name).asButton; - var c = item.getController("checked"); - if (c) - c.selectedIndex = checked ? 2 : 1; - }; - PopupMenu.prototype.isItemChecked = function (name) { - var item = this._list.getChild(name).asButton; - var c = item.getController("checked"); - if (c) - return c.selectedIndex == 2; - else - return false; - }; - PopupMenu.prototype.removeItem = function (name) { - var item = this._list.getChild(name); - if (item) { - var index = this._list.getChildIndex(item); - this._list.removeChildToPoolAt(index); - return true; - } - else - return false; - }; - PopupMenu.prototype.clearItems = function () { - this._list.removeChildrenToPool(); - }; - Object.defineProperty(PopupMenu.prototype, "itemCount", { - get: function () { - return this._list.numChildren; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(PopupMenu.prototype, "contentPane", { - get: function () { - return this._contentPane; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(PopupMenu.prototype, "list", { - get: function () { - return this._list; - }, - enumerable: true, - configurable: true - }); - PopupMenu.prototype.show = function (target, dir) { - var r = target ? target.root : fgui.GRoot.inst; - r.showPopup(this.contentPane, (target instanceof fgui.GRoot) ? null : target, dir); - }; - PopupMenu.prototype.__clickItem = function (evt) { - fgui.GTimers.inst.add(100, 1, this.__clickItem2, this, evt); - }; - PopupMenu.prototype.__clickItem2 = function (evt) { - var item = evt.itemObject.asButton; - if (item == null) - return; - if (item.grayed) { - this._list.selectedIndex = -1; - return; - } - var c = item.getController("checked"); - if (c && c.selectedIndex != 0) { - if (c.selectedIndex == 1) - c.selectedIndex = 2; - else - c.selectedIndex = 1; - } - var r = (this._contentPane.parent); - r.hidePopup(this.contentPane); - if (item.data != null) { - if (item.data.length == 1) - item.data(evt); - else - item.data(); - } - }; - PopupMenu.prototype.__addedToStage = function (evt) { - this._list.selectedIndex = -1; - this._list.resizeToFit(100000, 10); - }; - return PopupMenu; - }()); - fgui.PopupMenu = PopupMenu; -})(fgui || (fgui = {})); - -(function (fgui) { - var RelationItem = (function () { - function RelationItem(owner) { - this._owner = owner; - this._defs = new Array(); - } - Object.defineProperty(RelationItem.prototype, "owner", { - get: function () { - return this._owner; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RelationItem.prototype, "target", { - get: function () { - return this._target; - }, - set: function (value) { - if (this._target != value) { - if (this._target) - this.releaseRefTarget(this._target); - this._target = value; - if (this._target) - this.addRefTarget(this._target); - } - }, - enumerable: true, - configurable: true - }); - RelationItem.prototype.add = function (relationType, usePercent) { - if (relationType == fgui.RelationType.Size) { - this.add(fgui.RelationType.Width, usePercent); - this.add(fgui.RelationType.Height, usePercent); - return; - } - var length = this._defs.length; - for (var i = 0; i < length; i++) { - var def = this._defs[i]; - if (def.type == relationType) - return; - } - this.internalAdd(relationType, usePercent); - }; - RelationItem.prototype.internalAdd = function (relationType, usePercent) { - if (relationType == fgui.RelationType.Size) { - this.internalAdd(fgui.RelationType.Width, usePercent); - this.internalAdd(fgui.RelationType.Height, usePercent); - return; - } - var info = new RelationDef(); - info.percent = usePercent; - info.type = relationType; - info.axis = (relationType <= fgui.RelationType.Right_Right || relationType == fgui.RelationType.Width || relationType >= fgui.RelationType.LeftExt_Left && relationType <= fgui.RelationType.RightExt_Right) ? 0 : 1; - this._defs.push(info); - if (usePercent || relationType == fgui.RelationType.Left_Center || relationType == fgui.RelationType.Center_Center || relationType == fgui.RelationType.Right_Center - || relationType == fgui.RelationType.Top_Middle || relationType == fgui.RelationType.Middle_Middle || relationType == fgui.RelationType.Bottom_Middle) - this._owner.pixelSnapping = true; - }; - RelationItem.prototype.remove = function (relationType) { - if (relationType === void 0) { relationType = 0; } - if (relationType == fgui.RelationType.Size) { - this.remove(fgui.RelationType.Width); - this.remove(fgui.RelationType.Height); - return; - } - var dc = this._defs.length; - for (var k = 0; k < dc; k++) { - if (this._defs[k].type == relationType) { - this._defs.splice(k, 1); - break; - } - } - }; - RelationItem.prototype.copyFrom = function (source) { - this.target = source.target; - this._defs.length = 0; - var length = source._defs.length; - for (var i = 0; i < length; i++) { - var info = source._defs[i]; - var info2 = new RelationDef(); - info2.copyFrom(info); - this._defs.push(info2); - } - }; - RelationItem.prototype.dispose = function () { - if (this._target) { - this.releaseRefTarget(this._target); - this._target = null; - } - }; - Object.defineProperty(RelationItem.prototype, "isEmpty", { - get: function () { - return this._defs.length == 0; - }, - enumerable: true, - configurable: true - }); - RelationItem.prototype.applyOnSelfResized = function (dWidth, dHeight, applyPivot) { - var ox = this._owner.x; - var oy = this._owner.y; - var length = this._defs.length; - for (var i = 0; i < length; i++) { - var info = this._defs[i]; - switch (info.type) { - case fgui.RelationType.Center_Center: - this._owner.x -= (0.5 - (applyPivot ? this._owner.pivotX : 0)) * dWidth; - break; - case fgui.RelationType.Right_Center: - case fgui.RelationType.Right_Left: - case fgui.RelationType.Right_Right: - this._owner.x -= (1 - (applyPivot ? this._owner.pivotX : 0)) * dWidth; - break; - case fgui.RelationType.Middle_Middle: - this._owner.y -= (0.5 - (applyPivot ? this._owner.pivotY : 0)) * dHeight; - break; - case fgui.RelationType.Bottom_Middle: - case fgui.RelationType.Bottom_Top: - case fgui.RelationType.Bottom_Bottom: - this._owner.y -= (1 - (applyPivot ? this._owner.pivotY : 0)) * dHeight; - break; - } - } - if (ox != this._owner.x || oy != this._owner.y) { - ox = this._owner.x - ox; - oy = this._owner.y - oy; - this._owner.updateGearFromRelations(1, ox, oy); - if (this._owner.parent) { - var len = this._owner.parent._transitions.length; - if (len > 0) { - for (var i = 0; i < len; ++i) { - this._owner.parent._transitions[i].updateFromRelations(this._owner.id, ox, oy); - } - } - } - } - }; - RelationItem.prototype.applyOnXYChanged = function (info, dx, dy) { - var tmp; - switch (info.type) { - case fgui.RelationType.Left_Left: - case fgui.RelationType.Left_Center: - case fgui.RelationType.Left_Right: - case fgui.RelationType.Center_Center: - case fgui.RelationType.Right_Left: - case fgui.RelationType.Right_Center: - case fgui.RelationType.Right_Right: - this._owner.x += dx; - break; - case fgui.RelationType.Top_Top: - case fgui.RelationType.Top_Middle: - case fgui.RelationType.Top_Bottom: - case fgui.RelationType.Middle_Middle: - case fgui.RelationType.Bottom_Top: - case fgui.RelationType.Bottom_Middle: - case fgui.RelationType.Bottom_Bottom: - this._owner.y += dy; - break; - case fgui.RelationType.Width: - case fgui.RelationType.Height: - break; - case fgui.RelationType.LeftExt_Left: - case fgui.RelationType.LeftExt_Right: - if (this._owner != this._target.parent) { - tmp = this._owner.xMin; - this._owner.width = this._owner._rawWidth - dx; - this._owner.xMin = tmp + dx; - } - else - this._owner.width = this._owner._rawWidth - dx; - break; - case fgui.RelationType.RightExt_Left: - case fgui.RelationType.RightExt_Right: - if (this._owner != this._target.parent) { - tmp = this._owner.xMin; - this._owner.width = this._owner._rawWidth + dx; - this._owner.xMin = tmp; - } - else - this._owner.width = this._owner._rawWidth + dx; - break; - case fgui.RelationType.TopExt_Top: - case fgui.RelationType.TopExt_Bottom: - if (this._owner != this._target.parent) { - tmp = this._owner.yMin; - this._owner.height = this._owner._rawHeight - dy; - this._owner.yMin = tmp + dy; - } - else - this._owner.height = this._owner._rawHeight - dy; - break; - case fgui.RelationType.BottomExt_Top: - case fgui.RelationType.BottomExt_Bottom: - if (this._owner != this._target.parent) { - tmp = this._owner.yMin; - this._owner.height = this._owner._rawHeight + dy; - this._owner.yMin = tmp; - } - else - this._owner.height = this._owner._rawHeight + dy; - break; - } - }; - RelationItem.prototype.applyOnSizeChanged = function (info) { - var pos = 0, pivot = 0, delta = 0; - var v, tmp; - if (info.axis == 0) { - if (this._target != this._owner.parent) { - pos = this._target.x; - if (this._target.pivotAsAnchor) - pivot = this._target.pivotX; - } - if (info.percent) { - if (this._targetWidth != 0) - delta = this._target._width / this._targetWidth; - } - else - delta = this._target._width - this._targetWidth; - } - else { - if (this._target != this._owner.parent) { - pos = this._target.y; - if (this._target.pivotAsAnchor) - pivot = this._target.pivotY; - } - if (info.percent) { - if (this._targetHeight != 0) - delta = this._target._height / this._targetHeight; - } - else - delta = this._target._height - this._targetHeight; - } - switch (info.type) { - case fgui.RelationType.Left_Left: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin - pos) * delta; - else if (pivot != 0) - this._owner.x += delta * (-pivot); - break; - case fgui.RelationType.Left_Center: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin - pos) * delta; - else - this._owner.x += delta * (0.5 - pivot); - break; - case fgui.RelationType.Left_Right: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin - pos) * delta; - else - this._owner.x += delta * (1 - pivot); - break; - case fgui.RelationType.Center_Center: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin + this._owner._rawWidth * 0.5 - pos) * delta - this._owner._rawWidth * 0.5; - else - this._owner.x += delta * (0.5 - pivot); - break; - case fgui.RelationType.Right_Left: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin + this._owner._rawWidth - pos) * delta - this._owner._rawWidth; - else if (pivot != 0) - this._owner.x += delta * (-pivot); - break; - case fgui.RelationType.Right_Center: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin + this._owner._rawWidth - pos) * delta - this._owner._rawWidth; - else - this._owner.x += delta * (0.5 - pivot); - break; - case fgui.RelationType.Right_Right: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin + this._owner._rawWidth - pos) * delta - this._owner._rawWidth; - else - this._owner.x += delta * (1 - pivot); - break; - case fgui.RelationType.Top_Top: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin - pos) * delta; - else if (pivot != 0) - this._owner.y += delta * (-pivot); - break; - case fgui.RelationType.Top_Middle: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin - pos) * delta; - else - this._owner.y += delta * (0.5 - pivot); - break; - case fgui.RelationType.Top_Bottom: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin - pos) * delta; - else - this._owner.y += delta * (1 - pivot); - break; - case fgui.RelationType.Middle_Middle: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin + this._owner._rawHeight * 0.5 - pos) * delta - this._owner._rawHeight * 0.5; - else - this._owner.y += delta * (0.5 - pivot); - break; - case fgui.RelationType.Bottom_Top: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin + this._owner._rawHeight - pos) * delta - this._owner._rawHeight; - else if (pivot != 0) - this._owner.y += delta * (-pivot); - break; - case fgui.RelationType.Bottom_Middle: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin + this._owner._rawHeight - pos) * delta - this._owner._rawHeight; - else - this._owner.y += delta * (0.5 - pivot); - break; - case fgui.RelationType.Bottom_Bottom: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin + this._owner._rawHeight - pos) * delta - this._owner._rawHeight; - else - this._owner.y += delta * (1 - pivot); - break; - case fgui.RelationType.Width: - if (this._owner._underConstruct && this._owner == this._target.parent) - v = this._owner.sourceWidth - this._target.initWidth; - else - v = this._owner._rawWidth - this._targetWidth; - if (info.percent) - v = v * delta; - if (this._target == this._owner.parent) { - if (this._owner.pivotAsAnchor) { - tmp = this._owner.xMin; - this._owner.setSize(this._target._width + v, this._owner._rawHeight, true); - this._owner.xMin = tmp; - } - else - this._owner.setSize(this._target._width + v, this._owner._rawHeight, true); - } - else - this._owner.width = this._target._width + v; - break; - case fgui.RelationType.Height: - if (this._owner._underConstruct && this._owner == this._target.parent) - v = this._owner.sourceHeight - this._target.initHeight; - else - v = this._owner._rawHeight - this._targetHeight; - if (info.percent) - v = v * delta; - if (this._target == this._owner.parent) { - if (this._owner.pivotAsAnchor) { - tmp = this._owner.yMin; - this._owner.setSize(this._owner._rawWidth, this._target._height + v, true); - this._owner.yMin = tmp; - } - else - this._owner.setSize(this._owner._rawWidth, this._target._height + v, true); - } - else - this._owner.height = this._target._height + v; - break; - case fgui.RelationType.LeftExt_Left: - tmp = this._owner.xMin; - if (info.percent) - v = pos + (tmp - pos) * delta - tmp; - else - v = delta * (-pivot); - this._owner.width = this._owner._rawWidth - v; - this._owner.xMin = tmp + v; - break; - case fgui.RelationType.LeftExt_Right: - tmp = this._owner.xMin; - if (info.percent) - v = pos + (tmp - pos) * delta - tmp; - else - v = delta * (1 - pivot); - this._owner.width = this._owner._rawWidth - v; - this._owner.xMin = tmp + v; - break; - case fgui.RelationType.RightExt_Left: - tmp = this._owner.xMin; - if (info.percent) - v = pos + (tmp + this._owner._rawWidth - pos) * delta - (tmp + this._owner._rawWidth); - else - v = delta * (-pivot); - this._owner.width = this._owner._rawWidth + v; - this._owner.xMin = tmp; - break; - case fgui.RelationType.RightExt_Right: - tmp = this._owner.xMin; - if (info.percent) { - if (this._owner == this._target.parent) { - if (this._owner._underConstruct) - this._owner.width = pos + this._target._width - this._target._width * pivot + - (this._owner.sourceWidth - pos - this._target.initWidth + this._target.initWidth * pivot) * delta; - else - this._owner.width = pos + (this._owner._rawWidth - pos) * delta; - } - else { - v = pos + (tmp + this._owner._rawWidth - pos) * delta - (tmp + this._owner._rawWidth); - this._owner.width = this._owner._rawWidth + v; - this._owner.xMin = tmp; - } - } - else { - if (this._owner == this._target.parent) { - if (this._owner._underConstruct) - this._owner.width = this._owner.sourceWidth + (this._target._width - this._target.initWidth) * (1 - pivot); - else - this._owner.width = this._owner._rawWidth + delta * (1 - pivot); - } - else { - v = delta * (1 - pivot); - this._owner.width = this._owner._rawWidth + v; - this._owner.xMin = tmp; - } - } - break; - case fgui.RelationType.TopExt_Top: - tmp = this._owner.yMin; - if (info.percent) - v = pos + (tmp - pos) * delta - tmp; - else - v = delta * (-pivot); - this._owner.height = this._owner._rawHeight - v; - this._owner.yMin = tmp + v; - break; - case fgui.RelationType.TopExt_Bottom: - tmp = this._owner.yMin; - if (info.percent) - v = pos + (tmp - pos) * delta - tmp; - else - v = delta * (1 - pivot); - this._owner.height = this._owner._rawHeight - v; - this._owner.yMin = tmp + v; - break; - case fgui.RelationType.BottomExt_Top: - tmp = this._owner.yMin; - if (info.percent) - v = pos + (tmp + this._owner._rawHeight - pos) * delta - (tmp + this._owner._rawHeight); - else - v = delta * (-pivot); - this._owner.height = this._owner._rawHeight + v; - this._owner.yMin = tmp; - break; - case fgui.RelationType.BottomExt_Bottom: - tmp = this._owner.yMin; - if (info.percent) { - if (this._owner == this._target.parent) { - if (this._owner._underConstruct) - this._owner.height = pos + this._target._height - this._target._height * pivot + - (this._owner.sourceHeight - pos - this._target.initHeight + this._target.initHeight * pivot) * delta; - else - this._owner.height = pos + (this._owner._rawHeight - pos) * delta; - } - else { - v = pos + (tmp + this._owner._rawHeight - pos) * delta - (tmp + this._owner._rawHeight); - this._owner.height = this._owner._rawHeight + v; - this._owner.yMin = tmp; - } - } - else { - if (this._owner == this._target.parent) { - if (this._owner._underConstruct) - this._owner.height = this._owner.sourceHeight + (this._target._height - this._target.initHeight) * (1 - pivot); - else - this._owner.height = this._owner._rawHeight + delta * (1 - pivot); - } - else { - v = delta * (1 - pivot); - this._owner.height = this._owner._rawHeight + v; - this._owner.yMin = tmp; - } - } - break; - } - }; - RelationItem.prototype.addRefTarget = function (target) { - if (target != this._owner.parent) - target.addEventListener(fgui.GObject.XY_CHANGED, this.__targetXYChanged, this); - target.addEventListener(fgui.GObject.SIZE_CHANGED, this.__targetSizeChanged, this); - target.addEventListener(fgui.GObject.SIZE_DELAY_CHANGE, this.__targetSizeWillChange, this); - this._targetX = this._target.x; - this._targetY = this._target.y; - this._targetWidth = this._target._width; - this._targetHeight = this._target._height; - }; - RelationItem.prototype.releaseRefTarget = function (target) { - target.removeEventListener(fgui.GObject.XY_CHANGED, this.__targetXYChanged, this); - target.removeEventListener(fgui.GObject.SIZE_CHANGED, this.__targetSizeChanged, this); - target.removeEventListener(fgui.GObject.SIZE_DELAY_CHANGE, this.__targetSizeWillChange, this); - }; - RelationItem.prototype.__targetXYChanged = function (evt) { - if (this._owner.relations.handling != null || this._owner.group != null && this._owner.group._updating) { - this._targetX = this._target.x; - this._targetY = this._target.y; - return; - } - this._owner.relations.handling = this._target; - var ox = this._owner.x; - var oy = this._owner.y; - var dx = this._target.x - this._targetX; - var dy = this._target.y - this._targetY; - var length = this._defs.length; - for (var i = 0; i < length; i++) { - var info = this._defs[i]; - this.applyOnXYChanged(info, dx, dy); - } - this._targetX = this._target.x; - this._targetY = this._target.y; - if (ox != this._owner.x || oy != this._owner.y) { - ox = this._owner.x - ox; - oy = this._owner.y - oy; - this._owner.updateGearFromRelations(1, ox, oy); - if (this._owner.parent) { - var len = this._owner.parent._transitions.length; - if (len > 0) { - for (var i = 0; i < len; ++i) { - this._owner.parent._transitions[i].updateFromRelations(this._owner.id, ox, oy); - } - } - } - } - this._owner.relations.handling = null; - }; - RelationItem.prototype.__targetSizeChanged = function (evt) { - if (this._owner.relations.handling != null) - return; - this._owner.relations.handling = this._target; - var ox = this._owner.x; - var oy = this._owner.y; - var ow = this._owner._rawWidth; - var oh = this._owner._rawHeight; - var length = this._defs.length; - for (var i = 0; i < length; i++) { - var info = this._defs[i]; - this.applyOnSizeChanged(info); - } - this._targetWidth = this._target._width; - this._targetHeight = this._target._height; - if (ox != this._owner.x || oy != this._owner.y) { - ox = this._owner.x - ox; - oy = this._owner.y - oy; - this._owner.updateGearFromRelations(1, ox, oy); - if (this._owner.parent) { - var len = this._owner.parent._transitions.length; - if (len > 0) { - for (var i = 0; i < len; ++i) { - this._owner.parent._transitions[i].updateFromRelations(this._owner.id, ox, oy); - } - } - } - } - if (ow != this._owner._rawWidth || oh != this._owner._rawHeight) { - ow = this._owner._rawWidth - ow; - oh = this._owner._rawHeight - oh; - this._owner.updateGearFromRelations(2, ow, oh); - } - this._owner.relations.handling = null; - }; - RelationItem.prototype.__targetSizeWillChange = function (evt) { - this._owner.relations.sizeDirty = true; - }; - return RelationItem; - }()); - fgui.RelationItem = RelationItem; - var RelationDef = (function () { - function RelationDef() { - } - RelationDef.prototype.copyFrom = function (source) { - this.percent = source.percent; - this.type = source.type; - this.axis = source.axis; - }; - return RelationDef; - }()); - fgui.RelationDef = RelationDef; -})(fgui || (fgui = {})); - -(function (fgui) { - var Relations = (function () { - function Relations(owner) { - this._owner = owner; - this._items = new Array(); - } - Relations.prototype.add = function (target, relationType, usePercent) { - var length = this._items.length; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - if (item.target == target) { - item.add(relationType, usePercent); - return; - } - } - var newItem = new fgui.RelationItem(this._owner); - newItem.target = target; - newItem.add(relationType, usePercent); - this._items.push(newItem); - }; - Relations.prototype.remove = function (target, relationType) { - relationType = relationType || 0; - var cnt = this._items.length; - var i = 0; - while (i < cnt) { - var item = this._items[i]; - if (item.target == target) { - item.remove(relationType); - if (item.isEmpty) { - item.dispose(); - this._items.splice(i, 1); - cnt--; - } - else - i++; - } - else - i++; - } - }; - Relations.prototype.contains = function (target) { - var length = this._items.length; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - if (item.target == target) - return true; - } - return false; - }; - Relations.prototype.clearFor = function (target) { - var cnt = this._items.length; - var i = 0; - while (i < cnt) { - var item = this._items[i]; - if (item.target == target) { - item.dispose(); - this._items.splice(i, 1); - cnt--; - } - else - i++; - } - }; - Relations.prototype.clearAll = function () { - var length = this._items.length; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - item.dispose(); - } - this._items.length = 0; - }; - Relations.prototype.copyFrom = function (source) { - this.clearAll(); - var arr = source._items; - var length = arr.length; - for (var i = 0; i < length; i++) { - var ri = arr[i]; - var item = new fgui.RelationItem(this._owner); - item.copyFrom(ri); - this._items.push(item); - } - }; - Relations.prototype.dispose = function () { - this.clearAll(); - }; - Relations.prototype.onOwnerSizeChanged = function (dWidth, dHeight, applyPivot) { - if (this._items.length == 0) - return; - var length = this._items.length; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - item.applyOnSelfResized(dWidth, dHeight, applyPivot); - } - }; - Relations.prototype.ensureRelationsSizeCorrect = function () { - if (this._items.length == 0) - return; - this.sizeDirty = false; - var length = this._items.length; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - item.target.ensureSizeCorrect(); - } - }; - Object.defineProperty(Relations.prototype, "empty", { - get: function () { - return this._items.length == 0; - }, - enumerable: true, - configurable: true - }); - Relations.prototype.setup = function (buffer, parentToChild) { - var cnt = buffer.readByte(); - var target; - for (var i = 0; i < cnt; i++) { - var targetIndex = buffer.readShort(); - if (targetIndex == -1) - target = this._owner.parent; - else if (parentToChild) - target = this._owner.getChildAt(targetIndex); - else - target = this._owner.parent.getChildAt(targetIndex); - var newItem = new fgui.RelationItem(this._owner); - newItem.target = target; - this._items.push(newItem); - var cnt2 = buffer.readByte(); - for (var j = 0; j < cnt2; j++) { - var rt = buffer.readByte(); - var usePercent = buffer.readBool(); - newItem.internalAdd(rt, usePercent); - } - } - }; - return Relations; - }()); - fgui.Relations = Relations; -})(fgui || (fgui = {})); - -(function (fgui) { - var ScrollPane = (function (_super_1) { - __extends(ScrollPane, _super_1); - function ScrollPane(owner) { - var _this = _super_1.call(this) || this; - _this._owner = owner; - _this._maskContainer = new egret.DisplayObjectContainer(); - _this._owner._rootContainer.addChild(_this._maskContainer); - _this._container = _this._owner._container; - _this._container.x = 0; - _this._container.y = 0; - _this._maskContainer.addChild(_this._container); - _this._scrollBarMargin = new fgui.Margin(); - _this._xPos = 0; - _this._yPos = 0; - _this._aniFlag = 0; - _this._tweening = 0; - _this._footerLockedSize = 0; - _this._headerLockedSize = 0; - _this._viewSize = new egret.Point(); - _this._contentSize = new egret.Point(); - _this._pageSize = new egret.Point(1, 1); - _this._overlapSize = new egret.Point(); - _this._tweenTime = new egret.Point(); - _this._tweenStart = new egret.Point(); - _this._tweenDuration = new egret.Point(); - _this._tweenChange = new egret.Point(); - _this._velocity = new egret.Point(); - _this._containerPos = new egret.Point(); - _this._beginTouchPos = new egret.Point(); - _this._lastTouchPos = new egret.Point(); - _this._lastTouchGlobalPos = new egret.Point(); - _this._scrollStep = fgui.UIConfig.defaultScrollStep; - _this._decelerationRate = fgui.UIConfig.defaultScrollDecelerationRate; - _this._owner.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.__touchBegin, _this); - return _this; - } - ScrollPane.prototype.setup = function (buffer) { - this._scrollType = buffer.readByte(); - var scrollBarDisplay = buffer.readByte(); - var flags = buffer.readInt(); - if (buffer.readBool()) { - this._scrollBarMargin.top = buffer.readInt(); - this._scrollBarMargin.bottom = buffer.readInt(); - this._scrollBarMargin.left = buffer.readInt(); - this._scrollBarMargin.right = buffer.readInt(); - } - var vtScrollBarRes = buffer.readS(); - var hzScrollBarRes = buffer.readS(); - var headerRes = buffer.readS(); - var footerRes = buffer.readS(); - if ((flags & 1) != 0) - this._displayOnLeft = true; - if ((flags & 2) != 0) - this._snapToItem = true; - if ((flags & 4) != 0) - this._displayInDemand = true; - if ((flags & 8) != 0) - this._pageMode = true; - if (flags & 16) - this._touchEffect = true; - else if (flags & 32) - this._touchEffect = false; - else - this._touchEffect = fgui.UIConfig.defaultScrollTouchEffect; - if (flags & 64) - this._bouncebackEffect = true; - else if (flags & 128) - this._bouncebackEffect = false; - else - this._bouncebackEffect = fgui.UIConfig.defaultScrollBounceEffect; - if ((flags & 256) != 0) - this._inertiaDisabled = true; - if ((flags & 512) == 0) - this._maskContainer.scrollRect = new egret.Rectangle(); - if ((flags & 1024) != 0) - this._floating = true; - if ((flags & 2048) != 0) - this._dontClipMargin = true; - if (scrollBarDisplay == fgui.ScrollBarDisplayType.Default) - scrollBarDisplay = fgui.UIConfig.defaultScrollBarDisplay; - if (scrollBarDisplay != fgui.ScrollBarDisplayType.Hidden) { - if (this._scrollType == fgui.ScrollType.Both || this._scrollType == fgui.ScrollType.Vertical) { - var res = vtScrollBarRes ? vtScrollBarRes : fgui.UIConfig.verticalScrollBar; - if (res) { - this._vtScrollBar = fgui.UIPackage.createObjectFromURL(res); - if (!this._vtScrollBar) - throw "cannot create scrollbar from " + res; - this._vtScrollBar.setScrollPane(this, true); - this._owner._rootContainer.addChild(this._vtScrollBar.displayObject); - } - } - if (this._scrollType == fgui.ScrollType.Both || this._scrollType == fgui.ScrollType.Horizontal) { - var res = hzScrollBarRes ? hzScrollBarRes : fgui.UIConfig.horizontalScrollBar; - if (res) { - this._hzScrollBar = fgui.UIPackage.createObjectFromURL(res); - if (!this._hzScrollBar) - throw "cannot create scrollbar from " + res; - this._hzScrollBar.setScrollPane(this, false); - this._owner._rootContainer.addChild(this._hzScrollBar.displayObject); - } - } - if (scrollBarDisplay == fgui.ScrollBarDisplayType.Auto) - this._scrollBarDisplayAuto = true; - if (this._scrollBarDisplayAuto) { - if (this._vtScrollBar) - this._vtScrollBar.displayObject.visible = false; - if (this._hzScrollBar) - this._hzScrollBar.displayObject.visible = false; - } - } - if (headerRes) { - this._header = fgui.UIPackage.createObjectFromURL(headerRes); - if (!this._header) - throw "cannot create scrollPane header from " + headerRes; - } - if (footerRes) { - this._footer = fgui.UIPackage.createObjectFromURL(footerRes); - if (!this._footer) - throw "cannot create scrollPane footer from " + footerRes; - } - if (this._header || this._footer) - this._refreshBarAxis = (this._scrollType == fgui.ScrollType.Both || this._scrollType == fgui.ScrollType.Vertical) ? "y" : "x"; - this.setSize(this._owner.width, this._owner.height); - }; - ScrollPane.prototype.dispose = function () { - if (this._tweening != 0) - fgui.GTimers.inst.remove(this.tweenUpdate, this); - delete this._pageController; - if (this._hzScrollBar) - this._hzScrollBar.dispose(); - if (this._vtScrollBar) - this._vtScrollBar.dispose(); - if (this._header) - this._header.dispose(); - if (this._footer) - this._footer.dispose(); - }; - Object.defineProperty(ScrollPane.prototype, "owner", { - get: function () { - return this._owner; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "hzScrollBar", { - get: function () { - return this._hzScrollBar; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "vtScrollBar", { - get: function () { - return this._vtScrollBar; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "header", { - get: function () { - return this._header; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "footer", { - get: function () { - return this._footer; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "bouncebackEffect", { - get: function () { - return this._bouncebackEffect; - }, - set: function (sc) { - this._bouncebackEffect = sc; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "touchEffect", { - get: function () { - return this._touchEffect; - }, - set: function (sc) { - this._touchEffect = sc; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "scrollStep", { - get: function () { - return this._scrollStep; - }, - set: function (val) { - this._scrollStep = val; - if (this._scrollStep == 0) - this._scrollStep = fgui.UIConfig.defaultScrollStep; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "decelerationRate", { - get: function () { - return this._decelerationRate; - }, - set: function (val) { - this._decelerationRate = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "snapToItem", { - get: function () { - return this._snapToItem; - }, - set: function (value) { - this._snapToItem = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "isDragged", { - get: function () { - return this._dragged; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "percX", { - get: function () { - return this._overlapSize.x == 0 ? 0 : this._xPos / this._overlapSize.x; - }, - set: function (value) { - this.setPercX(value, false); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.setPercX = function (value, ani) { - if (ani === void 0) { ani = false; } - this._owner.ensureBoundsCorrect(); - this.setPosX(this._overlapSize.x * fgui.ToolSet.clamp01(value), ani); - }; - Object.defineProperty(ScrollPane.prototype, "percY", { - get: function () { - return this._overlapSize.y == 0 ? 0 : this._yPos / this._overlapSize.y; - }, - set: function (value) { - this.setPercY(value, false); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.setPercY = function (value, ani) { - if (ani === void 0) { ani = false; } - this._owner.ensureBoundsCorrect(); - this.setPosY(this._overlapSize.y * fgui.ToolSet.clamp01(value), ani); - }; - Object.defineProperty(ScrollPane.prototype, "posX", { - get: function () { - return this._xPos; - }, - set: function (value) { - this.setPosX(value, false); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.setPosX = function (value, ani) { - this._owner.ensureBoundsCorrect(); - if (this._loop == 1) - value = this.loopCheckingNewPos(value, "x"); - value = fgui.ToolSet.clamp(value, 0, this._overlapSize.x); - if (value != this._xPos) { - this._xPos = value; - this.posChanged(ani); - } - }; - Object.defineProperty(ScrollPane.prototype, "posY", { - get: function () { - return this._yPos; - }, - set: function (value) { - this.setPosY(value, false); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.setPosY = function (value, ani) { - this._owner.ensureBoundsCorrect(); - if (this._loop == 1) - value = this.loopCheckingNewPos(value, "y"); - value = fgui.ToolSet.clamp(value, 0, this._overlapSize.y); - if (value != this._yPos) { - this._yPos = value; - this.posChanged(ani); - } - }; - Object.defineProperty(ScrollPane.prototype, "contentWidth", { - get: function () { - return this._contentSize.x; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "contentHeight", { - get: function () { - return this._contentSize.y; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "viewWidth", { - get: function () { - return this._viewSize.x; - }, - set: function (value) { - value = value + this._owner.margin.left + this._owner.margin.right; - if (this._vtScrollBar && !this._floating) - value += this._vtScrollBar.width; - this._owner.width = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "viewHeight", { - get: function () { - return this._viewSize.y; - }, - set: function (value) { - value = value + this._owner.margin.top + this._owner.margin.bottom; - if (this._hzScrollBar && !this._floating) - value += this._hzScrollBar.height; - this._owner.height = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "currentPageX", { - get: function () { - if (!this._pageMode) - return 0; - var page = Math.floor(this._xPos / this._pageSize.x); - if (this._xPos - page * this._pageSize.x > this._pageSize.x * 0.5) - page++; - return page; - }, - set: function (value) { - this.setCurrentPageX(value, false); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "currentPageY", { - get: function () { - if (!this._pageMode) - return 0; - var page = Math.floor(this._yPos / this._pageSize.y); - if (this._yPos - page * this._pageSize.y > this._pageSize.y * 0.5) - page++; - return page; - }, - set: function (value) { - this.setCurrentPageY(value, false); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.setCurrentPageX = function (value, ani) { - if (!this._pageMode) - return; - this._owner.ensureBoundsCorrect(); - if (this._overlapSize.x > 0) - this.setPosX(value * this._pageSize.x, ani); - }; - ScrollPane.prototype.setCurrentPageY = function (value, ani) { - if (!this._pageMode) - return; - this._owner.ensureBoundsCorrect(); - if (this._overlapSize.y > 0) - this.setPosY(value * this._pageSize.y, ani); - }; - Object.defineProperty(ScrollPane.prototype, "isBottomMost", { - get: function () { - return this._yPos == this._overlapSize.y || this._overlapSize.y == 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "isRightMost", { - get: function () { - return this._xPos == this._overlapSize.x || this._overlapSize.x == 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "pageController", { - get: function () { - return this._pageController; - }, - set: function (value) { - this._pageController = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "scrollingPosX", { - get: function () { - return fgui.ToolSet.clamp(-this._container.x, 0, this._overlapSize.x); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "scrollingPosY", { - get: function () { - return fgui.ToolSet.clamp(-this._container.y, 0, this._overlapSize.y); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.scrollTop = function (ani) { - this.setPercY(0, ani); - }; - ScrollPane.prototype.scrollBottom = function (ani) { - this.setPercY(1, ani); - }; - ScrollPane.prototype.scrollUp = function (ratio, ani) { - ratio = ratio || 1; - if (this._pageMode) - this.setPosY(this._yPos - this._pageSize.y * ratio, ani); - else - this.setPosY(this._yPos - this._scrollStep * ratio, ani); - }; - ScrollPane.prototype.scrollDown = function (ratio, ani) { - ratio = ratio || 1; - if (this._pageMode) - this.setPosY(this._yPos + this._pageSize.y * ratio, ani); - else - this.setPosY(this._yPos + this._scrollStep * ratio, ani); - }; - ScrollPane.prototype.scrollLeft = function (ratio, ani) { - ratio = ratio || 1; - if (this._pageMode) - this.setPosX(this._xPos - this._pageSize.x * ratio, ani); - else - this.setPosX(this._xPos - this._scrollStep * ratio, ani); - }; - ScrollPane.prototype.scrollRight = function (ratio, ani) { - ratio = ratio || 1; - if (this._pageMode) - this.setPosX(this._xPos + this._pageSize.x * ratio, ani); - else - this.setPosX(this._xPos + this._scrollStep * ratio, ani); - }; - ScrollPane.prototype.scrollToView = function (target, ani, setFirst) { - this._owner.ensureBoundsCorrect(); - if (this._needRefresh) - this.refresh(); - var rect; - if (target instanceof fgui.GObject) { - if (target.parent != this._owner) { - target.parent.localToGlobalRect(target.x, target.y, target.width, target.height, s_rect); - rect = this._owner.globalToLocalRect(s_rect.x, s_rect.y, s_rect.width, s_rect.height, s_rect); - } - else { - rect = s_rect; - rect.setTo(target.x, target.y, target.width, target.height); - } - } - else - rect = target; - if (this._overlapSize.y > 0) { - var bottom = this._yPos + this._viewSize.y; - if (setFirst || rect.y <= this._yPos || rect.height >= this._viewSize.y) { - if (this._pageMode) - this.setPosY(Math.floor(rect.y / this._pageSize.y) * this._pageSize.y, ani); - else - this.setPosY(rect.y, ani); - } - else if (rect.y + rect.height > bottom) { - if (this._pageMode) - this.setPosY(Math.floor(rect.y / this._pageSize.y) * this._pageSize.y, ani); - else if (rect.height <= this._viewSize.y / 2) - this.setPosY(rect.y + rect.height * 2 - this._viewSize.y, ani); - else - this.setPosY(rect.y + rect.height - this._viewSize.y, ani); - } - } - if (this._overlapSize.x > 0) { - var right = this._xPos + this._viewSize.x; - if (setFirst || rect.x <= this._xPos || rect.width >= this._viewSize.x) { - if (this._pageMode) - this.setPosX(Math.floor(rect.x / this._pageSize.x) * this._pageSize.x, ani); - else - this.setPosX(rect.x, ani); - } - else if (rect.x + rect.width > right) { - if (this._pageMode) - this.setPosX(Math.floor(rect.x / this._pageSize.x) * this._pageSize.x, ani); - else if (rect.width <= this._viewSize.x / 2) - this.setPosX(rect.x + rect.width * 2 - this._viewSize.x, ani); - else - this.setPosX(rect.x + rect.width - this._viewSize.x, ani); - } - } - if (!ani && this._needRefresh) - this.refresh(); - }; - ScrollPane.prototype.isChildInView = function (obj) { - if (this._overlapSize.y > 0) { - var dist = obj.y + this._container.y; - if (dist < -obj.height || dist > this._viewSize.y) - return false; - } - if (this._overlapSize.x > 0) { - dist = obj.x + this._container.x; - if (dist < -obj.width || dist > this._viewSize.x) - return false; - } - return true; - }; - ScrollPane.prototype.cancelDragging = function () { - this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.__touchMove, this); - this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_END, this.__touchEnd, this); - this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.__touchTap, this); - if (ScrollPane.draggingPane == this) - ScrollPane.draggingPane = null; - _gestureFlag = 0; - this._dragged = false; - this._maskContainer.touchChildren = true; - }; - ScrollPane.prototype.lockHeader = function (size) { - if (this._headerLockedSize == size) - return; - this._headerLockedSize = size; - if (!this._refreshEventDispatching && this._container[this._refreshBarAxis] >= 0) { - this._tweenStart.setTo(this._container.x, this._container.y); - this._tweenChange.setTo(0, 0); - this._tweenChange[this._refreshBarAxis] = this._headerLockedSize - this._tweenStart[this._refreshBarAxis]; - this._tweenDuration.setTo(TWEEN_TIME_DEFAULT, TWEEN_TIME_DEFAULT); - this.startTween(2); - } - }; - ScrollPane.prototype.lockFooter = function (size) { - if (this._footerLockedSize == size) - return; - this._footerLockedSize = size; - if (!this._refreshEventDispatching && this._container[this._refreshBarAxis] <= -this._overlapSize[this._refreshBarAxis]) { - this._tweenStart.setTo(this._container.x, this._container.y); - this._tweenChange.setTo(0, 0); - var max = this._overlapSize[this._refreshBarAxis]; - if (max == 0) - max = Math.max(this._contentSize[this._refreshBarAxis] + this._footerLockedSize - this._viewSize[this._refreshBarAxis], 0); - else - max += this._footerLockedSize; - this._tweenChange[this._refreshBarAxis] = -max - this._tweenStart[this._refreshBarAxis]; - this._tweenDuration.setTo(TWEEN_TIME_DEFAULT, TWEEN_TIME_DEFAULT); - this.startTween(2); - } - }; - ScrollPane.prototype.onOwnerSizeChanged = function () { - this.setSize(this._owner.width, this._owner.height); - this.posChanged(false); - }; - ScrollPane.prototype.handleControllerChanged = function (c) { - if (this._pageController == c) { - if (this._scrollType == fgui.ScrollType.Horizontal) - this.setCurrentPageX(c.selectedIndex, true); - else - this.setCurrentPageY(c.selectedIndex, true); - } - }; - ScrollPane.prototype.updatePageController = function () { - if (this._pageController && !this._pageController.changing) { - var index; - if (this._scrollType == fgui.ScrollType.Horizontal) - index = this.currentPageX; - else - index = this.currentPageY; - if (index < this._pageController.pageCount) { - var c = this._pageController; - this._pageController = null; - c.selectedIndex = index; - this._pageController = c; - } - } - }; - ScrollPane.prototype.adjustMaskContainer = function () { - var mx = 0, my = 0; - if (this._dontClipMargin) { - if (this._displayOnLeft && this._vtScrollBar && !this._floating) - mx = this._vtScrollBar.width; - } - else { - if (this._displayOnLeft && this._vtScrollBar && !this._floating) - mx = this._owner.margin.left + this._vtScrollBar.width; - else - mx = this._owner.margin.left; - my = this._owner.margin.top; - } - this._maskContainer.x = mx; - this._maskContainer.y = my; - mx = this._owner._alignOffset.x; - my = this._owner._alignOffset.y; - if (mx != 0 || my != 0 || this._dontClipMargin) { - if (!this._alignContainer) { - this._alignContainer = new egret.DisplayObjectContainer(); - this._maskContainer.addChild(this._alignContainer); - this._alignContainer.addChild(this._container); - } - } - if (this._alignContainer) { - if (this._dontClipMargin) { - mx += this._owner.margin.left; - my += this._owner.margin.top; - } - this._alignContainer.x = mx; - this._alignContainer.y = my; - } - }; - ScrollPane.prototype.setSize = function (aWidth, aHeight) { - this.adjustMaskContainer(); - if (this._hzScrollBar) { - this._hzScrollBar.y = aHeight - this._hzScrollBar.height; - if (this._vtScrollBar && !this._vScrollNone) { - this._hzScrollBar.width = aWidth - this._vtScrollBar.width - this._scrollBarMargin.left - this._scrollBarMargin.right; - if (this._displayOnLeft) - this._hzScrollBar.x = this._scrollBarMargin.left + this._vtScrollBar.width; - else - this._hzScrollBar.x = this._scrollBarMargin.left; - } - else { - this._hzScrollBar.width = aWidth - this._scrollBarMargin.left - this._scrollBarMargin.right; - this._hzScrollBar.x = this._scrollBarMargin.left; - } - } - if (this._vtScrollBar) { - if (!this._displayOnLeft) - this._vtScrollBar.x = aWidth - this._vtScrollBar.width; - if (this._hzScrollBar) - this._vtScrollBar.height = aHeight - this._hzScrollBar.height - this._scrollBarMargin.top - this._scrollBarMargin.bottom; - else - this._vtScrollBar.height = aHeight - this._scrollBarMargin.top - this._scrollBarMargin.bottom; - this._vtScrollBar.y = this._scrollBarMargin.top; - } - this._viewSize.x = aWidth; - this._viewSize.y = aHeight; - if (this._hzScrollBar && !this._floating) - this._viewSize.y -= this._hzScrollBar.height; - if (this._vtScrollBar && !this._floating) - this._viewSize.x -= this._vtScrollBar.width; - this._viewSize.x -= (this._owner.margin.left + this._owner.margin.right); - this._viewSize.y -= (this._owner.margin.top + this._owner.margin.bottom); - this._viewSize.x = Math.max(1, this._viewSize.x); - this._viewSize.y = Math.max(1, this._viewSize.y); - this._pageSize.x = this._viewSize.x; - this._pageSize.y = this._viewSize.y; - this.handleSizeChanged(); - }; - ScrollPane.prototype.setContentSize = function (aWidth, aHeight) { - if (this._contentSize.x == aWidth && this._contentSize.y == aHeight) - return; - this._contentSize.x = aWidth; - this._contentSize.y = aHeight; - this.handleSizeChanged(); - }; - ScrollPane.prototype.changeContentSizeOnScrolling = function (deltaWidth, deltaHeight, deltaPosX, deltaPosY) { - var isRightmost = this._xPos == this._overlapSize.x; - var isBottom = this._yPos == this._overlapSize.y; - this._contentSize.x += deltaWidth; - this._contentSize.y += deltaHeight; - this.handleSizeChanged(); - if (this._tweening == 1) { - if (deltaWidth != 0 && isRightmost && this._tweenChange.x < 0) { - this._xPos = this._overlapSize.x; - this._tweenChange.x = -this._xPos - this._tweenStart.x; - } - if (deltaHeight != 0 && isBottom && this._tweenChange.y < 0) { - this._yPos = this._overlapSize.y; - this._tweenChange.y = -this._yPos - this._tweenStart.y; - } - } - else if (this._tweening == 2) { - if (deltaPosX != 0) { - this._container.x -= deltaPosX; - this._tweenStart.x -= deltaPosX; - this._xPos = -this._container.x; - } - if (deltaPosY != 0) { - this._container.y -= deltaPosY; - this._tweenStart.y -= deltaPosY; - this._yPos = -this._container.y; - } - } - else if (this._dragged) { - if (deltaPosX != 0) { - this._container.x -= deltaPosX; - this._containerPos.x -= deltaPosX; - this._xPos = -this._container.x; - } - if (deltaPosY != 0) { - this._container.y -= deltaPosY; - this._containerPos.y -= deltaPosY; - this._yPos = -this._container.y; - } - } - else { - if (deltaWidth != 0 && isRightmost) { - this._xPos = this._overlapSize.x; - this._container.x = -this._xPos; - } - if (deltaHeight != 0 && isBottom) { - this._yPos = this._overlapSize.y; - this._container.y = -this._yPos; - } - } - if (this._pageMode) - this.updatePageController(); - }; - ScrollPane.prototype.handleSizeChanged = function () { - if (this._displayInDemand) { - this._vScrollNone = this._contentSize.y <= this._viewSize.y; - this._hScrollNone = this._contentSize.x <= this._viewSize.x; - } - if (this._vtScrollBar) { - if (this._contentSize.y == 0) - this._vtScrollBar.setDisplayPerc(0); - else - this._vtScrollBar.setDisplayPerc(Math.min(1, this._viewSize.y / this._contentSize.y)); - } - if (this._hzScrollBar) { - if (this._contentSize.x == 0) - this._hzScrollBar.setDisplayPerc(0); - else - this._hzScrollBar.setDisplayPerc(Math.min(1, this._viewSize.x / this._contentSize.x)); - } - this.updateScrollBarVisible(); - var rect = this._maskContainer.scrollRect; - if (rect) { - rect.width = this._viewSize.x; - rect.height = this._viewSize.y; - if (this._vScrollNone && this._vtScrollBar) - rect.width += this._vtScrollBar.width; - if (this._hScrollNone && this._hzScrollBar) - rect.height += this._hzScrollBar.height; - if (this._dontClipMargin) { - rect.width += (this._owner.margin.left + this._owner.margin.right); - rect.height += (this._owner.margin.top + this._owner.margin.bottom); - } - this._maskContainer.scrollRect = rect; - } - if (this._scrollType == fgui.ScrollType.Horizontal || this._scrollType == fgui.ScrollType.Both) - this._overlapSize.x = Math.ceil(Math.max(0, this._contentSize.x - this._viewSize.x)); - else - this._overlapSize.x = 0; - if (this._scrollType == fgui.ScrollType.Vertical || this._scrollType == fgui.ScrollType.Both) - this._overlapSize.y = Math.ceil(Math.max(0, this._contentSize.y - this._viewSize.y)); - else - this._overlapSize.y = 0; - this._xPos = fgui.ToolSet.clamp(this._xPos, 0, this._overlapSize.x); - this._yPos = fgui.ToolSet.clamp(this._yPos, 0, this._overlapSize.y); - if (this._refreshBarAxis != null) { - var max = this._overlapSize[this._refreshBarAxis]; - if (max == 0) - max = Math.max(this._contentSize[this._refreshBarAxis] + this._footerLockedSize - this._viewSize[this._refreshBarAxis], 0); - else - max += this._footerLockedSize; - if (this._refreshBarAxis == "x") { - this._container.x = fgui.ToolSet.clamp(this._container.x, -max, this._headerLockedSize); - this._container.y = fgui.ToolSet.clamp(this._container.y, -this._overlapSize.y, 0); - } - else { - this._container.x = fgui.ToolSet.clamp(this._container.x, -this._overlapSize.x, 0); - this._container.y = fgui.ToolSet.clamp(this._container.y, -max, this._headerLockedSize); - } - if (this._header) { - if (this._refreshBarAxis == "x") - this._header.height = this._viewSize.y; - else - this._header.width = this._viewSize.x; - } - if (this._footer) { - if (this._refreshBarAxis == "y") - this._footer.height = this._viewSize.y; - else - this._footer.width = this._viewSize.x; - } - } - else { - this._container.x = fgui.ToolSet.clamp(this._container.x, -this._overlapSize.x, 0); - this._container.y = fgui.ToolSet.clamp(this._container.y, -this._overlapSize.y, 0); - } - this.updateScrollBarPos(); - if (this._pageMode) - this.updatePageController(); - }; - ScrollPane.prototype.posChanged = function (ani) { - if (this._aniFlag == 0) - this._aniFlag = ani ? 1 : -1; - else if (this._aniFlag == 1 && !ani) - this._aniFlag = -1; - this._needRefresh = true; - fgui.GTimers.inst.callLater(this.refresh, this); - if (this._tweening != 0) - this.killTween(); - }; - ScrollPane.prototype.refresh = function () { - this._needRefresh = false; - fgui.GTimers.inst.remove(this.refresh, this); - if (this._pageMode || this._snapToItem) { - sEndPos.setTo(-this._xPos, -this._yPos); - this.alignPosition(sEndPos, false); - this._xPos = -sEndPos.x; - this._yPos = -sEndPos.y; - } - this.refresh2(); - this.dispatchEventWith(ScrollPane.SCROLL); - if (this._needRefresh) { - this._needRefresh = false; - fgui.GTimers.inst.remove(this.refresh, this); - this.refresh2(); - } - this.updateScrollBarPos(); - this._aniFlag = 0; - }; - ScrollPane.prototype.refresh2 = function () { - if (this._aniFlag == 1 && !this._dragged) { - var posX; - var posY; - if (this._overlapSize.x > 0) - posX = -Math.floor(this._xPos); - else { - if (this._container.x != 0) - this._container.x = 0; - posX = 0; - } - if (this._overlapSize.y > 0) - posY = -Math.floor(this._yPos); - else { - if (this._container.y != 0) - this._container.y = 0; - posY = 0; - } - if (posX != this._container.x || posY != this._container.y) { - this._tweenDuration.setTo(TWEEN_TIME_GO, TWEEN_TIME_GO); - this._tweenStart.setTo(this._container.x, this._container.y); - this._tweenChange.setTo(posX - this._tweenStart.x, posY - this._tweenStart.y); - this.startTween(1); - } - else if (this._tweening != 0) - this.killTween(); - } - else { - if (this._tweening != 0) - this.killTween(); - this._container.x = Math.floor(-this._xPos); - this._container.y = Math.floor(-this._yPos); - this.loopCheckingCurrent(); - } - if (this._pageMode) - this.updatePageController(); - }; - ScrollPane.prototype.__touchBegin = function (evt) { - if (!this._touchEffect) - return; - if (this._tweening != 0) { - this.killTween(); - this._dragged = true; - } - else - this._dragged = false; - var pt = this._owner.globalToLocal(evt.stageX, evt.stageY, s_vec2); - this._containerPos.setTo(this._container.x, this._container.y); - this._beginTouchPos.setTo(pt.x, pt.y); - this._lastTouchPos.setTo(pt.x, pt.y); - this._lastTouchGlobalPos.setTo(evt.stageX, evt.stageY); - this._isHoldAreaDone = false; - this._velocity.setTo(0, 0); - this._velocityScale = 1; - this._lastMoveTime = egret.getTimer() / 1000; - this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__touchMove, this); - this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.__touchEnd, this); - this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_TAP, this.__touchTap, this); - }; - ScrollPane.prototype.__touchMove = function (evt) { - if (this._owner.displayObject.stage == null) - return; - if (!this._touchEffect) - return; - if (ScrollPane.draggingPane && ScrollPane.draggingPane != this || fgui.GObject.draggingObject) - return; - var pt = this._owner.globalToLocal(evt.stageX, evt.stageY, s_vec2); - var sensitivity = fgui.UIConfig.touchScrollSensitivity; - var diff, diff2; - var sv, sh, st; - if (this._scrollType == fgui.ScrollType.Vertical) { - if (!this._isHoldAreaDone) { - _gestureFlag |= 1; - diff = Math.abs(this._beginTouchPos.y - pt.y); - if (diff < sensitivity) - return; - if ((_gestureFlag & 2) != 0) { - diff2 = Math.abs(this._beginTouchPos.x - pt.x); - if (diff < diff2) - return; - } - } - sv = true; - } - else if (this._scrollType == fgui.ScrollType.Horizontal) { - if (!this._isHoldAreaDone) { - _gestureFlag |= 2; - diff = Math.abs(this._beginTouchPos.x - pt.x); - if (diff < sensitivity) - return; - if ((_gestureFlag & 1) != 0) { - diff2 = Math.abs(this._beginTouchPos.y - pt.y); - if (diff < diff2) - return; - } - } - sh = true; - } - else { - _gestureFlag = 3; - if (!this._isHoldAreaDone) { - diff = Math.abs(this._beginTouchPos.y - pt.y); - if (diff < sensitivity) { - diff = Math.abs(this._beginTouchPos.x - pt.x); - if (diff < sensitivity) - return; - } - } - sv = sh = true; - } - var newPosX = Math.floor(this._containerPos.x + pt.x - this._beginTouchPos.x); - var newPosY = Math.floor(this._containerPos.y + pt.y - this._beginTouchPos.y); - if (sv) { - if (newPosY > 0) { - if (!this._bouncebackEffect) - this._container.y = 0; - else if (this._header && this._header.maxHeight != 0) - this._container.y = Math.floor(Math.min(newPosY * 0.5, this._header.maxHeight)); - else - this._container.y = Math.floor(Math.min(newPosY * 0.5, this._viewSize.y * PULL_RATIO)); - } - else if (newPosY < -this._overlapSize.y) { - if (!this._bouncebackEffect) - this._container.y = -this._overlapSize.y; - else if (this._footer && this._footer.maxHeight > 0) - this._container.y = Math.floor(Math.max((newPosY + this._overlapSize.y) * 0.5, -this._footer.maxHeight) - this._overlapSize.y); - else - this._container.y = Math.floor(Math.max((newPosY + this._overlapSize.y) * 0.5, -this._viewSize.y * PULL_RATIO) - this._overlapSize.y); - } - else - this._container.y = newPosY; - } - if (sh) { - if (newPosX > 0) { - if (!this._bouncebackEffect) - this._container.x = 0; - else if (this._header && this._header.maxWidth != 0) - this._container.x = Math.floor(Math.min(newPosX * 0.5, this._header.maxWidth)); - else - this._container.x = Math.floor(Math.min(newPosX * 0.5, this._viewSize.x * PULL_RATIO)); - } - else if (newPosX < 0 - this._overlapSize.x) { - if (!this._bouncebackEffect) - this._container.x = -this._overlapSize.x; - else if (this._footer && this._footer.maxWidth > 0) - this._container.x = Math.floor(Math.max((newPosX + this._overlapSize.x) * 0.5, -this._footer.maxWidth) - this._overlapSize.x); - else - this._container.x = Math.floor(Math.max((newPosX + this._overlapSize.x) * 0.5, -this._viewSize.x * PULL_RATIO) - this._overlapSize.x); - } - else - this._container.x = newPosX; - } - var now = egret.getTimer() / 1000; - var deltaTime = Math.max(now - this._lastMoveTime, 1 / 60); - var deltaPositionX = pt.x - this._lastTouchPos.x; - var deltaPositionY = pt.y - this._lastTouchPos.y; - if (!sh) - deltaPositionX = 0; - if (!sv) - deltaPositionY = 0; - if (deltaTime != 0) { - var frameRate = this._owner.displayObject.stage.frameRate; - var elapsed = deltaTime * frameRate - 1; - if (elapsed > 1) { - var factor = Math.pow(0.833, elapsed); - this._velocity.x = this._velocity.x * factor; - this._velocity.y = this._velocity.y * factor; - } - this._velocity.x = fgui.ToolSet.lerp(this._velocity.x, deltaPositionX * 60 / frameRate / deltaTime, deltaTime * 10); - this._velocity.y = fgui.ToolSet.lerp(this._velocity.y, deltaPositionY * 60 / frameRate / deltaTime, deltaTime * 10); - } - var deltaGlobalPositionX = this._lastTouchGlobalPos.x - evt.stageX; - var deltaGlobalPositionY = this._lastTouchGlobalPos.y - evt.stageY; - if (deltaPositionX != 0) - this._velocityScale = Math.abs(deltaGlobalPositionX / deltaPositionX); - else if (deltaPositionY != 0) - this._velocityScale = Math.abs(deltaGlobalPositionY / deltaPositionY); - this._lastTouchPos.setTo(pt.x, pt.y); - this._lastTouchGlobalPos.setTo(evt.stageX, evt.stageY); - this._lastMoveTime = now; - if (this._overlapSize.x > 0) - this._xPos = fgui.ToolSet.clamp(-this._container.x, 0, this._overlapSize.x); - if (this._overlapSize.y > 0) - this._yPos = fgui.ToolSet.clamp(-this._container.y, 0, this._overlapSize.y); - if (this._loop != 0) { - newPosX = this._container.x; - newPosY = this._container.y; - if (this.loopCheckingCurrent()) { - this._containerPos.x += this._container.x - newPosX; - this._containerPos.y += this._container.y - newPosY; - } - } - ScrollPane.draggingPane = this; - this._isHoldAreaDone = true; - this._dragged = true; - this._maskContainer.touchChildren = false; - this.updateScrollBarPos(); - this.updateScrollBarVisible(); - if (this._pageMode) - this.updatePageController(); - this.dispatchEventWith(ScrollPane.SCROLL); - }; - ScrollPane.prototype.__touchEnd = function (evt) { - evt.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.__touchMove, this); - evt.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END, this.__touchEnd, this); - evt.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.__touchTap, this); - if (ScrollPane.draggingPane == this) - ScrollPane.draggingPane = null; - _gestureFlag = 0; - if (!this._dragged || !this._touchEffect || this._owner.displayObject.stage == null) { - this._dragged = false; - this._maskContainer.touchChildren = true; - return; - } - this._dragged = false; - this._maskContainer.touchChildren = true; - this._tweenStart.setTo(this._container.x, this._container.y); - sEndPos.setTo(this._tweenStart.x, this._tweenStart.y); - var flag = false; - if (this._container.x > 0) { - sEndPos.x = 0; - flag = true; - } - else if (this._container.x < -this._overlapSize.x) { - sEndPos.x = -this._overlapSize.x; - flag = true; - } - if (this._container.y > 0) { - sEndPos.y = 0; - flag = true; - } - else if (this._container.y < -this._overlapSize.y) { - sEndPos.y = -this._overlapSize.y; - flag = true; - } - if (flag) { - this._tweenChange.setTo(sEndPos.x - this._tweenStart.x, sEndPos.y - this._tweenStart.y); - if (this._tweenChange.x < -fgui.UIConfig.touchDragSensitivity || this._tweenChange.y < -fgui.UIConfig.touchDragSensitivity) { - this._refreshEventDispatching = true; - this.dispatchEventWith(ScrollPane.PULL_DOWN_RELEASE); - this._refreshEventDispatching = false; - } - else if (this._tweenChange.x > fgui.UIConfig.touchDragSensitivity || this._tweenChange.y > fgui.UIConfig.touchDragSensitivity) { - this._refreshEventDispatching = true; - this.dispatchEventWith(ScrollPane.PULL_UP_RELEASE); - this._refreshEventDispatching = false; - } - if (this._headerLockedSize > 0 && sEndPos[this._refreshBarAxis] == 0) { - sEndPos[this._refreshBarAxis] = this._headerLockedSize; - this._tweenChange.x = sEndPos.x - this._tweenStart.x; - this._tweenChange.y = sEndPos.y - this._tweenStart.y; - } - else if (this._footerLockedSize > 0 && sEndPos[this._refreshBarAxis] == -this._overlapSize[this._refreshBarAxis]) { - var max = this._overlapSize[this._refreshBarAxis]; - if (max == 0) - max = Math.max(this._contentSize[this._refreshBarAxis] + this._footerLockedSize - this._viewSize[this._refreshBarAxis], 0); - else - max += this._footerLockedSize; - sEndPos[this._refreshBarAxis] = -max; - this._tweenChange.x = sEndPos.x - this._tweenStart.x; - this._tweenChange.y = sEndPos.y - this._tweenStart.y; - } - this._tweenDuration.setTo(TWEEN_TIME_DEFAULT, TWEEN_TIME_DEFAULT); - } - else { - if (!this._inertiaDisabled) { - var frameRate = this._owner.displayObject.stage.frameRate; - var elapsed = (egret.getTimer() / 1000 - this._lastMoveTime) * frameRate - 1; - if (elapsed > 1) { - var factor = Math.pow(0.833, elapsed); - this._velocity.x = this._velocity.x * factor; - this._velocity.y = this._velocity.y * factor; - } - this.updateTargetAndDuration(this._tweenStart, sEndPos); - } - else - this._tweenDuration.setTo(TWEEN_TIME_DEFAULT, TWEEN_TIME_DEFAULT); - sOldChange.setTo(sEndPos.x - this._tweenStart.x, sEndPos.y - this._tweenStart.y); - this.loopCheckingTarget(sEndPos); - if (this._pageMode || this._snapToItem) - this.alignPosition(sEndPos, true); - this._tweenChange.x = sEndPos.x - this._tweenStart.x; - this._tweenChange.y = sEndPos.y - this._tweenStart.y; - if (this._tweenChange.x == 0 && this._tweenChange.y == 0) { - this.updateScrollBarVisible(); - return; - } - if (this._pageMode || this._snapToItem) { - this.fixDuration("x", sOldChange.x); - this.fixDuration("y", sOldChange.y); - } - } - this.startTween(2); - }; - ScrollPane.prototype.__touchTap = function (evt) { - this._dragged = false; - }; - ScrollPane.prototype.updateScrollBarPos = function () { - if (this._vtScrollBar) - this._vtScrollBar.setScrollPerc(this._overlapSize.y == 0 ? 0 : fgui.ToolSet.clamp(-this._container.y, 0, this._overlapSize.y) / this._overlapSize.y); - if (this._hzScrollBar) - this._hzScrollBar.setScrollPerc(this._overlapSize.x == 0 ? 0 : fgui.ToolSet.clamp(-this._container.x, 0, this._overlapSize.x) / this._overlapSize.x); - this.checkRefreshBar(); - }; - ScrollPane.prototype.updateScrollBarVisible = function () { - if (this._vtScrollBar) { - if (this._viewSize.y <= this._vtScrollBar.minSize || this._vScrollNone) - this._vtScrollBar.displayObject.visible = false; - else - this.updateScrollBarVisible2(this._vtScrollBar); - } - if (this._hzScrollBar) { - if (this._viewSize.x <= this._hzScrollBar.minSize || this._hScrollNone) - this._hzScrollBar.displayObject.visible = false; - else - this.updateScrollBarVisible2(this._hzScrollBar); - } - }; - ScrollPane.prototype.updateScrollBarVisible2 = function (bar) { - if (this._scrollBarDisplayAuto) - fgui.GTween.kill(bar, false, "alpha"); - if (this._scrollBarDisplayAuto && this._tweening == 0 && !this._dragged && !bar.gripDragging) { - if (bar.displayObject.visible) - fgui.GTween.to(1, 0, 0.5).setDelay(0.5).onComplete(this.__barTweenComplete, this).setTarget(bar, "alpha"); - } - else { - bar.alpha = 1; - bar.displayObject.visible = true; - } - }; - ScrollPane.prototype.__barTweenComplete = function (tweener) { - var bar = (tweener.target); - bar.alpha = 1; - bar.displayObject.visible = false; - }; - ScrollPane.prototype.getLoopPartSize = function (division, axis) { - return (this._contentSize[axis] + (axis == "x" ? this._owner.columnGap : this._owner.lineGap)) / division; - }; - ScrollPane.prototype.loopCheckingCurrent = function () { - var changed = false; - if (this._loop == 1 && this._overlapSize.x > 0) { - if (this._xPos < 0.001) { - this._xPos += this.getLoopPartSize(2, "x"); - changed = true; - } - else if (this._xPos >= this._overlapSize.x) { - this._xPos -= this.getLoopPartSize(2, "x"); - changed = true; - } - } - else if (this._loop == 2 && this._overlapSize.y > 0) { - if (this._yPos < 0.001) { - this._yPos += this.getLoopPartSize(2, "y"); - changed = true; - } - else if (this._yPos >= this._overlapSize.y) { - this._yPos -= this.getLoopPartSize(2, "y"); - changed = true; - } - } - if (changed) { - this._container.x = Math.floor(-this._xPos); - this._container.y = Math.floor(-this._yPos); - } - return changed; - }; - ScrollPane.prototype.loopCheckingTarget = function (endPos) { - if (this._loop == 1) - this.loopCheckingTarget2(endPos, "x"); - if (this._loop == 2) - this.loopCheckingTarget2(endPos, "y"); - }; - ScrollPane.prototype.loopCheckingTarget2 = function (endPos, axis) { - var halfSize; - var tmp; - if (endPos[axis] > 0) { - halfSize = this.getLoopPartSize(2, axis); - tmp = this._tweenStart[axis] - halfSize; - if (tmp <= 0 && tmp >= -this._overlapSize[axis]) { - endPos[axis] -= halfSize; - this._tweenStart[axis] = tmp; - } - } - else if (endPos[axis] < -this._overlapSize[axis]) { - halfSize = this.getLoopPartSize(2, axis); - tmp = this._tweenStart[axis] + halfSize; - if (tmp <= 0 && tmp >= -this._overlapSize[axis]) { - endPos[axis] += halfSize; - this._tweenStart[axis] = tmp; - } - } - }; - ScrollPane.prototype.loopCheckingNewPos = function (value, axis) { - if (this._overlapSize[axis] == 0) - return value; - var pos = axis == "x" ? this._xPos : this._yPos; - var changed = false; - var v; - if (value < 0.001) { - value += this.getLoopPartSize(2, axis); - if (value > pos) { - v = this.getLoopPartSize(6, axis); - v = Math.ceil((value - pos) / v) * v; - pos = fgui.ToolSet.clamp(pos + v, 0, this._overlapSize[axis]); - changed = true; - } - } - else if (value >= this._overlapSize[axis]) { - value -= this.getLoopPartSize(2, axis); - if (value < pos) { - v = this.getLoopPartSize(6, axis); - v = Math.ceil((pos - value) / v) * v; - pos = fgui.ToolSet.clamp(pos - v, 0, this._overlapSize[axis]); - changed = true; - } - } - if (changed) { - if (axis == "x") - this._container.x = -Math.floor(pos); - else - this._container.y = -Math.floor(pos); - } - return value; - }; - ScrollPane.prototype.alignPosition = function (pos, inertialScrolling) { - if (this._pageMode) { - pos.x = this.alignByPage(pos.x, "x", inertialScrolling); - pos.y = this.alignByPage(pos.y, "y", inertialScrolling); - } - else if (this._snapToItem) { - var pt = this._owner.getSnappingPosition(-pos.x, -pos.y, s_vec2); - if (pos.x < 0 && pos.x > -this._overlapSize.x) - pos.x = -pt.x; - if (pos.y < 0 && pos.y > -this._overlapSize.y) - pos.y = -pt.y; - } - }; - ScrollPane.prototype.alignByPage = function (pos, axis, inertialScrolling) { - var page; - if (pos > 0) - page = 0; - else if (pos < -this._overlapSize[axis]) - page = Math.ceil(this._contentSize[axis] / this._pageSize[axis]) - 1; - else { - page = Math.floor(-pos / this._pageSize[axis]); - var change = inertialScrolling ? (pos - this._containerPos[axis]) : (pos - this._container[axis]); - var testPageSize = Math.min(this._pageSize[axis], this._contentSize[axis] - (page + 1) * this._pageSize[axis]); - var delta = -pos - page * this._pageSize[axis]; - if (Math.abs(change) > this._pageSize[axis]) { - if (delta > testPageSize * 0.5) - page++; - } - else { - if (delta > testPageSize * (change < 0 ? 0.3 : 0.7)) - page++; - } - pos = -page * this._pageSize[axis]; - if (pos < -this._overlapSize[axis]) - pos = -this._overlapSize[axis]; - } - if (inertialScrolling) { - var oldPos = this._tweenStart[axis]; - var oldPage; - if (oldPos > 0) - oldPage = 0; - else if (oldPos < -this._overlapSize[axis]) - oldPage = Math.ceil(this._contentSize[axis] / this._pageSize[axis]) - 1; - else - oldPage = Math.floor(-oldPos / this._pageSize[axis]); - var startPage = Math.floor(-this._containerPos[axis] / this._pageSize[axis]); - if (Math.abs(page - startPage) > 1 && Math.abs(oldPage - startPage) <= 1) { - if (page > startPage) - page = startPage + 1; - else - page = startPage - 1; - pos = -page * this._pageSize[axis]; - } - } - return pos; - }; - ScrollPane.prototype.updateTargetAndDuration = function (orignPos, resultPos) { - resultPos.x = this.updateTargetAndDuration2(orignPos.x, "x"); - resultPos.y = this.updateTargetAndDuration2(orignPos.y, "y"); - }; - ScrollPane.prototype.updateTargetAndDuration2 = function (pos, axis) { - var v = this._velocity[axis]; - var duration = 0; - if (pos > 0) - pos = 0; - else if (pos < -this._overlapSize[axis]) - pos = -this._overlapSize[axis]; - else { - var isMobile = egret.Capabilities.isMobile; - var v2 = Math.abs(v) * this._velocityScale; - if (isMobile) - v2 *= 1136 / Math.max(this._owner.displayObject.stage.stageWidth, this._owner.displayObject.stage.stageHeight); - var ratio = 0; - if (this._pageMode || !isMobile) { - if (v2 > 500) - ratio = Math.pow((v2 - 500) / 500, 2); - } - else { - if (v2 > 1000) - ratio = Math.pow((v2 - 1000) / 1000, 2); - } - if (ratio != 0) { - if (ratio > 1) - ratio = 1; - v2 *= ratio; - v *= ratio; - this._velocity[axis] = v; - duration = Math.log(60 / v2) / Math.log(this._decelerationRate) / 60; - var change = Math.floor(v * duration * 0.4); - pos += change; - } - } - if (duration < TWEEN_TIME_DEFAULT) - duration = TWEEN_TIME_DEFAULT; - this._tweenDuration[axis] = duration; - return pos; - }; - ScrollPane.prototype.fixDuration = function (axis, oldChange) { - if (this._tweenChange[axis] == 0 || Math.abs(this._tweenChange[axis]) >= Math.abs(oldChange)) - return; - var newDuration = Math.abs(this._tweenChange[axis] / oldChange) * this._tweenDuration[axis]; - if (newDuration < TWEEN_TIME_DEFAULT) - newDuration = TWEEN_TIME_DEFAULT; - this._tweenDuration[axis] = newDuration; - }; - ScrollPane.prototype.startTween = function (type) { - this._tweenTime.setTo(0, 0); - this._tweening = type; - fgui.GTimers.inst.add(1, 0, this.tweenUpdate, this); - this.updateScrollBarVisible(); - }; - ScrollPane.prototype.killTween = function () { - if (this._tweening == 1) { - this._container.x = this._tweenStart.x + this._tweenChange.x; - this._container.y = this._tweenStart.y + this._tweenChange.y; - this.dispatchEventWith(ScrollPane.SCROLL); - } - this._tweening = 0; - fgui.GTimers.inst.remove(this.tweenUpdate, this); - this.updateScrollBarVisible(); - this.dispatchEventWith(ScrollPane.SCROLL_END); - }; - ScrollPane.prototype.checkRefreshBar = function () { - if (this._header == null && this._footer == null) - return; - var pos = this._container[this._refreshBarAxis]; - if (this._header) { - if (pos > 0) { - if (this._header.displayObject.parent == null) - this._maskContainer.addChildAt(this._header.displayObject, 0); - var pt = s_vec2; - pt.setTo(this._header.width, this._header.height); - pt[this._refreshBarAxis] = pos; - this._header.setSize(pt.x, pt.y); - } - else { - if (this._header.displayObject.parent) - this._maskContainer.removeChild(this._header.displayObject); - } - } - if (this._footer) { - var max = this._overlapSize[this._refreshBarAxis]; - if (pos < -max || max == 0 && this._footerLockedSize > 0) { - if (this._footer.displayObject.parent == null) - this._maskContainer.addChildAt(this._footer.displayObject, 0); - pt = s_vec2; - pt.setTo(this._footer.x, this._footer.y); - if (max > 0) - pt[this._refreshBarAxis] = pos + this._contentSize[this._refreshBarAxis]; - else - pt[this._refreshBarAxis] = Math.max(Math.min(pos + this._viewSize[this._refreshBarAxis], this._viewSize[this._refreshBarAxis] - this._footerLockedSize), this._viewSize[this._refreshBarAxis] - this._contentSize[this._refreshBarAxis]); - this._footer.setXY(pt.x, pt.y); - pt.setTo(this._footer.width, this._footer.height); - if (max > 0) - pt[this._refreshBarAxis] = -max - pos; - else - pt[this._refreshBarAxis] = this._viewSize[this._refreshBarAxis] - this._footer[this._refreshBarAxis]; - this._footer.setSize(pt.x, pt.y); - } - else { - if (this._footer.displayObject.parent) - this._maskContainer.removeChild(this._footer.displayObject); - } - } - }; - ScrollPane.prototype.tweenUpdate = function (timestamp) { - var nx = this.runTween("x"); - var ny = this.runTween("y"); - this._container.x = nx; - this._container.y = ny; - if (this._tweening == 2) { - if (this._overlapSize.x > 0) - this._xPos = fgui.ToolSet.clamp(-nx, 0, this._overlapSize.x); - if (this._overlapSize.y > 0) - this._yPos = fgui.ToolSet.clamp(-ny, 0, this._overlapSize.y); - if (this._pageMode) - this.updatePageController(); - } - if (this._tweenChange.x == 0 && this._tweenChange.y == 0) { - this._tweening = 0; - fgui.GTimers.inst.remove(this.tweenUpdate, this); - this.loopCheckingCurrent(); - this.updateScrollBarPos(); - this.updateScrollBarVisible(); - this.dispatchEventWith(ScrollPane.SCROLL); - this.dispatchEventWith(ScrollPane.SCROLL_END); - } - else { - this.updateScrollBarPos(); - this.dispatchEventWith(ScrollPane.SCROLL); - } - return true; - }; - ScrollPane.prototype.runTween = function (axis) { - var newValue; - if (this._tweenChange[axis] != 0) { - this._tweenTime[axis] += fgui.GTimers.deltaTime / 1000; - if (this._tweenTime[axis] >= this._tweenDuration[axis]) { - newValue = this._tweenStart[axis] + this._tweenChange[axis]; - this._tweenChange[axis] = 0; - } - else { - var ratio = easeFunc(this._tweenTime[axis], this._tweenDuration[axis]); - newValue = this._tweenStart[axis] + Math.floor(this._tweenChange[axis] * ratio); - } - var threshold1 = 0; - var threshold2 = -this._overlapSize[axis]; - if (this._headerLockedSize > 0 && this._refreshBarAxis == axis) - threshold1 = this._headerLockedSize; - if (this._footerLockedSize > 0 && this._refreshBarAxis == axis) { - var max = this._overlapSize[this._refreshBarAxis]; - if (max == 0) - max = Math.max(this._contentSize[this._refreshBarAxis] + this._footerLockedSize - this._viewSize[this._refreshBarAxis], 0); - else - max += this._footerLockedSize; - threshold2 = -max; - } - if (this._tweening == 2 && this._bouncebackEffect) { - if (newValue > 20 + threshold1 && this._tweenChange[axis] > 0 - || newValue > threshold1 && this._tweenChange[axis] == 0) { - this._tweenTime[axis] = 0; - this._tweenDuration[axis] = TWEEN_TIME_DEFAULT; - this._tweenChange[axis] = -newValue + threshold1; - this._tweenStart[axis] = newValue; - } - else if (newValue < threshold2 - 20 && this._tweenChange[axis] < 0 - || newValue < threshold2 && this._tweenChange[axis] == 0) { - this._tweenTime[axis] = 0; - this._tweenDuration[axis] = TWEEN_TIME_DEFAULT; - this._tweenChange[axis] = threshold2 - newValue; - this._tweenStart[axis] = newValue; - } - } - else { - if (newValue > threshold1) { - newValue = threshold1; - this._tweenChange[axis] = 0; - } - else if (newValue < threshold2) { - newValue = threshold2; - this._tweenChange[axis] = 0; - } - } - } - else - newValue = this._container[axis]; - return newValue; - }; - ScrollPane.SCROLL = "__scroll"; - ScrollPane.SCROLL_END = "__scrollEnd"; - ScrollPane.PULL_DOWN_RELEASE = "pullDownRelease"; - ScrollPane.PULL_UP_RELEASE = "pullUpRelease"; - return ScrollPane; - }(egret.EventDispatcher)); - fgui.ScrollPane = ScrollPane; - var _gestureFlag = 0; - var TWEEN_TIME_GO = 0.5; - var TWEEN_TIME_DEFAULT = 0.3; - var PULL_RATIO = 0.5; - var s_vec2 = new egret.Point(); - var s_rect = new egret.Rectangle(); - var sEndPos = new egret.Point(); - var sOldChange = new egret.Point(); - function easeFunc(t, d) { - return (t = t / d - 1) * t * t + 1; - } -})(fgui || (fgui = {})); - -(function (fgui) { - var Transition = (function () { - function Transition(owner) { - this._ownerBaseX = 0; - this._ownerBaseY = 0; - this._totalTimes = 0; - this._totalTasks = 0; - this._options = 0; - this._totalDuration = 0; - this._autoPlayTimes = 1; - this._autoPlayDelay = 0; - this._timeScale = 1; - this._startTime = 0; - this._endTime = 0; - this._owner = owner; - this._items = new Array(); - } - Transition.prototype.play = function (onComplete, onCompleteObj, onCompleteParam, times, delay, startTime, endTime) { - this._play(onComplete, onCompleteObj, onCompleteParam, times, delay, startTime, endTime, false); - }; - Transition.prototype.playReverse = function (onComplete, onCompleteObj, onCompleteParam, times, delay) { - this._play(onComplete, onCompleteObj, onCompleteParam, times, delay, 0, -1, true); - }; - Transition.prototype.changePlayTimes = function (value) { - this._totalTimes = value; - }; - Transition.prototype.setAutoPlay = function (value, times, delay) { - if (times == undefined) - times = -1; - if (delay == undefined) - delay = 0; - if (this._autoPlay != value) { - this._autoPlay = value; - this._autoPlayTimes = times; - this._autoPlayDelay = delay; - if (this._autoPlay) { - if (this._owner.onStage) - this.play(null, null, this._autoPlayTimes, this._autoPlayDelay); - } - else { - if (!this._owner.onStage) - this.stop(false, true); - } - } - }; - Transition.prototype._play = function (onComplete, onCompleteCaller, onCompleteParam, times, delay, startTime, endTime, reversed) { - if (times == undefined) - times = 1; - if (delay == undefined) - delay = 0; - if (startTime == undefined) - startTime = 0; - if (endTime == undefined) - endTime = -1; - this.stop(true, true); - this._totalTimes = times; - this._reversed = reversed; - this._startTime = startTime; - this._endTime = endTime; - this._playing = true; - this._paused = false; - this._onComplete = onComplete; - this._onCompleteParam = onCompleteParam; - this._onCompleteCaller = onCompleteCaller; - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (!item.target) { - if (item.targetId) - item.target = this._owner.getChildById(item.targetId); - else - item.target = this._owner; - } - else if (item.target != this._owner && item.target.parent != this._owner) - item.target = null; - if (item.target && item.type == ActionType.Transition) { - var trans = item.target.getTransition(item.value.transName); - if (trans == this) - trans = null; - if (trans) { - if (item.value.playTimes == 0) { - var j; - for (j = i - 1; j >= 0; j--) { - var item2 = this._items[j]; - if (item2.type == ActionType.Transition) { - if (item2.value.trans == trans) { - item2.value.stopTime = item.time - item2.time; - break; - } - } - } - if (j < 0) - item.value.stopTime = 0; - else - trans = null; - } - else - item.value.stopTime = -1; - } - item.value.trans = trans; - } - } - if (delay == 0) - this.onDelayedPlay(); - else - fgui.GTween.delayedCall(delay).onComplete(this.onDelayedPlay, this); - }; - Transition.prototype.stop = function (setToComplete, processCallback) { - if (setToComplete == undefined) - setToComplete = true; - if (!this._playing) - return; - this._playing = false; - this._totalTasks = 0; - this._totalTimes = 0; - var func = this._onComplete; - var param = this._onCompleteParam; - var thisObj = this._onCompleteCaller; - this._onComplete = null; - this._onCompleteParam = null; - this._onCompleteCaller = null; - fgui.GTween.kill(this); - var cnt = this._items.length; - if (this._reversed) { - for (var i = cnt - 1; i >= 0; i--) { - var item = this._items[i]; - if (!item.target) - continue; - this.stopItem(item, setToComplete); - } - } - else { - for (i = 0; i < cnt; i++) { - item = this._items[i]; - if (!item.target) - continue; - this.stopItem(item, setToComplete); - } - } - if (processCallback && func != null) { - func.call(thisObj, param); - } - }; - Transition.prototype.stopItem = function (item, setToComplete) { - if (item.displayLockToken != 0) { - item.target.releaseDisplayLock(item.displayLockToken); - item.displayLockToken = 0; - } - if (item.tweener) { - item.tweener.kill(setToComplete); - item.tweener = null; - if (item.type == ActionType.Shake && !setToComplete) { - item.target._gearLocked = true; - item.target.setXY(item.target.x - item.value.lastOffsetX, item.target.y - item.value.lastOffsetY); - item.target._gearLocked = false; - } - } - if (item.type == ActionType.Transition) { - var trans = item.value.trans; - if (trans) - trans.stop(setToComplete, false); - } - }; - Transition.prototype.setPaused = function (paused) { - if (!this._playing || this._paused == paused) - return; - this._paused = paused; - var tweener = fgui.GTween.getTween(this); - if (tweener) - tweener.setPaused(paused); - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (!item.target) - continue; - if (item.type == ActionType.Transition) { - if (item.value.trans) - item.value.trans.setPaused(paused); - } - else if (item.type == ActionType.Animation) { - if (paused) { - item.value.flag = item.target.getProp(fgui.ObjectPropID.Playing); - item.target.setProp(fgui.ObjectPropID.Playing, false); - } - else - item.target.setProp(fgui.ObjectPropID.Playing, item.value.flag); - } - if (item.tweener) - item.tweener.setPaused(paused); - } - }; - Transition.prototype.dispose = function () { - if (this._playing) - fgui.GTween.kill(this); - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.tweener) { - item.tweener.kill(); - item.tweener = null; - } - item.target = null; - item.hook = null; - if (item.tweenConfig) - item.tweenConfig.endHook = null; - } - this._items.length = 0; - this._playing = false; - this._onComplete = null; - this._onCompleteCaller = null; - this._onCompleteParam = null; - }; - Object.defineProperty(Transition.prototype, "playing", { - get: function () { - return this._playing; - }, - enumerable: true, - configurable: true - }); - Transition.prototype.setValue = function (label) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - var cnt = this._items.length; - var value; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.label == label) { - if (item.tweenConfig) - value = item.tweenConfig.startValue; - else - value = item.value; - } - else if (item.tweenConfig && item.tweenConfig.endLabel == label) { - value = item.tweenConfig.endValue; - } - else - continue; - switch (item.type) { - case ActionType.XY: - case ActionType.Size: - case ActionType.Pivot: - case ActionType.Scale: - case ActionType.Skew: - value.b1 = true; - value.b2 = true; - value.f1 = parseFloat(args[0]); - value.f2 = parseFloat(args[1]); - break; - case ActionType.Alpha: - value.f1 = parseFloat(args[0]); - break; - case ActionType.Rotation: - value.f1 = parseFloat(args[0]); - break; - case ActionType.Color: - value.f1 = parseFloat(args[0]); - break; - case ActionType.Animation: - value.frame = parseInt(args[0]); - if (args.length > 1) - value.playing = args[1]; - break; - case ActionType.Visible: - value.visible = args[0]; - break; - case ActionType.Sound: - value.sound = args[0]; - if (args.length > 1) - value.volume = parseFloat(args[1]); - break; - case ActionType.Transition: - value.transName = args[0]; - if (args.length > 1) - value.playTimes = parseInt(args[1]); - break; - case ActionType.Shake: - value.amplitude = parseFloat(args[0]); - if (args.length > 1) - value.duration = parseFloat(args[1]); - break; - case ActionType.ColorFilter: - value.f1 = parseFloat(args[0]); - value.f2 = parseFloat(args[1]); - value.f3 = parseFloat(args[2]); - value.f4 = parseFloat(args[3]); - break; - case ActionType.Text: - case ActionType.Icon: - value.text = args[0]; - break; - } - } - }; - Transition.prototype.setHook = function (label, callback, caller) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.label == label) { - item.hook = callback; - item.hookCaller = caller; - break; - } - else if (item.tweenConfig && item.tweenConfig.endLabel == label) { - item.tweenConfig.endHook = callback; - item.tweenConfig.endHookCaller = caller; - break; - } - } - }; - Transition.prototype.clearHooks = function () { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - item.hook = null; - item.hookCaller = null; - if (item.tweenConfig) { - item.tweenConfig.endHook = null; - item.tweenConfig.endHookCaller = null; - } - } - }; - Transition.prototype.setTarget = function (label, newTarget) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.label == label) { - item.targetId = (newTarget == this._owner || !newTarget) ? "" : newTarget.id; - if (this._playing) { - if (item.targetId.length > 0) - item.target = this._owner.getChildById(item.targetId); - else - item.target = this._owner; - } - else - item.target = null; - } - } - }; - Transition.prototype.setDuration = function (label, value) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.tweenConfig && item.label == label) - item.tweenConfig.duration = value; - } - }; - Transition.prototype.getLabelTime = function (label) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.label == label) - return item.time; - else if (item.tweenConfig && item.tweenConfig.endLabel == label) - return item.time + item.tweenConfig.duration; - } - return Number.NaN; - }; - Object.defineProperty(Transition.prototype, "timeScale", { - get: function () { - return this._timeScale; - }, - set: function (value) { - if (this._timeScale != value) { - this._timeScale = value; - if (this._playing) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.tweener) - item.tweener.setTimeScale(value); - else if (item.type == ActionType.Transition) { - if (item.value.trans) - item.value.trans.timeScale = value; - } - else if (item.type == ActionType.Animation) { - if (item.target) - item.target.setProp(fgui.ObjectPropID.TimeScale, value); - } - } - } - } - }, - enumerable: true, - configurable: true - }); - Transition.prototype.updateFromRelations = function (targetId, dx, dy) { - var cnt = this._items.length; - if (cnt == 0) - return; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.type == ActionType.XY && item.targetId == targetId) { - if (item.tweenConfig) { - item.tweenConfig.startValue.f1 += dx; - item.tweenConfig.startValue.f2 += dy; - item.tweenConfig.endValue.f1 += dx; - item.tweenConfig.endValue.f2 += dy; - } - else { - item.value.f1 += dx; - item.value.f2 += dy; - } - } - } - }; - Transition.prototype.onOwnerAddedToStage = function () { - if (this._autoPlay && !this._playing) - this.play(null, null, null, this._autoPlayTimes, this._autoPlayDelay); - }; - Transition.prototype.onOwnerRemovedFromStage = function () { - if ((this._options & OPTION_AUTO_STOP_DISABLED) == 0) - this.stop((this._options & OPTION_AUTO_STOP_AT_END) != 0 ? true : false, false); - }; - Transition.prototype.onDelayedPlay = function () { - this.internalPlay(); - this._playing = this._totalTasks > 0; - if (this._playing) { - if ((this._options & OPTION_IGNORE_DISPLAY_CONTROLLER) != 0) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.target && item.target != this._owner) - item.displayLockToken = item.target.addDisplayLock(); - } - } - } - else if (this._onComplete != null) { - var func = this._onComplete; - var param = this._onCompleteParam; - var thisObj = this._onCompleteCaller; - this._onComplete = null; - this._onCompleteParam = null; - this._onCompleteCaller = null; - func.call(thisObj, param); - } - }; - Transition.prototype.internalPlay = function () { - this._ownerBaseX = this._owner.x; - this._ownerBaseY = this._owner.y; - this._totalTasks = 0; - var cnt = this._items.length; - var item; - var needSkipAnimations = false; - var i; - if (!this._reversed) { - for (i = 0; i < cnt; i++) { - item = this._items[i]; - if (!item.target) - continue; - if (item.type == ActionType.Animation && this._startTime != 0 && item.time <= this._startTime) { - needSkipAnimations = true; - item.value.flag = false; - } - else - this.playItem(item); - } - } - else { - for (i = cnt - 1; i >= 0; i--) { - item = this._items[i]; - if (!item.target) - continue; - this.playItem(item); - } - } - if (needSkipAnimations) - this.skipAnimations(); - }; - Transition.prototype.playItem = function (item) { - var time; - if (item.tweenConfig) { - if (this._reversed) - time = (this._totalDuration - item.time - item.tweenConfig.duration); - else - time = item.time; - if (this._endTime == -1 || time <= this._endTime) { - var startValue; - var endValue; - if (this._reversed) { - startValue = item.tweenConfig.endValue; - endValue = item.tweenConfig.startValue; - } - else { - startValue = item.tweenConfig.startValue; - endValue = item.tweenConfig.endValue; - } - item.value.b1 = startValue.b1 || endValue.b1; - item.value.b2 = startValue.b2 || endValue.b2; - switch (item.type) { - case ActionType.XY: - case ActionType.Size: - case ActionType.Scale: - case ActionType.Skew: - item.tweener = fgui.GTween.to2(startValue.f1, startValue.f2, endValue.f1, endValue.f2, item.tweenConfig.duration); - break; - case ActionType.Alpha: - case ActionType.Rotation: - item.tweener = fgui.GTween.to(startValue.f1, endValue.f1, item.tweenConfig.duration); - break; - case ActionType.Color: - item.tweener = fgui.GTween.toColor(startValue.f1, endValue.f1, item.tweenConfig.duration); - break; - case ActionType.ColorFilter: - item.tweener = fgui.GTween.to4(startValue.f1, startValue.f2, startValue.f3, startValue.f4, endValue.f1, endValue.f2, endValue.f3, endValue.f4, item.tweenConfig.duration); - break; - } - item.tweener.setDelay(time) - .setEase(item.tweenConfig.easeType) - .setRepeat(item.tweenConfig.repeat, item.tweenConfig.yoyo) - .setTimeScale(this._timeScale) - .setTarget(item) - .onStart(this.onTweenStart, this) - .onUpdate(this.onTweenUpdate, this) - .onComplete(this.onTweenComplete, this); - if (this._endTime >= 0) - item.tweener.setBreakpoint(this._endTime - time); - this._totalTasks++; - } - } - else if (item.type == ActionType.Shake) { - if (this._reversed) - time = (this._totalDuration - item.time - item.value.duration); - else - time = item.time; - item.value.offsetX = item.value.offsetY = 0; - item.value.lastOffsetX = item.value.lastOffsetY = 0; - item.tweener = fgui.GTween.shake(0, 0, item.value.amplitude, item.value.duration) - .setDelay(time) - .setTimeScale(this._timeScale) - .setTarget(item) - .onUpdate(this.onTweenUpdate, this) - .onComplete(this.onTweenComplete, this); - if (this._endTime >= 0) - item.tweener.setBreakpoint(this._endTime - item.time); - this._totalTasks++; - } - else { - if (this._reversed) - time = (this._totalDuration - item.time); - else - time = item.time; - if (time <= this._startTime) { - this.applyValue(item); - this.callHook(item, false); - } - else if (this._endTime == -1 || time <= this._endTime) { - this._totalTasks++; - item.tweener = fgui.GTween.delayedCall(time) - .setTimeScale(this._timeScale) - .setTarget(item) - .onComplete(this.onDelayedPlayItem, this); - } - } - if (item.tweener != null) - item.tweener.seek(this._startTime); - }; - Transition.prototype.skipAnimations = function () { - var frame; - var playStartTime; - var playTotalTime; - var value; - var target; - var item; - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - item = this._items[i]; - if (item.type != ActionType.Animation || item.time > this._startTime) - continue; - value = item.value; - if (value.flag) - continue; - target = item.target; - frame = target.getProp(fgui.ObjectPropID.Frame); - playStartTime = target.getProp(fgui.ObjectPropID.Playing) ? 0 : -1; - playTotalTime = 0; - for (var j = i; j < cnt; j++) { - item = this._items[j]; - if (item.type != ActionType.Animation || item.target != target || item.time > this._startTime) - continue; - value = item.value; - value.flag = true; - if (value.frame != -1) { - frame = value.frame; - if (value.playing) - playStartTime = item.time; - else - playStartTime = -1; - playTotalTime = 0; - } - else { - if (value.playing) { - if (playStartTime < 0) - playStartTime = item.time; - } - else { - if (playStartTime >= 0) - playTotalTime += (item.time - playStartTime); - playStartTime = -1; - } - } - this.callHook(item, false); - } - if (playStartTime >= 0) - playTotalTime += (this._startTime - playStartTime); - target.setProp(fgui.ObjectPropID.Playing, playStartTime >= 0); - target.setProp(fgui.ObjectPropID.Frame, frame); - if (playTotalTime > 0) - target.setProp(fgui.ObjectPropID.DeltaTime, playTotalTime * 1000); - } - }; - Transition.prototype.onDelayedPlayItem = function (tweener) { - var item = tweener.target; - item.tweener = null; - this._totalTasks--; - this.applyValue(item); - this.callHook(item, false); - this.checkAllComplete(); - }; - Transition.prototype.onTweenStart = function (tweener) { - var item = tweener.target; - if (item.type == ActionType.XY || item.type == ActionType.Size) { - var startValue; - var endValue; - if (this._reversed) { - startValue = item.tweenConfig.endValue; - endValue = item.tweenConfig.startValue; - } - else { - startValue = item.tweenConfig.startValue; - endValue = item.tweenConfig.endValue; - } - if (item.type == ActionType.XY) { - if (item.target != this._owner) { - if (!startValue.b1) - tweener.startValue.x = item.target.x; - else if (startValue.b3) - tweener.startValue.x = startValue.f1 * this._owner.width; - if (!startValue.b2) - tweener.startValue.y = item.target.y; - else if (startValue.b3) - tweener.startValue.y = startValue.f2 * this._owner.height; - if (!endValue.b1) - tweener.endValue.x = tweener.startValue.x; - else if (endValue.b3) - tweener.endValue.x = endValue.f1 * this._owner.width; - if (!endValue.b2) - tweener.endValue.y = tweener.startValue.y; - else if (endValue.b3) - tweener.endValue.y = endValue.f2 * this._owner.height; - } - else { - if (!startValue.b1) - tweener.startValue.x = item.target.x - this._ownerBaseX; - if (!startValue.b2) - tweener.startValue.y = item.target.y - this._ownerBaseY; - if (!endValue.b1) - tweener.endValue.x = tweener.startValue.x; - if (!endValue.b2) - tweener.endValue.y = tweener.startValue.y; - } - } - else { - if (!startValue.b1) - tweener.startValue.x = item.target.width; - if (!startValue.b2) - tweener.startValue.y = item.target.height; - if (!endValue.b1) - tweener.endValue.x = tweener.startValue.x; - if (!endValue.b2) - tweener.endValue.y = tweener.startValue.y; - } - if (item.tweenConfig.path) { - item.value.b1 = item.value.b2 = true; - tweener.setPath(item.tweenConfig.path); - } - } - this.callHook(item, false); - }; - Transition.prototype.onTweenUpdate = function (tweener) { - var item = tweener.target; - switch (item.type) { - case ActionType.XY: - case ActionType.Size: - case ActionType.Scale: - case ActionType.Skew: - item.value.f1 = tweener.value.x; - item.value.f2 = tweener.value.y; - if (item.tweenConfig.path) { - item.value.f1 += tweener.startValue.x; - item.value.f2 += tweener.startValue.y; - } - break; - case ActionType.Alpha: - case ActionType.Rotation: - item.value.f1 = tweener.value.x; - break; - case ActionType.Color: - item.value.f1 = tweener.value.color; - break; - case ActionType.ColorFilter: - item.value.f1 = tweener.value.x; - item.value.f2 = tweener.value.y; - item.value.f3 = tweener.value.z; - item.value.f4 = tweener.value.w; - break; - case ActionType.Shake: - item.value.offsetX = tweener.deltaValue.x; - item.value.offsetY = tweener.deltaValue.y; - break; - } - this.applyValue(item); - }; - Transition.prototype.onTweenComplete = function (tweener) { - var item = tweener.target; - item.tweener = null; - this._totalTasks--; - if (tweener.allCompleted) - this.callHook(item, true); - this.checkAllComplete(); - }; - Transition.prototype.onPlayTransCompleted = function (item) { - this._totalTasks--; - this.checkAllComplete(); - }; - Transition.prototype.callHook = function (item, tweenEnd) { - if (tweenEnd) { - if (item.tweenConfig && item.tweenConfig.endHook) - item.tweenConfig.endHook.call(item.tweenConfig.endHookCaller); - } - else { - if (item.time >= this._startTime && item.hook != null) - item.hook.call(item.hookCaller); - } - }; - Transition.prototype.checkAllComplete = function () { - if (this._playing && this._totalTasks == 0) { - if (this._totalTimes < 0) { - this.internalPlay(); - } - else { - this._totalTimes--; - if (this._totalTimes > 0) - this.internalPlay(); - else { - this._playing = false; - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.target && item.displayLockToken != 0) { - item.target.releaseDisplayLock(item.displayLockToken); - item.displayLockToken = 0; - } - } - if (this._onComplete != null) { - var func = this._onComplete; - var param = this._onCompleteParam; - var thisObj = this._onCompleteCaller; - this._onComplete = null; - this._onCompleteParam = null; - this._onCompleteCaller = null; - func.call(thisObj, param); - } - } - } - } - }; - Transition.prototype.applyValue = function (item) { - item.target._gearLocked = true; - var value = item.value; - switch (item.type) { - case ActionType.XY: - if (item.target == this._owner) { - if (value.b1 && value.b2) - item.target.setXY(value.f1 + this._ownerBaseX, value.f2 + this._ownerBaseY); - else if (value.b1) - item.target.x = value.f1 + this._ownerBaseX; - else - item.target.y = value.f2 + this._ownerBaseY; - } - else { - if (value.b3) { - if (value.b1 && value.b2) - item.target.setXY(value.f1 * this._owner.width, value.f2 * this._owner.height); - else if (value.b1) - item.target.x = value.f1 * this._owner.width; - else if (value.b2) - item.target.y = value.f2 * this._owner.height; - } - else { - if (value.b1 && value.b2) - item.target.setXY(value.f1, value.f2); - else if (value.b1) - item.target.x = value.f1; - else if (value.b2) - item.target.y = value.f2; - } - } - break; - case ActionType.Size: - if (!value.b1) - value.f1 = item.target.width; - if (!value.b2) - value.f2 = item.target.height; - item.target.setSize(value.f1, value.f2); - break; - case ActionType.Pivot: - item.target.setPivot(value.f1, value.f2, item.target.pivotAsAnchor); - break; - case ActionType.Alpha: - item.target.alpha = value.f1; - break; - case ActionType.Rotation: - item.target.rotation = value.f1; - break; - case ActionType.Scale: - item.target.setScale(value.f1, value.f2); - break; - case ActionType.Skew: - item.target.setSkew(value.f1, value.f2); - break; - case ActionType.Color: - item.target.setProp(fgui.ObjectPropID.Color, value.f1); - break; - case ActionType.Animation: - if (value.frame >= 0) - item.target.setProp(fgui.ObjectPropID.Frame, value.frame); - item.target.setProp(fgui.ObjectPropID.Playing, value.playing); - item.target.setProp(fgui.ObjectPropID.TimeScale, this._timeScale); - break; - case ActionType.Visible: - item.target.visible = value.visible; - break; - case ActionType.Transition: - if (this._playing) { - var trans = value.trans; - if (trans) { - this._totalTasks++; - var startTime = this._startTime > item.time ? (this._startTime - item.time) : 0; - var endTime = this._endTime >= 0 ? (this._endTime - item.time) : -1; - if (value.stopTime >= 0 && (endTime < 0 || endTime > value.stopTime)) - endTime = value.stopTime; - trans.timeScale = this._timeScale; - trans._play(this.onPlayTransCompleted, this, item, value.playTimes, 0, startTime, endTime, this._reversed); - } - } - break; - case ActionType.Sound: - if (this._playing && item.time >= this._startTime) { - if (!value.audioClip) { - var pi = fgui.UIPackage.getItemByURL(value.sound); - if (pi) - value.audioClip = pi.owner.getItemAsset(pi); - } - if (value.audioClip) - fgui.GRoot.inst.playOneShotSound(value.audioClip, value.volume); - } - break; - case ActionType.Shake: - item.target.setXY(item.target.x - value.lastOffsetX + value.offsetX, item.target.y - value.lastOffsetY + value.offsetY); - value.lastOffsetX = value.offsetX; - value.lastOffsetY = value.offsetY; - break; - case ActionType.ColorFilter: - { - fgui.ToolSet.setColorFilter(item.target.displayObject, [value.f1, value.f2, value.f3, value.f4]); - break; - } - case ActionType.Text: - item.target.text = value.text; - break; - case ActionType.Icon: - item.target.icon = value.text; - break; - } - item.target._gearLocked = false; - }; - Transition.prototype.setup = function (buffer) { - this.name = buffer.readS(); - this._options = buffer.readInt(); - this._autoPlay = buffer.readBool(); - this._autoPlayTimes = buffer.readInt(); - this._autoPlayDelay = buffer.readFloat(); - var cnt = buffer.readShort(); - for (var i = 0; i < cnt; i++) { - var dataLen = buffer.readShort(); - var curPos = buffer.position; - buffer.seek(curPos, 0); - var item = new Item(buffer.readByte()); - this._items[i] = item; - item.time = buffer.readFloat(); - var targetId = buffer.readShort(); - if (targetId < 0) - item.targetId = ""; - else - item.targetId = this._owner.getChildAt(targetId).id; - item.label = buffer.readS(); - if (buffer.readBool()) { - buffer.seek(curPos, 1); - item.tweenConfig = new TweenConfig(); - item.tweenConfig.duration = buffer.readFloat(); - if (item.time + item.tweenConfig.duration > this._totalDuration) - this._totalDuration = item.time + item.tweenConfig.duration; - item.tweenConfig.easeType = buffer.readByte(); - item.tweenConfig.repeat = buffer.readInt(); - item.tweenConfig.yoyo = buffer.readBool(); - item.tweenConfig.endLabel = buffer.readS(); - buffer.seek(curPos, 2); - this.decodeValue(item, buffer, item.tweenConfig.startValue); - buffer.seek(curPos, 3); - this.decodeValue(item, buffer, item.tweenConfig.endValue); - if (buffer.version >= 2) { - var pathLen = buffer.readInt(); - if (pathLen > 0) { - item.tweenConfig.path = new fgui.GPath(); - var pts = new Array(); - for (var j = 0; j < pathLen; j++) { - var curveType = buffer.readByte(); - switch (curveType) { - case fgui.CurveType.Bezier: - pts.push(fgui.GPathPoint.newBezierPoint(buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat())); - break; - case fgui.CurveType.CubicBezier: - pts.push(fgui.GPathPoint.newCubicBezierPoint(buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat())); - break; - default: - pts.push(fgui.GPathPoint.newPoint(buffer.readFloat(), buffer.readFloat(), curveType)); - break; - } - } - item.tweenConfig.path.create(pts); - } - } - } - else { - if (item.time > this._totalDuration) - this._totalDuration = item.time; - buffer.seek(curPos, 2); - this.decodeValue(item, buffer, item.value); - } - buffer.position = curPos + dataLen; - } - }; - Transition.prototype.decodeValue = function (item, buffer, value) { - switch (item.type) { - case ActionType.XY: - case ActionType.Size: - case ActionType.Pivot: - case ActionType.Skew: - value.b1 = buffer.readBool(); - value.b2 = buffer.readBool(); - value.f1 = buffer.readFloat(); - value.f2 = buffer.readFloat(); - if (buffer.version >= 2 && item.type == ActionType.XY) - value.b3 = buffer.readBool(); - break; - case ActionType.Alpha: - case ActionType.Rotation: - value.f1 = buffer.readFloat(); - break; - case ActionType.Scale: - value.f1 = buffer.readFloat(); - value.f2 = buffer.readFloat(); - break; - case ActionType.Color: - value.f1 = buffer.readColor(); - break; - case ActionType.Animation: - value.playing = buffer.readBool(); - value.frame = buffer.readInt(); - break; - case ActionType.Visible: - value.visible = buffer.readBool(); - break; - case ActionType.Sound: - value.sound = buffer.readS(); - value.volume = buffer.readFloat(); - break; - case ActionType.Transition: - value.transName = buffer.readS(); - value.playTimes = buffer.readInt(); - break; - case ActionType.Shake: - value.amplitude = buffer.readFloat(); - value.duration = buffer.readFloat(); - break; - case ActionType.ColorFilter: - value.f1 = buffer.readFloat(); - value.f2 = buffer.readFloat(); - value.f3 = buffer.readFloat(); - value.f4 = buffer.readFloat(); - break; - case ActionType.Text: - case ActionType.Icon: - value.text = buffer.readS(); - break; - } - }; - return Transition; - }()); - fgui.Transition = Transition; - var OPTION_IGNORE_DISPLAY_CONTROLLER = 1; - var OPTION_AUTO_STOP_DISABLED = 2; - var OPTION_AUTO_STOP_AT_END = 4; - var ActionType = (function () { - function ActionType() { - } - ActionType.XY = 0; - ActionType.Size = 1; - ActionType.Scale = 2; - ActionType.Pivot = 3; - ActionType.Alpha = 4; - ActionType.Rotation = 5; - ActionType.Color = 6; - ActionType.Animation = 7; - ActionType.Visible = 8; - ActionType.Sound = 9; - ActionType.Transition = 10; - ActionType.Shake = 11; - ActionType.ColorFilter = 12; - ActionType.Skew = 13; - ActionType.Text = 14; - ActionType.Icon = 15; - ActionType.Unknown = 16; - return ActionType; - }()); - var Item = (function () { - function Item(type) { - this.type = type; - this.value = {}; - this.displayLockToken = 0; - } - return Item; - }()); - var TweenConfig = (function () { - function TweenConfig() { - this.duration = 0; - this.repeat = 0; - this.easeType = fgui.EaseType.QuadOut; - this.startValue = { b1: true, b2: true }; - this.endValue = { b1: true, b2: true }; - } - return TweenConfig; - }()); -})(fgui || (fgui = {})); - -(function (fgui) { - var TranslationHelper = (function () { - function TranslationHelper() { - } - TranslationHelper.loadFromXML = function (source) { - var strings = {}; - TranslationHelper.strings = strings; - var xml = egret.XML.parse(source); - var nodes = xml.children; - var length1 = nodes.length; - for (var i1 = 0; i1 < length1; i1++) { - var cxml = nodes[i1]; - if (cxml.name == "string") { - var key = cxml.attributes.name; - var text = cxml.children.length > 0 ? cxml.children[0].text : ""; - var i = key.indexOf("-"); - if (i == -1) - continue; - var key2 = key.substr(0, i); - var key3 = key.substr(i + 1); - var col = strings[key2]; - if (!col) { - col = {}; - strings[key2] = col; - } - col[key3] = text; - } - } - }; - TranslationHelper.translateComponent = function (item) { - if (TranslationHelper.strings == null) - return; - var compStrings = TranslationHelper.strings[item.owner.id + item.id]; - if (compStrings == null) - return; - var elementId, value; - var buffer = item.rawData; - var nextPos; - var itemCount; - var i, j, k; - var dataLen; - var curPos; - var valueCnt; - var page; - buffer.seek(0, 2); - var childCount = buffer.readShort(); - for (i = 0; i < childCount; i++) { - dataLen = buffer.readShort(); - curPos = buffer.position; - buffer.seek(curPos, 0); - var baseType = buffer.readByte(); - var type = baseType; - buffer.skip(4); - elementId = buffer.readS(); - if (type == fgui.ObjectType.Component) { - if (buffer.seek(curPos, 6)) - type = buffer.readByte(); - } - buffer.seek(curPos, 1); - if ((value = compStrings[elementId + "-tips"]) != null) - buffer.writeS(value); - buffer.seek(curPos, 2); - var gearCnt = buffer.readShort(); - for (j = 0; j < gearCnt; j++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - if (buffer.readByte() == 6) { - buffer.skip(2); - valueCnt = buffer.readShort(); - for (k = 0; k < valueCnt; k++) { - page = buffer.readS(); - if (page != null) { - if ((value = compStrings[elementId + "-texts_" + k]) != null) - buffer.writeS(value); - else - buffer.skip(2); - } - } - if (buffer.readBool() && (value = compStrings[elementId + "-texts_def"]) != null) - buffer.writeS(value); - } - if (baseType == fgui.ObjectType.Component && buffer.version >= 2) { - buffer.seek(curPos, 4); - buffer.skip(2); - buffer.skip(4 * buffer.readShort()); - var cpCount = buffer.readShort(); - for (var k = 0; k < cpCount; k++) { - var target = buffer.readS(); - var propertyId = buffer.readShort(); - if (propertyId == 0 && (value = compStrings[elementId + "-cp-" + target]) != null) - buffer.writeS(value); - else - buffer.skip(2); - } - } - buffer.position = nextPos; - } - switch (type) { - case fgui.ObjectType.Text: - case fgui.ObjectType.RichText: - case fgui.ObjectType.InputText: - { - if ((value = compStrings[elementId]) != null) { - buffer.seek(curPos, 6); - buffer.writeS(value); - } - if ((value = compStrings[elementId + "-prompt"]) != null) { - buffer.seek(curPos, 4); - buffer.writeS(value); - } - break; - } - case fgui.ObjectType.List: - case fgui.ObjectType.Tree: - { - buffer.seek(curPos, 8); - buffer.skip(2); - itemCount = buffer.readShort(); - for (j = 0; j < itemCount; j++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - buffer.skip(2); - if (type == fgui.ObjectType.Tree) - buffer.skip(2); - if ((value = compStrings[elementId + "-" + j]) != null) - buffer.writeS(value); - else - buffer.skip(2); - if ((value = compStrings[elementId + "-" + j + "-0"]) != null) - buffer.writeS(value); - else - buffer.skip(2); - if (buffer.version >= 2) { - buffer.skip(6); - buffer.skip(buffer.readUnsignedShort() * 4); - var cpCount = buffer.readUnsignedShort(); - for (var k = 0; k < cpCount; k++) { - var target = buffer.readS(); - var propertyId = buffer.readUnsignedShort(); - if (propertyId == 0 && (value = compStrings[elementId + "-" + j + "-" + target]) != null) - buffer.writeS(value); - else - buffer.skip(2); - } - } - buffer.position = nextPos; - } - break; - } - case fgui.ObjectType.Label: - { - if (buffer.seek(curPos, 6) && buffer.readByte() == type) { - if ((value = compStrings[elementId]) != null) - buffer.writeS(value); - else - buffer.skip(2); - buffer.skip(2); - if (buffer.readBool()) - buffer.skip(4); - buffer.skip(4); - if (buffer.readBool() && (value = compStrings[elementId + "-prompt"]) != null) - buffer.writeS(value); - } - break; - } - case fgui.ObjectType.Button: - { - if (buffer.seek(curPos, 6) && buffer.readByte() == type) { - if ((value = compStrings[elementId]) != null) - buffer.writeS(value); - else - buffer.skip(2); - if ((value = compStrings[elementId + "-0"]) != null) - buffer.writeS(value); - } - break; - } - case fgui.ObjectType.ComboBox: - { - if (buffer.seek(curPos, 6) && buffer.readByte() == type) { - itemCount = buffer.readShort(); - for (j = 0; j < itemCount; j++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - if ((value = compStrings[elementId + "-" + j]) != null) - buffer.writeS(value); - buffer.position = nextPos; - } - if ((value = compStrings[elementId]) != null) - buffer.writeS(value); - } - break; - } - } - buffer.position = curPos + dataLen; - } - }; - return TranslationHelper; - }()); - fgui.TranslationHelper = TranslationHelper; -})(fgui || (fgui = {})); - -(function (fgui) { - var UIConfig = (function () { - function UIConfig() { - } - UIConfig.defaultFont = "SimSun"; - UIConfig.modalLayerColor = 0x333333; - UIConfig.modalLayerAlpha = 0.2; - UIConfig.buttonSoundVolumeScale = 1; - UIConfig.defaultScrollStep = 25; - UIConfig.defaultScrollDecelerationRate = 0.967; - UIConfig.defaultScrollBarDisplay = fgui.ScrollBarDisplayType.Visible; - UIConfig.defaultScrollTouchEffect = true; - UIConfig.defaultScrollBounceEffect = true; - UIConfig.defaultComboBoxVisibleItemCount = 10; - UIConfig.touchScrollSensitivity = 20; - UIConfig.touchDragSensitivity = 10; - UIConfig.clickDragSensitivity = 2; - UIConfig.bringWindowToFrontOnClick = true; - UIConfig.frameTimeForAsyncUIConstruction = 2; - return UIConfig; - }()); - fgui.UIConfig = UIConfig; -})(fgui || (fgui = {})); - -(function (fgui) { - var UIObjectFactory = (function () { - function UIObjectFactory() { - } - UIObjectFactory.setExtension = function (url, type) { - if (url == null) - throw "Invaild url: " + url; - var pi = fgui.UIPackage.getItemByURL(url); - if (pi) - pi.extensionType = type; - UIObjectFactory.extensions[url] = type; - }; - UIObjectFactory.setPackageItemExtension = function (url, type) { - UIObjectFactory.setExtension(url, type); - }; - UIObjectFactory.setLoaderExtension = function (type) { - UIObjectFactory.loaderType = type; - }; - UIObjectFactory.resolvePackageItemExtension = function (pi) { - var extensionType = UIObjectFactory.extensions["ui://" + pi.owner.id + pi.id]; - if (!extensionType) - extensionType = UIObjectFactory.extensions["ui://" + pi.owner.name + "/" + pi.name]; - if (extensionType) - pi.extensionType = extensionType; - }; - UIObjectFactory.newObject = function (type, userClass) { - var obj; - if (typeof type === 'number') { - switch (type) { - case fgui.ObjectType.Image: - return new fgui.GImage(); - case fgui.ObjectType.MovieClip: - return new fgui.GMovieClip(); - case fgui.ObjectType.Component: - return new fgui.GComponent(); - case fgui.ObjectType.Text: - return new fgui.GTextField(); - case fgui.ObjectType.RichText: - return new fgui.GRichTextField(); - case fgui.ObjectType.InputText: - return new fgui.GTextInput(); - case fgui.ObjectType.Group: - return new fgui.GGroup(); - case fgui.ObjectType.List: - return new fgui.GList(); - case fgui.ObjectType.Graph: - return new fgui.GGraph(); - case fgui.ObjectType.Loader: - if (UIObjectFactory.loaderType) - return new UIObjectFactory.loaderType(); - else - return new fgui.GLoader(); - case fgui.ObjectType.Button: - return new fgui.GButton(); - case fgui.ObjectType.Label: - return new fgui.GLabel(); - case fgui.ObjectType.ProgressBar: - return new fgui.GProgressBar(); - case fgui.ObjectType.Slider: - return new fgui.GSlider(); - case fgui.ObjectType.ScrollBar: - return new fgui.GScrollBar(); - case fgui.ObjectType.ComboBox: - return new fgui.GComboBox(); - case fgui.ObjectType.Tree: - return new fgui.GTree(); - case fgui.ObjectType.Loader3D: - return new fgui.GLoader3D(); - default: - return null; - } - } - else { - if (type.type == fgui.PackageItemType.Component) { - if (userClass) - obj = new userClass(); - else if (type.extensionType) - obj = new type.extensionType(); - else - obj = UIObjectFactory.newObject(type.objectType); - } - else - obj = UIObjectFactory.newObject(type.objectType); - if (obj) - obj.packageItem = type; - } - return obj; - }; - UIObjectFactory.extensions = {}; - return UIObjectFactory; - }()); - fgui.UIObjectFactory = UIObjectFactory; -})(fgui || (fgui = {})); - -(function (fgui) { - var UIPackage = (function () { - function UIPackage() { - this._items = []; - this._itemsById = {}; - this._itemsByName = {}; - this._sprites = {}; - this._dependencies = []; - this._branches = []; - this._branchIndex = -1; - } - Object.defineProperty(UIPackage, "branch", { - get: function () { - return UIPackage._branch; - }, - set: function (value) { - UIPackage._branch = value; - for (var pkgId in UIPackage._instById) { - var pkg = UIPackage._instById[pkgId]; - if (pkg._branches) { - pkg._branchIndex = pkg._branches.indexOf(value); - } - } - }, - enumerable: true, - configurable: true - }); - UIPackage.getVar = function (key) { - return UIPackage._vars[key]; - }; - UIPackage.setVar = function (key, value) { - UIPackage._vars[key] = value; - }; - UIPackage.getById = function (id) { - return UIPackage._instById[id]; - }; - UIPackage.getByName = function (name) { - return UIPackage._instByName[name]; - }; - UIPackage.loadPackage = function (resKey) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () { - var pkg, asset, cnt, tasks, i, pi; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - pkg = UIPackage._instById[resKey]; - if (pkg) { - resolve(pkg); - return [2]; - } - return [4, RES.getResAsync(getAssetResKey(resKey, "fui"))]; - case 1: - asset = _a.sent(); - pkg = new UIPackage(); - pkg._resKey = resKey; - pkg.loadPackage(new fgui.ByteBuffer(asset)); - cnt = pkg._items.length; - tasks = []; - for (i = 0; i < cnt; i++) { - pi = pkg._items[i]; - if (pi.type == fgui.PackageItemType.Atlas || pi.type == fgui.PackageItemType.Sound) { - tasks.push(RES.getResAsync(pi.file)); - } - } - if (!(tasks.length > 0)) return [3, 3]; - return [4, Promise.all(tasks)]; - case 2: - _a.sent(); - _a.label = 3; - case 3: - UIPackage._instById[pkg.id] = pkg; - UIPackage._instByName[pkg.name] = pkg; - UIPackage._instById[pkg._resKey] = pkg; - resolve(pkg); - return [2]; - } - }); - }); })]; - }); - }); - }; - UIPackage.addPackage = function (resKey, descData) { - if (!descData) { - descData = RES.getRes(resKey); - if (!descData) - throw "Resource '" + resKey + "' not found, please check default.res.json!"; - } - var pkg = new UIPackage(); - pkg._resKey = resKey; - pkg.loadPackage(new fgui.ByteBuffer(descData)); - UIPackage._instById[pkg.id] = pkg; - UIPackage._instByName[pkg.name] = pkg; - UIPackage._instById[resKey] = pkg; - return pkg; - }; - UIPackage.removePackage = function (packageIdOrName) { - var pkg = UIPackage._instById[packageIdOrName]; - if (!pkg) - pkg = UIPackage._instByName[packageIdOrName]; - if (!pkg) - throw new Error("unknown package: " + packageIdOrName); - pkg.dispose(); - delete UIPackage._instById[pkg.id]; - delete UIPackage._instByName[pkg.name]; - delete UIPackage._instById[pkg._resKey]; - if (pkg._customId != null) - delete UIPackage._instById[pkg._customId]; - }; - UIPackage.createObject = function (pkgName, resName, userClass) { - var pkg = UIPackage.getByName(pkgName); - if (pkg) - return pkg.createObject(resName, userClass); - else - return null; - }; - UIPackage.createObjectFromURL = function (url, userClass) { - var pi = UIPackage.getItemByURL(url); - if (pi) - return pi.owner.internalCreateObject(pi, userClass); - else - return null; - }; - UIPackage.getItemURL = function (pkgName, resName) { - var pkg = UIPackage.getByName(pkgName); - if (!pkg) - return null; - var pi = pkg._itemsByName[resName]; - if (!pi) - return null; - return "ui://" + pkg.id + pi.id; - }; - UIPackage.getItemByURL = function (url) { - var pos1 = url.indexOf("//"); - if (pos1 == -1) - return null; - var pos2 = url.indexOf("/", pos1 + 2); - if (pos2 == -1) { - if (url.length > 13) { - var pkgId = url.substr(5, 8); - var pkg = UIPackage.getById(pkgId); - if (pkg != null) { - var srcId = url.substr(13); - return pkg.getItemById(srcId); - } - } - } - else { - var pkgName = url.substr(pos1 + 2, pos2 - pos1 - 2); - pkg = UIPackage.getByName(pkgName); - if (pkg != null) { - var srcName = url.substr(pos2 + 1); - return pkg.getItemByName(srcName); - } - } - return null; - }; - UIPackage.normalizeURL = function (url) { - if (url == null) - return null; - var pos1 = url.indexOf("//"); - if (pos1 == -1) - return null; - var pos2 = url.indexOf("/", pos1 + 2); - if (pos2 == -1) - return url; - var pkgName = url.substr(pos1 + 2, pos2 - pos1 - 2); - var srcName = url.substr(pos2 + 1); - return UIPackage.getItemURL(pkgName, srcName); - }; - UIPackage.setStringsSource = function (source) { - fgui.TranslationHelper.loadFromXML(source); - }; - UIPackage.prototype.loadPackage = function (buffer) { - if (buffer.readUnsignedInt() != 0x46475549) - throw "FairyGUI: old package format found in '" + this._resKey + "'"; - buffer.version = buffer.readInt(); - var compressed = buffer.readBool(); - this._id = buffer.readUTF(); - this._name = buffer.readUTF(); - buffer.skip(20); - if (compressed) { - var buf = new Uint8Array(buffer.buffer, buffer.position, buffer.length - buffer.position); - var inflater = new Zlib.RawInflate(buf); - var buffer2 = new fgui.ByteBuffer(inflater.decompress()); - buffer2.version = buffer.version; - buffer = buffer2; - } - var ver2 = buffer.version >= 2; - var indexTablePos = buffer.position; - var cnt; - var i; - var nextPos; - var str; - var branchIncluded; - buffer.seek(indexTablePos, 4); - cnt = buffer.readInt(); - var stringTable = new Array(cnt); - stringTable.reduceRight; - for (i = 0; i < cnt; i++) - stringTable[i] = buffer.readUTF(); - buffer.stringTable = stringTable; - buffer.seek(indexTablePos, 0); - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) - this._dependencies.push({ id: buffer.readS(), name: buffer.readS() }); - if (ver2) { - cnt = buffer.readShort(); - if (cnt > 0) { - this._branches = buffer.readSArray(cnt); - if (UIPackage._branch) - this._branchIndex = this._branches.indexOf(UIPackage._branch); - } - branchIncluded = cnt > 0; - } - buffer.seek(indexTablePos, 1); - var pi; - var path = this._resKey; - var pos = path.lastIndexOf('/'); - var shortPath = pos == -1 ? "" : path.substr(0, pos + 1); - path = path + "_"; - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readInt(); - nextPos += buffer.position; - pi = new fgui.PackageItem(); - pi.owner = this; - pi.type = buffer.readByte(); - pi.id = buffer.readS(); - pi.name = buffer.readS(); - buffer.readS(); - pi.file = buffer.readS(); - buffer.readBool(); - pi.width = buffer.readInt(); - pi.height = buffer.readInt(); - switch (pi.type) { - case fgui.PackageItemType.Image: - { - pi.objectType = fgui.ObjectType.Image; - var scaleOption = buffer.readByte(); - if (scaleOption == 1) { - pi.scale9Grid = new egret.Rectangle(); - pi.scale9Grid.x = buffer.readInt(); - pi.scale9Grid.y = buffer.readInt(); - pi.scale9Grid.width = buffer.readInt(); - pi.scale9Grid.height = buffer.readInt(); - pi.tileGridIndice = buffer.readInt(); - } - else if (scaleOption == 2) - pi.scaleByTile = true; - pi.smoothing = buffer.readBool(); - break; - } - case fgui.PackageItemType.MovieClip: - { - pi.smoothing = buffer.readBool(); - pi.objectType = fgui.ObjectType.MovieClip; - pi.rawData = buffer.readBuffer(); - break; - } - case fgui.PackageItemType.Font: - { - pi.rawData = buffer.readBuffer(); - break; - } - case fgui.PackageItemType.Component: - { - var extension = buffer.readByte(); - if (extension > 0) - pi.objectType = extension; - else - pi.objectType = fgui.ObjectType.Component; - pi.rawData = buffer.readBuffer(); - fgui.UIObjectFactory.resolvePackageItemExtension(pi); - break; - } - case fgui.PackageItemType.Atlas: - case fgui.PackageItemType.Sound: - case fgui.PackageItemType.Misc: - { - var pos_1 = pi.file.lastIndexOf("."); - pi.file = path + (pos_1 == -1 ? pi.file : getAssetResKey(pi.file.substring(0, pos_1), pi.file.substring(pos_1 + 1))); - break; - } - case fgui.PackageItemType.Spine: - case fgui.PackageItemType.DragonBones: - { - var pos_2 = pi.file.lastIndexOf("."); - pi.file = shortPath + (pos_2 == -1 ? pi.file : pi.file.substring(0, pos_2)); - pi.skeletonAnchor = new egret.Point(); - pi.skeletonAnchor.x = buffer.readFloat(); - pi.skeletonAnchor.y = buffer.readFloat(); - break; - } - } - if (ver2) { - str = buffer.readS(); - if (str) - pi.name = str + "/" + pi.name; - var branchCnt = buffer.readUnsignedByte(); - if (branchCnt > 0) { - if (branchIncluded) - pi.branches = buffer.readSArray(branchCnt); - else - this._itemsById[buffer.readS()] = pi; - } - var highResCnt = buffer.readUnsignedByte(); - if (highResCnt > 0) - pi.highResolution = buffer.readSArray(highResCnt); - } - this._items.push(pi); - this._itemsById[pi.id] = pi; - if (pi.name != null) - this._itemsByName[pi.name] = pi; - buffer.position = nextPos; - } - buffer.seek(indexTablePos, 2); - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - var itemId = buffer.readS(); - pi = this._itemsById[buffer.readS()]; - var sprite = { atlas: pi, rect: new egret.Rectangle(), offset: new egret.Point(), originalSize: new egret.Point() }; - sprite.rect.x = buffer.readInt(); - sprite.rect.y = buffer.readInt(); - sprite.rect.width = buffer.readInt(); - sprite.rect.height = buffer.readInt(); - sprite.rotated = buffer.readBool(); - if (ver2 && buffer.readBool()) { - sprite.offset.x = buffer.readInt(); - sprite.offset.y = buffer.readInt(); - sprite.originalSize.x = buffer.readInt(); - sprite.originalSize.y = buffer.readInt(); - } - else { - sprite.originalSize.x = sprite.rect.width; - sprite.originalSize.y = sprite.rect.height; - } - this._sprites[itemId] = sprite; - buffer.position = nextPos; - } - if (buffer.seek(indexTablePos, 3)) { - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readInt(); - nextPos += buffer.position; - pi = this._itemsById[buffer.readS()]; - if (pi && pi.type == fgui.PackageItemType.Image) { - pi.pixelHitTestData = new fgui.PixelHitTestData(); - pi.pixelHitTestData.load(buffer); - } - buffer.position = nextPos; - } - } - }; - UIPackage.prototype.dispose = function () { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var pi = this._items[i]; - if (pi.type == fgui.PackageItemType.Atlas) { - RES.destroyRes(pi.file, false); - } - else if (pi.type == fgui.PackageItemType.Sound) { - } - } - }; - Object.defineProperty(UIPackage.prototype, "id", { - get: function () { - return this._id; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIPackage.prototype, "name", { - get: function () { - return this._name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIPackage.prototype, "customId", { - get: function () { - return this._customId; - }, - set: function (value) { - if (this._customId != null) - delete UIPackage._instById[this._customId]; - this._customId = value; - if (this._customId != null) - UIPackage._instById[this._customId] = this; - }, - enumerable: true, - configurable: true - }); - UIPackage.prototype.createObject = function (resName, userClass) { - var pi = this._itemsByName[resName]; - if (pi) - return this.internalCreateObject(pi, userClass); - else - return null; - }; - UIPackage.prototype.internalCreateObject = function (item, userClass) { - var g = fgui.UIObjectFactory.newObject(item, userClass); - if (g == null) - return null; - UIPackage._constructing++; - g.constructFromResource(); - UIPackage._constructing--; - return g; - }; - UIPackage.prototype.getItemById = function (itemId) { - return this._itemsById[itemId]; - }; - UIPackage.prototype.getItemByName = function (resName) { - return this._itemsByName[resName]; - }; - UIPackage.prototype.getItemAssetByName = function (resName) { - var pi = this._itemsByName[resName]; - if (pi == null) { - throw "Resource not found -" + resName; - } - return this.getItemAsset(pi); - }; - UIPackage.prototype.getItemAsset = function (item) { - switch (item.type) { - case fgui.PackageItemType.Image: - if (!item.decoded) { - item.decoded = true; - var sprite = this._sprites[item.id]; - if (sprite) { - var atlas = this.getItemAsset(sprite.atlas); - item.asset = new egret.Texture(); - item.asset.bitmapData = atlas.bitmapData; - item.asset.$initData(atlas.$bitmapX + sprite.rect.x, atlas.$bitmapY + sprite.rect.y, sprite.rect.width, sprite.rect.height, sprite.offset.x, sprite.offset.y, sprite.originalSize.x, sprite.originalSize.y, atlas.$sourceWidth, atlas.$sourceHeight, sprite.rotated); - } - } - return item.asset; - case fgui.PackageItemType.Atlas: - case fgui.PackageItemType.Sound: - if (!item.decoded) { - item.decoded = true; - item.asset = RES.getRes(item.file); - if (!item.asset) - console.log("Resource '" + item.file + "' not found, please check default.res.json!"); - } - return item.asset; - case fgui.PackageItemType.Font: - if (!item.decoded) { - item.decoded = true; - this.loadFont(item); - } - return item.bitmapFont; - case fgui.PackageItemType.MovieClip: - if (!item.decoded) { - item.decoded = true; - this.loadMovieClip(item); - } - return item.frames; - case fgui.PackageItemType.Misc: - if (item.file) - return RES.getRes(item.file); - else - return null; - default: - return null; - } - }; - UIPackage.prototype.getItemAssetAsync = function (item, onComplete) { - if (item.decoded) { - onComplete(null, item); - return; - } - if (item.loading) { - item.loading.push(onComplete); - return; - } - switch (item.type) { - case fgui.PackageItemType.DragonBones: - item.loading = [onComplete]; - this.loadDragonBones(item); - break; - default: - this.getItemAsset(item); - onComplete(null, item); - break; - } - }; - UIPackage.prototype.loadMovieClip = function (item) { - var buffer = item.rawData; - buffer.seek(0, 0); - item.interval = buffer.readInt(); - item.swing = buffer.readBool(); - item.repeatDelay = buffer.readInt(); - buffer.seek(0, 1); - var frameCount = buffer.readShort(); - item.frames = Array(frameCount); - var spriteId; - var sprite; - var fx; - var fy; - for (var i = 0; i < frameCount; i++) { - var nextPos = buffer.readShort(); - nextPos += buffer.position; - var frame = {}; - fx = buffer.readInt(); - fy = buffer.readInt(); - buffer.readInt(); - buffer.readInt(); - frame.addDelay = buffer.readInt(); - spriteId = buffer.readS(); - if (spriteId != null && (sprite = this._sprites[spriteId]) != null) { - var atlas = this.getItemAsset(sprite.atlas); - frame.texture = new egret.Texture(); - frame.texture.bitmapData = atlas.bitmapData; - frame.texture.$initData(atlas.$bitmapX + sprite.rect.x, atlas.$bitmapY + sprite.rect.y, sprite.rect.width, sprite.rect.height, fx, fy, item.width, item.height, atlas.$sourceWidth, atlas.$sourceHeight, sprite.rotated); - } - item.frames[i] = frame; - buffer.position = nextPos; - } - }; - UIPackage.prototype.loadFont = function (item) { - var font = new fgui.BitmapFont(); - item.bitmapFont = font; - var buffer = item.rawData; - buffer.seek(0, 0); - font.ttf = buffer.readBool(); - font.tint = buffer.readBool(); - font.resizable = buffer.readBool(); - buffer.readBool(); - font.size = buffer.readInt(); - var xadvance = buffer.readInt(); - var lineHeight = buffer.readInt(); - var mainTexture; - var mainSprite = this._sprites[item.id]; - if (mainSprite) - mainTexture = (this.getItemAsset(mainSprite.atlas)); - buffer.seek(0, 1); - var bg; - var cnt = buffer.readInt(); - for (var i = 0; i < cnt; i++) { - var nextPos = buffer.readShort(); - nextPos += buffer.position; - bg = {}; - var ch = buffer.readChar(); - font.glyphs[ch] = bg; - var img = buffer.readS(); - var bx = buffer.readInt(); - var by = buffer.readInt(); - bg.x = buffer.readInt(); - bg.y = buffer.readInt(); - bg.width = buffer.readInt(); - bg.height = buffer.readInt(); - bg.advance = buffer.readInt(); - bg.channel = buffer.readByte(); - if (bg.channel == 1) - bg.channel = 3; - else if (bg.channel == 2) - bg.channel = 2; - else if (bg.channel == 3) - bg.channel = 1; - if (font.ttf) { - bg.texture = new egret.Texture(); - bg.texture.bitmapData = mainTexture.bitmapData; - bg.texture.$initData(mainTexture.$bitmapX + bx + mainSprite.rect.x, mainTexture.$bitmapY + by + mainSprite.rect.y, bg.width, bg.height, mainSprite.offset.x, mainSprite.offset.y, mainSprite.originalSize.x, mainSprite.originalSize.y, mainTexture.$sourceWidth, mainTexture.$sourceHeight, mainSprite.rotated); - bg.lineHeight = lineHeight; - } - else { - var charImg = this._itemsById[img]; - if (charImg) { - this.getItemAsset(charImg); - bg.width = charImg.width; - bg.height = charImg.height; - bg.texture = charImg.asset; - } - if (bg.advance == 0) { - if (xadvance == 0) - bg.advance = bg.x + bg.width; - else - bg.advance = xadvance; - } - bg.lineHeight = bg.y < 0 ? bg.height : (bg.y + bg.height); - if (bg.lineHeight < font.size) - bg.lineHeight = font.size; - } - buffer.position = nextPos; - } - }; - UIPackage.prototype.loadDragonBones = function (item) { - var jsonFile = getAssetResKey(item.file, ["json", "dbbin"]); - var str = item.file.replace("_ske", "_tex"); - var atlasFile = getAssetResKey(str, "json"); - var texFile = getAssetResKey(str, "png"); - var task1 = RES.getResAsync(jsonFile); - var task2 = RES.getResAsync(atlasFile); - var task3 = RES.getResAsync(texFile); - Promise.all([task1, task2, task3]).then(function (values) { - var egretFactory = dragonBones.EgretFactory.factory; - item.asset = egretFactory.parseDragonBonesData(values[0]); - item.atlasAsset = egretFactory.parseTextureAtlasData(values[1], values[2]); - item.armatureName = item.asset.armatureNames[0]; - var arr = item.loading; - delete item.loading; - arr.forEach(function (e) { return e(null, item); }); - }).catch(function (reason) { - var arr = item.loading; - delete item.loading; - arr.forEach(function (e) { return e(reason, item); }); - }); - }; - UIPackage._constructing = 0; - UIPackage._instById = {}; - UIPackage._instByName = {}; - UIPackage._branch = ""; - UIPackage._vars = {}; - return UIPackage; - }()); - fgui.UIPackage = UIPackage; - function getAssetResKey(file, types) { - if (Array.isArray(types)) { - for (var i = 0; i < types.length; i++) { - var key = file + "_" + types[i]; - if (RES.hasRes(key)) - return key; - } - return file; - } - else { - var key = file + "_" + types; - if (RES.hasRes(key)) - return key; - return file; - } - } -})(fgui || (fgui = {})); - -(function (fgui) { - var Window = (function (_super_1) { - __extends(Window, _super_1); - function Window() { - var _this = _super_1.call(this) || this; - _this._requestingCmd = 0; - _this._uiSources = new Array(); - _this.bringToFontOnClick = fgui.UIConfig.bringWindowToFrontOnClick; - _this.displayObject.addEventListener(egret.Event.ADDED_TO_STAGE, _this.__onShown, _this); - _this.displayObject.addEventListener(egret.Event.REMOVED_FROM_STAGE, _this.__onHidden, _this); - _this.displayObject.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.__mouseDown, _this, true); - return _this; - } - Window.prototype.addUISource = function (source) { - this._uiSources.push(source); - }; - Object.defineProperty(Window.prototype, "contentPane", { - get: function () { - return this._contentPane; - }, - set: function (val) { - if (this._contentPane != val) { - if (this._contentPane) - this.removeChild(this._contentPane); - this._contentPane = val; - if (this._contentPane) { - this.addChild(this._contentPane); - this.setSize(this._contentPane.width, this._contentPane.height); - this._contentPane.addRelation(this, fgui.RelationType.Size); - this._frame = (this._contentPane.getChild("frame")); - if (this._frame) { - this.closeButton = this._frame.getChild("closeButton"); - this.dragArea = this._frame.getChild("dragArea"); - this.contentArea = this._frame.getChild("contentArea"); - } - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "frame", { - get: function () { - return this._frame; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "closeButton", { - get: function () { - return this._closeButton; - }, - set: function (value) { - if (this._closeButton) - this._closeButton.removeClickListener(this.closeEventHandler, this); - this._closeButton = value; - if (this._closeButton) - this._closeButton.addClickListener(this.closeEventHandler, this); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "dragArea", { - get: function () { - return this._dragArea; - }, - set: function (value) { - if (this._dragArea != value) { - if (this._dragArea) { - this._dragArea.draggable = false; - this._dragArea.removeEventListener(fgui.DragEvent.DRAG_START, this.__dragStart, this); - } - this._dragArea = value; - if (this._dragArea) { - if ((this._dragArea instanceof fgui.GGraph) && this._dragArea.displayObject == null) - this._dragArea.asGraph.drawRect(0, 0, 0, 0, 0); - this._dragArea.draggable = true; - this._dragArea.addEventListener(fgui.DragEvent.DRAG_START, this.__dragStart, this); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "contentArea", { - get: function () { - return this._contentArea; - }, - set: function (value) { - this._contentArea = value; - }, - enumerable: true, - configurable: true - }); - Window.prototype.show = function () { - fgui.GRoot.inst.showWindow(this); - }; - Window.prototype.showOn = function (root) { - root.showWindow(this); - }; - Window.prototype.hide = function () { - if (this.isShowing) - this.doHideAnimation(); - }; - Window.prototype.hideImmediately = function () { - var r = (this.parent instanceof fgui.GRoot) ? this.parent : null; - if (!r) - r = fgui.GRoot.inst; - r.hideWindowImmediately(this); - }; - Window.prototype.centerOn = function (r, restraint) { - this.setXY(Math.round((r.width - this.width) / 2), Math.round((r.height - this.height) / 2)); - if (restraint) { - this.addRelation(r, fgui.RelationType.Center_Center); - this.addRelation(r, fgui.RelationType.Middle_Middle); - } - }; - Window.prototype.toggleStatus = function () { - if (this.isTop) - this.hide(); - else - this.show(); - }; - Object.defineProperty(Window.prototype, "isShowing", { - get: function () { - return this.parent != null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "isTop", { - get: function () { - return this.parent != null && this.parent.getChildIndex(this) == this.parent.numChildren - 1; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "modal", { - get: function () { - return this._modal; - }, - set: function (val) { - this._modal = val; - }, - enumerable: true, - configurable: true - }); - Window.prototype.bringToFront = function () { - this.root.bringToFront(this); - }; - Window.prototype.showModalWait = function (requestingCmd) { - if (requestingCmd != undefined) - this._requestingCmd = requestingCmd; - if (fgui.UIConfig.windowModalWaiting) { - if (!this._modalWaitPane) - this._modalWaitPane = fgui.UIPackage.createObjectFromURL(fgui.UIConfig.windowModalWaiting); - this.layoutModalWaitPane(); - this.addChild(this._modalWaitPane); - } - }; - Window.prototype.layoutModalWaitPane = function () { - if (this._contentArea) { - var pt = this._frame.localToGlobal(); - pt = this.globalToLocal(pt.x, pt.y, pt); - this._modalWaitPane.setXY(pt.x + this._contentArea.x, pt.y + this._contentArea.y); - this._modalWaitPane.setSize(this._contentArea.width, this._contentArea.height); - } - else - this._modalWaitPane.setSize(this.width, this.height); - }; - Window.prototype.closeModalWait = function (requestingCmd) { - if (requestingCmd != null && requestingCmd != 0) { - if (this._requestingCmd != requestingCmd) - return false; - } - this._requestingCmd = 0; - if (this._modalWaitPane && this._modalWaitPane.parent != null) - this.removeChild(this._modalWaitPane); - return true; - }; - Object.defineProperty(Window.prototype, "modalWaiting", { - get: function () { - return this._modalWaitPane && this._modalWaitPane.parent != null; - }, - enumerable: true, - configurable: true - }); - Window.prototype.init = function () { - if (this._inited || this._loading) - return; - if (this._uiSources.length > 0) { - this._loading = false; - var cnt = this._uiSources.length; - for (var i = 0; i < cnt; i++) { - var lib = this._uiSources[i]; - if (!lib.loaded) { - lib.load(this.__uiLoadComplete, this); - this._loading = true; - } - } - if (!this._loading) - this._init(); - } - else - this._init(); - }; - Window.prototype.onInit = function () { - }; - Window.prototype.onShown = function () { - }; - Window.prototype.onHide = function () { - }; - Window.prototype.doShowAnimation = function () { - this.onShown(); - }; - Window.prototype.doHideAnimation = function () { - this.hideImmediately(); - }; - Window.prototype.__uiLoadComplete = function () { - var cnt = this._uiSources.length; - for (var i = 0; i < cnt; i++) { - var lib = this._uiSources[i]; - if (!lib.loaded) - return; - } - this._loading = false; - this._init(); - }; - Window.prototype._init = function () { - this._inited = true; - this.onInit(); - if (this.isShowing) - this.doShowAnimation(); - }; - Window.prototype.dispose = function () { - this.displayObject.removeEventListener(egret.Event.ADDED_TO_STAGE, this.__onShown, this); - this.displayObject.removeEventListener(egret.Event.REMOVED_FROM_STAGE, this.__onHidden, this); - if (this.parent) - this.hideImmediately(); - _super_1.prototype.dispose.call(this); - }; - Window.prototype.closeEventHandler = function (evt) { - this.hide(); - }; - Window.prototype.__onShown = function (evt) { - if (!this._inited) - this.init(); - else - this.doShowAnimation(); - }; - Window.prototype.__onHidden = function (evt) { - this.closeModalWait(); - this.onHide(); - }; - Window.prototype.__mouseDown = function (evt) { - if (this.isShowing && this.bringToFontOnClick) - this.bringToFront(); - }; - Window.prototype.__dragStart = function (evt) { - evt.preventDefault(); - this.startDrag(evt.touchPointID, evt.stageX, evt.stageY); - }; - return Window; - }(fgui.GComponent)); - fgui.Window = Window; -})(fgui || (fgui = {})); - -(function (fgui) { - var ControllerAction = (function () { - function ControllerAction() { - } - ControllerAction.createAction = function (type) { - switch (type) { - case 0: - return new fgui.PlayTransitionAction(); - case 1: - return new fgui.ChangePageAction(); - } - return null; - }; - ControllerAction.prototype.run = function (controller, prevPage, curPage) { - if ((this.fromPage == null || this.fromPage.length == 0 || this.fromPage.indexOf(prevPage) != -1) - && (this.toPage == null || this.toPage.length == 0 || this.toPage.indexOf(curPage) != -1)) - this.enter(controller); - else - this.leave(controller); - }; - ControllerAction.prototype.enter = function (controller) { - }; - ControllerAction.prototype.leave = function (controller) { - }; - ControllerAction.prototype.setup = function (buffer) { - var cnt; - var i; - cnt = buffer.readShort(); - this.fromPage = []; - for (i = 0; i < cnt; i++) - this.fromPage[i] = buffer.readS(); - cnt = buffer.readShort(); - this.toPage = []; - for (i = 0; i < cnt; i++) - this.toPage[i] = buffer.readS(); - }; - return ControllerAction; - }()); - fgui.ControllerAction = ControllerAction; -})(fgui || (fgui = {})); - -(function (fgui) { - var ChangePageAction = (function (_super_1) { - __extends(ChangePageAction, _super_1); - function ChangePageAction() { - return _super_1.call(this) || this; - } - ChangePageAction.prototype.enter = function (controller) { - if (!this.controllerName) - return; - var gcom; - if (this.objectId) { - var obj = controller.parent.getChildById(this.objectId); - if (obj instanceof fgui.GComponent) - gcom = obj; - else - return; - } - else - gcom = controller.parent; - if (gcom) { - var cc = gcom.getController(this.controllerName); - if (cc && cc != controller && !cc.changing) { - if (this.targetPage == "~1") { - if (controller.selectedIndex < cc.pageCount) - cc.selectedIndex = controller.selectedIndex; - } - else if (this.targetPage == "~2") - cc.selectedPage = controller.selectedPage; - else - cc.selectedPageId = this.targetPage; - } - } - }; - ChangePageAction.prototype.setup = function (buffer) { - _super_1.prototype.setup.call(this, buffer); - this.objectId = buffer.readS(); - this.controllerName = buffer.readS(); - this.targetPage = buffer.readS(); - }; - return ChangePageAction; - }(fgui.ControllerAction)); - fgui.ChangePageAction = ChangePageAction; -})(fgui || (fgui = {})); - -(function (fgui) { - var PlayTransitionAction = (function (_super_1) { - __extends(PlayTransitionAction, _super_1); - function PlayTransitionAction() { - var _this = _super_1.call(this) || this; - _this.playTimes = 1; - _this.delay = 0; - _this.stopOnExit = false; - return _this; - } - PlayTransitionAction.prototype.enter = function (controller) { - var trans = controller.parent.getTransition(this.transitionName); - if (trans) { - if (this._currentTransition && this._currentTransition.playing) - trans.changePlayTimes(this.playTimes); - else - trans.play(null, null, null, this.playTimes, this.delay); - this._currentTransition = trans; - } - }; - PlayTransitionAction.prototype.leave = function (controller) { - if (this.stopOnExit && this._currentTransition) { - this._currentTransition.stop(); - this._currentTransition = null; - } - }; - PlayTransitionAction.prototype.setup = function (buffer) { - _super_1.prototype.setup.call(this, buffer); - this.transitionName = buffer.readS(); - this.playTimes = buffer.readInt(); - this.delay = buffer.readFloat(); - this.stopOnExit = buffer.readBool(); - }; - return PlayTransitionAction; - }(fgui.ControllerAction)); - fgui.PlayTransitionAction = PlayTransitionAction; -})(fgui || (fgui = {})); - -(function (fgui) { - var BitmapFont = (function () { - function BitmapFont() { - this.size = 0; - this.glyphs = {}; - } - return BitmapFont; - }()); - fgui.BitmapFont = BitmapFont; -})(fgui || (fgui = {})); - -(function (fgui) { - function fillImage(w, h, method, origin, clockwise, amount) { - if (amount <= 0) - return null; - else if (amount >= 0.9999) - return [0, 0, w, 0, w, h, 0, h]; - var points; - switch (method) { - case fgui.FillMethod.Horizontal: - points = fillHorizontal(w, h, origin, amount); - break; - case fgui.FillMethod.Vertical: - points = fillVertical(w, h, origin, amount); - break; - case fgui.FillMethod.Radial90: - points = fillRadial90(w, h, origin, clockwise, amount); - break; - case fgui.FillMethod.Radial180: - points = fillRadial180(w, h, origin, clockwise, amount); - break; - case fgui.FillMethod.Radial360: - points = fillRadial360(w, h, origin, clockwise, amount); - break; - } - return points; - } - fgui.fillImage = fillImage; - function fillHorizontal(w, h, origin, amount) { - var w2 = w * amount; - if (origin == fgui.FillOrigin.Left || origin == fgui.FillOrigin.Top) - return [0, 0, w2, 0, w2, h, 0, h]; - else - return [w, 0, w, h, w - w2, h, w - w2, 0]; - } - function fillVertical(w, h, origin, amount) { - var h2 = h * amount; - if (origin == fgui.FillOrigin.Left || origin == fgui.FillOrigin.Top) - return [0, 0, 0, h2, w, h2, w, 0]; - else - return [0, h, w, h, w, h - h2, 0, h - h2]; - } - function fillRadial90(w, h, origin, clockwise, amount) { - if (clockwise && (origin == fgui.FillOrigin.TopRight || origin == fgui.FillOrigin.BottomLeft) - || !clockwise && (origin == fgui.FillOrigin.TopLeft || origin == fgui.FillOrigin.BottomRight)) { - amount = 1 - amount; - } - var v, v2, h2; - v = Math.tan(Math.PI / 2 * amount); - h2 = w * v; - v2 = (h2 - h) / h2; - var points; - switch (origin) { - case fgui.FillOrigin.TopLeft: - if (clockwise) { - if (h2 <= h) - points = [0, 0, w, h2, w, 0]; - else - points = [0, 0, w * (1 - v2), h, w, h, w, 0]; - } - else { - if (h2 <= h) - points = [0, 0, w, h2, w, h, 0, h]; - else - points = [0, 0, w * (1 - v2), h, 0, h]; - } - break; - case fgui.FillOrigin.TopRight: - if (clockwise) { - if (h2 <= h) - points = [w, 0, 0, h2, 0, h, w, h]; - else - points = [w, 0, w * v2, h, w, h]; - } - else { - if (h2 <= h) - points = [w, 0, 0, h2, 0, 0]; - else - points = [w, 0, w * v2, h, 0, h, 0, 0]; - } - break; - case fgui.FillOrigin.BottomLeft: - if (clockwise) { - if (h2 <= h) - points = [0, h, w, h - h2, w, 0, 0, 0]; - else - points = [0, h, w * (1 - v2), 0, 0, 0]; - } - else { - if (h2 <= h) - points = [0, h, w, h - h2, w, h]; - else - points = [0, h, w * (1 - v2), 0, w, 0, w, h]; - } - break; - case fgui.FillOrigin.BottomRight: - if (clockwise) { - if (h2 <= h) - points = [w, h, 0, h - h2, 0, h]; - else - points = [w, h, w * v2, 0, 0, 0, 0, h]; - } - else { - if (h2 <= h) - points = [w, h, 0, h - h2, 0, 0, w, 0]; - else - points = [w, h, w * v2, 0, w, 0]; - } - break; - } - return points; - } - function movePoints(points, offsetX, offsetY) { - var cnt = points.length; - for (var i = 0; i < cnt; i += 2) { - points[i] += offsetX; - points[i + 1] += offsetY; - } - } - function fillRadial180(w, h, origin, clockwise, amount) { - var points; - switch (origin) { - case fgui.FillOrigin.Top: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial90(w / 2, h, clockwise ? fgui.FillOrigin.TopLeft : fgui.FillOrigin.TopRight, clockwise, amount); - if (clockwise) - movePoints(points, w / 2, 0); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial90(w / 2, h, clockwise ? fgui.FillOrigin.TopRight : fgui.FillOrigin.TopLeft, clockwise, amount); - if (clockwise) - points.push(w, h, w, 0); - else { - movePoints(points, w / 2, 0); - points.push(0, h, 0, 0); - } - } - break; - case fgui.FillOrigin.Bottom: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial90(w / 2, h, clockwise ? fgui.FillOrigin.BottomRight : fgui.FillOrigin.BottomLeft, clockwise, amount); - if (!clockwise) - movePoints(points, w / 2, 0); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial90(w / 2, h, clockwise ? fgui.FillOrigin.BottomLeft : fgui.FillOrigin.BottomRight, clockwise, amount); - if (clockwise) { - movePoints(points, w / 2, 0); - points.push(0, 0, 0, h); - } - else - points.push(w, 0, w, h); - } - break; - case fgui.FillOrigin.Left: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial90(w, h / 2, clockwise ? fgui.FillOrigin.BottomLeft : fgui.FillOrigin.TopLeft, clockwise, amount); - if (!clockwise) - movePoints(points, 0, h / 2); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial90(w, h / 2, clockwise ? fgui.FillOrigin.TopLeft : fgui.FillOrigin.BottomLeft, clockwise, amount); - if (clockwise) { - movePoints(points, 0, h / 2); - points.push(w, 0, 0, 0); - } - else - points.push(w, h, 0, h); - } - break; - case fgui.FillOrigin.Right: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial90(w, h / 2, clockwise ? fgui.FillOrigin.TopRight : fgui.FillOrigin.BottomRight, clockwise, amount); - if (clockwise) - movePoints(points, 0, h / 2); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial90(w, h / 2, clockwise ? fgui.FillOrigin.BottomRight : fgui.FillOrigin.TopRight, clockwise, amount); - if (clockwise) - points.push(0, h, w, h); - else { - movePoints(points, 0, h / 2); - points.push(0, 0, w, 0); - } - } - break; - } - return points; - } - function fillRadial360(w, h, origin, clockwise, amount) { - var points; - switch (origin) { - case fgui.FillOrigin.Top: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial180(w / 2, h, clockwise ? fgui.FillOrigin.Left : fgui.FillOrigin.Right, clockwise, amount); - if (clockwise) - movePoints(points, w / 2, 0); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial180(w / 2, h, clockwise ? fgui.FillOrigin.Right : fgui.FillOrigin.Left, clockwise, amount); - if (clockwise) - points.push(w, h, w, 0, w / 2, 0); - else { - movePoints(points, w / 2, 0); - points.push(0, h, 0, 0, w / 2, 0); - } - } - break; - case fgui.FillOrigin.Bottom: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial180(w / 2, h, clockwise ? fgui.FillOrigin.Right : fgui.FillOrigin.Left, clockwise, amount); - if (!clockwise) - movePoints(points, w / 2, 0); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial180(w / 2, h, clockwise ? fgui.FillOrigin.Left : fgui.FillOrigin.Right, clockwise, amount); - if (clockwise) { - movePoints(points, w / 2, 0); - points.push(0, 0, 0, h, w / 2, h); - } - else - points.push(w, 0, w, h, w / 2, h); - } - break; - case fgui.FillOrigin.Left: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial180(w, h / 2, clockwise ? fgui.FillOrigin.Bottom : fgui.FillOrigin.Top, clockwise, amount); - if (!clockwise) - movePoints(points, 0, h / 2); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial180(w, h / 2, clockwise ? fgui.FillOrigin.Top : fgui.FillOrigin.Bottom, clockwise, amount); - if (clockwise) { - movePoints(points, 0, h / 2); - points.push(w, 0, 0, 0, 0, h / 2); - } - else - points.push(w, h, 0, h, 0, h / 2); - } - break; - case fgui.FillOrigin.Right: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial180(w, h / 2, clockwise ? fgui.FillOrigin.Top : fgui.FillOrigin.Bottom, clockwise, amount); - if (clockwise) - movePoints(points, 0, h / 2); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial180(w, h / 2, clockwise ? fgui.FillOrigin.Bottom : fgui.FillOrigin.Top, clockwise, amount); - if (clockwise) - points.push(0, h, w, h, w, h / 2); - else { - movePoints(points, 0, h / 2); - points.push(0, 0, w, 0, w, h / 2); - } - } - break; - } - return points; - } -})(fgui || (fgui = {})); - -(function (fgui) { - var Image = (function (_super_1) { - __extends(Image, _super_1); - function Image() { - var _this = _super_1.call(this) || this; - _this._fillMethod = 0; - _this._fillOrigin = 0; - _this._fillAmount = 0; - _this._color = 0xFFFFFF; - return _this; - } - Object.defineProperty(Image.prototype, "color", { - get: function () { - return this._color; - }, - set: function (value) { - if (this._color != value) { - this._color = value; - if (this.tint == undefined) - fgui.ToolSet.setColorFilter(this, value); - else - this.tint = value; - } - }, - enumerable: true, - configurable: true - }); - Image.prototype.$setX = function (value) { - if (this.mask) - this.mask.x = value; - return _super_1.prototype.$setX.call(this, value); - }; - Image.prototype.$setY = function (value) { - if (this.mask) - this.mask.y = value; - return _super_1.prototype.$setY.call(this, value); - }; - Object.defineProperty(Image.prototype, "fillMethod", { - get: function () { - return this._fillMethod; - }, - set: function (value) { - if (this._fillMethod != value) { - this._fillMethod = value; - if (this._fillMethod != 0) { - if (!this._mask) { - this._mask = new egret.Shape(); - this._mask.touchEnabled = false; - } - this.mask = this._mask; - this._mask.x = this.x; - this._mask.y = this.y; - this.addEventListener(egret.Event.RESIZE, this.markChanged, this); - this.markChanged(); - } - else if (this.mask) { - this._mask.graphics.clear(); - this.mask = null; - this.removeEventListener(egret.Event.RESIZE, this.markChanged, this); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Image.prototype, "fillOrigin", { - get: function () { - return this._fillOrigin; - }, - set: function (value) { - if (this._fillOrigin != value) { - this._fillOrigin = value; - if (this._fillMethod != 0) - this.markChanged(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Image.prototype, "fillClockwise", { - get: function () { - return this._fillClockwise; - }, - set: function (value) { - if (this._fillClockwise != value) { - this._fillClockwise = value; - if (this._fillMethod != 0) - this.markChanged(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Image.prototype, "fillAmount", { - get: function () { - return this._fillAmount; - }, - set: function (value) { - if (this._fillAmount != value) { - this._fillAmount = value; - if (this._fillMethod != 0) - this.markChanged(); - } - }, - enumerable: true, - configurable: true - }); - Image.prototype.markChanged = function () { - if (!this._maskDirtyFlag) { - this._maskDirtyFlag = true; - fgui.GTimers.inst.callLater(this.doFill, this); - } - }; - Image.prototype.doFill = function () { - this._maskDirtyFlag = false; - if (!this._mask.parent && this.parent) - this.parent.addChild(this._mask); - var w = this.width; - var h = this.height; - var g = this._mask.graphics; - g.clear(); - if (w == 0 || h == 0) - return; - var points = fgui.fillImage(w, h, this._fillMethod, this._fillOrigin, this._fillClockwise, this._fillAmount); - if (!points) - return; - g.beginFill(0, 1); - fgui.ToolSet.fillPath(g, points, 0, 0); - g.endFill(); - }; - return Image; - }(egret.Bitmap)); - fgui.Image = Image; -})(fgui || (fgui = {})); - -(function (fgui) { - var MovieClip = (function (_super_1) { - __extends(MovieClip, _super_1); - function MovieClip() { - var _this = _super_1.call(this) || this; - _this.interval = 0; - _this.repeatDelay = 0; - _this.timeScale = 1; - _this._playing = true; - _this._frameCount = 0; - _this._frame = 0; - _this._start = 0; - _this._end = 0; - _this._times = 0; - _this._endAt = 0; - _this._status = 0; - _this._frameElapsed = 0; - _this._reversed = false; - _this._repeatedCount = 0; - _this.touchEnabled = false; - _this.setPlaySettings(); - return _this; - } - Object.defineProperty(MovieClip.prototype, "frames", { - get: function () { - return this._frames; - }, - set: function (value) { - this._frames = value; - this.scale9Grid = null; - this.fillMode = egret.BitmapFillMode.SCALE; - if (this._frames) - this._frameCount = this._frames.length; - else - this._frameCount = 0; - if (this._end == -1 || this._end > this._frameCount - 1) - this._end = this._frameCount - 1; - if (this._endAt == -1 || this._endAt > this._frameCount - 1) - this._endAt = this._frameCount - 1; - if (this._frame < 0 || this._frame > this._frameCount - 1) - this._frame = this._frameCount - 1; - this.drawFrame(); - this._frameElapsed = 0; - this._repeatedCount = 0; - this._reversed = false; - this.checkTimer(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "frameCount", { - get: function () { - return this._frameCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "frame", { - get: function () { - return this._frame; - }, - set: function (value) { - if (this._frame != value) { - if (this._frames && value >= this._frameCount) - value = this._frameCount - 1; - this._frame = value; - this._frameElapsed = 0; - this.drawFrame(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "playing", { - get: function () { - return this._playing; - }, - set: function (value) { - if (this._playing != value) { - this._playing = value; - this.checkTimer(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "smoothing", { - get: function () { - return this._smoothing; - }, - set: function (value) { - this._smoothing = value; - }, - enumerable: true, - configurable: true - }); - MovieClip.prototype.rewind = function () { - this._frame = 0; - this._frameElapsed = 0; - this._reversed = false; - this._repeatedCount = 0; - this.drawFrame(); - }; - MovieClip.prototype.syncStatus = function (anotherMc) { - this._frame = anotherMc._frame; - this._frameElapsed = anotherMc._frameElapsed; - this._reversed = anotherMc._reversed; - this._repeatedCount = anotherMc._repeatedCount; - this.drawFrame(); - }; - MovieClip.prototype.advance = function (timeInMiniseconds) { - var beginFrame = this._frame; - var beginReversed = this._reversed; - var backupTime = timeInMiniseconds; - while (true) { - var tt = this.interval + this._frames[this._frame].addDelay; - if (this._frame == 0 && this._repeatedCount > 0) - tt += this.repeatDelay; - if (timeInMiniseconds < tt) { - this._frameElapsed = 0; - break; - } - timeInMiniseconds -= tt; - if (this.swing) { - if (this._reversed) { - this._frame--; - if (this._frame <= 0) { - this._frame = 0; - this._repeatedCount++; - this._reversed = !this._reversed; - } - } - else { - this._frame++; - if (this._frame > this._frameCount - 1) { - this._frame = Math.max(0, this._frameCount - 2); - this._repeatedCount++; - this._reversed = !this._reversed; - } - } - } - else { - this._frame++; - if (this._frame > this._frameCount - 1) { - this._frame = 0; - this._repeatedCount++; - } - } - if (this._frame == beginFrame && this._reversed == beginReversed) { - var roundTime = backupTime - timeInMiniseconds; - timeInMiniseconds -= Math.floor(timeInMiniseconds / roundTime) * roundTime; - } - } - this.drawFrame(); - }; - MovieClip.prototype.setPlaySettings = function (start, end, times, endAt, endCallback, callbackObj) { - if (start == undefined) - start = 0; - if (end == undefined) - end = -1; - if (times == undefined) - times = 0; - if (endAt == undefined) - endAt = -1; - this._start = start; - this._end = end; - if (this._end == -1 || this._end > this._frameCount - 1) - this._end = this._frameCount - 1; - this._times = times; - this._endAt = endAt; - if (this._endAt == -1) - this._endAt = this._end; - this._status = 0; - this._callback = endCallback; - this._callbackObj = callbackObj; - this.frame = start; - }; - MovieClip.prototype.update = function () { - if (!this._playing || this._frameCount == 0 || this._status == 3) - return; - var dt = fgui.GTimers.deltaTime; - if (this.timeScale != 1) - dt *= this.timeScale; - this._frameElapsed += dt; - var tt = this.interval + this._frames[this._frame].addDelay; - if (this._frame == 0 && this._repeatedCount > 0) - tt += this.repeatDelay; - if (this._frameElapsed < tt) - return; - this._frameElapsed -= tt; - if (this._frameElapsed > this.interval) - this._frameElapsed = this.interval; - if (this.swing) { - if (this._reversed) { - this._frame--; - if (this._frame <= 0) { - this._frame = 0; - this._repeatedCount++; - this._reversed = !this._reversed; - } - } - else { - this._frame++; - if (this._frame > this._frameCount - 1) { - this._frame = Math.max(0, this._frameCount - 2); - this._repeatedCount++; - this._reversed = !this._reversed; - } - } - } - else { - this._frame++; - if (this._frame > this._frameCount - 1) { - this._frame = 0; - this._repeatedCount++; - } - } - if (this._status == 1) { - this._frame = this._start; - this._frameElapsed = 0; - this._status = 0; - } - else if (this._status == 2) { - this._frame = this._endAt; - this._frameElapsed = 0; - this._status = 3; - if (this._callback != null) { - var callback = this._callback; - var caller = this._callbackObj; - this._callback = null; - this._callbackObj = null; - callback.call(caller); - } - } - else { - if (this._frame == this._end) { - if (this._times > 0) { - this._times--; - if (this._times == 0) - this._status = 2; - else - this._status = 1; - } - else if (this._start != 0) - this._status = 1; - } - } - this.drawFrame(); - }; - MovieClip.prototype.drawFrame = function () { - if (this._frameCount > 0 && this._frame < this._frames.length) { - var frame = this._frames[this._frame]; - this.texture = frame.texture; - } - else - this.texture = null; - }; - MovieClip.prototype.checkTimer = function () { - if (this._playing && this._frameCount > 0 && this.stage != null) - fgui.GTimers.inst.add(1, 0, this.update, this); - else - fgui.GTimers.inst.remove(this.update, this); - }; - MovieClip.prototype.$onAddToStage = function (stage, nestLevel) { - _super_1.prototype.$onAddToStage.call(this, stage, nestLevel); - if (this._playing && this._frameCount > 0) - fgui.GTimers.inst.add(1, 0, this.update, this); - }; - MovieClip.prototype.$onRemoveFromStage = function () { - _super_1.prototype.$onRemoveFromStage.call(this); - fgui.GTimers.inst.remove(this.update, this); - }; - return MovieClip; - }(fgui.Image)); - fgui.MovieClip = MovieClip; -})(fgui || (fgui = {})); - -(function (fgui) { - var UIContainer = (function (_super_1) { - __extends(UIContainer, _super_1); - function UIContainer() { - var _this = _super_1.call(this) || this; - _this.touchEnabled = true; - _this.touchChildren = true; - return _this; - } - UIContainer.prototype.cacheHitArea = function (value) { - this._cachedHitArea = value; - if (value) { - if (!this._cachedMatrix) - this._cachedMatrix = new egret.Matrix(); - this._cachedMatrix.copyFrom(this.$getInvertedConcatenatedMatrix()); - } - }; - Object.defineProperty(UIContainer.prototype, "hitArea", { - get: function () { - return this._hitArea; - }, - set: function (value) { - this._hitArea = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIContainer.prototype, "opaque", { - get: function () { - return this._opaque; - }, - set: function (value) { - this._opaque = value; - }, - enumerable: true, - configurable: true - }); - UIContainer.prototype.$hitTest = function (stageX, stageY) { - if (!this.$visible) - return null; - if (this._hitArea) { - if (!this.touchEnabled) - return null; - if (this._hitArea.$graphics) { - if (!this._hitArea.$graphics.$hitTest(stageX, stageY)) - return null; - } - else { - var m = this._cachedHitArea ? this._cachedMatrix : this.$getInvertedConcatenatedMatrix(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - if (!this._hitArea.contains(localX, localY)) - return null; - } - return this; - } - var ret = _super_1.prototype.$hitTest.call(this, stageX, stageY); - if (ret == this && !this.touchEnabled) - return null; - if (ret == null && this._opaque) { - var m = this._cachedHitArea ? this._cachedMatrix : this.$getInvertedConcatenatedMatrix(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - if (localX >= 0 && localY >= 0 && localX <= this.$explicitWidth && localY <= this.$explicitHeight) - return this; - else - return null; - } - else if (ret == this && !this._opaque) - return null; - else - return ret; - }; - return UIContainer; - }(egret.DisplayObjectContainer)); - fgui.UIContainer = UIContainer; -})(fgui || (fgui = {})); - -(function (fgui) { - var DragEvent = (function (_super_1) { - __extends(DragEvent, _super_1); - function DragEvent(type, stageX, stageY, touchPointID) { - if (stageX === void 0) { stageX = 0; } - if (stageY === void 0) { stageY = 0; } - if (touchPointID === void 0) { touchPointID = -1; } - var _this = _super_1.call(this, type, false) || this; - _this.touchPointID = 0; - _this.stageX = stageX; - _this.stageY = stageY; - _this.touchPointID = touchPointID; - return _this; - } - DragEvent.prototype.preventDefault = function () { - this._prevented = true; - }; - DragEvent.prototype.isDefaultPrevented = function () { - return this._prevented; - }; - DragEvent.DRAG_START = "__dragStart"; - DragEvent.DRAG_END = "__dragEnd"; - DragEvent.DRAG_MOVING = "__dragMoving"; - return DragEvent; - }(egret.Event)); - fgui.DragEvent = DragEvent; -})(fgui || (fgui = {})); - -(function (fgui) { - var DropEvent = (function (_super_1) { - __extends(DropEvent, _super_1); - function DropEvent(type, source) { - var _this = _super_1.call(this, type, false) || this; - _this.source = source; - return _this; - } - DropEvent.DROP = "__drop"; - return DropEvent; - }(egret.Event)); - fgui.DropEvent = DropEvent; -})(fgui || (fgui = {})); - -(function (fgui) { - var ItemEvent = (function (_super_1) { - __extends(ItemEvent, _super_1); - function ItemEvent(type, itemObject, stageX, stageY) { - if (itemObject === void 0) { itemObject = null; } - if (stageX === void 0) { stageX = 0; } - if (stageY === void 0) { stageY = 0; } - var _this = _super_1.call(this, type, false) || this; - _this.itemObject = itemObject; - _this.stageX = stageX; - _this.stageY = stageY; - return _this; - } - ItemEvent.CLICK = "___itemClick"; - return ItemEvent; - }(egret.Event)); - fgui.ItemEvent = ItemEvent; -})(fgui || (fgui = {})); - -(function (fgui) { - var StateChangeEvent = (function (_super_1) { - __extends(StateChangeEvent, _super_1); - function StateChangeEvent(type) { - return _super_1.call(this, type, false) || this; - } - StateChangeEvent.CHANGED = "___stateChanged"; - return StateChangeEvent; - }(egret.Event)); - fgui.StateChangeEvent = StateChangeEvent; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearBase = (function () { - function GearBase(owner) { - this._owner = owner; - } - GearBase.create = function (owner, index) { - if (!Classes) - Classes = [ - fgui.GearDisplay, fgui.GearXY, fgui.GearSize, fgui.GearLook, fgui.GearColor, - fgui.GearAnimation, fgui.GearText, fgui.GearIcon, fgui.GearDisplay2, fgui.GearFontSize - ]; - return new (Classes[index])(owner); - }; - GearBase.prototype.dispose = function () { - if (this._tweenConfig && this._tweenConfig._tweener) { - this._tweenConfig._tweener.kill(); - this._tweenConfig._tweener = null; - } - }; - Object.defineProperty(GearBase.prototype, "controller", { - get: function () { - return this._controller; - }, - set: function (val) { - if (val != this._controller) { - this._controller = val; - if (this._controller) - this.init(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GearBase.prototype, "tweenConfig", { - get: function () { - if (!this._tweenConfig) - this._tweenConfig = new GearTweenConfig(); - return this._tweenConfig; - }, - enumerable: true, - configurable: true - }); - GearBase.prototype.setup = function (buffer) { - this._controller = this._owner.parent.getControllerAt(buffer.readShort()); - this.init(); - var i; - var page; - var cnt = buffer.readShort(); - if (this instanceof fgui.GearDisplay) { - this.pages = buffer.readSArray(cnt); - } - else if (this instanceof fgui.GearDisplay2) { - this.pages = buffer.readSArray(cnt); - } - else { - for (i = 0; i < cnt; i++) { - page = buffer.readS(); - if (page == null) - continue; - this.addStatus(page, buffer); - } - if (buffer.readBool()) - this.addStatus(null, buffer); - } - if (buffer.readBool()) { - this._tweenConfig = new GearTweenConfig(); - this._tweenConfig.easeType = buffer.readByte(); - this._tweenConfig.duration = buffer.readFloat(); - this._tweenConfig.delay = buffer.readFloat(); - } - if (buffer.version >= 2) { - if (this instanceof fgui.GearXY) { - if (buffer.readBool()) { - this.positionsInPercent = true; - for (i = 0; i < cnt; i++) { - page = buffer.readS(); - if (page == null) - continue; - this.addExtStatus(page, buffer); - } - if (buffer.readBool()) - this.addExtStatus(null, buffer); - } - } - else if (this instanceof fgui.GearDisplay2) - this.condition = buffer.readByte(); - } - }; - GearBase.prototype.updateFromRelations = function (dx, dy) { - }; - GearBase.prototype.addStatus = function (pageId, buffer) { - }; - GearBase.prototype.init = function () { - }; - GearBase.prototype.apply = function () { - }; - GearBase.prototype.updateState = function () { - }; - return GearBase; - }()); - fgui.GearBase = GearBase; - var Classes; - var GearTweenConfig = (function () { - function GearTweenConfig() { - this.tween = true; - this.easeType = fgui.EaseType.QuadOut; - this.duration = 0.3; - this.delay = 0; - } - return GearTweenConfig; - }()); - fgui.GearTweenConfig = GearTweenConfig; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearAnimation = (function (_super_1) { - __extends(GearAnimation, _super_1); - function GearAnimation(owner) { - return _super_1.call(this, owner) || this; - } - GearAnimation.prototype.init = function () { - this._default = { - playing: this._owner.getProp(fgui.ObjectPropID.Playing), - frame: this._owner.getProp(fgui.ObjectPropID.Frame) - }; - this._storage = {}; - }; - GearAnimation.prototype.addStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - this._storage[pageId] = gv = {}; - gv.playing = buffer.readBool(); - gv.frame = buffer.readInt(); - }; - GearAnimation.prototype.apply = function () { - this._owner._gearLocked = true; - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - gv = this._default; - this._owner.setProp(fgui.ObjectPropID.Playing, gv.playing); - this._owner.setProp(fgui.ObjectPropID.Frame, gv.frame); - this._owner._gearLocked = false; - }; - GearAnimation.prototype.updateState = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - this._storage[this._controller.selectedPageId] = gv = {}; - gv.playing = this._owner.getProp(fgui.ObjectPropID.Playing); - gv.frame = this._owner.getProp(fgui.ObjectPropID.Frame); - }; - return GearAnimation; - }(fgui.GearBase)); - fgui.GearAnimation = GearAnimation; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearColor = (function (_super_1) { - __extends(GearColor, _super_1); - function GearColor(owner) { - return _super_1.call(this, owner) || this; - } - GearColor.prototype.init = function () { - this._default = { - color: this._owner.getProp(fgui.ObjectPropID.Color), - strokeColor: this._owner.getProp(fgui.ObjectPropID.OutlineColor) - }; - this._storage = {}; - }; - GearColor.prototype.addStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - this._storage[pageId] = gv = {}; - gv.color = buffer.readColor(); - gv.strokeColor = buffer.readColor(); - }; - GearColor.prototype.apply = function () { - this._owner._gearLocked = true; - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - gv = this._default; - this._owner.setProp(fgui.ObjectPropID.Color, gv.color); - this._owner.setProp(fgui.ObjectPropID.OutlineColor, gv.strokeColor); - this._owner._gearLocked = false; - }; - GearColor.prototype.updateState = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - this._storage[this._controller.selectedPageId] = gv = {}; - gv.color = this._owner.getProp(fgui.ObjectPropID.Color); - gv.strokeColor = this._owner.getProp(fgui.ObjectPropID.OutlineColor); - }; - return GearColor; - }(fgui.GearBase)); - fgui.GearColor = GearColor; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearDisplay = (function (_super_1) { - __extends(GearDisplay, _super_1); - function GearDisplay(owner) { - var _this = _super_1.call(this, owner) || this; - _this._displayLockToken = 1; - _this._visible = 0; - return _this; - } - GearDisplay.prototype.init = function () { - this.pages = null; - }; - GearDisplay.prototype.apply = function () { - this._displayLockToken++; - if (this._displayLockToken == 0) - this._displayLockToken = 1; - if (this.pages == null || this.pages.length == 0 - || this.pages.indexOf(this._controller.selectedPageId) != -1) - this._visible = 1; - else - this._visible = 0; - }; - GearDisplay.prototype.addLock = function () { - this._visible++; - return this._displayLockToken; - }; - GearDisplay.prototype.releaseLock = function (token) { - if (token == this._displayLockToken) - this._visible--; - }; - Object.defineProperty(GearDisplay.prototype, "connected", { - get: function () { - return this._controller == null || this._visible > 0; - }, - enumerable: true, - configurable: true - }); - return GearDisplay; - }(fgui.GearBase)); - fgui.GearDisplay = GearDisplay; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearDisplay2 = (function (_super_1) { - __extends(GearDisplay2, _super_1); - function GearDisplay2(owner) { - var _this = _super_1.call(this, owner) || this; - _this._visible = 0; - return _this; - } - GearDisplay2.prototype.init = function () { - this.pages = null; - }; - GearDisplay2.prototype.apply = function () { - if (this.pages == null || this.pages.length == 0 - || this.pages.indexOf(this._controller.selectedPageId) != -1) - this._visible = 1; - else - this._visible = 0; - }; - GearDisplay2.prototype.evaluate = function (connected) { - var v = this._controller == null || this._visible > 0; - if (this.condition == 0) - v = v && connected; - else - v = v || connected; - return v; - }; - return GearDisplay2; - }(fgui.GearBase)); - fgui.GearDisplay2 = GearDisplay2; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearFontSize = (function (_super_1) { - __extends(GearFontSize, _super_1); - function GearFontSize(owner) { - var _this = _super_1.call(this, owner) || this; - _this._default = 0; - return _this; - } - GearFontSize.prototype.init = function () { - this._default = this._owner.getProp(fgui.ObjectPropID.FontSize); - this._storage = {}; - }; - GearFontSize.prototype.addStatus = function (pageId, buffer) { - if (pageId == null) - this._default = buffer.readInt(); - else - this._storage[pageId] = buffer.readInt(); - }; - GearFontSize.prototype.apply = function () { - this._owner._gearLocked = true; - var data = this._storage[this._controller.selectedPageId]; - if (data != undefined) - this._owner.setProp(fgui.ObjectPropID.FontSize, data); - else - this._owner.setProp(fgui.ObjectPropID.FontSize, this._default); - this._owner._gearLocked = false; - }; - GearFontSize.prototype.updateState = function () { - this._storage[this._controller.selectedPageId] = this._owner.getProp(fgui.ObjectPropID.FontSize); - }; - return GearFontSize; - }(fgui.GearBase)); - fgui.GearFontSize = GearFontSize; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearIcon = (function (_super_1) { - __extends(GearIcon, _super_1); - function GearIcon(owner) { - return _super_1.call(this, owner) || this; - } - GearIcon.prototype.init = function () { - this._default = this._owner.icon; - this._storage = {}; - }; - GearIcon.prototype.addStatus = function (pageId, buffer) { - if (pageId == null) - this._default = buffer.readS(); - else - this._storage[pageId] = buffer.readS(); - }; - GearIcon.prototype.apply = function () { - this._owner._gearLocked = true; - var data = this._storage[this._controller.selectedPageId]; - if (data !== undefined) - this._owner.icon = data; - else - this._owner.icon = this._default; - this._owner._gearLocked = false; - }; - GearIcon.prototype.updateState = function () { - this._storage[this._controller.selectedPageId] = this._owner.icon; - }; - return GearIcon; - }(fgui.GearBase)); - fgui.GearIcon = GearIcon; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearLook = (function (_super_1) { - __extends(GearLook, _super_1); - function GearLook(owner) { - return _super_1.call(this, owner) || this; - } - GearLook.prototype.init = function () { - this._default = { - alpha: this._owner.alpha, - rotation: this._owner.rotation, - grayed: this._owner.grayed, - touchable: this._owner.touchable - }; - this._storage = {}; - }; - GearLook.prototype.addStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - this._storage[pageId] = gv = {}; - gv.alpha = buffer.readFloat(); - gv.rotation = buffer.readFloat(); - gv.grayed = buffer.readBool(); - gv.touchable = buffer.readBool(); - }; - GearLook.prototype.apply = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - gv = this._default; - if (this._tweenConfig && this._tweenConfig.tween && !fgui.UIPackage._constructing && !fgui.GearBase.disableAllTweenEffect) { - this._owner._gearLocked = true; - this._owner.grayed = gv.grayed; - this._owner.touchable = gv.touchable; - this._owner._gearLocked = false; - if (this._tweenConfig._tweener) { - if (this._tweenConfig._tweener.endValue.x != gv.alpha || this._tweenConfig._tweener.endValue.y != gv.rotation) { - this._tweenConfig._tweener.kill(true); - this._tweenConfig._tweener = null; - } - else - return; - } - var a = gv.alpha != this._owner.alpha; - var b = gv.rotation != this._owner.rotation; - if (a || b) { - if (this._owner.checkGearController(0, this._controller)) - this._tweenConfig._displayLockToken = this._owner.addDisplayLock(); - this._tweenConfig._tweener = fgui.GTween.to2(this._owner.alpha, this._owner.rotation, gv.alpha, gv.rotation, this._tweenConfig.duration) - .setDelay(this._tweenConfig.delay) - .setEase(this._tweenConfig.easeType) - .setUserData((a ? 1 : 0) + (b ? 2 : 0)) - .setTarget(this) - .onUpdate(this.__tweenUpdate, this) - .onComplete(this.__tweenComplete, this); - } - } - else { - this._owner._gearLocked = true; - this._owner.grayed = gv.grayed; - this._owner.touchable = gv.touchable; - this._owner.alpha = gv.alpha; - this._owner.rotation = gv.rotation; - this._owner._gearLocked = false; - } - }; - GearLook.prototype.__tweenUpdate = function (tweener) { - var flag = tweener.userData; - this._owner._gearLocked = true; - if ((flag & 1) != 0) - this._owner.alpha = tweener.value.x; - if ((flag & 2) != 0) - this._owner.rotation = tweener.value.y; - this._owner._gearLocked = false; - }; - GearLook.prototype.__tweenComplete = function () { - if (this._tweenConfig._displayLockToken != 0) { - this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken); - this._tweenConfig._displayLockToken = 0; - } - this._tweenConfig._tweener = null; - }; - GearLook.prototype.updateState = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - this._storage[this._controller.selectedPageId] = gv = {}; - gv.alpha = this._owner.alpha; - gv.rotation = this._owner.rotation; - gv.grayed = this._owner.grayed; - gv.touchable = this._owner.touchable; - }; - return GearLook; - }(fgui.GearBase)); - fgui.GearLook = GearLook; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearSize = (function (_super_1) { - __extends(GearSize, _super_1); - function GearSize(owner) { - return _super_1.call(this, owner) || this; - } - GearSize.prototype.init = function () { - this._default = { - width: this._owner.width, - height: this._owner.height, - scaleX: this._owner.scaleX, - scaleY: this._owner.scaleY - }; - this._storage = {}; - }; - GearSize.prototype.addStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - this._storage[pageId] = gv = {}; - gv.width = buffer.readInt(); - gv.height = buffer.readInt(); - gv.scaleX = buffer.readFloat(); - gv.scaleY = buffer.readFloat(); - }; - GearSize.prototype.apply = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - gv = this._default; - if (this._tweenConfig && this._tweenConfig.tween && !fgui.UIPackage._constructing && !fgui.GearBase.disableAllTweenEffect) { - if (this._tweenConfig._tweener) { - if (this._tweenConfig._tweener.endValue.x != gv.width || this._tweenConfig._tweener.endValue.y != gv.height - || this._tweenConfig._tweener.endValue.z != gv.scaleX || this._tweenConfig._tweener.endValue.w != gv.scaleY) { - this._tweenConfig._tweener.kill(true); - this._tweenConfig._tweener = null; - } - else - return; - } - var a = gv.width != this._owner.width || gv.height != this._owner.height; - var b = gv.scaleX != this._owner.scaleX || gv.scaleY != this._owner.scaleY; - if (a || b) { - if (this._owner.checkGearController(0, this._controller)) - this._tweenConfig._displayLockToken = this._owner.addDisplayLock(); - this._tweenConfig._tweener = fgui.GTween.to4(this._owner.width, this._owner.height, this._owner.scaleX, this._owner.scaleY, gv.width, gv.height, gv.scaleX, gv.scaleY, this._tweenConfig.duration) - .setDelay(this._tweenConfig.delay) - .setEase(this._tweenConfig.easeType) - .setUserData((a ? 1 : 0) + (b ? 2 : 0)) - .setTarget(this) - .onUpdate(this.__tweenUpdate, this) - .onComplete(this.__tweenComplete, this); - } - } - else { - this._owner._gearLocked = true; - this._owner.setSize(gv.width, gv.height, this._owner.gearXY.controller == this._controller); - this._owner.setScale(gv.scaleX, gv.scaleY); - this._owner._gearLocked = false; - } - }; - GearSize.prototype.__tweenUpdate = function (tweener) { - var flag = tweener.userData; - this._owner._gearLocked = true; - if ((flag & 1) != 0) - this._owner.setSize(tweener.value.x, tweener.value.y, this._owner.checkGearController(1, this._controller)); - if ((flag & 2) != 0) - this._owner.setScale(tweener.value.z, tweener.value.w); - this._owner._gearLocked = false; - }; - GearSize.prototype.__tweenComplete = function () { - if (this._tweenConfig._displayLockToken != 0) { - this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken); - this._tweenConfig._displayLockToken = 0; - } - this._tweenConfig._tweener = null; - }; - GearSize.prototype.updateState = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - this._storage[this._controller.selectedPageId] = gv = {}; - gv.width = this._owner.width; - gv.height = this._owner.height; - gv.scaleX = this._owner.scaleX; - gv.scaleY = this._owner.scaleY; - }; - GearSize.prototype.updateFromRelations = function (dx, dy) { - if (this._controller == null || this._storage == null) - return; - for (var key in this._storage) { - var gv = this._storage[key]; - gv.width += dx; - gv.height += dy; - } - this._default.width += dx; - this._default.height += dy; - this.updateState(); - }; - return GearSize; - }(fgui.GearBase)); - fgui.GearSize = GearSize; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearText = (function (_super_1) { - __extends(GearText, _super_1); - function GearText(owner) { - return _super_1.call(this, owner) || this; - } - GearText.prototype.init = function () { - this._default = this._owner.text; - this._storage = {}; - }; - GearText.prototype.addStatus = function (pageId, buffer) { - if (pageId == null) - this._default = buffer.readS(); - else - this._storage[pageId] = buffer.readS(); - }; - GearText.prototype.apply = function () { - this._owner._gearLocked = true; - var data = this._storage[this._controller.selectedPageId]; - if (data !== undefined) - this._owner.text = data; - else - this._owner.text = this._default; - this._owner._gearLocked = false; - }; - GearText.prototype.updateState = function () { - this._storage[this._controller.selectedPageId] = this._owner.text; - }; - return GearText; - }(fgui.GearBase)); - fgui.GearText = GearText; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearXY = (function (_super_1) { - __extends(GearXY, _super_1); - function GearXY(owner) { - return _super_1.call(this, owner) || this; - } - GearXY.prototype.init = function () { - this._default = { - x: this._owner.x, - y: this._owner.y, - px: this._owner.x / this._owner.parent.width, - py: this._owner.y / this._owner.parent.height - }; - this._storage = {}; - }; - GearXY.prototype.addStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - this._storage[pageId] = gv = {}; - gv.x = buffer.readInt(); - gv.y = buffer.readInt(); - }; - GearXY.prototype.addExtStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - gv = this._storage[pageId]; - gv.px = buffer.readFloat(); - gv.py = buffer.readFloat(); - }; - GearXY.prototype.apply = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - gv = this._default; - var ex; - var ey; - if (this.positionsInPercent && this._owner.parent) { - ex = gv.px * this._owner.parent.width; - ey = gv.py * this._owner.parent.height; - } - else { - ex = gv.x; - ey = gv.y; - } - if (this._tweenConfig && this._tweenConfig.tween && !fgui.UIPackage._constructing && !fgui.GearBase.disableAllTweenEffect) { - if (this._tweenConfig._tweener) { - if (this._tweenConfig._tweener.endValue.x != ex || this._tweenConfig._tweener.endValue.y != ey) { - this._tweenConfig._tweener.kill(true); - this._tweenConfig._tweener = null; - } - else - return; - } - var ox = this._owner.x; - var oy = this._owner.y; - if (ox != ex || oy != ey) { - if (this._owner.checkGearController(0, this._controller)) - this._tweenConfig._displayLockToken = this._owner.addDisplayLock(); - this._tweenConfig._tweener = fgui.GTween.to2(ox, oy, ex, ey, this._tweenConfig.duration) - .setDelay(this._tweenConfig.delay) - .setEase(this._tweenConfig.easeType) - .setTarget(this) - .onUpdate(this.__tweenUpdate, this) - .onComplete(this.__tweenComplete, this); - } - } - else { - this._owner._gearLocked = true; - this._owner.setXY(ex, ey); - this._owner._gearLocked = false; - } - }; - GearXY.prototype.__tweenUpdate = function (tweener) { - this._owner._gearLocked = true; - this._owner.setXY(tweener.value.x, tweener.value.y); - this._owner._gearLocked = false; - }; - GearXY.prototype.__tweenComplete = function () { - if (this._tweenConfig._displayLockToken != 0) { - this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken); - this._tweenConfig._displayLockToken = 0; - } - this._tweenConfig._tweener = null; - }; - GearXY.prototype.updateState = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - this._storage[this._controller.selectedPageId] = gv = {}; - gv.x = this._owner.x; - gv.y = this._owner.y; - gv.px = this._owner.x / this._owner.parent.width; - gv.py = this._owner.y / this._owner.parent.height; - }; - GearXY.prototype.updateFromRelations = function (dx, dy) { - if (this._controller == null || this._storage == null || this.positionsInPercent) - return; - for (var key in this._storage) { - var pt = this._storage[key]; - pt.x += dx; - pt.y += dy; - } - this._default.x += dx; - this._default.y += dy; - this.updateState(); - }; - return GearXY; - }(fgui.GearBase)); - fgui.GearXY = GearXY; -})(fgui || (fgui = {})); - -(function (fgui) { - var _PiOver2 = Math.PI * 0.5; - var _TwoPi = Math.PI * 2; - function evaluateEase(easeType, time, duration, overshootOrAmplitude, period) { - switch (easeType) { - case fgui.EaseType.Linear: - return time / duration; - case fgui.EaseType.SineIn: - return -Math.cos(time / duration * _PiOver2) + 1; - case fgui.EaseType.SineOut: - return Math.sin(time / duration * _PiOver2); - case fgui.EaseType.SineInOut: - return -0.5 * (Math.cos(Math.PI * time / duration) - 1); - case fgui.EaseType.QuadIn: - return (time /= duration) * time; - case fgui.EaseType.QuadOut: - return -(time /= duration) * (time - 2); - case fgui.EaseType.QuadInOut: - if ((time /= duration * 0.5) < 1) - return 0.5 * time * time; - return -0.5 * ((--time) * (time - 2) - 1); - case fgui.EaseType.CubicIn: - return (time /= duration) * time * time; - case fgui.EaseType.CubicOut: - return ((time = time / duration - 1) * time * time + 1); - case fgui.EaseType.CubicInOut: - if ((time /= duration * 0.5) < 1) - return 0.5 * time * time * time; - return 0.5 * ((time -= 2) * time * time + 2); - case fgui.EaseType.QuartIn: - return (time /= duration) * time * time * time; - case fgui.EaseType.QuartOut: - return -((time = time / duration - 1) * time * time * time - 1); - case fgui.EaseType.QuartInOut: - if ((time /= duration * 0.5) < 1) - return 0.5 * time * time * time * time; - return -0.5 * ((time -= 2) * time * time * time - 2); - case fgui.EaseType.QuintIn: - return (time /= duration) * time * time * time * time; - case fgui.EaseType.QuintOut: - return ((time = time / duration - 1) * time * time * time * time + 1); - case fgui.EaseType.QuintInOut: - if ((time /= duration * 0.5) < 1) - return 0.5 * time * time * time * time * time; - return 0.5 * ((time -= 2) * time * time * time * time + 2); - case fgui.EaseType.ExpoIn: - return (time == 0) ? 0 : Math.pow(2, 10 * (time / duration - 1)); - case fgui.EaseType.ExpoOut: - if (time == duration) - return 1; - return (-Math.pow(2, -10 * time / duration) + 1); - case fgui.EaseType.ExpoInOut: - if (time == 0) - return 0; - if (time == duration) - return 1; - if ((time /= duration * 0.5) < 1) - return 0.5 * Math.pow(2, 10 * (time - 1)); - return 0.5 * (-Math.pow(2, -10 * --time) + 2); - case fgui.EaseType.CircIn: - return -(Math.sqrt(1 - (time /= duration) * time) - 1); - case fgui.EaseType.CircOut: - return Math.sqrt(1 - (time = time / duration - 1) * time); - case fgui.EaseType.CircInOut: - if ((time /= duration * 0.5) < 1) - return -0.5 * (Math.sqrt(1 - time * time) - 1); - return 0.5 * (Math.sqrt(1 - (time -= 2) * time) + 1); - case fgui.EaseType.ElasticIn: - var s0; - if (time == 0) - return 0; - if ((time /= duration) == 1) - return 1; - if (period == 0) - period = duration * 0.3; - if (overshootOrAmplitude < 1) { - overshootOrAmplitude = 1; - s0 = period / 4; - } - else - s0 = period / _TwoPi * Math.asin(1 / overshootOrAmplitude); - return -(overshootOrAmplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time * duration - s0) * _TwoPi / period)); - case fgui.EaseType.ElasticOut: - var s1; - if (time == 0) - return 0; - if ((time /= duration) == 1) - return 1; - if (period == 0) - period = duration * 0.3; - if (overshootOrAmplitude < 1) { - overshootOrAmplitude = 1; - s1 = period / 4; - } - else - s1 = period / _TwoPi * Math.asin(1 / overshootOrAmplitude); - return (overshootOrAmplitude * Math.pow(2, -10 * time) * Math.sin((time * duration - s1) * _TwoPi / period) + 1); - case fgui.EaseType.ElasticInOut: - var s; - if (time == 0) - return 0; - if ((time /= duration * 0.5) == 2) - return 1; - if (period == 0) - period = duration * (0.3 * 1.5); - if (overshootOrAmplitude < 1) { - overshootOrAmplitude = 1; - s = period / 4; - } - else - s = period / _TwoPi * Math.asin(1 / overshootOrAmplitude); - if (time < 1) - return -0.5 * (overshootOrAmplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time * duration - s) * _TwoPi / period)); - return overshootOrAmplitude * Math.pow(2, -10 * (time -= 1)) * Math.sin((time * duration - s) * _TwoPi / period) * 0.5 + 1; - case fgui.EaseType.BackIn: - return (time /= duration) * time * ((overshootOrAmplitude + 1) * time - overshootOrAmplitude); - case fgui.EaseType.BackOut: - return ((time = time / duration - 1) * time * ((overshootOrAmplitude + 1) * time + overshootOrAmplitude) + 1); - case fgui.EaseType.BackInOut: - if ((time /= duration * 0.5) < 1) - return 0.5 * (time * time * (((overshootOrAmplitude *= (1.525)) + 1) * time - overshootOrAmplitude)); - return 0.5 * ((time -= 2) * time * (((overshootOrAmplitude *= (1.525)) + 1) * time + overshootOrAmplitude) + 2); - case fgui.EaseType.BounceIn: - return bounce_easeIn(time, duration); - case fgui.EaseType.BounceOut: - return bounce_easeOut(time, duration); - case fgui.EaseType.BounceInOut: - return bounce_easeInOut(time, duration); - default: - return -(time /= duration) * (time - 2); - } - } - fgui.evaluateEase = evaluateEase; - function bounce_easeIn(time, duration) { - return 1 - bounce_easeOut(duration - time, duration); - } - function bounce_easeOut(time, duration) { - if ((time /= duration) < (1 / 2.75)) { - return (7.5625 * time * time); - } - if (time < (2 / 2.75)) { - return (7.5625 * (time -= (1.5 / 2.75)) * time + 0.75); - } - if (time < (2.5 / 2.75)) { - return (7.5625 * (time -= (2.25 / 2.75)) * time + 0.9375); - } - return (7.5625 * (time -= (2.625 / 2.75)) * time + 0.984375); - } - function bounce_easeInOut(time, duration) { - if (time < duration * 0.5) { - return bounce_easeIn(time * 2, duration) * 0.5; - } - return bounce_easeOut(time * 2 - duration, duration) * 0.5 + 0.5; - } -})(fgui || (fgui = {})); - -(function (fgui) { - var EaseType = (function () { - function EaseType() { - } - EaseType.Linear = 0; - EaseType.SineIn = 1; - EaseType.SineOut = 2; - EaseType.SineInOut = 3; - EaseType.QuadIn = 4; - EaseType.QuadOut = 5; - EaseType.QuadInOut = 6; - EaseType.CubicIn = 7; - EaseType.CubicOut = 8; - EaseType.CubicInOut = 9; - EaseType.QuartIn = 10; - EaseType.QuartOut = 11; - EaseType.QuartInOut = 12; - EaseType.QuintIn = 13; - EaseType.QuintOut = 14; - EaseType.QuintInOut = 15; - EaseType.ExpoIn = 16; - EaseType.ExpoOut = 17; - EaseType.ExpoInOut = 18; - EaseType.CircIn = 19; - EaseType.CircOut = 20; - EaseType.CircInOut = 21; - EaseType.ElasticIn = 22; - EaseType.ElasticOut = 23; - EaseType.ElasticInOut = 24; - EaseType.BackIn = 25; - EaseType.BackOut = 26; - EaseType.BackInOut = 27; - EaseType.BounceIn = 28; - EaseType.BounceOut = 29; - EaseType.BounceInOut = 30; - EaseType.Custom = 31; - return EaseType; - }()); - fgui.EaseType = EaseType; -})(fgui || (fgui = {})); - -(function (fgui) { - var GPath = (function () { - function GPath() { - this._segments = new Array(); - this._points = new Array(); - } - Object.defineProperty(GPath.prototype, "length", { - get: function () { - return this._fullLength; - }, - enumerable: true, - configurable: true - }); - GPath.prototype.create = function (pt1, pt2, pt3, pt4) { - var points; - if (Array.isArray(pt1)) - points = pt1; - else { - points = new Array(); - points.push(pt1); - points.push(pt2); - if (pt3) - points.push(pt3); - if (pt4) - points.push(pt4); - } - this._segments.length = 0; - this._points.length = 0; - this._fullLength = 0; - var cnt = points.length; - if (cnt == 0) - return; - var splinePoints = s_points; - splinePoints.length = 0; - var prev = points[0]; - if (prev.curveType == fgui.CurveType.CRSpline) - splinePoints.push(new egret.Point(prev.x, prev.y)); - for (var i = 1; i < cnt; i++) { - var current = points[i]; - if (prev.curveType != fgui.CurveType.CRSpline) { - var seg = {}; - seg.type = prev.curveType; - seg.ptStart = this._points.length; - if (prev.curveType == fgui.CurveType.Straight) { - seg.ptCount = 2; - this._points.push(new egret.Point(prev.x, prev.y)); - this._points.push(new egret.Point(current.x, current.y)); - } - else if (prev.curveType == fgui.CurveType.Bezier) { - seg.ptCount = 3; - this._points.push(new egret.Point(prev.x, prev.y)); - this._points.push(new egret.Point(current.x, current.y)); - this._points.push(new egret.Point(prev.control1_x, prev.control1_y)); - } - else if (prev.curveType == fgui.CurveType.CubicBezier) { - seg.ptCount = 4; - this._points.push(new egret.Point(prev.x, prev.y)); - this._points.push(new egret.Point(current.x, current.y)); - this._points.push(new egret.Point(prev.control1_x, prev.control1_y)); - this._points.push(new egret.Point(prev.control2_x, prev.control2_y)); - } - seg.length = fgui.ToolSet.distance(prev.x, prev.y, current.x, current.y); - this._fullLength += seg.length; - this._segments.push(seg); - } - if (current.curveType != fgui.CurveType.CRSpline) { - if (splinePoints.length > 0) { - splinePoints.push(new egret.Point(current.x, current.y)); - this.createSplineSegment(); - } - } - else - splinePoints.push(new egret.Point(current.x, current.y)); - prev = current; - } - if (splinePoints.length > 1) - this.createSplineSegment(); - }; - GPath.prototype.createSplineSegment = function () { - var splinePoints = s_points; - var cnt = splinePoints.length; - splinePoints.splice(0, 0, splinePoints[0]); - splinePoints.push(splinePoints[cnt]); - splinePoints.push(splinePoints[cnt]); - cnt += 3; - var seg = {}; - seg.type = fgui.CurveType.CRSpline; - seg.ptStart = this._points.length; - seg.ptCount = cnt; - this._points = this._points.concat(splinePoints); - seg.length = 0; - for (var i = 1; i < cnt; i++) { - seg.length += fgui.ToolSet.distance(splinePoints[i - 1].x, splinePoints[i - 1].y, splinePoints[i].x, splinePoints[i].y); - } - this._fullLength += seg.length; - this._segments.push(seg); - splinePoints.length = 0; - }; - GPath.prototype.clear = function () { - this._segments.length = 0; - this._points.length = 0; - }; - GPath.prototype.getPointAt = function (t, result) { - if (!result) - result = new egret.Point(); - else - result.x = result.y = 0; - t = fgui.ToolSet.clamp01(t); - var cnt = this._segments.length; - if (cnt == 0) { - return result; - } - var seg; - if (t == 1) { - seg = this._segments[cnt - 1]; - if (seg.type == fgui.CurveType.Straight) { - result.x = fgui.ToolSet.lerp(this._points[seg.ptStart].x, this._points[seg.ptStart + 1].x, t); - result.y = fgui.ToolSet.lerp(this._points[seg.ptStart].y, this._points[seg.ptStart + 1].y, t); - return result; - } - else if (seg.type == fgui.CurveType.Bezier || seg.type == fgui.CurveType.CubicBezier) - return this.onBezierCurve(seg.ptStart, seg.ptCount, t, result); - else - return this.onCRSplineCurve(seg.ptStart, seg.ptCount, t, result); - } - var len = t * this._fullLength; - for (var i = 0; i < cnt; i++) { - seg = this._segments[i]; - len -= seg.length; - if (len < 0) { - t = 1 + len / seg.length; - if (seg.type == fgui.CurveType.Straight) { - result.x = fgui.ToolSet.lerp(this._points[seg.ptStart].x, this._points[seg.ptStart + 1].x, t); - result.y = fgui.ToolSet.lerp(this._points[seg.ptStart].y, this._points[seg.ptStart + 1].y, t); - } - else if (seg.type == fgui.CurveType.Bezier || seg.type == fgui.CurveType.CubicBezier) - result = this.onBezierCurve(seg.ptStart, seg.ptCount, t, result); - else - result = this.onCRSplineCurve(seg.ptStart, seg.ptCount, t, result); - break; - } - } - return result; - }; - Object.defineProperty(GPath.prototype, "segmentCount", { - get: function () { - return this._segments.length; - }, - enumerable: true, - configurable: true - }); - GPath.prototype.getAnchorsInSegment = function (segmentIndex, points) { - if (points == null) - points = new Array(); - var seg = this._segments[segmentIndex]; - for (var i = 0; i < seg.ptCount; i++) - points.push(new egret.Point(this._points[seg.ptStart + i].x, this._points[seg.ptStart + i].y)); - return points; - }; - GPath.prototype.getPointsInSegment = function (segmentIndex, t0, t1, points, ts, pointDensity) { - if (points == null) - points = new Array(); - if (!pointDensity || isNaN(pointDensity)) - pointDensity = 0.1; - if (ts) - ts.push(t0); - var seg = this._segments[segmentIndex]; - if (seg.type == fgui.CurveType.Straight) { - points.push(new egret.Point(fgui.ToolSet.lerp(this._points[seg.ptStart].x, this._points[seg.ptStart + 1].x, t0), fgui.ToolSet.lerp(this._points[seg.ptStart].y, this._points[seg.ptStart + 1].y, t0))); - points.push(new egret.Point(fgui.ToolSet.lerp(this._points[seg.ptStart].x, this._points[seg.ptStart + 1].x, t1), fgui.ToolSet.lerp(this._points[seg.ptStart].y, this._points[seg.ptStart + 1].y, t1))); - } - else { - var func; - if (seg.type == fgui.CurveType.Bezier || seg.type == fgui.CurveType.CubicBezier) - func = this.onBezierCurve; - else - func = this.onCRSplineCurve; - points.push(func.call(this, seg.ptStart, seg.ptCount, t0, new egret.Point())); - var SmoothAmount = Math.min(seg.length * pointDensity, 50); - for (var j = 0; j <= SmoothAmount; j++) { - var t = j / SmoothAmount; - if (t > t0 && t < t1) { - points.push(func.call(this, seg.ptStart, seg.ptCount, t, new egret.Point())); - if (ts != null) - ts.push(t); - } - } - points.push(func.call(this, seg.ptStart, seg.ptCount, t1, new egret.Point())); - } - if (ts != null) - ts.push(t1); - return points; - }; - GPath.prototype.getAllPoints = function (points, ts, pointDensity) { - if (points == null) - points = new Array(); - if (!pointDensity || isNaN(pointDensity)) - pointDensity = 0.1; - var cnt = this._segments.length; - for (var i = 0; i < cnt; i++) - this.getPointsInSegment(i, 0, 1, points, ts, pointDensity); - return points; - }; - GPath.prototype.onCRSplineCurve = function (ptStart, ptCount, t, result) { - var adjustedIndex = Math.floor(t * (ptCount - 4)) + ptStart; - var p0x = this._points[adjustedIndex].x; - var p0y = this._points[adjustedIndex].y; - var p1x = this._points[adjustedIndex + 1].x; - var p1y = this._points[adjustedIndex + 1].y; - var p2x = this._points[adjustedIndex + 2].x; - var p2y = this._points[adjustedIndex + 2].y; - var p3x = this._points[adjustedIndex + 3].x; - var p3y = this._points[adjustedIndex + 3].y; - var adjustedT = (t == 1) ? 1 : fgui.ToolSet.repeat(t * (ptCount - 4), 1); - var t0 = ((-adjustedT + 2) * adjustedT - 1) * adjustedT * 0.5; - var t1 = (((3 * adjustedT - 5) * adjustedT) * adjustedT + 2) * 0.5; - var t2 = ((-3 * adjustedT + 4) * adjustedT + 1) * adjustedT * 0.5; - var t3 = ((adjustedT - 1) * adjustedT * adjustedT) * 0.5; - result.x = p0x * t0 + p1x * t1 + p2x * t2 + p3x * t3; - result.y = p0y * t0 + p1y * t1 + p2y * t2 + p3y * t3; - return result; - }; - GPath.prototype.onBezierCurve = function (ptStart, ptCount, t, result) { - var t2 = 1 - t; - var p0x = this._points[ptStart].x; - var p0y = this._points[ptStart].y; - var p1x = this._points[ptStart + 1].x; - var p1y = this._points[ptStart + 1].y; - var cp0x = this._points[ptStart + 2].x; - var cp0y = this._points[ptStart + 2].y; - if (ptCount == 4) { - var cp1x = this._points[ptStart + 3].x; - var cp1y = this._points[ptStart + 3].y; - result.x = t2 * t2 * t2 * p0x + 3 * t2 * t2 * t * cp0x + 3 * t2 * t * t * cp1x + t * t * t * p1x; - result.y = t2 * t2 * t2 * p0y + 3 * t2 * t2 * t * cp0y + 3 * t2 * t * t * cp1y + t * t * t * p1y; - } - else { - result.x = t2 * t2 * p0x + 2 * t2 * t * cp0x + t * t * p1x; - result.y = t2 * t2 * p0y + 2 * t2 * t * cp0y + t * t * p1y; - } - return result; - }; - return GPath; - }()); - fgui.GPath = GPath; - var s_points = new Array(); -})(fgui || (fgui = {})); - -(function (fgui) { - var CurveType; - (function (CurveType) { - CurveType[CurveType["CRSpline"] = 0] = "CRSpline"; - CurveType[CurveType["Bezier"] = 1] = "Bezier"; - CurveType[CurveType["CubicBezier"] = 2] = "CubicBezier"; - CurveType[CurveType["Straight"] = 3] = "Straight"; - })(CurveType = fgui.CurveType || (fgui.CurveType = {})); - var GPathPoint = (function () { - function GPathPoint() { - this.x = 0; - this.y = 0; - this.control1_x = 0; - this.control1_y = 0; - this.control2_x = 0; - this.control2_y = 0; - this.curveType = 0; - } - GPathPoint.newPoint = function (x, y, curveType) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (curveType === void 0) { curveType = 0; } - var pt = new GPathPoint(); - pt.x = x; - pt.y = y; - pt.control1_x = 0; - pt.control1_y = 0; - pt.control2_x = 0; - pt.control2_y = 0; - pt.curveType = curveType; - return pt; - }; - GPathPoint.newBezierPoint = function (x, y, control1_x, control1_y) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (control1_x === void 0) { control1_x = 0; } - if (control1_y === void 0) { control1_y = 0; } - var pt = new GPathPoint(); - pt.x = x; - pt.y = y; - pt.control1_x = control1_x; - pt.control1_y = control1_y; - pt.control2_x = 0; - pt.control2_y = 0; - pt.curveType = CurveType.Bezier; - return pt; - }; - GPathPoint.newCubicBezierPoint = function (x, y, control1_x, control1_y, control2_x, control2_y) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (control1_x === void 0) { control1_x = 0; } - if (control1_y === void 0) { control1_y = 0; } - if (control2_x === void 0) { control2_x = 0; } - if (control2_y === void 0) { control2_y = 0; } - var pt = new GPathPoint(); - pt.x = x; - pt.y = y; - pt.control1_x = control1_x; - pt.control1_y = control1_y; - pt.control2_x = control2_x; - pt.control2_y = control2_y; - pt.curveType = CurveType.CubicBezier; - return pt; - }; - GPathPoint.prototype.clone = function () { - var ret = new GPathPoint(); - ret.x = this.x; - ret.y = this.y; - ret.control1_x = this.control1_x; - ret.control1_y = this.control1_y; - ret.control2_x = this.control2_x; - ret.control2_y = this.control2_y; - ret.curveType = this.curveType; - return ret; - }; - return GPathPoint; - }()); - fgui.GPathPoint = GPathPoint; -})(fgui || (fgui = {})); - -(function (fgui) { - var GTween = (function () { - function GTween() { - } - GTween.to = function (start, end, duration) { - return fgui.TweenManager.createTween()._to(start, end, duration); - }; - GTween.to2 = function (start, start2, end, end2, duration) { - return fgui.TweenManager.createTween()._to2(start, start2, end, end2, duration); - }; - GTween.to3 = function (start, start2, start3, end, end2, end3, duration) { - return fgui.TweenManager.createTween()._to3(start, start2, start3, end, end2, end3, duration); - }; - GTween.to4 = function (start, start2, start3, start4, end, end2, end3, end4, duration) { - return fgui.TweenManager.createTween()._to4(start, start2, start3, start4, end, end2, end3, end4, duration); - }; - GTween.toColor = function (start, end, duration) { - return fgui.TweenManager.createTween()._toColor(start, end, duration); - }; - GTween.delayedCall = function (delay) { - return fgui.TweenManager.createTween().setDelay(delay); - }; - GTween.shake = function (startX, startY, amplitude, duration) { - return fgui.TweenManager.createTween()._shake(startX, startY, amplitude, duration); - }; - GTween.isTweening = function (target, propType) { - return fgui.TweenManager.isTweening(target, propType); - }; - GTween.kill = function (target, complete, propType) { - fgui.TweenManager.killTweens(target, complete, propType); - }; - GTween.getTween = function (target, propType) { - return fgui.TweenManager.getTween(target, propType); - }; - GTween.catchCallbackExceptions = true; - return GTween; - }()); - fgui.GTween = GTween; -})(fgui || (fgui = {})); - -(function (fgui) { - var GTweener = (function () { - function GTweener() { - this._startValue = new fgui.TweenValue(); - this._endValue = new fgui.TweenValue(); - this._value = new fgui.TweenValue(); - this._deltaValue = new fgui.TweenValue(); - this._reset(); - } - GTweener.prototype.setDelay = function (value) { - this._delay = value; - return this; - }; - Object.defineProperty(GTweener.prototype, "delay", { - get: function () { - return this._delay; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setDuration = function (value) { - this._duration = value; - return this; - }; - Object.defineProperty(GTweener.prototype, "duration", { - get: function () { - return this._duration; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setBreakpoint = function (value) { - this._breakpoint = value; - return this; - }; - GTweener.prototype.setEase = function (value) { - this._easeType = value; - return this; - }; - GTweener.prototype.setEasePeriod = function (value) { - this._easePeriod = value; - return this; - }; - GTweener.prototype.setEaseOvershootOrAmplitude = function (value) { - this._easeOvershootOrAmplitude = value; - return this; - }; - GTweener.prototype.setRepeat = function (repeat, yoyo) { - this._repeat = repeat; - this._yoyo = yoyo; - return this; - }; - Object.defineProperty(GTweener.prototype, "repeat", { - get: function () { - return this._repeat; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setTimeScale = function (value) { - this._timeScale = value; - return this; - }; - GTweener.prototype.setSnapping = function (value) { - this._snapping = value; - return this; - }; - GTweener.prototype.setTarget = function (value, propType) { - this._target = value; - this._propType = propType; - return this; - }; - Object.defineProperty(GTweener.prototype, "target", { - get: function () { - return this._target; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setUserData = function (value) { - this._userData = value; - return this; - }; - Object.defineProperty(GTweener.prototype, "userData", { - get: function () { - return this._userData; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setPath = function (value) { - this._path = value; - return this; - }; - GTweener.prototype.onUpdate = function (callback, caller) { - this._onUpdate = callback; - this._onUpdateCaller = caller; - return this; - }; - GTweener.prototype.onStart = function (callback, caller) { - this._onStart = callback; - this._onStartCaller = caller; - return this; - }; - GTweener.prototype.onComplete = function (callback, caller) { - this._onComplete = callback; - this._onCompleteCaller = caller; - return this; - }; - Object.defineProperty(GTweener.prototype, "startValue", { - get: function () { - return this._startValue; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "endValue", { - get: function () { - return this._endValue; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "value", { - get: function () { - return this._value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "deltaValue", { - get: function () { - return this._deltaValue; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "normalizedTime", { - get: function () { - return this._normalizedTime; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "completed", { - get: function () { - return this._ended != 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "allCompleted", { - get: function () { - return this._ended == 1; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setPaused = function (paused) { - this._paused = paused; - return this; - }; - GTweener.prototype.seek = function (time) { - if (this._killed) - return; - this._elapsedTime = time; - if (this._elapsedTime < this._delay) { - if (this._started) - this._elapsedTime = this._delay; - else - return; - } - this.update(); - }; - GTweener.prototype.kill = function (complete) { - if (this._killed) - return; - if (complete) { - if (this._ended == 0) { - if (this._breakpoint >= 0) - this._elapsedTime = this._delay + this._breakpoint; - else if (this._repeat >= 0) - this._elapsedTime = this._delay + this._duration * (this._repeat + 1); - else - this._elapsedTime = this._delay + this._duration * 2; - this.update(); - } - this.callCompleteCallback(); - } - this._killed = true; - }; - GTweener.prototype._to = function (start, end, duration) { - this._valueSize = 1; - this._startValue.x = start; - this._endValue.x = end; - this._value.x = start; - this._duration = duration; - return this; - }; - GTweener.prototype._to2 = function (start, start2, end, end2, duration) { - this._valueSize = 2; - this._startValue.x = start; - this._endValue.x = end; - this._startValue.y = start2; - this._endValue.y = end2; - this._value.x = start; - this._value.y = start2; - this._duration = duration; - return this; - }; - GTweener.prototype._to3 = function (start, start2, start3, end, end2, end3, duration) { - this._valueSize = 3; - this._startValue.x = start; - this._endValue.x = end; - this._startValue.y = start2; - this._endValue.y = end2; - this._startValue.z = start3; - this._endValue.z = end3; - this._value.x = start; - this._value.y = start2; - this._value.z = start3; - this._duration = duration; - return this; - }; - GTweener.prototype._to4 = function (start, start2, start3, start4, end, end2, end3, end4, duration) { - this._valueSize = 4; - this._startValue.x = start; - this._endValue.x = end; - this._startValue.y = start2; - this._endValue.y = end2; - this._startValue.z = start3; - this._endValue.z = end3; - this._startValue.w = start4; - this._endValue.w = end4; - this._value.x = start; - this._value.y = start2; - this._value.z = start3; - this._value.w = start4; - this._duration = duration; - return this; - }; - GTweener.prototype._toColor = function (start, end, duration) { - this._valueSize = 4; - this._startValue.color = start; - this._endValue.color = end; - this._value.color = start; - this._duration = duration; - return this; - }; - GTweener.prototype._shake = function (startX, startY, amplitude, duration) { - this._valueSize = 5; - this._startValue.x = startX; - this._startValue.y = startY; - this._startValue.w = amplitude; - this._duration = duration; - return this; - }; - GTweener.prototype._init = function () { - this._delay = 0; - this._duration = 0; - this._breakpoint = -1; - this._easeType = fgui.EaseType.QuadOut; - this._timeScale = 1; - this._easePeriod = 0; - this._easeOvershootOrAmplitude = 1.70158; - this._snapping = false; - this._repeat = 0; - this._yoyo = false; - this._valueSize = 0; - this._started = false; - this._paused = false; - this._killed = false; - this._elapsedTime = 0; - this._normalizedTime = 0; - this._ended = 0; - }; - GTweener.prototype._reset = function () { - this._target = null; - this._propType = null; - this._userData = null; - this._path = null; - this._onStart = this._onUpdate = this._onComplete = null; - this._onStartCaller = this._onUpdateCaller = this._onCompleteCaller = null; - }; - GTweener.prototype._update = function (dt) { - if (this._timeScale != 1) - dt *= this._timeScale; - if (dt == 0) - return; - if (this._ended != 0) { - this.callCompleteCallback(); - this._killed = true; - return; - } - this._elapsedTime += dt; - this.update(); - if (this._ended != 0) { - if (!this._killed) { - this.callCompleteCallback(); - this._killed = true; - } - } - }; - GTweener.prototype.update = function () { - this._ended = 0; - if (this._valueSize == 0) { - if (this._elapsedTime >= this._delay + this._duration) - this._ended = 1; - return; - } - if (!this._started) { - if (this._elapsedTime < this._delay) - return; - this._started = true; - this.callStartCallback(); - if (this._killed) - return; - } - var reversed = false; - var tt = this._elapsedTime - this._delay; - if (this._breakpoint >= 0 && tt >= this._breakpoint) { - tt = this._breakpoint; - this._ended = 2; - } - if (this._repeat != 0) { - var round = Math.floor(tt / this._duration); - tt -= this._duration * round; - if (this._yoyo) - reversed = round % 2 == 1; - if (this._repeat > 0 && this._repeat - round < 0) { - if (this._yoyo) - reversed = this._repeat % 2 == 1; - tt = this._duration; - this._ended = 1; - } - } - else if (tt >= this._duration) { - tt = this._duration; - this._ended = 1; - } - this._normalizedTime = fgui.evaluateEase(this._easeType, reversed ? (this._duration - tt) : tt, this._duration, this._easeOvershootOrAmplitude, this._easePeriod); - this._value.setZero(); - this._deltaValue.setZero(); - if (this._valueSize == 5) { - if (this._ended == 0) { - var r = this._startValue.w * (1 - this._normalizedTime); - var rx = r * (Math.random() > 0.5 ? 1 : -1); - var ry = r * (Math.random() > 0.5 ? 1 : -1); - this._deltaValue.x = rx; - this._deltaValue.y = ry; - this._value.x = this._startValue.x + rx; - this._value.y = this._startValue.y + ry; - } - else { - this._value.x = this._startValue.x; - this._value.y = this._startValue.y; - } - } - else if (this._path) { - var pt = s_vec2; - this._path.getPointAt(this._normalizedTime, pt); - if (this._snapping) { - pt.x = Math.round(pt.x); - pt.y = Math.round(pt.y); - } - this._deltaValue.x = pt.x - this._value.x; - this._deltaValue.y = pt.y - this._value.y; - this._value.x = pt.x; - this._value.y = pt.y; - } - else { - for (var i = 0; i < this._valueSize; i++) { - var n1 = this._startValue.getField(i); - var n2 = this._endValue.getField(i); - var f = n1 + (n2 - n1) * this._normalizedTime; - if (this._snapping) - f = Math.round(f); - this._deltaValue.setField(i, f - this._value.getField(i)); - this._value.setField(i, f); - } - } - if (this._target != null && this._propType != null) { - if (this._propType instanceof Function) { - switch (this._valueSize) { - case 1: - this._propType.call(this._target, this._value.x); - break; - case 2: - this._propType.call(this._target, this._value.x, this._value.y); - break; - case 3: - this._propType.call(this._target, this._value.x, this._value.y, this._value.z); - break; - case 4: - this._propType.call(this._target, this._value.x, this._value.y, this._value.z, this._value.w); - break; - case 5: - this._propType.call(this._target, this._value.color); - break; - case 6: - this._propType.call(this._target, this._value.x, this._value.y); - break; - } - } - else { - if (this._valueSize == 5) - this._target[this._propType] = this._value.color; - else - this._target[this._propType] = this._value.x; - } - } - this.callUpdateCallback(); - }; - GTweener.prototype.callStartCallback = function () { - if (this._onStart != null) { - try { - this._onStart.call(this._onStartCaller, this); - } - catch (err) { - console.log("FairyGUI: error in start callback > " + err); - } - } - }; - GTweener.prototype.callUpdateCallback = function () { - if (this._onUpdate != null) { - try { - this._onUpdate.call(this._onUpdateCaller, this); - } - catch (err) { - console.log("FairyGUI: error in update callback > " + err); - } - } - }; - GTweener.prototype.callCompleteCallback = function () { - if (this._onComplete != null) { - try { - this._onComplete.call(this._onCompleteCaller, this); - } - catch (err) { - console.log("FairyGUI: error in complete callback > " + err); - } - } - }; - return GTweener; - }()); - fgui.GTweener = GTweener; - var s_vec2 = new egret.Point(); -})(fgui || (fgui = {})); - -(function (fgui) { - var TweenManager = (function () { - function TweenManager() { - } - TweenManager.createTween = function () { - if (!_inited) { - egret.startTick(TweenManager.update, null); - _inited = true; - _lastTime = egret.getTimer(); - } - var tweener; - var cnt = _tweenerPool.length; - if (cnt > 0) { - tweener = _tweenerPool.pop(); - } - else - tweener = new fgui.GTweener(); - tweener._init(); - _activeTweens[_totalActiveTweens++] = tweener; - if (_totalActiveTweens == _activeTweens.length) - _activeTweens.length = _activeTweens.length + Math.ceil(_activeTweens.length * 0.5); - return tweener; - }; - TweenManager.isTweening = function (target, propType) { - if (target == null) - return false; - var anyType = propType == null; - for (var i = 0; i < _totalActiveTweens; i++) { - var tweener = _activeTweens[i]; - if (tweener != null && tweener.target == target && !tweener._killed - && (anyType || tweener._propType == propType)) - return true; - } - return false; - }; - TweenManager.killTweens = function (target, completed, propType) { - if (target == null) - return false; - var flag = false; - var cnt = _totalActiveTweens; - var anyType = propType == null; - for (var i = 0; i < cnt; i++) { - var tweener = _activeTweens[i]; - if (tweener != null && tweener.target == target && !tweener._killed - && (anyType || tweener._propType == propType)) { - tweener.kill(completed); - flag = true; - } - } - return flag; - }; - TweenManager.getTween = function (target, propType) { - if (target == null) - return null; - var cnt = _totalActiveTweens; - var anyType = propType == null; - for (var i = 0; i < cnt; i++) { - var tweener = _activeTweens[i]; - if (tweener != null && tweener.target == target && !tweener._killed - && (anyType || tweener._propType == propType)) { - return tweener; - } - } - return null; - }; - TweenManager.update = function (timestamp) { - var dt = timestamp - _lastTime; - _lastTime = timestamp; - dt /= 1000; - var cnt = _totalActiveTweens; - var freePosStart = -1; - var freePosCount = 0; - for (var i = 0; i < cnt; i++) { - var tweener = _activeTweens[i]; - if (tweener == null) { - if (freePosStart == -1) - freePosStart = i; - freePosCount++; - } - else if (tweener._killed) { - tweener._reset(); - _tweenerPool.push(tweener); - _activeTweens[i] = null; - if (freePosStart == -1) - freePosStart = i; - freePosCount++; - } - else { - if ((tweener._target instanceof fgui.GObject) && (tweener._target).isDisposed) - tweener._killed = true; - else if (!tweener._paused) - tweener._update(dt); - if (freePosStart != -1) { - _activeTweens[freePosStart] = tweener; - _activeTweens[i] = null; - freePosStart++; - } - } - } - if (freePosStart >= 0) { - if (_totalActiveTweens != cnt) { - var j = cnt; - cnt = _totalActiveTweens - cnt; - for (i = 0; i < cnt; i++) - _activeTweens[freePosStart++] = _activeTweens[j++]; - } - _totalActiveTweens = freePosStart; - } - return false; - }; - return TweenManager; - }()); - fgui.TweenManager = TweenManager; - var _activeTweens = new Array(30); - var _tweenerPool = new Array(); - var _totalActiveTweens = 0; - var _lastTime = 0; - var _inited; -})(fgui || (fgui = {})); - -(function (fgui) { - var TweenValue = (function () { - function TweenValue() { - this.x = this.y = this.z = this.w = 0; - } - Object.defineProperty(TweenValue.prototype, "color", { - get: function () { - return (this.w << 24) + (this.x << 16) + (this.y << 8) + this.z; - }, - set: function (value) { - this.x = (value & 0xFF0000) >> 16; - this.y = (value & 0x00FF00) >> 8; - this.z = (value & 0x0000FF); - this.w = (value & 0xFF000000) >> 24; - }, - enumerable: true, - configurable: true - }); - TweenValue.prototype.getField = function (index) { - switch (index) { - case 0: - return this.x; - case 1: - return this.y; - case 2: - return this.z; - case 3: - return this.w; - default: - throw new Error("Index out of bounds: " + index); - } - }; - TweenValue.prototype.setField = function (index, value) { - switch (index) { - case 0: - this.x = value; - break; - case 1: - this.y = value; - break; - case 2: - this.z = value; - break; - case 3: - this.w = value; - break; - default: - throw new Error("Index out of bounds: " + index); - } - }; - TweenValue.prototype.setZero = function () { - this.x = this.y = this.z = this.w = 0; - }; - return TweenValue; - }()); - fgui.TweenValue = TweenValue; -})(fgui || (fgui = {})); - -(function (fgui) { - var ByteBuffer = (function (_super_1) { - __extends(ByteBuffer, _super_1); - function ByteBuffer(buffer, bufferExtSize) { - var _this = _super_1.call(this, buffer, bufferExtSize) || this; - _this.version = 0; - return _this; - } - ByteBuffer.prototype.skip = function (count) { - this.position += count; - }; - ByteBuffer.prototype.readBool = function () { - return this.readByte() == 1; - }; - ByteBuffer.prototype.readS = function () { - var index = this.readUnsignedShort(); - if (index == 65534) - return null; - else if (index == 65533) - return ""; - else - return this.stringTable[index]; - }; - ByteBuffer.prototype.readSArray = function (cnt) { - var ret = new Array(cnt); - for (var i = 0; i < cnt; i++) - ret[i] = this.readS(); - return ret; - }; - ByteBuffer.prototype.writeS = function (value) { - var index = this.readUnsignedShort(); - if (index != 65534 && index != 65533) - this.stringTable[index] = value; - }; - ByteBuffer.prototype.readColor = function (hasAlpha) { - var r = this.readUnsignedByte(); - var g = this.readUnsignedByte(); - var b = this.readUnsignedByte(); - var a = this.readUnsignedByte(); - return (hasAlpha ? (a << 24) : 0) + (r << 16) + (g << 8) + b; - }; - ByteBuffer.prototype.readChar = function () { - var i = this.readUnsignedShort(); - return String.fromCharCode(i); - }; - ByteBuffer.prototype.readBuffer = function () { - var count = this.readUnsignedInt(); - var ba = new ByteBuffer(new Uint8Array(this.buffer, this.position, count)); - ba.stringTable = this.stringTable; - ba.version = this.version; - this.position += count; - return ba; - }; - ByteBuffer.prototype.seek = function (indexTablePos, blockIndex) { - var tmp = this.position; - this.position = indexTablePos; - var segCount = this.readByte(); - if (blockIndex < segCount) { - var useShort = this.readByte() == 1; - var newPos; - if (useShort) { - this.position += 2 * blockIndex; - newPos = this.readUnsignedShort(); - } - else { - this.position += 4 * blockIndex; - newPos = this.readUnsignedInt(); - } - if (newPos > 0) { - this.position = indexTablePos + newPos; - return true; - } - else { - this.position = tmp; - return false; - } - } - else { - this.position = tmp; - return false; - } - }; - return ByteBuffer; - }(egret.ByteArray)); - fgui.ByteBuffer = ByteBuffer; -})(fgui || (fgui = {})); - -(function (fgui) { - var ColorMatrix = (function () { - function ColorMatrix(p_brightness, p_contrast, p_saturation, p_hue) { - this.matrix = new Array(LENGTH); - this.reset(); - if (p_brightness !== undefined || p_contrast !== undefined || p_saturation !== undefined || p_hue !== undefined) - this.adjustColor(p_brightness, p_contrast, p_saturation, p_hue); - } - ColorMatrix.prototype.reset = function () { - for (var i = 0; i < LENGTH; i++) { - this.matrix[i] = IDENTITY_MATRIX[i]; - } - }; - ColorMatrix.prototype.invert = function () { - this.multiplyMatrix([-1, 0, 0, 0, 255, - 0, -1, 0, 0, 255, - 0, 0, -1, 0, 255, - 0, 0, 0, 1, 0]); - }; - ColorMatrix.prototype.adjustColor = function (p_brightness, p_contrast, p_saturation, p_hue) { - this.adjustHue(p_hue || 0); - this.adjustContrast(p_contrast || 0); - this.adjustBrightness(p_brightness || 0); - this.adjustSaturation(p_saturation || 0); - }; - ColorMatrix.prototype.adjustBrightness = function (p_val) { - p_val = this.cleanValue(p_val, 1) * 255; - this.multiplyMatrix([ - 1, 0, 0, 0, p_val, - 0, 1, 0, 0, p_val, - 0, 0, 1, 0, p_val, - 0, 0, 0, 1, 0 - ]); - }; - ColorMatrix.prototype.adjustContrast = function (p_val) { - p_val = this.cleanValue(p_val, 1); - var s = p_val + 1; - var o = 128 * (1 - s); - this.multiplyMatrix([ - s, 0, 0, 0, o, - 0, s, 0, 0, o, - 0, 0, s, 0, o, - 0, 0, 0, 1, 0 - ]); - }; - ColorMatrix.prototype.adjustSaturation = function (p_val) { - p_val = this.cleanValue(p_val, 1); - p_val += 1; - var invSat = 1 - p_val; - var invLumR = invSat * LUMA_R; - var invLumG = invSat * LUMA_G; - var invLumB = invSat * LUMA_B; - this.multiplyMatrix([ - (invLumR + p_val), invLumG, invLumB, 0, 0, - invLumR, (invLumG + p_val), invLumB, 0, 0, - invLumR, invLumG, (invLumB + p_val), 0, 0, - 0, 0, 0, 1, 0 - ]); - }; - ColorMatrix.prototype.adjustHue = function (p_val) { - p_val = this.cleanValue(p_val, 1); - p_val *= Math.PI; - var cos = Math.cos(p_val); - var sin = Math.sin(p_val); - this.multiplyMatrix([ - ((LUMA_R + (cos * (1 - LUMA_R))) + (sin * -(LUMA_R))), ((LUMA_G + (cos * -(LUMA_G))) + (sin * -(LUMA_G))), ((LUMA_B + (cos * -(LUMA_B))) + (sin * (1 - LUMA_B))), 0, 0, - ((LUMA_R + (cos * -(LUMA_R))) + (sin * 0.143)), ((LUMA_G + (cos * (1 - LUMA_G))) + (sin * 0.14)), ((LUMA_B + (cos * -(LUMA_B))) + (sin * -0.283)), 0, 0, - ((LUMA_R + (cos * -(LUMA_R))) + (sin * -((1 - LUMA_R)))), ((LUMA_G + (cos * -(LUMA_G))) + (sin * LUMA_G)), ((LUMA_B + (cos * (1 - LUMA_B))) + (sin * LUMA_B)), 0, 0, - 0, 0, 0, 1, 0 - ]); - }; - ColorMatrix.prototype.concat = function (p_matrix) { - if (p_matrix.length != LENGTH) { - return; - } - this.multiplyMatrix(p_matrix); - }; - ColorMatrix.prototype.clone = function () { - var result = new ColorMatrix(); - result.copyMatrix(this.matrix); - return result; - }; - ColorMatrix.prototype.copyMatrix = function (p_matrix) { - var l = LENGTH; - for (var i = 0; i < l; i++) { - this.matrix[i] = p_matrix[i]; - } - }; - ColorMatrix.prototype.multiplyMatrix = function (p_matrix) { - var col = []; - var i = 0; - for (var y = 0; y < 4; ++y) { - for (var x = 0; x < 5; ++x) { - col[i + x] = p_matrix[i] * this.matrix[x] + - p_matrix[i + 1] * this.matrix[x + 5] + - p_matrix[i + 2] * this.matrix[x + 10] + - p_matrix[i + 3] * this.matrix[x + 15] + - (x == 4 ? p_matrix[i + 4] : 0); - } - i += 5; - } - this.copyMatrix(col); - }; - ColorMatrix.prototype.cleanValue = function (p_val, p_limit) { - return Math.min(p_limit, Math.max(-p_limit, p_val)); - }; - return ColorMatrix; - }()); - fgui.ColorMatrix = ColorMatrix; - var IDENTITY_MATRIX = [ - 1, 0, 0, 0, 0, - 0, 1, 0, 0, 0, - 0, 0, 1, 0, 0, - 0, 0, 0, 1, 0 - ]; - var LENGTH = IDENTITY_MATRIX.length; - var LUMA_R = 0.299; - var LUMA_G = 0.587; - var LUMA_B = 0.114; -})(fgui || (fgui = {})); - -(function (fgui) { - var GTimers = (function () { - function GTimers() { - this._enumI = 0; - this._enumCount = 0; - this._lastTime = 0; - this._items = new Array(); - this._itemPool = new Array(); - this._lastTime = egret.getTimer(); - GTimers.time = this._lastTime; - egret.startTick(this.__timer, this); - } - GTimers.prototype.getItem = function () { - if (this._itemPool.length) - return this._itemPool.pop(); - else - return new TimerItem(); - }; - GTimers.prototype.findItem = function (callback, thisObj) { - var len = this._items.length; - for (var i = 0; i < len; i++) { - var item = this._items[i]; - if (item.callback == callback && item.thisObj == thisObj) - return item; - } - return null; - }; - GTimers.prototype.add = function (delayInMiniseconds, repeat, callback, thisObj, callbackParam) { - var item = this.findItem(callback, thisObj); - if (!item) { - item = this.getItem(); - item.callback = callback; - item.hasParam = callback.length == 1; - item.thisObj = thisObj; - this._items.push(item); - } - item.delay = delayInMiniseconds; - item.counter = 0; - item.repeat = repeat; - item.param = callbackParam; - item.end = false; - }; - GTimers.prototype.callLater = function (callback, thisObj, callbackParam) { - this.add(1, 1, callback, thisObj, callbackParam); - }; - GTimers.prototype.callDelay = function (delay, callback, thisObj, callbackParam) { - this.add(delay, 1, callback, thisObj, callbackParam); - }; - GTimers.prototype.exists = function (callback, thisObj) { - var item = this.findItem(callback, thisObj); - return item != null; - }; - GTimers.prototype.remove = function (callback, thisObj) { - var item = this.findItem(callback, thisObj); - if (item) { - var i = this._items.indexOf(item); - this._items.splice(i, 1); - if (i < this._enumI) - this._enumI--; - this._enumCount--; - item.reset(); - this._itemPool.push(item); - } - }; - GTimers.prototype.__timer = function (timeStamp) { - GTimers.time = timeStamp; - GTimers.deltaTime = timeStamp - this._lastTime; - this._lastTime = timeStamp; - this._enumI = 0; - this._enumCount = this._items.length; - while (this._enumI < this._enumCount) { - var item = this._items[this._enumI]; - this._enumI++; - if (item.advance(GTimers.deltaTime)) { - if (item.end) { - this._enumI--; - this._enumCount--; - this._items.splice(this._enumI, 1); - } - if (item.hasParam) - item.callback.call(item.thisObj, item.param); - else - item.callback.call(item.thisObj); - if (item.end) { - item.reset(); - this._itemPool.push(item); - } - } - } - return false; - }; - GTimers.deltaTime = 0; - GTimers.time = 0; - GTimers.inst = new GTimers(); - return GTimers; - }()); - fgui.GTimers = GTimers; - var TimerItem = (function () { - function TimerItem() { - this.delay = 0; - this.counter = 0; - this.repeat = 0; - } - TimerItem.prototype.advance = function (elapsed) { - this.counter += elapsed; - if (this.counter >= this.delay) { - this.counter -= this.delay; - if (this.counter > this.delay) - this.counter = this.delay; - if (this.repeat > 0) { - this.repeat--; - if (this.repeat == 0) - this.end = true; - } - return true; - } - else - return false; - }; - TimerItem.prototype.reset = function () { - this.callback = null; - this.thisObj = null; - this.param = null; - }; - return TimerItem; - }()); -})(fgui || (fgui = {})); - -(function (fgui) { - var UBBParser = (function () { - function UBBParser() { - this._readPos = 0; - this.smallFontSize = 12; - this.normalFontSize = 14; - this.largeFontSize = 16; - this.defaultImgWidth = 0; - this.defaultImgHeight = 0; - this._handlers = {}; - this._handlers["url"] = this.onTag_URL; - this._handlers["img"] = this.onTag_IMG; - this._handlers["b"] = this.onTag_Simple; - this._handlers["i"] = this.onTag_Simple; - this._handlers["u"] = this.onTag_Simple; - this._handlers["sup"] = this.onTag_Simple; - this._handlers["sub"] = this.onTag_Simple; - this._handlers["color"] = this.onTag_COLOR; - this._handlers["font"] = this.onTag_FONT; - this._handlers["size"] = this.onTag_SIZE; - } - UBBParser.prototype.onTag_URL = function (tagName, end, attr) { - if (!end) { - if (attr != null) - return ""; - else { - var href = this.getTagText(); - return ""; - } - } - else - return ""; - }; - UBBParser.prototype.onTag_IMG = function (tagName, end, attr) { - if (!end) { - var src = this.getTagText(true); - if (!src) - return null; - if (this.defaultImgWidth) - return ""; - else - return ""; - } - else - return null; - }; - UBBParser.prototype.onTag_Simple = function (tagName, end, attr) { - return end ? ("") : ("<" + tagName + ">"); - }; - UBBParser.prototype.onTag_COLOR = function (tagName, end, attr) { - if (!end) - return ""; - else - return ""; - }; - UBBParser.prototype.onTag_FONT = function (tagName, end, attr) { - if (!end) - return ""; - else - return ""; - }; - UBBParser.prototype.onTag_SIZE = function (tagName, end, attr) { - if (!end) { - if (attr == "normal") - attr = "" + this.normalFontSize; - else if (attr == "small") - attr = "" + this.smallFontSize; - else if (attr == "large") - attr = "" + this.largeFontSize; - else if (attr.length && attr.charAt(0) == "+") - attr = "" + (this.smallFontSize + parseInt(attr.substr(1))); - else if (attr.length && attr.charAt(0) == "-") - attr = "" + (this.smallFontSize - parseInt(attr.substr(1))); - return ""; - } - else - return ""; - }; - UBBParser.prototype.getTagText = function (remove) { - if (remove === void 0) { remove = false; } - var pos1 = this._readPos; - var pos2; - var result = ""; - while ((pos2 = this._text.indexOf("[", pos1)) != -1) { - if (this._text.charCodeAt(pos2 - 1) == 92) { - result += this._text.substring(pos1, pos2 - 1); - result += "["; - pos1 = pos2 + 1; - } - else { - result += this._text.substring(pos1, pos2); - break; - } - } - if (pos2 == -1) - return null; - if (remove) - this._readPos = pos2; - return result; - }; - UBBParser.prototype.parse = function (text, remove) { - this._text = text; - var pos1 = 0, pos2, pos3; - var end; - var tag, attr; - var repl; - var func; - var result = ""; - while ((pos2 = this._text.indexOf("[", pos1)) != -1) { - if (pos2 > 0 && this._text.charCodeAt(pos2 - 1) == 92) { - result += this._text.substring(pos1, pos2 - 1); - result += "["; - pos1 = pos2 + 1; - continue; - } - result += this._text.substring(pos1, pos2); - pos1 = pos2; - pos2 = this._text.indexOf("]", pos1); - if (pos2 == -1) - break; - end = this._text.charAt(pos1 + 1) == '/'; - tag = this._text.substring(end ? pos1 + 2 : pos1 + 1, pos2); - this._readPos = pos2 + 1; - attr = null; - repl = null; - pos3 = tag.indexOf("="); - if (pos3 != -1) { - attr = tag.substring(pos3 + 1); - tag = tag.substring(0, pos3); - } - tag = tag.toLowerCase(); - func = this._handlers[tag]; - if (func != null) { - if (!remove) { - repl = func.call(this, tag, end, attr); - if (repl != null) - result += repl; - } - } - else - result += this._text.substring(pos1, this._readPos); - pos1 = this._readPos; - } - if (pos1 < this._text.length) - result += this._text.substr(pos1); - this._text = null; - return result; - }; - UBBParser.inst = new UBBParser(); - return UBBParser; - }()); - fgui.UBBParser = UBBParser; -})(fgui || (fgui = {})); - -(function (fgui) { - var ToolSet = (function () { - function ToolSet() { - } - ToolSet.startsWith = function (source, str, ignoreCase) { - if (!source) - return false; - else if (source.length < str.length) - return false; - else { - source = source.substring(0, str.length); - if (!ignoreCase) - return source == str; - else - return source.toLowerCase() == str.toLowerCase(); - } - }; - ToolSet.trimRight = function (targetString) { - var tempChar = ""; - for (var i = targetString.length - 1; i >= 0; i--) { - tempChar = targetString.charAt(i); - if (tempChar != " " && tempChar != "\n" && tempChar != "\r") { - break; - } - } - return targetString.substring(0, i + 1); - }; - ToolSet.convertToHtmlColor = function (argb, hasAlpha) { - var alpha; - if (hasAlpha) - alpha = (argb >> 24 & 0xFF).toString(16); - else - alpha = ""; - var red = (argb >> 16 & 0xFF).toString(16); - var green = (argb >> 8 & 0xFF).toString(16); - var blue = (argb & 0xFF).toString(16); - if (alpha.length == 1) - alpha = "0" + alpha; - if (red.length == 1) - red = "0" + red; - if (green.length == 1) - green = "0" + green; - if (blue.length == 1) - blue = "0" + blue; - return "#" + alpha + red + green + blue; - }; - ToolSet.convertFromHtmlColor = function (str, hasAlpha) { - if (str.length < 1) - return 0; - if (str.charAt(0) == "#") - str = str.substr(1); - if (str.length == 8) - return (parseInt(str.substr(0, 2), 16) << 24) + parseInt(str.substr(2), 16); - else if (hasAlpha) - return 0xFF000000 + parseInt(str, 16); - else - return parseInt(str, 16); - }; - ToolSet.displayObjectToGObject = function (obj) { - while (obj && !(obj instanceof egret.Stage)) { - if (obj["$owner"]) - return fgui.GObject.cast(obj); - obj = obj.parent; - } - return null; - }; - ToolSet.encodeHTML = function (str) { - if (!str) - return ""; - else - return str.replace(/&/g, "&").replace(//g, ">").replace(/'/g, "'").replace(/"/g, """); - }; - ToolSet.clamp = function (value, min, max) { - if (value < min) - value = min; - else if (value > max) - value = max; - return value; - }; - ToolSet.clamp01 = function (value) { - if (value > 1) - value = 1; - else if (value < 0) - value = 0; - return value; - }; - ToolSet.lerp = function (start, end, percent) { - return (start + percent * (end - start)); - }; - ToolSet.repeat = function (t, length) { - return t - Math.floor(t / length) * length; - }; - ToolSet.distance = function (x1, y1, x2, y2) { - return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)); - }; - ToolSet.fillPath = function (ctx, points, px, py) { - var cnt = points.length; - ctx.moveTo(points[0] + px, points[1] + py); - for (var i = 2; i < cnt; i += 2) - ctx.lineTo(points[i] + px, points[i + 1] + py); - ctx.lineTo(points[0] + px, points[1] + py); - }; - ToolSet.setColorFilter = function (obj, color) { - var filter = obj.$_colorFilter_; - var filters = obj.filters; - var toApplyColor; - var toApplyGray; - var tp = typeof (color); - if (tp == "boolean") { - toApplyColor = filter ? filter.$_color_ : null; - toApplyGray = color; - } - else { - toApplyColor = color == 0xFFFFFF ? null : color; - toApplyGray = filter ? filter.$_grayed_ : false; - } - if ((!toApplyColor && toApplyColor !== 0) && !toApplyGray) { - if (filters && filter) { - var i = filters.indexOf(filter); - if (i != -1) { - filters.splice(i, 1); - if (filters.length > 0) - obj.filters = filters; - else - obj.filters = null; - } - } - return; - } - if (!filter) { - filter = new egret.ColorMatrixFilter(); - obj.$_colorFilter_ = filter; - } - if (!filters) - filters = [filter]; - else { - var i_1 = filters.indexOf(filter); - if (i_1 == -1) - filters.push(filter); - } - obj.filters = filters; - filter.$_color_ = toApplyColor; - filter.$_grayed_ = toApplyGray; - var mat = filter.matrix; - if (toApplyGray) { - for (var i_2 = 0; i_2 < 20; i_2++) - mat[i_2] = grayScaleMatrix[i_2]; - } - else if (toApplyColor instanceof Array) { - getColorMatrix(toApplyColor[0], toApplyColor[1], toApplyColor[2], toApplyColor[3], mat); - } - else { - for (var i_3 = 0; i_3 < 20; i_3++) { - mat[i_3] = (i_3 == 0 || i_3 == 6 || i_3 == 12 || i_3 == 18) ? 1 : 0; - } - mat[0] = ((color >> 16) & 0xFF) / 255; - mat[6] = ((color >> 8) & 0xFF) / 255; - mat[12] = (color & 0xFF) / 255; - } - filter.matrix = mat; - }; - return ToolSet; - }()); - fgui.ToolSet = ToolSet; - var grayScaleMatrix = [ - 0.3, 0.6, 0, 0, 0, - 0.3, 0.6, 0, 0, 0, - 0.3, 0.6, 0, 0, 0, - 0, 0, 0, 1, 0 - ]; - var helper = new fgui.ColorMatrix(); - function getColorMatrix(p_brightness, p_contrast, p_saturation, p_hue, result) { - if (!result) - result = new Array(fgui.ColorMatrix.length); - helper.reset(); - helper.adjustColor(p_brightness, p_contrast, p_saturation, p_hue); - helper.matrix.forEach(function (e, i) { return result[i] = e; }); - } -})(fgui || (fgui = {})); diff --git a/demo/libs/fairygui/fairygui.min.js b/demo/libs/fairygui/fairygui.min.js deleted file mode 100644 index 180e2cf7..00000000 --- a/demo/libs/fairygui/fairygui.min.js +++ /dev/null @@ -1 +0,0 @@ -window.fgui={},window.fairygui=window.fgui,window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();var __awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(o,r){function s(t){try{h(n.next(t))}catch(t){r(t)}}function a(t){try{h(n.throw(t))}catch(t){r(t)}}function h(t){t.done?o(t.value):new i(function(e){e(t.value)}).then(s,a)}h((n=n.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var i,n,o,r,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(o=2&r[0]?n.return:r[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,r[1])).done)return o;switch(n=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,n=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===r[0]||2===r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]0){for(var i=0;i0){for(n=this._objectPool.length-i.listItemCount-1,o=0;o=s)return}t.GTimers.inst.remove(this.run,this);var h=this._objectPool[0];this._itemList.length=0,this._objectPool.length=0,null!=this.callback&&this.callback.call(this.callbackObj,h)},e}();t.AsyncOperation=e}(fgui||(fgui={})),function(t){var e=0,i=function(i){function n(){var t=i.call(this)||this;return t._pageIds=[],t._pageNames=[],t._selectedIndex=-1,t._previousIndex=-1,t}return __extends(n,i),n.prototype.dispose=function(){},Object.defineProperty(n.prototype,"selectedIndex",{get:function(){return this._selectedIndex},set:function(e){if(this._selectedIndex!=e){if(e>this._pageIds.length-1)throw"index out of bounds: "+e;this.changing=!0,this._previousIndex=this._selectedIndex,this._selectedIndex=e,this.parent.applyController(this),this.dispatchEvent(new t.StateChangeEvent(t.StateChangeEvent.CHANGED)),this.changing=!1}},enumerable:!0,configurable:!0}),n.prototype.setSelectedIndex=function(t){if(this._selectedIndex!=t){if(t>this._pageIds.length-1)throw"index out of bounds: "+t;this.changing=!0,this._previousIndex=this._selectedIndex,this._selectedIndex=t,this.parent.applyController(this),this.changing=!1}},Object.defineProperty(n.prototype,"previsousIndex",{get:function(){return this._previousIndex},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectedPage",{get:function(){return-1==this._selectedIndex?null:this._pageNames[this._selectedIndex]},set:function(t){var e=this._pageNames.indexOf(t);-1==e&&(e=0),this.selectedIndex=e},enumerable:!0,configurable:!0}),n.prototype.setSelectedPage=function(t){var e=this._pageNames.indexOf(t);-1==e&&(e=0),this.setSelectedIndex(e)},Object.defineProperty(n.prototype,"previousPage",{get:function(){return-1==this._previousIndex?null:this._pageNames[this._previousIndex]},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"pageCount",{get:function(){return this._pageIds.length},enumerable:!0,configurable:!0}),n.prototype.getPageName=function(t){return this._pageNames[t]},n.prototype.addPage=function(t){this.addPageAt(t||"",this._pageIds.length)},n.prototype.addPageAt=function(t,i){var n=""+e++;i==this._pageIds.length?(this._pageIds.push(n),this._pageNames.push(t)):(this._pageIds.splice(i,0,n),this._pageNames.splice(i,0,t))},n.prototype.removePage=function(t){var e=this._pageNames.indexOf(t);-1!=e&&(this._pageIds.splice(e,1),this._pageNames.splice(e,1),this._selectedIndex>=this._pageIds.length?this.selectedIndex=this._selectedIndex-1:this.parent.applyController(this))},n.prototype.removePageAt=function(t){void 0===t&&(t=0),this._pageIds.splice(t,1),this._pageNames.splice(t,1),this._selectedIndex>=this._pageIds.length?this.selectedIndex=this._selectedIndex-1:this.parent.applyController(this)},n.prototype.clearPages=function(){this._pageIds.length=0,this._pageNames.length=0,-1!=this._selectedIndex?this.selectedIndex=-1:this.parent.applyController(this)},n.prototype.hasPage=function(t){return-1!=this._pageNames.indexOf(t)},n.prototype.getPageIndexById=function(t){return this._pageIds.indexOf(t)},n.prototype.getPageIdByName=function(t){var e=this._pageNames.indexOf(t);return-1!=e?this._pageIds[e]:null},n.prototype.getPageNameById=function(t){var e=this._pageIds.indexOf(t);return-1!=e?this._pageNames[e]:null},n.prototype.getPageId=function(t){return void 0===t&&(t=0),this._pageIds[t]},Object.defineProperty(n.prototype,"selectedPageId",{get:function(){return-1==this._selectedIndex?null:this._pageIds[this._selectedIndex]},set:function(t){var e=this._pageIds.indexOf(t);this.selectedIndex=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"oppositePageId",{set:function(t){this._pageIds.indexOf(t)>0?this.selectedIndex=0:this._pageIds.length>1&&(this.selectedIndex=1)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"previousPageId",{get:function(){return-1==this._previousIndex?null:this._pageIds[this._previousIndex]},enumerable:!0,configurable:!0}),n.prototype.runActions=function(){if(this._actions)for(var t=this._actions.length,e=0;e=2)switch(e.readByte()){case 1:s=e.readShort();break;case 2:-1==(s=this._pageNames.indexOf(t.UIPackage.branch))&&(s=0);break;case 3:-1==(s=this._pageNames.indexOf(t.UIPackage.getVar(e.readS())))&&(s=0)}if(e.seek(o,2),(r=e.readShort())>0)for(this._actions||(this._actions=new Array),i=0;i0?this._selectedIndex=s:this._selectedIndex=-1},n}(egret.EventDispatcher);t.Controller=i}(fgui||(fgui={})),function(t){var e=function(){function e(){this._agent=new t.GLoader,this._agent.draggable=!0,this._agent.touchable=!1,this._agent.setSize(100,100),this._agent.setPivot(.5,.5,!0),this._agent.align=t.AlignType.Center,this._agent.verticalAlign=t.VertAlignType.Middle,this._agent.sortingOrder=1e6,this._agent.addEventListener(t.DragEvent.DRAG_END,this.__dragEnd,this)}return Object.defineProperty(e,"inst",{get:function(){return null==e._inst&&(e._inst=new e),e._inst},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dragAgent",{get:function(){return this._agent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dragging",{get:function(){return null!=this._agent.parent},enumerable:!0,configurable:!0}),e.prototype.startDrag=function(e,i,n,o){if(!this._agent.parent){this._sourceData=n,this._agent.url=i,t.GRoot.inst.addChild(this._agent);var r=t.GRoot.inst.globalToLocal(t.GRoot.mouseX,t.GRoot.mouseY);this._agent.setXY(r.x,r.y),this._agent.startDrag(o)}},e.prototype.cancel=function(){this._agent.parent&&(this._agent.stopDrag(),t.GRoot.inst.removeChild(this._agent),this._sourceData=null)},e.prototype.__dragEnd=function(e){if(null!=this._agent.parent){t.GRoot.inst.removeChild(this._agent);var i=this._sourceData;this._sourceData=null;for(var n=t.GRoot.inst.getObjectUnderPoint(e.stageX,e.stageY);n;){if(n.hasEventListener(t.DropEvent.DROP)){var o=new t.DropEvent(t.DropEvent.DROP,i);return n.requestFocus(),void n.dispatchEvent(o)}n=n.parent}}},e}();t.DragDropManager=e}(fgui||(fgui={})),function(t){!function(t){t[t.Common=0]="Common",t[t.Check=1]="Check",t[t.Radio=2]="Radio"}(t.ButtonMode||(t.ButtonMode={})),function(t){t[t.None=0]="None",t[t.Both=1]="Both",t[t.Height=2]="Height"}(t.AutoSizeType||(t.AutoSizeType={})),function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right"}(t.AlignType||(t.AlignType={})),function(t){t[t.Top=0]="Top",t[t.Middle=1]="Middle",t[t.Bottom=2]="Bottom"}(t.VertAlignType||(t.VertAlignType={})),function(t){t[t.None=0]="None",t[t.Scale=1]="Scale",t[t.ScaleMatchHeight=2]="ScaleMatchHeight",t[t.ScaleMatchWidth=3]="ScaleMatchWidth",t[t.ScaleFree=4]="ScaleFree",t[t.ScaleNoBorder=5]="ScaleNoBorder"}(t.LoaderFillType||(t.LoaderFillType={})),function(t){t[t.SingleColumn=0]="SingleColumn",t[t.SingleRow=1]="SingleRow",t[t.FlowHorizontal=2]="FlowHorizontal",t[t.FlowVertical=3]="FlowVertical",t[t.Pagination=4]="Pagination"}(t.ListLayoutType||(t.ListLayoutType={})),function(t){t[t.Single=0]="Single",t[t.Multiple=1]="Multiple",t[t.Multiple_SingleClick=2]="Multiple_SingleClick",t[t.None=3]="None"}(t.ListSelectionMode||(t.ListSelectionMode={})),function(t){t[t.Visible=0]="Visible",t[t.Hidden=1]="Hidden",t[t.Scroll=2]="Scroll"}(t.OverflowType||(t.OverflowType={})),function(t){t[t.Image=0]="Image",t[t.MovieClip=1]="MovieClip",t[t.Sound=2]="Sound",t[t.Component=3]="Component",t[t.Atlas=4]="Atlas",t[t.Font=5]="Font",t[t.Swf=6]="Swf",t[t.Misc=7]="Misc",t[t.Unknown=8]="Unknown",t[t.Spine=9]="Spine",t[t.DragonBones=10]="DragonBones"}(t.PackageItemType||(t.PackageItemType={})),function(t){t[t.Image=0]="Image",t[t.MovieClip=1]="MovieClip",t[t.Swf=2]="Swf",t[t.Graph=3]="Graph",t[t.Loader=4]="Loader",t[t.Group=5]="Group",t[t.Text=6]="Text",t[t.RichText=7]="RichText",t[t.InputText=8]="InputText",t[t.Component=9]="Component",t[t.List=10]="List",t[t.Label=11]="Label",t[t.Button=12]="Button",t[t.ComboBox=13]="ComboBox",t[t.ProgressBar=14]="ProgressBar",t[t.Slider=15]="Slider",t[t.ScrollBar=16]="ScrollBar",t[t.Tree=17]="Tree",t[t.Loader3D=18]="Loader3D"}(t.ObjectType||(t.ObjectType={})),function(t){t[t.Percent=0]="Percent",t[t.ValueAndMax=1]="ValueAndMax",t[t.Value=2]="Value",t[t.Max=3]="Max"}(t.ProgressTitleType||(t.ProgressTitleType={})),function(t){t[t.Default=0]="Default",t[t.Visible=1]="Visible",t[t.Auto=2]="Auto",t[t.Hidden=3]="Hidden"}(t.ScrollBarDisplayType||(t.ScrollBarDisplayType={})),function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical",t[t.Both=2]="Both"}(t.ScrollType||(t.ScrollType={})),function(t){t[t.None=0]="None",t[t.Horizontal=1]="Horizontal",t[t.Vertical=2]="Vertical",t[t.Both=3]="Both"}(t.FlipType||(t.FlipType={})),function(t){t[t.Ascent=0]="Ascent",t[t.Descent=1]="Descent",t[t.Arch=2]="Arch"}(t.ChildrenRenderOrder||(t.ChildrenRenderOrder={})),function(t){t[t.None=0]="None",t[t.Horizontal=1]="Horizontal",t[t.Vertical=2]="Vertical"}(t.GroupLayoutType||(t.GroupLayoutType={})),function(t){t[t.Auto=0]="Auto",t[t.Up=1]="Up",t[t.Down=2]="Down"}(t.PopupDirection||(t.PopupDirection={})),function(t){t[t.Left_Left=0]="Left_Left",t[t.Left_Center=1]="Left_Center",t[t.Left_Right=2]="Left_Right",t[t.Center_Center=3]="Center_Center",t[t.Right_Left=4]="Right_Left",t[t.Right_Center=5]="Right_Center",t[t.Right_Right=6]="Right_Right",t[t.Top_Top=7]="Top_Top",t[t.Top_Middle=8]="Top_Middle",t[t.Top_Bottom=9]="Top_Bottom",t[t.Middle_Middle=10]="Middle_Middle",t[t.Bottom_Top=11]="Bottom_Top",t[t.Bottom_Middle=12]="Bottom_Middle",t[t.Bottom_Bottom=13]="Bottom_Bottom",t[t.Width=14]="Width",t[t.Height=15]="Height",t[t.LeftExt_Left=16]="LeftExt_Left",t[t.LeftExt_Right=17]="LeftExt_Right",t[t.RightExt_Left=18]="RightExt_Left",t[t.RightExt_Right=19]="RightExt_Right",t[t.TopExt_Top=20]="TopExt_Top",t[t.TopExt_Bottom=21]="TopExt_Bottom",t[t.BottomExt_Top=22]="BottomExt_Top",t[t.BottomExt_Bottom=23]="BottomExt_Bottom",t[t.Size=24]="Size"}(t.RelationType||(t.RelationType={})),function(t){t[t.None=0]="None",t[t.Horizontal=1]="Horizontal",t[t.Vertical=2]="Vertical",t[t.Radial90=3]="Radial90",t[t.Radial180=4]="Radial180",t[t.Radial360=5]="Radial360"}(t.FillMethod||(t.FillMethod={})),function(t){t[t.Top=0]="Top",t[t.Bottom=1]="Bottom",t[t.Left=2]="Left",t[t.Right=3]="Right",t[t.TopLeft=0]="TopLeft",t[t.TopRight=1]="TopRight",t[t.BottomLeft=2]="BottomLeft",t[t.BottomRight=3]="BottomRight"}(t.FillOrigin||(t.FillOrigin={})),function(t){t[t.TopLeft=0]="TopLeft",t[t.TopRight=1]="TopRight",t[t.BottomLeft=2]="BottomLeft",t[t.BottomRight=3]="BottomRight"}(t.FillOrigin90||(t.FillOrigin90={})),function(t){t[t.Text=0]="Text",t[t.Icon=1]="Icon",t[t.Color=2]="Color",t[t.OutlineColor=3]="OutlineColor",t[t.Playing=4]="Playing",t[t.Frame=5]="Frame",t[t.DeltaTime=6]="DeltaTime",t[t.TimeScale=7]="TimeScale",t[t.FontSize=8]="FontSize",t[t.Selected=9]="Selected"}(t.ObjectPropID||(t.ObjectPropID={}))}(fgui||(fgui={})),function(t){var e=function(e){function h(){var i=e.call(this)||this;return i._x=0,i._y=0,i._alpha=1,i._rotation=0,i._visible=!0,i._touchable=!0,i._scaleX=1,i._scaleY=1,i._skewX=0,i._skewY=0,i._pivotX=0,i._pivotY=0,i._pivotOffsetX=0,i._pivotOffsetY=0,i._sortingOrder=0,i._internalVisible=!0,i._disposed=!1,i.sourceWidth=0,i.sourceHeight=0,i.initWidth=0,i.initHeight=0,i.minWidth=0,i.minHeight=0,i.maxWidth=0,i.maxHeight=0,i._width=0,i._height=0,i._rawWidth=0,i._rawHeight=0,i._sizePercentInGroup=0,i._id=""+n++,i._name="",i.createDisplayObject(),i._relations=new t.Relations(i),i._gears=new Array(10),i}return __extends(h,e),Object.defineProperty(h.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"name",{get:function(){return this._name},set:function(t){this._name=t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"x",{get:function(){return this._x},set:function(t){this.setXY(t,this._y)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"y",{get:function(){return this._y},set:function(t){this.setXY(this._x,t)},enumerable:!0,configurable:!0}),h.prototype.setXY=function(e,n){if(this._x!=e||this._y!=n){var o=e-this._x,s=n-this._y;this._x=e,this._y=n,this.handleXYChanged(),this instanceof t.GGroup&&this.moveChildren(o,s),this.updateGear(1),!this._parent||this._parent instanceof t.GList||(this._parent.setBoundsChangedFlag(),this._group&&this._group.setBoundsChangedFlag(!0),this.dispatchEventWith(h.XY_CHANGED)),h.draggingObject!=this||i||this.localToGlobalRect(0,0,this._width,this._height,r)}},Object.defineProperty(h.prototype,"xMin",{get:function(){return this._pivotAsAnchor?this._x-this._width*this._pivotX:this._x},set:function(t){this._pivotAsAnchor?this.setXY(t+this._width*this._pivotX,this._y):this.setXY(t,this._y)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"yMin",{get:function(){return this._pivotAsAnchor?this._y-this._height*this._pivotY:this._y},set:function(t){this._pivotAsAnchor?this.setXY(this._x,t+this._height*this._pivotY):this.setXY(this._x,t)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"pixelSnapping",{get:function(){return this._pixelSnapping},set:function(t){this._pixelSnapping!=t&&(this._pixelSnapping=t,this.handleXYChanged())},enumerable:!0,configurable:!0}),h.prototype.center=function(e){var i;i=this._parent?this.parent:this.root,this.setXY((i.width-this._width)/2,(i.height-this._height)/2),e&&(this.addRelation(i,t.RelationType.Center_Center),this.addRelation(i,t.RelationType.Middle_Middle))},Object.defineProperty(h.prototype,"width",{get:function(){return this.ensureSizeCorrect(),this._relations.sizeDirty&&this._relations.ensureRelationsSizeCorrect(),this._width},set:function(t){this.setSize(t,this._rawHeight)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"height",{get:function(){return this.ensureSizeCorrect(),this._relations.sizeDirty&&this._relations.ensureRelationsSizeCorrect(),this._height},set:function(t){this.setSize(this._rawWidth,t)},enumerable:!0,configurable:!0}),h.prototype.setSize=function(e,i,n){if(this._rawWidth!=e||this._rawHeight!=i){this._rawWidth=e,this._rawHeight=i,e0&&e>this.maxWidth&&(e=this.maxWidth),this.maxHeight>0&&i>this.maxHeight&&(i=this.maxHeight);var o=e-this._width,r=i-this._height;this._width=e,this._height=i,this.handleSizeChanged(),0==this._pivotX&&0==this._pivotY||(this._pivotAsAnchor?this.applyPivot():(n||this.setXY(this.x-this._pivotX*o,this.y-this._pivotY*r),this.updatePivotOffset())),this instanceof t.GGroup&&this.resizeChildren(o,r),this.updateGear(2),this._parent&&(this._relations.onOwnerSizeChanged(o,r,this._pivotAsAnchor||!n),this._parent.setBoundsChangedFlag(),this._group&&this._group.setBoundsChangedFlag()),this.dispatchEventWith(h.SIZE_CHANGED)}},h.prototype.makeFullScreen=function(){this.setSize(t.GRoot.inst.width,t.GRoot.inst.height)},h.prototype.ensureSizeCorrect=function(){},Object.defineProperty(h.prototype,"actualWidth",{get:function(){return this.width*Math.abs(this._scaleX)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"actualHeight",{get:function(){return this.height*Math.abs(this._scaleY)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"scaleX",{get:function(){return this._scaleX},set:function(t){this.setScale(t,this._scaleY)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"scaleY",{get:function(){return this._scaleY},set:function(t){this.setScale(this._scaleX,t)},enumerable:!0,configurable:!0}),h.prototype.setScale=function(t,e){this._scaleX==t&&this._scaleY==e||(this._scaleX=t,this._scaleY=e,this.handleScaleChanged(),this.applyPivot(),this.updateGear(2))},Object.defineProperty(h.prototype,"skewX",{get:function(){return this._skewX},set:function(t){this.setSkew(t,this._skewY)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"skewY",{get:function(){return this._skewY},set:function(t){this.setSkew(this._skewX,t)},enumerable:!0,configurable:!0}),h.prototype.setSkew=function(t,e){this._skewX==t&&this._skewY==e||(this._skewX=t,this._skewY=e,this._displayObject&&(this._displayObject.skewX=t,this._displayObject.skewY=e),this.applyPivot())},Object.defineProperty(h.prototype,"pivotX",{get:function(){return this._pivotX},set:function(t){this.setPivot(t,this._pivotY)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"pivotY",{get:function(){return this._pivotY},set:function(t){this.setPivot(this._pivotX,t)},enumerable:!0,configurable:!0}),h.prototype.setPivot=function(t,e,i){this._pivotX==t&&this._pivotY==e&&this._pivotAsAnchor==i||(this._pivotX=t,this._pivotY=e,this._pivotAsAnchor=i,this.updatePivotOffset(),this.handleXYChanged())},Object.defineProperty(h.prototype,"pivotAsAnchor",{get:function(){return this._pivotAsAnchor},enumerable:!0,configurable:!0}),h.prototype.internalSetPivot=function(t,e,i){this._pivotX=t,this._pivotY=e,this._pivotAsAnchor=i,i&&this.handleXYChanged()},h.prototype.updatePivotOffset=function(){if(this._displayObject)if(0!=this._pivotX||0!=this._pivotY){var t=this._pivotX*this._width,e=this._pivotY*this._height,i=this._displayObject.matrix.transformPoint(t,e,s);this._pivotOffsetX=this._pivotX*this._width-(i.x-this._displayObject.x),this._pivotOffsetY=this._pivotY*this._height-(i.y-this._displayObject.y)}else this._pivotOffsetX=0,this._pivotOffsetY=0},h.prototype.applyPivot=function(){0==this._pivotX&&0==this._pivotY||(this.updatePivotOffset(),this.handleXYChanged())},Object.defineProperty(h.prototype,"touchable",{get:function(){return this._touchable},set:function(e){if(this._touchable!=e){if(this._touchable=e,this.updateGear(3),this instanceof t.GImage||this instanceof t.GMovieClip||this instanceof t.GTextField&&!(this instanceof t.GTextInput)&&!(this instanceof t.GRichTextField))return;this._displayObject&&(this._displayObject.touchEnabled=this._touchable,this._displayObject instanceof egret.DisplayObjectContainer&&(this._displayObject.touchChildren=this._touchable))}},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"grayed",{get:function(){return this._grayed},set:function(t){this._grayed!=t&&(this._grayed=t,this.handleGrayedChanged(),this.updateGear(3))},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"enabled",{get:function(){return!this._grayed&&this._touchable},set:function(t){this.grayed=!t,this.touchable=t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"rotation",{get:function(){return this._rotation},set:function(t){this._rotation!=t&&(this._rotation=t,this._displayObject&&(this._displayObject.rotation=this.normalizeRotation),this.applyPivot(),this.updateGear(3))},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"normalizeRotation",{get:function(){var t=this._rotation%360;return t>180?t-=360:t<-180&&(t+=360),t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!=t&&(this._alpha=t,this.handleAlphaChanged(),this.updateGear(3))},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"visible",{get:function(){return this._visible},set:function(t){this._visible!=t&&(this._visible=t,this.handleVisibleChanged(),this._parent&&this._parent.setBoundsChangedFlag(),this._group&&this._group.excludeInvisibles&&this._group.setBoundsChangedFlag())},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"internalVisible",{get:function(){return this._internalVisible&&(!this._group||this._group.internalVisible)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"internalVisible2",{get:function(){return this._visible&&(!this._group||this._group.internalVisible2)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"internalVisible3",{get:function(){return this._visible&&this._internalVisible},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"sortingOrder",{get:function(){return this._sortingOrder},set:function(t){if(t<0&&(t=0),this._sortingOrder!=t){var e=this._sortingOrder;this._sortingOrder=t,this._parent&&this._parent.childSortingOrderChanged(this,e,this._sortingOrder)}},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"focused",{get:function(){return this.root.focus==this},enumerable:!0,configurable:!0}),h.prototype.requestFocus=function(){this.root.focus=this},Object.defineProperty(h.prototype,"tooltips",{get:function(){return this._tooltips},set:function(t){this._tooltips=t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"blendMode",{get:function(){return this._displayObject.blendMode},set:function(t){this._displayObject.blendMode=t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"filters",{get:function(){return this._displayObject.filters},set:function(t){this._displayObject.filters=t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"inContainer",{get:function(){return null!=this._displayObject&&null!=this._displayObject.parent},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"onStage",{get:function(){return null!=this._displayObject&&null!=this._displayObject.stage},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"resourceURL",{get:function(){return this.packageItem?"ui://"+this.packageItem.owner.id+this.packageItem.id:null},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"group",{get:function(){return this._group},set:function(t){this._group!=t&&(this._group&&this._group.setBoundsChangedFlag(),this._group=t,this._group&&this._group.setBoundsChangedFlag())},enumerable:!0,configurable:!0}),h.prototype.getGear=function(e){var i=this._gears[e];return null==i&&(this._gears[e]=i=t.GearBase.create(this,e)),i},h.prototype.updateGear=function(t){if(!this._underConstruct&&!this._gearLocked){var e=this._gears[t];e&&e.controller&&e.updateState()}},h.prototype.checkGearController=function(t,e){return null!=this._gears[t]&&this._gears[t].controller==e},h.prototype.updateGearFromRelations=function(t,e,i){this._gears[t]&&this._gears[t].updateFromRelations(e,i)},h.prototype.addDisplayLock=function(){var t=this._gears[0];if(t&&t.controller){var e=t.addLock();return this.checkGearDisplay(),e}return 0},h.prototype.releaseDisplayLock=function(t){var e=this._gears[0];e&&e.controller&&(e.releaseLock(t),this.checkGearDisplay())},h.prototype.checkGearDisplay=function(){if(!this._handlingController){var t=null==this._gears[0]||this._gears[0].connected;this._gears[8]&&(t=this._gears[8].evaluate(t)),t!=this._internalVisible&&(this._internalVisible=t,this._parent&&this._parent.childStateChanged(this),this._group&&this._group.excludeInvisibles&&this._group.setBoundsChangedFlag())}},Object.defineProperty(h.prototype,"gearXY",{get:function(){return this.getGear(1)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"gearSize",{get:function(){return this.getGear(2)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"gearLook",{get:function(){return this.getGear(3)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"relations",{get:function(){return this._relations},enumerable:!0,configurable:!0}),h.prototype.addRelation=function(t,e,i){this._relations.add(t,e,i)},h.prototype.removeRelation=function(t,e){this._relations.remove(t,e||0)},Object.defineProperty(h.prototype,"displayObject",{get:function(){return this._displayObject},enumerable:!0,configurable:!0}),h.prototype.setDisplayObject=function(t){this._displayObject!=t&&(this._displayObject&&delete this._displayObject.$owner,this._displayObject=t,this._displayObject.$owner=this)},Object.defineProperty(h.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t},enumerable:!0,configurable:!0}),h.prototype.removeFromParent=function(){this._parent&&this._parent.removeChild(this)},Object.defineProperty(h.prototype,"root",{get:function(){if(this instanceof t.GRoot)return this;for(var e=this._parent;e;){if(e instanceof t.GRoot)return e;e=e.parent}return t.GRoot.inst},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asCom",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asButton",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asLabel",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asProgress",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asTextField",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asRichTextField",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asTextInput",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asLoader",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asList",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asTree",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asGraph",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asGroup",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asSlider",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asComboBox",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asImage",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asMovieClip",{get:function(){return this},enumerable:!0,configurable:!0}),h.cast=function(t){return t.$owner},Object.defineProperty(h.prototype,"text",{get:function(){return null},set:function(t){},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"icon",{get:function(){return null},set:function(t){},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"isDisposed",{get:function(){return this._disposed},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"treeNode",{get:function(){return this._treeNode},enumerable:!0,configurable:!0}),h.prototype.dispose=function(){if(!this._disposed){this._disposed=!0,this.removeFromParent(),this._relations.dispose(),this._displayObject=null;for(var t=0;t<10;t++){var e=this._gears[t];e&&e.dispose()}}},h.prototype.addClickListener=function(t,e){this.addEventListener(egret.TouchEvent.TOUCH_TAP,t,e)},h.prototype.removeClickListener=function(t,e){this.removeEventListener(egret.TouchEvent.TOUCH_TAP,t,e)},h.prototype.hasClickListener=function(){return this.hasEventListener(egret.TouchEvent.TOUCH_TAP)},h.prototype.addEventListener=function(t,i,n){e.prototype.addEventListener.call(this,t,i,n),this._displayObject&&this._displayObject.addEventListener(t,this._reDispatch,this)},h.prototype.removeEventListener=function(t,i,n){e.prototype.removeEventListener.call(this,t,i,n),this._displayObject&&!this.hasEventListener(t)&&this._displayObject.removeEventListener(t,this._reDispatch,this)},h.prototype._reDispatch=function(t){this.dispatchEvent(t)},Object.defineProperty(h.prototype,"draggable",{get:function(){return this._draggable},set:function(t){this._draggable!=t&&(this._draggable=t,this.initDrag())},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"dragBounds",{get:function(){return this._dragBounds},set:function(t){this._dragBounds=t},enumerable:!0,configurable:!0}),h.prototype.startDrag=function(t,e,i){null!=this._displayObject.stage&&this.dragBegin(t,e,i)},h.prototype.stopDrag=function(){this.dragEnd()},Object.defineProperty(h.prototype,"dragging",{get:function(){return h.draggingObject==this},enumerable:!0,configurable:!0}),h.prototype.localToGlobal=function(t,e,i){return t=t||0,e=e||0,this._pivotAsAnchor&&(t+=this._pivotX*this._width,e+=this._pivotY*this._height),this._displayObject.localToGlobal(t,e,i)},h.prototype.globalToLocal=function(t,e,i){t=t||0,e=e||0;var n=this._displayObject.globalToLocal(t,e,i);return this._pivotAsAnchor&&(n.x-=this._pivotX*this._width,n.y-=this._pivotY*this._height),n},h.prototype.localToRoot=function(e,i,n){e=e||0,i=i||0;var o=this._displayObject.localToGlobal(e,i,n);return o.x/=t.GRoot.contentScaleFactor,o.y/=t.GRoot.contentScaleFactor,o},h.prototype.rootToLocal=function(e,i,n){return e=e||0,i=i||0,e*=t.GRoot.contentScaleFactor,i*=t.GRoot.contentScaleFactor,this._displayObject.globalToLocal(e,i,n)},h.prototype.localToGlobalRect=function(t,e,i,n,o){t=t||0,e=e||0,i=i||0,n=n||0,o=o||new egret.Rectangle;var r=this.localToGlobal(t,e);return o.x=r.x,o.y=r.y,r=this.localToGlobal(t+i,e+n),o.right=r.x,o.bottom=r.y,o},h.prototype.globalToLocalRect=function(t,e,i,n,o){t=t||0,e=e||0,i=i||0,n=n||0,o=o||new egret.Rectangle;var r=this.globalToLocal(t,e);return o.x=r.x,o.y=r.y,r=this.globalToLocal(t+i,e+n),o.right=r.x,o.bottom=r.y,o},h.prototype.handleControllerChanged=function(t){this._handlingController=!0;for(var e=0;e<10;e++){var i=this._gears[e];i&&i.controller==t&&i.apply()}this._handlingController=!1,this.checkGearDisplay()},h.prototype.createDisplayObject=function(){},h.prototype.switchDisplayObject=function(e){if(e!=this._displayObject){var i=this._displayObject;if(this._displayObject&&this._displayObject.parent){var n=this._displayObject.parent.getChildIndex(this._displayObject);this._displayObject.parent.addChildAt(e,n),this._displayObject.parent.removeChild(this._displayObject)}this._displayObject=e,this._displayObject.x=i.x,this._displayObject.y=i.y,this._displayObject.rotation=i.rotation,this._displayObject.alpha=i.alpha,this._displayObject.visible=i.visible,this._displayObject.touchEnabled=i.touchEnabled,this._displayObject.scaleX=i.scaleX,this._displayObject.scaleY=i.scaleY,t.ToolSet.setColorFilter(this._displayObject,this._grayed),this._displayObject instanceof egret.DisplayObjectContainer&&(this._displayObject.touchChildren=this._touchable)}},h.prototype.handleXYChanged=function(){if(this._displayObject){var t=this._x,e=this._y;this._pivotAsAnchor&&(t-=this._pivotX*this._width,e-=this._pivotY*this._height),this._pixelSnapping&&(t=Math.round(t),e=Math.round(e)),this._displayObject.x=t+this._pivotOffsetX,this._displayObject.y=e+this._pivotOffsetY}},h.prototype.handleSizeChanged=function(){this._displayObject&&(this._displayObject.width=this._width,this._displayObject.height=this._height)},h.prototype.handleScaleChanged=function(){this._displayObject&&(this._displayObject.scaleX=this._scaleX,this._displayObject.scaleY=this._scaleY)},h.prototype.handleGrayedChanged=function(){this._displayObject&&t.ToolSet.setColorFilter(this._displayObject,this._grayed)},h.prototype.handleAlphaChanged=function(){this._displayObject&&(this._displayObject.alpha=this._alpha)},h.prototype.handleVisibleChanged=function(){this._displayObject&&(this._displayObject.visible=this.internalVisible2),this instanceof t.GGroup&&this.handleVisibleChanged()},h.prototype.getProp=function(e){switch(e){case t.ObjectPropID.Text:return this.text;case t.ObjectPropID.Icon:return this.icon;case t.ObjectPropID.Color:case t.ObjectPropID.OutlineColor:return NaN;case t.ObjectPropID.Playing:return!1;case t.ObjectPropID.Frame:case t.ObjectPropID.DeltaTime:return 0;case t.ObjectPropID.TimeScale:return 1;case t.ObjectPropID.FontSize:return 0;case t.ObjectPropID.Selected:return!1;default:return}},h.prototype.setProp=function(e,i){switch(e){case t.ObjectPropID.Text:this.text=i;break;case t.ObjectPropID.Icon:this.icon=i}},h.prototype.constructFromResource=function(){},h.prototype.setup_beforeAdd=function(e,i){var n,o;e.seek(i,0),e.skip(5),this._id=e.readS(),this._name=e.readS(),n=e.readInt(),o=e.readInt(),this.setXY(n,o),e.readBool()&&(this.initWidth=e.readInt(),this.initHeight=e.readInt(),this.setSize(this.initWidth,this.initHeight,!0)),e.readBool()&&(this.minWidth=e.readInt(),this.maxWidth=e.readInt(),this.minHeight=e.readInt(),this.maxHeight=e.readInt()),e.readBool()&&(n=e.readFloat(),o=e.readFloat(),this.setScale(n,o)),e.readBool()&&(n=e.readFloat(),o=e.readFloat(),this.setSkew(n,o)),e.readBool()&&(n=e.readFloat(),o=e.readFloat(),this.setPivot(n,o,e.readBool())),1!=(n=e.readFloat())&&(this.alpha=n),0!=(n=e.readFloat())&&(this.rotation=n),e.readBool()||(this.visible=!1),e.readBool()||(this.touchable=!1),e.readBool()&&(this.grayed=!0);var r=e.readByte();2==r?this.blendMode=egret.BlendMode.ADD:5==r&&(this.blendMode=egret.BlendMode.ERASE),1==e.readByte()&&this._displayObject&&t.ToolSet.setColorFilter(this._displayObject,[e.readFloat(),e.readFloat(),e.readFloat(),e.readFloat()]);var s=e.readS();null!=s&&(this.data=s)},h.prototype.setup_afterAdd=function(t,e){t.seek(e,1);var i=t.readS();null!=i&&(this.tooltips=i);var n=t.readShort();n>=0&&(this.group=this.parent.getChildAt(n)),t.seek(e,2);for(var o=t.readShort(),r=0;ru.right&&(l=u.right-r.width)u.bottom&&(c=u.bottom-r.height)=0;--t){var n=this._children[t];n.parent=null,n.dispose()}this._boundsChanged=!1,e.prototype.dispose.call(this)},Object.defineProperty(i.prototype,"displayListContainer",{get:function(){return this._container},enumerable:!0,configurable:!0}),i.prototype.addChild=function(t){return this.addChildAt(t,this._children.length),t},i.prototype.addChildAt=function(t,e){if(void 0===e&&(e=0),!t)throw"child is null";var i=this._children.length;if(e>=0&&e<=i){if(t.parent==this)this.setChildIndex(t,e);else{t.removeFromParent(),t.parent=this;var n=this._children.length;0!=t.sortingOrder?(this._sortingChildCount++,e=this.getInsertPosForSortingChild(t)):this._sortingChildCount>0&&e>n-this._sortingChildCount&&(e=n-this._sortingChildCount),e==n?this._children.push(t):this._children.splice(e,0,t),this.childStateChanged(t),this.setBoundsChangedFlag()}return t}throw"Invalid child index"},i.prototype.getInsertPosForSortingChild=function(t){var e=this._children.length,i=0;for(i=0;i=0&&e=this.numChildren)&&(e=this.numChildren-1);for(var n=t;n<=e;++n)this.removeChildAt(t,i)},i.prototype.getChildAt=function(t){if(t>=0&&t0&&e>n-this._sortingChildCount-1&&(e=n-this._sortingChildCount-1),this._setChildIndex(t,i,e)}},i.prototype.setChildIndexBefore=function(t,e){var i=this._children.indexOf(t);if(-1==i)throw"Not a child of this container";if(0!=t.sortingOrder)return i;var n=this._children.length;return this._sortingChildCount>0&&e>n-this._sortingChildCount-1&&(e=n-this._sortingChildCount-1),io&&(n=o),i==n)return i;if(this._children.splice(i,1),this._children.splice(n,0,e),e.inContainer){var r,s=0;if(this._childrenRenderOrder==t.ChildrenRenderOrder.Ascent){for(r=0;rn;r--)this._children[r].inContainer&&s++;s==this._container.numChildren&&s--,this._container.setChildIndex(e.displayObject,s)}else t.GTimers.inst.callLater(this.buildNativeDisplayList,this);this.setBoundsChangedFlag()}return n},i.prototype.swapChildren=function(t,e){var i=this._children.indexOf(t),n=this._children.indexOf(e);if(-1==i||-1==n)throw"Not a child of this container";this.swapChildrenAt(i,n)},i.prototype.swapChildrenAt=function(t,e){var i=this._children[t],n=this._children[e];this.setChildIndex(i,e),this.setChildIndex(n,t)},Object.defineProperty(i.prototype,"numChildren",{get:function(){return this._children.length},enumerable:!0,configurable:!0}),i.prototype.isAncestorOf=function(t){if(!t)return!1;for(var e=t.parent;e;){if(e==this)return!0;e=e.parent}return!1},i.prototype.addController=function(t){this._controllers.push(t),t.parent=this,this.applyController(t)},i.prototype.getControllerAt=function(t){return this._controllers[t]},i.prototype.getController=function(t){for(var e=this._controllers.length,i=0;i=0&&(i=this._children[n])!=e;n--)i.displayObject&&i.displayObject.parent&&r++;this._container.addChildAt(e.displayObject,r)}else this._container.addChild(e.displayObject),t.GTimers.inst.callLater(this.buildNativeDisplayList,this)}}else e.displayObject.parent&&this._container.removeChild(e.displayObject)}},i.prototype.buildNativeDisplayList=function(){var e,i,n=this._children.length;if(0!=n)switch(this._childrenRenderOrder){case t.ChildrenRenderOrder.Ascent:for(e=0;e=0;e--)(i=this._children[e]).displayObject&&i.internalVisible&&this._container.addChild(i.displayObject);break;case t.ChildrenRenderOrder.Arch:var o=t.ToolSet.clamp(this._apexIndex,0,n);for(e=0;e=o;e--)(i=this._children[e]).displayObject&&i.internalVisible&&this._container.addChild(i.displayObject)}},i.prototype.applyController=function(t){this._applyingController=t;for(var e=this._children.length,i=0;ia&&(a=n);s=0&&t.x<=this.width&&t.y+t.height>=0&&t.y<=this.height:!this._scrollPane||this._scrollPane.isChildInView(t)},i.prototype.getFirstChildInView=function(){for(var t=this._children.length,e=0;e0)for(var e=0;e0)for(var e=0;e0){t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY;var r=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,a=0,h=0;for(h=0;hr&&(r=a),(a=l.y+l.actualHeight)>s&&(s=a)}i=r-t,n=s-e}this.setBounds(t,e,i,n)},i.prototype.setBounds=function(t,e,i,n){void 0===n&&(n=0),this._boundsChanged=!1,this._scrollPane&&this._scrollPane.setContentSize(Math.round(t+i),Math.round(e+n))},Object.defineProperty(i.prototype,"viewWidth",{get:function(){return this._scrollPane?this._scrollPane.viewWidth:this.width-this._margin.left-this._margin.right},set:function(t){this._scrollPane?this._scrollPane.viewWidth=t:this.width=t+this._margin.left+this._margin.right},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"viewHeight",{get:function(){return this._scrollPane?this._scrollPane.viewHeight:this.height-this._margin.top-this._margin.bottom},set:function(t){this._scrollPane?this._scrollPane.viewHeight=t:this.height=t+this._margin.top+this._margin.bottom},enumerable:!0,configurable:!0}),i.prototype.getSnappingPosition=function(t,e,i){i||(i=new egret.Point);var n=this._children.length;if(0==n)return i.x=0,i.y=0,i;this.ensureBoundsCorrect();var o=null,r=null,s=0;if(0!=e){for(;s0&&s--;s0&&(this.displayObject.addEventListener(egret.Event.ADDED_TO_STAGE,this.___added,this),this.displayObject.addEventListener(egret.Event.REMOVED_FROM_STAGE,this.___removed,this)),this.applyAllControllers(),this._buildingDisplayList=!1,this._underConstruct=!1,this.buildNativeDisplayList(),this.setBoundsChangedFlag(),u.objectType!=t.ObjectType.Component&&this.constructExtension(_),this.onConstruct()},i.prototype.onConstruct=function(){this.constructFromXML(null)},i.prototype.constructExtension=function(t){},i.prototype.constructFromXML=function(t){},i.prototype.setup_afterAdd=function(t,i){e.prototype.setup_afterAdd.call(this,t,i),t.seek(i,4);var n=t.readShort();-1!=n&&this._scrollPane&&(this._scrollPane.pageController=this._parent.getControllerAt(n));for(var o=t.readShort(),r=0;r=2)for(o=t.readShort(),r=0;r=0&&(this._relatedController=this.parent.getControllerAt(o)),this._relatedPageId=t.readS(),null!=(n=t.readS())&&(this._sound=n),t.readBool()&&(this._soundVolumeScale=t.readFloat()),this.selected=t.readBool()))},i.prototype.__mousedown=function(e){this._down=!0,t.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_END,this.__mouseup,this),this._mode==t.ButtonMode.Common&&(this.grayed&&this._buttonController&&this._buttonController.hasPage(i.DISABLED)?this.setState(i.SELECTED_DISABLED):this.setState(i.DOWN)),this._linkedPopup&&(this._linkedPopup instanceof t.Window?this._linkedPopup.toggleStatus():this.root.togglePopup(this._linkedPopup,this))},i.prototype.__mouseup=function(e){if(this._down){if(t.GRoot.inst.nativeStage.removeEventListener(egret.TouchEvent.TOUCH_END,this.__mouseup,this),this._down=!1,!this.displayObject)return;this._mode==t.ButtonMode.Common&&(this.grayed&&this._buttonController&&this._buttonController.hasPage(i.DISABLED)?this.setState(i.DISABLED):this._over?this.setState(i.OVER):this.setState(i.UP))}},i.prototype.__click=function(e){if(this._sound){var i=t.UIPackage.getItemByURL(this._sound);if(i){var n=i.owner.getItemAsset(i);n&&t.GRoot.inst.playOneShotSound(n,this._soundVolumeScale)}}this._mode==t.ButtonMode.Check?this._changeStateOnClick&&(this.selected=!this._selected,this.dispatchEvent(new t.StateChangeEvent(t.StateChangeEvent.CHANGED))):this._mode==t.ButtonMode.Radio?this._changeStateOnClick&&!this._selected&&(this.selected=!0,this.dispatchEvent(new t.StateChangeEvent(t.StateChangeEvent.CHANGED))):this._relatedController&&(this._relatedController.selectedPageId=this._relatedPageId)},i.UP="up",i.DOWN="down",i.OVER="over",i.SELECTED_OVER="selectedOver",i.DISABLED="disabled",i.SELECTED_DISABLED="selectedDisabled",i}(t.GComponent);t.GButton=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){var i=e.call(this)||this;return i._visibleItemCount=0,i._selectedIndex=0,i._popupDirection=t.PopupDirection.Auto,i._visibleItemCount=t.UIConfig.defaultComboBoxVisibleItemCount,i._itemsUpdated=!0,i._selectedIndex=-1,i._items=[],i._values=[],i}return __extends(i,e),Object.defineProperty(i.prototype,"text",{get:function(){return this._titleObject?this._titleObject.text:null},set:function(t){this._titleObject&&(this._titleObject.text=t),this.updateGear(6)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._iconObject?this._iconObject.icon:null},set:function(t){this._iconObject&&(this._iconObject.icon=t),this.updateGear(7)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"titleColor",{get:function(){var t=this.getTextField();return t?t.color:0},set:function(t){var e=this.getTextField();e&&(e.color=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"titleFontSize",{get:function(){var t=this.getTextField();return t?t.fontSize:0},set:function(t){var e=this.getTextField();e&&(e.fontSize=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visibleItemCount",{get:function(){return this._visibleItemCount},set:function(t){this._visibleItemCount=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"popupDirection",{get:function(){return this._popupDirection},set:function(t){this._popupDirection=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"items",{get:function(){return this._items},set:function(t){t?this._items=t.concat():this._items.length=0,this._items.length>0?(this._selectedIndex>=this._items.length?this._selectedIndex=this._items.length-1:-1==this._selectedIndex&&(this._selectedIndex=0),this.text=this._items[this._selectedIndex],this._icons&&this._selectedIndex=0&&this._selectedIndex0?(this._selectedIndex=0,this.text=this._items[0]):this._selectedIndex=-1,null!=(s=t.readS())&&(this.icon=s),t.readBool()&&(this.titleColor=t.readColor()),(o=t.readInt())>0&&(this._visibleItemCount=o),this._popupDirection=t.readByte(),(o=t.readShort())>=0&&(this._selectionController=this.parent.getControllerAt(o))}},i.prototype.showDropdown=function(){if(this._itemsUpdated){this._itemsUpdated=!1,this._list.removeChildrenToPool();for(var e=this._items.length,i=0;i>24&255)/255,r=t.readColor(!0),this._fillColor=16777215&r,this._fillAlpha=(r>>24&255)/255,t.readBool())for(this._cornerRadius=new Array(4),n=0;n<4;n++)this._cornerRadius[n]=t.readFloat();if(3==this._type)for(o=t.readShort(),this._polygonPoints=[],this._polygonPoints.length=o,n=0;n0))for(this._distances=[],n=0;na&&(a=n),(n=i.yMin+i.height)>h&&(h=n),l=!1);var c=0,u=0;l||(this._updating|=1,this.setXY(r,s),this._updating&=2,c=a-r,u=h-s),0==(2&this._updating)?(this._updating|=2,this.setSize(c,u),this._updating&=1):(this._updating&=1,this.resizeChildren(this._width-c,this._height-u))},i.prototype.handleLayout=function(){var e,i,n;if(this._updating|=1,this._layout==t.GroupLayoutType.Horizontal){var o=this.x;for(n=this._parent.numChildren,i=0;i0?o._sizePercentInGroup=(1==this._layout?o.width:o.height)/this._totalSize:o._sizePercentInGroup=0)}var a=0,h=1,l=!1;if(1==this._layout){a=this.width-(this._numChildren-1)*this._columnGap,-1!=this._mainChildIndex&&a>=this._totalSize&&((o=this._parent.getChildAt(this._mainChildIndex)).setSize(a-(this._totalSize-this._mainGridMinSize),o._rawHeight+i,!0),a-=o.width,h-=o._sizePercentInGroup,l=!0);var c=this.x;for(n=0;n=this._totalSize&&((o=this._parent.getChildAt(this._mainChildIndex)).setSize(o._rawWidth+e,a-(this._totalSize-this._mainGridMinSize),!0),a-=o.height,h-=o._sizePercentInGroup,l=!0);var u=this.y;for(n=0;n=2&&(this._excludeInvisibles=t.readBool(),this._autoSizeDisabled=t.readBool(),this._mainChildIndex=t.readInt())},i.prototype.setup_afterAdd=function(t,i){e.prototype.setup_afterAdd.call(this,t,i),this.visible||this.handleVisibleChanged()},i}(t.GObject);t.GGroup=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){var i=e.call(this)||this;return i._flip=t.FlipType.None,i}return __extends(i,e),Object.defineProperty(i.prototype,"color",{get:function(){return this._content.color},set:function(t){this._content.color!=t&&(this._content.color=t,this.updateGear(4))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"flip",{get:function(){return this._flip},set:function(e){if(this._flip!=e){this._flip=e;var i=1,n=1;this._flip!=t.FlipType.Horizontal&&this._flip!=t.FlipType.Both||(i=-1),this._flip!=t.FlipType.Vertical&&this._flip!=t.FlipType.Both||(n=-1),this._content.scaleX=i,this._content.scaleY=n,this.handleXYChanged()}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillMethod",{get:function(){return this._content.fillMethod},set:function(t){this._content.fillMethod=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillOrigin",{get:function(){return this._content.fillOrigin},set:function(t){this._content.fillOrigin=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillClockwise",{get:function(){return this._content.fillClockwise},set:function(t){this._content.fillClockwise=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillAmount",{get:function(){return this._content.fillAmount},set:function(t){this._content.fillAmount=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"texture",{get:function(){return this._content.texture},set:function(t){t?(this.sourceWidth=t.textureWidth,this.sourceHeight=t.textureHeight):(this.sourceWidth=0,this.sourceHeight=0),this.initWidth=this.sourceWidth,this.initHeight=this.sourceHeight,this._content.scale9Grid=null,this._content.fillMode=egret.BitmapFillMode.SCALE,this._content.texture=t},enumerable:!0,configurable:!0}),i.prototype.createDisplayObject=function(){this._content=new t.Image,this._content.touchEnabled=!1,this.setDisplayObject(this._content)},i.prototype.constructFromResource=function(){var t=this.packageItem.getBranch();this.sourceWidth=t.width,this.sourceHeight=t.height,this.initWidth=this.sourceWidth,this.initHeight=this.sourceHeight,this.setSize(this.sourceWidth,this.sourceHeight),(t=t.getHighResolution()).load(),this._content.scale9Grid=t.scale9Grid,this._content.smoothing=t.smoothing,t.scaleByTile&&(this._content.fillMode=egret.BitmapFillMode.REPEAT),this.setSize(this.sourceWidth,this.sourceHeight),this._content.texture=t.asset},i.prototype.handleXYChanged=function(){e.prototype.handleXYChanged.call(this),this._flip!=t.FlipType.None&&(-1==this._content.scaleX&&(this._content.x+=this.width),-1==this._content.scaleY&&(this._content.y+=this.height))},i.prototype.getProp=function(i){return i==t.ObjectPropID.Color?this.color:e.prototype.getProp.call(this,i)},i.prototype.setProp=function(i,n){i==t.ObjectPropID.Color?this.color=n:e.prototype.setProp.call(this,i,n)},i.prototype.setup_beforeAdd=function(t,i){e.prototype.setup_beforeAdd.call(this,t,i),t.seek(i,5),t.readBool()&&(this.color=t.readColor()),this.flip=t.readByte(),this._content.fillMethod=t.readByte(),0!=this._content.fillMethod&&(this._content.fillOrigin=t.readByte(),this._content.fillClockwise=t.readBool(),this._content.fillAmount=t.readFloat())},i}(t.GObject);t.GImage=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){return e.call(this)||this}return __extends(i,e),Object.defineProperty(i.prototype,"icon",{get:function(){if(this._iconObject)return this._iconObject.icon},set:function(t){this._iconObject&&(this._iconObject.icon=t),this.updateGear(7)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._titleObject?this._titleObject.text:null},set:function(t){this._titleObject&&(this._titleObject.text=t),this.updateGear(6)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"text",{get:function(){return this.title},set:function(t){this.title=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"titleColor",{get:function(){var t=this.getTextField();return t?t.color:0},set:function(t){var e=this.getTextField();e&&(e.color=t),this.updateGear(4)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"titleFontSize",{get:function(){var t=this.getTextField();return t?t.fontSize:0},set:function(t){var e=this.getTextField();e&&(e.fontSize=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"editable",{get:function(){return!!(this._titleObject&&this._titleObject instanceof t.GTextInput)&&this._titleObject.asTextInput.editable},set:function(t){this._titleObject&&(this._titleObject.asTextInput.editable=t)},enumerable:!0,configurable:!0}),i.prototype.getTextField=function(){return this._titleObject instanceof t.GTextField?this._titleObject:this._titleObject instanceof i||this._titleObject instanceof t.GButton?this._titleObject.getTextField():null},i.prototype.getProp=function(i){switch(i){case t.ObjectPropID.Color:return this.titleColor;case t.ObjectPropID.OutlineColor:var n=this.getTextField();return n?n.strokeColor:0;case t.ObjectPropID.FontSize:return this.titleFontSize;default:return e.prototype.getProp.call(this,i)}},i.prototype.setProp=function(i,n){switch(i){case t.ObjectPropID.Color:this.titleColor=n;break;case t.ObjectPropID.OutlineColor:var o=this.getTextField();o&&(o.strokeColor=n);break;case t.ObjectPropID.FontSize:this.titleFontSize=n;break;default:e.prototype.setProp.call(this,i,n)}},i.prototype.constructExtension=function(t){this._titleObject=this.getChild("title"),this._iconObject=this.getChild("icon")},i.prototype.setup_afterAdd=function(i,n){if(e.prototype.setup_afterAdd.call(this,i,n),i.seek(n,6)&&i.readByte()==this.packageItem.objectType){var o;null!=(o=i.readS())&&(this.title=o),null!=(o=i.readS())&&(this.icon=o),i.readBool()&&(this.titleColor=i.readColor());var r=i.readInt();if(0!=r&&(this.titleFontSize=r),i.readBool()){var s=this.getTextField();s instanceof t.GTextInput?(null!=(o=i.readS())&&(s.promptText=o),null!=(o=i.readS())&&(s.restrict=o),0!=(r=i.readInt())&&(s.maxLength=r),r=i.readInt(),i.readBool()&&(s.password=!0)):i.skip(13)}}},i}(t.GComponent);t.GLabel=e}(fgui||(fgui={})),function(t){var e=function(e){function n(){var i=e.call(this)||this;return i.scrollItemToViewOnClick=!0,i.foldInvisibleItems=!1,i._lineCount=0,i._columnCount=0,i._lineGap=0,i._columnGap=0,i._lastSelectedIndex=0,i._numItems=0,i._realNumItems=0,i._firstIndex=0,i._curLineItemCount=0,i._curLineItemCount2=0,i._virtualListChanged=0,i.itemInfoVer=0,i._trackBounds=!0,i._pool=new t.GObjectPool,i._layout=t.ListLayoutType.SingleColumn,i._autoResizeItem=!0,i._lastSelectedIndex=-1,i._selectionMode=t.ListSelectionMode.Single,i.opaque=!0,i._align=t.AlignType.Left,i._verticalAlign=t.VertAlignType.Top,i._container=new egret.DisplayObjectContainer,i._rootContainer.addChild(i._container),i}return __extends(n,e),n.prototype.dispose=function(){this._pool.clear(),e.prototype.dispose.call(this)},Object.defineProperty(n.prototype,"layout",{get:function(){return this._layout},set:function(t){this._layout!=t&&(this._layout=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"lineCount",{get:function(){return this._lineCount},set:function(t){this._lineCount!=t&&(this._lineCount=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"columnCount",{get:function(){return this._columnCount},set:function(t){this._columnCount!=t&&(this._columnCount=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"lineGap",{get:function(){return this._lineGap},set:function(t){this._lineGap!=t&&(this._lineGap=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"columnGap",{get:function(){return this._columnGap},set:function(t){this._columnGap!=t&&(this._columnGap=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"align",{get:function(){return this._align},set:function(t){this._align!=t&&(this._align=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"verticalAlign",{get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!=t&&(this._verticalAlign=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"virtualItemSize",{get:function(){return this._itemSize},set:function(t){this._virtual&&(this._itemSize||(this._itemSize=new egret.Point),this._itemSize.copyFrom(t),this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"defaultItem",{get:function(){return this._defaultItem},set:function(t){this._defaultItem=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"autoResizeItem",{get:function(){return this._autoResizeItem},set:function(t){this._autoResizeItem!=t&&(this._autoResizeItem=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectionMode",{get:function(){return this._selectionMode},set:function(t){this._selectionMode=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectionController",{get:function(){return this._selectionController},set:function(t){this._selectionController=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"itemPool",{get:function(){return this._pool},enumerable:!0,configurable:!0}),n.prototype.getFromPool=function(t){t||(t=this._defaultItem);var e=this._pool.getObject(t);return e&&(e.visible=!0),e},n.prototype.returnToPool=function(t){t.displayObject.cacheAsBitmap=!1,this._pool.returnObject(t)},n.prototype.addChildAt=function(i,n){return e.prototype.addChildAt.call(this,i,n),i instanceof t.GButton&&(i.selected=!1,i.changeStateOnClick=!1),i.addEventListener(egret.TouchEvent.TOUCH_TAP,this.__clickItem,this),i},n.prototype.addItem=function(e){return e||(e=this._defaultItem),this.addChild(t.UIPackage.createObjectFromURL(e))},n.prototype.addItemFromPool=function(t){return this.addChild(this.getFromPool(t))},n.prototype.removeChildAt=function(t,i){var n=e.prototype.removeChildAt.call(this,t,i);return n.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.__clickItem,this),n},n.prototype.removeChildToPoolAt=function(t){var i=e.prototype.removeChildAt.call(this,t);this.returnToPool(i)},n.prototype.removeChildToPool=function(t){e.prototype.removeChild.call(this,t),this.returnToPool(t)},n.prototype.removeChildrenToPool=function(t,e){null==t&&(t=0),null==e&&(e=-1),(e<0||e>=this._children.length)&&(e=this._children.length-1);for(var i=t;i<=e;++i)this.removeChildToPoolAt(t)},Object.defineProperty(n.prototype,"selectedIndex",{get:function(){var e;if(this._virtual)for(e=0;e=0&&e=0&&(this.clearSelection(),this.addSelection(i,!0));else if(this._layout==t.ListLayoutType.FlowHorizontal||this._layout==t.ListLayoutType.Pagination){for(var n=this._children[i],o=0,r=i-1;r>=0;r--){var s=this._children[r];if(s.y!=n.y){n=s;break}o++}for(;r>=0;r--)if((s=this._children[r]).y!=n.y){this.clearSelection(),this.addSelection(r+o+1,!0);break}}break;case 3:if(this._layout==t.ListLayoutType.SingleRow||this._layout==t.ListLayoutType.FlowHorizontal||this._layout==t.ListLayoutType.Pagination)++i=0&&(this.clearSelection(),this.addSelection(i,!0));else if(this._layout==t.ListLayoutType.FlowVertical){for(n=this._children[i],o=0,r=i-1;r>=0;r--){if((s=this._children[r]).x!=n.x){n=s;break}o++}for(;r>=0;r--)if((s=this._children[r]).x!=n.x){this.clearSelection(),this.addSelection(r+o+1,!0);break}}}},n.prototype.__clickItem=function(e){if(!this._scrollPane||!this._scrollPane.isDragged){var i=e.currentTarget;this.setSelectionOnEvent(i),this._scrollPane&&this.scrollItemToViewOnClick&&this._scrollPane.scrollToView(i,!0);var n=new t.ItemEvent(t.ItemEvent.CLICK,i);n.stageX=e.stageX,n.stageY=e.stageY,this.dispatchItemEvent(n)}},n.prototype.dispatchItemEvent=function(t){this.dispatchEvent(t)},n.prototype.setSelectionOnEvent=function(e){if(e instanceof t.GButton&&this._selectionMode!=t.ListSelectionMode.None){var i=!1,n=this.childIndexToItemIndex(this.getChildIndex(e));if(this._selectionMode==t.ListSelectionMode.Single)e.selected||(this.clearSelectionExcept(e),e.selected=!0);else if(t.GRoot.shiftKeyDown){if(!e.selected)if(-1!=this._lastSelectedIndex){var o,r=Math.min(this._lastSelectedIndex,n),s=Math.max(this._lastSelectedIndex,n);if(s=Math.min(s,this.numItems-1),this._virtual)for(o=r;o<=s;o++){var a=this._virtualItems[o];a.obj instanceof t.GButton&&(a.obj.selected=!0),a.selected=!0}else for(o=r;o<=s;o++){var h=this.getChildAt(o);h instanceof t.GButton&&(h.selected=!0)}i=!0}else e.selected=!0}else t.GRoot.ctrlKeyDown||this._selectionMode==t.ListSelectionMode.Multiple_SingleClick?e.selected=!e.selected:e.selected?this.clearSelectionExcept(e):(this.clearSelectionExcept(e),e.selected=!0);i||(this._lastSelectedIndex=n),e.selected&&this.updateSelectionController(n)}},n.prototype.resizeToFit=function(e,i){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===i&&(i=0),this.ensureBoundsCorrect();var n=this.numItems;if(e>n&&(e=n),this._virtual){var o=Math.ceil(e/this._curLineItemCount);this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal?this.viewHeight=o*this._itemSize.y+Math.max(0,o-1)*this._lineGap:this.viewWidth=o*this._itemSize.x+Math.max(0,o-1)*this._columnGap}else if(0==e)this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal?this.viewHeight=i:this.viewWidth=i;else{for(var r,s=e-1;s>=0&&(r=this.getChildAt(s),this.foldInvisibleItems&&!r.visible);)s--;if(s<0)this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal?this.viewHeight=i:this.viewWidth=i;else{var a=0;this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal?((a=r.y+r.height)e&&(e=n.width)}return e},n.prototype.handleSizeChanged=function(){e.prototype.handleSizeChanged.call(this),this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0)},n.prototype.handleControllerChanged=function(t){e.prototype.handleControllerChanged.call(this,t),this._selectionController==t&&(this.selectedIndex=t.selectedIndex)},n.prototype.updateSelectionController=function(t){if(this._selectionController&&!this._selectionController.changing&&tthis._virtualItems[a].height/2&&athis._virtualItems[a].width/2&&athis._virtualItems[a].width/2&&a=this._virtualItems.length)throw"Invalid child index: "+e+">"+this._virtualItems.length;var o;this._loop&&(e=Math.floor(this._firstIndex/this._numItems)*this._numItems+e);var r,s=this._virtualItems[e],a=0;if(this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal){for(r=this._curLineItemCount-1;r0&&(e%=this._numItems),e},n.prototype.itemIndexToChildIndex=function(e){if(!this._virtual)return e;if(this._layout==t.ListLayoutType.Pagination)return this.getChildIndex(this._virtualItems[e].obj);if(this._loop&&this._numItems>0){var i=this._firstIndex%this._numItems;e>=i?e-=i:e=this._numItems-i+e}else e-=this._firstIndex;return e},n.prototype.setVirtual=function(){this._setVirtual(!1)},n.prototype.setVirtualAndLoop=function(){this._setVirtual(!0)},n.prototype._setVirtual=function(e){if(!this._virtual){if(null==this._scrollPane)throw"Virtual list must be scrollable!";if(e){if(this._layout==t.ListLayoutType.FlowHorizontal||this._layout==t.ListLayoutType.FlowVertical)throw"Loop list is not supported for FlowHorizontal or FlowVertical layout!";this._scrollPane.bouncebackEffect=!1}if(this._virtual=!0,this._loop=e,this._virtualItems=new Array,this.removeChildrenToPool(),null==this._itemSize){this._itemSize=new egret.Point;var i=this.getFromPool(null);if(null==i)throw"Virtual List must have a default list item resource.";this._itemSize.x=i.width,this._itemSize.y=i.height,this.returnToPool(i)}this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal?(this._scrollPane.scrollStep=this._itemSize.y,this._loop&&(this._scrollPane._loop=2)):(this._scrollPane.scrollStep=this._itemSize.x,this._loop&&(this._scrollPane._loop=1)),this._scrollPane.addEventListener(t.ScrollPane.SCROLL,this.__scrolled,this),this.setVirtualListChangedFlag(!0)}},Object.defineProperty(n.prototype,"numItems",{get:function(){return this._virtual?this._numItems:this._children.length},set:function(e){if(this._virtual){if(null==this.itemRenderer)throw"Set itemRenderer first!";this._numItems=e,this._loop?this._realNumItems=6*this._numItems:this._realNumItems=this._numItems;var i=this._virtualItems.length;if(this._realNumItems>i)for(r=i;ro)for(var r=o;r0?this._curLineItemCount=this._columnCount:(this._curLineItemCount=Math.floor((this._scrollPane.viewWidth+this._columnGap)/(this._itemSize.x+this._columnGap)),this._curLineItemCount<=0&&(this._curLineItemCount=1)):this._layout==t.ListLayoutType.FlowVertical?this._lineCount>0?this._curLineItemCount=this._lineCount:(this._curLineItemCount=Math.floor((this._scrollPane.viewHeight+this._lineGap)/(this._itemSize.y+this._lineGap)),this._curLineItemCount<=0&&(this._curLineItemCount=1)):(this._columnCount>0?this._curLineItemCount=this._columnCount:(this._curLineItemCount=Math.floor((this._scrollPane.viewWidth+this._columnGap)/(this._itemSize.x+this._columnGap)),this._curLineItemCount<=0&&(this._curLineItemCount=1)),this._lineCount>0?this._curLineItemCount2=this._lineCount:(this._curLineItemCount2=Math.floor((this._scrollPane.viewHeight+this._lineGap)/(this._itemSize.y+this._lineGap)),this._curLineItemCount2<=0&&(this._curLineItemCount2=1))));var i=0,n=0;if(this._realNumItems>0){var o,r=Math.ceil(this._realNumItems/this._curLineItemCount)*this._curLineItemCount,s=Math.min(this._curLineItemCount,this._realNumItems);if(this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal){for(o=0;o0&&(i-=this._lineGap),this._autoResizeItem)n=this._scrollPane.viewWidth;else{for(o=0;o0&&(n-=this._columnGap)}}else if(this._layout==t.ListLayoutType.SingleRow||this._layout==t.ListLayoutType.FlowVertical){for(o=0;o0&&(n-=this._columnGap),this._autoResizeItem)i=this._scrollPane.viewHeight;else{for(o=0;o0&&(i-=this._lineGap)}}else{n=Math.ceil(r/(this._curLineItemCount*this._curLineItemCount2))*this.viewWidth,i=this.viewHeight}}this.handleAlign(n,i),this._scrollPane.setContentSize(n,i),this._eventLocked=!1,this.handleScroll(!0)},n.prototype.__scrolled=function(t){this.handleScroll(!1)},n.prototype.getIndexOnPos1=function(t){if(this._realNumItems0&&!t){if((n=this.getChildAt(0).y)>i){for(e=this._firstIndex-this._curLineItemCount;e>=0;e-=this._curLineItemCount)if((n-=this._virtualItems[e].height+this._lineGap)<=i)return i=n,e;return i=0,0}for(e=this._firstIndex;ei)return i=n,e;n=o}return i=n,this._realNumItems-this._curLineItemCount}for(n=0,e=0;ei)return i=n,e;n=o}return i=n,this._realNumItems-this._curLineItemCount},n.prototype.getIndexOnPos2=function(t){if(this._realNumItems0&&!t){if((n=this.getChildAt(0).x)>i){for(e=this._firstIndex-this._curLineItemCount;e>=0;e-=this._curLineItemCount)if((n-=this._virtualItems[e].width+this._columnGap)<=i)return i=n,e;return i=0,0}for(e=this._firstIndex;ei)return i=n,e;n=o}return i=n,this._realNumItems-this._curLineItemCount}for(n=0,e=0;ei)return i=n,e;n=o}return i=n,this._realNumItems-this._curLineItemCount},n.prototype.getIndexOnPos3=function(t){if(this._realNumItemsi)return i=a,s+e;a=n}return i=a,s+this._curLineItemCount-1},n.prototype.handleScroll=function(e){if(!this._eventLocked){if(this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal){for(var i=0;this.handleScroll1(e);)if(e=!1,++i>20){console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size.");break}this.handleArchOrder1()}else if(this._layout==t.ListLayoutType.SingleRow||this._layout==t.ListLayoutType.FlowVertical){for(i=0;this.handleScroll2(e);)if(e=!1,++i>20){console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size.");break}this.handleArchOrder2()}else this.handleScroll3(e);this._boundsChanged=!1}},n.prototype.handleScroll1=function(e){var n=this._scrollPane.scrollingPosY,o=n+this._scrollPane.viewHeight,r=o==this._scrollPane.contentHeight;i=n;var s=this.getIndexOnPos1(e);if(n=i,s==this._firstIndex&&!e)return!1;var a=this._firstIndex;this._firstIndex=s;var h,l,c,u,_,p=s,d=a>s,g=this.numChildren,f=a+g-1,y=d?f:a,m=0,b=n,v=0,w=0,C=this.defaultItem,S=(this._scrollPane.viewWidth-this._columnGap*(this._curLineItemCount-1))/this._curLineItemCount;for(this.itemInfoVer++;p=a;_--)if((c=this._virtualItems[_]).obj&&c.updateFlag!=this.itemInfoVer&&c.obj.resourceURL==C){c.obj instanceof t.GButton&&(c.selected=c.obj.selected),l.obj=c.obj,c.obj=null,_==y&&y--;break}}else for(_=y;_<=f;_++)if((c=this._virtualItems[_]).obj&&c.updateFlag!=this.itemInfoVer&&c.obj.resourceURL==C){c.obj instanceof t.GButton&&(c.selected=c.obj.selected),l.obj=c.obj,c.obj=null,_==y&&y++;break}l.obj?this.setChildIndex(l.obj,d?p-s:this.numChildren):(l.obj=this._pool.getObject(C),d?this.addChildAt(l.obj,p-s):this.addChild(l.obj)),l.obj instanceof t.GButton&&(l.obj.selected=l.selected),h=!0}else h=e;h&&(this._autoResizeItem&&(this._layout==t.ListLayoutType.SingleColumn||this._columnCount>0)&&l.obj.setSize(S,l.obj.height,!0),this.itemRenderer.call(this.callbackThisObj,p%this._numItems,l.obj),p%this._curLineItemCount==0&&(v+=Math.ceil(l.obj.height)-l.height,p==s&&a>s&&(w=Math.ceil(l.obj.height)-l.height)),l.width=Math.ceil(l.obj.width),l.height=Math.ceil(l.obj.height)),l.updateFlag=this.itemInfoVer,l.obj.setXY(m,b),p==s&&(o+=l.height),m+=l.width+this._columnGap,p%this._curLineItemCount==this._curLineItemCount-1&&(m=0,b+=l.height+this._lineGap),p++}for(u=0;u0&&this.numChildren>0&&this._container.y<=0&&this.getChildAt(0).y>-this._container.y},n.prototype.handleScroll2=function(e){var n=this._scrollPane.scrollingPosX,o=n+this._scrollPane.viewWidth,r=n==this._scrollPane.contentWidth;i=n;var s=this.getIndexOnPos2(e);if(n=i,s==this._firstIndex&&!e)return!1;var a=this._firstIndex;this._firstIndex=s;var h,l,c,u,_,p=s,d=a>s,g=this.numChildren,f=a+g-1,y=d?f:a,m=n,b=0,v=0,w=0,C=this.defaultItem,S=(this._scrollPane.viewHeight-this._lineGap*(this._curLineItemCount-1))/this._curLineItemCount;for(this.itemInfoVer++;p=a;_--)if((c=this._virtualItems[_]).obj&&c.updateFlag!=this.itemInfoVer&&c.obj.resourceURL==C){c.obj instanceof t.GButton&&(c.selected=c.obj.selected),l.obj=c.obj,c.obj=null,_==y&&y--;break}}else for(_=y;_<=f;_++)if((c=this._virtualItems[_]).obj&&c.updateFlag!=this.itemInfoVer&&c.obj.resourceURL==C){c.obj instanceof t.GButton&&(c.selected=c.obj.selected),l.obj=c.obj,c.obj=null,_==y&&y++;break}l.obj?this.setChildIndex(l.obj,d?p-s:this.numChildren):(l.obj=this._pool.getObject(C),d?this.addChildAt(l.obj,p-s):this.addChild(l.obj)),l.obj instanceof t.GButton&&(l.obj.selected=l.selected),h=!0}else h=e;h&&(this._autoResizeItem&&(this._layout==t.ListLayoutType.SingleRow||this._lineCount>0)&&l.obj.setSize(l.obj.width,S,!0),this.itemRenderer.call(this.callbackThisObj,p%this._numItems,l.obj),p%this._curLineItemCount==0&&(v+=Math.ceil(l.obj.width)-l.width,p==s&&a>s&&(w=Math.ceil(l.obj.width)-l.width)),l.width=Math.ceil(l.obj.width),l.height=Math.ceil(l.obj.height)),l.updateFlag=this.itemInfoVer,l.obj.setXY(m,b),p==s&&(o+=l.width),b+=l.height+this._lineGap,p%this._curLineItemCount==this._curLineItemCount-1&&(b=0,m+=l.width+this._columnGap),p++}for(u=0;u0&&this.numChildren>0&&this._container.x<=0&&this.getChildAt(0).x>-this._container.x},n.prototype.handleScroll3=function(e){var n=this._scrollPane.scrollingPosX;i=n;var o=this.getIndexOnPos3(e);if(n=i,o!=this._firstIndex||e){var r=this._firstIndex;this._firstIndex=o;var s,a,h,l,c,u,_=r,p=this._virtualItems.length,d=this._curLineItemCount*this._curLineItemCount2,g=o%this._curLineItemCount,f=this.viewWidth,y=Math.floor(o/d)*d,m=y+2*d,b=this._defaultItem,v=(this._scrollPane.viewWidth-this._columnGap*(this._curLineItemCount-1))/this._curLineItemCount,w=(this._scrollPane.viewHeight-this._lineGap*(this._curLineItemCount2-1))/this._curLineItemCount2;for(this.itemInfoVer++,a=y;a=this._realNumItems)){if(c=a%this._curLineItemCount,a-yg)continue;(h=this._virtualItems[a]).updateFlag=this.itemInfoVer}var C=0;for(a=y;a=this._realNumItems)&&(h=this._virtualItems[a]).updateFlag==this.itemInfoVer){if(null==h.obj){for(;_=this._realNumItems||((h=this._virtualItems[a]).updateFlag==this.itemInfoVer&&h.obj.setXY(x,T),h.height>I&&(I=h.height),a%this._curLineItemCount==this._curLineItemCount-1?(x=S,T+=I+this._lineGap,I=0,a==y+d-1&&(x=S+=f,T=0)):x+=h.width+this._columnGap);for(a=_;ar&&(r=i.width));if((h=o)<=d&&this._autoResizeItem&&this._scrollPane&&this._scrollPane._displayInDemand&&this._scrollPane.vtScrollBar)for(p+=this._scrollPane.vtScrollBar.width,e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(i.setSize(p,i.height,!0),i.width>r&&(r=i.width));a=Math.ceil(r)}else if(this._layout==t.ListLayoutType.SingleRow){for(e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(0!=n&&(n+=this._columnGap),i.x=n,this._autoResizeItem&&i.setSize(i.width,d,!0),n+=Math.ceil(i.width),i.height>s&&(s=i.height));if((a=n)<=p&&this._autoResizeItem&&this._scrollPane&&this._scrollPane._displayInDemand&&this._scrollPane.hzScrollBar)for(d+=this._scrollPane.hzScrollBar.height,e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(i.setSize(i.width,d,!0),i.height>s&&(s=i.height));h=Math.ceil(s)}else if(this._layout==t.ListLayoutType.FlowHorizontal)if(this._autoResizeItem&&this._columnCount>0){for(e=0;e<_;e++)if(i=this.getChildAt(e),(!this.foldInvisibleItems||i.visible)&&(g+=i.sourceWidth,++l==this._columnCount||e==_-1)){for(y=(p-g-(l-1)*this._columnGap)/g,n=0,l=f;l<=e;l++)i=this.getChildAt(l),this.foldInvisibleItems&&!i.visible||(i.setXY(n,o),ls&&(s=i.height));o+=Math.ceil(s)+this._lineGap,s=0,l=0,f=e+1,g=0}h=o+Math.ceil(s),a=p}else{for(e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(0!=n&&(n+=this._columnGap),(0!=this._columnCount&&l>=this._columnCount||0==this._columnCount&&n+i.width>p&&0!=s)&&(n=0,o+=Math.ceil(s)+this._lineGap,s=0,l=0),i.setXY(n,o),(n+=Math.ceil(i.width))>r&&(r=n),i.height>s&&(s=i.height),l++);h=o+Math.ceil(s),a=Math.ceil(r)}else if(this._layout==t.ListLayoutType.FlowVertical)if(this._autoResizeItem&&this._lineCount>0){for(e=0;e<_;e++)if(i=this.getChildAt(e),(!this.foldInvisibleItems||i.visible)&&(g+=i.sourceHeight,++l==this._lineCount||e==_-1)){for(y=(d-g-(l-1)*this._lineGap)/g,o=0,l=f;l<=e;l++)i=this.getChildAt(l),this.foldInvisibleItems&&!i.visible||(i.setXY(n,o),lr&&(r=i.width));n+=Math.ceil(r)+this._columnGap,r=0,l=0,f=e+1,g=0}a=n+Math.ceil(r),h=d}else{for(e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(0!=o&&(o+=this._lineGap),(0!=this._lineCount&&l>=this._lineCount||0==this._lineCount&&o+i.height>d&&0!=r)&&(o=0,n+=Math.ceil(r)+this._columnGap,r=0,l=0),i.setXY(n,o),(o+=Math.ceil(i.height))>s&&(s=o),i.width>r&&(r=i.width),l++);a=n+Math.ceil(r),h=Math.ceil(s)}else{var m;if(this._autoResizeItem&&this._lineCount>0&&(m=Math.floor((d-(this._lineCount-1)*this._lineGap)/this._lineCount)),this._autoResizeItem&&this._columnCount>0){for(e=0;e<_;e++)if(i=this.getChildAt(e),(!this.foldInvisibleItems||i.visible)&&(0==l&&(0!=this._lineCount&&u>=this._lineCount||0==this._lineCount&&o+(this._lineCount>0?m:i.height)>d)&&(c++,o=0,u=0),g+=i.sourceWidth,++l==this._columnCount||e==_-1)){for(y=(p-g-(l-1)*this._columnGap)/g,n=0,l=f;l<=e;l++)i=this.getChildAt(l),this.foldInvisibleItems&&!i.visible||(i.setXY(c*p+n,o),l0?m:i.height,!0),n+=Math.ceil(i.width)+this._columnGap):i.setSize(p-n,this._lineCount>0?m:i.height,!0),i.height>s&&(s=i.height));o+=Math.ceil(s)+this._lineGap,s=0,l=0,f=e+1,g=0,u++}}else for(e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(0!=n&&(n+=this._columnGap),this._autoResizeItem&&this._lineCount>0&&i.setSize(i.width,m,!0),(0!=this._columnCount&&l>=this._columnCount||0==this._columnCount&&n+i.width>p&&0!=s)&&(n=0,o+=Math.ceil(s)+this._lineGap,s=0,l=0,u++,(0!=this._lineCount&&u>=this._lineCount||0==this._lineCount&&o+i.height>d&&0!=r)&&(c++,o=0,u=0)),i.setXY(c*p+n,o),(n+=Math.ceil(i.width))>r&&(r=n),i.height>s&&(s=i.height),l++);h=c>0?d:o+Math.ceil(s),a=(c+1)*p}this.handleAlign(a,h),this.setBounds(0,0,a,h)}},n.prototype.setup_beforeAdd=function(i,n){e.prototype.setup_beforeAdd.call(this,i,n),i.seek(n,5),this._layout=i.readByte(),this._selectionMode=i.readByte(),this._align=i.readByte(),this._verticalAlign=i.readByte(),this._lineGap=i.readShort(),this._columnGap=i.readShort(),this._lineCount=i.readShort(),this._columnCount=i.readShort(),this._autoResizeItem=i.readBool(),this._childrenRenderOrder=i.readByte(),this._apexIndex=i.readShort(),i.readBool()&&(this._margin.top=i.readInt(),this._margin.bottom=i.readInt(),this._margin.left=i.readInt(),this._margin.right=i.readInt());var o=i.readByte();if(o==t.OverflowType.Scroll){var r=i.position;i.seek(n,7),this.setupScroll(i),i.position=r}else this.setupOverflow(o);i.readBool()&&i.skip(8),i.version>=2&&(this.scrollItemToViewOnClick=i.readBool(),this.foldInvisibleItems=i.readBool()),i.seek(n,8),this._defaultItem=i.readS(),this.readItems(i)},n.prototype.readItems=function(t){var e,i,n,o;for(e=t.readShort(),i=0;i=2)for(o=e.readShort(),r=0;rs?r=s:s=r:this._fill==t.LoaderFillType.ScaleNoBorder&&(r>s?s=r:r=s),this._shrinkOnly&&(r>1&&(r=1),s>1&&(s=1)),e=this.sourceWidth*r,i=this.sourceHeight*s)),this._content2?this._content2.setScale(r,s):(this._content.width=e,this._content.height=i),n=this._align==t.AlignType.Center?Math.floor((this.width-e)/2):this._align==t.AlignType.Right?this.width-e:0,o=this._verticalAlign==t.VertAlignType.Middle?Math.floor((this.height-i)/2):this._verticalAlign==t.VertAlignType.Bottom?this.height-i:0,this._content2?this._content2.setXY(n,o):(this._content.x=n,this._content.y=o)}}else this._autoSize&&(this._updatingLayout=!0,this.setSize(50,30),this._updatingLayout=!1)},i.prototype.clearContent=function(){this.clearErrorState(),!this._contentItem&&this._content.texture&&this.freeExternal(this._content.texture),this._content.texture=null,this._content.frames=null,this._content2&&(this._container.removeChild(this._content2.displayObject),this._content2.dispose(),this._content2=null),this._contentItem=null},i.prototype.handleSizeChanged=function(){e.prototype.handleSizeChanged.call(this),this._updatingLayout||this.updateLayout()},i.prototype.getProp=function(i){switch(i){case t.ObjectPropID.Color:return this.color;case t.ObjectPropID.Playing:return this.playing;case t.ObjectPropID.Frame:return this.frame;case t.ObjectPropID.TimeScale:return this._content.timeScale;default:return e.prototype.getProp.call(this,i)}},i.prototype.setProp=function(i,n){switch(i){case t.ObjectPropID.Color:this.color=n;break;case t.ObjectPropID.Playing:this.playing=n;break;case t.ObjectPropID.Frame:this.frame=n;break;case t.ObjectPropID.TimeScale:this._content.timeScale=n;break;case t.ObjectPropID.DeltaTime:this._content.advance(n);break;default:e.prototype.setProp.call(this,i,n)}},i.prototype.setup_beforeAdd=function(t,i){e.prototype.setup_beforeAdd.call(this,t,i),t.seek(i,5),this._url=t.readS(),this._align=t.readByte(),this._verticalAlign=t.readByte(),this._fill=t.readByte(),this._shrinkOnly=t.readBool(),this._autoSize=t.readBool(),this._showErrorSign=t.readBool(),this._content.playing=t.readBool(),this._content.frame=t.readInt(),t.readBool()&&(this.color=t.readColor()),this._content.fillMethod=t.readByte(),0!=this._content.fillMethod&&(this._content.fillOrigin=t.readByte(),this._content.fillClockwise=t.readBool(),this._content.fillAmount=t.readFloat()),this._url&&this.loadContent()},i._errorSignPool=new t.GObjectPool,i}(t.GObject);t.GLoader=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){var i=e.call(this)||this;return i._frame=0,i._playing=!0,i._url="",i._fill=t.LoaderFillType.None,i._align=t.AlignType.Left,i._verticalAlign=t.VertAlignType.Top,i._color=16777215,i}return __extends(i,e),i.prototype.createDisplayObject=function(){var e=new t.UIContainer;e.opaque=!0,this.setDisplayObject(e),this._container=new egret.DisplayObjectContainer,e.addChild(this._container)},i.prototype.dispose=function(){e.prototype.dispose.call(this)},Object.defineProperty(i.prototype,"url",{get:function(){return this._url},set:function(t){this._url!=t&&(this._url=t,this.loadContent(),this.updateGear(7))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._url},set:function(t){this.url=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"align",{get:function(){return this._align},set:function(t){this._align!=t&&(this._align=t,this.updateLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"verticalAlign",{get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!=t&&(this._verticalAlign=t,this.updateLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fill",{get:function(){return this._fill},set:function(t){this._fill!=t&&(this._fill=t,this.updateLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shrinkOnly",{get:function(){return this._shrinkOnly},set:function(t){this._shrinkOnly!=t&&(this._shrinkOnly=t,this.updateLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"autoSize",{get:function(){return this._autoSize},set:function(t){this._autoSize!=t&&(this._autoSize=t,this.updateLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"playing",{get:function(){return this._playing},set:function(t){this._playing!=t&&(this._playing=t,this.updateGear(5),this.onChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"frame",{get:function(){return this._frame},set:function(t){this._frame!=t&&(this._frame=t,this.updateGear(5),this.onChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationName",{get:function(){return this._animationName},set:function(t){this._animationName!=t&&(this._animationName=t,this.onChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skinName",{get:function(){return this._skinName},set:function(t){this._skinName!=t&&(this._skinName=t,this.onChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"loop",{get:function(){return this._loop},set:function(t){this._loop!=t&&(this._loop=t,this.onChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"color",{get:function(){return this._color},set:function(t){this._color!=t&&(this._color=t,this.updateGear(4),this._content&&(this._content.tint=t))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"content",{get:function(){},enumerable:!0,configurable:!0}),i.prototype.loadContent=function(){this.clearContent(),this._url&&(t.ToolSet.startsWith(this._url,"ui://")?this.loadFromPackage(this._url):this.loadExternal())},i.prototype.loadFromPackage=function(e){this._contentItem=t.UIPackage.getItemByURL(e),this._contentItem&&(this._contentItem=this._contentItem.getBranch(),this.sourceWidth=this._contentItem.width,this.sourceHeight=this._contentItem.height,this._contentItem=this._contentItem.getHighResolution(),this._autoSize&&this.setSize(this.sourceWidth,this.sourceHeight),this._contentItem.type!=t.PackageItemType.Spine&&this._contentItem.type!=t.PackageItemType.DragonBones||this._contentItem.owner.getItemAssetAsync(this._contentItem,this.onLoaded.bind(this)))},i.prototype.onLoaded=function(e,i){this._contentItem==i&&(e&&console.warn(e),this._contentItem.asset&&this._contentItem.type==t.PackageItemType.DragonBones&&this.setDragonBones(this._contentItem.armatureName,this._contentItem.asset.name,this._contentItem.atlasAsset.name,this._skinName,this._contentItem.skeletonAnchor))},i.prototype.setDragonBones=function(t,e,i,n,o){this.url=null;var r=dragonBones.EgretFactory.factory;this._content=r.buildArmatureDisplay(t,e,i,n),this._container.addChild(this._content),this._content.x=o.x,this._content.y=o.y,this._content.tint=this._color,this.onChangeDragonBones(),this.updateLayout()},i.prototype.onChange=function(){this.onChangeDragonBones()},i.prototype.onChangeDragonBones=function(){this._content instanceof dragonBones.EgretArmatureDisplay&&(this._animationName?this._playing?this._content.animation.play(this._animationName,this._loop?0:1):this._content.animation.gotoAndStopByFrame(this._animationName,this._frame):this._content.animation.reset())},i.prototype.loadExternal=function(){},i.prototype.updateLayout=function(){var e=this.sourceWidth,i=this.sourceHeight;if(this._autoSize&&(this._updatingLayout=!0,0==e&&(e=50),0==i&&(i=30),this.setSize(e,i),this._updatingLayout=!1,e==this._width&&i==this._height))return this._container.scaleX=this._container.scaleY=1,void(this._container.x=this._container.y=0);var n,o,r=1,s=1;this._fill!=t.LoaderFillType.None&&(r=this.width/this.sourceWidth,s=this.height/this.sourceHeight,1==r&&1==s||(this._fill==t.LoaderFillType.ScaleMatchHeight?r=s:this._fill==t.LoaderFillType.ScaleMatchWidth?s=r:this._fill==t.LoaderFillType.Scale?r>s?r=s:s=r:this._fill==t.LoaderFillType.ScaleNoBorder&&(r>s?s=r:r=s),this._shrinkOnly&&(r>1&&(r=1),s>1&&(s=1)),e=this.sourceWidth*r,i=this.sourceHeight*s)),this._container.scaleX=r,this._container.scaleY=s,n=this._align==t.AlignType.Center?Math.floor((this.width-e)/2):this._align==t.AlignType.Right?this.width-e:0,o=this._verticalAlign==t.VertAlignType.Middle?Math.floor((this.height-i)/2):this._verticalAlign==t.VertAlignType.Bottom?this.height-i:0,this._container.x=n,this._container.y=o},i.prototype.clearContent=function(){this._contentItem=null,this._content&&(this._container.removeChild(this._content),"dispose"in this._content&&this._content.dispose(),this._content=null)},i.prototype.handleSizeChanged=function(){e.prototype.handleSizeChanged.call(this),this._updatingLayout||this.updateLayout()},i.prototype.handleGrayedChanged=function(){},i.prototype.getProp=function(i){switch(i){case t.ObjectPropID.Color:return this.color;case t.ObjectPropID.Playing:return this.playing;case t.ObjectPropID.Frame:return this.frame;case t.ObjectPropID.TimeScale:return 1;default:return e.prototype.getProp.call(this,i)}},i.prototype.setProp=function(i,n){switch(i){case t.ObjectPropID.Color:this.color=n;break;case t.ObjectPropID.Playing:this.playing=n;break;case t.ObjectPropID.Frame:this.frame=n;break;case t.ObjectPropID.TimeScale:case t.ObjectPropID.DeltaTime:break;default:e.prototype.setProp.call(this,i,n)}},i.prototype.setup_beforeAdd=function(t,i){e.prototype.setup_beforeAdd.call(this,t,i),t.seek(i,5),this._url=t.readS(),this._align=t.readByte(),this._verticalAlign=t.readByte(),this._fill=t.readByte(),this._shrinkOnly=t.readBool(),this._autoSize=t.readBool(),this._animationName=t.readS(),this._skinName=t.readS(),this._playing=t.readBool(),this._frame=t.readInt(),this._loop=t.readBool(),t.readBool()&&(this.color=t.readColor()),this._url&&this.loadContent()},i}(t.GObject);t.GLoader3D=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){return e.call(this)||this}return __extends(i,e),Object.defineProperty(i.prototype,"color",{get:function(){return this._content.color},set:function(t){this._content.color!=t&&(this._content.color=t,this.updateGear(4))},enumerable:!0,configurable:!0}),i.prototype.createDisplayObject=function(){this._content=new t.MovieClip,this._content.touchEnabled=!1,this.setDisplayObject(this._content)},Object.defineProperty(i.prototype,"playing",{get:function(){return this._content.playing},set:function(t){this._content.playing!=t&&(this._content.playing=t,this.updateGear(5))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"frame",{get:function(){return this._content.frame},set:function(t){this._content.frame!=t&&(this._content.frame=t,this.updateGear(5))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"timeScale",{get:function(){return this._content.timeScale},set:function(t){this._content.timeScale=t},enumerable:!0,configurable:!0}),i.prototype.rewind=function(){this._content.rewind()},i.prototype.syncStatus=function(t){this._content.syncStatus(t._content)},i.prototype.advance=function(t){this._content.advance(t)},i.prototype.setPlaySettings=function(t,e,i,n,o,r){this._content.setPlaySettings(t,e,i,n,o,r)},i.prototype.getProp=function(i){switch(i){case t.ObjectPropID.Color:return this.color;case t.ObjectPropID.Playing:return this.playing;case t.ObjectPropID.Frame:return this.frame;case t.ObjectPropID.TimeScale:return this.timeScale;default:return e.prototype.getProp.call(this,i)}},i.prototype.setProp=function(i,n){switch(i){case t.ObjectPropID.Color:this.color=n;break;case t.ObjectPropID.Playing:this.playing=n;break;case t.ObjectPropID.Frame:this.frame=n;break;case t.ObjectPropID.TimeScale:this.timeScale=n;break;case t.ObjectPropID.DeltaTime:this.advance(n);break;default:e.prototype.setProp.call(this,i,n)}},i.prototype.constructFromResource=function(){var t=this.packageItem.getBranch();this.sourceWidth=t.width,this.sourceHeight=t.height,this.initWidth=this.sourceWidth,this.initHeight=this.sourceHeight,this.setSize(this.sourceWidth,this.sourceHeight),(t=t.getHighResolution()).load(),this._content.interval=t.interval,this._content.swing=t.swing,this._content.repeatDelay=t.repeatDelay,this._content.frames=t.frames,this._content.smoothing=t.smoothing},i.prototype.setup_beforeAdd=function(t,i){e.prototype.setup_beforeAdd.call(this,t,i),t.seek(i,5),t.readBool()&&(this.color=t.readColor()),t.readByte(),this._content.frame=t.readInt(),this._content.playing=t.readBool()},i}(t.GObject);t.GMovieClip=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){var i=e.call(this)||this;return i._min=0,i._max=0,i._value=0,i._barMaxWidth=0,i._barMaxHeight=0,i._barMaxWidthDelta=0,i._barMaxHeightDelta=0,i._barStartX=0,i._barStartY=0,i._titleType=t.ProgressTitleType.Percent,i._value=50,i._max=100,i}return __extends(i,e),Object.defineProperty(i.prototype,"titleType",{get:function(){return this._titleType},set:function(t){this._titleType!=t&&(this._titleType=t,this.update(this._value))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"min",{get:function(){return this._min},set:function(t){this._min!=t&&(this._min=t,this.update(this._value))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"max",{get:function(){return this._max},set:function(t){this._max!=t&&(this._max=t,this.update(this._value))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"value",{get:function(){return this._value},set:function(e){this._value!=e&&(t.GTween.kill(this,!1,this.update),this._value=e,this.update(e))},enumerable:!0,configurable:!0}),i.prototype.tweenValue=function(e,i){var n,o=t.GTween.getTween(this,this.update);return o?(n=o.value.x,o.kill()):n=this._value,this._value=e,t.GTween.to(n,this._value,i).setTarget(this,this.update).setEase(t.EaseType.Linear)},i.prototype.update=function(e){var i=t.ToolSet.clamp01((e-this._min)/(this._max-this._min));if(this._titleObject)switch(this._titleType){case t.ProgressTitleType.Percent:this._titleObject.text=Math.floor(100*i)+"%";break;case t.ProgressTitleType.ValueAndMax:this._titleObject.text=Math.floor(e)+"/"+Math.floor(this._max);break;case t.ProgressTitleType.Value:this._titleObject.text=""+Math.floor(e);break;case t.ProgressTitleType.Max:this._titleObject.text=""+Math.floor(this._max)}var n=this.width-this._barMaxWidthDelta,o=this.height-this._barMaxHeightDelta;this._reverse?(this._barObjectH&&(this.setFillAmount(this._barObjectH,1-i)||(this._barObjectH.width=Math.round(n*i),this._barObjectH.x=this._barStartX+(n-this._barObjectH.width))),this._barObjectV&&(this.setFillAmount(this._barObjectV,1-i)||(this._barObjectV.height=Math.round(o*i),this._barObjectV.y=this._barStartY+(o-this._barObjectV.height)))):(this._barObjectH&&(this.setFillAmount(this._barObjectH,i)||(this._barObjectH.width=Math.round(n*i))),this._barObjectV&&(this.setFillAmount(this._barObjectV,i)||(this._barObjectV.height=Math.round(o*i)))),this._aniObject&&this._aniObject.setProp(t.ObjectPropID.Frame,Math.floor(100*i))},i.prototype.setFillAmount=function(e,i){return(e instanceof t.GImage||e instanceof t.GLoader)&&e.fillMethod!=t.FillMethod.None&&(e.fillAmount=i,!0)},i.prototype.constructExtension=function(t){t.seek(0,6),this._titleType=t.readByte(),this._reverse=t.readBool(),this._titleObject=this.getChild("title"),this._barObjectH=this.getChild("bar"),this._barObjectV=this.getChild("bar_v"),this._aniObject=this.getChild("ani"),this._barObjectH&&(this._barMaxWidth=this._barObjectH.width,this._barMaxWidthDelta=this.width-this._barMaxWidth,this._barStartX=this._barObjectH.x),this._barObjectV&&(this._barMaxHeight=this._barObjectV.height,this._barMaxHeightDelta=this.height-this._barMaxHeight,this._barStartY=this._barObjectV.y)},i.prototype.handleSizeChanged=function(){e.prototype.handleSizeChanged.call(this),this._barObjectH&&(this._barMaxWidth=this.width-this._barMaxWidthDelta),this._barObjectV&&(this._barMaxHeight=this.height-this._barMaxHeightDelta),this._underConstruct||this.update(this._value)},i.prototype.setup_afterAdd=function(t,i){e.prototype.setup_afterAdd.call(this,t,i),t.seek(i,6)&&t.readByte()==this.packageItem.objectType?(this._value=t.readInt(),this._max=t.readInt(),t.version>=2&&(this._min=t.readInt()),this.update(this._value)):this.update(this._value)},i}(t.GComponent);t.GProgressBar=e}(fgui||(fgui={})),function(t){var e=function(e){function s(){var i=e.call(this)||this;return i._fontSize=0,i._leading=0,i._letterSpacing=0,i._textWidth=0,i._textHeight=0,i._fontSize=12,i._align=t.AlignType.Left,i._verticalAlign=t.VertAlignType.Top,i._text="",i._leading=3,i._color=0,i._autoSize=t.AutoSizeType.Both,i._widthAutoSize=!0,i._heightAutoSize=!0,i}return __extends(s,e),s.prototype.createDisplayObject=function(){this._textField=new egret.TextField,this._textField.touchEnabled=!1,this.setDisplayObject(this._textField)},s.prototype.switchBitmapMode=function(t){t&&this.displayObject==this._textField?(null==this._bitmapContainer&&(this._bitmapContainer=new egret.Sprite),this.switchDisplayObject(this._bitmapContainer)):t||this.displayObject!=this._bitmapContainer||this.switchDisplayObject(this._textField)},s.prototype.dispose=function(){e.prototype.dispose.call(this),this._bitmapFont=null,this._requireRender=!1},Object.defineProperty(s.prototype,"text",{get:function(){return this._text},set:function(t){this._text=t,null==this._text&&(this._text=""),this.updateGear(6),this.parent&&this.parent._underConstruct?this.renderNow():this.render()},enumerable:!0,configurable:!0}),s.prototype.updateTextFieldText=function(){var e=this._text;if(this._templateVars&&(e=this.parseTemplate(e)),this._ubbEnabled){var i=s._htmlParser.parser(t.UBBParser.inst.parse(t.ToolSet.encodeHTML(e)));if(this._underline)for(var n=0;n0&&(this._textWidth+=4),this._textHeight=Math.ceil(this._textField.textHeight),this._textHeight>0&&(this._textHeight+=4);var e,i=0;this._widthAutoSize?(e=this._textWidth,this._textField.width=e):e=this.width,this._heightAutoSize?(i=this._textHeight,this._textField.height!=this._textHeight&&(this._textField.height=this._textHeight)):(i=this.height,this._textHeight>i&&(this._textHeight=i)),t&&(this._updatingSize=!0,this.setSize(e,i),this._updatingSize=!1)}},s.prototype.renderWithBitmapFont=function(e){this.switchBitmapMode(!0),this._bitmapPool||(this._bitmapPool=[]);for(var s=this._bitmapContainer.numChildren,a=0;a=65&&B<=90||B>=97&&B<=122?(0==m&&(b=p),m++):(m>0&&(v=p),m=0),32==B)f=Math.ceil(this._fontSize/2),y=this._fontSize;else{var L=this._bitmapFont.glyphs[k];L?(f=Math.ceil(L.advance*T),y=Math.ceil(L.lineHeight*T)):(f=0,y=0)}if(y>g&&(g=y),y>d&&(d=y),0!=p&&(p+=c),p+=f,!x||p<=_)C+=k;else{if((l=n()).height=d,l.textHeight=g,0==C.length)l.text=k;else if(m>0&&v>0){var A=(C+=k).length-m;l.text=t.ToolSet.trimRight(C.substr(0,A)),l.width=v,C=C.substr(A),p-=b}else l.text=C,l.width=p-(f+c),C=k,p=f,d=y,g=y;l.y=S,S+=l.height+u,l.width>this._textWidth&&(this._textWidth=l.width),m=0,b=0,v=0,this._lines.push(l)}}else C+=k,(l=n()).width=p,0==g&&(0==w&&(w=this._fontSize),0==d&&(d=w),g=d),l.height=d,w=d,l.textHeight=g,l.text=C,l.y=S,S+=l.height+u,l.width>this._textWidth&&(this._textWidth=l.width),this._lines.push(l),C="",p=0,d=0,g=0,m=0,b=0,v=0}C.length>0&&((l=n()).width=p,0==d&&(d=w),0==g&&(g=d),l.height=d,l.textHeight=g,l.text=C,l.y=S,l.width>this._textWidth&&(this._textWidth=l.width),this._lines.push(l)),this._textWidth>0&&(this._textWidth+=2*o),0==this._lines.length?this._textHeight=0:(l=this._lines[this._lines.length-1],this._textHeight=l.y+l.height+r);var z,E=0;if(z=this._widthAutoSize?0==this._textWidth?0:this._textWidth:this.width,E=this._heightAutoSize?0==this._textHeight?0:this._textHeight:this.height,e&&(this._updatingSize=!0,this.setSize(z,E),this._updatingSize=!1),0!=z&&0!=E){var M=o,F=0,R=0;_=this.width-2*o;var D=this._lines.length;for(a=0;a0&&92==t.charCodeAt(e-1))s+=t.substring(r,e-1),s+="{",r=e+1;else{if(s+=t.substring(r,e),r=e,-1==(e=t.indexOf("}",r)))break;e!=r+1?(-1!=(i=(n=t.substring(r+1,e)).indexOf("="))?s+=null==(o=this._templateVars[n.substring(0,i)])?n.substring(i+1):o:null!=(o=this._templateVars[n])&&(s+=o),r=e+1):(s+=t.substr(r,2),r=e+1)}return rthis.width?t.x=this.width-t.width:t.x+t.width<0&&(t.x=0),t.y>this.height?t.y=this.height-t.height:t.y+t.height<0&&(t.y=0),this.adjustModalLayer()},i.prototype.hideWindow=function(t){t.hide()},i.prototype.hideWindowImmediately=function(t){t.parent==this&&this.removeChild(t),this.adjustModalLayer()},i.prototype.bringToFront=function(e){var i,n=this.numChildren;for(i=null==this._modalLayer.parent||e.modal?n-1:this.getChildIndex(this._modalLayer)-1;i>=0;i--){var o=this.getChildAt(i);if(o==e)return;if(o instanceof t.Window)break}i>=0&&this.setChildIndex(e,i)},i.prototype.showModalWait=function(e){null!=t.UIConfig.globalModalWaiting&&(null==this._modalWaitPane&&(this._modalWaitPane=t.UIPackage.createObjectFromURL(t.UIConfig.globalModalWaiting)),this._modalWaitPane.setSize(this.width,this.height),this._modalWaitPane.addRelation(this,t.RelationType.Size),this.addChild(this._modalWaitPane),this._modalWaitPane.text=e)},i.prototype.closeModalWait=function(){null!=this._modalWaitPane&&null!=this._modalWaitPane.parent&&this.removeChild(this._modalWaitPane)},i.prototype.closeAllExceptModals=function(){for(var e=this._children.slice(),i=e.length,n=0;n=0;e--){var i=this.getChildAt(e);if(i instanceof t.Window)return i}return null},Object.defineProperty(i.prototype,"modalLayer",{get:function(){return this._modalLayer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hasModalWindow",{get:function(){return null!=this._modalLayer.parent},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"modalWaiting",{get:function(){return this._modalWaitPane&&this._modalWaitPane.inContainer},enumerable:!0,configurable:!0}),i.prototype.showPopup=function(e,n,o){if(this._popupStack.length>0){var r=this._popupStack.indexOf(e);if(-1!=r)for(var s=this._popupStack.length-1;s>=r;s--)this.removeChild(this._popupStack.pop())}if(this._popupStack.push(e),n)for(var a=n;a;){if(a.parent==this){e.sortingOrderthis.width&&(l=l+u-e.width),c=h.y+_,((void 0===o||o===t.PopupDirection.Auto)&&h.y+e.height>this.height||!1===o||o===t.PopupDirection.Up)&&(c=h.y-e.height-1)<0&&(c=0,l+=u/2),e.x=l,e.y=c},i.prototype.togglePopup=function(t,e,i){-1==this._justClosedPopups.indexOf(t)&&this.showPopup(t,e,i)},i.prototype.hidePopup=function(t){if(t){var e=this._popupStack.indexOf(t);if(-1!=e)for(var i=this._popupStack.length-1;i>=e;i--)this.closePopup(this._popupStack.pop())}else{for(i=this._popupStack.length-1;i>=0;i--)this.closePopup(this._popupStack[i]);this._popupStack.length=0}},Object.defineProperty(i.prototype,"hasAnyPopup",{get:function(){return 0!=this._popupStack.length},enumerable:!0,configurable:!0}),i.prototype.closePopup=function(e){e.parent&&(e instanceof t.Window?e.hide():this.removeChild(e))},i.prototype.showTooltips=function(e){if(null==this._defaultTooltipWin){var i=t.UIConfig.tooltipsWin;if(!i)return void console.error("UIConfig.tooltipsWin not defined");this._defaultTooltipWin=t.UIPackage.createObjectFromURL(i)}this._defaultTooltipWin.text=e,this.showTooltipsWin(this._defaultTooltipWin)},i.prototype.showTooltipsWin=function(t,e){this.hideTooltips(),this._tooltipWin=t;var n=0,o=0;e?(n=e.x,o=e.y):(n=i.mouseX+10,o=i.mouseY+20);var r=this.globalToLocal(n,o);n=r.x,o=r.y,n+this._tooltipWin.width>this.width&&(n=n-this._tooltipWin.width-1)<0&&(n=10),o+this._tooltipWin.height>this.height&&(o=o-this._tooltipWin.height-1,n-this._tooltipWin.width-1>0&&(n=n-this._tooltipWin.width-1),o<0&&(o=10)),this._tooltipWin.x=n,this._tooltipWin.y=o,this.addChild(this._tooltipWin)},i.prototype.hideTooltips=function(){this._tooltipWin&&(this._tooltipWin.parent&&this.removeChild(this._tooltipWin),this._tooltipWin=null)},i.prototype.getObjectUnderPoint=function(e,i){var n=this._nativeStage.$hitTest(e,i);return n?t.ToolSet.displayObjectToGObject(n):null},Object.defineProperty(i.prototype,"focus",{get:function(){return null},set:function(t){},enumerable:!0,configurable:!0}),i.prototype.setFocus=function(t){},Object.defineProperty(i.prototype,"volumeScale",{get:function(){return this._volumeScale},set:function(t){this._volumeScale=t},enumerable:!0,configurable:!0}),i.prototype.playOneShotSound=function(t,e){e=e||1;var i=this._volumeScale*e;t.play(0,1).volume=i},i.prototype.adjustModalLayer=function(){var e=this.numChildren;this._modalWaitPane&&this._modalWaitPane.parent&&this.setChildIndex(this._modalWaitPane,e-1);for(var i=e-1;i>=0;i--){var n=this.getChildAt(i);if(n instanceof t.Window&&n.modal)return void(null==this._modalLayer.parent?this.addChildAt(this._modalLayer,i):this.setChildIndexBefore(this._modalLayer,i))}this._modalLayer.parent&&this.removeChild(this._modalLayer)},i.prototype.__addedToStage=function(e){this.displayObject.removeEventListener(egret.Event.ADDED_TO_STAGE,this.__addedToStage,this),this._nativeStage=this.displayObject.stage,this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__stageMouseDownCapture,this,!0),this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_END,this.__stageMouseUpCapture,this,!0),this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.__stageMouseMoveCapture,this,!0),this._modalLayer=new t.GGraph,this._modalLayer.setSize(this.width,this.height),this._modalLayer.drawRect(0,0,0,t.UIConfig.modalLayerColor,t.UIConfig.modalLayerAlpha),this._modalLayer.addRelation(this,t.RelationType.Size),this.displayObject.stage.addEventListener(egret.Event.RESIZE,this.__winResize,this),this.__winResize(null)},i.prototype.__stageMouseDownCapture=function(t){if(i.mouseX=t.stageX,i.mouseY=t.stageY,i.touchDown=!0,this._tooltipWin&&this.hideTooltips(),this._justClosedPopups.length=0,this._popupStack.length>0){for(var e=t.target;e!=this.displayObject.stage&&e;){if(e.$owner){var n=this._popupStack.indexOf(e.$owner);if(-1!=n){for(var o=this._popupStack.length-1;o>n;o--){var r=this._popupStack.pop();this.closePopup(r),this._justClosedPopups.push(r)}return}}e=e.parent}for(o=this._popupStack.length-1;o>=0;o--)r=this._popupStack[o],this.closePopup(r),this._justClosedPopups.push(r);this._popupStack.length=0}},i.prototype.__stageMouseMoveCapture=function(t){i.mouseX=t.stageX,i.mouseY=t.stageY},i.prototype.__stageMouseUpCapture=function(t){i.touchDown=!1},i.prototype.__winResize=function(t){this.setSize(this._nativeStage.stageWidth,this._nativeStage.stageHeight)},i.prototype.updateContentScaleLevel=function(){i.contentScaleLevel=0},i.contentScaleLevel=0,i.contentScaleFactor=1,i}(t.GComponent);t.GRoot=e}(fgui||(fgui={})),function(t){var e=function(t){function e(){var e=t.call(this)||this;return e._dragOffset=new egret.Point,e._scrollPerc=0,e}return __extends(e,t),e.prototype.setScrollPane=function(t,e){this._target=t,this._vertical=e},e.prototype.setDisplayPerc=function(t){this._vertical?(this._fixedGripSize||(this._grip.height=Math.floor(t*this._bar.height)),this._grip.y=this._bar.y+(this._bar.height-this._grip.height)*this._scrollPerc):(this._fixedGripSize||(this._grip.width=Math.floor(t*this._bar.width)),this._grip.x=this._bar.x+(this._bar.width-this._grip.width)*this._scrollPerc),this._grip.visible=0!=t&&1!=t},e.prototype.setScrollPerc=function(t){this._scrollPerc=t,this._vertical?this._grip.y=this._bar.y+(this._bar.height-this._grip.height)*this._scrollPerc:this._grip.x=this._bar.x+(this._bar.width-this._grip.width)*this._scrollPerc},Object.defineProperty(e.prototype,"minSize",{get:function(){return this._vertical?(this._arrowButton1?this._arrowButton1.height:0)+(this._arrowButton2?this._arrowButton2.height:0):(this._arrowButton1?this._arrowButton1.width:0)+(this._arrowButton2?this._arrowButton2.width:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"gripDragging",{get:function(){return this._gripDragging},enumerable:!0,configurable:!0}),e.prototype.constructExtension=function(t){t.seek(0,6),this._fixedGripSize=t.readBool(),this._grip=this.getChild("grip"),this._grip?(this._bar=this.getChild("bar"),this._bar?(this._arrowButton1=this.getChild("arrow1"),this._arrowButton2=this.getChild("arrow2"),this._grip.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__gripMouseDown,this),this._arrowButton1&&this._arrowButton1.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__arrowButton1Click,this),this._arrowButton2&&this._arrowButton2.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__arrowButton2Click,this),this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__barMouseDown,this)):console.error("需要定义bar")):console.error("需要定义grip")},e.prototype.__gripMouseDown=function(t){this._gripDragging=!0,this._target.updateScrollBarVisible(),t.stopPropagation(),this.globalToLocal(t.stageX,t.stageY,this._dragOffset),this._dragOffset.x-=this._grip.x,this._dragOffset.y-=this._grip.y,this._grip.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.__gripMouseMove,this),this._grip.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.__gripMouseUp,this)},e.prototype.__gripMouseMove=function(t){if(this.onStage){var e=this.globalToLocal(t.stageX,t.stageY,i);if(this._vertical){var n=e.y-this._dragOffset.y;this._target.setPercY((n-this._bar.y)/(this._bar.height-this._grip.height),!1)}else{var o=e.x-this._dragOffset.x;this._target.setPercX((o-this._bar.x)/(this._bar.width-this._grip.width),!1)}}},e.prototype.__gripMouseUp=function(t){var e=t.currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.__gripMouseMove,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.__gripMouseUp,this),this.onStage||(this._gripDragging=!1,this._target.updateScrollBarVisible())},e.prototype.__arrowButton1Click=function(t){t.stopPropagation(),this._vertical?this._target.scrollUp():this._target.scrollLeft()},e.prototype.__arrowButton2Click=function(t){t.stopPropagation(),this._vertical?this._target.scrollDown():this._target.scrollRight()},e.prototype.__barMouseDown=function(t){var e=this._grip.globalToLocal(t.stageX,t.stageY,i);this._vertical?e.y<0?this._target.scrollUp(4):this._target.scrollDown(4):e.x<0?this._target.scrollLeft(4):this._target.scrollRight(4)},e}(t.GComponent);t.GScrollBar=e;var i=new egret.Point}(fgui||(fgui={})),function(t){var e=function(e){function n(){var i=e.call(this)||this;return i._min=0,i._max=0,i._value=0,i._barMaxWidth=0,i._barMaxHeight=0,i._barMaxWidthDelta=0,i._barMaxHeightDelta=0,i._clickPercent=0,i._barStartX=0,i._barStartY=0,i.changeOnClick=!0,i.canDrag=!0,i._titleType=t.ProgressTitleType.Percent,i._value=50,i._max=100,i._clickPos=new egret.Point,i}return __extends(n,e),Object.defineProperty(n.prototype,"titleType",{get:function(){return this._titleType},set:function(t){this._titleType=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"wholeNumbers",{get:function(){return this._wholeNumbers},set:function(t){this._wholeNumbers!=t&&(this._wholeNumbers=t,this.update())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"min",{get:function(){return this._min},set:function(t){this._min!=t&&(this._min=t,this.update())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"max",{get:function(){return this._max},set:function(t){this._max!=t&&(this._max=t,this.update())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this._value},set:function(t){this._value!=t&&(this._value=t,this.update())},enumerable:!0,configurable:!0}),n.prototype.update=function(){this.updateWithPercent((this._value-this._min)/(this._max-this._min))},n.prototype.updateWithPercent=function(e,i){if(e=t.ToolSet.clamp01(e),i){var n=t.ToolSet.clamp(this._min+(this._max-this._min)*e,this._min,this._max);this._wholeNumbers&&(n=Math.round(n),e=t.ToolSet.clamp01((n-this._min)/(this._max-this._min))),n!=this._value&&(this._value=n,this.dispatchEvent(new t.StateChangeEvent(t.StateChangeEvent.CHANGED)))}if(this._titleObject)switch(this._titleType){case t.ProgressTitleType.Percent:this._titleObject.text=Math.floor(100*e)+"%";break;case t.ProgressTitleType.ValueAndMax:this._titleObject.text=this._value+"/"+this._max;break;case t.ProgressTitleType.Value:this._titleObject.text=""+this._value;break;case t.ProgressTitleType.Max:this._titleObject.text=""+this._max}var o=this.width-this._barMaxWidthDelta,r=this.height-this._barMaxHeightDelta;this._reverse?(this._barObjectH&&(this._barObjectH.width=Math.round(o*e),this._barObjectH.x=this._barStartX+(o-this._barObjectH.width)),this._barObjectV&&(this._barObjectV.height=Math.round(r*e),this._barObjectV.y=this._barStartY+(r-this._barObjectV.height))):(this._barObjectH&&(this._barObjectH.width=Math.round(o*e)),this._barObjectV&&(this._barObjectV.height=Math.round(r*e)))},n.prototype.constructExtension=function(t){t.seek(0,6),this._titleType=t.readByte(),this._reverse=t.readBool(),t.version>=2&&(this._wholeNumbers=t.readBool(),this.changeOnClick=t.readBool()),this._titleObject=this.getChild("title"),this._barObjectH=this.getChild("bar"),this._barObjectV=this.getChild("bar_v"),this._gripObject=this.getChild("grip"),this._barObjectH&&(this._barMaxWidth=this._barObjectH.width,this._barMaxWidthDelta=this.width-this._barMaxWidth,this._barStartX=this._barObjectH.x),this._barObjectV&&(this._barMaxHeight=this._barObjectV.height,this._barMaxHeightDelta=this.height-this._barMaxHeight,this._barStartY=this._barObjectV.y),this._gripObject&&this._gripObject.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__gripMouseDown,this),this.displayObject.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__barMouseDown,this)},n.prototype.handleSizeChanged=function(){e.prototype.handleSizeChanged.call(this),this._barObjectH&&(this._barMaxWidth=this.width-this._barMaxWidthDelta),this._barObjectV&&(this._barMaxHeight=this.height-this._barMaxHeightDelta),this._underConstruct||this.update()},n.prototype.setup_afterAdd=function(t,i){e.prototype.setup_afterAdd.call(this,t,i),t.seek(i,6)&&t.readByte()==this.packageItem.objectType?(this._value=t.readInt(),this._max=t.readInt(),t.version>=2&&(this._min=t.readInt()),this.update()):this.update()},n.prototype.__gripMouseDown=function(e){this.canDrag=!0,e.stopPropagation(),this._clickPos=this.globalToLocal(e.stageX,e.stageY),this._clickPercent=t.ToolSet.clamp01((this._value-this._min)/(this._max-this._min)),this._gripObject.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.__gripMouseMove,this),this._gripObject.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.__gripMouseUp,this)},n.prototype.__gripMouseMove=function(t){if(this.canDrag){var e,n=this.globalToLocal(t.stageX,t.stageY,i),o=n.x-this._clickPos.x,r=n.y-this._clickPos.y;this._reverse&&(o=-o,r=-r),e=this._barObjectH?this._clickPercent+o/this._barMaxWidth:this._clickPercent+r/this._barMaxHeight,this.updateWithPercent(e,!0)}},n.prototype.__gripMouseUp=function(t){t.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.__gripMouseMove,this),t.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END,this.__gripMouseUp,this)},n.prototype.__barMouseDown=function(e){if(this.changeOnClick){var n,o=this._gripObject.globalToLocal(e.stageX,e.stageY,i),r=t.ToolSet.clamp01((this._value-this._min)/(this._max-this._min));this._barObjectH&&(n=o.x/this._barMaxWidth),this._barObjectV&&(n=o.y/this._barMaxHeight),this._reverse?r-=n:r+=n,this.updateWithPercent(r,!0)}},n}(t.GComponent);t.GSlider=e;var i=new egret.Point}(fgui||(fgui={})),function(t){var e=function(e){function i(){var t=e.call(this)||this;return t._widthAutoSize=!1,t._heightAutoSize=!1,t.displayObject.touchChildren=!0,t._textField.type=egret.TextFieldType.INPUT,t._textField.addEventListener(egret.Event.CHANGE,t.__textChanged,t),t._textField.addEventListener(egret.FocusEvent.FOCUS_IN,t.__focusIn,t),t._textField.addEventListener(egret.FocusEvent.FOCUS_OUT,t.__focusOut,t),t}return __extends(i,e),i.prototype.dispose=function(){e.prototype.dispose.call(this)},Object.defineProperty(i.prototype,"editable",{get:function(){return this._textField.type==egret.TextFieldType.INPUT},set:function(t){this._textField.type=t?egret.TextFieldType.INPUT:egret.TextFieldType.DYNAMIC},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"maxLength",{get:function(){return this._textField.maxChars},set:function(t){this._textField.maxChars=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"promptText",{get:function(){return this._promptText},set:function(t){this._promptText=t,this.updateTextFieldText()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"restrict",{get:function(){return this._textField.restrict},set:function(t){this._textField.restrict=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"password",{get:function(){return this._password},set:function(t){this._password!=t&&(this._password=t,this._textField.displayAsPassword=this._password,this._textField.inputType=t?egret.TextFieldInputType.PASSWORD:egret.TextFieldInputType.TEXT,this.render())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"verticalAlign",{get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!=t&&(this._verticalAlign=t,this.updateVertAlign())},enumerable:!0,configurable:!0}),i.prototype.updateVertAlign=function(){switch(this._verticalAlign){case t.VertAlignType.Top:this._textField.verticalAlign=egret.VerticalAlign.TOP;break;case t.VertAlignType.Middle:this._textField.verticalAlign=egret.VerticalAlign.MIDDLE;break;case t.VertAlignType.Bottom:this._textField.verticalAlign=egret.VerticalAlign.BOTTOM}},i.prototype.updateTextFieldText=function(){!this._text&&this._promptText?(this._textField.displayAsPassword=!1,this._textField.textFlow=(new egret.HtmlTextParser).parser(t.UBBParser.inst.parse(this._promptText))):(this._textField.displayAsPassword=this._password,this._ubbEnabled?this._textField.textFlow=(new egret.HtmlTextParser).parser(t.UBBParser.inst.parse(t.ToolSet.encodeHTML(this._text))):this._textField.text=this._text)},i.prototype.handleSizeChanged=function(){this._updatingSize||(this._textField.width=Math.ceil(this.width),this._textField.height=Math.ceil(this.height))},i.prototype.setup_beforeAdd=function(t,i){e.prototype.setup_beforeAdd.call(this,t,i),t.seek(i,4);var n=t.readS();null!=n&&(this._promptText=n),null!=(n=t.readS())&&(this._textField.restrict=n);var o=t.readInt();0!=o&&(this._textField.maxChars=o),o=t.readInt(),t.readBool()&&(this.password=!0),this.updateVertAlign()},i.prototype.setup_afterAdd=function(i,n){e.prototype.setup_afterAdd.call(this,i,n),!this._text&&this._promptText&&(this._textField.displayAsPassword=!1,this._textField.textFlow=(new egret.HtmlTextParser).parser(t.UBBParser.inst.parse(t.ToolSet.encodeHTML(this._promptText))))},i.prototype.__textChanged=function(t){this._text=this._textField.text},i.prototype.__focusIn=function(t){!this._text&&this._promptText&&(this._textField.displayAsPassword=this._password,this._textField.text="")},i.prototype.__focusOut=function(e){this._text=this._textField.text,!this._text&&this._promptText&&(this._textField.displayAsPassword=!1,this._textField.textFlow=(new egret.HtmlTextParser).parser(t.UBBParser.inst.parse(t.ToolSet.encodeHTML(this._promptText))))},i}(t.GTextField);t.GTextInput=e}(fgui||(fgui={})),function(t){var e=function(e){function n(){var i=e.call(this)||this;return i._indent=15,i._rootNode=new t.GTreeNode(!0),i._rootNode._setTree(i),i._rootNode.expanded=!0,i}return __extends(n,e),Object.defineProperty(n.prototype,"rootNode",{get:function(){return this._rootNode},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"indent",{get:function(){return this._indent},set:function(t){this._indent=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"clickToExpand",{get:function(){return this._clickToExpand},set:function(t){this._clickToExpand=t},enumerable:!0,configurable:!0}),n.prototype.getSelectedNode=function(){return-1!=this.selectedIndex?this.getChildAt(this.selectedIndex)._treeNode:null},n.prototype.getSelectedNodes=function(t){t||(t=new Array),i.length=0,e.prototype.getSelection.call(this,i);for(var n=i.length,o=new Array,r=0;rl)a.addChild(c);else if(h=0&&e<=i){if(t._parent==this)this.setChildIndex(t,e);else t._parent&&t._parent.removeChild(t),e==this._children.length?this._children.push(t):this._children.splice(e,0,t),t._parent=this,t._level=this._level+1,t._setTree(this._tree),(this._tree&&this==this._tree.rootNode||this._cell&&this._cell.parent&&this._expanded)&&this._tree._afterInserted(t);return t}throw new RangeError("Invalid child index")},t.prototype.removeChild=function(t){var e=this._children.indexOf(t);return-1!=e&&this.removeChildAt(e),t},t.prototype.removeChildAt=function(t){if(t>=0&&t=this.numChildren)&&(e=this.numChildren-1);for(var i=t;i<=e;++i)this.removeChildAt(t)},t.prototype.getChildAt=function(t){if(t>=0&&t=this._parent._children.length-1?null:this._parent._children[t+1]},t.prototype.setChildIndex=function(t,e){var i=this._children.indexOf(t);if(-1==i)throw"Not a child of this container";var n=this._children.length;e<0?e=0:e>n&&(e=n),i!=e&&(this._children.splice(i,1),this._children.splice(e,0,t),(this._tree&&this==this._tree.rootNode||this._cell&&this._cell.parent&&this._expanded)&&this._tree._afterMoved(t))},t.prototype.swapChildren=function(t,e){var i=this._children.indexOf(t),n=this._children.indexOf(e);if(-1==i||-1==n)throw"Not a child of this container";this.swapChildrenAt(i,n)},t.prototype.swapChildrenAt=function(t,e){var i=this._children[t],n=this._children[e];this.setChildIndex(i,e),this.setChildIndex(n,t)},Object.defineProperty(t.prototype,"numChildren",{get:function(){return this._children.length},enumerable:!0,configurable:!0}),t.prototype.expandToRoot=function(){for(var t=this;t;)t.expanded=!0,t=t.parent},Object.defineProperty(t.prototype,"tree",{get:function(){return this._tree},enumerable:!0,configurable:!0}),t.prototype._setTree=function(t){if(this._tree=t,this._tree&&this._tree.treeNodeWillExpand&&this._expanded&&this._tree.treeNodeWillExpand(this,!0),this._children)for(var e=this._children.length,i=0;i=this._data.pixelWidth)return!1;var i=e*this._data.pixelWidth+t,n=Math.floor(i/8),o=i%8;return n>=0&&n>o&1)},t}();t.PixelHitTest=e;var i=function(){function t(){}return t.prototype.load=function(t){t.readInt(),this.pixelWidth=t.readInt(),this.scale=1/t.readByte();var e=t.readInt();this.pixels=[];for(var i=0;i0){var e=this.highResolution[t.GRoot.contentScaleLevel-1];if(e)return this.owner.getItemById(e)}return this},e.prototype.toString=function(){return this.name},e}();t.PackageItem=e}(fgui||(fgui={})),function(t){var e=function(){function e(e){if(!e&&!(e=t.UIConfig.popupMenu))throw"UIConfig.popupMenu not defined";this._contentPane=t.UIPackage.createObjectFromURL(e).asCom,this._contentPane.addEventListener(egret.Event.ADDED_TO_STAGE,this.__addedToStage,this),this._list=this._contentPane.getChild("list"),this._list.removeChildrenToPool(),this._list.addRelation(this._contentPane,t.RelationType.Width),this._list.removeRelation(this._contentPane,t.RelationType.Height),this._contentPane.addRelation(this._list,t.RelationType.Height),this._list.addEventListener(t.ItemEvent.CLICK,this.__clickItem,this)}return e.prototype.dispose=function(){this._contentPane.dispose()},e.prototype.addItem=function(t,e){var i=this._list.addItemFromPool().asButton;i.title=t,i.data=e,i.grayed=!1;var n=i.getController("checked");return n&&(n.selectedIndex=0),i},e.prototype.addItemAt=function(t,e,i){var n=this._list.getFromPool().asButton;this._list.addChildAt(n,e),n.title=t,n.data=i,n.grayed=!1;var o=n.getController("checked");return o&&(o.selectedIndex=0),n},e.prototype.addSeperator=function(){if(null==t.UIConfig.popupMenu_seperator)throw"UIConfig.popupMenu_seperator not defined";this.list.addItemFromPool(t.UIConfig.popupMenu_seperator)},e.prototype.getItemName=function(t){return this._list.getChildAt(t).name},e.prototype.setItemText=function(t,e){this._list.getChild(t).asButton.title=e},e.prototype.setItemVisible=function(t,e){var i=this._list.getChild(t).asButton;i.visible!=e&&(i.visible=e,this._list.setBoundsChangedFlag())},e.prototype.setItemGrayed=function(t,e){this._list.getChild(t).asButton.grayed=e},e.prototype.setItemCheckable=function(t,e){var i=this._list.getChild(t).asButton.getController("checked");i&&(e?0==i.selectedIndex&&(i.selectedIndex=1):i.selectedIndex=0)},e.prototype.setItemChecked=function(t,e){var i=this._list.getChild(t).asButton.getController("checked");i&&(i.selectedIndex=e?2:1)},e.prototype.isItemChecked=function(t){var e=this._list.getChild(t).asButton.getController("checked");return!!e&&2==e.selectedIndex},e.prototype.removeItem=function(t){var e=this._list.getChild(t);if(e){var i=this._list.getChildIndex(e);return this._list.removeChildToPoolAt(i),!0}return!1},e.prototype.clearItems=function(){this._list.removeChildrenToPool()},Object.defineProperty(e.prototype,"itemCount",{get:function(){return this._list.numChildren},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contentPane",{get:function(){return this._contentPane},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"list",{get:function(){return this._list},enumerable:!0,configurable:!0}),e.prototype.show=function(e,i){(e?e.root:t.GRoot.inst).showPopup(this.contentPane,e instanceof t.GRoot?null:e,i)},e.prototype.__clickItem=function(e){t.GTimers.inst.add(100,1,this.__clickItem2,this,e)},e.prototype.__clickItem2=function(t){var e=t.itemObject.asButton;if(null!=e)if(e.grayed)this._list.selectedIndex=-1;else{var i=e.getController("checked");i&&0!=i.selectedIndex&&(1==i.selectedIndex?i.selectedIndex=2:i.selectedIndex=1),this._contentPane.parent.hidePopup(this.contentPane),null!=e.data&&(1==e.data.length?e.data(t):e.data())}},e.prototype.__addedToStage=function(t){this._list.selectedIndex=-1,this._list.resizeToFit(1e5,10)},e}();t.PopupMenu=e}(fgui||(fgui={})),function(t){var e=function(){function e(t){this._owner=t,this._defs=new Array}return Object.defineProperty(e.prototype,"owner",{get:function(){return this._owner},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},set:function(t){this._target!=t&&(this._target&&this.releaseRefTarget(this._target),this._target=t,this._target&&this.addRefTarget(this._target))},enumerable:!0,configurable:!0}),e.prototype.add=function(e,i){if(e==t.RelationType.Size)return this.add(t.RelationType.Width,i),void this.add(t.RelationType.Height,i);for(var n=this._defs.length,o=0;o=t.RelationType.LeftExt_Left&&e<=t.RelationType.RightExt_Right?0:1,this._defs.push(o),(n||e==t.RelationType.Left_Center||e==t.RelationType.Center_Center||e==t.RelationType.Right_Center||e==t.RelationType.Top_Middle||e==t.RelationType.Middle_Middle||e==t.RelationType.Bottom_Middle)&&(this._owner.pixelSnapping=!0)},e.prototype.remove=function(e){if(void 0===e&&(e=0),e==t.RelationType.Size)return this.remove(t.RelationType.Width),void this.remove(t.RelationType.Height);for(var i=this._defs.length,n=0;n0)for(a=0;a0)for(s=0;s0)for(s=0;s.5*this._pageSize.x&&t++,t},set:function(t){this.setCurrentPageX(t,!1)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"currentPageY",{get:function(){if(!this._pageMode)return 0;var t=Math.floor(this._yPos/this._pageSize.y);return this._yPos-t*this._pageSize.y>.5*this._pageSize.y&&t++,t},set:function(t){this.setCurrentPageY(t,!1)},enumerable:!0,configurable:!0}),c.prototype.setCurrentPageX=function(t,e){this._pageMode&&(this._owner.ensureBoundsCorrect(),this._overlapSize.x>0&&this.setPosX(t*this._pageSize.x,e))},c.prototype.setCurrentPageY=function(t,e){this._pageMode&&(this._owner.ensureBoundsCorrect(),this._overlapSize.y>0&&this.setPosY(t*this._pageSize.y,e))},Object.defineProperty(c.prototype,"isBottomMost",{get:function(){return this._yPos==this._overlapSize.y||0==this._overlapSize.y},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"isRightMost",{get:function(){return this._xPos==this._overlapSize.x||0==this._overlapSize.x},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"pageController",{get:function(){return this._pageController},set:function(t){this._pageController=t},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scrollingPosX",{get:function(){return t.ToolSet.clamp(-this._container.x,0,this._overlapSize.x)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scrollingPosY",{get:function(){return t.ToolSet.clamp(-this._container.y,0,this._overlapSize.y)},enumerable:!0,configurable:!0}),c.prototype.scrollTop=function(t){this.setPercY(0,t)},c.prototype.scrollBottom=function(t){this.setPercY(1,t)},c.prototype.scrollUp=function(t,e){t=t||1,this._pageMode?this.setPosY(this._yPos-this._pageSize.y*t,e):this.setPosY(this._yPos-this._scrollStep*t,e)},c.prototype.scrollDown=function(t,e){t=t||1,this._pageMode?this.setPosY(this._yPos+this._pageSize.y*t,e):this.setPosY(this._yPos+this._scrollStep*t,e)},c.prototype.scrollLeft=function(t,e){t=t||1,this._pageMode?this.setPosX(this._xPos-this._pageSize.x*t,e):this.setPosX(this._xPos-this._scrollStep*t,e)},c.prototype.scrollRight=function(t,e){t=t||1,this._pageMode?this.setPosX(this._xPos+this._pageSize.x*t,e):this.setPosX(this._xPos+this._scrollStep*t,e)},c.prototype.scrollToView=function(e,i,n){var o;if(this._owner.ensureBoundsCorrect(),this._needRefresh&&this.refresh(),e instanceof t.GObject?e.parent!=this._owner?(e.parent.localToGlobalRect(e.x,e.y,e.width,e.height,a),o=this._owner.globalToLocalRect(a.x,a.y,a.width,a.height,a)):(o=a).setTo(e.x,e.y,e.width,e.height):o=e,this._overlapSize.y>0){var r=this._yPos+this._viewSize.y;n||o.y<=this._yPos||o.height>=this._viewSize.y?this._pageMode?this.setPosY(Math.floor(o.y/this._pageSize.y)*this._pageSize.y,i):this.setPosY(o.y,i):o.y+o.height>r&&(this._pageMode?this.setPosY(Math.floor(o.y/this._pageSize.y)*this._pageSize.y,i):o.height<=this._viewSize.y/2?this.setPosY(o.y+2*o.height-this._viewSize.y,i):this.setPosY(o.y+o.height-this._viewSize.y,i))}if(this._overlapSize.x>0){var s=this._xPos+this._viewSize.x;n||o.x<=this._xPos||o.width>=this._viewSize.x?this._pageMode?this.setPosX(Math.floor(o.x/this._pageSize.x)*this._pageSize.x,i):this.setPosX(o.x,i):o.x+o.width>s&&(this._pageMode?this.setPosX(Math.floor(o.x/this._pageSize.x)*this._pageSize.x,i):o.width<=this._viewSize.x/2?this.setPosX(o.x+2*o.width-this._viewSize.x,i):this.setPosX(o.x+o.width-this._viewSize.x,i))}!i&&this._needRefresh&&this.refresh()},c.prototype.isChildInView=function(t){if(this._overlapSize.y>0){var e=t.y+this._container.y;if(e<-t.height||e>this._viewSize.y)return!1}return!(this._overlapSize.x>0&&((e=t.x+this._container.x)<-t.width||e>this._viewSize.x))},c.prototype.cancelDragging=function(){this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.__touchMove,this),this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_END,this.__touchEnd,this),this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.__touchTap,this),c.draggingPane==this&&(c.draggingPane=null),i=0,this._dragged=!1,this._maskContainer.touchChildren=!0},c.prototype.lockHeader=function(t){this._headerLockedSize!=t&&(this._headerLockedSize=t,!this._refreshEventDispatching&&this._container[this._refreshBarAxis]>=0&&(this._tweenStart.setTo(this._container.x,this._container.y),this._tweenChange.setTo(0,0),this._tweenChange[this._refreshBarAxis]=this._headerLockedSize-this._tweenStart[this._refreshBarAxis],this._tweenDuration.setTo(o,o),this.startTween(2)))},c.prototype.lockFooter=function(t){if(this._footerLockedSize!=t&&(this._footerLockedSize=t,!this._refreshEventDispatching&&this._container[this._refreshBarAxis]<=-this._overlapSize[this._refreshBarAxis])){this._tweenStart.setTo(this._container.x,this._container.y),this._tweenChange.setTo(0,0);var e=this._overlapSize[this._refreshBarAxis];0==e?e=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0):e+=this._footerLockedSize,this._tweenChange[this._refreshBarAxis]=-e-this._tweenStart[this._refreshBarAxis],this._tweenDuration.setTo(o,o),this.startTween(2)}},c.prototype.onOwnerSizeChanged=function(){this.setSize(this._owner.width,this._owner.height),this.posChanged(!1)},c.prototype.handleControllerChanged=function(e){this._pageController==e&&(this._scrollType==t.ScrollType.Horizontal?this.setCurrentPageX(e.selectedIndex,!0):this.setCurrentPageY(e.selectedIndex,!0))},c.prototype.updatePageController=function(){var e;if(this._pageController&&!this._pageController.changing&&(e=this._scrollType==t.ScrollType.Horizontal?this.currentPageX:this.currentPageY)0?t=-Math.floor(this._xPos):(0!=this._container.x&&(this._container.x=0),t=0),this._overlapSize.y>0?e=-Math.floor(this._yPos):(0!=this._container.y&&(this._container.y=0),e=0),t!=this._container.x||e!=this._container.y?(this._tweenDuration.setTo(n,n),this._tweenStart.setTo(this._container.x,this._container.y),this._tweenChange.setTo(t-this._tweenStart.x,e-this._tweenStart.y),this.startTween(1)):0!=this._tweening&&this.killTween());this._pageMode&&this.updatePageController()},c.prototype.__touchBegin=function(t){if(this._touchEffect){0!=this._tweening?(this.killTween(),this._dragged=!0):this._dragged=!1;var e=this._owner.globalToLocal(t.stageX,t.stageY,s);this._containerPos.setTo(this._container.x,this._container.y),this._beginTouchPos.setTo(e.x,e.y),this._lastTouchPos.setTo(e.x,e.y),this._lastTouchGlobalPos.setTo(t.stageX,t.stageY),this._isHoldAreaDone=!1,this._velocity.setTo(0,0),this._velocityScale=1,this._lastMoveTime=egret.getTimer()/1e3,this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.__touchMove,this),this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.__touchEnd,this),this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_TAP,this.__touchTap,this)}},c.prototype.__touchMove=function(e){if(null!=this._owner.displayObject.stage&&this._touchEffect&&!(c.draggingPane&&c.draggingPane!=this||t.GObject.draggingObject)){var n,o,a,h=this._owner.globalToLocal(e.stageX,e.stageY,s),l=t.UIConfig.touchScrollSensitivity;if(this._scrollType==t.ScrollType.Vertical){if(!this._isHoldAreaDone){if(i|=1,(n=Math.abs(this._beginTouchPos.y-h.y))0?this._bouncebackEffect?this._header&&0!=this._header.maxHeight?this._container.y=Math.floor(Math.min(.5*_,this._header.maxHeight)):this._container.y=Math.floor(Math.min(.5*_,this._viewSize.y*r)):this._container.y=0:_<-this._overlapSize.y?this._bouncebackEffect?this._footer&&this._footer.maxHeight>0?this._container.y=Math.floor(Math.max(.5*(_+this._overlapSize.y),-this._footer.maxHeight)-this._overlapSize.y):this._container.y=Math.floor(Math.max(.5*(_+this._overlapSize.y),-this._viewSize.y*r)-this._overlapSize.y):this._container.y=-this._overlapSize.y:this._container.y=_),a&&(u>0?this._bouncebackEffect?this._header&&0!=this._header.maxWidth?this._container.x=Math.floor(Math.min(.5*u,this._header.maxWidth)):this._container.x=Math.floor(Math.min(.5*u,this._viewSize.x*r)):this._container.x=0:u<0-this._overlapSize.x?this._bouncebackEffect?this._footer&&this._footer.maxWidth>0?this._container.x=Math.floor(Math.max(.5*(u+this._overlapSize.x),-this._footer.maxWidth)-this._overlapSize.x):this._container.x=Math.floor(Math.max(.5*(u+this._overlapSize.x),-this._viewSize.x*r)-this._overlapSize.x):this._container.x=-this._overlapSize.x:this._container.x=u);var p=egret.getTimer()/1e3,d=Math.max(p-this._lastMoveTime,1/60),g=h.x-this._lastTouchPos.x,f=h.y-this._lastTouchPos.y;if(a||(g=0),o||(f=0),0!=d){var y=this._owner.displayObject.stage.frameRate,m=d*y-1;if(m>1){var b=Math.pow(.833,m);this._velocity.x=this._velocity.x*b,this._velocity.y=this._velocity.y*b}this._velocity.x=t.ToolSet.lerp(this._velocity.x,60*g/y/d,10*d),this._velocity.y=t.ToolSet.lerp(this._velocity.y,60*f/y/d,10*d)}var v=this._lastTouchGlobalPos.x-e.stageX,w=this._lastTouchGlobalPos.y-e.stageY;0!=g?this._velocityScale=Math.abs(v/g):0!=f&&(this._velocityScale=Math.abs(w/f)),this._lastTouchPos.setTo(h.x,h.y),this._lastTouchGlobalPos.setTo(e.stageX,e.stageY),this._lastMoveTime=p,this._overlapSize.x>0&&(this._xPos=t.ToolSet.clamp(-this._container.x,0,this._overlapSize.x)),this._overlapSize.y>0&&(this._yPos=t.ToolSet.clamp(-this._container.y,0,this._overlapSize.y)),0!=this._loop&&(u=this._container.x,_=this._container.y,this.loopCheckingCurrent()&&(this._containerPos.x+=this._container.x-u,this._containerPos.y+=this._container.y-_)),c.draggingPane=this,this._isHoldAreaDone=!0,this._dragged=!0,this._maskContainer.touchChildren=!1,this.updateScrollBarPos(),this.updateScrollBarVisible(),this._pageMode&&this.updatePageController(),this.dispatchEventWith(c.SCROLL)}},c.prototype.__touchEnd=function(e){if(e.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.__touchMove,this),e.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END,this.__touchEnd,this),e.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.__touchTap,this),c.draggingPane==this&&(c.draggingPane=null),i=0,!this._dragged||!this._touchEffect||null==this._owner.displayObject.stage)return this._dragged=!1,void(this._maskContainer.touchChildren=!0);this._dragged=!1,this._maskContainer.touchChildren=!0,this._tweenStart.setTo(this._container.x,this._container.y),h.setTo(this._tweenStart.x,this._tweenStart.y);var n=!1;if(this._container.x>0?(h.x=0,n=!0):this._container.x<-this._overlapSize.x&&(h.x=-this._overlapSize.x,n=!0),this._container.y>0?(h.y=0,n=!0):this._container.y<-this._overlapSize.y&&(h.y=-this._overlapSize.y,n=!0),n){if(this._tweenChange.setTo(h.x-this._tweenStart.x,h.y-this._tweenStart.y),this._tweenChange.x<-t.UIConfig.touchDragSensitivity||this._tweenChange.y<-t.UIConfig.touchDragSensitivity?(this._refreshEventDispatching=!0,this.dispatchEventWith(c.PULL_DOWN_RELEASE),this._refreshEventDispatching=!1):(this._tweenChange.x>t.UIConfig.touchDragSensitivity||this._tweenChange.y>t.UIConfig.touchDragSensitivity)&&(this._refreshEventDispatching=!0,this.dispatchEventWith(c.PULL_UP_RELEASE),this._refreshEventDispatching=!1),this._headerLockedSize>0&&0==h[this._refreshBarAxis])h[this._refreshBarAxis]=this._headerLockedSize,this._tweenChange.x=h.x-this._tweenStart.x,this._tweenChange.y=h.y-this._tweenStart.y;else if(this._footerLockedSize>0&&h[this._refreshBarAxis]==-this._overlapSize[this._refreshBarAxis]){var r=this._overlapSize[this._refreshBarAxis];0==r?r=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0):r+=this._footerLockedSize,h[this._refreshBarAxis]=-r,this._tweenChange.x=h.x-this._tweenStart.x,this._tweenChange.y=h.y-this._tweenStart.y}this._tweenDuration.setTo(o,o)}else{if(this._inertiaDisabled)this._tweenDuration.setTo(o,o);else{var s=this._owner.displayObject.stage.frameRate,a=(egret.getTimer()/1e3-this._lastMoveTime)*s-1;if(a>1){var u=Math.pow(.833,a);this._velocity.x=this._velocity.x*u,this._velocity.y=this._velocity.y*u}this.updateTargetAndDuration(this._tweenStart,h)}if(l.setTo(h.x-this._tweenStart.x,h.y-this._tweenStart.y),this.loopCheckingTarget(h),(this._pageMode||this._snapToItem)&&this.alignPosition(h,!0),this._tweenChange.x=h.x-this._tweenStart.x,this._tweenChange.y=h.y-this._tweenStart.y,0==this._tweenChange.x&&0==this._tweenChange.y)return void this.updateScrollBarVisible();(this._pageMode||this._snapToItem)&&(this.fixDuration("x",l.x),this.fixDuration("y",l.y))}this.startTween(2)},c.prototype.__touchTap=function(t){this._dragged=!1},c.prototype.updateScrollBarPos=function(){this._vtScrollBar&&this._vtScrollBar.setScrollPerc(0==this._overlapSize.y?0:t.ToolSet.clamp(-this._container.y,0,this._overlapSize.y)/this._overlapSize.y),this._hzScrollBar&&this._hzScrollBar.setScrollPerc(0==this._overlapSize.x?0:t.ToolSet.clamp(-this._container.x,0,this._overlapSize.x)/this._overlapSize.x),this.checkRefreshBar()},c.prototype.updateScrollBarVisible=function(){this._vtScrollBar&&(this._viewSize.y<=this._vtScrollBar.minSize||this._vScrollNone?this._vtScrollBar.displayObject.visible=!1:this.updateScrollBarVisible2(this._vtScrollBar)),this._hzScrollBar&&(this._viewSize.x<=this._hzScrollBar.minSize||this._hScrollNone?this._hzScrollBar.displayObject.visible=!1:this.updateScrollBarVisible2(this._hzScrollBar))},c.prototype.updateScrollBarVisible2=function(e){this._scrollBarDisplayAuto&&t.GTween.kill(e,!1,"alpha"),!this._scrollBarDisplayAuto||0!=this._tweening||this._dragged||e.gripDragging?(e.alpha=1,e.displayObject.visible=!0):e.displayObject.visible&&t.GTween.to(1,0,.5).setDelay(.5).onComplete(this.__barTweenComplete,this).setTarget(e,"alpha")},c.prototype.__barTweenComplete=function(t){var e=t.target;e.alpha=1,e.displayObject.visible=!1},c.prototype.getLoopPartSize=function(t,e){return(this._contentSize[e]+("x"==e?this._owner.columnGap:this._owner.lineGap))/t},c.prototype.loopCheckingCurrent=function(){var t=!1;return 1==this._loop&&this._overlapSize.x>0?this._xPos<.001?(this._xPos+=this.getLoopPartSize(2,"x"),t=!0):this._xPos>=this._overlapSize.x&&(this._xPos-=this.getLoopPartSize(2,"x"),t=!0):2==this._loop&&this._overlapSize.y>0&&(this._yPos<.001?(this._yPos+=this.getLoopPartSize(2,"y"),t=!0):this._yPos>=this._overlapSize.y&&(this._yPos-=this.getLoopPartSize(2,"y"),t=!0)),t&&(this._container.x=Math.floor(-this._xPos),this._container.y=Math.floor(-this._yPos)),t},c.prototype.loopCheckingTarget=function(t){1==this._loop&&this.loopCheckingTarget2(t,"x"),2==this._loop&&this.loopCheckingTarget2(t,"y")},c.prototype.loopCheckingTarget2=function(t,e){var i,n;t[e]>0?(i=this.getLoopPartSize(2,e),(n=this._tweenStart[e]-i)<=0&&n>=-this._overlapSize[e]&&(t[e]-=i,this._tweenStart[e]=n)):t[e]<-this._overlapSize[e]&&(i=this.getLoopPartSize(2,e),(n=this._tweenStart[e]+i)<=0&&n>=-this._overlapSize[e]&&(t[e]+=i,this._tweenStart[e]=n))},c.prototype.loopCheckingNewPos=function(e,i){if(0==this._overlapSize[i])return e;var n,o="x"==i?this._xPos:this._yPos,r=!1;return e<.001?(e+=this.getLoopPartSize(2,i))>o&&(n=this.getLoopPartSize(6,i),n=Math.ceil((e-o)/n)*n,o=t.ToolSet.clamp(o+n,0,this._overlapSize[i]),r=!0):e>=this._overlapSize[i]&&(e-=this.getLoopPartSize(2,i))-this._overlapSize.x&&(t.x=-i.x),t.y<0&&t.y>-this._overlapSize.y&&(t.y=-i.y)}},c.prototype.alignByPage=function(t,e,i){var n;if(t>0)n=0;else if(t<-this._overlapSize[e])n=Math.ceil(this._contentSize[e]/this._pageSize[e])-1;else{n=Math.floor(-t/this._pageSize[e]);var o=i?t-this._containerPos[e]:t-this._container[e],r=Math.min(this._pageSize[e],this._contentSize[e]-(n+1)*this._pageSize[e]),s=-t-n*this._pageSize[e];Math.abs(o)>this._pageSize[e]?s>.5*r&&n++:s>r*(o<0?.3:.7)&&n++,(t=-n*this._pageSize[e])<-this._overlapSize[e]&&(t=-this._overlapSize[e])}if(i){var a,h=this._tweenStart[e];a=h>0?0:h<-this._overlapSize[e]?Math.ceil(this._contentSize[e]/this._pageSize[e])-1:Math.floor(-h/this._pageSize[e]);var l=Math.floor(-this._containerPos[e]/this._pageSize[e]);Math.abs(n-l)>1&&Math.abs(a-l)<=1&&(t=-(n=n>l?l+1:l-1)*this._pageSize[e])}return t},c.prototype.updateTargetAndDuration=function(t,e){e.x=this.updateTargetAndDuration2(t.x,"x"),e.y=this.updateTargetAndDuration2(t.y,"y")},c.prototype.updateTargetAndDuration2=function(t,e){var i=this._velocity[e],n=0;if(t>0)t=0;else if(t<-this._overlapSize[e])t=-this._overlapSize[e];else{var r=egret.Capabilities.isMobile,s=Math.abs(i)*this._velocityScale;r&&(s*=1136/Math.max(this._owner.displayObject.stage.stageWidth,this._owner.displayObject.stage.stageHeight));var a=0;if(this._pageMode||!r?s>500&&(a=Math.pow((s-500)/500,2)):s>1e3&&(a=Math.pow((s-1e3)/1e3,2)),0!=a)a>1&&(a=1),s*=a,i*=a,this._velocity[e]=i,n=Math.log(60/s)/Math.log(this._decelerationRate)/60,t+=Math.floor(i*n*.4)}return n=Math.abs(e))){var i=Math.abs(this._tweenChange[t]/e)*this._tweenDuration[t];i0){null==this._header.displayObject.parent&&this._maskContainer.addChildAt(this._header.displayObject,0);var e=s;e.setTo(this._header.width,this._header.height),e[this._refreshBarAxis]=t,this._header.setSize(e.x,e.y)}else this._header.displayObject.parent&&this._maskContainer.removeChild(this._header.displayObject);if(this._footer){var i=this._overlapSize[this._refreshBarAxis];t<-i||0==i&&this._footerLockedSize>0?(null==this._footer.displayObject.parent&&this._maskContainer.addChildAt(this._footer.displayObject,0),(e=s).setTo(this._footer.x,this._footer.y),e[this._refreshBarAxis]=i>0?t+this._contentSize[this._refreshBarAxis]:Math.max(Math.min(t+this._viewSize[this._refreshBarAxis],this._viewSize[this._refreshBarAxis]-this._footerLockedSize),this._viewSize[this._refreshBarAxis]-this._contentSize[this._refreshBarAxis]),this._footer.setXY(e.x,e.y),e.setTo(this._footer.width,this._footer.height),e[this._refreshBarAxis]=i>0?-i-t:this._viewSize[this._refreshBarAxis]-this._footer[this._refreshBarAxis],this._footer.setSize(e.x,e.y)):this._footer.displayObject.parent&&this._maskContainer.removeChild(this._footer.displayObject)}}},c.prototype.tweenUpdate=function(e){var i=this.runTween("x"),n=this.runTween("y");return this._container.x=i,this._container.y=n,2==this._tweening&&(this._overlapSize.x>0&&(this._xPos=t.ToolSet.clamp(-i,0,this._overlapSize.x)),this._overlapSize.y>0&&(this._yPos=t.ToolSet.clamp(-n,0,this._overlapSize.y)),this._pageMode&&this.updatePageController()),0==this._tweenChange.x&&0==this._tweenChange.y?(this._tweening=0,t.GTimers.inst.remove(this.tweenUpdate,this),this.loopCheckingCurrent(),this.updateScrollBarPos(),this.updateScrollBarVisible(),this.dispatchEventWith(c.SCROLL),this.dispatchEventWith(c.SCROLL_END)):(this.updateScrollBarPos(),this.dispatchEventWith(c.SCROLL)),!0},c.prototype.runTween=function(e){var i,n,r;if(0!=this._tweenChange[e]){if(this._tweenTime[e]+=t.GTimers.deltaTime/1e3,this._tweenTime[e]>=this._tweenDuration[e])i=this._tweenStart[e]+this._tweenChange[e],this._tweenChange[e]=0;else{var s=(n=this._tweenTime[e],r=this._tweenDuration[e],(n=n/r-1)*n*n+1);i=this._tweenStart[e]+Math.floor(this._tweenChange[e]*s)}var a=0,h=-this._overlapSize[e];if(this._headerLockedSize>0&&this._refreshBarAxis==e&&(a=this._headerLockedSize),this._footerLockedSize>0&&this._refreshBarAxis==e){var l=this._overlapSize[this._refreshBarAxis];0==l?l=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0):l+=this._footerLockedSize,h=-l}2==this._tweening&&this._bouncebackEffect?i>20+a&&this._tweenChange[e]>0||i>a&&0==this._tweenChange[e]?(this._tweenTime[e]=0,this._tweenDuration[e]=o,this._tweenChange[e]=-i+a,this._tweenStart[e]=i):(ia?(i=a,this._tweenChange[e]=0):i=0;d--){var g=this._items[d];if(g.type==r.Transition&&g.value.trans==p){g.value.stopTime=_.time-g.time;break}}d<0?_.value.stopTime=0:p=null}else _.value.stopTime=-1;_.value.trans=p}}0==s?this.onDelayedPlay():t.GTween.delayedCall(s).onComplete(this.onDelayedPlay,this)},e.prototype.stop=function(e,i){if(null==e&&(e=!0),this._playing){this._playing=!1,this._totalTasks=0,this._totalTimes=0;var n=this._onComplete,o=this._onCompleteParam,r=this._onCompleteCaller;this._onComplete=null,this._onCompleteParam=null,this._onCompleteCaller=null,t.GTween.kill(this);var s=this._items.length;if(this._reversed)for(var a=s-1;a>=0;a--){var h=this._items[a];h.target&&this.stopItem(h,e)}else for(a=0;a1&&(n.playing=e[1]);break;case r.Visible:n.visible=e[0];break;case r.Sound:n.sound=e[0],e.length>1&&(n.volume=parseFloat(e[1]));break;case r.Transition:n.transName=e[0],e.length>1&&(n.playTimes=parseInt(e[1]));break;case r.Shake:n.amplitude=parseFloat(e[0]),e.length>1&&(n.duration=parseFloat(e[1]));break;case r.ColorFilter:n.f1=parseFloat(e[0]),n.f2=parseFloat(e[1]),n.f3=parseFloat(e[2]),n.f4=parseFloat(e[3]);break;case r.Text:case r.Icon:n.text=e[0]}}},e.prototype.setHook=function(t,e,i){for(var n=this._items.length,o=0;o0?o.target=this._owner.getChildById(o.targetId):o.target=this._owner:o.target=null)}},e.prototype.setDuration=function(t,e){for(var i=this._items.length,n=0;n0,this._playing){if(0!=(this._options&i))for(var t=this._items.length,e=0;e=0;e--)(t=this._items[e]).target&&this.playItem(t);else for(e=0;e=0&&e.tweener.setBreakpoint(this._endTime-i),this._totalTasks++}}else e.type==r.Shake?(i=this._reversed?this._totalDuration-e.time-e.value.duration:e.time,e.value.offsetX=e.value.offsetY=0,e.value.lastOffsetX=e.value.lastOffsetY=0,e.tweener=t.GTween.shake(0,0,e.value.amplitude,e.value.duration).setDelay(i).setTimeScale(this._timeScale).setTarget(e).onUpdate(this.onTweenUpdate,this).onComplete(this.onTweenComplete,this),this._endTime>=0&&e.tweener.setBreakpoint(this._endTime-e.time),this._totalTasks++):(i=this._reversed?this._totalDuration-e.time:e.time)<=this._startTime?(this.applyValue(e),this.callHook(e,!1)):(-1==this._endTime||i<=this._endTime)&&(this._totalTasks++,e.tweener=t.GTween.delayedCall(i).setTimeScale(this._timeScale).setTarget(e).onComplete(this.onDelayedPlayItem,this));null!=e.tweener&&e.tweener.seek(this._startTime)},e.prototype.skipAnimations=function(){for(var e,i,n,o,s,a,h=this._items.length,l=0;lthis._startTime||(o=a.value).flag)){e=(s=a.target).getProp(t.ObjectPropID.Frame),i=s.getProp(t.ObjectPropID.Playing)?0:-1,n=0;for(var c=l;cthis._startTime||((o=a.value).flag=!0,-1!=o.frame?(e=o.frame,i=o.playing?a.time:-1,n=0):o.playing?i<0&&(i=a.time):(i>=0&&(n+=a.time-i),i=-1),this.callHook(a,!1));i>=0&&(n+=this._startTime-i),s.setProp(t.ObjectPropID.Playing,i>=0),s.setProp(t.ObjectPropID.Frame,e),n>0&&s.setProp(t.ObjectPropID.DeltaTime,1e3*n)}},e.prototype.onDelayedPlayItem=function(t){var e=t.target;e.tweener=null,this._totalTasks--,this.applyValue(e),this.callHook(e,!1),this.checkAllComplete()},e.prototype.onTweenStart=function(t){var e,i,n=t.target;n.type!=r.XY&&n.type!=r.Size||(this._reversed?(e=n.tweenConfig.endValue,i=n.tweenConfig.startValue):(e=n.tweenConfig.startValue,i=n.tweenConfig.endValue),n.type==r.XY?n.target!=this._owner?(e.b1?e.b3&&(t.startValue.x=e.f1*this._owner.width):t.startValue.x=n.target.x,e.b2?e.b3&&(t.startValue.y=e.f2*this._owner.height):t.startValue.y=n.target.y,i.b1?i.b3&&(t.endValue.x=i.f1*this._owner.width):t.endValue.x=t.startValue.x,i.b2?i.b3&&(t.endValue.y=i.f2*this._owner.height):t.endValue.y=t.startValue.y):(e.b1||(t.startValue.x=n.target.x-this._ownerBaseX),e.b2||(t.startValue.y=n.target.y-this._ownerBaseY),i.b1||(t.endValue.x=t.startValue.x),i.b2||(t.endValue.y=t.startValue.y)):(e.b1||(t.startValue.x=n.target.width),e.b2||(t.startValue.y=n.target.height),i.b1||(t.endValue.x=t.startValue.x),i.b2||(t.endValue.y=t.startValue.y)),n.tweenConfig.path&&(n.value.b1=n.value.b2=!0,t.setPath(n.tweenConfig.path)));this.callHook(n,!1)},e.prototype.onTweenUpdate=function(t){var e=t.target;switch(e.type){case r.XY:case r.Size:case r.Scale:case r.Skew:e.value.f1=t.value.x,e.value.f2=t.value.y,e.tweenConfig.path&&(e.value.f1+=t.startValue.x,e.value.f2+=t.startValue.y);break;case r.Alpha:case r.Rotation:e.value.f1=t.value.x;break;case r.Color:e.value.f1=t.value.color;break;case r.ColorFilter:e.value.f1=t.value.x,e.value.f2=t.value.y,e.value.f3=t.value.z,e.value.f4=t.value.w;break;case r.Shake:e.value.offsetX=t.deltaValue.x,e.value.offsetY=t.deltaValue.y}this.applyValue(e)},e.prototype.onTweenComplete=function(t){var e=t.target;e.tweener=null,this._totalTasks--,t.allCompleted&&this.callHook(e,!0),this.checkAllComplete()},e.prototype.onPlayTransCompleted=function(t){this._totalTasks--,this.checkAllComplete()},e.prototype.callHook=function(t,e){e?t.tweenConfig&&t.tweenConfig.endHook&&t.tweenConfig.endHook.call(t.tweenConfig.endHookCaller):t.time>=this._startTime&&null!=t.hook&&t.hook.call(t.hookCaller)},e.prototype.checkAllComplete=function(){if(this._playing&&0==this._totalTasks)if(this._totalTimes<0)this.internalPlay();else if(this._totalTimes--,this._totalTimes>0)this.internalPlay();else{this._playing=!1;for(var t=this._items.length,e=0;e=0&&e.target.setProp(t.ObjectPropID.Frame,i.frame),e.target.setProp(t.ObjectPropID.Playing,i.playing),e.target.setProp(t.ObjectPropID.TimeScale,this._timeScale);break;case r.Visible:e.target.visible=i.visible;break;case r.Transition:if(this._playing){var n=i.trans;if(n){this._totalTasks++;var o=this._startTime>e.time?this._startTime-e.time:0,s=this._endTime>=0?this._endTime-e.time:-1;i.stopTime>=0&&(s<0||s>i.stopTime)&&(s=i.stopTime),n.timeScale=this._timeScale,n._play(this.onPlayTransCompleted,this,e,i.playTimes,0,o,s,this._reversed)}}break;case r.Sound:if(this._playing&&e.time>=this._startTime){if(!i.audioClip){var a=t.UIPackage.getItemByURL(i.sound);a&&(i.audioClip=a.owner.getItemAsset(a))}i.audioClip&&t.GRoot.inst.playOneShotSound(i.audioClip,i.volume)}break;case r.Shake:e.target.setXY(e.target.x-i.lastOffsetX+i.offsetX,e.target.y-i.lastOffsetY+i.offsetY),i.lastOffsetX=i.offsetX,i.lastOffsetY=i.offsetY;break;case r.ColorFilter:t.ToolSet.setColorFilter(e.target.displayObject,[i.f1,i.f2,i.f3,i.f4]);break;case r.Text:e.target.text=i.text;break;case r.Icon:e.target.icon=i.text}e.target._gearLocked=!1},e.prototype.setup=function(e){this.name=e.readS(),this._options=e.readInt(),this._autoPlay=e.readBool(),this._autoPlayTimes=e.readInt(),this._autoPlayDelay=e.readFloat();for(var i=e.readShort(),n=0;nthis._totalDuration&&(this._totalDuration=h.time+h.tweenConfig.duration),h.tweenConfig.easeType=e.readByte(),h.tweenConfig.repeat=e.readInt(),h.tweenConfig.yoyo=e.readBool(),h.tweenConfig.endLabel=e.readS(),e.seek(r,2),this.decodeValue(h,e,h.tweenConfig.startValue),e.seek(r,3),this.decodeValue(h,e,h.tweenConfig.endValue),e.version>=2){var c=e.readInt();if(c>0){h.tweenConfig.path=new t.GPath;for(var u=new Array,_=0;_this._totalDuration&&(this._totalDuration=h.time),e.seek(r,2),this.decodeValue(h,e,h.value);e.position=r+o}},e.prototype.decodeValue=function(t,e,i){switch(t.type){case r.XY:case r.Size:case r.Pivot:case r.Skew:i.b1=e.readBool(),i.b2=e.readBool(),i.f1=e.readFloat(),i.f2=e.readFloat(),e.version>=2&&t.type==r.XY&&(i.b3=e.readBool());break;case r.Alpha:case r.Rotation:i.f1=e.readFloat();break;case r.Scale:i.f1=e.readFloat(),i.f2=e.readFloat();break;case r.Color:i.f1=e.readColor();break;case r.Animation:i.playing=e.readBool(),i.frame=e.readInt();break;case r.Visible:i.visible=e.readBool();break;case r.Sound:i.sound=e.readS(),i.volume=e.readFloat();break;case r.Transition:i.transName=e.readS(),i.playTimes=e.readInt();break;case r.Shake:i.amplitude=e.readFloat(),i.duration=e.readFloat();break;case r.ColorFilter:i.f1=e.readFloat(),i.f2=e.readFloat(),i.f3=e.readFloat(),i.f4=e.readFloat();break;case r.Text:case r.Icon:i.text=e.readS()}},e}();t.Transition=e;var i=1,n=2,o=4,r=function(){function t(){}return t.XY=0,t.Size=1,t.Scale=2,t.Pivot=3,t.Alpha=4,t.Rotation=5,t.Color=6,t.Animation=7,t.Visible=8,t.Sound=9,t.Transition=10,t.Shake=11,t.ColorFilter=12,t.Skew=13,t.Text=14,t.Icon=15,t.Unknown=16,t}(),s=function(){return function(t){this.type=t,this.value={},this.displayLockToken=0}}(),a=function(){return function(){this.duration=0,this.repeat=0,this.easeType=t.EaseType.QuadOut,this.startValue={b1:!0,b2:!0},this.endValue={b1:!0,b2:!0}}}()}(fgui||(fgui={})),function(t){var e=function(){function e(){}return e.loadFromXML=function(t){var i={};e.strings=i;for(var n=egret.XML.parse(t).children,o=n.length,r=0;r0?s.children[0].text:"",l=a.indexOf("-");if(-1==l)continue;var c=a.substr(0,l),u=a.substr(l+1),_=i[c];_||(_={},i[c]=_),_[u]=h}}},e.translateComponent=function(i){if(null!=e.strings){var n=e.strings[i.owner.id+i.id];if(null!=n){var o,r,s,a,h,l,c,u,_,p=i.rawData;p.seek(0,2);var d=p.readShort();for(h=0;h=2){p.seek(u,4),p.skip(2),p.skip(4*p.readShort());for(var m=p.readShort(),b=0;b=2){p.skip(6),p.skip(4*p.readUnsignedShort());for(m=p.readUnsignedShort(),b=0;b0?[4,Promise.all(h)]:[3,3];case 2:u.sent(),u.label=3;case 3:return e._instById[o.id]=o,e._instByName[o.name]=o,e._instById[o._resKey]=o,r(o),[2]}})})})]})})},e.addPackage=function(i,n){if(!n&&!(n=RES.getRes(i)))throw"Resource '"+i+"' not found, please check default.res.json!";var o=new e;return o._resKey=i,o.loadPackage(new t.ByteBuffer(n)),e._instById[o.id]=o,e._instByName[o.name]=o,e._instById[i]=o,o},e.removePackage=function(t){var i=e._instById[t];if(i||(i=e._instByName[t]),!i)throw new Error("unknown package: "+t);i.dispose(),delete e._instById[i.id],delete e._instByName[i.name],delete e._instById[i._resKey],null!=i._customId&&delete e._instById[i._customId]},e.createObject=function(t,i,n){var o=e.getByName(t);return o?o.createObject(i,n):null},e.createObjectFromURL=function(t,i){var n=e.getItemByURL(t);return n?n.owner.internalCreateObject(n,i):null},e.getItemURL=function(t,i){var n=e.getByName(t);if(!n)return null;var o=n._itemsByName[i];return o?"ui://"+n.id+o.id:null},e.getItemByURL=function(t){var i=t.indexOf("//");if(-1==i)return null;var n=t.indexOf("/",i+2);if(-1==n){if(t.length>13){var o=t.substr(5,8),r=e.getById(o);if(null!=r){var s=t.substr(13);return r.getItemById(s)}}}else{var a=t.substr(i+2,n-i-2);if(null!=(r=e.getByName(a))){var h=t.substr(n+1);return r.getItemByName(h)}}return null},e.normalizeURL=function(t){if(null==t)return null;var i=t.indexOf("//");if(-1==i)return null;var n=t.indexOf("/",i+2);if(-1==n)return t;var o=t.substr(i+2,n-i-2),r=t.substr(n+1);return e.getItemURL(o,r)},e.setStringsSource=function(e){t.TranslationHelper.loadFromXML(e)},e.prototype.loadPackage=function(n){if(1179080009!=n.readUnsignedInt())throw"FairyGUI: old package format found in '"+this._resKey+"'";n.version=n.readInt();var o=n.readBool();if(this._id=n.readUTF(),this._name=n.readUTF(),n.skip(20),o){var r=new Uint8Array(n.buffer,n.position,n.length-n.position),s=new Zlib.RawInflate(r),a=new t.ByteBuffer(s.decompress());a.version=n.version,n=a}var h,l,c,u,_,p=n.version>=2,d=n.position;n.seek(d,4),h=n.readInt();var g,f=new Array(h);for(f.reduceRight,l=0;l0&&(this._branches=n.readSArray(h),e._branch&&(this._branchIndex=this._branches.indexOf(e._branch))),_=h>0),n.seek(d,1);var y=this._resKey,m=y.lastIndexOf("/"),b=-1==m?"":y.substr(0,m+1);for(y+="_",h=n.readShort(),l=0;l0?w:t.ObjectType.Component,g.rawData=n.readBuffer(),t.UIObjectFactory.resolvePackageItemExtension(g);break;case t.PackageItemType.Atlas:case t.PackageItemType.Sound:case t.PackageItemType.Misc:var C=g.file.lastIndexOf(".");g.file=y+(-1==C?g.file:i(g.file.substring(0,C),g.file.substring(C+1)));break;case t.PackageItemType.Spine:case t.PackageItemType.DragonBones:var S=g.file.lastIndexOf(".");g.file=b+(-1==S?g.file:g.file.substring(0,S)),g.skeletonAnchor=new egret.Point,g.skeletonAnchor.x=n.readFloat(),g.skeletonAnchor.y=n.readFloat()}if(p){(u=n.readS())&&(g.name=u+"/"+g.name);var x=n.readUnsignedByte();x>0&&(_?g.branches=n.readSArray(x):this._itemsById[n.readS()]=g);var T=n.readUnsignedByte();T>0&&(g.highResolution=n.readSArray(T))}this._items.push(g),this._itemsById[g.id]=g,null!=g.name&&(this._itemsByName[g.name]=g),n.position=c}for(n.seek(d,2),h=n.readShort(),l=0;l0){this._loading=!1;for(var t=this._uiSources.length,e=0;e=.9999)return[0,0,o,0,o,r,0,r];var c;switch(s){case t.FillMethod.Horizontal:c=function(e,i,n,o){var r=e*o;return n==t.FillOrigin.Left||n==t.FillOrigin.Top?[0,0,r,0,r,i,0,i]:[e,0,e,i,e-r,i,e-r,0]}(o,r,a,l);break;case t.FillMethod.Vertical:c=function(e,i,n,o){var r=i*o;return n==t.FillOrigin.Left||n==t.FillOrigin.Top?[0,0,0,r,e,r,e,0]:[0,i,e,i,e,i-r,0,i-r]}(o,r,a,l);break;case t.FillMethod.Radial90:c=e(o,r,a,h,l);break;case t.FillMethod.Radial180:c=n(o,r,a,h,l);break;case t.FillMethod.Radial360:c=function(e,o,r,s,a){var h;switch(r){case t.FillOrigin.Top:a<=.5?(a/=.5,h=n(e/2,o,s?t.FillOrigin.Left:t.FillOrigin.Right,s,a),s&&i(h,e/2,0)):(a=(a-.5)/.5,h=n(e/2,o,s?t.FillOrigin.Right:t.FillOrigin.Left,s,a),s?h.push(e,o,e,0,e/2,0):(i(h,e/2,0),h.push(0,o,0,0,e/2,0)));break;case t.FillOrigin.Bottom:a<=.5?(a/=.5,h=n(e/2,o,s?t.FillOrigin.Right:t.FillOrigin.Left,s,a),s||i(h,e/2,0)):(a=(a-.5)/.5,h=n(e/2,o,s?t.FillOrigin.Left:t.FillOrigin.Right,s,a),s?(i(h,e/2,0),h.push(0,0,0,o,e/2,o)):h.push(e,0,e,o,e/2,o));break;case t.FillOrigin.Left:a<=.5?(a/=.5,h=n(e,o/2,s?t.FillOrigin.Bottom:t.FillOrigin.Top,s,a),s||i(h,0,o/2)):(a=(a-.5)/.5,h=n(e,o/2,s?t.FillOrigin.Top:t.FillOrigin.Bottom,s,a),s?(i(h,0,o/2),h.push(e,0,0,0,0,o/2)):h.push(e,o,0,o,0,o/2));break;case t.FillOrigin.Right:a<=.5?(a/=.5,h=n(e,o/2,s?t.FillOrigin.Top:t.FillOrigin.Bottom,s,a),s&&i(h,0,o/2)):(a=(a-.5)/.5,h=n(e,o/2,s?t.FillOrigin.Bottom:t.FillOrigin.Top,s,a),s?h.push(0,o,e,o,e,o/2):(i(h,0,o/2),h.push(0,0,e,0,e,o/2)))}return h}(o,r,a,h,l)}return c}}(fgui||(fgui={})),function(t){var e=function(e){function i(){var t=e.call(this)||this;return t._fillMethod=0,t._fillOrigin=0,t._fillAmount=0,t._color=16777215,t}return __extends(i,e),Object.defineProperty(i.prototype,"color",{get:function(){return this._color},set:function(e){this._color!=e&&(this._color=e,null==this.tint?t.ToolSet.setColorFilter(this,e):this.tint=e)},enumerable:!0,configurable:!0}),i.prototype.$setX=function(t){return this.mask&&(this.mask.x=t),e.prototype.$setX.call(this,t)},i.prototype.$setY=function(t){return this.mask&&(this.mask.y=t),e.prototype.$setY.call(this,t)},Object.defineProperty(i.prototype,"fillMethod",{get:function(){return this._fillMethod},set:function(t){this._fillMethod!=t&&(this._fillMethod=t,0!=this._fillMethod?(this._mask||(this._mask=new egret.Shape,this._mask.touchEnabled=!1),this.mask=this._mask,this._mask.x=this.x,this._mask.y=this.y,this.addEventListener(egret.Event.RESIZE,this.markChanged,this),this.markChanged()):this.mask&&(this._mask.graphics.clear(),this.mask=null,this.removeEventListener(egret.Event.RESIZE,this.markChanged,this)))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillOrigin",{get:function(){return this._fillOrigin},set:function(t){this._fillOrigin!=t&&(this._fillOrigin=t,0!=this._fillMethod&&this.markChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillClockwise",{get:function(){return this._fillClockwise},set:function(t){this._fillClockwise!=t&&(this._fillClockwise=t,0!=this._fillMethod&&this.markChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillAmount",{get:function(){return this._fillAmount},set:function(t){this._fillAmount!=t&&(this._fillAmount=t,0!=this._fillMethod&&this.markChanged())},enumerable:!0,configurable:!0}),i.prototype.markChanged=function(){this._maskDirtyFlag||(this._maskDirtyFlag=!0,t.GTimers.inst.callLater(this.doFill,this))},i.prototype.doFill=function(){this._maskDirtyFlag=!1,!this._mask.parent&&this.parent&&this.parent.addChild(this._mask);var e=this.width,i=this.height,n=this._mask.graphics;if(n.clear(),0!=e&&0!=i){var o=t.fillImage(e,i,this._fillMethod,this._fillOrigin,this._fillClockwise,this._fillAmount);o&&(n.beginFill(0,1),t.ToolSet.fillPath(n,o,0,0),n.endFill())}},i}(egret.Bitmap);t.Image=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.interval=0,t.repeatDelay=0,t.timeScale=1,t._playing=!0,t._frameCount=0,t._frame=0,t._start=0,t._end=0,t._times=0,t._endAt=0,t._status=0,t._frameElapsed=0,t._reversed=!1,t._repeatedCount=0,t.touchEnabled=!1,t.setPlaySettings(),t}return __extends(i,e),Object.defineProperty(i.prototype,"frames",{get:function(){return this._frames},set:function(t){this._frames=t,this.scale9Grid=null,this.fillMode=egret.BitmapFillMode.SCALE,this._frames?this._frameCount=this._frames.length:this._frameCount=0,(-1==this._end||this._end>this._frameCount-1)&&(this._end=this._frameCount-1),(-1==this._endAt||this._endAt>this._frameCount-1)&&(this._endAt=this._frameCount-1),(this._frame<0||this._frame>this._frameCount-1)&&(this._frame=this._frameCount-1),this.drawFrame(),this._frameElapsed=0,this._repeatedCount=0,this._reversed=!1,this.checkTimer()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"frameCount",{get:function(){return this._frameCount},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"frame",{get:function(){return this._frame},set:function(t){this._frame!=t&&(this._frames&&t>=this._frameCount&&(t=this._frameCount-1),this._frame=t,this._frameElapsed=0,this.drawFrame())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"playing",{get:function(){return this._playing},set:function(t){this._playing!=t&&(this._playing=t,this.checkTimer())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"smoothing",{get:function(){return this._smoothing},set:function(t){this._smoothing=t},enumerable:!0,configurable:!0}),i.prototype.rewind=function(){this._frame=0,this._frameElapsed=0,this._reversed=!1,this._repeatedCount=0,this.drawFrame()},i.prototype.syncStatus=function(t){this._frame=t._frame,this._frameElapsed=t._frameElapsed,this._reversed=t._reversed,this._repeatedCount=t._repeatedCount,this.drawFrame()},i.prototype.advance=function(t){for(var e=this._frame,i=this._reversed,n=t;;){var o=this.interval+this._frames[this._frame].addDelay;if(0==this._frame&&this._repeatedCount>0&&(o+=this.repeatDelay),tthis._frameCount-1&&(this._frame=Math.max(0,this._frameCount-2),this._repeatedCount++,this._reversed=!this._reversed)):(this._frame++,this._frame>this._frameCount-1&&(this._frame=0,this._repeatedCount++)),this._frame==e&&this._reversed==i){var r=n-t;t-=Math.floor(t/r)*r}}this.drawFrame()},i.prototype.setPlaySettings=function(t,e,i,n,o,r){null==t&&(t=0),null==e&&(e=-1),null==i&&(i=0),null==n&&(n=-1),this._start=t,this._end=e,(-1==this._end||this._end>this._frameCount-1)&&(this._end=this._frameCount-1),this._times=i,this._endAt=n,-1==this._endAt&&(this._endAt=this._end),this._status=0,this._callback=o,this._callbackObj=r,this.frame=t},i.prototype.update=function(){if(this._playing&&0!=this._frameCount&&3!=this._status){var e=t.GTimers.deltaTime;1!=this.timeScale&&(e*=this.timeScale),this._frameElapsed+=e;var i=this.interval+this._frames[this._frame].addDelay;if(0==this._frame&&this._repeatedCount>0&&(i+=this.repeatDelay),!(this._frameElapsedthis.interval&&(this._frameElapsed=this.interval),this.swing?this._reversed?(this._frame--,this._frame<=0&&(this._frame=0,this._repeatedCount++,this._reversed=!this._reversed)):(this._frame++,this._frame>this._frameCount-1&&(this._frame=Math.max(0,this._frameCount-2),this._repeatedCount++,this._reversed=!this._reversed)):(this._frame++,this._frame>this._frameCount-1&&(this._frame=0,this._repeatedCount++)),1==this._status)this._frame=this._start,this._frameElapsed=0,this._status=0;else if(2==this._status){if(this._frame=this._endAt,this._frameElapsed=0,this._status=3,null!=this._callback){var n=this._callback,o=this._callbackObj;this._callback=null,this._callbackObj=null,n.call(o)}}else this._frame==this._end&&(this._times>0?(this._times--,0==this._times?this._status=2:this._status=1):0!=this._start&&(this._status=1));this.drawFrame()}}},i.prototype.drawFrame=function(){if(this._frameCount>0&&this._frame0&&null!=this.stage?t.GTimers.inst.add(1,0,this.update,this):t.GTimers.inst.remove(this.update,this)},i.prototype.$onAddToStage=function(i,n){e.prototype.$onAddToStage.call(this,i,n),this._playing&&this._frameCount>0&&t.GTimers.inst.add(1,0,this.update,this)},i.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this),t.GTimers.inst.remove(this.update,this)},i}(t.Image);t.MovieClip=e}(fgui||(fgui={})),function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.touchEnabled=!0,e.touchChildren=!0,e}return __extends(e,t),e.prototype.cacheHitArea=function(t){this._cachedHitArea=t,t&&(this._cachedMatrix||(this._cachedMatrix=new egret.Matrix),this._cachedMatrix.copyFrom(this.$getInvertedConcatenatedMatrix()))},Object.defineProperty(e.prototype,"hitArea",{get:function(){return this._hitArea},set:function(t){this._hitArea=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"opaque",{get:function(){return this._opaque},set:function(t){this._opaque=t},enumerable:!0,configurable:!0}),e.prototype.$hitTest=function(e,i){if(!this.$visible)return null;if(this._hitArea){if(!this.touchEnabled)return null;if(this._hitArea.$graphics){if(!this._hitArea.$graphics.$hitTest(e,i))return null}else{var n=(s=this._cachedHitArea?this._cachedMatrix:this.$getInvertedConcatenatedMatrix()).a*e+s.c*i+s.tx,o=s.b*e+s.d*i+s.ty;if(!this._hitArea.contains(n,o))return null}return this}var r=t.prototype.$hitTest.call(this,e,i);if(r==this&&!this.touchEnabled)return null;if(null==r&&this._opaque){var s;n=(s=this._cachedHitArea?this._cachedMatrix:this.$getInvertedConcatenatedMatrix()).a*e+s.c*i+s.tx,o=s.b*e+s.d*i+s.ty;return n>=0&&o>=0&&n<=this.$explicitWidth&&o<=this.$explicitHeight?this:null}return r!=this||this._opaque?r:null},e}(egret.DisplayObjectContainer);t.UIContainer=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e,i,n,o){void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=-1);var r=t.call(this,e,!1)||this;return r.touchPointID=0,r.stageX=i,r.stageY=n,r.touchPointID=o,r}return __extends(e,t),e.prototype.preventDefault=function(){this._prevented=!0},e.prototype.isDefaultPrevented=function(){return this._prevented},e.DRAG_START="__dragStart",e.DRAG_END="__dragEnd",e.DRAG_MOVING="__dragMoving",e}(egret.Event);t.DragEvent=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e,i){var n=t.call(this,e,!1)||this;return n.source=i,n}return __extends(e,t),e.DROP="__drop",e}(egret.Event);t.DropEvent=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e,i,n,o){void 0===i&&(i=null),void 0===n&&(n=0),void 0===o&&(o=0);var r=t.call(this,e,!1)||this;return r.itemObject=i,r.stageX=n,r.stageY=o,r}return __extends(e,t),e.CLICK="___itemClick",e}(egret.Event);t.ItemEvent=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e){return t.call(this,e,!1)||this}return __extends(e,t),e.CHANGED="___stateChanged",e}(egret.Event);t.StateChangeEvent=e}(fgui||(fgui={})),function(t){var e,i=function(){function i(t){this._owner=t}return i.create=function(i,n){return e||(e=[t.GearDisplay,t.GearXY,t.GearSize,t.GearLook,t.GearColor,t.GearAnimation,t.GearText,t.GearIcon,t.GearDisplay2,t.GearFontSize]),new e[n](i)},i.prototype.dispose=function(){this._tweenConfig&&this._tweenConfig._tweener&&(this._tweenConfig._tweener.kill(),this._tweenConfig._tweener=null)},Object.defineProperty(i.prototype,"controller",{get:function(){return this._controller},set:function(t){t!=this._controller&&(this._controller=t,this._controller&&this.init())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"tweenConfig",{get:function(){return this._tweenConfig||(this._tweenConfig=new n),this._tweenConfig},enumerable:!0,configurable:!0}),i.prototype.setup=function(e){var i,o;this._controller=this._owner.parent.getControllerAt(e.readShort()),this.init();var r=e.readShort();if(this instanceof t.GearDisplay)this.pages=e.readSArray(r);else if(this instanceof t.GearDisplay2)this.pages=e.readSArray(r);else{for(i=0;i=2)if(this instanceof t.GearXY){if(e.readBool()){for(this.positionsInPercent=!0,i=0;i0},enumerable:!0,configurable:!0}),e}(t.GearBase);t.GearDisplay=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e){var i=t.call(this,e)||this;return i._visible=0,i}return __extends(e,t),e.prototype.init=function(){this.pages=null},e.prototype.apply=function(){null==this.pages||0==this.pages.length||-1!=this.pages.indexOf(this._controller.selectedPageId)?this._visible=1:this._visible=0},e.prototype.evaluate=function(t){var e=null==this._controller||this._visible>0;return e=0==this.condition?e&&t:e||t},e}(t.GearBase);t.GearDisplay2=e}(fgui||(fgui={})),function(t){var e=function(e){function i(t){var i=e.call(this,t)||this;return i._default=0,i}return __extends(i,e),i.prototype.init=function(){this._default=this._owner.getProp(t.ObjectPropID.FontSize),this._storage={}},i.prototype.addStatus=function(t,e){null==t?this._default=e.readInt():this._storage[t]=e.readInt()},i.prototype.apply=function(){this._owner._gearLocked=!0;var e=this._storage[this._controller.selectedPageId];null!=e?this._owner.setProp(t.ObjectPropID.FontSize,e):this._owner.setProp(t.ObjectPropID.FontSize,this._default),this._owner._gearLocked=!1},i.prototype.updateState=function(){this._storage[this._controller.selectedPageId]=this._owner.getProp(t.ObjectPropID.FontSize)},i}(t.GearBase);t.GearFontSize=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.init=function(){this._default=this._owner.icon,this._storage={}},e.prototype.addStatus=function(t,e){null==t?this._default=e.readS():this._storage[t]=e.readS()},e.prototype.apply=function(){this._owner._gearLocked=!0;var t=this._storage[this._controller.selectedPageId];this._owner.icon=void 0!==t?t:this._default,this._owner._gearLocked=!1},e.prototype.updateState=function(){this._storage[this._controller.selectedPageId]=this._owner.icon},e}(t.GearBase);t.GearIcon=e}(fgui||(fgui={})),function(t){var e=function(e){function i(t){return e.call(this,t)||this}return __extends(i,e),i.prototype.init=function(){this._default={alpha:this._owner.alpha,rotation:this._owner.rotation,grayed:this._owner.grayed,touchable:this._owner.touchable},this._storage={}},i.prototype.addStatus=function(t,e){var i;null==t?i=this._default:this._storage[t]=i={},i.alpha=e.readFloat(),i.rotation=e.readFloat(),i.grayed=e.readBool(),i.touchable=e.readBool()},i.prototype.apply=function(){var e=this._storage[this._controller.selectedPageId];if(e||(e=this._default),this._tweenConfig&&this._tweenConfig.tween&&!t.UIPackage._constructing&&!t.GearBase.disableAllTweenEffect){if(this._owner._gearLocked=!0,this._owner.grayed=e.grayed,this._owner.touchable=e.touchable,this._owner._gearLocked=!1,this._tweenConfig._tweener){if(this._tweenConfig._tweener.endValue.x==e.alpha&&this._tweenConfig._tweener.endValue.y==e.rotation)return;this._tweenConfig._tweener.kill(!0),this._tweenConfig._tweener=null}var i=e.alpha!=this._owner.alpha,n=e.rotation!=this._owner.rotation;(i||n)&&(this._owner.checkGearController(0,this._controller)&&(this._tweenConfig._displayLockToken=this._owner.addDisplayLock()),this._tweenConfig._tweener=t.GTween.to2(this._owner.alpha,this._owner.rotation,e.alpha,e.rotation,this._tweenConfig.duration).setDelay(this._tweenConfig.delay).setEase(this._tweenConfig.easeType).setUserData((i?1:0)+(n?2:0)).setTarget(this).onUpdate(this.__tweenUpdate,this).onComplete(this.__tweenComplete,this))}else this._owner._gearLocked=!0,this._owner.grayed=e.grayed,this._owner.touchable=e.touchable,this._owner.alpha=e.alpha,this._owner.rotation=e.rotation,this._owner._gearLocked=!1},i.prototype.__tweenUpdate=function(t){var e=t.userData;this._owner._gearLocked=!0,0!=(1&e)&&(this._owner.alpha=t.value.x),0!=(2&e)&&(this._owner.rotation=t.value.y),this._owner._gearLocked=!1},i.prototype.__tweenComplete=function(){0!=this._tweenConfig._displayLockToken&&(this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken),this._tweenConfig._displayLockToken=0),this._tweenConfig._tweener=null},i.prototype.updateState=function(){var t=this._storage[this._controller.selectedPageId];t||(this._storage[this._controller.selectedPageId]=t={}),t.alpha=this._owner.alpha,t.rotation=this._owner.rotation,t.grayed=this._owner.grayed,t.touchable=this._owner.touchable},i}(t.GearBase);t.GearLook=e}(fgui||(fgui={})),function(t){var e=function(e){function i(t){return e.call(this,t)||this}return __extends(i,e),i.prototype.init=function(){this._default={width:this._owner.width,height:this._owner.height,scaleX:this._owner.scaleX,scaleY:this._owner.scaleY},this._storage={}},i.prototype.addStatus=function(t,e){var i;null==t?i=this._default:this._storage[t]=i={},i.width=e.readInt(),i.height=e.readInt(),i.scaleX=e.readFloat(),i.scaleY=e.readFloat()},i.prototype.apply=function(){var e=this._storage[this._controller.selectedPageId];if(e||(e=this._default),this._tweenConfig&&this._tweenConfig.tween&&!t.UIPackage._constructing&&!t.GearBase.disableAllTweenEffect){if(this._tweenConfig._tweener){if(this._tweenConfig._tweener.endValue.x==e.width&&this._tweenConfig._tweener.endValue.y==e.height&&this._tweenConfig._tweener.endValue.z==e.scaleX&&this._tweenConfig._tweener.endValue.w==e.scaleY)return;this._tweenConfig._tweener.kill(!0),this._tweenConfig._tweener=null}var i=e.width!=this._owner.width||e.height!=this._owner.height,n=e.scaleX!=this._owner.scaleX||e.scaleY!=this._owner.scaleY;(i||n)&&(this._owner.checkGearController(0,this._controller)&&(this._tweenConfig._displayLockToken=this._owner.addDisplayLock()),this._tweenConfig._tweener=t.GTween.to4(this._owner.width,this._owner.height,this._owner.scaleX,this._owner.scaleY,e.width,e.height,e.scaleX,e.scaleY,this._tweenConfig.duration).setDelay(this._tweenConfig.delay).setEase(this._tweenConfig.easeType).setUserData((i?1:0)+(n?2:0)).setTarget(this).onUpdate(this.__tweenUpdate,this).onComplete(this.__tweenComplete,this))}else this._owner._gearLocked=!0,this._owner.setSize(e.width,e.height,this._owner.gearXY.controller==this._controller),this._owner.setScale(e.scaleX,e.scaleY),this._owner._gearLocked=!1},i.prototype.__tweenUpdate=function(t){var e=t.userData;this._owner._gearLocked=!0,0!=(1&e)&&this._owner.setSize(t.value.x,t.value.y,this._owner.checkGearController(1,this._controller)),0!=(2&e)&&this._owner.setScale(t.value.z,t.value.w),this._owner._gearLocked=!1},i.prototype.__tweenComplete=function(){0!=this._tweenConfig._displayLockToken&&(this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken),this._tweenConfig._displayLockToken=0),this._tweenConfig._tweener=null},i.prototype.updateState=function(){var t=this._storage[this._controller.selectedPageId];t||(this._storage[this._controller.selectedPageId]=t={}),t.width=this._owner.width,t.height=this._owner.height,t.scaleX=this._owner.scaleX,t.scaleY=this._owner.scaleY},i.prototype.updateFromRelations=function(t,e){if(null!=this._controller&&null!=this._storage){for(var i in this._storage){var n=this._storage[i];n.width+=t,n.height+=e}this._default.width+=t,this._default.height+=e,this.updateState()}},i}(t.GearBase);t.GearSize=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.init=function(){this._default=this._owner.text,this._storage={}},e.prototype.addStatus=function(t,e){null==t?this._default=e.readS():this._storage[t]=e.readS()},e.prototype.apply=function(){this._owner._gearLocked=!0;var t=this._storage[this._controller.selectedPageId];this._owner.text=void 0!==t?t:this._default,this._owner._gearLocked=!1},e.prototype.updateState=function(){this._storage[this._controller.selectedPageId]=this._owner.text},e}(t.GearBase);t.GearText=e}(fgui||(fgui={})),function(t){var e=function(e){function i(t){return e.call(this,t)||this}return __extends(i,e),i.prototype.init=function(){this._default={x:this._owner.x,y:this._owner.y,px:this._owner.x/this._owner.parent.width,py:this._owner.y/this._owner.parent.height},this._storage={}},i.prototype.addStatus=function(t,e){var i;null==t?i=this._default:this._storage[t]=i={},i.x=e.readInt(),i.y=e.readInt()},i.prototype.addExtStatus=function(t,e){var i;(i=null==t?this._default:this._storage[t]).px=e.readFloat(),i.py=e.readFloat()},i.prototype.apply=function(){var e,i,n=this._storage[this._controller.selectedPageId];if(n||(n=this._default),this.positionsInPercent&&this._owner.parent?(e=n.px*this._owner.parent.width,i=n.py*this._owner.parent.height):(e=n.x,i=n.y),this._tweenConfig&&this._tweenConfig.tween&&!t.UIPackage._constructing&&!t.GearBase.disableAllTweenEffect){if(this._tweenConfig._tweener){if(this._tweenConfig._tweener.endValue.x==e&&this._tweenConfig._tweener.endValue.y==i)return;this._tweenConfig._tweener.kill(!0),this._tweenConfig._tweener=null}var o=this._owner.x,r=this._owner.y;o==e&&r==i||(this._owner.checkGearController(0,this._controller)&&(this._tweenConfig._displayLockToken=this._owner.addDisplayLock()),this._tweenConfig._tweener=t.GTween.to2(o,r,e,i,this._tweenConfig.duration).setDelay(this._tweenConfig.delay).setEase(this._tweenConfig.easeType).setTarget(this).onUpdate(this.__tweenUpdate,this).onComplete(this.__tweenComplete,this))}else this._owner._gearLocked=!0,this._owner.setXY(e,i),this._owner._gearLocked=!1},i.prototype.__tweenUpdate=function(t){this._owner._gearLocked=!0,this._owner.setXY(t.value.x,t.value.y),this._owner._gearLocked=!1},i.prototype.__tweenComplete=function(){0!=this._tweenConfig._displayLockToken&&(this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken),this._tweenConfig._displayLockToken=0),this._tweenConfig._tweener=null},i.prototype.updateState=function(){var t=this._storage[this._controller.selectedPageId];t||(this._storage[this._controller.selectedPageId]=t={}),t.x=this._owner.x,t.y=this._owner.y,t.px=this._owner.x/this._owner.parent.width,t.py=this._owner.y/this._owner.parent.height},i.prototype.updateFromRelations=function(t,e){if(null!=this._controller&&null!=this._storage&&!this.positionsInPercent){for(var i in this._storage){var n=this._storage[i];n.x+=t,n.y+=e}this._default.x+=t,this._default.y+=e,this.updateState()}},i}(t.GearBase);t.GearXY=e}(fgui||(fgui={})),function(t){var e=.5*Math.PI,i=2*Math.PI;function n(t,e){return 1-o(e-t,e)}function o(t,e){return(t/=e)<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}t.evaluateEase=function(r,s,a,h,l){switch(r){case t.EaseType.Linear:return s/a;case t.EaseType.SineIn:return 1-Math.cos(s/a*e);case t.EaseType.SineOut:return Math.sin(s/a*e);case t.EaseType.SineInOut:return-.5*(Math.cos(Math.PI*s/a)-1);case t.EaseType.QuadIn:return(s/=a)*s;case t.EaseType.QuadOut:return-(s/=a)*(s-2);case t.EaseType.QuadInOut:return(s/=.5*a)<1?.5*s*s:-.5*(--s*(s-2)-1);case t.EaseType.CubicIn:return(s/=a)*s*s;case t.EaseType.CubicOut:return(s=s/a-1)*s*s+1;case t.EaseType.CubicInOut:return(s/=.5*a)<1?.5*s*s*s:.5*((s-=2)*s*s+2);case t.EaseType.QuartIn:return(s/=a)*s*s*s;case t.EaseType.QuartOut:return-((s=s/a-1)*s*s*s-1);case t.EaseType.QuartInOut:return(s/=.5*a)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2);case t.EaseType.QuintIn:return(s/=a)*s*s*s*s;case t.EaseType.QuintOut:return(s=s/a-1)*s*s*s*s+1;case t.EaseType.QuintInOut:return(s/=.5*a)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2);case t.EaseType.ExpoIn:return 0==s?0:Math.pow(2,10*(s/a-1));case t.EaseType.ExpoOut:return s==a?1:1-Math.pow(2,-10*s/a);case t.EaseType.ExpoInOut:return 0==s?0:s==a?1:(s/=.5*a)<1?.5*Math.pow(2,10*(s-1)):.5*(2-Math.pow(2,-10*--s));case t.EaseType.CircIn:return-(Math.sqrt(1-(s/=a)*s)-1);case t.EaseType.CircOut:return Math.sqrt(1-(s=s/a-1)*s);case t.EaseType.CircInOut:return(s/=.5*a)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1);case t.EaseType.ElasticIn:var c;return 0==s?0:1==(s/=a)?1:(0==l&&(l=.3*a),h<1?(h=1,c=l/4):c=l/i*Math.asin(1/h),-h*Math.pow(2,10*(s-=1))*Math.sin((s*a-c)*i/l));case t.EaseType.ElasticOut:var u;return 0==s?0:1==(s/=a)?1:(0==l&&(l=.3*a),h<1?(h=1,u=l/4):u=l/i*Math.asin(1/h),h*Math.pow(2,-10*s)*Math.sin((s*a-u)*i/l)+1);case t.EaseType.ElasticInOut:var _;return 0==s?0:2==(s/=.5*a)?1:(0==l&&(l=a*(.3*1.5)),h<1?(h=1,_=l/4):_=l/i*Math.asin(1/h),s<1?h*Math.pow(2,10*(s-=1))*Math.sin((s*a-_)*i/l)*-.5:h*Math.pow(2,-10*(s-=1))*Math.sin((s*a-_)*i/l)*.5+1);case t.EaseType.BackIn:return(s/=a)*s*((h+1)*s-h);case t.EaseType.BackOut:return(s=s/a-1)*s*((h+1)*s+h)+1;case t.EaseType.BackInOut:return(s/=.5*a)<1?s*s*((1+(h*=1.525))*s-h)*.5:.5*((s-=2)*s*((1+(h*=1.525))*s+h)+2);case t.EaseType.BounceIn:return n(s,a);case t.EaseType.BounceOut:return o(s,a);case t.EaseType.BounceInOut:return function(t,e){return t<.5*e?.5*n(2*t,e):.5*o(2*t-e,e)+.5}(s,a);default:return-(s/=a)*(s-2)}}}(fgui||(fgui={})),function(t){var e=function(){function t(){}return t.Linear=0,t.SineIn=1,t.SineOut=2,t.SineInOut=3,t.QuadIn=4,t.QuadOut=5,t.QuadInOut=6,t.CubicIn=7,t.CubicOut=8,t.CubicInOut=9,t.QuartIn=10,t.QuartOut=11,t.QuartInOut=12,t.QuintIn=13,t.QuintOut=14,t.QuintInOut=15,t.ExpoIn=16,t.ExpoOut=17,t.ExpoInOut=18,t.CircIn=19,t.CircOut=20,t.CircInOut=21,t.ElasticIn=22,t.ElasticOut=23,t.ElasticInOut=24,t.BackIn=25,t.BackOut=26,t.BackInOut=27,t.BounceIn=28,t.BounceOut=29,t.BounceInOut=30,t.Custom=31,t}();t.EaseType=e}(fgui||(fgui={})),function(t){var e=function(){function e(){this._segments=new Array,this._points=new Array}return Object.defineProperty(e.prototype,"length",{get:function(){return this._fullLength},enumerable:!0,configurable:!0}),e.prototype.create=function(e,n,o,r){var s;Array.isArray(e)?s=e:((s=new Array).push(e),s.push(n),o&&s.push(o),r&&s.push(r)),this._segments.length=0,this._points.length=0,this._fullLength=0;var a=s.length;if(0!=a){var h=i;h.length=0;var l=s[0];l.curveType==t.CurveType.CRSpline&&h.push(new egret.Point(l.x,l.y));for(var c=1;c0&&(h.push(new egret.Point(u.x,u.y)),this.createSplineSegment()):h.push(new egret.Point(u.x,u.y)),l=u}h.length>1&&this.createSplineSegment()}},e.prototype.createSplineSegment=function(){var e=i,n=e.length;e.splice(0,0,e[0]),e.push(e[n]),e.push(e[n]),n+=3;var o={};o.type=t.CurveType.CRSpline,o.ptStart=this._points.length,o.ptCount=n,this._points=this._points.concat(e),o.length=0;for(var r=1;ri&&u=0?this._elapsedTime=this._delay+this._breakpoint:this._repeat>=0?this._elapsedTime=this._delay+this._duration*(this._repeat+1):this._elapsedTime=this._delay+2*this._duration,this.update()),this.callCompleteCallback()),this._killed=!0)},e.prototype._to=function(t,e,i){return this._valueSize=1,this._startValue.x=t,this._endValue.x=e,this._value.x=t,this._duration=i,this},e.prototype._to2=function(t,e,i,n,o){return this._valueSize=2,this._startValue.x=t,this._endValue.x=i,this._startValue.y=e,this._endValue.y=n,this._value.x=t,this._value.y=e,this._duration=o,this},e.prototype._to3=function(t,e,i,n,o,r,s){return this._valueSize=3,this._startValue.x=t,this._endValue.x=n,this._startValue.y=e,this._endValue.y=o,this._startValue.z=i,this._endValue.z=r,this._value.x=t,this._value.y=e,this._value.z=i,this._duration=s,this},e.prototype._to4=function(t,e,i,n,o,r,s,a,h){return this._valueSize=4,this._startValue.x=t,this._endValue.x=o,this._startValue.y=e,this._endValue.y=r,this._startValue.z=i,this._endValue.z=s,this._startValue.w=n,this._endValue.w=a,this._value.x=t,this._value.y=e,this._value.z=i,this._value.w=n,this._duration=h,this},e.prototype._toColor=function(t,e,i){return this._valueSize=4,this._startValue.color=t,this._endValue.color=e,this._value.color=t,this._duration=i,this},e.prototype._shake=function(t,e,i,n){return this._valueSize=5,this._startValue.x=t,this._startValue.y=e,this._startValue.w=i,this._duration=n,this},e.prototype._init=function(){this._delay=0,this._duration=0,this._breakpoint=-1,this._easeType=t.EaseType.QuadOut,this._timeScale=1,this._easePeriod=0,this._easeOvershootOrAmplitude=1.70158,this._snapping=!1,this._repeat=0,this._yoyo=!1,this._valueSize=0,this._started=!1,this._paused=!1,this._killed=!1,this._elapsedTime=0,this._normalizedTime=0,this._ended=0},e.prototype._reset=function(){this._target=null,this._propType=null,this._userData=null,this._path=null,this._onStart=this._onUpdate=this._onComplete=null,this._onStartCaller=this._onUpdateCaller=this._onCompleteCaller=null},e.prototype._update=function(t){if(1!=this._timeScale&&(t*=this._timeScale),0!=t){if(0!=this._ended)return this.callCompleteCallback(),void(this._killed=!0);this._elapsedTime+=t,this.update(),0!=this._ended&&(this._killed||(this.callCompleteCallback(),this._killed=!0))}},e.prototype.update=function(){if(this._ended=0,0!=this._valueSize){if(!this._started){if(this._elapsedTime=0&&n>=this._breakpoint&&(n=this._breakpoint,this._ended=2),0!=this._repeat){var o=Math.floor(n/this._duration);n-=this._duration*o,this._yoyo&&(e=o%2==1),this._repeat>0&&this._repeat-o<0&&(this._yoyo&&(e=this._repeat%2==1),n=this._duration,this._ended=1)}else n>=this._duration&&(n=this._duration,this._ended=1);if(this._normalizedTime=t.evaluateEase(this._easeType,e?this._duration-n:n,this._duration,this._easeOvershootOrAmplitude,this._easePeriod),this._value.setZero(),this._deltaValue.setZero(),5==this._valueSize)if(0==this._ended){var r=this._startValue.w*(1-this._normalizedTime),s=r*(Math.random()>.5?1:-1),a=r*(Math.random()>.5?1:-1);this._deltaValue.x=s,this._deltaValue.y=a,this._value.x=this._startValue.x+s,this._value.y=this._startValue.y+a}else this._value.x=this._startValue.x,this._value.y=this._startValue.y;else if(this._path){var h=i;this._path.getPointAt(this._normalizedTime,h),this._snapping&&(h.x=Math.round(h.x),h.y=Math.round(h.y)),this._deltaValue.x=h.x-this._value.x,this._deltaValue.y=h.y-this._value.y,this._value.x=h.x,this._value.y=h.y}else for(var l=0;l=this._delay+this._duration&&(this._ended=1)},e.prototype.callStartCallback=function(){if(null!=this._onStart)try{this._onStart.call(this._onStartCaller,this)}catch(t){console.log("FairyGUI: error in start callback > "+t)}},e.prototype.callUpdateCallback=function(){if(null!=this._onUpdate)try{this._onUpdate.call(this._onUpdateCaller,this)}catch(t){console.log("FairyGUI: error in update callback > "+t)}},e.prototype.callCompleteCallback=function(){if(null!=this._onComplete)try{this._onComplete.call(this._onCompleteCaller,this)}catch(t){console.log("FairyGUI: error in complete callback > "+t)}},e}();t.GTweener=e;var i=new egret.Point}(fgui||(fgui={})),function(t){var e=function(){function e(){}return e.createTween=function(){var a;return i||(egret.startTick(e.update,null),i=!0,s=egret.getTimer()),(a=o.length>0?o.pop():new t.GTweener)._init(),n[r++]=a,r==n.length&&(n.length=n.length+Math.ceil(.5*n.length)),a},e.isTweening=function(t,e){if(null==t)return!1;for(var i=null==e,o=0;o=0){if(r!=a){var u=a;for(a=r-a,l=0;l>16,this.y=(65280&t)>>8,this.z=255&t,this.w=(4278190080&t)>>24},enumerable:!0,configurable:!0}),t.prototype.getField=function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("Index out of bounds: "+t)}},t.prototype.setField=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("Index out of bounds: "+t)}},t.prototype.setZero=function(){this.x=this.y=this.z=this.w=0},t}();t.TweenValue=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.version=0,n}return __extends(e,t),e.prototype.skip=function(t){this.position+=t},e.prototype.readBool=function(){return 1==this.readByte()},e.prototype.readS=function(){var t=this.readUnsignedShort();return 65534==t?null:65533==t?"":this.stringTable[t]},e.prototype.readSArray=function(t){for(var e=new Array(t),i=0;i0?(this.position=t+i,!0):(this.position=n,!1)):(this.position=n,!1)},e}(egret.ByteArray);t.ByteBuffer=e}(fgui||(fgui={})),function(t){var e=function(){function t(t,e,i,o){this.matrix=new Array(n),this.reset(),void 0===t&&void 0===e&&void 0===i&&void 0===o||this.adjustColor(t,e,i,o)}return t.prototype.reset=function(){for(var t=0;t=this.delay&&(this.counter-=this.delay,this.counter>this.delay&&(this.counter=this.delay),this.repeat>0&&(this.repeat--,0==this.repeat&&(this.end=!0)),!0)},t.prototype.reset=function(){this.callback=null,this.thisObj=null,this.param=null},t}()}(fgui||(fgui={})),function(t){var e=function(){function t(){this._readPos=0,this.smallFontSize=12,this.normalFontSize=14,this.largeFontSize=16,this.defaultImgWidth=0,this.defaultImgHeight=0,this._handlers={},this._handlers.url=this.onTag_URL,this._handlers.img=this.onTag_IMG,this._handlers.b=this.onTag_Simple,this._handlers.i=this.onTag_Simple,this._handlers.u=this.onTag_Simple,this._handlers.sup=this.onTag_Simple,this._handlers.sub=this.onTag_Simple,this._handlers.color=this.onTag_COLOR,this._handlers.font=this.onTag_FONT,this._handlers.size=this.onTag_SIZE}return t.prototype.onTag_URL=function(t,e,i){return e?"":null!=i?'':''},t.prototype.onTag_IMG=function(t,e,i){if(e)return null;var n=this.getTagText(!0);return n?this.defaultImgWidth?'':'':null},t.prototype.onTag_Simple=function(t,e,i){return e?"":"<"+t+">"},t.prototype.onTag_COLOR=function(t,e,i){return e?"":''},t.prototype.onTag_FONT=function(t,e,i){return e?"":''},t.prototype.onTag_SIZE=function(t,e,i){return e?"":("normal"==i?i=""+this.normalFontSize:"small"==i?i=""+this.smallFontSize:"large"==i?i=""+this.largeFontSize:i.length&&"+"==i.charAt(0)?i=""+(this.smallFontSize+parseInt(i.substr(1))):i.length&&"-"==i.charAt(0)&&(i=""+(this.smallFontSize-parseInt(i.substr(1)))),'')},t.prototype.getTagText=function(t){void 0===t&&(t=!1);for(var e,i=this._readPos,n="";-1!=(e=this._text.indexOf("[",i));){if(92!=this._text.charCodeAt(e-1)){n+=this._text.substring(i,e);break}n+=this._text.substring(i,e-1),n+="[",i=e+1}return-1==e?null:(t&&(this._readPos=e),n)},t.prototype.parse=function(t,e){this._text=t;for(var i,n,o,r,s,a,h,l=0,c="";-1!=(i=this._text.indexOf("[",l));)if(i>0&&92==this._text.charCodeAt(i-1))c+=this._text.substring(l,i-1),c+="[",l=i+1;else{if(c+=this._text.substring(l,i),l=i,-1==(i=this._text.indexOf("]",l)))break;o="/"==this._text.charAt(l+1),r=this._text.substring(o?l+2:l+1,i),this._readPos=i+1,s=null,a=null,-1!=(n=r.indexOf("="))&&(s=r.substring(n+1),r=r.substring(0,n)),r=r.toLowerCase(),null!=(h=this._handlers[r])?e||null!=(a=h.call(this,r,o,s))&&(c+=a):c+=this._text.substring(l,this._readPos),l=this._readPos}return l=0&&(" "==(e=t.charAt(i))||"\n"==e||"\r"==e);i--);return t.substring(0,i+1)},e.convertToHtmlColor=function(t,e){var i;i=e?(t>>24&255).toString(16):"";var n=(t>>16&255).toString(16),o=(t>>8&255).toString(16),r=(255&t).toString(16);return 1==i.length&&(i="0"+i),1==n.length&&(n="0"+n),1==o.length&&(o="0"+o),1==r.length&&(r="0"+r),"#"+i+n+o+r},e.convertFromHtmlColor=function(t,e){return t.length<1?0:("#"==t.charAt(0)&&(t=t.substr(1)),8==t.length?(parseInt(t.substr(0,2),16)<<24)+parseInt(t.substr(2),16):e?4278190080+parseInt(t,16):parseInt(t,16))},e.displayObjectToGObject=function(e){for(;e&&!(e instanceof egret.Stage);){if(e.$owner)return t.GObject.cast(e);e=e.parent}return null},e.encodeHTML=function(t){return t?t.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,"""):""},e.clamp=function(t,e,i){return ti&&(t=i),t},e.clamp01=function(t){return t>1?t=1:t<0&&(t=0),t},e.lerp=function(t,e,i){return t+i*(e-t)},e.repeat=function(t,e){return t-Math.floor(t/e)*e},e.distance=function(t,e,i,n){return Math.sqrt(Math.pow(t-i,2)+Math.pow(e-n,2))},e.fillPath=function(t,e,i,n){var o=e.length;t.moveTo(e[0]+i,e[1]+n);for(var r=2;r>16&255)/255,l[6]=(o>>8&255)/255,l[12]=(255&o)/255}a.matrix=l}else if(h&&a){var _=h.indexOf(a);-1!=_&&(h.splice(_,1),h.length>0?e.filters=h:e.filters=null)}},e}();t.ToolSet=e;var i=[.3,.6,0,0,0,.3,.6,0,0,0,.3,.6,0,0,0,0,0,0,1,0],n=new t.ColorMatrix}(fgui||(fgui={})); \ No newline at end of file diff --git a/demo/libs/framework/framework.d.ts b/demo/libs/framework/framework.d.ts deleted file mode 100644 index 5b23c9a5..00000000 --- a/demo/libs/framework/framework.d.ts +++ /dev/null @@ -1,2638 +0,0 @@ -declare interface Array { - findIndex(predicate: (c: T) => boolean): number; - any(predicate: (c: T) => boolean): boolean; - firstOrDefault(predicate: (c: T) => boolean): T; - find(predicate: (c: T) => boolean): T; - where(predicate: (c: T) => boolean): Array; - count(predicate: (c: T) => boolean): number; - findAll(predicate: (c: T) => boolean): Array; - contains(value: T): boolean; - removeAll(predicate: (c: T) => boolean): void; - remove(element: T): boolean; - removeAt(index: number): void; - removeRange(index: number, count: number): void; - select(selector: Function): Array; - orderBy(keySelector: Function, comparer: Function): Array; - orderByDescending(keySelector: Function, comparer: Function): Array; - groupBy(keySelector: Function): Array; - sum(selector: Function): number; -} -declare module es { - class PriorityQueueNode { - priority: number; - insertionIndex: number; - queueIndex: number; - } -} -declare module es { - class AStarPathfinder { - static search(graph: IAstarGraph, start: T, goal: T): T[]; - static recontructPath(cameFrom: Map, start: T, goal: T): T[]; - private static hasKey; - private static getKey; - } -} -declare module es { - class AstarGridGraph implements IAstarGraph { - dirs: Vector2[]; - walls: Vector2[]; - weightedNodes: Vector2[]; - defaultWeight: number; - weightedNodeWeight: number; - private _width; - private _height; - private _neighbors; - constructor(width: number, height: number); - isNodeInBounds(node: Vector2): boolean; - isNodePassable(node: Vector2): boolean; - search(start: Vector2, goal: Vector2): Vector2[]; - getNeighbors(node: Vector2): Vector2[]; - cost(from: Vector2, to: Vector2): number; - heuristic(node: Vector2, goal: Vector2): number; - } -} -declare module es { - interface IAstarGraph { - getNeighbors(node: T): Array; - cost(from: T, to: T): number; - heuristic(node: T, goal: T): any; - } -} -declare module es { - class PriorityQueue { - private _numNodes; - private _nodes; - private _numNodesEverEnqueued; - constructor(maxNodes: number); - readonly count: number; - readonly maxSize: number; - clear(): void; - contains(node: T): boolean; - enqueue(node: T, priority: number): void; - dequeue(): T; - remove(node: T): void; - isValidQueue(): boolean; - private onNodeUpdated; - private cascadeDown; - private cascadeUp; - private swap; - private hasHigherPriority; - } -} -declare module es { - class BreadthFirstPathfinder { - static search(graph: IUnweightedGraph, start: T, goal: T): T[]; - private static hasKey; - } -} -declare module es { - interface IUnweightedGraph { - getNeighbors(node: T): T[]; - } -} -declare module es { - class UnweightedGraph implements IUnweightedGraph { - edges: Map; - addEdgesForNode(node: T, edges: T[]): this; - getNeighbors(node: T): T[]; - } -} -declare module es { - class Vector2 implements IEquatable { - x: number; - y: number; - constructor(x?: number, y?: number); - static readonly zero: Vector2; - static readonly one: Vector2; - static readonly unitX: Vector2; - static readonly unitY: Vector2; - static add(value1: Vector2, value2: Vector2): Vector2; - static divide(value1: Vector2, value2: Vector2): Vector2; - static multiply(value1: Vector2, value2: Vector2): Vector2; - static subtract(value1: Vector2, value2: Vector2): Vector2; - static normalize(value: Vector2): Vector2; - static dot(value1: Vector2, value2: Vector2): number; - static distanceSquared(value1: Vector2, value2: Vector2): number; - static clamp(value1: Vector2, min: Vector2, max: Vector2): Vector2; - static lerp(value1: Vector2, value2: Vector2, amount: number): Vector2; - static transform(position: Vector2, matrix: Matrix2D): Vector2; - static distance(value1: Vector2, value2: Vector2): number; - static angle(from: Vector2, to: Vector2): number; - static negate(value: Vector2): Vector2; - add(value: Vector2): Vector2; - divide(value: Vector2): Vector2; - multiply(value: Vector2): Vector2; - subtract(value: Vector2): this; - normalize(): void; - length(): number; - lengthSquared(): number; - round(): Vector2; - equals(other: Vector2 | object): boolean; - } -} -declare module es { - class UnweightedGridGraph implements IUnweightedGraph { - private static readonly CARDINAL_DIRS; - private static readonly COMPASS_DIRS; - walls: Vector2[]; - private _width; - private _hegiht; - private _dirs; - private _neighbors; - constructor(width: number, height: number, allowDiagonalSearch?: boolean); - isNodeInBounds(node: Vector2): boolean; - isNodePassable(node: Vector2): boolean; - getNeighbors(node: Vector2): Vector2[]; - search(start: Vector2, goal: Vector2): Vector2[]; - } -} -declare module es { - interface IWeightedGraph { - getNeighbors(node: T): T[]; - cost(from: T, to: T): number; - } -} -declare module es { - class WeightedGridGraph implements IWeightedGraph { - static readonly CARDINAL_DIRS: Vector2[]; - private static readonly COMPASS_DIRS; - walls: Vector2[]; - weightedNodes: Vector2[]; - defaultWeight: number; - weightedNodeWeight: number; - private _width; - private _height; - private _dirs; - private _neighbors; - constructor(width: number, height: number, allowDiagonalSearch?: boolean); - isNodeInBounds(node: Vector2): boolean; - isNodePassable(node: Vector2): boolean; - search(start: Vector2, goal: Vector2): Vector2[]; - getNeighbors(node: Vector2): Vector2[]; - cost(from: Vector2, to: Vector2): number; - } -} -declare module es { - class WeightedNode extends PriorityQueueNode { - data: T; - constructor(data: T); - } - class WeightedPathfinder { - static search(graph: IWeightedGraph, start: T, goal: T): T[]; - static recontructPath(cameFrom: Map, start: T, goal: T): T[]; - private static hasKey; - private static getKey; - } -} -declare module es { - class AStarStorage { - static readonly MAX_NODES: number; - _opened: AStarNode[]; - _closed: AStarNode[]; - _numOpened: number; - _numClosed: number; - _lastFoundOpened: number; - _lastFoundClosed: number; - constructor(); - clear(): void; - findOpened(node: AStarNode): AStarNode; - findClosed(node: AStarNode): AStarNode; - hasOpened(): boolean; - removeOpened(node: AStarNode): void; - removeClosed(node: AStarNode): void; - isOpen(node: AStarNode): boolean; - isClosed(node: AStarNode): boolean; - addToOpenList(node: AStarNode): void; - addToClosedList(node: AStarNode): void; - removeCheapestOpenNode(): AStarNode; - } -} -declare module es { - class AStarNode implements IEquatable, IPoolable { - worldState: WorldState; - costSoFar: number; - heuristicCost: number; - costSoFarAndHeuristicCost: number; - action: Action; - parent: AStarNode; - parentWorldState: WorldState; - depth: number; - equals(other: AStarNode): boolean; - compareTo(other: AStarNode): number; - reset(): void; - clone(): AStarNode; - toString(): string; - } - class AStar { - static storage: AStarStorage; - static plan(ap: ActionPlanner, start: WorldState, goal: WorldState, selectedNodes?: AStarNode[]): Action[]; - static reconstructPlan(goalNode: AStarNode, selectedNodes: AStarNode[]): Action[]; - static calculateHeuristic(fr: WorldState, to: WorldState): number; - } -} -declare module es { - class Action { - name: string; - cost: number; - _preConditions: Set<[string, boolean]>; - _postConditions: Set<[string, boolean]>; - constructor(name?: string, cost?: number); - setPrecondition(conditionName: string, value: boolean): void; - setPostcondition(conditionName: string, value: boolean): void; - validate(): boolean; - toString(): string; - } -} -declare module es { - class ActionPlanner { - static readonly MAX_CONDITIONS: number; - conditionNames: string[]; - _actions: Action[]; - _viableActions: Action[]; - _preConditions: WorldState[]; - _postConditions: WorldState[]; - _numConditionNames: number; - constructor(); - createWorldState(): WorldState; - addAction(action: Action): void; - plan(startState: WorldState, goalState: WorldState, selectedNode?: any): Action[]; - getPossibleTransitions(fr: WorldState): AStarNode[]; - applyPostConditions(ap: ActionPlanner, actionnr: number, fr: WorldState): WorldState; - findConditionNameIndex(conditionName: string): any; - findActionIndex(action: Action): number; - } -} -declare module es { - abstract class Agent { - actions: Action[]; - _planner: ActionPlanner; - constructor(); - plan(debugPlan?: boolean): boolean; - hasActionPlan(): boolean; - abstract getWorldState(): WorldState; - abstract getGoalState(): WorldState; - } -} -declare module es { - class WorldState implements IEquatable { - values: number; - dontCare: number; - planner: ActionPlanner; - static create(planner: ActionPlanner): WorldState; - constructor(planner: ActionPlanner, values: number, dontcare: number); - set(conditionId: number | string, value: boolean): boolean; - equals(other: WorldState): boolean; - describe(planner: ActionPlanner): string; - } -} -declare module es { - class Core extends egret.DisplayObjectContainer { - static emitter: Emitter; - static debugRenderEndabled: boolean; - static graphicsDevice: GraphicsDevice; - static content: ContentManager; - static _instance: Core; - _nextScene: Scene; - _sceneTransition: SceneTransition; - _globalManagers: GlobalManager[]; - _coroutineManager: CoroutineManager; - _timerManager: TimerManager; - constructor(); - static readonly Instance: Core; - _frameCounterElapsedTime: number; - _frameCounter: number; - _scene: Scene; - static scene: Scene; - static startSceneTransition(sceneTransition: T): T; - static registerGlobalManager(manager: es.GlobalManager): void; - static unregisterGlobalManager(manager: es.GlobalManager): void; - static getGlobalManager(type: any): T; - static startCoroutine(enumerator: Iterator): CoroutineImpl; - static schedule(timeInSeconds: number, repeats: boolean, context: any, onTime: (timer: ITimer) => void): Timer; - onOrientationChanged(): void; - draw(): Promise; - startDebugUpdate(): void; - endDebugUpdate(): void; - startDebugDraw(elapsedGameTime: number): void; - endDebugDraw(): void; - onSceneChanged(): void; - protected onGraphicsDeviceReset(): void; - protected initialize(): void; - protected update(): Promise; - private onAddToStage; - } -} -declare module es { - class Colors { - static renderableBounds: number; - static renderableCenter: number; - static colliderBounds: number; - static colliderEdge: number; - static colliderPosition: number; - static colliderCenter: number; - } - class Size { - static readonly lineSizeMultiplier: number; - } - class Debug { - private static _debugDrawItems; - static drawHollowRect(rectanle: Rectangle, color: number, duration?: number): void; - static render(): void; - } -} -declare module es { - class DebugDefaults { - static verletParticle: number; - static verletConstraintEdge: number; - } -} -declare module es { - enum DebugDrawType { - line = 0, - hollowRectangle = 1, - pixel = 2, - text = 3 - } - class DebugDrawItem { - rectangle: Rectangle; - color: number; - duration: number; - drawType: DebugDrawType; - text: string; - start: Vector2; - end: Vector2; - x: number; - y: number; - size: number; - constructor(rectangle: Rectangle, color: number, duration: number); - draw(shape: egret.Shape): boolean; - } -} -declare module es { - abstract class Component extends egret.HashObject { - entity: Entity; - updateInterval: number; - debugDisplayObject: egret.DisplayObjectContainer; - readonly transform: Transform; - private _enabled; - enabled: boolean; - private _updateOrder; - updateOrder: number; - initialize(): void; - onAddedToEntity(): void; - onRemovedFromEntity(): void; - onEntityTransformChanged(comp: transform.Component): void; - debugRender(camera: Camera): void; - onEnabled(): void; - onDisabled(): void; - update(): void; - setEnabled(isEnabled: boolean): this; - setUpdateOrder(updateOrder: number): this; - } -} -declare module es { - enum CoreEvents { - GraphicsDeviceReset = 0, - SceneChanged = 1, - OrientationChanged = 2 - } -} -declare module es { - class Entity { - static _idGenerator: number; - scene: Scene; - name: string; - readonly id: number; - readonly transform: Transform; - readonly components: ComponentList; - updateInterval: number; - componentBits: BitSet; - constructor(name: string); - _isDestroyed: boolean; - readonly isDestroyed: boolean; - private _tag; - tag: number; - private _enabled; - enabled: boolean; - private _updateOrder; - updateOrder: number; - parent: Transform; - readonly childCount: number; - position: Vector2; - localPosition: Vector2; - rotation: number; - rotationDegrees: number; - localRotation: number; - localRotationDegrees: number; - scale: Vector2; - localScale: Vector2; - readonly worldInverseTransform: Matrix2D; - readonly localToWorldTransform: Matrix2D; - readonly worldToLocalTransform: Matrix2D; - onTransformChanged(comp: transform.Component): void; - setTag(tag: number): Entity; - setEnabled(isEnabled: boolean): this; - setUpdateOrder(updateOrder: number): this; - destroy(): void; - detachFromScene(): void; - attachToScene(newScene: Scene): void; - onAddedToScene(): void; - onRemovedFromScene(): void; - update(): void; - debugRender(camera: Camera): void; - addComponent(component: T): T; - getComponent(type: any): T; - hasComponent(type: any): boolean; - getOrCreateComponent(type: T): T; - getComponents(typeName: string | any, componentList?: any): any; - removeComponent(component: Component): void; - removeComponentForType(type: any): boolean; - removeAllComponents(): void; - compareTo(other: Entity): number; - toString(): string; - } -} -declare module es { - class Scene extends egret.DisplayObjectContainer { - camera: Camera; - readonly content: ContentManager; - enablePostProcessing: boolean; - readonly entities: EntityList; - readonly renderableComponents: RenderableComponentList; - readonly entityProcessors: EntityProcessorList; - _screenshotRequestCallback: Function; - readonly _sceneComponents: SceneComponent[]; - _renderers: Renderer[]; - readonly _postProcessors: PostProcessor[]; - _didSceneBegin: any; - dynamicBatch: boolean; - constructor(); - static createWithDefaultRenderer(): Scene; - initialize(): void; - onStart(): Promise; - unload(): void; - onActive(): void; - onDeactive(): void; - begin(): void; - end(): void; - updateResolutionScaler(): void; - update(): void; - render(): void; - dynamicInBatch(): void; - postRender(): void; - requestScreenshot(callback: Function): void; - addSceneComponent(component: T): T; - getSceneComponent(type: any): T; - getOrCreateSceneComponent(type: any): T; - removeSceneComponent(component: SceneComponent): void; - addRenderer(renderer: T): T; - getRenderer(type: any): T; - removeRenderer(renderer: Renderer): void; - addPostProcessor(postProcessor: T): T; - getPostProcessor(type: any): T; - removePostProcessor(postProcessor: PostProcessor): void; - createEntity(name: string): Entity; - addEntity(entity: Entity): Entity; - destroyAllEntities(): void; - findEntity(name: string): Entity; - findEntitiesWithTag(tag: number): Entity[]; - entitiesOfType(type: any): T[]; - findComponentOfType(type: any): T; - findComponentsOfType(type: any): T[]; - addEntityProcessor(processor: EntitySystem): EntitySystem; - removeEntityProcessor(processor: EntitySystem): void; - getEntityProcessor(): T; - } -} -declare module transform { - enum Component { - position = 0, - scale = 1, - rotation = 2 - } -} -declare module es { - import HashObject = egret.HashObject; - enum DirtyType { - clean = 0, - positionDirty = 1, - scaleDirty = 2, - rotationDirty = 3 - } - class Transform extends HashObject { - readonly entity: Entity; - hierarchyDirty: DirtyType; - _localDirty: boolean; - _localPositionDirty: boolean; - _localScaleDirty: boolean; - _localRotationDirty: boolean; - _positionDirty: boolean; - _worldToLocalDirty: boolean; - _worldInverseDirty: boolean; - _localTransform: Matrix2D; - _worldTransform: Matrix2D; - _rotationMatrix: Matrix2D; - _translationMatrix: Matrix2D; - _scaleMatrix: Matrix2D; - _children: Transform[]; - constructor(entity: Entity); - readonly childCount: number; - rotationDegrees: number; - localRotationDegrees: number; - readonly localToWorldTransform: Matrix2D; - _parent: Transform; - parent: Transform; - _worldToLocalTransform: Matrix2D; - readonly worldToLocalTransform: Matrix2D; - _worldInverseTransform: Matrix2D; - readonly worldInverseTransform: Matrix2D; - _position: Vector2; - position: Vector2; - _scale: Vector2; - scale: Vector2; - _rotation: number; - rotation: number; - _localPosition: Vector2; - localPosition: Vector2; - _localScale: Vector2; - localScale: Vector2; - _localRotation: number; - localRotation: number; - getChild(index: number): Transform; - setParent(parent: Transform): Transform; - setPosition(x: number, y: number): Transform; - setLocalPosition(localPosition: Vector2): Transform; - setRotation(radians: number): Transform; - setRotationDegrees(degrees: number): Transform; - lookAt(pos: Vector2): void; - setLocalRotation(radians: number): this; - setLocalRotationDegrees(degrees: number): Transform; - setScale(scale: Vector2): Transform; - setLocalScale(scale: Vector2): Transform; - roundPosition(): void; - updateTransform(): void; - setDirty(dirtyFlagType: DirtyType): void; - copyFrom(transform: Transform): void; - toString(): string; - equals(other: Transform): boolean; - } -} -declare module es { - interface CameraInset { - left: number; - right: number; - top: number; - bottom: number; - } - class Camera extends Component { - _inset: CameraInset; - _areMatrixedDirty: boolean; - _areBoundsDirty: boolean; - _isProjectionMatrixDirty: boolean; - constructor(); - position: Vector2; - rotation: number; - rawZoom: number; - _zoom: number; - zoom: number; - _minimumZoom: number; - minimumZoom: number; - _maximumZoom: number; - maximumZoom: number; - _bounds: Rectangle; - readonly bounds: Rectangle; - _transformMatrix: Matrix2D; - readonly transformMatrix: Matrix2D; - _inverseTransformMatrix: Matrix2D; - readonly inverseTransformMatrix: Matrix2D; - _origin: Vector2; - origin: Vector2; - setInset(left: number, right: number, top: number, bottom: number): Camera; - setPosition(position: Vector2): this; - setRotation(rotation: number): Camera; - setZoom(zoom: number): Camera; - setMinimumZoom(minZoom: number): Camera; - setMaximumZoom(maxZoom: number): Camera; - forceMatrixUpdate(): void; - onEntityTransformChanged(comp: transform.Component): void; - zoomIn(deltaZoom: number): void; - zoomOut(deltaZoom: number): void; - worldToScreenPoint(worldPosition: Vector2): Vector2; - screenToWorldPoint(screenPosition: Vector2): Vector2; - onSceneRenderTargetSizeChanged(newWidth: number, newHeight: number): void; - mouseToWorldPoint(): Vector2; - protected updateMatrixes(): void; - } -} -declare module es { - class CameraShake extends Component { - _shakeDirection: Vector2; - _shakeOffset: Vector2; - _shakeIntensity: number; - _shakeDegredation: number; - shake(shakeIntensify?: number, shakeDegredation?: number, shakeDirection?: Vector2): void; - update(): void; - } -} -declare module es { - class ComponentPool { - private _cache; - private _type; - constructor(typeClass: any); - obtain(): T; - free(component: T): void; - } -} -declare module es { - enum CameraStyle { - lockOn = 0, - cameraWindow = 1 - } - class FollowCamera extends Component { - camera: Camera; - followLerp: number; - deadzone: Rectangle; - focusOffset: Vector2; - mapLockEnabled: boolean; - mapSize: Rectangle; - _targetEntity: Entity; - _targetCollider: Collider; - _desiredPositionDelta: Vector2; - _cameraStyle: CameraStyle; - _worldSpaceDeadZone: Rectangle; - private rectShape; - constructor(targetEntity?: Entity, camera?: Camera, cameraStyle?: CameraStyle); - onAddedToEntity(): void; - onGraphicsDeviceReset(): void; - update(): void; - debugRender(camera: Camera): void; - clampToMapSize(position: Vector2): Vector2; - follow(targetEntity: Entity, cameraStyle?: CameraStyle): void; - updateFollow(): void; - setCenteredDeadzone(width: number, height: number): void; - } -} -declare module es { - interface IUpdatable { - enabled: boolean; - updateOrder: number; - update(): any; - } - class IUpdatableComparer implements IComparer { - compare(a: Component, b: Component): number; - } -} -declare module es { - abstract class PooledComponent extends Component { - abstract reset(): any; - } -} -declare module es { - class SceneComponent { - scene: Scene; - enabled: boolean; - updateOrder: number; - _enabled: boolean; - onEnabled(): void; - onDisabled(): void; - onRemovedFromScene(): void; - update(): void; - setEnabled(isEnabled: boolean): SceneComponent; - setUpdateOrder(updateOrder: number): this; - compareTo(other: SceneComponent): number; - } -} -declare module es { - interface ITriggerListener { - onTriggerEnter(other: Collider, local: Collider): any; - onTriggerExit(other: Collider, local: Collider): any; - } -} -declare module es { - class Mover extends Component { - private _triggerHelper; - onAddedToEntity(): void; - calculateMovement(motion: Vector2, collisionResult: CollisionResult): boolean; - applyMovement(motion: Vector2): void; - move(motion: Vector2, collisionResult: CollisionResult): boolean; - } -} -declare module es { - class ProjectileMover extends Component { - private _tempTriggerList; - private _collider; - onAddedToEntity(): void; - move(motion: Vector2): boolean; - private notifyTriggerListeners; - } -} -declare module es { - abstract class Collider extends Component { - shape: Shape; - isTrigger: boolean; - physicsLayer: Ref; - collidesWithLayers: Ref; - shouldColliderScaleAndRotateWithTransform: boolean; - registeredPhysicsBounds: Rectangle; - _localOffsetLength: number; - _isPositionDirty: boolean; - _isRotationDirty: boolean; - protected _colliderRequiresAutoSizing: any; - protected _isParentEntityAddedToScene: any; - protected _isColliderRegistered: any; - readonly absolutePosition: Vector2; - readonly rotation: number; - readonly bounds: Rectangle; - protected _localOffset: Vector2; - localOffset: Vector2; - setLocalOffset(offset: Vector2): Collider; - setShouldColliderScaleAndRotateWithTransform(shouldColliderScaleAndRotationWithTransform: boolean): Collider; - onAddedToEntity(): void; - onRemovedFromEntity(): void; - onEntityTransformChanged(comp: transform.Component): void; - onEnabled(): void; - onDisabled(): void; - registerColliderWithPhysicsSystem(): void; - unregisterColliderWithPhysicsSystem(): void; - overlaps(other: Collider): boolean; - collidesWith(collider: Collider, motion: Vector2, result: CollisionResult): boolean; - } -} -declare module es { - class BoxCollider extends Collider { - hollowShape: egret.Shape; - polygonShape: egret.Shape; - pixelShape1: egret.Shape; - pixelShape2: egret.Shape; - constructor(x?: number, y?: number, width?: number, height?: number); - width: number; - height: number; - setSize(width: number, height: number): this; - setWidth(width: number): BoxCollider; - setHeight(height: number): void; - debugRender(camera: Camera): void; - toString(): string; - } -} -declare module es { - class CircleCollider extends Collider { - private rectShape; - private circleShape; - private pixelShape1; - private pixelShape2; - constructor(radius?: number); - radius: number; - setRadius(radius: number): CircleCollider; - debugRender(camera: Camera): void; - toString(): string; - } -} -declare module es { - class PolygonCollider extends Collider { - constructor(points: Vector2[]); - } -} -declare module es { - abstract class RenderableComponent extends Component implements IRenderable { - displayObject: egret.DisplayObject; - hollowShape: egret.Shape; - pixelShape: egret.Shape; - color: number; - protected _areBoundsDirty: boolean; - readonly width: number; - readonly height: number; - debugRenderEnabled: boolean; - protected _localOffset: Vector2; - localOffset: Vector2; - protected _renderLayer: number; - renderLayer: number; - protected _bounds: Rectangle; - readonly bounds: Rectangle; - private _isVisible; - isVisible: boolean; - onEntityTransformChanged(comp: transform.Component): void; - abstract render(camera: Camera): any; - debugRender(camera: Camera): void; - isVisibleFromCamera(camera: Camera): boolean; - setRenderLayer(renderLayer: number): RenderableComponent; - setColor(color: number): RenderableComponent; - setLocalOffset(offset: Vector2): RenderableComponent; - sync(camera: Camera): void; - compareTo(other: RenderableComponent): number; - toString(): string; - protected onBecameVisible(): void; - protected onBecameInvisible(): void; - } -} -declare module es { - class Mesh extends RenderableComponent { - displayObject: egret.Mesh; - readonly bounds: Rectangle; - _primitiveCount: number; - _topLeftVertPosition: Vector2; - _width: number; - _height: number; - _triangles: number[]; - _verts: VertexPositionColorTexture[]; - recalculateBounds(recalculateUVs: boolean): this; - setTexture(texture: egret.Texture): Mesh; - setVertPositions(positions: Vector2[]): this; - setTriangles(triangles: number[]): this; - render(camera: es.Camera): void; - } - class VertexPositionColorTexture { - position: Vector2; - textureCoordinate: Vector2; - } -} -declare module es { - class SpriteRenderer extends RenderableComponent { - constructor(sprite?: Sprite | egret.Texture); - readonly bounds: Rectangle; - originNormalized: Vector2; - protected _origin: Vector2; - origin: Vector2; - protected _sprite: Sprite; - sprite: Sprite; - setSprite(sprite: Sprite): SpriteRenderer; - setOrigin(origin: Vector2): SpriteRenderer; - setOriginNormalized(value: Vector2): SpriteRenderer; - render(camera: Camera): void; - } -} -declare module es { - class TiledSpriteRenderer extends SpriteRenderer { - readonly bounds: Rectangle; - scrollX: number; - scrollY: number; - textureScale: Vector2; - width: number; - height: number; - gapXY: Vector2; - protected _sourceRect: Rectangle; - protected _textureScale: Vector2; - protected _inverseTexScale: Vector2; - private _gapX; - private _gapY; - constructor(sprite: Sprite); - setGapXY(value: Vector2): TiledSpriteRenderer; - render(camera: es.Camera): void; - } -} -declare module es { - class ScrollingSpriteRenderer extends TiledSpriteRenderer { - scrollSpeedX: number; - scroolSpeedY: number; - textureScale: Vector2; - scrollWidth: number; - scrollHeight: number; - private _scrollX; - private _scrollY; - private _scrollWidth; - private _scrollHeight; - constructor(sprite: Sprite); - update(): void; - } -} -declare module es { - class Sprite { - texture2D: egret.Texture; - readonly sourceRect: Rectangle; - readonly center: Vector2; - origin: Vector2; - readonly uvs: Rectangle; - constructor(texture: egret.Texture, sourceRect?: Rectangle, origin?: Vector2); - static spritesFromAtlas(texture: egret.Texture, cellWidth: number, cellHeight: number, cellOffset?: number, maxCellsToInclude?: number): Sprite[]; - } -} -declare module es { - class SpriteAnimation { - readonly sprites: Sprite[]; - readonly frameRate: number; - constructor(sprites: Sprite[], frameRate?: number); - } -} -declare module es { - enum LoopMode { - loop = 0, - once = 1, - clampForever = 2, - pingPong = 3, - pingPongOnce = 4 - } - enum State { - none = 0, - running = 1, - paused = 2, - completed = 3 - } - class SpriteAnimator extends SpriteRenderer { - onAnimationCompletedEvent: (string: any) => {}; - speed: number; - animationState: State; - currentAnimation: SpriteAnimation; - currentAnimationName: string; - currentFrame: number; - _elapsedTime: number; - _loopMode: LoopMode; - constructor(sprite?: Sprite); - readonly isRunning: boolean; - private _animations; - readonly animations: Map; - update(): void; - addAnimation(name: string, animation: SpriteAnimation): SpriteAnimator; - play(name: string, loopMode?: LoopMode): void; - isAnimationActive(name: string): boolean; - pause(): void; - unPause(): void; - stop(): void; - } -} -declare module es { - import Bitmap = egret.Bitmap; - class StaticSpriteContainerRenderer extends RenderableComponent { - displayObject: egret.DisplayObjectContainer; - private displayObjectCache; - constructor(sprite?: Sprite[] | egret.Texture[]); - readonly bounds: Rectangle; - originNormalized: Vector2; - protected _origin: Vector2; - origin: Vector2; - pushSprite(sprite: Sprite): StaticSpriteContainerRenderer; - getSprite(sprite: Sprite): Bitmap; - setOrigin(origin: Vector2): StaticSpriteContainerRenderer; - setOriginNormalized(value: Vector2): StaticSpriteContainerRenderer; - render(camera: Camera): void; - } -} -declare module es { - class EntitySystem { - private _entities; - constructor(matcher?: Matcher); - private _scene; - scene: Scene; - private _matcher; - readonly matcher: Matcher; - initialize(): void; - onChanged(entity: Entity): void; - add(entity: Entity): void; - onAdded(entity: Entity): void; - remove(entity: Entity): void; - onRemoved(entity: Entity): void; - update(): void; - lateUpdate(): void; - protected begin(): void; - protected process(entities: Entity[]): void; - protected lateProcess(entities: Entity[]): void; - protected end(): void; - } -} -declare module es { - abstract class EntityProcessingSystem extends EntitySystem { - constructor(matcher: Matcher); - abstract processEntity(entity: Entity): any; - lateProcessEntity(entity: Entity): void; - protected process(entities: Entity[]): void; - protected lateProcess(entities: Entity[]): void; - } -} -declare module es { - abstract class PassiveSystem extends EntitySystem { - onChanged(entity: Entity): void; - protected process(entities: Entity[]): void; - } -} -declare module es { - abstract class ProcessingSystem extends EntitySystem { - onChanged(entity: Entity): void; - abstract processSystem(): any; - protected process(entities: Entity[]): void; - } -} -declare module es { - class BitSet { - private static LONG_MASK; - private _bits; - constructor(nbits?: number); - and(bs: BitSet): void; - andNot(bs: BitSet): void; - cardinality(): number; - clear(pos?: number): void; - get(pos: number): boolean; - intersects(set: BitSet): boolean; - isEmpty(): boolean; - nextSetBit(from: number): number; - set(pos: number, value?: boolean): void; - private ensure; - } -} -declare module es { - class ComponentList { - static compareUpdatableOrder: IUpdatableComparer; - _entity: Entity; - _components: FastList; - _componentsToAdd: Component[]; - _componentsToRemove: Component[]; - _tempBufferList: Component[]; - _isComponentListUnsorted: boolean; - constructor(entity: Entity); - readonly count: number; - readonly buffer: Component[]; - markEntityListUnsorted(): void; - add(component: Component): void; - remove(component: Component): void; - removeAllComponents(): void; - deregisterAllComponents(): void; - registerAllComponents(): void; - updateLists(): void; - handleRemove(component: Component): void; - getComponent(type: any, onlyReturnInitializedComponents: boolean): T; - getComponents(typeName: string | any, components?: any): any; - update(): void; - onEntityTransformChanged(comp: transform.Component): void; - onEntityEnabled(): void; - onEntityDisabled(): void; - debugRender(camera: Camera): void; - } -} -declare module es { - class ComponentTypeManager { - private static _componentTypesMask; - static add(type: any): void; - static getIndexFor(type: any): number; - } -} -declare module es { - class EntityList { - scene: Scene; - _entities: Entity[]; - _entitiesToAdded: Entity[]; - _entitiesToRemove: Entity[]; - _isEntityListUnsorted: boolean; - _entityDict: Map; - _unsortedTags: Set; - _addToSceneEntityList: Entity[]; - frameAllocate: boolean; - maxAllocate: number; - constructor(scene: Scene); - readonly count: number; - readonly buffer: Entity[]; - markEntityListUnsorted(): void; - markTagUnsorted(tag: number): void; - add(entity: Entity): void; - remove(entity: Entity): void; - removeAllEntities(): void; - contains(entity: Entity): boolean; - getTagList(tag: number): Entity[]; - addToTagList(entity: Entity): void; - removeFromTagList(entity: Entity): void; - update(): void; - updateLists(): void; - private perEntityAddToScene; - findEntity(name: string): Entity; - entitiesWithTag(tag: number): Entity[]; - entitiesOfType(type: any): T[]; - findComponentOfType(type: any): T; - findComponentsOfType(type: any): T[]; - } -} -declare module es { - class EntityProcessorList { - protected _processors: EntitySystem[]; - add(processor: EntitySystem): void; - remove(processor: EntitySystem): void; - onComponentAdded(entity: Entity): void; - onComponentRemoved(entity: Entity): void; - onEntityAdded(entity: Entity): void; - onEntityRemoved(entity: Entity): void; - begin(): void; - update(): void; - lateUpdate(): void; - end(): void; - getProcessor(): T; - protected notifyEntityChanged(entity: Entity): void; - protected removeFromProcessors(entity: Entity): void; - } -} -declare module es { - class FasterDictionary { - _values: TValue[]; - _valuesInfo: FastNode[]; - _buckets: number[]; - _freeValueCellIndex: number; - _collisions: number; - constructor(size?: number); - getValuesArray(count: { - value: number; - }): TValue[]; - readonly valuesArray: TValue[]; - readonly count: number; - add(key: TKey, value: TValue): void; - addValue(key: TKey, value: TValue, indexSet: { - value: number; - }): boolean; - remove(key: TKey): boolean; - trim(): void; - clear(): void; - fastClear(): void; - containsKey(key: TKey): boolean; - tryGetValue(key: TKey): TValue; - tryFindIndex(key: TKey, findIndex: { - value: number; - }): boolean; - getDirectValue(index: number): TValue; - getIndex(key: TKey): number; - static updateLinkedList(index: number, valuesInfo: FastNode[]): void; - static hash(key: any): number; - static reduce(x: number, n: number): number; - } - class FastNode { - readonly key: any; - readonly hashcode: number; - previous: number; - next: number; - constructor(key: any, hash: number, previousNode?: number); - } -} -declare module es { - class FastList { - buffer: T[]; - length: number; - constructor(size?: number); - clear(): void; - reset(): void; - add(item: T): void; - remove(item: T): void; - removeAt(index: number): void; - contains(item: T): boolean; - ensureCapacity(additionalItemCount?: number): void; - addRange(array: T[]): void; - sort(comparer: IComparer): void; - } -} -declare module es { - class HashHelpers { - static readonly hashCollisionThreshold: number; - static readonly hashPrime: number; - static readonly primes: number[]; - static readonly maxPrimeArrayLength: number; - static isPrime(candidate: number): boolean; - static getPrime(min: number): number; - static expandPrime(oldSize: number): number; - static getHashCode(str: any): number; - } -} -declare module es { - class Matcher { - protected allSet: BitSet; - protected exclusionSet: BitSet; - protected oneSet: BitSet; - static empty(): Matcher; - getAllSet(): BitSet; - getExclusionSet(): BitSet; - getOneSet(): BitSet; - IsIntersted(e: Entity): boolean; - all(...types: any[]): Matcher; - exclude(...types: any[]): this; - one(...types: any[]): this; - } -} -declare class ObjectUtils { - static clone(p: any, c?: T): T; - static elements(p: {}): any[]; -} -declare module es { - interface IRenderable { - bounds: Rectangle; - enabled: boolean; - renderLayer: number; - isVisible: boolean; - isVisibleFromCamera(camera: Camera): any; - render(camera: Camera): any; - debugRender(camera: Camera): any; - } - class RenderableComparer { - compare(self: IRenderable, other: IRenderable): number; - } -} -declare module es { - class RenderableComponentList { - static compareUpdatableOrder: RenderableComparer; - _components: IRenderable[]; - _componentsByRenderLayer: Map; - _unsortedRenderLayers: number[]; - private _componentsNeedSort; - componentsNeedSort: boolean; - readonly count: number; - readonly buffer: IRenderable[]; - add(component: IRenderable): void; - remove(component: IRenderable): void; - updateRenderableRenderLayer(component: IRenderable, oldRenderLayer: number, newRenderLayer: number): void; - setRenderLayerNeedsComponentSort(renderLayer: number): void; - setNeedsComponentSort(): void; - addToRenderLayerList(component: IRenderable, renderLayer: number): void; - componentsWithRenderLayer(renderLayer: number): IRenderable[]; - updateList(): void; - } -} -declare class StringUtils { - private static specialSigns; - static matchChineseWord(str: string): string[]; - static lTrim(target: string): string; - static rTrim(target: string): string; - static trim(target: string): string; - static isWhiteSpace(str: string): boolean; - static replaceMatch(mainStr: string, targetStr: string, replaceStr: string, caseMark?: boolean): string; - static htmlSpecialChars(str: string, reversion?: boolean): string; - static zfill(str: string, width?: number): string; - static reverse(str: string): string; - static cutOff(str: string, start: number, len: number, order?: boolean): string; - static strReplace(str: string, rStr: string[]): string; -} -declare module es { - class TextureUtils { - static sharedCanvas: HTMLCanvasElement; - static sharedContext: CanvasRenderingContext2D; - static convertImageToCanvas(texture: egret.Texture, rect?: egret.Rectangle): HTMLCanvasElement; - static toDataURL(type: string, texture: egret.Texture, rect?: egret.Rectangle, encoderOptions?: any): string; - static eliFoTevas(type: string, texture: egret.Texture, filePath: string, rect?: egret.Rectangle, encoderOptions?: any): void; - static getPixel32(texture: egret.Texture, x: number, y: number): number[]; - static getPixels(texture: egret.Texture, x: number, y: number, width?: number, height?: number): number[]; - } -} -declare module es { - class Time { - static unscaledDeltaTime: any; - static deltaTime: number; - static timeScale: number; - static frameCount: number; - static _timeSinceSceneLoad: any; - private static _lastTime; - static update(currentTime: number): void; - static sceneChanged(): void; - static checkEvery(interval: number): boolean; - } -} -declare class TimeUtils { - static monthId(d?: Date): number; - static dateId(t?: Date): number; - static weekId(d?: Date, first?: boolean): number; - static diffDay(a: Date, b: Date, fixOne?: boolean): number; - static getFirstDayOfWeek(d?: Date): Date; - static getFirstOfDay(d?: Date): Date; - static getNextFirstOfDay(d?: Date): Date; - static formatDate(date: Date): string; - static formatDateTime(date: Date): string; - static parseDate(s: string): Date; - static secondToTime(time?: number, partition?: string, showHour?: boolean): string; - static timeToMillisecond(time: string, partition?: string): string; -} -declare module es { - class Graphics { - static Instance: Graphics; - pixelTexture: Sprite; - constructor(); - } -} -declare module es { - class GraphicsCapabilities extends egret.Capabilities { - initialize(device: GraphicsDevice): void; - private platformInitialize; - } -} -declare module es { - class GraphicsDevice { - graphicsCapabilities: GraphicsCapabilities; - constructor(); - private _viewport; - readonly viewport: Viewport; - private setup; - } -} -declare module es { - class Viewport { - private _x; - private _y; - private _minDepth; - private _maxDepth; - constructor(x: number, y: number, width: number, height: number); - private _width; - width: number; - private _height; - height: number; - readonly aspectRatio: number; - bounds: Rectangle; - } -} -declare module es { - class GaussianBlurEffect extends egret.CustomFilter { - private static blur_frag; - constructor(); - } -} -declare module es { - class PolygonLightEffect extends egret.CustomFilter { - private static vertSrc; - private static fragmentSrc; - constructor(); - } -} -declare module es { - class PostProcessor { - static default_vert: string; - enabled: boolean; - effect: egret.Filter; - scene: Scene; - shape: egret.Shape; - constructor(effect?: egret.Filter); - onAddedToScene(scene: Scene): void; - process(): void; - onSceneBackBufferSizeChanged(newWidth: number, newHeight: number): void; - unload(): void; - protected drawFullscreenQuad(): void; - } -} -declare module es { - class GaussianBlurPostProcessor extends PostProcessor { - onAddedToScene(scene: Scene): void; - } -} -declare module es { - abstract class Renderer { - camera: Camera; - readonly renderOrder: number; - renderTexture: egret.RenderTexture; - shouldDebugRender: boolean; - readonly wantsToRenderToSceneRenderTarget: boolean; - protected constructor(renderOrder: number, camera?: Camera); - onAddedToScene(scene: Scene): void; - unload(): void; - abstract render(scene: Scene): any; - onSceneBackBufferSizeChanged(newWidth: number, newHeight: number): void; - compareTo(other: Renderer): number; - protected beginRender(cam: Camera): void; - protected renderAfterStateCheck(renderable: IRenderable, cam: Camera): void; - protected debugRender(scene: Scene, cam: Camera): void; - } -} -declare module es { - class DefaultRenderer extends Renderer { - constructor(); - render(scene: Scene): void; - } -} -declare module es { - class RenderLayerExcludeRenderer extends Renderer { - excludedRenderLayers: number[]; - constructor(renderOrder: number, ...excludedRenderLayers: number[]); - render(scene: es.Scene): void; - protected debugRender(scene: es.Scene, cam: es.Camera): void; - } -} -declare module es { - class ScreenSpaceRenderer extends Renderer { - renderLayers: number[]; - constructor(renderOrder: number, ...renderLayers: number[]); - render(scene: Scene): void; - protected debugRender(scene: es.Scene, cam: es.Camera): void; - onSceneBackBufferSizeChanged(newWidth: number, newHeight: number): void; - } -} -declare module es { - class PolyLight extends RenderableComponent { - power: number; - private _lightEffect; - private _indices; - constructor(radius: number, color: number, power: number); - protected _radius: number; - radius: number; - setRadius(radius: number): void; - render(camera: Camera): void; - reset(): void; - private computeTriangleIndices; - } -} -declare module es { - class GaussianBlur { - static createBlurredTexture(image: egret.Texture, deviation?: number): void; - static createBlurredTextureData(srcData: Color[], width: number, height: number, deviation?: number): Color[]; - static gaussianConvolution(matrix: FasterDictionary<{ - x: number; - y: number; - }, number>, deviation: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static processPoint(matrix: FasterDictionary<{ - x: number; - y: number; - }, number>, x: number, y: number, kernel: FasterDictionary<{ - x: number; - y: number; - }, number>, direction: number): number; - static calculate1DSampleKernel(deviation: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static calculate1DSampleKernelOfSize(deviation: number, size: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static calculateNormalized1DSampleKernel(deviation: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static normalizeMatrix(matrix: FasterDictionary<{ - x: number; - y: number; - }, number>): FasterDictionary<{ - x: number; - y: number; - }, number>; - } -} -declare module es { - abstract class SceneTransition { - loadsNewScene: boolean; - isNewSceneLoaded: boolean; - onScreenObscured: Function; - onTransitionCompleted: Function; - protected sceneLoadAction: Function; - constructor(sceneLoadAction: Function); - private _hasPreviousSceneRender; - readonly hasPreviousSceneRender: boolean; - preRender(): void; - render(): void; - onBeginTransition(): Promise; - tickEffectProgressProperty(filter: egret.CustomFilter, duration: number, easeType: Function, reverseDirection?: boolean): Promise; - protected transitionComplete(): void; - protected loadNextScene(): Promise; - } -} -declare module es { - class FadeTransition extends SceneTransition { - fadeToColor: number; - fadeOutDuration: number; - fadeEaseType: Function; - delayBeforeFadeInDuration: number; - private _mask; - private _alpha; - constructor(sceneLoadAction: Function); - onBeginTransition(): Promise; - protected transitionComplete(): void; - render(): void; - } -} -declare module es { - class WindTransition extends SceneTransition { - duration: number; - easeType: (t: number) => number; - private _mask; - private _windEffect; - constructor(sceneLoadAction: Function); - windSegments: number; - size: number; - onBeginTransition(): Promise; - protected transitionComplete(): void; - } -} -declare module es { - class Bezier { - static getPoint(p0: Vector2, p1: Vector2, p2: Vector2, t: number): Vector2; - static getFirstDerivative(p0: Vector2, p1: Vector2, p2: Vector2, t: number): Vector2; - static getFirstDerivativeThree(start: Vector2, firstControlPoint: Vector2, secondControlPoint: Vector2, end: Vector2, t: number): Vector2; - static getPointThree(start: Vector2, firstControlPoint: Vector2, secondControlPoint: Vector2, end: Vector2, t: number): Vector2; - static getOptimizedDrawingPoints(start: Vector2, firstCtrlPoint: Vector2, secondCtrlPoint: Vector2, end: Vector2, distanceTolerance?: number): Vector2[]; - private static recursiveGetOptimizedDrawingPoints; - } -} -declare module es { - class Flags { - static isFlagSet(self: number, flag: number): boolean; - static isUnshiftedFlagSet(self: number, flag: number): boolean; - static setFlagExclusive(self: Ref, flag: number): void; - static setFlag(self: Ref, flag: number): void; - static unsetFlag(self: Ref, flag: number): void; - static invertFlags(self: Ref): void; - } -} -declare module es { - class MathHelper { - static readonly Epsilon: number; - static readonly Rad2Deg: number; - static readonly Deg2Rad: number; - static readonly PiOver2: number; - static toDegrees(radians: number): number; - static toRadians(degrees: number): number; - static map(value: number, leftMin: number, leftMax: number, rightMin: number, rightMax: number): number; - static lerp(value1: number, value2: number, amount: number): number; - static clamp(value: number, min: number, max: number): number; - static pointOnCirlce(circleCenter: Vector2, radius: number, angleInDegrees: number): Vector2; - static isEven(value: number): boolean; - static clamp01(value: number): number; - static angleBetweenVectors(from: Vector2, to: Vector2): number; - static incrementWithWrap(t: number, length: number): number; - static approach(start: number, end: number, shift: number): number; - } -} -declare module es { - var matrixPool: any[]; - class Matrix2D extends egret.Matrix { - m11: number; - m12: number; - m21: number; - m22: number; - m31: number; - m32: number; - static create(): Matrix2D; - identity(): Matrix2D; - translate(dx: number, dy: number): Matrix2D; - scale(sx: number, sy: number): Matrix2D; - rotate(angle: number): Matrix2D; - invert(): Matrix2D; - add(matrix: Matrix2D): Matrix2D; - substract(matrix: Matrix2D): Matrix2D; - divide(matrix: Matrix2D): Matrix2D; - multiply(matrix: Matrix2D): Matrix2D; - determinant(): number; - release(matrix: Matrix2D): void; - } -} -declare module es { - class Rectangle extends egret.Rectangle { - _tempMat: Matrix2D; - _transformMat: Matrix2D; - readonly max: Vector2; - readonly center: Vector2; - location: Vector2; - size: Vector2; - static fromMinMax(minX: number, minY: number, maxX: number, maxY: number): Rectangle; - static rectEncompassingPoints(points: Vector2[]): Rectangle; - intersects(value: egret.Rectangle): boolean; - rayIntersects(ray: Ray2D, distance: Ref): boolean; - containsRect(value: Rectangle): boolean; - contains(x: number, y: number): boolean; - getHalfSize(): Vector2; - getClosestPointOnRectangleBorderToPoint(point: Vector2, edgeNormal: Vector2): Vector2; - getClosestPointOnBoundsToOrigin(): Vector2; - calculateBounds(parentPosition: Vector2, position: Vector2, origin: Vector2, scale: Vector2, rotation: number, width: number, height: number): void; - } -} -declare module es { - class SubpixelFloat { - remainder: number; - update(amount: number): number; - reset(): void; - } -} -declare module es { - class SubpixelVector2 { - _x: SubpixelFloat; - _y: SubpixelFloat; - update(amount: Vector2): void; - reset(): void; - } -} -declare module es { - class Vector3 { - x: number; - y: number; - z: number; - constructor(x: number, y: number, z: number); - } -} -declare module es { - class ColliderTriggerHelper { - private _entity; - private _activeTriggerIntersections; - private _previousTriggerIntersections; - private _tempTriggerList; - constructor(entity: Entity); - update(): void; - private checkForExitedColliders; - private notifyTriggerListeners; - } -} -declare module es { - enum PointSectors { - center = 0, - top = 1, - bottom = 2, - topLeft = 9, - topRight = 5, - left = 8, - right = 4, - bottomLeft = 10, - bottomRight = 6 - } - class Collisions { - static isLineToLine(a1: Vector2, a2: Vector2, b1: Vector2, b2: Vector2): boolean; - static lineToLineIntersection(a1: Vector2, a2: Vector2, b1: Vector2, b2: Vector2): Vector2; - static closestPointOnLine(lineA: Vector2, lineB: Vector2, closestTo: Vector2): Vector2; - static circleToCircle(circleCenter1: Vector2, circleRadius1: number, circleCenter2: Vector2, circleRadius2: number): boolean; - static circleToLine(circleCenter: Vector2, radius: number, lineFrom: Vector2, lineTo: Vector2): boolean; - static circleToPoint(circleCenter: Vector2, radius: number, point: Vector2): boolean; - static rectToCircle(rect: egret.Rectangle, cPosition: Vector2, cRadius: number): boolean; - static rectToLine(rect: Rectangle, lineFrom: Vector2, lineTo: Vector2): boolean; - static rectToPoint(rX: number, rY: number, rW: number, rH: number, point: Vector2): boolean; - static getSector(rX: number, rY: number, rW: number, rH: number, point: Vector2): PointSectors; - } -} -declare module es { - class RaycastHit { - collider: Collider; - fraction: number; - distance: number; - point: Vector2; - normal: Vector2; - centroid: Vector2; - constructor(collider?: Collider, fraction?: number, distance?: number, point?: Vector2, normal?: Vector2); - setValues(collider: Collider, fraction: number, distance: number, point: Vector2): void; - setValuesNonCollider(fraction: number, distance: number, point: Vector2, normal: Vector2): void; - reset(): void; - toString(): string; - } -} -declare module es { - class Physics { - static spatialHashCellSize: number; - static readonly allLayers: number; - private static _spatialHash; - static raycastsHitTriggers: boolean; - static raycastsStartInColliders: boolean; - static _hitArray: RaycastHit[]; - static reset(): void; - static clear(): void; - static overlapCircleAll(center: Vector2, randius: number, results: any[], layerMask?: number): number; - static boxcastBroadphase(rect: Rectangle, layerMask?: number): Collider[]; - static boxcastBroadphaseExcludingSelf(collider: Collider, rect: Rectangle, layerMask?: number): Collider[]; - static addCollider(collider: Collider): void; - static removeCollider(collider: Collider): void; - static updateCollider(collider: Collider): void; - static linecast(start: Vector2, end: Vector2, layerMask?: number): RaycastHit; - static linecastAll(start: Vector2, end: Vector2, hits: RaycastHit[], layerMask?: number): number; - static debugDraw(secondsToDisplay: any): void; - } -} -declare module es { - class Ray2D { - start: Vector2; - end: Vector2; - direction: Vector2; - constructor(position: Vector2, end: Vector2); - } -} -declare module es { - class SpatialHash { - gridBounds: Rectangle; - _raycastParser: RaycastResultParser; - _cellSize: number; - _inverseCellSize: number; - _overlapTestCircle: Circle; - _cellDict: NumberDictionary; - _tempHashSet: Collider[]; - constructor(cellSize?: number); - register(collider: Collider): void; - remove(collider: Collider): void; - removeWithBruteForce(obj: Collider): void; - clear(): void; - debugDraw(secondsToDisplay: number, textScale?: number): void; - aabbBroadphase(bounds: Rectangle, excludeCollider: Collider, layerMask: number): Collider[]; - linecast(start: Vector2, end: Vector2, hits: RaycastHit[], layerMask: number): number; - overlapCircle(circleCenter: Vector2, radius: number, results: Collider[], layerMask: any): number; - private cellCoords; - private cellAtPosition; - private debugDrawCellDetails; - } - class NumberDictionary { - _store: Map; - add(x: number, y: number, list: Collider[]): void; - remove(obj: Collider): void; - tryGetValue(x: number, y: number): Collider[]; - getKey(x: number, y: number): string; - clear(): void; - } - class RaycastResultParser { - hitCounter: number; - static compareRaycastHits: (a: RaycastHit, b: RaycastHit) => number; - _hits: RaycastHit[]; - _tempHit: RaycastHit; - _checkedColliders: Collider[]; - _cellHits: RaycastHit[]; - _ray: Ray2D; - _layerMask: number; - start(ray: Ray2D, hits: RaycastHit[], layerMask: number): void; - checkRayIntersection(cellX: number, cellY: number, cell: Collider[]): boolean; - reset(): void; - } -} -declare module es { - abstract class Shape { - position: Vector2; - center: Vector2; - bounds: Rectangle; - abstract recalculateBounds(collider: Collider): any; - abstract overlaps(other: Shape): boolean; - abstract collidesWithShape(other: Shape, collisionResult: CollisionResult): boolean; - abstract collidesWithLine(start: Vector2, end: Vector2, hit: RaycastHit): boolean; - abstract containsPoint(point: Vector2): any; - abstract pointCollidesWithShape(point: Vector2, result: CollisionResult): boolean; - } -} -declare module es { - class Polygon extends Shape { - points: Vector2[]; - _areEdgeNormalsDirty: boolean; - _originalPoints: Vector2[]; - _polygonCenter: Vector2; - isBox: boolean; - isUnrotated: boolean; - constructor(points: Vector2[], isBox?: boolean); - _edgeNormals: Vector2[]; - readonly edgeNormals: Vector2[]; - setPoints(points: Vector2[]): void; - recalculateCenterAndEdgeNormals(): void; - buildEdgeNormals(): void; - static buildSymmetricalPolygon(vertCount: number, radius: number): any[]; - static recenterPolygonVerts(points: Vector2[]): void; - static findPolygonCenter(points: Vector2[]): Vector2; - static getFarthestPointInDirection(points: Vector2[], direction: Vector2): Vector2; - static getClosestPointOnPolygonToPoint(points: Vector2[], point: Vector2, distanceSquared: Ref, edgeNormal: Vector2): Vector2; - static rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints: Vector2[]): void; - recalculateBounds(collider: Collider): void; - overlaps(other: Shape): any; - collidesWithShape(other: Shape, result: CollisionResult): boolean; - collidesWithLine(start: es.Vector2, end: es.Vector2, hit: es.RaycastHit): boolean; - containsPoint(point: Vector2): boolean; - pointCollidesWithShape(point: Vector2, result: CollisionResult): boolean; - } -} -declare module es { - class Box extends Polygon { - width: number; - height: number; - constructor(width: number, height: number); - private static buildBox; - updateBox(width: number, height: number): void; - overlaps(other: Shape): any; - collidesWithShape(other: Shape, result: CollisionResult): boolean; - containsPoint(point: Vector2): boolean; - pointCollidesWithShape(point: es.Vector2, result: es.CollisionResult): boolean; - } -} -declare module es { - class Circle extends Shape { - radius: number; - _originalRadius: number; - constructor(radius: number); - recalculateBounds(collider: es.Collider): void; - overlaps(other: Shape): any; - collidesWithShape(other: Shape, result: CollisionResult): boolean; - collidesWithLine(start: es.Vector2, end: es.Vector2, hit: es.RaycastHit): boolean; - containsPoint(point: es.Vector2): boolean; - pointCollidesWithShape(point: Vector2, result: CollisionResult): boolean; - } -} -declare module es { - class CollisionResult { - collider: Collider; - normal: Vector2; - minimumTranslationVector: Vector2; - point: Vector2; - removeHorizontal(deltaMovement: Vector2): void; - invertResult(): this; - toString(): string; - } -} -declare module es { - class RealtimeCollisions { - static intersectMovingCircleBox(s: Circle, b: Box, movement: Vector2, time: Ref): boolean; - } -} -declare module es { - class ShapeCollisions { - static polygonToPolygon(first: Polygon, second: Polygon, result: CollisionResult): boolean; - static intervalDistance(minA: number, maxA: number, minB: number, maxB: any): number; - static getInterval(axis: Vector2, polygon: Polygon, min: number, max: number): { - min: number; - max: number; - }; - static circleToPolygon(circle: Circle, polygon: Polygon, result: CollisionResult): boolean; - static circleToBox(circle: Circle, box: Box, result: CollisionResult): boolean; - static pointToCircle(point: Vector2, circle: Circle, result: CollisionResult): boolean; - static pointToBox(point: Vector2, box: Box, result: CollisionResult): boolean; - static closestPointOnLine(lineA: Vector2, lineB: Vector2, closestTo: Vector2): Vector2; - static pointToPoly(point: Vector2, poly: Polygon, result: CollisionResult): boolean; - static circleToCircle(first: Circle, second: Circle, result: CollisionResult): boolean; - static boxToBox(first: Box, second: Box, result: CollisionResult): boolean; - private static minkowskiDifference; - static lineToPoly(start: Vector2, end: Vector2, polygon: Polygon, hit: RaycastHit): boolean; - static lineToLine(a1: Vector2, a2: Vector2, b1: Vector2, b2: Vector2, intersection: Vector2): boolean; - static lineToCircle(start: Vector2, end: Vector2, s: Circle, hit: RaycastHit): boolean; - static boxToBoxCast(first: Box, second: Box, movement: Vector2, hit: RaycastHit): boolean; - } -} -declare module es { - class Particle { - position: Vector2; - lastPosition: Vector2; - mass: number; - radius: number; - collidesWithColliders: boolean; - isPinned: boolean; - acceleration: Vector2; - pinnedPosition: Vector2; - applyForce(force: Vector2): void; - } -} -declare module es { - class VerletWorld { - gravity: Vector2; - constraintIterations: number; - maximumStepIterations: number; - simulationBounds?: Rectangle; - allowDragging: boolean; - _composites: Composite[]; - static _colliders: Collider[]; - _tempCircle: Circle; - _leftOverTime: number; - _fixedDeltaTime: number; - _iterationSteps: number; - _fixedDeltaTimeSq: number; - constructor(simulationBounds?: Rectangle); - update(): void; - handleCollisions(p: Particle, collidesWithLayers: number): void; - constrainParticleToBounds(p: Particle): void; - updateTiming(): void; - addComposite(composite: T): T; - removeComposite(composite: Composite): void; - handleDragging(): void; - debugRender(camera: Camera): void; - } -} -declare module es { - class Composite { - friction: Vector2; - collidesWithLayers: number; - particles: Particle[]; - _constraints: Constraint[]; - solveConstraints(): void; - updateParticles(deltaTimeSquared: number, gravity: Vector2): void; - handleConstraintCollisions(): void; - debugRender(camera: Camera): void; - } -} -declare module es { - abstract class Constraint { - collidesWithColliders: boolean; - abstract solve(): any; - handleCollisions(collidesWithLayers: number): void; - } -} -declare class ArrayUtils { - static bubbleSort(ary: number[]): void; - static insertionSort(ary: number[]): void; - static binarySearch(ary: number[], value: number): number; - static findElementIndex(ary: any[], num: any): any; - static getMaxElementIndex(ary: number[]): number; - static getMinElementIndex(ary: number[]): number; - static getUniqueAry(ary: number[]): number[]; - static getDifferAry(aryA: number[], aryB: number[]): number[]; - static swap(array: any[], index1: number, index2: number): void; - static clearList(ary: any[]): void; - static cloneList(ary: any[]): any[]; - static equals(ary1: number[], ary2: number[]): Boolean; - static insert(ary: any[], index: number, value: any): any; -} -declare module es { - class Base64Utils { - private static _keyStr; - static readonly nativeBase64: boolean; - static decode(input: string): string; - static encode(input: string): string; - static decodeBase64AsArray(input: string, bytes: number): Uint32Array; - static decompress(data: string, decoded: any, compression: string): any; - static decodeCSV(input: string): Array; - } -} -declare module es { - class Color { - private _packedValue; - constructor(r: number, g: number, b: number, alpha: number); - b: number; - g: number; - r: number; - a: number; - packedValue: number; - equals(other: Color): boolean; - } -} -declare module es { - class ContentManager { - protected loadedAssets: Map; - loadRes(name: string, local?: boolean): Promise; - dispose(): void; - } -} -declare module es { - class DrawUtils { - static getColorMatrix(color: number): egret.ColorMatrixFilter; - } -} -declare module es { - class EdgeExt { - static oppositeEdge(self: Edge): Edge; - static isHorizontal(self: Edge): boolean; - static isVertical(self: Edge): boolean; - } -} -declare module es { - class FuncPack { - func: Function; - context: any; - constructor(func: Function, context: any); - } - class Emitter { - private _messageTable; - constructor(); - addObserver(eventType: T, handler: Function, context: any): void; - removeObserver(eventType: T, handler: Function): void; - emit(eventType: T, data?: any): void; - } -} -declare module es { - enum Edge { - top = 0, - bottom = 1, - left = 2, - right = 3 - } -} -declare module es { - class Enumerable { - static repeat(element: T, count: number): any[]; - } -} -declare module es { - class EqualityComparer implements IEqualityComparer { - static default(): EqualityComparer; - protected constructor(); - equals(x: T, y: T): boolean; - } -} -declare module es { - class GlobalManager { - _enabled: boolean; - enabled: boolean; - setEnabled(isEnabled: boolean): void; - onEnabled(): void; - onDisabled(): void; - update(): void; - } -} -declare module es { - interface IComparer { - compare(x: T, y: T): number; - } -} -declare module es { - interface IEqualityComparer { - equals(x: any, y: any): boolean; - } -} -declare module es { - interface IEquatable { - equals(other: T): boolean; - } -} -declare module es { - class ListPool { - private static readonly _objectQueue; - static warmCache(cacheCount: number): void; - static trimCache(cacheCount: any): void; - static clearCache(): void; - static obtain(): T[]; - static free(obj: Array): void; - } -} -declare module es { - class NumberExtension { - static toNumber(value: any): number; - } -} -declare module es { - class Pair implements IEquatable> { - first: T; - second: T; - constructor(first: T, second: T); - clear(): void; - equals(other: Pair): boolean; - } -} -declare module es { - class Pool { - private static _objectQueue; - static warmCache(type: any, cacheCount: number): void; - static trimCache(cacheCount: number): void; - static clearCache(): void; - static obtain(type: any): T; - static free(obj: T): void; - } - interface IPoolable { - reset(): any; - } -} -declare class RandomUtils { - static randrange(start: number, stop: number, step?: number): number; - static randint(a: number, b: number): number; - static randnum(a: number, b: number): number; - static shuffle(array: any[]): any[]; - static choice(sequence: any): any; - static sample(sequence: any[], num: number): any[]; - static random(): number; - static boolean(chance?: number): boolean; - private static _randomCompare; -} -declare module es { - class RectangleExt { - static getSide(rect: Rectangle, edge: Edge): number; - static union(first: Rectangle, point: Vector2): Rectangle; - static getHalfRect(rect: Rectangle, edge: Edge): Rectangle; - static getRectEdgePortion(rect: Rectangle, edge: Edge, size?: number): Rectangle; - static expandSide(rect: Rectangle, edge: Edge, amount: number): void; - static contract(rect: Rectangle, horizontalAmount: any, verticalAmount: any): void; - } -} -declare module es { - class Ref { - value: T; - constructor(value: T); - } -} -declare module es { - class SubpixelNumber { - remainder: number; - update(amount: number): number; - reset(): void; - } -} -declare module es { - class Triangulator { - triangleIndices: number[]; - private _triPrev; - private _triNext; - static testPointTriangle(point: Vector2, a: Vector2, b: Vector2, c: Vector2): boolean; - triangulate(points: Vector2[], arePointsCCW?: boolean): void; - private initialize; - } -} -declare module es { - class Vector2Ext { - static isTriangleCCW(a: Vector2, center: Vector2, c: Vector2): boolean; - static halfVector(): Vector2; - static cross(u: Vector2, v: Vector2): number; - static perpendicular(first: Vector2, second: Vector2): Vector2; - static normalize(vec: Vector2): void; - static transformA(sourceArray: Vector2[], sourceIndex: number, matrix: Matrix2D, destinationArray: Vector2[], destinationIndex: number, length: number): void; - static transformR(position: Vector2, matrix: Matrix2D, result: Vector2): void; - static transform(sourceArray: Vector2[], matrix: Matrix2D, destinationArray: Vector2[]): void; - static round(vec: Vector2): Vector2; - } -} -declare class WebGLUtils { - static getContext(): CanvasRenderingContext2D; -} -declare module es { - class Layout { - clientArea: Rectangle; - safeArea: Rectangle; - constructor(); - place(size: Vector2, horizontalMargin: number, verticalMargine: number, alignment: Alignment): Rectangle; - } - enum Alignment { - none = 0, - left = 1, - right = 2, - horizontalCenter = 4, - top = 8, - bottom = 16, - verticalCenter = 32, - topLeft = 9, - topRight = 10, - topCenter = 12, - bottomLeft = 17, - bottomRight = 18, - bottomCenter = 20, - centerLeft = 33, - centerRight = 34, - center = 36 - } -} -declare namespace stopwatch { - class Stopwatch { - private readonly getSystemTime; - private _startSystemTime; - private _stopSystemTime; - private _stopDuration; - private _pendingSliceStartStopwatchTime; - private _completeSlices; - constructor(getSystemTime?: GetTimeFunc); - getState(): State; - isIdle(): boolean; - isRunning(): boolean; - isStopped(): boolean; - slice(): Slice; - getCompletedSlices(): Slice[]; - getCompletedAndPendingSlices(): Slice[]; - getPendingSlice(): Slice; - getTime(): number; - reset(): void; - start(forceReset?: boolean): void; - stop(recordPendingSlice?: boolean): number; - private calculatePendingSlice; - private caculateStopwatchTime; - private getSystemTimeOfCurrentStopwatchTime; - private recordPendingSlice; - } - type GetTimeFunc = () => number; - enum State { - IDLE = "IDLE", - RUNNING = "RUNNING", - STOPPED = "STOPPED" - } - function setDefaultSystemTimeGetter(systemTimeGetter?: GetTimeFunc): void; - interface Slice { - readonly startTime: number; - readonly endTime: number; - readonly duration: number; - } -} -declare module es { - class TimeRuler { - static readonly maxBars: number; - static readonly maxSamples: number; - static readonly maxNestCall: number; - static readonly barHeight: number; - static readonly maxSampleFrames: number; - static readonly logSnapDuration: number; - static readonly barPadding: number; - static readonly autoAdjustDelay: number; - private static _instance; - targetSampleFrames: number; - width: number; - enabled: true; - showLog: boolean; - logs: FrameLog[]; - private sampleFrames; - private _position; - private prevLog; - private curLog; - private frameCount; - private markers; - private stopwacth; - private _markerNameToIdMap; - private _updateCount; - private _frameAdjust; - private _rectShape1; - private _rectShape2; - private _rectShape3; - private _rectShape4; - private _rectShape5; - private _rectShape6; - constructor(); - static readonly Instance: TimeRuler; - startFrame(): void; - beginMark(markerName: string, color: number, barIndex?: number): void; - endMark(markerName: string, barIndex?: number): void; - getAverageTime(barIndex: number, markerName: string): number; - resetLog(): void; - render(position?: Vector2, width?: number): void; - private onGraphicsDeviceReset; - } - class FrameLog { - bars: MarkerCollection[]; - constructor(); - } - class MarkerCollection { - markers: Marker[]; - markCount: number; - markerNests: number[]; - nestCount: number; - constructor(); - } - class Marker { - markerId: number; - beginTime: number; - endTime: number; - color: number; - } - class MarkerInfo { - name: string; - logs: MarkerLog[]; - constructor(name: any); - } - class MarkerLog { - snapMin: number; - snapMax: number; - snapAvg: number; - min: number; - max: number; - avg: number; - samples: number; - color: number; - initialized: boolean; - } -} -declare module es { - interface ICoroutine { - stop(): any; - setUseUnscaledDeltaTime(useUnscaledDeltaTime: any): ICoroutine; - } - class Coroutine { - static waitForSeconds(seconds: number): WaitForSeconds; - } - class WaitForSeconds { - static waiter: WaitForSeconds; - waitTime: number; - wait(seconds: number): WaitForSeconds; - } -} -declare module es { - class CoroutineImpl implements ICoroutine, IPoolable { - enumerator: Iterator; - waitTimer: number; - isDone: boolean; - waitForCoroutine: CoroutineImpl; - useUnscaledDeltaTime: boolean; - stop(): void; - setUseUnscaledDeltaTime(useUnscaledDeltaTime: any): es.ICoroutine; - prepareForuse(): void; - reset(): void; - } - class CoroutineManager extends GlobalManager { - _isInUpdate: boolean; - _unblockedCoroutines: CoroutineImpl[]; - _shouldRunNextFrame: CoroutineImpl[]; - startCoroutine(enumerator: Iterator): CoroutineImpl; - update(): void; - tickCoroutine(coroutine: CoroutineImpl): boolean; - } -} -declare module es { - class TouchState { - x: number; - y: number; - touchPoint: number; - touchDown: boolean; - readonly position: Vector2; - reset(): void; - } - class Input { - private static _init; - private static _previousTouchState; - private static _resolutionOffset; - private static _touchIndex; - private static _gameTouchs; - static readonly gameTouchs: TouchState[]; - private static _resolutionScale; - static readonly resolutionScale: Vector2; - private static _totalTouchCount; - static readonly totalTouchCount: number; - static readonly touchPosition: Vector2; - static _virtualInputs: VirtualInput[]; - static maxSupportedTouch: number; - static readonly touchPositionDelta: Vector2; - static initialize(): void; - static update(): void; - static scaledPosition(position: Vector2): Vector2; - static isKeyPressed(key: Keys): boolean; - static isKeyPressedBoth(keyA: Keys, keyB: Keys): boolean; - static isKeyDown(key: Keys): boolean; - static isKeyDownBoth(keyA: Keys, keyB: Keys): boolean; - static isKeyReleased(key: Keys): boolean; - static isKeyReleasedBoth(keyA: Keys, keyB: Keys): boolean; - private static initTouchCache; - private static touchBegin; - private static touchMove; - private static touchEnd; - private static setpreviousTouchState; - } -} -import Keys = es.Keys; -declare class KeyboardUtils { - static currentKeys: Keys[]; - static previousKeys: Keys[]; - private static keyStatusKeys; - static init(): void; - static update(): void; - static destroy(): void; - private static onKeyDownHandler; - private static onKeyUpHandler; -} -declare module es { - enum Keys { - none = 0, - back = 8, - tab = 9, - enter = 13, - capsLock = 20, - escape = 27, - space = 32, - pageUp = 33, - pageDown = 34, - end = 35, - home = 36, - left = 37, - up = 38, - right = 39, - down = 40, - select = 41, - print = 42, - execute = 43, - printScreen = 44, - insert = 45, - delete = 46, - help = 47, - d0 = 48, - d1 = 49, - d2 = 50, - d3 = 51, - d4 = 52, - d5 = 53, - d6 = 54, - d7 = 55, - d8 = 56, - d9 = 57, - a = 65, - b = 66, - c = 67, - d = 68, - e = 69, - f = 70, - g = 71, - h = 72, - i = 73, - j = 74, - k = 75, - l = 76, - m = 77, - n = 78, - o = 79, - p = 80, - q = 81, - r = 82, - s = 83, - t = 84, - u = 85, - v = 86, - w = 87, - x = 88, - y = 89, - z = 90, - leftWindows = 91, - rightWindows = 92, - apps = 93, - sleep = 95, - numPad0 = 96, - numPad1 = 97, - numPad2 = 98, - numPad3 = 99, - numPad4 = 100, - numPad5 = 101, - numPad6 = 102, - numPad7 = 103, - numPad8 = 104, - numPad9 = 105, - multiply = 106, - add = 107, - seperator = 108, - subtract = 109, - decimal = 110, - divide = 111, - f1 = 112, - f2 = 113, - f3 = 114, - f4 = 115, - f5 = 116, - f6 = 117, - f7 = 118, - f8 = 119, - f9 = 120, - f10 = 121, - f11 = 122, - f12 = 123, - f13 = 124, - f14 = 125, - f15 = 126, - f16 = 127, - f17 = 128, - f18 = 129, - f19 = 130, - f20 = 131, - f21 = 132, - f22 = 133, - f23 = 134, - f24 = 135, - numLock = 144, - scroll = 145, - leftShift = 160, - rightShift = 161, - leftControl = 162, - rightControl = 163, - leftAlt = 164, - rightAlt = 165, - browserBack = 166, - browserForward = 167 - } -} -declare module es { - enum OverlapBehavior { - cancelOut = 0, - takeOlder = 1, - takeNewer = 2 - } - abstract class VirtualInput { - protected constructor(); - deregister(): void; - abstract update(): any; - } - abstract class VirtualInputNode { - update(): void; - } -} -declare module es { - class VirtualIntegerAxis extends VirtualInput { - nodes: VirtualAxisNode[]; - readonly value: number; - constructor(...nodes: VirtualAxisNode[]); - update(): void; - addKeyboardKeys(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys): this; - } - abstract class VirtualAxisNode extends VirtualInputNode { - abstract value: number; - } -} -declare module es { - class VirtualAxis extends VirtualInput { - nodes: VirtualAxisNode[]; - readonly value: number; - constructor(...nodes: VirtualAxisNode[]); - update(): void; - } - class KeyboardKeys extends VirtualAxisNode { - overlapBehavior: OverlapBehavior; - positive: Keys; - negative: Keys; - _value: number; - _turned: boolean; - constructor(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys); - update(): void; - readonly value: number; - } -} -declare module es { - class VirtualButton extends VirtualInput { - nodes: Node[]; - bufferTime: number; - firstRepeatTime: number; - mutiRepeatTime: number; - isRepeating: boolean; - _bufferCounter: number; - _repeatCounter: number; - _willRepeat: boolean; - constructor(bufferTime?: number, ...nodes: Node[]); - setRepeat(firstRepeatTime: number, mutiRepeatTime?: number): void; - update(): void; - readonly isDown: boolean; - readonly isPressed: boolean; - readonly isReleased: boolean; - consumeBuffer(): void; - addKeyboardKey(key: Keys): VirtualButton; - } - abstract class Node extends VirtualInputNode { - abstract isDown: boolean; - abstract isPressed: boolean; - abstract isReleased: boolean; - } - class KeyboardKey extends Node { - key: Keys; - constructor(key: Keys); - readonly isDown: boolean; - readonly isPressed: boolean; - readonly isReleased: boolean; - } -} -declare module es { - class AssetPacker { - protected itemsToRaster: TextureToPack[]; - onProcessCompleted: Function; - useCache: boolean; - cacheName: string; - protected _sprites: Map; - protected allow4096Textures: boolean; - addTextureToPack(texture: egret.Texture, customID: string): void; - process(allow4096Textures?: boolean): Promise; - protected loadPack(): Promise; - protected createPack(): void; - dispose(): void; - getTexture(id: string): egret.Texture; - } -} -declare module es { - class IntegerRectangle extends Rectangle { - id: number; - } -} -declare module es { - class RectanglePacker { - private _width; - private _height; - private _padding; - private _packedWidth; - private _packedHeight; - private _insertList; - private _insertedRectangles; - private _freeAreas; - private _newFreeAreas; - private _outsideRectangle; - private _sortableSizeStack; - private _rectangleStack; - readonly rectangleCount: number; - readonly packedWidth: number; - readonly packedHeight: number; - readonly padding: number; - constructor(width: number, height: number, padding?: number); - reset(width: number, height: number, padding?: number): void; - insertRectangle(width: number, height: number, id: number): void; - packRectangles(sort?: boolean): number; - getRectangle(index: number, rectangle: IntegerRectangle): IntegerRectangle; - getRectangleId(index: number): number; - private generateNewFreeAreas; - private filterSelfSubAreas; - private generateDividedAreas; - private getFreeAreaIndex; - private allocateSize; - private freeSize; - private allocateRectangle; - private freeRectangle; - } -} -declare module es { - class SortableSize { - width: number; - height: number; - id: number; - constructor(width: number, height: number, id: number); - } -} -declare module es { - class TextureAssets { - assets: TextureAsset[]; - constructor(assets: TextureAsset[]); - } - class TextureAsset { - x: number; - y: number; - width: number; - height: number; - name: string; - } -} -declare module es { - class TextureToPack { - texture: egret.Texture; - id: string; - constructor(texture: egret.Texture, id: string); - } -} -declare module es { - interface ITimer { - context: any; - stop(): any; - reset(): any; - getContext(): T; - } -} -declare module es { - class Timer implements ITimer { - context: any; - _timeInSeconds: number; - _repeats: boolean; - _onTime: (timer: ITimer) => void; - _isDone: boolean; - _elapsedTime: number; - getContext(): T; - reset(): void; - stop(): void; - tick(): boolean; - initialize(timeInsSeconds: number, repeats: boolean, context: any, onTime: (timer: ITimer) => void): void; - unload(): void; - } -} -declare module es { - class TimerManager extends GlobalManager { - _timers: Timer[]; - update(): void; - schedule(timeInSeconds: number, repeats: boolean, context: any, onTime: (timer: ITimer) => void): Timer; - } -} diff --git a/demo/libs/framework/framework.js b/demo/libs/framework/framework.js deleted file mode 100644 index ef66adfa..00000000 --- a/demo/libs/framework/framework.js +++ /dev/null @@ -1,11788 +0,0 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -Array.prototype.findIndex = function (predicate) { - function findIndex(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { - if (predicate.call(arguments[2], array[i], i, array)) { - return i; - } - } - return -1; - } - return findIndex(this, predicate); -}; -Array.prototype.any = function (predicate) { - function any(array, predicate) { - return array.findIndex(predicate) > -1; - } - return any(this, predicate); -}; -Array.prototype.firstOrDefault = function (predicate) { - function firstOrDefault(array, predicate) { - var index = array.findIndex(predicate); - return index == -1 ? null : array[index]; - } - return firstOrDefault(this, predicate); -}; -Array.prototype.find = function (predicate) { - function find(array, predicate) { - return array.firstOrDefault(predicate); - } - return find(this, predicate); -}; -Array.prototype.where = function (predicate) { - function where(array, predicate) { - if (typeof (array.reduce) === "function") { - return array.reduce(function (ret, element, index) { - if (predicate.call(arguments[2], element, index, array)) { - ret.push(element); - } - return ret; - }, []); - } - else { - var ret = []; - for (var i = 0, len = array.length; i < len; i++) { - var element = array[i]; - if (predicate.call(arguments[2], element, i, array)) { - ret.push(element); - } - } - return ret; - } - } - return where(this, predicate); -}; -Array.prototype.count = function (predicate) { - function count(array, predicate) { - return array.where(predicate).length; - } - return count(this, predicate); -}; -Array.prototype.findAll = function (predicate) { - function findAll(array, predicate) { - return array.where(predicate); - } - return findAll(this, predicate); -}; -Array.prototype.contains = function (value) { - function contains(array, value) { - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] instanceof egret.HashObject && value instanceof egret.HashObject) { - if (array[i].hashCode == value.hashCode) - return true; - } - if (array[i] == value) { - return true; - } - } - return false; - } - return contains(this, value); -}; -Array.prototype.removeAll = function (predicate) { - function removeAll(array, predicate) { - var index; - do { - index = array.findIndex(predicate); - if (index >= 0) { - array.splice(index, 1); - } - } while (index >= 0); - } - removeAll(this, predicate); -}; -Array.prototype.remove = function (element) { - function remove(array, element) { - var index = array.findIndex(function (x) { - return x === element; - }); - if (index >= 0) { - array.splice(index, 1); - return true; - } - else { - return false; - } - } - return remove(this, element); -}; -Array.prototype.removeAt = function (index) { - function removeAt(array, index) { - array.splice(index, 1); - } - return removeAt(this, index); -}; -Array.prototype.removeRange = function (index, count) { - function removeRange(array, index, count) { - array.splice(index, count); - } - return removeRange(this, index, count); -}; -Array.prototype.select = function (selector) { - function select(array, selector) { - if (typeof (array.reduce) === "function") { - return array.reduce(function (ret, element, index) { - ret.push(selector.call(arguments[2], element, index, array)); - return ret; - }, []); - } - else { - var ret = []; - for (var i = 0, len = array.length; i < len; i++) { - ret.push(selector.call(arguments[2], array[i], i, array)); - } - return ret; - } - } - return select(this, selector); -}; -Array.prototype.orderBy = function (keySelector, comparer) { - function orderBy(array, keySelector, comparer) { - array.sort(function (x, y) { - var v1 = keySelector(x); - var v2 = keySelector(y); - if (comparer) { - return comparer(v1, v2); - } - else { - return (v1 > v2) ? 1 : -1; - } - }); - return array; - } - return orderBy(this, keySelector, comparer); -}; -Array.prototype.orderByDescending = function (keySelector, comparer) { - function orderByDescending(array, keySelector, comparer) { - array.sort(function (x, y) { - var v1 = keySelector(x); - var v2 = keySelector(y); - if (comparer) { - return -comparer(v1, v2); - } - else { - return (v1 < v2) ? 1 : -1; - } - }); - return array; - } - return orderByDescending(this, keySelector, comparer); -}; -Array.prototype.groupBy = function (keySelector) { - function groupBy(array, keySelector) { - if (typeof (array.reduce) === "function") { - var keys_1 = []; - return array.reduce(function (groups, element, index) { - var key = JSON.stringify(keySelector.call(arguments[1], element, index, array)); - var index2 = keys_1.findIndex(function (x) { - return x === key; - }); - if (index2 < 0) { - index2 = keys_1.push(key) - 1; - } - if (!groups[index2]) { - groups[index2] = []; - } - groups[index2].push(element); - return groups; - }, []); - } - else { - var groups = []; - var keys = []; - var _loop_1 = function (i, len) { - var key = JSON.stringify(keySelector.call(arguments_1[1], array[i], i, array)); - var index = keys.findIndex(function (x) { - return x === key; - }); - if (index < 0) { - index = keys.push(key) - 1; - } - if (!groups[index]) { - groups[index] = []; - } - groups[index].push(array[i]); - }; - var arguments_1 = arguments; - for (var i = 0, len = array.length; i < len; i++) { - _loop_1(i, len); - } - return groups; - } - } - return groupBy(this, keySelector); -}; -Array.prototype.sum = function (selector) { - function sum(array, selector) { - var ret; - for (var i = 0, len = array.length; i < len; i++) { - if (i == 0) { - if (selector) { - ret = selector.call(arguments[2], array[i], i, array); - } - else { - ret = array[i]; - } - } - else { - if (selector) { - ret += selector.call(arguments[2], array[i], i, array); - } - else { - ret += array[i]; - } - } - } - return ret; - } - return sum(this, selector); -}; -var es; -(function (es) { - var PriorityQueueNode = (function () { - function PriorityQueueNode() { - this.priority = 0; - this.insertionIndex = 0; - this.queueIndex = 0; - } - return PriorityQueueNode; - }()); - es.PriorityQueueNode = PriorityQueueNode; -})(es || (es = {})); -var es; -(function (es) { - var AStarPathfinder = (function () { - function AStarPathfinder() { - } - AStarPathfinder.search = function (graph, start, goal) { - var _this = this; - var foundPath = false; - var cameFrom = new Map(); - cameFrom.set(start, start); - var costSoFar = new Map(); - var frontier = new es.PriorityQueue(1000); - frontier.enqueue(new AStarNode(start), 0); - costSoFar.set(start, 0); - var _loop_2 = function () { - var current = frontier.dequeue(); - if (current.data instanceof es.Vector2 && goal instanceof es.Vector2 && current.data.equals(goal)) { - foundPath = true; - return "break"; - } - else if (current.data == goal) { - foundPath = true; - return "break"; - } - graph.getNeighbors(current.data).forEach(function (next) { - var newCost = costSoFar.get(current.data) + graph.cost(current.data, next); - if (!_this.hasKey(costSoFar, next) || newCost < costSoFar.get(next)) { - costSoFar.set(next, newCost); - var priority = newCost + graph.heuristic(next, goal); - frontier.enqueue(new AStarNode(next), priority); - cameFrom.set(next, current.data); - } - }); - }; - while (frontier.count > 0) { - var state_1 = _loop_2(); - if (state_1 === "break") - break; - } - return foundPath ? this.recontructPath(cameFrom, start, goal) : null; - }; - AStarPathfinder.recontructPath = function (cameFrom, start, goal) { - var path = []; - var current = goal; - path.push(goal); - while (current != start) { - current = this.getKey(cameFrom, current); - path.push(current); - } - path.reverse(); - return path; - }; - AStarPathfinder.hasKey = function (map, compareKey) { - var iterator = map.keys(); - var r; - while (r = iterator.next(), !r.done) { - if (r.value instanceof es.Vector2 && compareKey instanceof es.Vector2 && r.value.equals(compareKey)) - return true; - else if (r.value == compareKey) - return true; - } - return false; - }; - AStarPathfinder.getKey = function (map, compareKey) { - var iterator = map.keys(); - var valueIterator = map.values(); - var r; - var v; - while (r = iterator.next(), v = valueIterator.next(), !r.done) { - if (r.value instanceof es.Vector2 && compareKey instanceof es.Vector2 && r.value.equals(compareKey)) - return v.value; - else if (r.value == compareKey) - return v.value; - } - return null; - }; - return AStarPathfinder; - }()); - es.AStarPathfinder = AStarPathfinder; - var AStarNode = (function (_super) { - __extends(AStarNode, _super); - function AStarNode(data) { - var _this = _super.call(this) || this; - _this.data = data; - return _this; - } - return AStarNode; - }(es.PriorityQueueNode)); -})(es || (es = {})); -var es; -(function (es) { - var AstarGridGraph = (function () { - function AstarGridGraph(width, height) { - this.dirs = [ - new es.Vector2(1, 0), - new es.Vector2(0, -1), - new es.Vector2(-1, 0), - new es.Vector2(0, 1) - ]; - this.walls = []; - this.weightedNodes = []; - this.defaultWeight = 1; - this.weightedNodeWeight = 5; - this._neighbors = new Array(4); - this._width = width; - this._height = height; - } - AstarGridGraph.prototype.isNodeInBounds = function (node) { - return 0 <= node.x && node.x < this._width && 0 <= node.y && node.y < this._height; - }; - AstarGridGraph.prototype.isNodePassable = function (node) { - return !this.walls.firstOrDefault(function (wall) { return wall.equals(node); }); - }; - AstarGridGraph.prototype.search = function (start, goal) { - return es.AStarPathfinder.search(this, start, goal); - }; - AstarGridGraph.prototype.getNeighbors = function (node) { - var _this = this; - this._neighbors.length = 0; - this.dirs.forEach(function (dir) { - var next = new es.Vector2(node.x + dir.x, node.y + dir.y); - if (_this.isNodeInBounds(next) && _this.isNodePassable(next)) - _this._neighbors.push(next); - }); - return this._neighbors; - }; - AstarGridGraph.prototype.cost = function (from, to) { - return this.weightedNodes.find(function (p) { return p.equals(to); }) ? this.weightedNodeWeight : this.defaultWeight; - }; - AstarGridGraph.prototype.heuristic = function (node, goal) { - return Math.abs(node.x - goal.x) + Math.abs(node.y - goal.y); - }; - return AstarGridGraph; - }()); - es.AstarGridGraph = AstarGridGraph; -})(es || (es = {})); -var es; -(function (es) { - var PriorityQueue = (function () { - function PriorityQueue(maxNodes) { - this._numNodes = 0; - this._nodes = new Array(maxNodes + 1); - this._numNodesEverEnqueued = 0; - } - Object.defineProperty(PriorityQueue.prototype, "count", { - get: function () { - return this._numNodes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(PriorityQueue.prototype, "maxSize", { - get: function () { - return this._nodes.length - 1; - }, - enumerable: true, - configurable: true - }); - PriorityQueue.prototype.clear = function () { - this._nodes.splice(1, this._numNodes); - this._numNodes = 0; - }; - PriorityQueue.prototype.contains = function (node) { - if (!node) { - console.error("node cannot be null"); - return false; - } - if (node.queueIndex < 0 || node.queueIndex >= this._nodes.length) { - console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?"); - return false; - } - return (this._nodes[node.queueIndex] == node); - }; - PriorityQueue.prototype.enqueue = function (node, priority) { - node.priority = priority; - this._numNodes++; - this._nodes[this._numNodes] = node; - node.queueIndex = this._numNodes; - node.insertionIndex = this._numNodesEverEnqueued++; - this.cascadeUp(this._nodes[this._numNodes]); - }; - PriorityQueue.prototype.dequeue = function () { - var returnMe = this._nodes[1]; - this.remove(returnMe); - return returnMe; - }; - PriorityQueue.prototype.remove = function (node) { - if (node.queueIndex == this._numNodes) { - this._nodes[this._numNodes] = null; - this._numNodes--; - return; - } - var formerLastNode = this._nodes[this._numNodes]; - this.swap(node, formerLastNode); - delete this._nodes[this._numNodes]; - this._numNodes--; - this.onNodeUpdated(formerLastNode); - }; - PriorityQueue.prototype.isValidQueue = function () { - for (var i = 1; i < this._nodes.length; i++) { - if (this._nodes[i]) { - var childLeftIndex = 2 * i; - if (childLeftIndex < this._nodes.length && this._nodes[childLeftIndex] && - this.hasHigherPriority(this._nodes[childLeftIndex], this._nodes[i])) - return false; - var childRightIndex = childLeftIndex + 1; - if (childRightIndex < this._nodes.length && this._nodes[childRightIndex] && - this.hasHigherPriority(this._nodes[childRightIndex], this._nodes[i])) - return false; - } - } - return true; - }; - PriorityQueue.prototype.onNodeUpdated = function (node) { - var parentIndex = Math.floor(node.queueIndex / 2); - var parentNode = this._nodes[parentIndex]; - if (parentIndex > 0 && this.hasHigherPriority(node, parentNode)) { - this.cascadeUp(node); - } - else { - this.cascadeDown(node); - } - }; - PriorityQueue.prototype.cascadeDown = function (node) { - var newParent; - var finalQueueIndex = node.queueIndex; - while (true) { - newParent = node; - var childLeftIndex = 2 * finalQueueIndex; - if (childLeftIndex > this._numNodes) { - node.queueIndex = finalQueueIndex; - this._nodes[finalQueueIndex] = node; - break; - } - var childLeft = this._nodes[childLeftIndex]; - if (this.hasHigherPriority(childLeft, newParent)) { - newParent = childLeft; - } - var childRightIndex = childLeftIndex + 1; - if (childRightIndex <= this._numNodes) { - var childRight = this._nodes[childRightIndex]; - if (this.hasHigherPriority(childRight, newParent)) { - newParent = childRight; - } - } - if (newParent != node) { - this._nodes[finalQueueIndex] = newParent; - var temp = newParent.queueIndex; - newParent.queueIndex = finalQueueIndex; - finalQueueIndex = temp; - } - else { - node.queueIndex = finalQueueIndex; - this._nodes[finalQueueIndex] = node; - break; - } - } - }; - PriorityQueue.prototype.cascadeUp = function (node) { - var parent = Math.floor(node.queueIndex / 2); - while (parent >= 1) { - var parentNode = this._nodes[parent]; - if (this.hasHigherPriority(parentNode, node)) - break; - this.swap(node, parentNode); - parent = Math.floor(node.queueIndex / 2); - } - }; - PriorityQueue.prototype.swap = function (node1, node2) { - this._nodes[node1.queueIndex] = node2; - this._nodes[node2.queueIndex] = node1; - var temp = node1.queueIndex; - node1.queueIndex = node2.queueIndex; - node2.queueIndex = temp; - }; - PriorityQueue.prototype.hasHigherPriority = function (higher, lower) { - return (higher.priority < lower.priority || - (higher.priority == lower.priority && higher.insertionIndex < lower.insertionIndex)); - }; - return PriorityQueue; - }()); - es.PriorityQueue = PriorityQueue; -})(es || (es = {})); -var es; -(function (es) { - var BreadthFirstPathfinder = (function () { - function BreadthFirstPathfinder() { - } - BreadthFirstPathfinder.search = function (graph, start, goal) { - var _this = this; - var foundPath = false; - var frontier = []; - frontier.unshift(start); - var cameFrom = new Map(); - cameFrom.set(start, start); - var _loop_3 = function () { - var current = frontier.shift(); - if (JSON.stringify(current) == JSON.stringify(goal)) { - foundPath = true; - return "break"; - } - graph.getNeighbors(current).forEach(function (next) { - if (!_this.hasKey(cameFrom, next)) { - frontier.unshift(next); - cameFrom.set(next, current); - } - }); - }; - while (frontier.length > 0) { - var state_2 = _loop_3(); - if (state_2 === "break") - break; - } - return foundPath ? es.AStarPathfinder.recontructPath(cameFrom, start, goal) : null; - }; - BreadthFirstPathfinder.hasKey = function (map, compareKey) { - var iterator = map.keys(); - var r; - while (r = iterator.next(), !r.done) { - if (JSON.stringify(r.value) == JSON.stringify(compareKey)) - return true; - } - return false; - }; - return BreadthFirstPathfinder; - }()); - es.BreadthFirstPathfinder = BreadthFirstPathfinder; -})(es || (es = {})); -var es; -(function (es) { - var UnweightedGraph = (function () { - function UnweightedGraph() { - this.edges = new Map(); - } - UnweightedGraph.prototype.addEdgesForNode = function (node, edges) { - this.edges.set(node, edges); - return this; - }; - UnweightedGraph.prototype.getNeighbors = function (node) { - return this.edges.get(node); - }; - return UnweightedGraph; - }()); - es.UnweightedGraph = UnweightedGraph; -})(es || (es = {})); -var es; -(function (es) { - var Vector2 = (function () { - function Vector2(x, y) { - this.x = 0; - this.y = 0; - this.x = x ? x : 0; - this.y = y != undefined ? y : this.x; - } - Object.defineProperty(Vector2, "zero", { - get: function () { - return new Vector2(0, 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Vector2, "one", { - get: function () { - return new Vector2(1, 1); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Vector2, "unitX", { - get: function () { - return new Vector2(1, 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Vector2, "unitY", { - get: function () { - return new Vector2(0, 1); - }, - enumerable: true, - configurable: true - }); - Vector2.add = function (value1, value2) { - var result = new Vector2(0, 0); - result.x = value1.x + value2.x; - result.y = value1.y + value2.y; - return result; - }; - Vector2.divide = function (value1, value2) { - var result = new Vector2(0, 0); - result.x = value1.x / value2.x; - result.y = value1.y / value2.y; - return result; - }; - Vector2.multiply = function (value1, value2) { - var result = new Vector2(0, 0); - result.x = value1.x * value2.x; - result.y = value1.y * value2.y; - return result; - }; - Vector2.subtract = function (value1, value2) { - var result = new Vector2(0, 0); - result.x = value1.x - value2.x; - result.y = value1.y - value2.y; - return result; - }; - Vector2.normalize = function (value) { - var nValue = new Vector2(value.x, value.y); - var val = 1 / Math.sqrt((nValue.x * nValue.x) + (nValue.y * nValue.y)); - nValue.x *= val; - nValue.y *= val; - return nValue; - }; - Vector2.dot = function (value1, value2) { - return (value1.x * value2.x) + (value1.y * value2.y); - }; - Vector2.distanceSquared = function (value1, value2) { - var v1 = value1.x - value2.x, v2 = value1.y - value2.y; - return (v1 * v1) + (v2 * v2); - }; - Vector2.clamp = function (value1, min, max) { - return new Vector2(es.MathHelper.clamp(value1.x, min.x, max.x), es.MathHelper.clamp(value1.y, min.y, max.y)); - }; - Vector2.lerp = function (value1, value2, amount) { - return new Vector2(es.MathHelper.lerp(value1.x, value2.x, amount), es.MathHelper.lerp(value1.y, value2.y, amount)); - }; - Vector2.transform = function (position, matrix) { - return new Vector2((position.x * matrix.m11) + (position.y * matrix.m21) + matrix.m31, (position.x * matrix.m12) + (position.y * matrix.m22) + matrix.m32); - }; - Vector2.distance = function (value1, value2) { - var v1 = value1.x - value2.x, v2 = value1.y - value2.y; - return Math.sqrt((v1 * v1) + (v2 * v2)); - }; - Vector2.angle = function (from, to) { - from = Vector2.normalize(from); - to = Vector2.normalize(to); - return Math.acos(es.MathHelper.clamp(Vector2.dot(from, to), -1, 1)) * es.MathHelper.Rad2Deg; - }; - Vector2.negate = function (value) { - value.x = -value.x; - value.y = -value.y; - return value; - }; - Vector2.prototype.add = function (value) { - this.x += value.x; - this.y += value.y; - return this; - }; - Vector2.prototype.divide = function (value) { - this.x /= value.x; - this.y /= value.y; - return this; - }; - Vector2.prototype.multiply = function (value) { - this.x *= value.x; - this.y *= value.y; - return this; - }; - Vector2.prototype.subtract = function (value) { - this.x -= value.x; - this.y -= value.y; - return this; - }; - Vector2.prototype.normalize = function () { - var val = 1 / Math.sqrt((this.x * this.x) + (this.y * this.y)); - this.x *= val; - this.y *= val; - }; - Vector2.prototype.length = function () { - return Math.sqrt((this.x * this.x) + (this.y * this.y)); - }; - Vector2.prototype.lengthSquared = function () { - return (this.x * this.x) + (this.y * this.y); - }; - Vector2.prototype.round = function () { - return new Vector2(Math.round(this.x), Math.round(this.y)); - }; - Vector2.prototype.equals = function (other) { - if (other instanceof Vector2) { - return other.x == this.x && other.y == this.y; - } - return false; - }; - return Vector2; - }()); - es.Vector2 = Vector2; -})(es || (es = {})); -var es; -(function (es) { - var UnweightedGridGraph = (function () { - function UnweightedGridGraph(width, height, allowDiagonalSearch) { - if (allowDiagonalSearch === void 0) { allowDiagonalSearch = false; } - this.walls = []; - this._neighbors = new Array(4); - this._width = width; - this._hegiht = height; - this._dirs = allowDiagonalSearch ? UnweightedGridGraph.COMPASS_DIRS : UnweightedGridGraph.CARDINAL_DIRS; - } - UnweightedGridGraph.prototype.isNodeInBounds = function (node) { - return 0 <= node.x && node.x < this._width && 0 <= node.y && node.y < this._hegiht; - }; - UnweightedGridGraph.prototype.isNodePassable = function (node) { - return !this.walls.firstOrDefault(function (wall) { return JSON.stringify(wall) == JSON.stringify(node); }); - }; - UnweightedGridGraph.prototype.getNeighbors = function (node) { - var _this = this; - this._neighbors.length = 0; - this._dirs.forEach(function (dir) { - var next = new es.Vector2(node.x + dir.x, node.y + dir.y); - if (_this.isNodeInBounds(next) && _this.isNodePassable(next)) - _this._neighbors.push(next); - }); - return this._neighbors; - }; - UnweightedGridGraph.prototype.search = function (start, goal) { - return es.BreadthFirstPathfinder.search(this, start, goal); - }; - UnweightedGridGraph.CARDINAL_DIRS = [ - new es.Vector2(1, 0), - new es.Vector2(0, -1), - new es.Vector2(-1, 0), - new es.Vector2(0, -1) - ]; - UnweightedGridGraph.COMPASS_DIRS = [ - new es.Vector2(1, 0), - new es.Vector2(1, -1), - new es.Vector2(0, -1), - new es.Vector2(-1, -1), - new es.Vector2(-1, 0), - new es.Vector2(-1, 1), - new es.Vector2(0, 1), - new es.Vector2(1, 1), - ]; - return UnweightedGridGraph; - }()); - es.UnweightedGridGraph = UnweightedGridGraph; -})(es || (es = {})); -var es; -(function (es) { - var WeightedGridGraph = (function () { - function WeightedGridGraph(width, height, allowDiagonalSearch) { - if (allowDiagonalSearch === void 0) { allowDiagonalSearch = false; } - this.walls = []; - this.weightedNodes = []; - this.defaultWeight = 1; - this.weightedNodeWeight = 5; - this._neighbors = new Array(4); - this._width = width; - this._height = height; - this._dirs = allowDiagonalSearch ? WeightedGridGraph.COMPASS_DIRS : WeightedGridGraph.CARDINAL_DIRS; - } - WeightedGridGraph.prototype.isNodeInBounds = function (node) { - return 0 <= node.x && node.x < this._width && 0 <= node.y && node.y < this._height; - }; - WeightedGridGraph.prototype.isNodePassable = function (node) { - return !this.walls.firstOrDefault(function (wall) { return JSON.stringify(wall) == JSON.stringify(node); }); - }; - WeightedGridGraph.prototype.search = function (start, goal) { - return es.WeightedPathfinder.search(this, start, goal); - }; - WeightedGridGraph.prototype.getNeighbors = function (node) { - var _this = this; - this._neighbors.length = 0; - this._dirs.forEach(function (dir) { - var next = new es.Vector2(node.x + dir.x, node.y + dir.y); - if (_this.isNodeInBounds(next) && _this.isNodePassable(next)) - _this._neighbors.push(next); - }); - return this._neighbors; - }; - WeightedGridGraph.prototype.cost = function (from, to) { - return this.weightedNodes.find(function (t) { return JSON.stringify(t) == JSON.stringify(to); }) ? this.weightedNodeWeight : this.defaultWeight; - }; - WeightedGridGraph.CARDINAL_DIRS = [ - new es.Vector2(1, 0), - new es.Vector2(0, -1), - new es.Vector2(-1, 0), - new es.Vector2(0, 1) - ]; - WeightedGridGraph.COMPASS_DIRS = [ - new es.Vector2(1, 0), - new es.Vector2(1, -1), - new es.Vector2(0, -1), - new es.Vector2(-1, -1), - new es.Vector2(-1, 0), - new es.Vector2(-1, 1), - new es.Vector2(0, 1), - new es.Vector2(1, 1), - ]; - return WeightedGridGraph; - }()); - es.WeightedGridGraph = WeightedGridGraph; -})(es || (es = {})); -var es; -(function (es) { - var WeightedNode = (function (_super) { - __extends(WeightedNode, _super); - function WeightedNode(data) { - var _this = _super.call(this) || this; - _this.data = data; - return _this; - } - return WeightedNode; - }(es.PriorityQueueNode)); - es.WeightedNode = WeightedNode; - var WeightedPathfinder = (function () { - function WeightedPathfinder() { - } - WeightedPathfinder.search = function (graph, start, goal) { - var _this = this; - var foundPath = false; - var cameFrom = new Map(); - cameFrom.set(start, start); - var costSoFar = new Map(); - var frontier = new es.PriorityQueue(1000); - frontier.enqueue(new WeightedNode(start), 0); - costSoFar.set(start, 0); - var _loop_4 = function () { - var current = frontier.dequeue(); - if (JSON.stringify(current.data) == JSON.stringify(goal)) { - foundPath = true; - return "break"; - } - graph.getNeighbors(current.data).forEach(function (next) { - var newCost = costSoFar.get(current.data) + graph.cost(current.data, next); - if (!_this.hasKey(costSoFar, next) || newCost < costSoFar.get(next)) { - costSoFar.set(next, newCost); - var priprity = newCost; - frontier.enqueue(new WeightedNode(next), priprity); - cameFrom.set(next, current.data); - } - }); - }; - while (frontier.count > 0) { - var state_3 = _loop_4(); - if (state_3 === "break") - break; - } - return foundPath ? this.recontructPath(cameFrom, start, goal) : null; - }; - WeightedPathfinder.recontructPath = function (cameFrom, start, goal) { - var path = []; - var current = goal; - path.push(goal); - while (current != start) { - current = this.getKey(cameFrom, current); - path.push(current); - } - path.reverse(); - return path; - }; - WeightedPathfinder.hasKey = function (map, compareKey) { - var iterator = map.keys(); - var r; - while (r = iterator.next(), !r.done) { - if (JSON.stringify(r.value) == JSON.stringify(compareKey)) - return true; - } - return false; - }; - WeightedPathfinder.getKey = function (map, compareKey) { - var iterator = map.keys(); - var valueIterator = map.values(); - var r; - var v; - while (r = iterator.next(), v = valueIterator.next(), !r.done) { - if (JSON.stringify(r.value) == JSON.stringify(compareKey)) - return v.value; - } - return null; - }; - return WeightedPathfinder; - }()); - es.WeightedPathfinder = WeightedPathfinder; -})(es || (es = {})); -var es; -(function (es) { - var AStarStorage = (function () { - function AStarStorage() { - this._opened = new Array(AStarStorage.MAX_NODES); - this._closed = new Array(AStarStorage.MAX_NODES); - } - AStarStorage.prototype.clear = function () { - for (var i = 0; i < this._numOpened; i++) { - es.Pool.free(this._opened[i]); - this._opened[i] = null; - } - for (var i = 0; i < this._numClosed; i++) { - es.Pool.free(this._closed[i]); - this._closed[i] = null; - } - this._numOpened = this._numClosed = 0; - this._lastFoundClosed = this._lastFoundOpened = 0; - }; - AStarStorage.prototype.findOpened = function (node) { - for (var i = 0; i < this._numOpened; i++) { - var care = node.worldState.dontCare ^ -1; - if ((node.worldState.values & care) == (this._opened[i].worldState.values & care)) { - this._lastFoundClosed = i; - return this._closed[i]; - } - } - return null; - }; - AStarStorage.prototype.findClosed = function (node) { - for (var i = 0; i < this._numClosed; i++) { - var care = node.worldState.dontCare ^ -1; - if ((node.worldState.values & care) == (this._closed[i].worldState.values & care)) { - this._lastFoundClosed = i; - return this._closed[i]; - } - } - return null; - }; - AStarStorage.prototype.hasOpened = function () { - return this._numOpened > 0; - }; - AStarStorage.prototype.removeOpened = function (node) { - if (this._numOpened > 0) - this._opened[this._lastFoundOpened] = this._opened[this._numOpened - 1]; - this._numOpened--; - }; - AStarStorage.prototype.removeClosed = function (node) { - if (this._numClosed > 0) - this._closed[this._lastFoundClosed] = this._closed[this._numClosed - 1]; - this._numClosed--; - }; - AStarStorage.prototype.isOpen = function (node) { - return this._opened.indexOf(node) > -1; - }; - AStarStorage.prototype.isClosed = function (node) { - return this._closed.indexOf(node) > -1; - }; - AStarStorage.prototype.addToOpenList = function (node) { - this._opened[this._numOpened++] = node; - }; - AStarStorage.prototype.addToClosedList = function (node) { - this._closed[this._numClosed++] = node; - }; - AStarStorage.prototype.removeCheapestOpenNode = function () { - var lowestVal = Number.MAX_VALUE; - this._lastFoundOpened = -1; - for (var i = 0; i < this._numOpened; i++) { - if (this._opened[i].costSoFarAndHeuristicCost < lowestVal) { - lowestVal = this._opened[i].costSoFarAndHeuristicCost; - this._lastFoundOpened = i; - } - } - var val = this._opened[this._lastFoundOpened]; - this.removeOpened(val); - return val; - }; - AStarStorage.MAX_NODES = 128; - return AStarStorage; - }()); - es.AStarStorage = AStarStorage; -})(es || (es = {})); -var es; -(function (es) { - var AStarNode = (function () { - function AStarNode() { - } - AStarNode.prototype.equals = function (other) { - var care = this.worldState.dontCare ^ -1; - return (this.worldState.values & care) == (other.worldState.values & care); - }; - AStarNode.prototype.compareTo = function (other) { - return this.costSoFarAndHeuristicCost - other.costSoFarAndHeuristicCost; - }; - AStarNode.prototype.reset = function () { - this.action = null; - this.parent = null; - }; - AStarNode.prototype.clone = function () { - var node = new AStarNode(); - node.action = this.action; - node.costSoFar = this.costSoFar; - node.depth = this.depth; - node.parent = this.parent; - node.parentWorldState = this.parentWorldState; - node.heuristicCost = this.heuristicCost; - node.worldState = this.worldState; - return node; - }; - AStarNode.prototype.toString = function () { - return "[cost: " + this.costSoFar + " | heuristic: " + this.heuristicCost + "]: " + this.action; - }; - return AStarNode; - }()); - es.AStarNode = AStarNode; - var AStar = (function () { - function AStar() { - } - AStar.plan = function (ap, start, goal, selectedNodes) { - if (selectedNodes === void 0) { selectedNodes = null; } - this.storage.clear(); - var currentNode = es.Pool.obtain(AStarNode); - currentNode.worldState = start; - currentNode.parentWorldState = start; - currentNode.costSoFar = 0; - currentNode.heuristicCost = this.calculateHeuristic(start, goal); - currentNode.costSoFarAndHeuristicCost = currentNode.costSoFar + currentNode.heuristicCost; - currentNode.depth = 1; - this.storage.addToOpenList(currentNode); - while (true) { - if (!this.storage.hasOpened()) { - this.storage.clear(); - return null; - } - currentNode = this.storage.removeCheapestOpenNode(); - this.storage.addToClosedList(currentNode); - if (goal.equals(currentNode.worldState)) { - var plan = this.reconstructPlan(currentNode, selectedNodes); - this.storage.clear(); - return plan; - } - var neighbors = ap.getPossibleTransitions(currentNode.worldState); - for (var i = 0; i < neighbors.length; i++) { - var cur = neighbors[i]; - var opened = this.storage.findOpened(cur); - var closed_1 = this.storage.findClosed(cur); - var cost = currentNode.costSoFar + cur.costSoFar; - if (opened != null && cost < opened.costSoFar) { - this.storage.removeOpened(opened); - opened = null; - } - if (closed_1 != null && cost < closed_1.costSoFar) { - this.storage.removeClosed(closed_1); - } - if (opened == null && closed_1 == null) { - var nb = es.Pool.obtain(AStarNode); - nb.worldState = cur.worldState; - nb.costSoFar = cost; - nb.heuristicCost = this.calculateHeuristic(cur.worldState, goal); - nb.costSoFarAndHeuristicCost = nb.costSoFar + nb.heuristicCost; - nb.action = cur.action; - nb.parentWorldState = currentNode.worldState; - nb.parent = currentNode; - nb.depth = currentNode.depth + 1; - this.storage.addToOpenList(nb); - } - } - es.ListPool.free(neighbors); - } - }; - AStar.reconstructPlan = function (goalNode, selectedNodes) { - var totalActionsInPlan = goalNode.depth - 1; - var plan = new Array(totalActionsInPlan); - var curnode = goalNode; - for (var i = 0; i <= totalActionsInPlan - 1; i++) { - if (selectedNodes != null) - selectedNodes.push(curnode.clone()); - plan.push(curnode.action); - curnode = curnode.parent; - } - if (selectedNodes != null) - selectedNodes.reverse(); - return plan; - }; - AStar.calculateHeuristic = function (fr, to) { - var care = (to.dontCare ^ -1); - var diff = (fr.values & care) ^ (to.values & care); - var dist = 0; - for (var i = 0; i < es.ActionPlanner.MAX_CONDITIONS; ++i) - if ((diff & (1 << i)) != 0) - dist++; - return dist; - }; - AStar.storage = new es.AStarStorage(); - return AStar; - }()); - es.AStar = AStar; -})(es || (es = {})); -var es; -(function (es) { - var Action = (function () { - function Action(name, cost) { - if (cost === void 0) { cost = 1; } - this.cost = 1; - this._preConditions = new Set(); - this._postConditions = new Set(); - this.name = name; - this.cost = cost; - } - Action.prototype.setPrecondition = function (conditionName, value) { - this._preConditions.add([conditionName, value]); - }; - Action.prototype.setPostcondition = function (conditionName, value) { - this._preConditions.add([conditionName, value]); - }; - Action.prototype.validate = function () { - return true; - }; - Action.prototype.toString = function () { - return "[Action] " + this.name + " - cost: " + this.cost; - }; - return Action; - }()); - es.Action = Action; -})(es || (es = {})); -var es; -(function (es) { - var ActionPlanner = (function () { - function ActionPlanner() { - this.conditionNames = new Array(ActionPlanner.MAX_CONDITIONS); - this._actions = []; - this._viableActions = []; - this._preConditions = new Array(ActionPlanner.MAX_CONDITIONS); - this._postConditions = new Array(ActionPlanner.MAX_CONDITIONS); - this._numConditionNames = 0; - for (var i = 0; i < ActionPlanner.MAX_CONDITIONS; ++i) { - this.conditionNames[i] = null; - this._preConditions[i] = es.WorldState.create(this); - this._postConditions[i] = es.WorldState.create(this); - } - } - ActionPlanner.prototype.createWorldState = function () { - return es.WorldState.create(this); - }; - ActionPlanner.prototype.addAction = function (action) { - var _this = this; - var actionId = this.findActionIndex(action); - if (actionId == -1) - throw new Error("无法找到或创建行动"); - action._preConditions.forEach(function (preCondition) { - var conditionId = _this.findConditionNameIndex(preCondition[0]); - if (conditionId == -1) - throw new Error("无法找到或创建条件名称"); - _this._preConditions[actionId].set(conditionId, preCondition[1]); - }); - action._postConditions.forEach(function (postCondition) { - var conditionId = _this.findConditionNameIndex(postCondition[0]); - if (conditionId == -1) - throw new Error("找不到条件名称"); - _this._postConditions[actionId].set(conditionId, postCondition[1]); - }); - }; - ActionPlanner.prototype.plan = function (startState, goalState, selectedNode) { - if (selectedNode === void 0) { selectedNode = null; } - this._viableActions.length = 0; - for (var i = 0; i < this._actions.length; i++) { - if (this._actions[i].validate()) - this._viableActions.push(this._actions[i]); - } - return es.AStar.plan(this, startState, goalState, selectedNode); - }; - ActionPlanner.prototype.getPossibleTransitions = function (fr) { - var result = es.ListPool.obtain(); - for (var i = 0; i < this._viableActions.length; ++i) { - var pre = this._preConditions[i]; - var care = (pre.dontCare ^ -1); - var met = ((pre.values & care) == (fr.values & care)); - if (met) { - var node = es.Pool.obtain(es.AStarNode); - node.action = this._viableActions[i]; - node.costSoFar = this._viableActions[i].cost; - node.worldState = this.applyPostConditions(this, i, fr); - result.push(node); - } - } - return result; - }; - ActionPlanner.prototype.applyPostConditions = function (ap, actionnr, fr) { - var pst = ap._postConditions[actionnr]; - var unaffected = pst.dontCare; - var affected = (unaffected ^ -1); - fr.values = (fr.values & unaffected) | (pst.values & affected); - fr.dontCare &= pst.dontCare; - return fr; - }; - ActionPlanner.prototype.findConditionNameIndex = function (conditionName) { - var idx; - for (idx = 0; idx < this._numConditionNames; ++idx) { - if (this.conditionNames[idx] == conditionName) - return idx; - } - if (idx < ActionPlanner.MAX_CONDITIONS - 1) { - this.conditionNames[idx] = conditionName; - this._numConditionNames++; - return idx; - } - return -1; - }; - ActionPlanner.prototype.findActionIndex = function (action) { - var idx = this._actions.indexOf(action); - if (idx > -1) - return idx; - this._actions.push(action); - return this._actions.length - 1; - }; - ActionPlanner.MAX_CONDITIONS = 64; - return ActionPlanner; - }()); - es.ActionPlanner = ActionPlanner; -})(es || (es = {})); -var es; -(function (es) { - var Agent = (function () { - function Agent() { - this._planner = new es.ActionPlanner(); - } - Agent.prototype.plan = function (debugPlan) { - if (debugPlan === void 0) { debugPlan = false; } - var nodes = null; - if (debugPlan) - nodes = []; - this.actions = this._planner.plan(this.getWorldState(), this.getGoalState(), nodes); - if (nodes != null && nodes.length > 0) { - console.log("---- ActionPlanner plan ----"); - console.log("plan cost = " + nodes[nodes.length - 1].costSoFar); - console.log(" start" + "\t" + this.getWorldState().describe(this._planner)); - for (var i = 0; i < nodes.length; i++) { - console.log(i + ": " + nodes[i].action.name + "\t" + nodes[i].worldState.describe(this._planner)); - es.Pool.free(nodes[i]); - } - } - return this.hasActionPlan(); - }; - Agent.prototype.hasActionPlan = function () { - return this.actions != null && this.actions.length > 0; - }; - return Agent; - }()); - es.Agent = Agent; -})(es || (es = {})); -var es; -(function (es) { - var WorldState = (function () { - function WorldState(planner, values, dontcare) { - this.planner = planner; - this.values = values; - this.dontCare = dontcare; - } - WorldState.create = function (planner) { - return new WorldState(planner, 0, -1); - }; - WorldState.prototype.set = function (conditionId, value) { - if (typeof conditionId == "string") { - return this.set(this.planner.findConditionNameIndex(conditionId), value); - } - this.values = value ? (this.values | (1 << conditionId)) : (this.values & ~(1 << conditionId)); - this.dontCare ^= (1 << conditionId); - return true; - }; - WorldState.prototype.equals = function (other) { - var care = this.dontCare ^ -1; - return (this.values & care) == (other.values & care); - }; - WorldState.prototype.describe = function (planner) { - var s = ""; - for (var i = 0; i < es.ActionPlanner.MAX_CONDITIONS; i++) { - if ((this.dontCare & (1 << i)) == 0) { - var val = planner.conditionNames[i]; - if (val == null) - continue; - var set = ((this.values & (1 << i)) != 0); - if (s.length > 0) - s += ", "; - s += (set ? val.toUpperCase() : val); - } - } - return s; - }; - return WorldState; - }()); - es.WorldState = WorldState; -})(es || (es = {})); -var es; -(function (es) { - var Core = (function (_super) { - __extends(Core, _super); - function Core() { - var _this = _super.call(this) || this; - _this._globalManagers = []; - _this._coroutineManager = new es.CoroutineManager(); - _this._timerManager = new es.TimerManager(); - _this._frameCounterElapsedTime = 0; - _this._frameCounter = 0; - Core._instance = _this; - Core.emitter = new es.Emitter(); - Core.content = new es.ContentManager(); - _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _this); - Core.registerGlobalManager(_this._coroutineManager); - Core.registerGlobalManager(_this._timerManager); - return _this; - } - Object.defineProperty(Core, "Instance", { - get: function () { - return this._instance; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Core, "scene", { - get: function () { - if (!this._instance) - return null; - return this._instance._scene; - }, - set: function (value) { - if (!value) { - console.error("场景不能为空"); - return; - } - if (this._instance._scene == null) { - this._instance.addChild(value); - this._instance._scene = value; - this._instance._scene.begin(); - Core.Instance.onSceneChanged(); - } - else { - this._instance._nextScene = value; - } - }, - enumerable: true, - configurable: true - }); - Core.startSceneTransition = function (sceneTransition) { - if (this._instance._sceneTransition) { - console.warn("在前一个场景完成之前,不能开始一个新的场景转换。"); - return; - } - this._instance._sceneTransition = sceneTransition; - return sceneTransition; - }; - Core.registerGlobalManager = function (manager) { - this._instance._globalManagers.push(manager); - manager.enabled = true; - }; - Core.unregisterGlobalManager = function (manager) { - this._instance._globalManagers.remove(manager); - manager.enabled = false; - }; - Core.getGlobalManager = function (type) { - for (var i = 0; i < this._instance._globalManagers.length; i++) { - if (this._instance._globalManagers[i] instanceof type) - return this._instance._globalManagers[i]; - } - return null; - }; - Core.startCoroutine = function (enumerator) { - return this._instance._coroutineManager.startCoroutine(enumerator); - }; - Core.schedule = function (timeInSeconds, repeats, context, onTime) { - if (repeats === void 0) { repeats = false; } - if (context === void 0) { context = null; } - return this._instance._timerManager.schedule(timeInSeconds, repeats, context, onTime); - }; - Core.prototype.onOrientationChanged = function () { - Core.emitter.emit(es.CoreEvents.OrientationChanged); - }; - Core.prototype.draw = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (!this._sceneTransition) return [3, 4]; - this._sceneTransition.preRender(); - if (!(this._scene && !this._sceneTransition.hasPreviousSceneRender)) return [3, 2]; - this._scene.render(); - this._scene.postRender(); - return [4, this._sceneTransition.onBeginTransition()]; - case 1: - _a.sent(); - return [3, 3]; - case 2: - if (this._sceneTransition) { - if (this._scene && this._sceneTransition.isNewSceneLoaded) { - this._scene.render(); - this._scene.postRender(); - } - this._sceneTransition.render(); - } - _a.label = 3; - case 3: return [3, 5]; - case 4: - if (this._scene) { - this._scene.render(); - es.Debug.render(); - this._scene.postRender(); - } - _a.label = 5; - case 5: return [2]; - } - }); - }); - }; - Core.prototype.startDebugUpdate = function () { - es.TimeRuler.Instance.startFrame(); - es.TimeRuler.Instance.beginMark("update", 0x00FF00); - }; - Core.prototype.endDebugUpdate = function () { - es.TimeRuler.Instance.endMark("update"); - }; - Core.prototype.startDebugDraw = function (elapsedGameTime) { - es.TimeRuler.Instance.beginMark("draw", 0xFFD700); - this._frameCounter++; - this._frameCounterElapsedTime += elapsedGameTime; - if (this._frameCounterElapsedTime >= 1) { - this._frameCounter = 0; - this._frameCounterElapsedTime -= 1; - } - }; - Core.prototype.endDebugDraw = function () { - es.TimeRuler.Instance.endMark("draw"); - es.TimeRuler.Instance.render(); - }; - Core.prototype.onSceneChanged = function () { - Core.emitter.emit(es.CoreEvents.SceneChanged); - es.Time.sceneChanged(); - }; - Core.prototype.onGraphicsDeviceReset = function () { - Core.emitter.emit(es.CoreEvents.GraphicsDeviceReset); - }; - Core.prototype.initialize = function () { - es.Graphics.Instance = new es.Graphics(); - }; - Core.prototype.update = function () { - return __awaiter(this, void 0, void 0, function () { - var i; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - es.Time.update(egret.getTimer()); - es.Input.update(); - if (!this._scene) return [3, 2]; - for (i = this._globalManagers.length - 1; i >= 0; i--) { - if (this._globalManagers[i].enabled) - this._globalManagers[i].update(); - } - if (!this._sceneTransition || - (this._sceneTransition && (!this._sceneTransition.loadsNewScene || this._sceneTransition.isNewSceneLoaded))) { - this._scene.update(); - } - if (!this._nextScene) return [3, 2]; - if (this._scene.parent) - this._scene.parent.removeChild(this._scene); - this._scene.end(); - this._scene = this._nextScene; - this._nextScene = null; - this.onSceneChanged(); - return [4, this._scene.begin()]; - case 1: - _a.sent(); - this.addChild(this._scene); - _a.label = 2; - case 2: return [4, this.draw()]; - case 3: - _a.sent(); - return [2]; - } - }); - }); - }; - Core.prototype.onAddToStage = function () { - Core.graphicsDevice = new es.GraphicsDevice(); - this.addEventListener(egret.Event.RESIZE, this.onGraphicsDeviceReset, this); - this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE, this.onOrientationChanged, this); - this.addEventListener(egret.Event.ENTER_FRAME, this.update, this); - es.Input.initialize(); - KeyboardUtils.init(); - this.initialize(); - }; - Core.debugRenderEndabled = false; - return Core; - }(egret.DisplayObjectContainer)); - es.Core = Core; -})(es || (es = {})); -var es; -(function (es) { - var Colors = (function () { - function Colors() { - } - Colors.renderableBounds = 0xffff00; - Colors.renderableCenter = 0x9932CC; - Colors.colliderBounds = 0x555555; - Colors.colliderEdge = 0x8B0000; - Colors.colliderPosition = 0xFFFF00; - Colors.colliderCenter = 0xFF0000; - return Colors; - }()); - es.Colors = Colors; - var Size = (function () { - function Size() { - } - Object.defineProperty(Size, "lineSizeMultiplier", { - get: function () { - return Math.max(Math.ceil(es.Core.scene.x / es.Core.scene.width), 1); - }, - enumerable: true, - configurable: true - }); - return Size; - }()); - es.Size = Size; - var Debug = (function () { - function Debug() { - } - Debug.drawHollowRect = function (rectanle, color, duration) { - if (duration === void 0) { duration = 0; } - this._debugDrawItems.push(new es.DebugDrawItem(rectanle, color, duration)); - }; - Debug.render = function () { - if (this._debugDrawItems.length > 0) { - var debugShape = new egret.Shape(); - if (es.Core.scene) { - es.Core.scene.addChild(debugShape); - } - for (var i = this._debugDrawItems.length - 1; i >= 0; i--) { - var item = this._debugDrawItems[i]; - if (item.draw(debugShape)) - this._debugDrawItems.removeAt(i); - } - } - }; - Debug._debugDrawItems = []; - return Debug; - }()); - es.Debug = Debug; -})(es || (es = {})); -var es; -(function (es) { - var DebugDefaults = (function () { - function DebugDefaults() { - } - DebugDefaults.verletParticle = 0xDC345E; - DebugDefaults.verletConstraintEdge = 0x433E36; - return DebugDefaults; - }()); - es.DebugDefaults = DebugDefaults; -})(es || (es = {})); -var es; -(function (es) { - var DebugDrawType; - (function (DebugDrawType) { - DebugDrawType[DebugDrawType["line"] = 0] = "line"; - DebugDrawType[DebugDrawType["hollowRectangle"] = 1] = "hollowRectangle"; - DebugDrawType[DebugDrawType["pixel"] = 2] = "pixel"; - DebugDrawType[DebugDrawType["text"] = 3] = "text"; - })(DebugDrawType = es.DebugDrawType || (es.DebugDrawType = {})); - var DebugDrawItem = (function () { - function DebugDrawItem(rectangle, color, duration) { - this.rectangle = rectangle; - this.color = color; - this.duration = duration; - this.drawType = DebugDrawType.hollowRectangle; - } - DebugDrawItem.prototype.draw = function (shape) { - switch (this.drawType) { - case DebugDrawType.line: - break; - case DebugDrawType.hollowRectangle: - break; - case DebugDrawType.pixel: - break; - case DebugDrawType.text: - break; - } - this.duration -= es.Time.deltaTime; - return this.duration < 0; - }; - return DebugDrawItem; - }()); - es.DebugDrawItem = DebugDrawItem; -})(es || (es = {})); -var es; -(function (es) { - var Component = (function (_super) { - __extends(Component, _super); - function Component() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.updateInterval = 1; - _this.debugDisplayObject = new egret.DisplayObjectContainer(); - _this._enabled = true; - _this._updateOrder = 0; - return _this; - } - Object.defineProperty(Component.prototype, "transform", { - get: function () { - return this.entity.transform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Component.prototype, "enabled", { - get: function () { - return this.entity ? this.entity.enabled && this._enabled : this._enabled; - }, - set: function (value) { - this.setEnabled(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Component.prototype, "updateOrder", { - get: function () { - return this._updateOrder; - }, - set: function (value) { - this.setUpdateOrder(value); - }, - enumerable: true, - configurable: true - }); - Component.prototype.initialize = function () { - }; - Component.prototype.onAddedToEntity = function () { - }; - Component.prototype.onRemovedFromEntity = function () { - }; - Component.prototype.onEntityTransformChanged = function (comp) { - }; - Component.prototype.debugRender = function (camera) { - }; - Component.prototype.onEnabled = function () { - }; - Component.prototype.onDisabled = function () { - }; - Component.prototype.update = function () { - }; - Component.prototype.setEnabled = function (isEnabled) { - if (this._enabled != isEnabled) { - this._enabled = isEnabled; - if (this._enabled) { - this.onEnabled(); - } - else { - this.onDisabled(); - } - } - return this; - }; - Component.prototype.setUpdateOrder = function (updateOrder) { - if (this._updateOrder != updateOrder) { - this._updateOrder = updateOrder; - } - return this; - }; - return Component; - }(egret.HashObject)); - es.Component = Component; -})(es || (es = {})); -var es; -(function (es) { - var CoreEvents; - (function (CoreEvents) { - CoreEvents[CoreEvents["GraphicsDeviceReset"] = 0] = "GraphicsDeviceReset"; - CoreEvents[CoreEvents["SceneChanged"] = 1] = "SceneChanged"; - CoreEvents[CoreEvents["OrientationChanged"] = 2] = "OrientationChanged"; - })(CoreEvents = es.CoreEvents || (es.CoreEvents = {})); -})(es || (es = {})); -var es; -(function (es) { - var Entity = (function () { - function Entity(name) { - this.updateInterval = 1; - this._tag = 0; - this._enabled = true; - this._updateOrder = 0; - this.components = new es.ComponentList(this); - this.transform = new es.Transform(this); - this.name = name; - this.id = Entity._idGenerator++; - this.componentBits = new es.BitSet(); - } - Object.defineProperty(Entity.prototype, "isDestroyed", { - get: function () { - return this._isDestroyed; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "tag", { - get: function () { - return this._tag; - }, - set: function (value) { - this.setTag(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "enabled", { - get: function () { - return this._enabled; - }, - set: function (value) { - this.setEnabled(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "updateOrder", { - get: function () { - return this._updateOrder; - }, - set: function (value) { - this.setUpdateOrder(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "parent", { - get: function () { - return this.transform.parent; - }, - set: function (value) { - this.transform.setParent(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "childCount", { - get: function () { - return this.transform.childCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "position", { - get: function () { - return this.transform.position; - }, - set: function (value) { - this.transform.setPosition(value.x, value.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "localPosition", { - get: function () { - return this.transform.localPosition; - }, - set: function (value) { - this.transform.setLocalPosition(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "rotation", { - get: function () { - return this.transform.rotation; - }, - set: function (value) { - this.transform.setRotation(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "rotationDegrees", { - get: function () { - return this.transform.rotationDegrees; - }, - set: function (value) { - this.transform.setRotationDegrees(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "localRotation", { - get: function () { - return this.transform.localRotation; - }, - set: function (value) { - this.transform.setLocalRotation(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "localRotationDegrees", { - get: function () { - return this.transform.localRotationDegrees; - }, - set: function (value) { - this.transform.setLocalRotationDegrees(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "scale", { - get: function () { - return this.transform.scale; - }, - set: function (value) { - this.transform.setScale(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "localScale", { - get: function () { - return this.transform.localScale; - }, - set: function (value) { - this.transform.setLocalScale(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "worldInverseTransform", { - get: function () { - return this.transform.worldInverseTransform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "localToWorldTransform", { - get: function () { - return this.transform.localToWorldTransform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "worldToLocalTransform", { - get: function () { - return this.transform.worldToLocalTransform; - }, - enumerable: true, - configurable: true - }); - Entity.prototype.onTransformChanged = function (comp) { - this.components.onEntityTransformChanged(comp); - }; - Entity.prototype.setTag = function (tag) { - if (this._tag != tag) { - if (this.scene) - this.scene.entities.removeFromTagList(this); - this._tag = tag; - if (this.scene) - this.scene.entities.addToTagList(this); - } - return this; - }; - Entity.prototype.setEnabled = function (isEnabled) { - if (this._enabled != isEnabled) { - this._enabled = isEnabled; - if (this._enabled) - this.components.onEntityEnabled(); - else - this.components.onEntityDisabled(); - } - return this; - }; - Entity.prototype.setUpdateOrder = function (updateOrder) { - if (this._updateOrder != updateOrder) { - this._updateOrder = updateOrder; - if (this.scene) { - this.scene.entities.markEntityListUnsorted(); - this.scene.entities.markTagUnsorted(this.tag); - } - return this; - } - }; - Entity.prototype.destroy = function () { - this._isDestroyed = true; - this.scene.entities.remove(this); - this.transform.parent = null; - for (var i = this.transform.childCount - 1; i >= 0; i--) { - var child = this.transform.getChild(i); - child.entity.destroy(); - } - }; - Entity.prototype.detachFromScene = function () { - this.scene.entities.remove(this); - this.components.deregisterAllComponents(); - for (var i = 0; i < this.transform.childCount; i++) - this.transform.getChild(i).entity.detachFromScene(); - }; - Entity.prototype.attachToScene = function (newScene) { - this.scene = newScene; - newScene.entities.add(this); - this.components.registerAllComponents(); - for (var i = 0; i < this.transform.childCount; i++) { - this.transform.getChild(i).entity.attachToScene(newScene); - } - }; - Entity.prototype.onAddedToScene = function () { - }; - Entity.prototype.onRemovedFromScene = function () { - if (this._isDestroyed) - this.components.removeAllComponents(); - }; - Entity.prototype.update = function () { - this.components.update(); - }; - Entity.prototype.debugRender = function (camera) { - this.components.debugRender(camera); - }; - Entity.prototype.addComponent = function (component) { - component.entity = this; - this.components.add(component); - component.initialize(); - return component; - }; - Entity.prototype.getComponent = function (type) { - return this.components.getComponent(type, false); - }; - Entity.prototype.hasComponent = function (type) { - return this.components.getComponent(type, false) != null; - }; - Entity.prototype.getOrCreateComponent = function (type) { - var comp = this.components.getComponent(type, true); - if (!comp) { - comp = this.addComponent(type); - } - return comp; - }; - Entity.prototype.getComponents = function (typeName, componentList) { - return this.components.getComponents(typeName, componentList); - }; - Entity.prototype.removeComponent = function (component) { - this.components.remove(component); - }; - Entity.prototype.removeComponentForType = function (type) { - var comp = this.getComponent(type); - if (comp) { - this.removeComponent(comp); - return true; - } - return false; - }; - Entity.prototype.removeAllComponents = function () { - for (var i = 0; i < this.components.count; i++) { - this.removeComponent(this.components.buffer[i]); - } - }; - Entity.prototype.compareTo = function (other) { - var compare = this._updateOrder - other._updateOrder; - if (compare == 0) - compare = this.id - other.id; - return compare; - }; - Entity.prototype.toString = function () { - return "[Entity: name: " + this.name + ", tag: " + this.tag + ", enabled: " + this.enabled + ", depth: " + this.updateOrder + "]"; - }; - Entity._idGenerator = 0; - return Entity; - }()); - es.Entity = Entity; -})(es || (es = {})); -var es; -(function (es) { - var Scene = (function (_super) { - __extends(Scene, _super); - function Scene() { - var _this = _super.call(this) || this; - _this.enablePostProcessing = true; - _this._sceneComponents = []; - _this._renderers = []; - _this._postProcessors = []; - _this.dynamicBatch = false; - _this.entities = new es.EntityList(_this); - _this.renderableComponents = new es.RenderableComponentList(); - _this.content = new es.ContentManager(); - _this.entityProcessors = new es.EntityProcessorList(); - _this.initialize(); - return _this; - } - Scene.createWithDefaultRenderer = function () { - var scene = new Scene(); - scene.addRenderer(new es.DefaultRenderer()); - return scene; - }; - Scene.prototype.initialize = function () { - }; - Scene.prototype.onStart = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2]; - }); - }); - }; - Scene.prototype.unload = function () { - }; - Scene.prototype.onActive = function () { - }; - Scene.prototype.onDeactive = function () { - }; - Scene.prototype.begin = function () { - if (this._renderers.length == 0) { - this.addRenderer(new es.DefaultRenderer()); - console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染"); - } - var cameraEntity = this.findEntity("camera"); - if (!cameraEntity) - cameraEntity = this.createEntity("camera"); - this.camera = cameraEntity.getOrCreateComponent(new es.Camera()); - es.Physics.reset(); - this.updateResolutionScaler(); - if (this.entityProcessors) - this.entityProcessors.begin(); - es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.updateResolutionScaler, this); - es.Core.emitter.addObserver(es.CoreEvents.OrientationChanged, this.updateResolutionScaler, this); - this.addEventListener(egret.Event.ACTIVATE, this.onActive, this); - this.addEventListener(egret.Event.DEACTIVATE, this.onDeactive, this); - this._didSceneBegin = true; - this.onStart(); - }; - Scene.prototype.end = function () { - this._didSceneBegin = false; - es.Core.emitter.removeObserver(es.CoreEvents.GraphicsDeviceReset, this.updateResolutionScaler); - es.Core.emitter.removeObserver(es.CoreEvents.OrientationChanged, this.updateResolutionScaler); - this.removeEventListener(egret.Event.DEACTIVATE, this.onDeactive, this); - this.removeEventListener(egret.Event.ACTIVATE, this.onActive, this); - for (var i = 0; i < this._renderers.length; i++) { - this._renderers[i].unload(); - } - for (var i = 0; i < this._postProcessors.length; i++) { - this._postProcessors[i].unload(); - } - this.entities.removeAllEntities(); - this.removeChildren(); - for (var i = 0; i < this._sceneComponents.length; i++) { - this._sceneComponents[i].onRemovedFromScene(); - } - this._sceneComponents.length = 0; - this.camera = null; - this.content.dispose(); - if (this.entityProcessors) - this.entityProcessors.end(); - if (this.parent) - this.parent.removeChild(this); - this.unload(); - }; - Scene.prototype.updateResolutionScaler = function () { - this.camera.onSceneRenderTargetSizeChanged(es.Core.Instance.stage.stageWidth, es.Core.Instance.stage.stageHeight); - }; - Scene.prototype.update = function () { - this.entities.updateLists(); - for (var i = this._sceneComponents.length - 1; i >= 0; i--) { - if (this._sceneComponents[i].enabled) - this._sceneComponents[i].update(); - } - if (this.entityProcessors) - this.entityProcessors.update(); - this.entities.update(); - if (this.entityProcessors) - this.entityProcessors.lateUpdate(); - this.renderableComponents.updateList(); - }; - Scene.prototype.render = function () { - if (this._renderers.length == 0) { - console.error("场景中没有渲染器!"); - return; - } - for (var i = 0; i < this._renderers.length; i++) { - this.camera.forceMatrixUpdate(); - this._renderers[i].render(this); - } - }; - Scene.prototype.dynamicInBatch = function () { - this.removeChildren(); - var batching = false; - var displayContainer; - for (var _i = 0, _a = this.renderableComponents.buffer; _i < _a.length; _i++) { - var component = _a[_i]; - if (component instanceof es.SpriteAnimator) { - this.addChild(component.displayObject); - this.addChild(component.debugDisplayObject); - batching = false; - displayContainer = null; - } - else if (component instanceof es.RenderableComponent) { - if (!batching) { - batching = true; - displayContainer = new egret.DisplayObjectContainer(); - displayContainer.cacheAsBitmap = true; - displayContainer.touchEnabled = false; - displayContainer.touchChildren = false; - this.addChild(displayContainer); - } - displayContainer.addChild(component.displayObject); - displayContainer.addChild(component.debugDisplayObject); - } - } - }; - Scene.prototype.postRender = function () { - if (this.enablePostProcessing) { - for (var i = 0; i < this._postProcessors.length; i++) { - if (this._postProcessors[i].enabled) { - this._postProcessors[i].process(); - } - } - } - if (this._screenshotRequestCallback) { - var tex = new egret.RenderTexture(); - tex.drawToTexture(this, new es.Rectangle(0, 0, this.stage.stageWidth, this.stage.stageHeight)); - this._screenshotRequestCallback(tex); - this._screenshotRequestCallback = null; - } - }; - Scene.prototype.requestScreenshot = function (callback) { - this._screenshotRequestCallback = callback; - }; - Scene.prototype.addSceneComponent = function (component) { - component.scene = this; - component.onEnabled(); - this._sceneComponents.push(component); - this._sceneComponents.sort(component.compareTo); - return component; - }; - Scene.prototype.getSceneComponent = function (type) { - for (var i = 0; i < this._sceneComponents.length; i++) { - var component = this._sceneComponents[i]; - if (component instanceof type) - return component; - } - return null; - }; - Scene.prototype.getOrCreateSceneComponent = function (type) { - var comp = this.getSceneComponent(type); - if (comp == null) - comp = this.addSceneComponent(new type()); - return comp; - }; - Scene.prototype.removeSceneComponent = function (component) { - if (!this._sceneComponents.contains(component)) { - console.warn("SceneComponent" + component + "\u4E0D\u5728SceneComponents\u5217\u8868\u4E2D!"); - return; - } - this._sceneComponents.remove(component); - component.onRemovedFromScene(); - }; - Scene.prototype.addRenderer = function (renderer) { - this._renderers.push(renderer); - this._renderers.sort(); - renderer.onAddedToScene(this); - return renderer; - }; - Scene.prototype.getRenderer = function (type) { - for (var i = 0; i < this._renderers.length; i++) { - if (this._renderers[i] instanceof type) - return this._renderers[i]; - } - return null; - }; - Scene.prototype.removeRenderer = function (renderer) { - if (!this._renderers.contains(renderer)) - return; - this._renderers.remove(renderer); - renderer.unload(); - }; - Scene.prototype.addPostProcessor = function (postProcessor) { - this._postProcessors.push(postProcessor); - this._postProcessors.sort(); - postProcessor.onAddedToScene(this); - if (this._didSceneBegin) { - postProcessor.onSceneBackBufferSizeChanged(this.stage.stageWidth, this.stage.stageHeight); - } - return postProcessor; - }; - Scene.prototype.getPostProcessor = function (type) { - for (var i = 0; i < this._postProcessors.length; i++) { - if (this._postProcessors[i] instanceof type) - return this._postProcessors[i]; - } - return null; - }; - Scene.prototype.removePostProcessor = function (postProcessor) { - if (!this._postProcessors.contains(postProcessor)) - return; - this._postProcessors.remove(postProcessor); - postProcessor.unload(); - }; - Scene.prototype.createEntity = function (name) { - var entity = new es.Entity(name); - return this.addEntity(entity); - }; - Scene.prototype.addEntity = function (entity) { - if (this.entities.buffer.contains(entity)) - console.warn("\u60A8\u8BD5\u56FE\u5C06\u540C\u4E00\u5B9E\u4F53\u6DFB\u52A0\u5230\u573A\u666F\u4E24\u6B21: " + entity); - this.entities.add(entity); - entity.scene = this; - for (var i = 0; i < entity.transform.childCount; i++) - this.addEntity(entity.transform.getChild(i).entity); - return entity; - }; - Scene.prototype.destroyAllEntities = function () { - for (var i = 0; i < this.entities.count; i++) { - this.entities.buffer[i].destroy(); - } - }; - Scene.prototype.findEntity = function (name) { - return this.entities.findEntity(name); - }; - Scene.prototype.findEntitiesWithTag = function (tag) { - return this.entities.entitiesWithTag(tag); - }; - Scene.prototype.entitiesOfType = function (type) { - return this.entities.entitiesOfType(type); - }; - Scene.prototype.findComponentOfType = function (type) { - return this.entities.findComponentOfType(type); - }; - Scene.prototype.findComponentsOfType = function (type) { - return this.entities.findComponentsOfType(type); - }; - Scene.prototype.addEntityProcessor = function (processor) { - processor.scene = this; - this.entityProcessors.add(processor); - return processor; - }; - Scene.prototype.removeEntityProcessor = function (processor) { - this.entityProcessors.remove(processor); - }; - Scene.prototype.getEntityProcessor = function () { - return this.entityProcessors.getProcessor(); - }; - return Scene; - }(egret.DisplayObjectContainer)); - es.Scene = Scene; -})(es || (es = {})); -var transform; -(function (transform) { - var Component; - (function (Component) { - Component[Component["position"] = 0] = "position"; - Component[Component["scale"] = 1] = "scale"; - Component[Component["rotation"] = 2] = "rotation"; - })(Component = transform.Component || (transform.Component = {})); -})(transform || (transform = {})); -var es; -(function (es) { - var HashObject = egret.HashObject; - var DirtyType; - (function (DirtyType) { - DirtyType[DirtyType["clean"] = 0] = "clean"; - DirtyType[DirtyType["positionDirty"] = 1] = "positionDirty"; - DirtyType[DirtyType["scaleDirty"] = 2] = "scaleDirty"; - DirtyType[DirtyType["rotationDirty"] = 3] = "rotationDirty"; - })(DirtyType = es.DirtyType || (es.DirtyType = {})); - var Transform = (function (_super) { - __extends(Transform, _super); - function Transform(entity) { - var _this = _super.call(this) || this; - _this._localTransform = es.Matrix2D.create(); - _this._worldTransform = es.Matrix2D.create().identity(); - _this._rotationMatrix = es.Matrix2D.create().identity(); - _this._translationMatrix = es.Matrix2D.create().identity(); - _this._scaleMatrix = es.Matrix2D.create().identity(); - _this._worldToLocalTransform = es.Matrix2D.create().identity(); - _this._worldInverseTransform = es.Matrix2D.create().identity(); - _this._position = es.Vector2.zero; - _this._scale = es.Vector2.one; - _this._rotation = 0; - _this._localPosition = es.Vector2.zero; - _this._localScale = es.Vector2.one; - _this._localRotation = 0; - _this.entity = entity; - _this.scale = _this._localScale = es.Vector2.one; - _this._children = []; - return _this; - } - Object.defineProperty(Transform.prototype, "childCount", { - get: function () { - return this._children.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "rotationDegrees", { - get: function () { - return es.MathHelper.toDegrees(this._rotation); - }, - set: function (value) { - this.setRotation(es.MathHelper.toRadians(value)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "localRotationDegrees", { - get: function () { - return es.MathHelper.toDegrees(this._localRotation); - }, - set: function (value) { - this.localRotation = es.MathHelper.toRadians(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "localToWorldTransform", { - get: function () { - this.updateTransform(); - return this._worldTransform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "parent", { - get: function () { - return this._parent; - }, - set: function (value) { - this.setParent(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "worldToLocalTransform", { - get: function () { - if (this._worldToLocalDirty) { - if (!this.parent) { - this._worldToLocalTransform = es.Matrix2D.create().identity(); - } - else { - this.parent.updateTransform(); - this._worldToLocalTransform = this.parent._worldTransform.invert(); - } - this._worldToLocalDirty = false; - } - return this._worldToLocalTransform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "worldInverseTransform", { - get: function () { - this.updateTransform(); - if (this._worldInverseDirty) { - this._worldInverseTransform = this._worldTransform.invert(); - this._worldInverseDirty = false; - } - return this._worldInverseTransform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "position", { - get: function () { - this.updateTransform(); - if (this._positionDirty) { - if (!this.parent) { - this._position = this._localPosition; - } - else { - this.parent.updateTransform(); - es.Vector2Ext.transformR(this._localPosition, this.parent._worldTransform, this._position); - } - this._positionDirty = false; - } - return this._position; - }, - set: function (value) { - this.setPosition(value.x, value.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "scale", { - get: function () { - this.updateTransform(); - return this._scale; - }, - set: function (value) { - this.setScale(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "rotation", { - get: function () { - this.updateTransform(); - return this._rotation; - }, - set: function (value) { - this.setRotation(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "localPosition", { - get: function () { - this.updateTransform(); - return this._localPosition; - }, - set: function (value) { - this.setLocalPosition(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "localScale", { - get: function () { - this.updateTransform(); - return this._localScale; - }, - set: function (value) { - this.setLocalScale(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "localRotation", { - get: function () { - this.updateTransform(); - return this._localRotation; - }, - set: function (value) { - this.setLocalRotation(value); - }, - enumerable: true, - configurable: true - }); - Transform.prototype.getChild = function (index) { - return this._children[index]; - }; - Transform.prototype.setParent = function (parent) { - if (this._parent.equals(parent)) - return this; - if (!this._parent) { - this._parent._children.remove(this); - this._parent._children.push(this); - } - this._parent = parent; - this.setDirty(DirtyType.positionDirty); - return this; - }; - Transform.prototype.setPosition = function (x, y) { - var position = new es.Vector2(x, y); - if (position.equals(this._position)) - return this; - this._position = position; - if (this.parent) { - this.localPosition = es.Vector2.transform(this._position, this._worldToLocalTransform); - } - else { - this.localPosition = position; - } - this._positionDirty = false; - return this; - }; - Transform.prototype.setLocalPosition = function (localPosition) { - if (localPosition.equals(this._localPosition)) - return this; - this._localPosition = localPosition; - this._localDirty = this._positionDirty = this._localPositionDirty = this._localRotationDirty = this._localScaleDirty = true; - this.setDirty(DirtyType.positionDirty); - return this; - }; - Transform.prototype.setRotation = function (radians) { - this._rotation = radians; - if (this.parent) { - this.localRotation = this.parent.rotation + radians; - } - else { - this.localRotation = radians; - } - return this; - }; - Transform.prototype.setRotationDegrees = function (degrees) { - return this.setRotation(es.MathHelper.toRadians(degrees)); - }; - Transform.prototype.lookAt = function (pos) { - var sign = this.position.x > pos.x ? -1 : 1; - var vectorToAlignTo = es.Vector2.normalize(es.Vector2.subtract(this.position, pos)); - this.rotation = sign * Math.acos(es.Vector2.dot(vectorToAlignTo, es.Vector2.unitY)); - }; - Transform.prototype.setLocalRotation = function (radians) { - this._localRotation = radians; - this._localDirty = this._positionDirty = this._localPositionDirty = this._localRotationDirty = this._localScaleDirty = true; - this.setDirty(DirtyType.rotationDirty); - return this; - }; - Transform.prototype.setLocalRotationDegrees = function (degrees) { - return this.setLocalRotation(es.MathHelper.toRadians(degrees)); - }; - Transform.prototype.setScale = function (scale) { - this._scale = scale; - if (this.parent) { - this.localScale = es.Vector2.divide(scale, this.parent._scale); - } - else { - this.localScale = scale; - } - return this; - }; - Transform.prototype.setLocalScale = function (scale) { - this._localScale = scale; - this._localDirty = this._positionDirty = this._localScaleDirty = true; - this.setDirty(DirtyType.scaleDirty); - return this; - }; - Transform.prototype.roundPosition = function () { - this.position = this._position.round(); - }; - Transform.prototype.updateTransform = function () { - if (this.hierarchyDirty != DirtyType.clean) { - if (this.parent) - this.parent.updateTransform(); - if (this._localDirty) { - if (this._localPositionDirty) { - this._translationMatrix = es.Matrix2D.create().translate(this._localPosition.x, this._localPosition.y); - this._localPositionDirty = false; - } - if (this._localRotationDirty) { - this._rotationMatrix = es.Matrix2D.create().rotate(this._localRotation); - this._localRotationDirty = false; - } - if (this._localScaleDirty) { - this._scaleMatrix = es.Matrix2D.create().scale(this._localScale.x, this._localScale.y); - this._localScaleDirty = false; - } - this._localTransform = this._scaleMatrix.multiply(this._rotationMatrix); - this._localTransform = this._localTransform.multiply(this._translationMatrix); - if (!this.parent) { - this._worldTransform = this._localTransform; - this._rotation = this._localRotation; - this._scale = this._localScale; - this._worldInverseDirty = true; - } - this._localDirty = false; - } - if (this.parent) { - this._worldTransform = this._localTransform.multiply(this.parent._worldTransform); - this._rotation = this._localRotation + this.parent._rotation; - this._scale = es.Vector2.multiply(this.parent._scale, this._localScale); - this._worldInverseDirty = true; - } - this._worldToLocalDirty = true; - this._positionDirty = true; - this.hierarchyDirty = DirtyType.clean; - } - }; - Transform.prototype.setDirty = function (dirtyFlagType) { - if ((this.hierarchyDirty & dirtyFlagType) == 0) { - this.hierarchyDirty |= dirtyFlagType; - switch (dirtyFlagType) { - case es.DirtyType.positionDirty: - this.entity.onTransformChanged(transform.Component.position); - break; - case es.DirtyType.rotationDirty: - this.entity.onTransformChanged(transform.Component.rotation); - break; - case es.DirtyType.scaleDirty: - this.entity.onTransformChanged(transform.Component.scale); - break; - } - if (!this._children) - this._children = []; - for (var i = 0; i < this._children.length; i++) - this._children[i].setDirty(dirtyFlagType); - } - }; - Transform.prototype.copyFrom = function (transform) { - this._position = transform.position; - this._localPosition = transform._localPosition; - this._rotation = transform._rotation; - this._localRotation = transform._localRotation; - this._scale = transform._scale; - this._localScale = transform._localScale; - this.setDirty(DirtyType.positionDirty); - this.setDirty(DirtyType.rotationDirty); - this.setDirty(DirtyType.scaleDirty); - }; - Transform.prototype.toString = function () { - return "[Transform: parent: " + this.parent + ", position: " + this.position + ", rotation: " + this.rotation + ",\n scale: " + this.scale + ", localPosition: " + this._localPosition + ", localRotation: " + this._localRotation + ",\n localScale: " + this._localScale + "]"; - }; - Transform.prototype.equals = function (other) { - return other.hashCode == this.hashCode; - }; - return Transform; - }(HashObject)); - es.Transform = Transform; -})(es || (es = {})); -var es; -(function (es) { - var Camera = (function (_super) { - __extends(Camera, _super); - function Camera() { - var _this = _super.call(this) || this; - _this._inset = { left: 0, right: 0, top: 0, bottom: 0 }; - _this._areMatrixedDirty = true; - _this._areBoundsDirty = true; - _this._isProjectionMatrixDirty = true; - _this._zoom = 0; - _this._minimumZoom = 0.3; - _this._maximumZoom = 3; - _this._bounds = new es.Rectangle(); - _this._transformMatrix = new es.Matrix2D().identity(); - _this._inverseTransformMatrix = new es.Matrix2D().identity(); - _this._origin = es.Vector2.zero; - _this.setZoom(0); - return _this; - } - Object.defineProperty(Camera.prototype, "position", { - get: function () { - return this.entity.transform.position; - }, - set: function (value) { - this.entity.transform.position = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "rotation", { - get: function () { - return this.entity.transform.rotation; - }, - set: function (value) { - this.entity.transform.rotation = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "rawZoom", { - get: function () { - return this._zoom; - }, - set: function (value) { - if (value != this._zoom) { - this._zoom = value; - this._areMatrixedDirty = true; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "zoom", { - get: function () { - if (this._zoom == 0) - return 1; - if (this._zoom < 1) - return es.MathHelper.map(this._zoom, this._minimumZoom, 1, -1, 0); - return es.MathHelper.map(this._zoom, 1, this._maximumZoom, 0, 1); - }, - set: function (value) { - this.setZoom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "minimumZoom", { - get: function () { - return this._minimumZoom; - }, - set: function (value) { - this.setMinimumZoom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "maximumZoom", { - get: function () { - return this._maximumZoom; - }, - set: function (value) { - this.setMaximumZoom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "bounds", { - get: function () { - if (this._areMatrixedDirty) - this.updateMatrixes(); - if (this._areBoundsDirty) { - var topLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, this._inset.top)); - var bottomRight = this.screenToWorldPoint(new es.Vector2(es.Core.graphicsDevice.viewport.width - this._inset.right, es.Core.graphicsDevice.viewport.height - this._inset.bottom)); - if (this.entity.transform.rotation != 0) { - var topRight = this.screenToWorldPoint(new es.Vector2(es.Core.graphicsDevice.viewport.width - this._inset.right, this._inset.top)); - var bottomLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, es.Core.graphicsDevice.viewport.height - this._inset.bottom)); - var minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - var maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - var minY = Math.min(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - var maxY = Math.max(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - this._bounds.location = new es.Vector2(minX, minY); - this._bounds.width = maxX - minX; - this._bounds.height = maxY - minY; - } - else { - this._bounds.location = topLeft; - this._bounds.width = bottomRight.x - topLeft.x; - this._bounds.height = bottomRight.y - topLeft.y; - } - this._areBoundsDirty = false; - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "transformMatrix", { - get: function () { - if (this._areMatrixedDirty) - this.updateMatrixes(); - return this._transformMatrix; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "inverseTransformMatrix", { - get: function () { - if (this._areMatrixedDirty) - this.updateMatrixes(); - return this._inverseTransformMatrix; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "origin", { - get: function () { - return this._origin; - }, - set: function (value) { - if (this._origin != value) { - this._origin = value; - this._areMatrixedDirty = true; - } - }, - enumerable: true, - configurable: true - }); - Camera.prototype.setInset = function (left, right, top, bottom) { - this._inset = { left: left, right: right, top: top, bottom: bottom }; - this._areBoundsDirty = true; - return this; - }; - Camera.prototype.setPosition = function (position) { - this.entity.transform.setPosition(position.x, position.y); - return this; - }; - Camera.prototype.setRotation = function (rotation) { - this.entity.transform.setRotation(rotation); - return this; - }; - Camera.prototype.setZoom = function (zoom) { - var newZoom = es.MathHelper.clamp(zoom, -1, 1); - if (newZoom == 0) { - this._zoom = 1; - } - else if (newZoom < 0) { - this._zoom = es.MathHelper.map(newZoom, -1, 0, this._minimumZoom, 1); - } - else { - this._zoom = es.MathHelper.map(newZoom, 0, 1, 1, this._maximumZoom); - } - this._areMatrixedDirty = true; - return this; - }; - Camera.prototype.setMinimumZoom = function (minZoom) { - if (minZoom <= 0) { - console.error("minimumZoom must be greater than zero"); - return; - } - if (this._zoom < minZoom) - this._zoom = this.minimumZoom; - this._minimumZoom = minZoom; - return this; - }; - Camera.prototype.setMaximumZoom = function (maxZoom) { - if (maxZoom <= 0) { - console.error("maximumZoom must be greater than zero"); - return; - } - if (this._zoom > maxZoom) - this._zoom = maxZoom; - this._maximumZoom = maxZoom; - return this; - }; - Camera.prototype.forceMatrixUpdate = function () { - this._areMatrixedDirty = true; - }; - Camera.prototype.onEntityTransformChanged = function (comp) { - this._areMatrixedDirty = true; - }; - Camera.prototype.zoomIn = function (deltaZoom) { - this.zoom += deltaZoom; - }; - Camera.prototype.zoomOut = function (deltaZoom) { - this.zoom -= deltaZoom; - }; - Camera.prototype.worldToScreenPoint = function (worldPosition) { - this.updateMatrixes(); - es.Vector2Ext.transformR(worldPosition, this._transformMatrix, worldPosition); - return worldPosition; - }; - Camera.prototype.screenToWorldPoint = function (screenPosition) { - this.updateMatrixes(); - es.Vector2Ext.transformR(screenPosition, this._inverseTransformMatrix, screenPosition); - return screenPosition; - }; - Camera.prototype.onSceneRenderTargetSizeChanged = function (newWidth, newHeight) { - this._isProjectionMatrixDirty = true; - var oldOrigin = this._origin; - this.origin = new es.Vector2(newWidth / 2, newHeight / 2); - this.entity.transform.position.add(es.Vector2.subtract(this._origin, oldOrigin)); - }; - Camera.prototype.mouseToWorldPoint = function () { - return this.screenToWorldPoint(es.Input.touchPosition); - }; - Camera.prototype.updateMatrixes = function () { - if (!this._areMatrixedDirty) - return; - var tempMat; - this._transformMatrix = es.Matrix2D.create().translate(-this.entity.transform.position.x, -this.entity.transform.position.y); - if (this._zoom != 1) { - tempMat = es.Matrix2D.create().scale(this._zoom, this._zoom); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - } - if (this.entity.transform.rotation != 0) { - tempMat = es.Matrix2D.create().rotate(this.entity.transform.rotation); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - } - tempMat = es.Matrix2D.create().translate(Math.floor(this._origin.x), Math.floor(this._origin.y)); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - this._inverseTransformMatrix = this._transformMatrix.invert(); - this._areBoundsDirty = true; - this._areMatrixedDirty = false; - }; - return Camera; - }(es.Component)); - es.Camera = Camera; -})(es || (es = {})); -var es; -(function (es) { - var CameraShake = (function (_super) { - __extends(CameraShake, _super); - function CameraShake() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._shakeDirection = es.Vector2.zero; - _this._shakeOffset = es.Vector2.zero; - _this._shakeIntensity = 0; - _this._shakeDegredation = 0.95; - return _this; - } - CameraShake.prototype.shake = function (shakeIntensify, shakeDegredation, shakeDirection) { - if (shakeIntensify === void 0) { shakeIntensify = 15; } - if (shakeDegredation === void 0) { shakeDegredation = 0.9; } - if (shakeDirection === void 0) { shakeDirection = es.Vector2.zero; } - this.enabled = true; - if (this._shakeIntensity < shakeIntensify) { - this._shakeDirection = shakeDirection; - this._shakeIntensity = shakeIntensify; - if (shakeDegredation < 0 || shakeDegredation >= 1) { - shakeDegredation = 0.95; - } - this._shakeDegredation = shakeDegredation; - } - }; - CameraShake.prototype.update = function () { - if (Math.abs(this._shakeIntensity) > 0) { - this._shakeOffset = this._shakeDirection; - if (this._shakeOffset.x != 0 || this._shakeOffset.y != 0) { - this._shakeOffset.normalize(); - } - else { - this._shakeOffset.x = this._shakeOffset.x + Math.random() - 0.5; - this._shakeOffset.y = this._shakeOffset.y + Math.random() - 0.5; - } - this._shakeOffset.multiply(new es.Vector2(this._shakeIntensity)); - this._shakeIntensity *= -this._shakeDegredation; - if (Math.abs(this._shakeIntensity) <= 0.01) { - this._shakeIntensity = 0; - this.enabled = false; - } - } - this.entity.scene.camera.position.add(this._shakeOffset); - }; - return CameraShake; - }(es.Component)); - es.CameraShake = CameraShake; -})(es || (es = {})); -var es; -(function (es) { - var ComponentPool = (function () { - function ComponentPool(typeClass) { - this._type = typeClass; - this._cache = []; - } - ComponentPool.prototype.obtain = function () { - try { - return this._cache.length > 0 ? this._cache.shift() : new this._type(); - } - catch (err) { - throw new Error(this._type + err); - } - }; - ComponentPool.prototype.free = function (component) { - component.reset(); - this._cache.push(component); - }; - return ComponentPool; - }()); - es.ComponentPool = ComponentPool; -})(es || (es = {})); -var es; -(function (es) { - var CameraStyle; - (function (CameraStyle) { - CameraStyle[CameraStyle["lockOn"] = 0] = "lockOn"; - CameraStyle[CameraStyle["cameraWindow"] = 1] = "cameraWindow"; - })(CameraStyle = es.CameraStyle || (es.CameraStyle = {})); - var FollowCamera = (function (_super) { - __extends(FollowCamera, _super); - function FollowCamera(targetEntity, camera, cameraStyle) { - if (targetEntity === void 0) { targetEntity = null; } - if (camera === void 0) { camera = null; } - if (cameraStyle === void 0) { cameraStyle = CameraStyle.lockOn; } - var _this = _super.call(this) || this; - _this.followLerp = 0.1; - _this.deadzone = new es.Rectangle(); - _this.focusOffset = es.Vector2.zero; - _this.mapLockEnabled = false; - _this.mapSize = new es.Rectangle(); - _this._desiredPositionDelta = new es.Vector2(); - _this._worldSpaceDeadZone = new es.Rectangle(); - _this.rectShape = new egret.Shape(); - _this._targetEntity = targetEntity; - _this._cameraStyle = cameraStyle; - _this.camera = camera; - return _this; - } - FollowCamera.prototype.onAddedToEntity = function () { - if (!this.camera) - this.camera = this.entity.scene.camera; - this.follow(this._targetEntity, this._cameraStyle); - es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this); - }; - FollowCamera.prototype.onGraphicsDeviceReset = function () { - es.Core.schedule(0, false, this, function (t) { - var self = t.context; - self.follow(self._targetEntity, self._cameraStyle); - }); - }; - FollowCamera.prototype.update = function () { - var halfScreen = es.Vector2.multiply(this.camera.bounds.size, new es.Vector2(0.5)); - this._worldSpaceDeadZone.x = this.camera.position.x - halfScreen.x * es.Core.scene.scaleX + this.deadzone.x + this.focusOffset.x; - this._worldSpaceDeadZone.y = this.camera.position.y - halfScreen.y * es.Core.scene.scaleY + this.deadzone.y + this.focusOffset.y; - this._worldSpaceDeadZone.width = this.deadzone.width; - this._worldSpaceDeadZone.height = this.deadzone.height; - if (this._targetEntity) - this.updateFollow(); - this.camera.position = es.Vector2.lerp(this.camera.position, es.Vector2.add(this.camera.position, this._desiredPositionDelta), this.followLerp); - this.entity.transform.roundPosition(); - if (this.mapLockEnabled) { - this.camera.position = this.clampToMapSize(this.camera.position); - this.entity.transform.roundPosition(); - } - }; - FollowCamera.prototype.debugRender = function (camera) { - if (!this.rectShape) - this.debugDisplayObject.addChild(this.rectShape); - this.rectShape.graphics.clear(); - if (this._cameraStyle == CameraStyle.lockOn) { - this.rectShape.graphics.beginFill(0x8B0000, 0); - this.rectShape.graphics.lineStyle(1, 0x8B0000); - this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x - 5 - camera.bounds.x, this._worldSpaceDeadZone.y - 5 - camera.bounds.y, this._worldSpaceDeadZone.width, this._worldSpaceDeadZone.height); - this.rectShape.graphics.endFill(); - } - else { - this.rectShape.graphics.beginFill(0x8B0000, 0); - this.rectShape.graphics.lineStyle(1, 0x8B0000); - this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x - camera.bounds.x, this._worldSpaceDeadZone.y - camera.bounds.y, this._worldSpaceDeadZone.width, this._worldSpaceDeadZone.height); - this.rectShape.graphics.endFill(); - } - }; - FollowCamera.prototype.clampToMapSize = function (position) { - var halfScreen = es.Vector2.multiply(this.camera.bounds.size, new es.Vector2(0.5)).add(new es.Vector2(this.mapSize.x, this.mapSize.y)); - var cameraMax = new es.Vector2(this.mapSize.width - halfScreen.x, this.mapSize.height - halfScreen.y); - return es.Vector2.clamp(position, halfScreen, cameraMax); - }; - FollowCamera.prototype.follow = function (targetEntity, cameraStyle) { - if (cameraStyle === void 0) { cameraStyle = CameraStyle.cameraWindow; } - this._targetEntity = targetEntity; - this._cameraStyle = cameraStyle; - var cameraBounds = this.camera.bounds; - switch (this._cameraStyle) { - case CameraStyle.cameraWindow: - var w = cameraBounds.width / 6; - var h = cameraBounds.height / 3; - this.deadzone = new es.Rectangle((cameraBounds.width - w) / 2, (cameraBounds.height - h) / 2, w, h); - break; - case CameraStyle.lockOn: - this.deadzone = new es.Rectangle(cameraBounds.width / 2, cameraBounds.height / 2, 10, 10); - break; - } - }; - FollowCamera.prototype.updateFollow = function () { - this._desiredPositionDelta.x = this._desiredPositionDelta.y = 0; - if (this._cameraStyle == CameraStyle.lockOn) { - var targetX = this._targetEntity.transform.position.x; - var targetY = this._targetEntity.transform.position.y; - if (this._worldSpaceDeadZone.x > targetX) - this._desiredPositionDelta.x = targetX - this._worldSpaceDeadZone.x; - else if (this._worldSpaceDeadZone.x < targetX) - this._desiredPositionDelta.x = targetX - this._worldSpaceDeadZone.x; - if (this._worldSpaceDeadZone.y < targetY) - this._desiredPositionDelta.y = targetY - this._worldSpaceDeadZone.y; - else if (this._worldSpaceDeadZone.y > targetY) - this._desiredPositionDelta.y = targetY - this._worldSpaceDeadZone.y; - } - else { - if (!this._targetCollider) { - this._targetCollider = this._targetEntity.getComponent(es.Collider); - if (!this._targetCollider) - return; - } - var targetBounds = this._targetEntity.getComponent(es.Collider).bounds; - if (!this._worldSpaceDeadZone.containsRect(targetBounds)) { - if (this._worldSpaceDeadZone.left > targetBounds.left) - this._desiredPositionDelta.x = targetBounds.left - this._worldSpaceDeadZone.left; - else if (this._worldSpaceDeadZone.right < targetBounds.right) - this._desiredPositionDelta.x = targetBounds.right - this._worldSpaceDeadZone.right; - if (this._worldSpaceDeadZone.bottom < targetBounds.bottom) - this._desiredPositionDelta.y = targetBounds.bottom - this._worldSpaceDeadZone.bottom; - else if (this._worldSpaceDeadZone.top > targetBounds.top) - this._desiredPositionDelta.y = targetBounds.top - this._worldSpaceDeadZone.top; - } - } - }; - FollowCamera.prototype.setCenteredDeadzone = function (width, height) { - if (!this.camera) { - console.error("相机是null。我们不能得到它的边界。请等到该组件添加到实体之后"); - return; - } - var cameraBounds = this.camera.bounds; - this.deadzone = new es.Rectangle((cameraBounds.width - width) / 2, (cameraBounds.height - height) / 2, width, height); - }; - return FollowCamera; - }(es.Component)); - es.FollowCamera = FollowCamera; -})(es || (es = {})); -var es; -(function (es) { - var IUpdatableComparer = (function () { - function IUpdatableComparer() { - } - IUpdatableComparer.prototype.compare = function (a, b) { - return a.updateOrder - b.updateOrder; - }; - return IUpdatableComparer; - }()); - es.IUpdatableComparer = IUpdatableComparer; -})(es || (es = {})); -var es; -(function (es) { - var PooledComponent = (function (_super) { - __extends(PooledComponent, _super); - function PooledComponent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return PooledComponent; - }(es.Component)); - es.PooledComponent = PooledComponent; -})(es || (es = {})); -var es; -(function (es) { - var SceneComponent = (function () { - function SceneComponent() { - this.updateOrder = 0; - this._enabled = true; - } - Object.defineProperty(SceneComponent.prototype, "enabled", { - get: function () { - return this._enabled; - }, - set: function (value) { - this.setEnabled(value); - }, - enumerable: true, - configurable: true - }); - SceneComponent.prototype.onEnabled = function () { - }; - SceneComponent.prototype.onDisabled = function () { - }; - SceneComponent.prototype.onRemovedFromScene = function () { - }; - SceneComponent.prototype.update = function () { - }; - SceneComponent.prototype.setEnabled = function (isEnabled) { - if (this._enabled != isEnabled) { - this._enabled = isEnabled; - if (this._enabled) { - } - else { - } - } - return this; - }; - SceneComponent.prototype.setUpdateOrder = function (updateOrder) { - if (this.updateOrder != updateOrder) { - this.updateOrder = updateOrder; - es.Core.scene._sceneComponents.sort(this.compareTo); - } - return this; - }; - SceneComponent.prototype.compareTo = function (other) { - return this.updateOrder - other.updateOrder; - }; - return SceneComponent; - }()); - es.SceneComponent = SceneComponent; -})(es || (es = {})); -var es; -(function (es) { - var Mover = (function (_super) { - __extends(Mover, _super); - function Mover() { - return _super !== null && _super.apply(this, arguments) || this; - } - Mover.prototype.onAddedToEntity = function () { - this._triggerHelper = new es.ColliderTriggerHelper(this.entity); - }; - Mover.prototype.calculateMovement = function (motion, collisionResult) { - if (!this.entity.getComponent(es.Collider) || !this._triggerHelper) { - return false; - } - var colliders = this.entity.getComponents(es.Collider); - for (var i = 0; i < colliders.length; i++) { - var collider = colliders[i]; - if (collider.isTrigger) - continue; - var bounds = collider.bounds; - bounds.x += motion.x; - bounds.y += motion.y; - var neighbors = es.Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers.value); - for (var j = 0; j < neighbors.length; j++) { - var neighbor = neighbors[j]; - if (neighbor.isTrigger) - continue; - var _internalcollisionResult = new es.CollisionResult(); - if (collider.collidesWith(neighbor, motion, _internalcollisionResult)) { - motion = motion.subtract(_internalcollisionResult.minimumTranslationVector); - if (_internalcollisionResult.collider != null) { - collisionResult = _internalcollisionResult; - } - } - } - } - es.ListPool.free(colliders); - return collisionResult.collider != null; - }; - Mover.prototype.applyMovement = function (motion) { - this.entity.position = es.Vector2.add(this.entity.position, motion); - if (this._triggerHelper) - this._triggerHelper.update(); - }; - Mover.prototype.move = function (motion, collisionResult) { - this.calculateMovement(motion, collisionResult); - this.applyMovement(motion); - return collisionResult.collider != null; - }; - return Mover; - }(es.Component)); - es.Mover = Mover; -})(es || (es = {})); -var es; -(function (es) { - var ProjectileMover = (function (_super) { - __extends(ProjectileMover, _super); - function ProjectileMover() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._tempTriggerList = []; - return _this; - } - ProjectileMover.prototype.onAddedToEntity = function () { - this._collider = this.entity.getComponent(es.Collider); - if (!this._collider) - console.warn("ProjectileMover has no Collider. ProjectilMover requires a Collider!"); - }; - ProjectileMover.prototype.move = function (motion) { - if (!this._collider) - return false; - var didCollide = false; - this.entity.position.add(motion); - var neighbors = es.Physics.boxcastBroadphase(this._collider.bounds, this._collider.collidesWithLayers.value); - for (var _i = 0, neighbors_1 = neighbors; _i < neighbors_1.length; _i++) { - var neighbor = neighbors_1[_i]; - if (this._collider.overlaps(neighbor) && neighbor.enabled) { - didCollide = true; - this.notifyTriggerListeners(this._collider, neighbor); - } - } - return didCollide; - }; - ProjectileMover.prototype.notifyTriggerListeners = function (self, other) { - other.entity.getComponents("ITriggerListener", this._tempTriggerList); - for (var i = 0; i < this._tempTriggerList.length; i++) { - this._tempTriggerList[i].onTriggerEnter(self, other); - } - this._tempTriggerList.length = 0; - this.entity.getComponents("ITriggerListener", this._tempTriggerList); - for (var i = 0; i < this._tempTriggerList.length; i++) { - this._tempTriggerList[i].onTriggerEnter(other, self); - } - this._tempTriggerList.length = 0; - }; - return ProjectileMover; - }(es.Component)); - es.ProjectileMover = ProjectileMover; -})(es || (es = {})); -var es; -(function (es) { - var Collider = (function (_super) { - __extends(Collider, _super); - function Collider() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.physicsLayer = new es.Ref(1 << 0); - _this.collidesWithLayers = new es.Ref(es.Physics.allLayers); - _this.shouldColliderScaleAndRotateWithTransform = true; - _this.registeredPhysicsBounds = new es.Rectangle(); - _this._isPositionDirty = true; - _this._isRotationDirty = true; - _this._localOffset = es.Vector2.zero; - return _this; - } - Object.defineProperty(Collider.prototype, "absolutePosition", { - get: function () { - return es.Vector2.add(this.entity.transform.position, this._localOffset); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Collider.prototype, "rotation", { - get: function () { - if (this.shouldColliderScaleAndRotateWithTransform && this.entity) - return this.entity.transform.rotation; - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Collider.prototype, "bounds", { - get: function () { - if (this._isPositionDirty || this._isRotationDirty) { - this.shape.recalculateBounds(this); - this._isPositionDirty = this._isRotationDirty = false; - } - return this.shape.bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Collider.prototype, "localOffset", { - get: function () { - return this._localOffset; - }, - set: function (value) { - this.setLocalOffset(value); - }, - enumerable: true, - configurable: true - }); - Collider.prototype.setLocalOffset = function (offset) { - if (this._localOffset != offset) { - this.unregisterColliderWithPhysicsSystem(); - this._localOffset = offset; - this._localOffsetLength = this._localOffset.length(); - this._isPositionDirty = true; - this.registerColliderWithPhysicsSystem(); - } - return this; - }; - Collider.prototype.setShouldColliderScaleAndRotateWithTransform = function (shouldColliderScaleAndRotationWithTransform) { - this.shouldColliderScaleAndRotateWithTransform = shouldColliderScaleAndRotationWithTransform; - this._isPositionDirty = this._isRotationDirty = true; - return this; - }; - Collider.prototype.onAddedToEntity = function () { - if (this._colliderRequiresAutoSizing) { - if (!(this instanceof es.BoxCollider || this instanceof es.CircleCollider)) { - console.error("Only box and circle colliders can be created automatically"); - return; - } - var renderable = this.entity.getComponent(es.RenderableComponent); - if (renderable) { - var renderableBounds = renderable.bounds; - var width = renderableBounds.width / this.entity.transform.scale.x; - var height = renderableBounds.height / this.entity.transform.scale.y; - if (this instanceof es.CircleCollider) { - this.radius = Math.max(width, height) * 0.5; - } - else { - this.width = width; - this.height = height; - } - this.localOffset = es.Vector2.subtract(renderableBounds.center, this.entity.transform.position); - } - else { - console.warn("碰撞器没有形状和RenderableComponent。不知道如何调整大小."); - } - } - this._isParentEntityAddedToScene = true; - this.registerColliderWithPhysicsSystem(); - }; - Collider.prototype.onRemovedFromEntity = function () { - this.unregisterColliderWithPhysicsSystem(); - this._isParentEntityAddedToScene = false; - }; - Collider.prototype.onEntityTransformChanged = function (comp) { - switch (comp) { - case transform.Component.position: - this._isPositionDirty = true; - break; - case transform.Component.scale: - this._isPositionDirty = true; - break; - case transform.Component.rotation: - this._isRotationDirty = true; - break; - } - if (this._isColliderRegistered) - es.Physics.updateCollider(this); - }; - Collider.prototype.onEnabled = function () { - this.registerColliderWithPhysicsSystem(); - this._isPositionDirty = this._isRotationDirty = true; - }; - Collider.prototype.onDisabled = function () { - this.unregisterColliderWithPhysicsSystem(); - }; - Collider.prototype.registerColliderWithPhysicsSystem = function () { - if (this._isParentEntityAddedToScene && !this._isColliderRegistered) { - es.Physics.addCollider(this); - this._isColliderRegistered = true; - } - }; - Collider.prototype.unregisterColliderWithPhysicsSystem = function () { - if (this._isParentEntityAddedToScene && this._isColliderRegistered) { - es.Physics.removeCollider(this); - } - this._isColliderRegistered = false; - }; - Collider.prototype.overlaps = function (other) { - return this.shape.overlaps(other.shape); - }; - Collider.prototype.collidesWith = function (collider, motion, result) { - var oldPosition = this.entity.position; - this.entity.position.add(motion); - var didCollide = this.shape.collidesWithShape(collider.shape, result); - if (didCollide) - result.collider = collider; - this.entity.position = oldPosition; - return didCollide; - }; - return Collider; - }(es.Component)); - es.Collider = Collider; -})(es || (es = {})); -var es; -(function (es) { - var BoxCollider = (function (_super) { - __extends(BoxCollider, _super); - function BoxCollider(x, y, width, height) { - var _this = _super.call(this) || this; - _this.hollowShape = new egret.Shape(); - _this.polygonShape = new egret.Shape(); - _this.pixelShape1 = new egret.Shape(); - _this.pixelShape2 = new egret.Shape(); - if (x == undefined && y == undefined) { - if (width == undefined && height == undefined) { - _this.shape = new es.Box(1, 1); - _this._colliderRequiresAutoSizing = true; - } - else if (width != undefined && height != undefined) { - x = -width / 2; - y = -height / 2; - _this._localOffset = new es.Vector2(x + width / 2, y + height / 2); - _this.shape = new es.Box(width, height); - } - } - else if (x != undefined && y != undefined && width != undefined && height != undefined) { - _this._localOffset = new es.Vector2(x + width / 2, y + height / 2); - _this.shape = new es.Box(width, height); - } - return _this; - } - Object.defineProperty(BoxCollider.prototype, "width", { - get: function () { - return this.shape.width; - }, - set: function (value) { - this.setWidth(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BoxCollider.prototype, "height", { - get: function () { - return this.shape.height; - }, - set: function (value) { - this.setHeight(value); - }, - enumerable: true, - configurable: true - }); - BoxCollider.prototype.setSize = function (width, height) { - this._colliderRequiresAutoSizing = false; - var box = this.shape; - if (width != box.width || height != box.height) { - box.updateBox(width, height); - if (this.entity && this._isParentEntityAddedToScene) - es.Physics.updateCollider(this); - } - return this; - }; - BoxCollider.prototype.setWidth = function (width) { - this._colliderRequiresAutoSizing = false; - var box = this.shape; - if (width != box.width) { - box.updateBox(width, box.height); - if (this.entity && this._isParentEntityAddedToScene) - es.Physics.updateCollider(this); - } - return this; - }; - BoxCollider.prototype.setHeight = function (height) { - this._colliderRequiresAutoSizing = false; - var box = this.shape; - if (height != box.height) { - box.updateBox(box.width, height); - if (this.entity && this._isParentEntityAddedToScene) - es.Physics.updateCollider(this); - } - }; - BoxCollider.prototype.debugRender = function (camera) { - var poly = this.shape; - if (!this.hollowShape.parent) - this.debugDisplayObject.addChild(this.hollowShape); - if (!this.polygonShape.parent) - this.debugDisplayObject.addChild(this.polygonShape); - if (!this.pixelShape1.parent) - this.debugDisplayObject.addChild(this.pixelShape1); - if (!this.pixelShape2.parent) - this.debugDisplayObject.addChild(this.pixelShape2); - this.hollowShape.graphics.clear(); - this.hollowShape.graphics.beginFill(es.Colors.colliderBounds, 0); - this.hollowShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderBounds); - this.hollowShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.hollowShape.graphics.endFill(); - this.polygonShape.graphics.clear(); - if (poly.points.length >= 2) { - this.polygonShape.graphics.beginFill(es.Colors.colliderEdge, 0); - this.polygonShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderEdge); - for (var i = 0; i < poly.points.length; i++) { - if (i == 0) { - this.polygonShape.graphics.moveTo(poly.position.x + poly.points[i].x - camera.bounds.x, poly.position.y + poly.points[i].y - camera.bounds.y); - } - else { - this.polygonShape.graphics.lineTo(poly.position.x + poly.points[i].x - camera.bounds.x, poly.position.y + poly.points[i].y - camera.bounds.y); - } - } - this.polygonShape.graphics.lineTo(poly.position.x + poly.points[poly.points.length - 1].x - camera.bounds.x, poly.position.y + poly.points[0].y - camera.bounds.y); - this.polygonShape.graphics.endFill(); - } - this.pixelShape1.graphics.clear(); - this.pixelShape1.graphics.beginFill(es.Colors.colliderPosition, 0); - this.pixelShape1.graphics.lineStyle(4 * es.Size.lineSizeMultiplier, es.Colors.colliderPosition); - this.pixelShape1.graphics.moveTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.lineTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.endFill(); - this.pixelShape2.graphics.clear(); - this.pixelShape2.graphics.beginFill(es.Colors.colliderCenter, 0); - this.pixelShape2.graphics.lineStyle(2 * es.Size.lineSizeMultiplier, es.Colors.colliderCenter); - this.pixelShape2.graphics.moveTo(this.entity.transform.position.x + this.shape.center.x - camera.bounds.x, this.entity.transform.position.y + this.shape.center.y - camera.bounds.y); - this.pixelShape2.graphics.lineTo(this.entity.transform.position.x + this.shape.center.x - camera.bounds.x, this.entity.transform.position.y + this.shape.center.y - camera.bounds.y); - this.pixelShape2.graphics.endFill(); - }; - BoxCollider.prototype.toString = function () { - return "[BoxCollider: bounds: " + this.bounds + "]"; - }; - return BoxCollider; - }(es.Collider)); - es.BoxCollider = BoxCollider; -})(es || (es = {})); -var es; -(function (es) { - var CircleCollider = (function (_super) { - __extends(CircleCollider, _super); - function CircleCollider(radius) { - var _this = _super.call(this) || this; - _this.rectShape = new egret.Shape(); - _this.circleShape = new egret.Shape(); - _this.pixelShape1 = new egret.Shape(); - _this.pixelShape2 = new egret.Shape(); - if (radius == undefined) { - _this.shape = new es.Circle(1); - _this._colliderRequiresAutoSizing = true; - } - else { - _this.shape = new es.Circle(radius); - } - return _this; - } - Object.defineProperty(CircleCollider.prototype, "radius", { - get: function () { - return this.shape.radius; - }, - set: function (value) { - this.setRadius(value); - }, - enumerable: true, - configurable: true - }); - CircleCollider.prototype.setRadius = function (radius) { - this._colliderRequiresAutoSizing = false; - var circle = this.shape; - if (radius != circle.radius) { - circle.radius = radius; - circle._originalRadius = radius; - if (this.entity && this._isParentEntityAddedToScene) - es.Physics.updateCollider(this); - } - return this; - }; - CircleCollider.prototype.debugRender = function (camera) { - if (!this.rectShape.parent) - this.debugDisplayObject.addChild(this.rectShape); - if (!this.circleShape.parent) - this.debugDisplayObject.addChild(this.circleShape); - if (!this.pixelShape1.parent) - this.debugDisplayObject.addChild(this.pixelShape1); - if (!this.pixelShape2.parent) - this.debugDisplayObject.addChild(this.pixelShape2); - this.rectShape.graphics.clear(); - this.rectShape.graphics.beginFill(es.Colors.colliderBounds, 0); - this.rectShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderBounds); - this.rectShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.rectShape.graphics.endFill(); - this.circleShape.graphics.clear(); - this.circleShape.graphics.beginFill(es.Colors.colliderEdge, 0); - this.circleShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderEdge); - this.circleShape.graphics.drawCircle(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y, this.shape.radius); - this.circleShape.graphics.endFill(); - this.pixelShape1.graphics.clear(); - this.pixelShape1.graphics.beginFill(es.Colors.colliderPosition, 0); - this.pixelShape1.graphics.lineStyle(4 * es.Size.lineSizeMultiplier, es.Colors.colliderPosition); - this.pixelShape1.graphics.moveTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.lineTo(this.entity.transform.position.x - camera.bounds.y, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.endFill(); - this.pixelShape2.graphics.clear(); - this.pixelShape2.graphics.beginFill(es.Colors.colliderCenter, 0); - this.pixelShape2.graphics.lineStyle(2 * es.Size.lineSizeMultiplier, es.Colors.colliderCenter); - this.pixelShape2.graphics.moveTo(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y); - this.pixelShape2.graphics.lineTo(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y); - this.pixelShape2.graphics.endFill(); - }; - CircleCollider.prototype.toString = function () { - return "[CircleCollider: bounds: " + this.bounds + ", radius: " + this.shape.radius + "]"; - }; - return CircleCollider; - }(es.Collider)); - es.CircleCollider = CircleCollider; -})(es || (es = {})); -var es; -(function (es) { - var PolygonCollider = (function (_super) { - __extends(PolygonCollider, _super); - function PolygonCollider(points) { - var _this = _super.call(this) || this; - var isPolygonClosed = points[0] == points[points.length - 1]; - if (isPolygonClosed) - points.splice(points.length - 1, 1); - var center = es.Polygon.findPolygonCenter(points); - _this.setLocalOffset(center); - es.Polygon.recenterPolygonVerts(points); - _this.shape = new es.Polygon(points); - return _this; - } - return PolygonCollider; - }(es.Collider)); - es.PolygonCollider = PolygonCollider; -})(es || (es = {})); -var es; -(function (es) { - var RenderableComponent = (function (_super) { - __extends(RenderableComponent, _super); - function RenderableComponent() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.displayObject = new egret.DisplayObject(); - _this.hollowShape = new egret.Shape(); - _this.pixelShape = new egret.Shape(); - _this.color = 0x000000; - _this._areBoundsDirty = true; - _this.debugRenderEnabled = true; - _this._localOffset = es.Vector2.zero; - _this._renderLayer = 0; - _this._bounds = new es.Rectangle(); - return _this; - } - Object.defineProperty(RenderableComponent.prototype, "width", { - get: function () { - return this.bounds.width; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "height", { - get: function () { - return this.bounds.height; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "localOffset", { - get: function () { - return this._localOffset; - }, - set: function (value) { - this.setLocalOffset(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "renderLayer", { - get: function () { - return this._renderLayer; - }, - set: function (value) { - this.setRenderLayer(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, es.Vector2.zero, this.entity.transform.scale, this.entity.transform.rotation, this.width, this.height); - this._areBoundsDirty = false; - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "isVisible", { - get: function () { - return this._isVisible; - }, - set: function (value) { - if (this._isVisible != value) { - this._isVisible = value; - if (this._isVisible) - this.onBecameVisible(); - else - this.onBecameInvisible(); - } - }, - enumerable: true, - configurable: true - }); - RenderableComponent.prototype.onEntityTransformChanged = function (comp) { - this._areBoundsDirty = true; - }; - RenderableComponent.prototype.debugRender = function (camera) { - if (!this.debugRenderEnabled) - return; - if (!this.hollowShape.parent) - this.debugDisplayObject.addChild(this.hollowShape); - if (!this.pixelShape.parent) - this.debugDisplayObject.addChild(this.pixelShape); - if (!this.entity.getComponent(es.Collider)) { - this.hollowShape.graphics.clear(); - this.hollowShape.graphics.beginFill(es.Colors.renderableBounds, 0); - this.hollowShape.graphics.lineStyle(1, es.Colors.renderableBounds); - this.hollowShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.hollowShape.graphics.endFill(); - } - var pixelPos = es.Vector2.add(this.entity.transform.position, this._localOffset).subtract(camera.bounds.location); - this.pixelShape.graphics.clear(); - this.pixelShape.graphics.beginFill(es.Colors.renderableCenter, 0); - this.pixelShape.graphics.lineStyle(4, es.Colors.renderableCenter); - this.pixelShape.graphics.moveTo(pixelPos.x, pixelPos.y); - this.pixelShape.graphics.lineTo(pixelPos.x, pixelPos.y); - this.pixelShape.graphics.endFill(); - }; - RenderableComponent.prototype.isVisibleFromCamera = function (camera) { - if (!camera) - return false; - this.isVisible = camera.bounds.intersects(this.bounds); - return this.isVisible; - }; - RenderableComponent.prototype.setRenderLayer = function (renderLayer) { - if (renderLayer != this._renderLayer) { - this.displayObject.zIndex = renderLayer; - var oldRenderLayer = this._renderLayer; - this._renderLayer = renderLayer; - if (this.entity && this.entity.scene) - this.entity.scene.renderableComponents.updateRenderableRenderLayer(this, oldRenderLayer, this._renderLayer); - } - return this; - }; - RenderableComponent.prototype.setColor = function (color) { - this.color = color; - return this; - }; - RenderableComponent.prototype.setLocalOffset = function (offset) { - if (this._localOffset != offset) { - this._localOffset = offset; - } - return this; - }; - RenderableComponent.prototype.sync = function (camera) { - if (this.displayObject.x != this.bounds.x - camera.bounds.y) - this.displayObject.x = this.bounds.x - camera.bounds.y; - if (this.displayObject.y != this.bounds.y - camera.bounds.y) - this.displayObject.y = this.bounds.y - camera.bounds.y; - if (this.displayObject.scaleX != this.entity.scale.x) - this.displayObject.scaleX = this.entity.scale.x; - if (this.displayObject.scaleY != this.entity.scale.y) - this.displayObject.scaleY = this.entity.scale.y; - if (this.displayObject.rotation != this.entity.rotationDegrees) - this.displayObject.rotation = this.entity.rotationDegrees; - }; - RenderableComponent.prototype.compareTo = function (other) { - return other.renderLayer - this.renderLayer; - }; - RenderableComponent.prototype.toString = function () { - return "[RenderableComponent] renderLayer: " + this.renderLayer; - }; - RenderableComponent.prototype.onBecameVisible = function () { - this.displayObject.visible = this.isVisible; - this.debugDisplayObject.visible = this.isVisible; - }; - RenderableComponent.prototype.onBecameInvisible = function () { - this.displayObject.visible = this.isVisible; - this.debugDisplayObject.visible = this.isVisible; - }; - return RenderableComponent; - }(es.Component)); - es.RenderableComponent = RenderableComponent; -})(es || (es = {})); -var es; -(function (es) { - var Mesh = (function (_super) { - __extends(Mesh, _super); - function Mesh() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.displayObject = new egret.Mesh(); - _this._primitiveCount = 0; - _this._width = 0; - _this._height = 0; - _this._triangles = []; - _this._verts = []; - return _this; - } - Object.defineProperty(Mesh.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - this._bounds.calculateBounds(es.Vector2.add(this.entity.transform.position, this._topLeftVertPosition), es.Vector2.zero, es.Vector2.zero, this.entity.transform.scale, this.entity.transform.rotation, this._width, this._height); - this._areBoundsDirty = false; - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Mesh.prototype.recalculateBounds = function (recalculateUVs) { - this._topLeftVertPosition = new es.Vector2(Number.MAX_VALUE, Number.MAX_VALUE); - var max = new es.Vector2(Number.MIN_VALUE, Number.MIN_VALUE); - for (var i = 0; i < this._verts.length; i++) { - this._topLeftVertPosition.x = Math.min(this._topLeftVertPosition.x, this._verts[i].position.x); - this._topLeftVertPosition.y = Math.min(this._topLeftVertPosition.y, this._verts[i].position.y); - max.x = Math.max(max.x, this._verts[i].position.x); - max.y = Math.max(max.y, this._verts[i].position.y); - } - this._width = max.x - this._topLeftVertPosition.x; - this._height = max.y - this._topLeftVertPosition.y; - if (recalculateUVs) { - for (var i = 0; i < this._verts.length; i++) { - this._verts[i].textureCoordinate.x = (this._verts[i].position.x - this._topLeftVertPosition.x) / this._width; - this._verts[i].textureCoordinate.y = (this._verts[i].position.y - this._topLeftVertPosition.y) / this._height; - } - } - return this; - }; - Mesh.prototype.setTexture = function (texture) { - this.displayObject.texture = texture; - return this; - }; - Mesh.prototype.setVertPositions = function (positions) { - if (this._verts == undefined || this._verts.length != positions.length) { - this._verts = new Array(positions.length); - this._verts.fill(new VertexPositionColorTexture(), 0, positions.length); - } - for (var i = 0; i < this._verts.length; i++) { - this._verts[i].position = positions[i]; - } - return this; - }; - Mesh.prototype.setTriangles = function (triangles) { - if (triangles.length % 3 != 0) { - console.error("三角形必须是3的倍数"); - return; - } - this._primitiveCount = triangles.length / 3; - this._triangles = triangles; - return this; - }; - Mesh.prototype.render = function (camera) { - var renderNode = this.displayObject.$renderNode; - renderNode.imageWidth = this._width; - renderNode.imageHeight = this._height; - renderNode.vertices = this._triangles; - }; - return Mesh; - }(es.RenderableComponent)); - es.Mesh = Mesh; - var VertexPositionColorTexture = (function () { - function VertexPositionColorTexture() { - } - return VertexPositionColorTexture; - }()); - es.VertexPositionColorTexture = VertexPositionColorTexture; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var SpriteRenderer = (function (_super) { - __extends(SpriteRenderer, _super); - function SpriteRenderer(sprite) { - if (sprite === void 0) { sprite = null; } - var _this = _super.call(this) || this; - if (sprite instanceof es.Sprite) - _this.setSprite(sprite); - else if (sprite instanceof egret.Texture) - _this.setSprite(new es.Sprite(sprite)); - return _this; - } - Object.defineProperty(SpriteRenderer.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - if (this._sprite) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, this.entity.transform.scale, this.entity.transform.rotation, this._sprite.sourceRect.width, this._sprite.sourceRect.height); - this._areBoundsDirty = false; - } - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteRenderer.prototype, "originNormalized", { - get: function () { - return new es.Vector2(this._origin.x / this.width * this.entity.transform.scale.x, this._origin.y / this.height * this.entity.transform.scale.y); - }, - set: function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteRenderer.prototype, "origin", { - get: function () { - return this._origin; - }, - set: function (value) { - this.setOrigin(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteRenderer.prototype, "sprite", { - get: function () { - return this._sprite; - }, - set: function (value) { - this.setSprite(value); - }, - enumerable: true, - configurable: true - }); - SpriteRenderer.prototype.setSprite = function (sprite) { - this._sprite = sprite; - if (this._sprite) { - this._origin = this._sprite.origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - } - this.displayObject = new Bitmap(sprite.texture2D); - this.displayObject.touchEnabled = false; - return this; - }; - SpriteRenderer.prototype.setOrigin = function (origin) { - if (!this._origin.equals(origin)) { - this._origin = origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - this._areBoundsDirty = true; - } - return this; - }; - SpriteRenderer.prototype.setOriginNormalized = function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - return this; - }; - SpriteRenderer.prototype.render = function (camera) { - this.sync(camera); - if (this.displayObject.x != this.bounds.x - camera.bounds.x + this._origin.x) - this.displayObject.x = this.bounds.x - camera.bounds.x + this._origin.x * this.entity.scale.x; - if (this.displayObject.y != this.bounds.y - camera.bounds.y + this._origin.y) - this.displayObject.y = this.bounds.y - camera.bounds.y + this._origin.y * this.entity.scale.y; - if (this.displayObject.anchorOffsetX != this._origin.x) - this.displayObject.anchorOffsetX = this._origin.x; - if (this.displayObject.anchorOffsetY != this._origin.y) - this.displayObject.anchorOffsetY = this._origin.y; - }; - return SpriteRenderer; - }(es.RenderableComponent)); - es.SpriteRenderer = SpriteRenderer; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var RenderTexture = egret.RenderTexture; - var TiledSpriteRenderer = (function (_super) { - __extends(TiledSpriteRenderer, _super); - function TiledSpriteRenderer(sprite) { - var _this = _super.call(this, sprite) || this; - _this._textureScale = es.Vector2.one; - _this._inverseTexScale = es.Vector2.one; - _this._gapX = 0; - _this._gapY = 0; - _this._sourceRect = sprite.sourceRect; - var bitmap = _this.displayObject; - bitmap.$fillMode = egret.BitmapFillMode.REPEAT; - return _this; - } - Object.defineProperty(TiledSpriteRenderer.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - if (this._sprite) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, this.entity.transform.scale, this.entity.transform.rotation, this.width, this.height); - this._areBoundsDirty = false; - } - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "scrollX", { - get: function () { - return this._sourceRect.x; - }, - set: function (value) { - this._sourceRect.x = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "scrollY", { - get: function () { - return this._sourceRect.y; - }, - set: function (value) { - this._sourceRect.y = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "textureScale", { - get: function () { - return this._textureScale; - }, - set: function (value) { - this._textureScale = value; - this._inverseTexScale = new es.Vector2(1 / this._textureScale.x, 1 / this._textureScale.y); - this._sourceRect.width = Math.floor(this._sprite.sourceRect.width * this._inverseTexScale.x); - this._sourceRect.height = Math.floor(this._sprite.sourceRect.height * this._inverseTexScale.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "width", { - get: function () { - return this._sourceRect.width; - }, - set: function (value) { - this._areBoundsDirty = true; - this._sourceRect.width = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "height", { - get: function () { - return this._sourceRect.height; - }, - set: function (value) { - this._areBoundsDirty = true; - this._sourceRect.height = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "gapXY", { - get: function () { - return new es.Vector2(this._gapX, this._gapY); - }, - set: function (value) { - this._gapX = value.x; - this._gapY = value.y; - var renderTexture = new RenderTexture(); - var newRectangle = this.sprite.sourceRect; - newRectangle.x = 0; - newRectangle.y = 0; - newRectangle.width += this._gapX; - newRectangle.height += this._gapY; - renderTexture.drawToTexture(this.displayObject, newRectangle); - if (!this.displayObject) { - this.displayObject = new Bitmap(renderTexture); - } - else { - this.displayObject.texture = renderTexture; - } - }, - enumerable: true, - configurable: true - }); - TiledSpriteRenderer.prototype.setGapXY = function (value) { - this.gapXY = value; - return this; - }; - TiledSpriteRenderer.prototype.render = function (camera) { - _super.prototype.render.call(this, camera); - var bitmap = this.displayObject; - bitmap.width = this.width; - bitmap.height = this.height; - bitmap.scrollRect = this._sourceRect; - }; - return TiledSpriteRenderer; - }(es.SpriteRenderer)); - es.TiledSpriteRenderer = TiledSpriteRenderer; -})(es || (es = {})); -var es; -(function (es) { - var ScrollingSpriteRenderer = (function (_super) { - __extends(ScrollingSpriteRenderer, _super); - function ScrollingSpriteRenderer(sprite) { - var _this = _super.call(this, sprite) || this; - _this.scrollSpeedX = 15; - _this.scroolSpeedY = 0; - _this._scrollX = 0; - _this._scrollY = 0; - _this._scrollWidth = 0; - _this._scrollHeight = 0; - _this._scrollWidth = _this.width; - _this._scrollHeight = _this.height; - return _this; - } - Object.defineProperty(ScrollingSpriteRenderer.prototype, "textureScale", { - get: function () { - return this._textureScale; - }, - set: function (value) { - this._textureScale = value; - this._inverseTexScale = new es.Vector2(1 / this._textureScale.x, 1 / this._textureScale.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollingSpriteRenderer.prototype, "scrollWidth", { - get: function () { - return this._scrollWidth; - }, - set: function (value) { - this._scrollWidth = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollingSpriteRenderer.prototype, "scrollHeight", { - get: function () { - return this._scrollHeight; - }, - set: function (value) { - this._scrollHeight = value; - }, - enumerable: true, - configurable: true - }); - ScrollingSpriteRenderer.prototype.update = function () { - if (!this.sprite) - return; - this._scrollX += this.scrollSpeedX * es.Time.deltaTime; - this._scrollY += this.scroolSpeedY * es.Time.deltaTime; - this._sourceRect.x = Math.floor(this._scrollX); - this._sourceRect.y = Math.floor(this._scrollY); - this._sourceRect.width = this._scrollWidth + Math.abs(this._scrollX); - this._sourceRect.height = this._scrollHeight + Math.abs(this._scrollY); - }; - return ScrollingSpriteRenderer; - }(es.TiledSpriteRenderer)); - es.ScrollingSpriteRenderer = ScrollingSpriteRenderer; -})(es || (es = {})); -var es; -(function (es) { - var SpriteSheet = egret.SpriteSheet; - var Sprite = (function () { - function Sprite(texture, sourceRect, origin) { - if (sourceRect === void 0) { sourceRect = new es.Rectangle(0, 0, texture.textureWidth, texture.textureHeight); } - if (origin === void 0) { origin = sourceRect.getHalfSize(); } - this.uvs = new es.Rectangle(); - this.texture2D = texture; - this.sourceRect = sourceRect; - this.center = new es.Vector2(sourceRect.width * 0.5, sourceRect.height * 0.5); - this.origin = origin; - var inverseTexW = 1 / texture.textureWidth; - var inverseTexH = 1 / texture.textureHeight; - this.uvs.x = sourceRect.x * inverseTexW; - this.uvs.y = sourceRect.y * inverseTexH; - this.uvs.width = sourceRect.width * inverseTexW; - this.uvs.height = sourceRect.height * inverseTexH; - } - Sprite.spritesFromAtlas = function (texture, cellWidth, cellHeight, cellOffset, maxCellsToInclude) { - if (cellOffset === void 0) { cellOffset = 0; } - if (maxCellsToInclude === void 0) { maxCellsToInclude = Number.MAX_VALUE; } - var sprites = []; - var cols = texture.textureWidth / cellWidth; - var rows = texture.textureHeight / cellHeight; - var i = 0; - var spriteSheet = new SpriteSheet(texture); - for (var y = 0; y < rows; y++) { - for (var x = 0; x < cols; x++) { - if (i++ < cellOffset) - continue; - var texture_1 = spriteSheet.getTexture(y + "_" + x); - if (!texture_1) - texture_1 = spriteSheet.createTexture(y + "_" + x, x * cellWidth, y * cellHeight, cellWidth, cellHeight); - sprites.push(new Sprite(texture_1)); - if (sprites.length == maxCellsToInclude) - return sprites; - } - } - return sprites; - }; - return Sprite; - }()); - es.Sprite = Sprite; -})(es || (es = {})); -var es; -(function (es) { - var SpriteAnimation = (function () { - function SpriteAnimation(sprites, frameRate) { - if (frameRate === void 0) { frameRate = 10; } - this.sprites = sprites; - this.frameRate = frameRate; - } - return SpriteAnimation; - }()); - es.SpriteAnimation = SpriteAnimation; -})(es || (es = {})); -var es; -(function (es) { - var LoopMode; - (function (LoopMode) { - LoopMode[LoopMode["loop"] = 0] = "loop"; - LoopMode[LoopMode["once"] = 1] = "once"; - LoopMode[LoopMode["clampForever"] = 2] = "clampForever"; - LoopMode[LoopMode["pingPong"] = 3] = "pingPong"; - LoopMode[LoopMode["pingPongOnce"] = 4] = "pingPongOnce"; - })(LoopMode = es.LoopMode || (es.LoopMode = {})); - var State; - (function (State) { - State[State["none"] = 0] = "none"; - State[State["running"] = 1] = "running"; - State[State["paused"] = 2] = "paused"; - State[State["completed"] = 3] = "completed"; - })(State = es.State || (es.State = {})); - var SpriteAnimator = (function (_super) { - __extends(SpriteAnimator, _super); - function SpriteAnimator(sprite) { - var _this = _super.call(this, sprite) || this; - _this.speed = 1; - _this.animationState = State.none; - _this._elapsedTime = 0; - _this._animations = new Map(); - return _this; - } - Object.defineProperty(SpriteAnimator.prototype, "isRunning", { - get: function () { - return this.animationState == State.running; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteAnimator.prototype, "animations", { - get: function () { - return this._animations; - }, - enumerable: true, - configurable: true - }); - SpriteAnimator.prototype.update = function () { - if (this.animationState != State.running || !this.currentAnimation) - return; - var animation = this.currentAnimation; - var secondsPerFrame = 1 / (animation.frameRate * this.speed); - var iterationDuration = secondsPerFrame * animation.sprites.length; - this._elapsedTime += es.Time.deltaTime; - var time = Math.abs(this._elapsedTime); - if (this._loopMode == LoopMode.once && time > iterationDuration || - this._loopMode == LoopMode.pingPongOnce && time > iterationDuration * 2) { - this.animationState = State.completed; - this._elapsedTime = 0; - this.currentFrame = 0; - this.displayObject.texture = animation.sprites[this.currentFrame].texture2D; - return; - } - var i = Math.floor(time / secondsPerFrame); - var n = animation.sprites.length; - if (n > 2 && (this._loopMode == LoopMode.pingPong || this._loopMode == LoopMode.pingPongOnce)) { - var maxIndex = n - 1; - this.currentFrame = maxIndex - Math.abs(maxIndex - i % (maxIndex * 2)); - } - else { - this.currentFrame = i % n; - } - this.displayObject.texture = animation.sprites[this.currentFrame].texture2D; - }; - SpriteAnimator.prototype.addAnimation = function (name, animation) { - if (!this.sprite && animation.sprites.length > 0) - this.setSprite(animation.sprites[0]); - this._animations[name] = animation; - return this; - }; - SpriteAnimator.prototype.play = function (name, loopMode) { - if (loopMode === void 0) { loopMode = null; } - this.currentAnimation = this._animations[name]; - this.currentAnimationName = name; - this.currentFrame = 0; - this.animationState = State.running; - this.displayObject.texture = this.currentAnimation.sprites[0].texture2D; - this._elapsedTime = 0; - this._loopMode = loopMode ? loopMode : LoopMode.loop; - }; - SpriteAnimator.prototype.isAnimationActive = function (name) { - return this.currentAnimation && this.currentAnimationName == name; - }; - SpriteAnimator.prototype.pause = function () { - this.animationState = State.paused; - }; - SpriteAnimator.prototype.unPause = function () { - this.animationState = State.running; - }; - SpriteAnimator.prototype.stop = function () { - this.currentAnimation = null; - this.currentAnimationName = null; - this.currentFrame = 0; - this.animationState = State.none; - }; - return SpriteAnimator; - }(es.SpriteRenderer)); - es.SpriteAnimator = SpriteAnimator; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var StaticSpriteContainerRenderer = (function (_super) { - __extends(StaticSpriteContainerRenderer, _super); - function StaticSpriteContainerRenderer(sprite) { - if (sprite === void 0) { sprite = null; } - var _this = _super.call(this) || this; - _this.displayObject = new egret.DisplayObjectContainer(); - _this.displayObjectCache = new Map(); - for (var _i = 0, sprite_1 = sprite; _i < sprite_1.length; _i++) { - var s = sprite_1[_i]; - if (s instanceof es.Sprite) - _this.pushSprite(s); - else if (s instanceof egret.Texture) - _this.pushSprite(new es.Sprite(s)); - } - _this.displayObject.cacheAsBitmap = true; - return _this; - } - Object.defineProperty(StaticSpriteContainerRenderer.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - if (this.displayObject) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, this.entity.transform.scale, this.entity.transform.rotation, this.displayObject.width, this.displayObject.height); - this._areBoundsDirty = false; - } - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(StaticSpriteContainerRenderer.prototype, "originNormalized", { - get: function () { - return new es.Vector2(this._origin.x / this.width * this.entity.transform.scale.x, this._origin.y / this.height * this.entity.transform.scale.y); - }, - set: function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(StaticSpriteContainerRenderer.prototype, "origin", { - get: function () { - return this._origin; - }, - set: function (value) { - this.setOrigin(value); - }, - enumerable: true, - configurable: true - }); - StaticSpriteContainerRenderer.prototype.pushSprite = function (sprite) { - if (sprite) { - this._origin = sprite.origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - } - var bitmap = new Bitmap(sprite.texture2D); - this.displayObject.addChild(new Bitmap(sprite.texture2D)); - this.displayObjectCache.set(sprite, bitmap); - return this; - }; - StaticSpriteContainerRenderer.prototype.getSprite = function (sprite) { - return this.displayObjectCache.get(sprite); - }; - StaticSpriteContainerRenderer.prototype.setOrigin = function (origin) { - if (this._origin != origin) { - this._origin = origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - this._areBoundsDirty = true; - } - return this; - }; - StaticSpriteContainerRenderer.prototype.setOriginNormalized = function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - return this; - }; - StaticSpriteContainerRenderer.prototype.render = function (camera) { - this.sync(camera); - if (this.displayObject.x != this.bounds.x - camera.bounds.x) - this.displayObject.x = this.bounds.x - camera.bounds.x; - if (this.displayObject.y != this.bounds.y - camera.bounds.y) - this.displayObject.y = this.bounds.y - camera.bounds.y; - }; - return StaticSpriteContainerRenderer; - }(es.RenderableComponent)); - es.StaticSpriteContainerRenderer = StaticSpriteContainerRenderer; -})(es || (es = {})); -var es; -(function (es) { - var EntitySystem = (function () { - function EntitySystem(matcher) { - this._entities = []; - this._matcher = matcher ? matcher : es.Matcher.empty(); - } - Object.defineProperty(EntitySystem.prototype, "scene", { - get: function () { - return this._scene; - }, - set: function (value) { - this._scene = value; - this._entities = []; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EntitySystem.prototype, "matcher", { - get: function () { - return this._matcher; - }, - enumerable: true, - configurable: true - }); - EntitySystem.prototype.initialize = function () { - }; - EntitySystem.prototype.onChanged = function (entity) { - var contains = this._entities.contains(entity); - var interest = this._matcher.IsIntersted(entity); - if (interest && !contains) - this.add(entity); - else if (!interest && contains) - this.remove(entity); - }; - EntitySystem.prototype.add = function (entity) { - this._entities.push(entity); - this.onAdded(entity); - }; - EntitySystem.prototype.onAdded = function (entity) { - }; - EntitySystem.prototype.remove = function (entity) { - this._entities.remove(entity); - this.onRemoved(entity); - }; - EntitySystem.prototype.onRemoved = function (entity) { - }; - EntitySystem.prototype.update = function () { - this.begin(); - this.process(this._entities); - }; - EntitySystem.prototype.lateUpdate = function () { - this.lateProcess(this._entities); - this.end(); - }; - EntitySystem.prototype.begin = function () { - }; - EntitySystem.prototype.process = function (entities) { - }; - EntitySystem.prototype.lateProcess = function (entities) { - }; - EntitySystem.prototype.end = function () { - }; - return EntitySystem; - }()); - es.EntitySystem = EntitySystem; -})(es || (es = {})); -var es; -(function (es) { - var EntityProcessingSystem = (function (_super) { - __extends(EntityProcessingSystem, _super); - function EntityProcessingSystem(matcher) { - return _super.call(this, matcher) || this; - } - EntityProcessingSystem.prototype.lateProcessEntity = function (entity) { - }; - EntityProcessingSystem.prototype.process = function (entities) { - var _this = this; - entities.forEach(function (entity) { return _this.processEntity(entity); }); - }; - EntityProcessingSystem.prototype.lateProcess = function (entities) { - var _this = this; - entities.forEach(function (entity) { return _this.lateProcessEntity(entity); }); - }; - return EntityProcessingSystem; - }(es.EntitySystem)); - es.EntityProcessingSystem = EntityProcessingSystem; -})(es || (es = {})); -var es; -(function (es) { - var PassiveSystem = (function (_super) { - __extends(PassiveSystem, _super); - function PassiveSystem() { - return _super !== null && _super.apply(this, arguments) || this; - } - PassiveSystem.prototype.onChanged = function (entity) { - }; - PassiveSystem.prototype.process = function (entities) { - this.begin(); - this.end(); - }; - return PassiveSystem; - }(es.EntitySystem)); - es.PassiveSystem = PassiveSystem; -})(es || (es = {})); -var es; -(function (es) { - var ProcessingSystem = (function (_super) { - __extends(ProcessingSystem, _super); - function ProcessingSystem() { - return _super !== null && _super.apply(this, arguments) || this; - } - ProcessingSystem.prototype.onChanged = function (entity) { - }; - ProcessingSystem.prototype.process = function (entities) { - this.begin(); - this.processSystem(); - this.end(); - }; - return ProcessingSystem; - }(es.EntitySystem)); - es.ProcessingSystem = ProcessingSystem; -})(es || (es = {})); -var es; -(function (es) { - var BitSet = (function () { - function BitSet(nbits) { - if (nbits === void 0) { nbits = 64; } - var length = nbits >> 6; - if ((nbits & BitSet.LONG_MASK) != 0) - length++; - this._bits = new Array(length); - } - BitSet.prototype.and = function (bs) { - var max = Math.min(this._bits.length, bs._bits.length); - var i; - for (var i_1 = 0; i_1 < max; ++i_1) - this._bits[i_1] &= bs._bits[i_1]; - while (i < this._bits.length) - this._bits[i++] = 0; - }; - BitSet.prototype.andNot = function (bs) { - var i = Math.min(this._bits.length, bs._bits.length); - while (--i >= 0) - this._bits[i] &= ~bs._bits[i]; - }; - BitSet.prototype.cardinality = function () { - var card = 0; - for (var i = this._bits.length - 1; i >= 0; i--) { - var a = this._bits[i]; - if (a == 0) - continue; - if (a == -1) { - card += 64; - continue; - } - a = ((a >> 1) & 0x5555555555555555) + (a & 0x5555555555555555); - a = ((a >> 2) & 0x3333333333333333) + (a & 0x3333333333333333); - var b = ((a >> 32) + a); - b = ((b >> 4) & 0x0f0f0f0f) + (b & 0x0f0f0f0f); - b = ((b >> 8) & 0x00ff00ff) + (b & 0x00ff00ff); - card += ((b >> 16) & 0x0000ffff) + (b & 0x0000ffff); - } - return card; - }; - BitSet.prototype.clear = function (pos) { - if (pos != undefined) { - var offset = pos >> 6; - this.ensure(offset); - this._bits[offset] &= ~(1 << pos); - } - else { - for (var i = 0; i < this._bits.length; i++) - this._bits[i] = 0; - } - }; - BitSet.prototype.get = function (pos) { - var offset = pos >> 6; - if (offset >= this._bits.length) - return false; - return (this._bits[offset] & (1 << pos)) != 0; - }; - BitSet.prototype.intersects = function (set) { - var i = Math.min(this._bits.length, set._bits.length); - while (--i >= 0) { - if ((this._bits[i] & set._bits[i]) != 0) - return true; - } - return false; - }; - BitSet.prototype.isEmpty = function () { - for (var i = this._bits.length - 1; i >= 0; i--) { - if (this._bits[i]) - return false; - } - return true; - }; - BitSet.prototype.nextSetBit = function (from) { - var offset = from >> 6; - var mask = 1 << from; - while (offset < this._bits.length) { - var h = this._bits[offset]; - do { - if ((h & mask) != 0) - return from; - mask <<= 1; - from++; - } while (mask != 0); - mask = 1; - offset++; - } - return -1; - }; - BitSet.prototype.set = function (pos, value) { - if (value === void 0) { value = true; } - if (value) { - var offset = pos >> 6; - this.ensure(offset); - this._bits[offset] |= 1 << pos; - } - else { - this.clear(pos); - } - }; - BitSet.prototype.ensure = function (lastElt) { - if (lastElt >= this._bits.length) { - var nd = new Number[lastElt + 1]; - nd = this._bits.copyWithin(0, 0, this._bits.length); - this._bits = nd; - } - }; - BitSet.LONG_MASK = 0x3f; - return BitSet; - }()); - es.BitSet = BitSet; -})(es || (es = {})); -var es; -(function (es) { - var ComponentList = (function () { - function ComponentList(entity) { - this._components = new es.FastList(); - this._componentsToAdd = []; - this._componentsToRemove = []; - this._tempBufferList = []; - this._entity = entity; - } - Object.defineProperty(ComponentList.prototype, "count", { - get: function () { - return this._components.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ComponentList.prototype, "buffer", { - get: function () { - return this._components.buffer; - }, - enumerable: true, - configurable: true - }); - ComponentList.prototype.markEntityListUnsorted = function () { - this._isComponentListUnsorted = true; - }; - ComponentList.prototype.add = function (component) { - this._componentsToAdd.push(component); - }; - ComponentList.prototype.remove = function (component) { - if (this._componentsToRemove.contains(component)) - console.warn("\u60A8\u6B63\u5728\u5C1D\u8BD5\u5220\u9664\u4E00\u4E2A\u60A8\u5DF2\u7ECF\u5220\u9664\u7684\u7EC4\u4EF6(" + component + ")"); - if (this._componentsToAdd.contains(component)) { - this._componentsToAdd.remove(component); - return; - } - this._componentsToRemove.push(component); - }; - ComponentList.prototype.removeAllComponents = function () { - for (var i = 0; i < this._components.length; i++) { - this.handleRemove(this._components[i]); - } - this._components.clear(); - this._componentsToAdd.length = 0; - this._componentsToRemove.length = 0; - }; - ComponentList.prototype.deregisterAllComponents = function () { - for (var i = 0; i < this._components.length; i++) { - var component = this._components.buffer[i]; - if (!component) - continue; - if (component instanceof es.RenderableComponent) { - if (component.displayObject.parent) - component.displayObject.parent.removeChild(component.displayObject); - this._entity.scene.renderableComponents.remove(component); - } - if (component.debugDisplayObject.parent) - component.debugDisplayObject.parent.removeChild(component.debugDisplayObject); - this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component), false); - this._entity.scene.entityProcessors.onComponentRemoved(this._entity); - } - }; - ComponentList.prototype.registerAllComponents = function () { - for (var i = 0; i < this._components.length; i++) { - var component = this._components.buffer[i]; - if (component instanceof es.RenderableComponent) { - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.displayObject); - this._entity.scene.renderableComponents.add(component); - } - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.debugDisplayObject); - this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component)); - this._entity.scene.entityProcessors.onComponentAdded(this._entity); - } - if (this._entity.scene.dynamicBatch) - this._entity.scene.dynamicInBatch(); - }; - ComponentList.prototype.updateLists = function () { - if (this._componentsToRemove.length > 0) { - for (var i = 0; i < this._componentsToRemove.length; i++) { - this.handleRemove(this._componentsToRemove[i]); - this._components.remove(this._componentsToRemove[i]); - } - this._componentsToRemove.length = 0; - } - if (this._componentsToAdd.length > 0) { - for (var i = 0, count = this._componentsToAdd.length; i < count; i++) { - var component = this._componentsToAdd[i]; - if (component instanceof es.RenderableComponent) { - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.displayObject); - this._entity.scene.renderableComponents.add(component); - } - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.debugDisplayObject); - this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component)); - this._entity.scene.entityProcessors.onComponentAdded(this._entity); - this._components.add(component); - this._tempBufferList.push(component); - } - if (this._entity.scene.dynamicBatch) - this._entity.scene.dynamicInBatch(); - this._componentsToAdd.length = 0; - this._isComponentListUnsorted = true; - for (var i = 0; i < this._tempBufferList.length; i++) { - var component = this._tempBufferList[i]; - component.onAddedToEntity(); - if (component.enabled) { - component.onEnabled(); - } - } - this._tempBufferList.length = 0; - } - if (this._isComponentListUnsorted) { - this._components.sort(ComponentList.compareUpdatableOrder); - this._isComponentListUnsorted = false; - } - }; - ComponentList.prototype.handleRemove = function (component) { - if (!component) - return; - if (component instanceof es.RenderableComponent) { - if (component.displayObject.parent) - component.displayObject.parent.removeChild(component.displayObject); - this._entity.scene.renderableComponents.remove(component); - } - if (component.debugDisplayObject.parent) - component.debugDisplayObject.parent.removeChild(component.debugDisplayObject); - this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component), false); - this._entity.scene.entityProcessors.onComponentRemoved(this._entity); - component.onRemovedFromEntity(); - component.entity = null; - }; - ComponentList.prototype.getComponent = function (type, onlyReturnInitializedComponents) { - for (var i = 0; i < this._components.length; i++) { - var component = this._components.buffer[i]; - if (component instanceof type) - return component; - } - if (!onlyReturnInitializedComponents) { - for (var i = 0; i < this._componentsToAdd.length; i++) { - var component = this._componentsToAdd[i]; - if (component instanceof type) - return component; - } - } - return null; - }; - ComponentList.prototype.getComponents = function (typeName, components) { - if (!components) - components = []; - for (var i = 0; i < this._components.length; i++) { - var component = this._components.buffer[i]; - if (typeof (typeName) == "string") { - if (egret.is(component, typeName)) { - components.push(component); - } - } - else { - if (component instanceof typeName) { - components.push(component); - } - } - } - for (var i = 0; i < this._componentsToAdd.length; i++) { - var component = this._componentsToAdd[i]; - if (typeof (typeName) == "string") { - if (egret.is(component, typeName)) { - components.push(component); - } - } - else { - if (component instanceof typeName) { - components.push(component); - } - } - } - return components; - }; - ComponentList.prototype.update = function () { - this.updateLists(); - for (var i = 0; i < this._components.length; i++) { - var updatableComponent = this._components.buffer[i]; - if (updatableComponent.enabled && - (updatableComponent.updateInterval == 1 || - es.Time.frameCount % updatableComponent.updateInterval == 0)) - updatableComponent.update(); - } - }; - ComponentList.prototype.onEntityTransformChanged = function (comp) { - for (var i = 0; i < this._components.length; i++) { - if (this._components.buffer[i].enabled) - this._components.buffer[i].onEntityTransformChanged(comp); - } - for (var i = 0; i < this._componentsToAdd.length; i++) { - if (this._componentsToAdd[i].enabled) - this._componentsToAdd[i].onEntityTransformChanged(comp); - } - }; - ComponentList.prototype.onEntityEnabled = function () { - for (var i = 0; i < this._components.length; i++) - this._components.buffer[i].onEnabled(); - }; - ComponentList.prototype.onEntityDisabled = function () { - for (var i = 0; i < this._components.length; i++) - this._components.buffer[i].onDisabled(); - }; - ComponentList.prototype.debugRender = function (camera) { - for (var i = 0; i < this._components.length; i++) { - if (this._components.buffer[i].enabled) - this._components.buffer[i].debugRender(camera); - } - }; - ComponentList.compareUpdatableOrder = new es.IUpdatableComparer(); - return ComponentList; - }()); - es.ComponentList = ComponentList; -})(es || (es = {})); -var es; -(function (es) { - var ComponentTypeManager = (function () { - function ComponentTypeManager() { - } - ComponentTypeManager.add = function (type) { - if (!this._componentTypesMask.has(type)) - this._componentTypesMask[type] = this._componentTypesMask.size; - }; - ComponentTypeManager.getIndexFor = function (type) { - var v = -1; - if (!this._componentTypesMask.has(type)) { - this.add(type); - v = this._componentTypesMask.get(type); - } - return v; - }; - ComponentTypeManager._componentTypesMask = new Map(); - return ComponentTypeManager; - }()); - es.ComponentTypeManager = ComponentTypeManager; -})(es || (es = {})); -var es; -(function (es) { - var EntityList = (function () { - function EntityList(scene) { - this._entities = []; - this._entitiesToAdded = []; - this._entitiesToRemove = []; - this._entityDict = new Map(); - this._unsortedTags = new Set(); - this._addToSceneEntityList = []; - this.frameAllocate = false; - this.maxAllocate = 10; - this.scene = scene; - } - Object.defineProperty(EntityList.prototype, "count", { - get: function () { - return this._entities.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EntityList.prototype, "buffer", { - get: function () { - return this._entities; - }, - enumerable: true, - configurable: true - }); - EntityList.prototype.markEntityListUnsorted = function () { - this._isEntityListUnsorted = true; - }; - EntityList.prototype.markTagUnsorted = function (tag) { - this._unsortedTags.add(tag); - }; - EntityList.prototype.add = function (entity) { - if (this._entitiesToAdded.indexOf(entity) == -1) - this._entitiesToAdded.push(entity); - }; - EntityList.prototype.remove = function (entity) { - if (!this._entitiesToRemove.contains(entity)) { - console.warn("\u60A8\u6B63\u5728\u5C1D\u8BD5\u5220\u9664\u5DF2\u7ECF\u5220\u9664\u7684\u5B9E\u4F53(" + entity.name + ")"); - return; - } - if (this._entitiesToAdded.contains(entity)) { - this._entitiesToAdded.remove(entity); - return; - } - if (!this._entitiesToRemove.contains(entity)) - this._entitiesToRemove.push(entity); - }; - EntityList.prototype.removeAllEntities = function () { - this._unsortedTags.clear(); - this._entitiesToAdded.length = 0; - this._isEntityListUnsorted = false; - this.updateLists(); - for (var i = 0; i < this._entities.length; i++) { - this._entities[i]._isDestroyed = true; - this._entities[i].onRemovedFromScene(); - this._entities[i].scene = null; - } - this._entities.length = 0; - this._entityDict.clear(); - }; - EntityList.prototype.contains = function (entity) { - return this._entities.findIndex(function (e) { return e.id == entity.id; }) != -1 || - this._entitiesToAdded.findIndex(function (e) { return e.id == entity.id; }) != -1; - }; - EntityList.prototype.getTagList = function (tag) { - var list = this._entityDict.get(tag); - if (!list) { - list = []; - this._entityDict.set(tag, list); - } - return list; - }; - EntityList.prototype.addToTagList = function (entity) { - var list = this.getTagList(entity.tag); - if (list.findIndex(function (e) { return e.id == entity.id; }) == -1) { - list.push(entity); - this._unsortedTags.add(entity.tag); - } - }; - EntityList.prototype.removeFromTagList = function (entity) { - var list = this._entityDict.get(entity.tag); - if (list) { - list.remove(entity); - } - }; - EntityList.prototype.update = function () { - for (var i = 0; i < this._entities.length; i++) { - var entity = this._entities[i]; - if (entity.enabled && (entity.updateInterval == 1 || es.Time.frameCount % entity.updateInterval == 0)) - entity.update(); - } - }; - EntityList.prototype.updateLists = function () { - var _this = this; - if (this._entitiesToRemove.length > 0) { - for (var _i = 0, _a = this._entitiesToRemove; _i < _a.length; _i++) { - var entity = _a[_i]; - this.removeFromTagList(entity); - this._entities.remove(entity); - entity.onRemovedFromScene(); - entity.scene = null; - this.scene.entityProcessors.onEntityRemoved(entity); - } - this._entitiesToRemove.length = 0; - } - while (this._addToSceneEntityList.length > 0) { - var entity = this._addToSceneEntityList.shift(); - entity.onAddedToScene(); - } - if (this._entitiesToAdded.length > 0) { - if (this.frameAllocate && this._entitiesToAdded.length > this.maxAllocate) { - for (var i = 0; i < this.maxAllocate; i++) { - this.perEntityAddToScene(); - } - if (this._entitiesToAdded.length == 0) - this._isEntityListUnsorted = true; - } - else { - while (this._entitiesToAdded.length > 0) { - this.perEntityAddToScene(); - } - this._isEntityListUnsorted = true; - } - } - if (this._isEntityListUnsorted) { - this._entities.sort(function (a, b) { - return a.compareTo(b); - }); - this._isEntityListUnsorted = false; - } - if (this._addToSceneEntityList.length == 0 && this._unsortedTags.size > 0) { - this._unsortedTags.forEach(function (tag) { - _this._entityDict.get(tag).sort(function (a, b) { - return a.compareTo(b); - }); - }); - this._unsortedTags.clear(); - } - }; - EntityList.prototype.perEntityAddToScene = function () { - var entity = this._entitiesToAdded.shift(); - this._addToSceneEntityList.push(entity); - if (this._entities.findIndex(function (e) { return e.id == entity.id; }) == -1) { - this._entities.push(entity); - entity.scene = this.scene; - this.addToTagList(entity); - this.scene.entityProcessors.onEntityAdded(entity); - } - }; - EntityList.prototype.findEntity = function (name) { - for (var i = 0; i < this._entities.length; i++) { - if (this._entities[i].name == name) - return this._entities[i]; - } - return this._entitiesToAdded.firstOrDefault(function (entity) { return entity.name == name; }); - }; - EntityList.prototype.entitiesWithTag = function (tag) { - var list = this.getTagList(tag); - var returnList = es.ListPool.obtain(); - returnList.length = this._entities.length; - for (var i = 0; i < list.length; i++) - returnList.push(list[i]); - return returnList; - }; - EntityList.prototype.entitiesOfType = function (type) { - var list = es.ListPool.obtain(); - for (var i = 0; i < this._entities.length; i++) { - if (this._entities[i] instanceof type) - list.push(this._entities[i]); - } - for (var _i = 0, _a = this._entitiesToAdded; _i < _a.length; _i++) { - var entity = _a[_i]; - if (entity instanceof type) - list.push(entity); - } - return list; - }; - EntityList.prototype.findComponentOfType = function (type) { - for (var i = 0; i < this._entities.length; i++) { - if (this._entities[i].enabled) { - var comp = this._entities[i].getComponent(type); - if (comp) - return comp; - } - } - for (var i = 0; i < this._entitiesToAdded.length; i++) { - var entity = this._entitiesToAdded[i]; - if (entity.enabled) { - var comp = entity.getComponent(type); - if (comp) - return comp; - } - } - return null; - }; - EntityList.prototype.findComponentsOfType = function (type) { - var comps = es.ListPool.obtain(); - for (var i = 0; i < this._entities.length; i++) { - if (this._entities[i].enabled) - this._entities[i].getComponents(type, comps); - } - for (var i = 0; i < this._entitiesToAdded.length; i++) { - var entity = this._entitiesToAdded[i]; - if (entity.enabled) - entity.getComponents(type, comps); - } - return comps; - }; - return EntityList; - }()); - es.EntityList = EntityList; -})(es || (es = {})); -var es; -(function (es) { - var EntityProcessorList = (function () { - function EntityProcessorList() { - this._processors = []; - } - EntityProcessorList.prototype.add = function (processor) { - this._processors.push(processor); - }; - EntityProcessorList.prototype.remove = function (processor) { - this._processors.remove(processor); - }; - EntityProcessorList.prototype.onComponentAdded = function (entity) { - this.notifyEntityChanged(entity); - }; - EntityProcessorList.prototype.onComponentRemoved = function (entity) { - this.notifyEntityChanged(entity); - }; - EntityProcessorList.prototype.onEntityAdded = function (entity) { - this.notifyEntityChanged(entity); - }; - EntityProcessorList.prototype.onEntityRemoved = function (entity) { - this.removeFromProcessors(entity); - }; - EntityProcessorList.prototype.begin = function () { - }; - EntityProcessorList.prototype.update = function () { - for (var i = 0; i < this._processors.length; i++) { - this._processors[i].update(); - } - }; - EntityProcessorList.prototype.lateUpdate = function () { - for (var i = 0; i < this._processors.length; i++) { - this._processors[i].lateUpdate(); - } - }; - EntityProcessorList.prototype.end = function () { - }; - EntityProcessorList.prototype.getProcessor = function () { - for (var i = 0; i < this._processors.length; i++) { - var processor = this._processors[i]; - if (processor instanceof es.EntitySystem) - return processor; - } - return null; - }; - EntityProcessorList.prototype.notifyEntityChanged = function (entity) { - for (var i = 0; i < this._processors.length; i++) { - this._processors[i].onChanged(entity); - } - }; - EntityProcessorList.prototype.removeFromProcessors = function (entity) { - for (var i = 0; i < this._processors.length; i++) { - this._processors[i].remove(entity); - } - }; - return EntityProcessorList; - }()); - es.EntityProcessorList = EntityProcessorList; -})(es || (es = {})); -var es; -(function (es) { - var FasterDictionary = (function () { - function FasterDictionary(size) { - if (size === void 0) { size = 1; } - this._freeValueCellIndex = 0; - this._collisions = 0; - this._valuesInfo = new Array(size); - this._values = new Array(size); - this._buckets = new Array(es.HashHelpers.getPrime(size)); - } - FasterDictionary.prototype.getValuesArray = function (count) { - count.value = this._freeValueCellIndex; - return this._values; - }; - Object.defineProperty(FasterDictionary.prototype, "valuesArray", { - get: function () { - return this._values; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(FasterDictionary.prototype, "count", { - get: function () { - return this._freeValueCellIndex; - }, - enumerable: true, - configurable: true - }); - FasterDictionary.prototype.add = function (key, value) { - if (!this.addValue(key, value, { value: 0 })) - throw new Error("key 已经存在"); - }; - FasterDictionary.prototype.addValue = function (key, value, indexSet) { - var hash = es.HashHelpers.getHashCode(key); - var bucketIndex = FasterDictionary.reduce(hash, this._buckets.length); - if (this._freeValueCellIndex == this._values.length) { - var expandPrime = es.HashHelpers.expandPrime(this._freeValueCellIndex); - this._values.length = expandPrime; - this._valuesInfo.length = expandPrime; - } - var valueIndex = es.NumberExtension.toNumber(this._buckets[bucketIndex]) - 1; - if (valueIndex == -1) { - this._valuesInfo[this._freeValueCellIndex] = new FastNode(key, hash); - } - else { - { - var currentValueIndex = valueIndex; - do { - if (this._valuesInfo[currentValueIndex].hashcode == hash && - this._valuesInfo[currentValueIndex].key == key) { - this._values[currentValueIndex] = value; - indexSet.value = currentValueIndex; - return false; - } - currentValueIndex = this._valuesInfo[currentValueIndex].previous; - } while (currentValueIndex != -1); - } - this._collisions++; - this._valuesInfo[this._freeValueCellIndex] = new FastNode(key, hash, valueIndex); - this._valuesInfo[valueIndex].next = this._freeValueCellIndex; - } - this._buckets[bucketIndex] = (this._freeValueCellIndex + 1); - this._values[this._freeValueCellIndex] = value; - indexSet.value = this._freeValueCellIndex; - this._freeValueCellIndex++; - if (this._collisions > this._buckets.length) { - this._buckets = new Array(es.HashHelpers.expandPrime(this._collisions)); - this._collisions = 0; - for (var newValueIndex = 0; newValueIndex < this._freeValueCellIndex; newValueIndex++) { - bucketIndex = FasterDictionary.reduce(this._valuesInfo[newValueIndex].hashcode, this._buckets.length); - var existingValueIndex = es.NumberExtension.toNumber(this._buckets[bucketIndex]) - 1; - this._buckets[bucketIndex] = newValueIndex + 1; - if (existingValueIndex != -1) { - this._collisions++; - this._valuesInfo[newValueIndex].previous = existingValueIndex; - this._valuesInfo[newValueIndex].next = -1; - this._valuesInfo[existingValueIndex].next = newValueIndex; - } - else { - this._valuesInfo[newValueIndex].next = -1; - this._valuesInfo[newValueIndex].previous = -1; - } - } - } - return true; - }; - FasterDictionary.prototype.remove = function (key) { - var hash = FasterDictionary.hash(key); - var bucketIndex = FasterDictionary.reduce(hash, this._buckets.length); - var indexToValueToRemove = es.NumberExtension.toNumber(this._buckets[bucketIndex]) - 1; - while (indexToValueToRemove != -1) { - if (this._valuesInfo[indexToValueToRemove].hashcode == hash && - this._valuesInfo[indexToValueToRemove].key == key) { - if (this._buckets[bucketIndex] - 1 == indexToValueToRemove) { - if (this._valuesInfo[indexToValueToRemove].next != -1) - throw new Error("如果 bucket 指向单元格,那么 next 必须不存在。"); - var value = this._valuesInfo[indexToValueToRemove].previous; - this._buckets[bucketIndex] = value + 1; - } - else { - if (this._valuesInfo[indexToValueToRemove].next == -1) - throw new Error("如果 bucket 指向另一个单元格,则 NEXT 必须存在"); - } - FasterDictionary.updateLinkedList(indexToValueToRemove, this._valuesInfo); - break; - } - indexToValueToRemove = this._valuesInfo[indexToValueToRemove].previous; - } - if (indexToValueToRemove == -1) - return false; - this._freeValueCellIndex--; - if (indexToValueToRemove != this._freeValueCellIndex) { - var movingBucketIndex = FasterDictionary.reduce(this._valuesInfo[this._freeValueCellIndex].hashcode, this._buckets.length); - if (this._buckets[movingBucketIndex] - 1 == this._freeValueCellIndex) - this._buckets[movingBucketIndex] = (indexToValueToRemove + 1); - var next = this._valuesInfo[this._freeValueCellIndex].next; - var previous = this._valuesInfo[this._freeValueCellIndex].previous; - if (next != -1) - this._valuesInfo[next].previous = indexToValueToRemove; - if (previous != -1) - this._valuesInfo[previous].next = indexToValueToRemove; - this._valuesInfo[indexToValueToRemove] = this._valuesInfo[this._freeValueCellIndex]; - this._values[indexToValueToRemove] = this._values[this._freeValueCellIndex]; - } - return true; - }; - FasterDictionary.prototype.trim = function () { - var expandPrime = es.HashHelpers.expandPrime(this._freeValueCellIndex); - if (expandPrime < this._valuesInfo.length) { - this._values.length = expandPrime; - this._valuesInfo.length = expandPrime; - } - }; - FasterDictionary.prototype.clear = function () { - if (this._freeValueCellIndex == 0) - return; - this._freeValueCellIndex = 0; - this._buckets.length = 0; - this._values.length = 0; - this._valuesInfo.length = 0; - }; - FasterDictionary.prototype.fastClear = function () { - if (this._freeValueCellIndex == 0) - return; - this._freeValueCellIndex = 0; - this._buckets.length = 0; - this._valuesInfo.length = 0; - }; - FasterDictionary.prototype.containsKey = function (key) { - if (this.tryFindIndex(key, { value: 0 })) { - return true; - } - return false; - }; - FasterDictionary.prototype.tryGetValue = function (key) { - var findIndex = { value: 0 }; - if (this.tryFindIndex(key, findIndex)) { - return this._values[findIndex.value]; - } - return null; - }; - FasterDictionary.prototype.tryFindIndex = function (key, findIndex) { - var hash = FasterDictionary.hash(key); - var bucketIndex = FasterDictionary.reduce(hash, this._buckets.length); - var valueIndex = es.NumberExtension.toNumber(this._buckets[bucketIndex]) - 1; - while (valueIndex != -1) { - if (this._valuesInfo[valueIndex].hashcode == hash && this._valuesInfo[valueIndex].key == key) { - findIndex.value = valueIndex; - return true; - } - valueIndex = this._valuesInfo[valueIndex].previous; - } - findIndex.value = 0; - return false; - }; - FasterDictionary.prototype.getDirectValue = function (index) { - return this._values[index]; - }; - FasterDictionary.prototype.getIndex = function (key) { - var findIndex = { value: 0 }; - if (this.tryFindIndex(key, findIndex)) - return findIndex.value; - throw new Error("未找到key"); - }; - FasterDictionary.updateLinkedList = function (index, valuesInfo) { - var next = valuesInfo[index].next; - var previous = valuesInfo[index].previous; - if (next != -1) - valuesInfo[next].previous = previous; - if (previous != -1) - valuesInfo[previous].next = next; - }; - FasterDictionary.hash = function (key) { - return es.HashHelpers.getHashCode(key); - }; - FasterDictionary.reduce = function (x, n) { - if (x >= n) - return x % n; - return x; - }; - return FasterDictionary; - }()); - es.FasterDictionary = FasterDictionary; - var FastNode = (function () { - function FastNode(key, hash, previousNode) { - if (previousNode === void 0) { previousNode = -1; } - this.key = key; - this.hashcode = hash; - this.previous = previousNode; - this.next = -1; - } - return FastNode; - }()); - es.FastNode = FastNode; -})(es || (es = {})); -var es; -(function (es) { - var FastList = (function () { - function FastList(size) { - if (size === void 0) { size = 5; } - this.length = 0; - this.buffer = new Array(size); - } - FastList.prototype.clear = function () { - this.buffer.length = 0; - this.length = 0; - }; - FastList.prototype.reset = function () { - this.length = 0; - }; - FastList.prototype.add = function (item) { - if (this.length == this.buffer.length) - this.buffer.length = Math.max(this.buffer.length << 1, 10); - this.buffer[this.length++] = item; - }; - FastList.prototype.remove = function (item) { - var comp = es.EqualityComparer.default(); - for (var i = 0; i < this.length; ++i) { - if (comp.equals(this.buffer[i], item)) { - this.removeAt(i); - return; - } - } - }; - FastList.prototype.removeAt = function (index) { - if (index >= this.length) - throw new Error("index超出范围!"); - this.length--; - this.buffer.removeAt(index); - }; - FastList.prototype.contains = function (item) { - var comp = es.EqualityComparer.default(); - for (var i = 0; i < this.length; ++i) { - if (comp.equals(this.buffer[i], item)) - return true; - } - return false; - }; - FastList.prototype.ensureCapacity = function (additionalItemCount) { - if (additionalItemCount === void 0) { additionalItemCount = 1; } - if (this.length + additionalItemCount >= this.buffer.length) - this.buffer.length = Math.max(this.buffer.length << 1, this.length + additionalItemCount); - }; - FastList.prototype.addRange = function (array) { - for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { - var item = array_1[_i]; - this.add(item); - } - }; - FastList.prototype.sort = function (comparer) { - this.buffer.sort(comparer.compare); - }; - return FastList; - }()); - es.FastList = FastList; -})(es || (es = {})); -var es; -(function (es) { - var HashHelpers = (function () { - function HashHelpers() { - } - HashHelpers.isPrime = function (candidate) { - if ((candidate & 1) != 0) { - var limit = Math.sqrt(candidate); - for (var divisor = 3; divisor <= limit; divisor += 2) { - if ((candidate & divisor) == 0) - return false; - } - return true; - } - return (candidate == 2); - }; - HashHelpers.getPrime = function (min) { - if (min < 0) - throw new Error("参数错误 min不能小于0"); - for (var i = 0; i < this.primes.length; i++) { - var prime = this.primes[i]; - if (prime >= min) - return prime; - } - for (var i = (min | 1); i < Number.MAX_VALUE; i += 2) { - if (this.isPrime(i) && ((i - 1) % this.hashPrime != 0)) - return i; - } - return min; - }; - HashHelpers.expandPrime = function (oldSize) { - var newSize = 2 * oldSize; - if (newSize > this.maxPrimeArrayLength && this.maxPrimeArrayLength > oldSize) { - return this.maxPrimeArrayLength; - } - return this.getPrime(newSize); - }; - HashHelpers.getHashCode = function (str) { - var s; - if (typeof str == 'object') { - s = JSON.stringify(str); - } - else { - s = str.toString(); - } - var hash = 0; - if (s.length == 0) - return hash; - for (var i = 0; i < s.length; i++) { - var char = s.charCodeAt(i); - hash = ((hash << 5) - hash) + char; - hash = hash & hash; - } - return hash; - }; - HashHelpers.hashCollisionThreshold = 100; - HashHelpers.hashPrime = 101; - HashHelpers.primes = [3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919, - 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591, - 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, 90523, 108631, 130363, 156437, - 187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263, - 1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369]; - HashHelpers.maxPrimeArrayLength = 0x7FEFFFFD; - return HashHelpers; - }()); - es.HashHelpers = HashHelpers; -})(es || (es = {})); -var es; -(function (es) { - var Matcher = (function () { - function Matcher() { - this.allSet = new es.BitSet(); - this.exclusionSet = new es.BitSet(); - this.oneSet = new es.BitSet(); - } - Matcher.empty = function () { - return new Matcher(); - }; - Matcher.prototype.getAllSet = function () { - return this.allSet; - }; - Matcher.prototype.getExclusionSet = function () { - return this.exclusionSet; - }; - Matcher.prototype.getOneSet = function () { - return this.oneSet; - }; - Matcher.prototype.IsIntersted = function (e) { - if (!this.allSet.isEmpty()) { - for (var i = this.allSet.nextSetBit(0); i >= 0; i = this.allSet.nextSetBit(i + 1)) { - if (!e.componentBits.get(i)) - return false; - } - } - if (!this.exclusionSet.isEmpty() && this.exclusionSet.intersects(e.componentBits)) - return false; - if (!this.oneSet.isEmpty() && !this.oneSet.intersects(e.componentBits)) - return false; - return true; - }; - Matcher.prototype.all = function () { - var _this = this; - var types = []; - for (var _i = 0; _i < arguments.length; _i++) { - types[_i] = arguments[_i]; - } - types.forEach(function (type) { - _this.allSet.set(es.ComponentTypeManager.getIndexFor(type)); - }); - return this; - }; - Matcher.prototype.exclude = function () { - var _this = this; - var types = []; - for (var _i = 0; _i < arguments.length; _i++) { - types[_i] = arguments[_i]; - } - types.forEach(function (type) { - _this.exclusionSet.set(es.ComponentTypeManager.getIndexFor(type)); - }); - return this; - }; - Matcher.prototype.one = function () { - var _this = this; - var types = []; - for (var _i = 0; _i < arguments.length; _i++) { - types[_i] = arguments[_i]; - } - types.forEach(function (type) { - _this.oneSet.set(es.ComponentTypeManager.getIndexFor(type)); - }); - return this; - }; - return Matcher; - }()); - es.Matcher = Matcher; -})(es || (es = {})); -var ObjectUtils = (function () { - function ObjectUtils() { - } - ObjectUtils.clone = function (p, c) { - if (c === void 0) { c = null; } - var c = c || {}; - for (var i in p) { - if (typeof p[i] === 'object') { - c[i] = p[i] instanceof Array ? [] : {}; - this.clone(p[i], c[i]); - } - else { - c[i] = p[i]; - } - } - return c; - }; - ObjectUtils.elements = function (p) { - var c = []; - for (var i in p) { - if (Array.isArray(p[i])) { - for (var _i = 0, _a = p[i]; _i < _a.length; _i++) { - var v = _a[_i]; - c.push(v); - } - } - else { - c.push(p[i]); - } - } - return c; - }; - return ObjectUtils; -}()); -var es; -(function (es) { - var RenderableComparer = (function () { - function RenderableComparer() { - } - RenderableComparer.prototype.compare = function (self, other) { - return other.renderLayer - self.renderLayer; - }; - return RenderableComparer; - }()); - es.RenderableComparer = RenderableComparer; -})(es || (es = {})); -var es; -(function (es) { - var RenderableComponentList = (function () { - function RenderableComponentList() { - this._components = []; - this._componentsByRenderLayer = new Map(); - this._unsortedRenderLayers = []; - this._componentsNeedSort = true; - } - Object.defineProperty(RenderableComponentList.prototype, "componentsNeedSort", { - get: function () { - return this._componentsNeedSort; - }, - set: function (value) { - this._componentsNeedSort = value; - es.Core.scene.sortableChildren = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponentList.prototype, "count", { - get: function () { - return this._components.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponentList.prototype, "buffer", { - get: function () { - return this._components; - }, - enumerable: true, - configurable: true - }); - RenderableComponentList.prototype.add = function (component) { - this._components.push(component); - this.addToRenderLayerList(component, component.renderLayer); - }; - RenderableComponentList.prototype.remove = function (component) { - this._components.remove(component); - this._componentsByRenderLayer.get(component.renderLayer).remove(component); - }; - RenderableComponentList.prototype.updateRenderableRenderLayer = function (component, oldRenderLayer, newRenderLayer) { - if (this._componentsByRenderLayer.has(oldRenderLayer) && this._componentsByRenderLayer.get(oldRenderLayer).contains(component)) { - this._componentsByRenderLayer.get(oldRenderLayer).remove(component); - this.addToRenderLayerList(component, newRenderLayer); - } - }; - RenderableComponentList.prototype.setRenderLayerNeedsComponentSort = function (renderLayer) { - if (!this._unsortedRenderLayers.contains(renderLayer)) - this._unsortedRenderLayers.push(renderLayer); - this.componentsNeedSort = true; - }; - RenderableComponentList.prototype.setNeedsComponentSort = function () { - this.componentsNeedSort = true; - }; - RenderableComponentList.prototype.addToRenderLayerList = function (component, renderLayer) { - var list = this.componentsWithRenderLayer(renderLayer); - if (list.contains(component)) { - console.warn("组件呈现层列表已经包含此组件"); - return; - } - list.push(component); - if (!this._unsortedRenderLayers.contains(renderLayer)) - this._unsortedRenderLayers.push(renderLayer); - this.componentsNeedSort = true; - }; - RenderableComponentList.prototype.componentsWithRenderLayer = function (renderLayer) { - if (!this._componentsByRenderLayer.get(renderLayer)) { - this._componentsByRenderLayer.set(renderLayer, []); - } - return this._componentsByRenderLayer.get(renderLayer); - }; - RenderableComponentList.prototype.updateList = function () { - if (this.componentsNeedSort) { - this._components.sort(RenderableComponentList.compareUpdatableOrder.compare); - this.componentsNeedSort = false; - } - if (this._unsortedRenderLayers.length > 0) { - for (var i = 0, count = this._unsortedRenderLayers.length; i < count; i++) { - var renderLayerComponents = this._componentsByRenderLayer.get(this._unsortedRenderLayers[i]); - if (renderLayerComponents) { - renderLayerComponents.sort(RenderableComponentList.compareUpdatableOrder.compare); - } - } - this._unsortedRenderLayers.length = 0; - } - }; - RenderableComponentList.compareUpdatableOrder = new es.RenderableComparer(); - return RenderableComponentList; - }()); - es.RenderableComponentList = RenderableComponentList; -})(es || (es = {})); -var StringUtils = (function () { - function StringUtils() { - } - StringUtils.matchChineseWord = function (str) { - var patternA = /[\u4E00-\u9FA5]+/gim; - return str.match(patternA); - }; - StringUtils.lTrim = function (target) { - var startIndex = 0; - while (this.isWhiteSpace(target.charAt(startIndex))) { - startIndex++; - } - return target.slice(startIndex, target.length); - }; - StringUtils.rTrim = function (target) { - var endIndex = target.length - 1; - while (this.isWhiteSpace(target.charAt(endIndex))) { - endIndex--; - } - return target.slice(0, endIndex + 1); - }; - StringUtils.trim = function (target) { - if (target == null) { - return null; - } - return this.rTrim(this.lTrim(target)); - }; - StringUtils.isWhiteSpace = function (str) { - if (str == " " || str == "\t" || str == "\r" || str == "\n") - return true; - return false; - }; - StringUtils.replaceMatch = function (mainStr, targetStr, replaceStr, caseMark) { - if (caseMark === void 0) { caseMark = false; } - var len = mainStr.length; - var tempStr = ""; - var isMatch = false; - var tempTarget = caseMark == true ? targetStr.toLowerCase() : targetStr; - for (var i = 0; i < len; i++) { - isMatch = false; - if (mainStr.charAt(i) == tempTarget.charAt(0)) { - if (mainStr.substr(i, tempTarget.length) == tempTarget) { - isMatch = true; - } - } - if (isMatch) { - tempStr += replaceStr; - i = i + tempTarget.length - 1; - } - else { - tempStr += mainStr.charAt(i); - } - } - return tempStr; - }; - StringUtils.htmlSpecialChars = function (str, reversion) { - if (reversion === void 0) { reversion = false; } - var len = this.specialSigns.length; - for (var i = 0; i < len; i += 2) { - var from = void 0; - var to = void 0; - from = this.specialSigns[i]; - to = this.specialSigns[i + 1]; - if (reversion) { - var temp = from; - from = to; - to = temp; - } - str = this.replaceMatch(str, from, to); - } - return str; - }; - StringUtils.zfill = function (str, width) { - if (width === void 0) { width = 2; } - if (!str) { - return str; - } - width = Math.floor(width); - var slen = str.length; - if (slen >= width) { - return str; - } - var negative = false; - if (str.substr(0, 1) == '-') { - negative = true; - str = str.substr(1); - } - var len = width - slen; - for (var i = 0; i < len; i++) { - str = '0' + str; - } - if (negative) { - str = '-' + str; - } - return str; - }; - StringUtils.reverse = function (str) { - if (str.length > 1) - return this.reverse(str.substring(1)) + str.substring(0, 1); - else - return str; - }; - StringUtils.cutOff = function (str, start, len, order) { - if (order === void 0) { order = true; } - start = Math.floor(start); - len = Math.floor(len); - var length = str.length; - if (start > length) - start = length; - var s = start; - var e = start + len; - var newStr; - if (order) { - newStr = str.substring(0, s) + str.substr(e, length); - } - else { - s = length - 1 - start - len; - e = s + len; - newStr = str.substring(0, s + 1) + str.substr(e + 1, length); - } - return newStr; - }; - StringUtils.strReplace = function (str, rStr) { - var i = 0, len = rStr.length; - for (; i < len; i++) { - if (rStr[i] == null || rStr[i] == "") { - rStr[i] = "无"; - } - str = str.replace("{" + i + "}", rStr[i]); - } - return str; - }; - StringUtils.specialSigns = [ - '&', '&', - '<', '<', - '>', '>', - '"', '"', - "'", ''', - '®', '®', - '©', '©', - '™', '™', - ]; - return StringUtils; -}()); -var es; -(function (es) { - var TextureUtils = (function () { - function TextureUtils() { - } - TextureUtils.convertImageToCanvas = function (texture, rect) { - if (!this.sharedCanvas) { - this.sharedCanvas = egret.sys.createCanvas(); - this.sharedContext = this.sharedCanvas.getContext("2d"); - } - var w = texture.$getTextureWidth(); - var h = texture.$getTextureHeight(); - if (!rect) { - rect = egret.$TempRectangle; - rect.x = 0; - rect.y = 0; - rect.width = w; - rect.height = h; - } - rect.x = Math.min(rect.x, w - 1); - rect.y = Math.min(rect.y, h - 1); - rect.width = Math.min(rect.width, w - rect.x); - rect.height = Math.min(rect.height, h - rect.y); - var iWidth = Math.floor(rect.width); - var iHeight = Math.floor(rect.height); - var surface = this.sharedCanvas; - surface["style"]["width"] = iWidth + "px"; - surface["style"]["height"] = iHeight + "px"; - this.sharedCanvas.width = iWidth; - this.sharedCanvas.height = iHeight; - if (egret.Capabilities.renderMode == "webgl") { - var renderTexture = void 0; - if (!texture.$renderBuffer) { - if (egret.sys.systemRenderer["renderClear"]) { - egret.sys.systemRenderer["renderClear"](); - } - renderTexture = new egret.RenderTexture(); - renderTexture.drawToTexture(new egret.Bitmap(texture)); - } - else { - renderTexture = texture; - } - var pixels = renderTexture.$renderBuffer.getPixels(rect.x, rect.y, iWidth, iHeight); - var x = 0; - var y = 0; - for (var i = 0; i < pixels.length; i += 4) { - this.sharedContext.fillStyle = - 'rgba(' + pixels[i] - + ',' + pixels[i + 1] - + ',' + pixels[i + 2] - + ',' + (pixels[i + 3] / 255) + ')'; - this.sharedContext.fillRect(x, y, 1, 1); - x++; - if (x == iWidth) { - x = 0; - y++; - } - } - if (!texture.$renderBuffer) { - renderTexture.dispose(); - } - return surface; - } - else { - var bitmapData = texture; - var offsetX = Math.round(bitmapData.$offsetX); - var offsetY = Math.round(bitmapData.$offsetY); - var bitmapWidth = bitmapData.$bitmapWidth; - var bitmapHeight = bitmapData.$bitmapHeight; - var $TextureScaleFactor = es.Core._instance.stage.textureScaleFactor; - this.sharedContext.drawImage(bitmapData.$bitmapData.source, bitmapData.$bitmapX + rect.x / $TextureScaleFactor, bitmapData.$bitmapY + rect.y / $TextureScaleFactor, bitmapWidth * rect.width / w, bitmapHeight * rect.height / h, offsetX, offsetY, rect.width, rect.height); - return surface; - } - }; - TextureUtils.toDataURL = function (type, texture, rect, encoderOptions) { - try { - var surface = this.convertImageToCanvas(texture, rect); - var result = surface.toDataURL(type, encoderOptions); - return result; - } - catch (e) { - egret.$error(1033); - } - return null; - }; - TextureUtils.eliFoTevas = function (type, texture, filePath, rect, encoderOptions) { - var surface = this.convertImageToCanvas(texture, rect); - var result = surface.toTempFilePathSync({ - fileType: type.indexOf("png") >= 0 ? "png" : "jpg" - }); - wx.getFileSystemManager().saveFile({ - tempFilePath: result, - filePath: wx.env.USER_DATA_PATH + "/" + filePath, - success: function (res) { - } - }); - return result; - }; - TextureUtils.getPixel32 = function (texture, x, y) { - egret.$warn(1041, "getPixel32", "getPixels"); - return texture.getPixels(x, y); - }; - TextureUtils.getPixels = function (texture, x, y, width, height) { - if (width === void 0) { width = 1; } - if (height === void 0) { height = 1; } - if (egret.Capabilities.renderMode == "webgl") { - var renderTexture = void 0; - if (!texture.$renderBuffer) { - renderTexture = new egret.RenderTexture(); - renderTexture.drawToTexture(new egret.Bitmap(texture)); - } - else { - renderTexture = texture; - } - var pixels = renderTexture.$renderBuffer.getPixels(x, y, width, height); - return pixels; - } - try { - var surface = this.convertImageToCanvas(texture); - var result = this.sharedContext.getImageData(x, y, width, height).data; - return result; - } - catch (e) { - egret.$error(1039); - } - }; - return TextureUtils; - }()); - es.TextureUtils = TextureUtils; -})(es || (es = {})); -var es; -(function (es) { - var Time = (function () { - function Time() { - } - Time.update = function (currentTime) { - var dt = (currentTime - this._lastTime) / 1000; - this.deltaTime = dt * this.timeScale; - this.unscaledDeltaTime = dt; - this._timeSinceSceneLoad += dt; - this.frameCount++; - this._lastTime = currentTime; - }; - Time.sceneChanged = function () { - this._timeSinceSceneLoad = 0; - }; - Time.checkEvery = function (interval) { - return Math.floor(this._timeSinceSceneLoad / interval) > Math.floor((this._timeSinceSceneLoad - this.deltaTime) / interval); - }; - Time.deltaTime = 0; - Time.timeScale = 1; - Time.frameCount = 0; - Time._lastTime = 0; - return Time; - }()); - es.Time = Time; -})(es || (es = {})); -var TimeUtils = (function () { - function TimeUtils() { - } - TimeUtils.monthId = function (d) { - if (d === void 0) { d = null; } - d = d ? d : new Date(); - var y = d.getFullYear(); - var m = d.getMonth() + 1; - var g = m < 10 ? "0" : ""; - return parseInt(y + g + m); - }; - TimeUtils.dateId = function (t) { - if (t === void 0) { t = null; } - t = t ? t : new Date(); - var m = t.getMonth() + 1; - var a = m < 10 ? "0" : ""; - var d = t.getDate(); - var b = d < 10 ? "0" : ""; - return parseInt(t.getFullYear() + a + m + b + d); - }; - TimeUtils.weekId = function (d, first) { - if (d === void 0) { d = null; } - if (first === void 0) { first = true; } - d = d ? d : new Date(); - var c = new Date(); - c.setTime(d.getTime()); - c.setDate(1); - c.setMonth(0); - var year = c.getFullYear(); - var firstDay = c.getDay(); - if (firstDay == 0) { - firstDay = 7; - } - var max = false; - if (firstDay <= 4) { - max = firstDay > 1; - c.setDate(c.getDate() - (firstDay - 1)); - } - else { - c.setDate(c.getDate() + 7 - firstDay + 1); - } - var num = this.diffDay(d, c, false); - if (num < 0) { - c.setDate(1); - c.setMonth(0); - c.setDate(c.getDate() - 1); - return this.weekId(c, false); - } - var week = num / 7; - var weekIdx = Math.floor(week) + 1; - if (weekIdx == 53) { - c.setTime(d.getTime()); - c.setDate(c.getDate() - 1); - var endDay = c.getDay(); - if (endDay == 0) { - endDay = 7; - } - if (first && (!max || endDay < 4)) { - c.setFullYear(c.getFullYear() + 1); - c.setDate(1); - c.setMonth(0); - return this.weekId(c, false); - } - } - var g = weekIdx > 9 ? "" : "0"; - var s = year + "00" + g + weekIdx; - return parseInt(s); - }; - TimeUtils.diffDay = function (a, b, fixOne) { - if (fixOne === void 0) { fixOne = false; } - var x = (a.getTime() - b.getTime()) / 86400000; - return fixOne ? Math.ceil(x) : Math.floor(x); - }; - TimeUtils.getFirstDayOfWeek = function (d) { - d = d ? d : new Date(); - var day = d.getDay() || 7; - return new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1 - day, 0, 0, 0, 0); - }; - TimeUtils.getFirstOfDay = function (d) { - d = d ? d : new Date(); - d.setHours(0, 0, 0, 0); - return d; - }; - TimeUtils.getNextFirstOfDay = function (d) { - return new Date(this.getFirstOfDay(d).getTime() + 86400000); - }; - TimeUtils.formatDate = function (date) { - var y = date.getFullYear(); - var m = date.getMonth() + 1; - m = m < 10 ? '0' + m : m; - var d = date.getDate(); - d = d < 10 ? ('0' + d) : d; - return y + '-' + m + '-' + d; - }; - TimeUtils.formatDateTime = function (date) { - var y = date.getFullYear(); - var m = date.getMonth() + 1; - m = m < 10 ? ('0' + m) : m; - var d = date.getDate(); - d = d < 10 ? ('0' + d) : d; - var h = date.getHours(); - var i = date.getMinutes(); - i = i < 10 ? ('0' + i) : i; - var s = date.getSeconds(); - s = s < 10 ? ('0' + s) : s; - return y + '-' + m + '-' + d + ' ' + h + ':' + i + ":" + s; - }; - TimeUtils.parseDate = function (s) { - var t = Date.parse(s); - if (!isNaN(t)) { - return new Date(Date.parse(s.replace(/-/g, "/"))); - } - else { - return new Date(); - } - }; - TimeUtils.secondToTime = function (time, partition, showHour) { - if (time === void 0) { time = 0; } - if (partition === void 0) { partition = ":"; } - if (showHour === void 0) { showHour = true; } - var hours = Math.floor(time / 3600); - var minutes = Math.floor(time % 3600 / 60); - var seconds = Math.floor(time % 3600 % 60); - var h = hours.toString(); - var m = minutes.toString(); - var s = seconds.toString(); - if (hours < 10) - h = "0" + h; - if (minutes < 10) - m = "0" + m; - if (seconds < 10) - s = "0" + s; - var timeStr; - if (showHour) - timeStr = h + partition + m + partition + s; - else - timeStr = m + partition + s; - return timeStr; - }; - TimeUtils.timeToMillisecond = function (time, partition) { - if (partition === void 0) { partition = ":"; } - var _ary = time.split(partition); - var timeNum = 0; - var len = _ary.length; - for (var i = 0; i < len; i++) { - var n = _ary[i]; - timeNum += n * Math.pow(60, (len - 1 - i)); - } - timeNum *= 1000; - return timeNum.toString(); - }; - return TimeUtils; -}()); -var es; -(function (es) { - var Graphics = (function () { - function Graphics() { - var _this = this; - var arrayBuffer = new ArrayBuffer(1); - arrayBuffer[0] = 0xffffff; - egret.BitmapData.create("arraybuffer", arrayBuffer, function (bitmapData) { - var tex = new egret.Texture(); - tex.bitmapData = bitmapData; - _this.pixelTexture = new es.Sprite(tex); - }); - } - return Graphics; - }()); - es.Graphics = Graphics; -})(es || (es = {})); -var es; -(function (es) { - var GraphicsCapabilities = (function (_super) { - __extends(GraphicsCapabilities, _super); - function GraphicsCapabilities() { - return _super !== null && _super.apply(this, arguments) || this; - } - GraphicsCapabilities.prototype.initialize = function (device) { - this.platformInitialize(device); - }; - GraphicsCapabilities.prototype.platformInitialize = function (device) { - if (GraphicsCapabilities.runtimeType != egret.RuntimeType.WXGAME) - return; - var capabilities = this; - capabilities["isMobile"] = true; - var systemInfo = wx.getSystemInfoSync(); - var systemStr = systemInfo.system.toLowerCase(); - if (systemStr.indexOf("ios") > -1) { - capabilities["os"] = "iOS"; - } - else if (systemStr.indexOf("android") > -1) { - capabilities["os"] = "Android"; - } - var language = systemInfo.language; - if (language.indexOf('zh') > -1) { - language = "zh-CN"; - } - else { - language = "en-US"; - } - capabilities["language"] = language; - }; - return GraphicsCapabilities; - }(egret.Capabilities)); - es.GraphicsCapabilities = GraphicsCapabilities; -})(es || (es = {})); -var es; -(function (es) { - var GraphicsDevice = (function () { - function GraphicsDevice() { - this.setup(); - this.graphicsCapabilities = new es.GraphicsCapabilities(); - this.graphicsCapabilities.initialize(this); - } - Object.defineProperty(GraphicsDevice.prototype, "viewport", { - get: function () { - return this._viewport; - }, - enumerable: true, - configurable: true - }); - GraphicsDevice.prototype.setup = function () { - this._viewport = new es.Viewport(0, 0, es.Core._instance.stage.stageWidth, es.Core._instance.stage.stageHeight); - }; - return GraphicsDevice; - }()); - es.GraphicsDevice = GraphicsDevice; -})(es || (es = {})); -var es; -(function (es) { - var Viewport = (function () { - function Viewport(x, y, width, height) { - this._x = x; - this._y = y; - this._width = width; - this._height = height; - this._minDepth = 0; - this._maxDepth = 1; - } - Object.defineProperty(Viewport.prototype, "width", { - get: function () { - return this._width; - }, - set: function (value) { - this._width = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Viewport.prototype, "height", { - get: function () { - return this._height; - }, - set: function (value) { - this._height = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Viewport.prototype, "aspectRatio", { - get: function () { - if ((this._height != 0) && (this._width != 0)) - return (this._width / this._height); - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Viewport.prototype, "bounds", { - get: function () { - return new es.Rectangle(this._x, this._y, this._width, this._height); - }, - set: function (value) { - this._x = value.x; - this._y = value.y; - this._width = value.width; - this._height = value.height; - }, - enumerable: true, - configurable: true - }); - return Viewport; - }()); - es.Viewport = Viewport; -})(es || (es = {})); -var es; -(function (es) { - var GaussianBlurEffect = (function (_super) { - __extends(GaussianBlurEffect, _super); - function GaussianBlurEffect() { - return _super.call(this, es.PostProcessor.default_vert, GaussianBlurEffect.blur_frag, { - screenWidth: es.Core.graphicsDevice.viewport.width, - screenHeight: es.Core.graphicsDevice.viewport.height - }) || this; - } - GaussianBlurEffect.blur_frag = "precision mediump float;\n" + - "uniform sampler2D uSampler;\n" + - "uniform float screenWidth;\n" + - "uniform float screenHeight;\n" + - "float normpdf(in float x, in float sigma)\n" + - "{\n" + - "return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n" + - "}\n" + - "void main()\n" + - "{\n" + - "vec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\n" + - "const int mSize = 11;\n" + - "const int kSize = (mSize - 1)/2;\n" + - "float kernel[mSize];\n" + - "vec3 final_colour = vec3(0.0);\n" + - "float sigma = 7.0;\n" + - "float z = 0.0;\n" + - "for (int j = 0; j <= kSize; ++j)\n" + - "{\n" + - "kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n" + - "}\n" + - "for (int j = 0; j < mSize; ++j)\n" + - "{\n" + - "z += kernel[j];\n" + - "}\n" + - "for (int i = -kSize; i <= kSize; ++i)\n" + - "{\n" + - "for (int j = -kSize; j <= kSize; ++j)\n" + - "{\n" + - "final_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n" + - "}\n}\n" + - "gl_FragColor = vec4(final_colour/(z*z), 1.0);\n" + - "}"; - return GaussianBlurEffect; - }(egret.CustomFilter)); - es.GaussianBlurEffect = GaussianBlurEffect; -})(es || (es = {})); -var es; -(function (es) { - var PolygonLightEffect = (function (_super) { - __extends(PolygonLightEffect, _super); - function PolygonLightEffect() { - return _super.call(this, PolygonLightEffect.vertSrc, PolygonLightEffect.fragmentSrc) || this; - } - PolygonLightEffect.vertSrc = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - "uniform vec2 projectionVector;\n" + - "varying vec2 vTextureCoord;\n" + - "const vec2 center = vec2(-1.0, 1.0);\n" + - "void main(void) {\n" + - " gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - " vTextureCoord = aTextureCoord;\n" + - "}"; - PolygonLightEffect.fragmentSrc = "precision lowp float;\n" + - "varying vec2 vTextureCoord;\n" + - "uniform sampler2D uSampler;\n" + - "#define SAMPLE_COUNT 15\n" + - "uniform vec2 _sampleOffsets[SAMPLE_COUNT];\n" + - "uniform float _sampleWeights[SAMPLE_COUNT];\n" + - "void main(void) {\n" + - "vec4 c = vec4(0, 0, 0, 0);\n" + - "for( int i = 0; i < SAMPLE_COUNT; i++ )\n" + - " c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\n" + - "gl_FragColor = c;\n" + - "}"; - return PolygonLightEffect; - }(egret.CustomFilter)); - es.PolygonLightEffect = PolygonLightEffect; -})(es || (es = {})); -var es; -(function (es) { - var PostProcessor = (function () { - function PostProcessor(effect) { - if (effect === void 0) { effect = null; } - this.enabled = true; - this.effect = effect; - } - PostProcessor.prototype.onAddedToScene = function (scene) { - this.scene = scene; - this.shape = new egret.Shape(); - this.shape.graphics.beginFill(0xFFFFFF, 1); - this.shape.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this.shape.graphics.endFill(); - scene.addChild(this.shape); - }; - PostProcessor.prototype.process = function () { - this.drawFullscreenQuad(); - }; - PostProcessor.prototype.onSceneBackBufferSizeChanged = function (newWidth, newHeight) { - }; - PostProcessor.prototype.unload = function () { - if (this.effect) { - this.effect = null; - } - this.scene.removeChild(this.shape); - this.scene = null; - }; - PostProcessor.prototype.drawFullscreenQuad = function () { - this.scene.filters = [this.effect]; - }; - PostProcessor.default_vert = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - "attribute vec2 aColor;\n" + - "uniform vec2 projectionVector;\n" + - "varying vec2 vTextureCoord;\n" + - "varying vec4 vColor;\n" + - "const vec2 center = vec2(-1.0, 1.0);\n" + - "void main(void) {\n" + - "gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - "vTextureCoord = aTextureCoord;\n" + - "vColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n" + - "}"; - return PostProcessor; - }()); - es.PostProcessor = PostProcessor; -})(es || (es = {})); -var es; -(function (es) { - var GaussianBlurPostProcessor = (function (_super) { - __extends(GaussianBlurPostProcessor, _super); - function GaussianBlurPostProcessor() { - return _super !== null && _super.apply(this, arguments) || this; - } - GaussianBlurPostProcessor.prototype.onAddedToScene = function (scene) { - _super.prototype.onAddedToScene.call(this, scene); - this.effect = new es.GaussianBlurEffect(); - }; - return GaussianBlurPostProcessor; - }(es.PostProcessor)); - es.GaussianBlurPostProcessor = GaussianBlurPostProcessor; -})(es || (es = {})); -var es; -(function (es) { - var Renderer = (function () { - function Renderer(renderOrder, camera) { - if (camera === void 0) { camera = null; } - this.renderOrder = 0; - this.shouldDebugRender = true; - this.camera = camera; - this.renderOrder = renderOrder; - } - Object.defineProperty(Renderer.prototype, "wantsToRenderToSceneRenderTarget", { - get: function () { - return !!this.renderTexture; - }, - enumerable: true, - configurable: true - }); - Renderer.prototype.onAddedToScene = function (scene) { - }; - Renderer.prototype.unload = function () { - }; - Renderer.prototype.onSceneBackBufferSizeChanged = function (newWidth, newHeight) { - }; - Renderer.prototype.compareTo = function (other) { - return this.renderOrder - other.renderOrder; - }; - Renderer.prototype.beginRender = function (cam) { - }; - Renderer.prototype.renderAfterStateCheck = function (renderable, cam) { - renderable.render(cam); - }; - Renderer.prototype.debugRender = function (scene, cam) { - for (var i = 0; i < scene.entities.count; i++) { - var entity = scene.entities.buffer[i]; - if (entity.enabled) - entity.debugRender(cam); - } - }; - return Renderer; - }()); - es.Renderer = Renderer; -})(es || (es = {})); -var es; -(function (es) { - var DefaultRenderer = (function (_super) { - __extends(DefaultRenderer, _super); - function DefaultRenderer() { - return _super.call(this, 0, null) || this; - } - DefaultRenderer.prototype.render = function (scene) { - var cam = this.camera ? this.camera : scene.camera; - this.beginRender(cam); - for (var i = 0; i < scene.renderableComponents.count; i++) { - var renderable = scene.renderableComponents.buffer[i]; - if (renderable.enabled && renderable.isVisibleFromCamera(cam)) - this.renderAfterStateCheck(renderable, cam); - } - }; - return DefaultRenderer; - }(es.Renderer)); - es.DefaultRenderer = DefaultRenderer; -})(es || (es = {})); -var es; -(function (es) { - var RenderLayerExcludeRenderer = (function (_super) { - __extends(RenderLayerExcludeRenderer, _super); - function RenderLayerExcludeRenderer(renderOrder) { - var excludedRenderLayers = []; - for (var _i = 1; _i < arguments.length; _i++) { - excludedRenderLayers[_i - 1] = arguments[_i]; - } - var _this = _super.call(this, renderOrder, null) || this; - _this.excludedRenderLayers = excludedRenderLayers; - return _this; - } - RenderLayerExcludeRenderer.prototype.render = function (scene) { - var cam = this.camera ? this.camera : scene.camera; - this.beginRender(cam); - for (var i = 0; i < scene.renderableComponents.count; i++) { - var renderable = scene.renderableComponents.buffer[i]; - if (!this.excludedRenderLayers.contains(renderable.renderLayer) && renderable.enabled && - renderable.isVisibleFromCamera(cam)) - this.renderAfterStateCheck(renderable, cam); - } - if (this.shouldDebugRender && es.Core.debugRenderEndabled) - this.debugRender(scene, cam); - }; - RenderLayerExcludeRenderer.prototype.debugRender = function (scene, cam) { - for (var i = 0; i < scene.renderableComponents.count; i++) { - var renderable = scene.renderableComponents.buffer[i]; - if (!this.excludedRenderLayers.contains(renderable.renderLayer) && renderable.enabled && - renderable.isVisibleFromCamera(cam)) - renderable.debugRender(cam); - } - _super.prototype.debugRender.call(this, scene, cam); - }; - return RenderLayerExcludeRenderer; - }(es.Renderer)); - es.RenderLayerExcludeRenderer = RenderLayerExcludeRenderer; -})(es || (es = {})); -var es; -(function (es) { - var ScreenSpaceRenderer = (function (_super) { - __extends(ScreenSpaceRenderer, _super); - function ScreenSpaceRenderer(renderOrder) { - var renderLayers = []; - for (var _i = 1; _i < arguments.length; _i++) { - renderLayers[_i - 1] = arguments[_i]; - } - var _this = _super.call(this, renderOrder, null) || this; - renderLayers.sort(); - renderLayers.reverse(); - _this.renderLayers = renderLayers; - return _this; - } - ScreenSpaceRenderer.prototype.render = function (scene) { - this.beginRender(this.camera); - for (var i = 0; i < this.renderLayers.length; i++) { - var renderables = scene.renderableComponents.componentsWithRenderLayer(this.renderLayers[i]); - for (var j = 0; j < renderables.length; j++) { - var renderable = renderables[j]; - if (renderable.enabled && renderable.isVisibleFromCamera(this.camera)) - this.renderAfterStateCheck(renderable, this.camera); - } - } - if (this.shouldDebugRender && es.Core.debugRenderEndabled) - this.debugRender(scene, this.camera); - }; - ScreenSpaceRenderer.prototype.debugRender = function (scene, cam) { - for (var i = 0; i < this.renderLayers.length; i++) { - var renderables = scene.renderableComponents.componentsWithRenderLayer(this.renderLayers[i]); - for (var j = 0; j < renderables.length; j++) { - var entity = renderables[j]; - if (entity.enabled) - entity.debugRender(cam); - } - } - }; - ScreenSpaceRenderer.prototype.onSceneBackBufferSizeChanged = function (newWidth, newHeight) { - _super.prototype.onSceneBackBufferSizeChanged.call(this, newWidth, newHeight); - if (!this.camera) - this.camera = es.Core.scene.createEntity("screenspace camera").addComponent(new es.Camera()); - }; - return ScreenSpaceRenderer; - }(es.Renderer)); - es.ScreenSpaceRenderer = ScreenSpaceRenderer; -})(es || (es = {})); -var es; -(function (es) { - var PolyLight = (function (_super) { - __extends(PolyLight, _super); - function PolyLight(radius, color, power) { - var _this = _super.call(this) || this; - _this._indices = []; - _this.radius = radius; - _this.power = power; - _this.color = color; - _this.computeTriangleIndices(); - return _this; - } - Object.defineProperty(PolyLight.prototype, "radius", { - get: function () { - return this._radius; - }, - set: function (value) { - this.setRadius(value); - }, - enumerable: true, - configurable: true - }); - PolyLight.prototype.setRadius = function (radius) { - if (radius != this._radius) { - this._radius = radius; - this._areBoundsDirty = true; - } - }; - PolyLight.prototype.render = function (camera) { - }; - PolyLight.prototype.reset = function () { - }; - PolyLight.prototype.computeTriangleIndices = function (totalTris) { - if (totalTris === void 0) { totalTris = 20; } - this._indices.length = 0; - for (var i = 0; i < totalTris; i += 2) { - this._indices.push(0); - this._indices.push(i + 2); - this._indices.push(i + 1); - } - }; - return PolyLight; - }(es.RenderableComponent)); - es.PolyLight = PolyLight; -})(es || (es = {})); -var es; -(function (es) { - var GaussianBlur = (function () { - function GaussianBlur() { - } - GaussianBlur.createBlurredTexture = function (image, deviation) { - if (deviation === void 0) { deviation = 1; } - var pixelData = image.getPixels(0, 0, image.textureWidth, image.textureHeight); - var srcData = new Array(image.textureWidth * image.textureHeight); - for (var i = 0; i < image.textureWidth; i++) { - for (var j = 0; j < image.textureHeight; j++) { - var width = image.textureWidth; - var r = pixelData[i * 4 + j * width]; - var g = pixelData[i * 4 + j * width + 1]; - var b = pixelData[i * 4 + j * width + 2]; - var a = pixelData[i * 4 + j * width + 3]; - srcData[i + j * width] = new es.Color(r, g, b, a); - } - } - var destData = this.createBlurredTextureData(srcData, image.textureWidth, image.textureHeight, deviation); - var arrayBuffer = new ArrayBuffer(destData.length); - destData.forEach(function (value, index) { - arrayBuffer[index] = value.packedValue; - }); - egret.BitmapData.create("arraybuffer", arrayBuffer, function (bitmapData) { - }); - }; - GaussianBlur.createBlurredTextureData = function (srcData, width, height, deviation) { - if (deviation === void 0) { deviation = 1; } - var matrixR = new es.FasterDictionary(); - var matrixG = new es.FasterDictionary(); - var matrixB = new es.FasterDictionary(); - var matrixA = new es.FasterDictionary(); - var destData = new Array(width * height); - for (var i = 0; i < width; i++) { - for (var j = 0; j < height; j++) { - matrixR.add({ x: i, y: j }, srcData[i + j * width].r); - matrixG.add({ x: i, y: j }, srcData[i + j * width].g); - matrixB.add({ x: i, y: j }, srcData[i + j * width].b); - matrixA.add({ x: i, y: j }, srcData[i + j * width].a); - } - } - matrixR = this.gaussianConvolution(matrixR, deviation); - matrixG = this.gaussianConvolution(matrixG, deviation); - matrixB = this.gaussianConvolution(matrixB, deviation); - matrixA = this.gaussianConvolution(matrixA, deviation); - for (var i = 0; i < width; i++) { - for (var j = 0; j < height; j++) { - var r = Math.min(255, matrixR.tryGetValue({ x: i, y: j })); - var g = Math.min(255, matrixG.tryGetValue({ x: i, y: j })); - var b = Math.min(255, matrixB.tryGetValue({ x: i, y: j })); - var a = Math.min(255, matrixA.tryGetValue({ x: i, y: j })); - destData[i + j * width] = new es.Color(r, g, b, a); - } - } - return destData; - }; - GaussianBlur.gaussianConvolution = function (matrix, deviation) { - var kernel = this.calculateNormalized1DSampleKernel(deviation); - var res1 = new es.FasterDictionary(); - var res2 = new es.FasterDictionary(); - for (var i = 0; i < matrix._valuesInfo.length; i++) { - for (var j = 0; j < matrix.valuesArray.length; j++) - res1.add({ x: i, y: j }, this.processPoint(matrix, i, j, kernel, 0)); - } - for (var i = 0; i < matrix._valuesInfo.length; i++) { - for (var j = 0; j < matrix.valuesArray.length; j++) - res2.add({ x: i, y: j }, this.processPoint(res1, i, j, kernel, 1)); - } - return res2; - }; - GaussianBlur.processPoint = function (matrix, x, y, kernel, direction) { - var res = 0; - var half = kernel._valuesInfo.length / 2; - for (var i = 0; i < kernel._valuesInfo.length; i++) { - var cox = direction == 0 ? x + i - half : x; - var coy = direction == 1 ? y + i - half : y; - if (cox >= 0 && cox < matrix._valuesInfo.length && coy >= 0 && coy < matrix.valuesArray.length) - res += matrix.tryGetValue({ x: cox, y: coy }) * kernel.tryGetValue({ x: i, y: 0 }); - } - return res; - }; - GaussianBlur.calculate1DSampleKernel = function (deviation) { - var size = Math.ceil(deviation * 3) * 3 + 1; - return this.calculate1DSampleKernelOfSize(deviation, size); - }; - GaussianBlur.calculate1DSampleKernelOfSize = function (deviation, size) { - var ret = new es.FasterDictionary(); - var half = (size - 1) / 2; - for (var i = 0; i < size; i++) { - ret.add({ x: i, y: 0 }, 1 / (Math.sqrt(2 * Math.PI) * deviation) * Math.exp(-(i - half) * (i - half) / (2 * deviation * deviation))); - } - return ret; - }; - GaussianBlur.calculateNormalized1DSampleKernel = function (deviation) { - return this.normalizeMatrix(this.calculate1DSampleKernel(deviation)); - }; - GaussianBlur.normalizeMatrix = function (matrix) { - var ret = new es.FasterDictionary(); - var sum = 0; - for (var i = 0; i < ret._valuesInfo.length; i++) { - for (var j = 0; j < ret.valuesArray.length; j++) { - sum += matrix.tryGetValue({ x: i, y: j }); - } - } - if (sum != 0) { - for (var i = 0; i < ret._valuesInfo.length; i++) { - for (var j = 0; j < ret.valuesArray.length; j++) { - ret.add({ x: i, y: j }, matrix.tryGetValue({ x: i, y: j }) / sum); - } - } - } - return ret; - }; - return GaussianBlur; - }()); - es.GaussianBlur = GaussianBlur; -})(es || (es = {})); -var es; -(function (es) { - var SceneTransition = (function () { - function SceneTransition(sceneLoadAction) { - this.sceneLoadAction = sceneLoadAction; - this.loadsNewScene = sceneLoadAction != null; - } - Object.defineProperty(SceneTransition.prototype, "hasPreviousSceneRender", { - get: function () { - if (!this._hasPreviousSceneRender) { - this._hasPreviousSceneRender = true; - return false; - } - return true; - }, - enumerable: true, - configurable: true - }); - SceneTransition.prototype.preRender = function () { - }; - SceneTransition.prototype.render = function () { - }; - SceneTransition.prototype.onBeginTransition = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.loadNextScene()]; - case 1: - _a.sent(); - this.transitionComplete(); - return [2]; - } - }); - }); - }; - SceneTransition.prototype.tickEffectProgressProperty = function (filter, duration, easeType, reverseDirection) { - if (reverseDirection === void 0) { reverseDirection = false; } - return new Promise(function (resolve) { - var start = reverseDirection ? 1 : 0; - var end = reverseDirection ? 0 : 1; - egret.Tween.get(filter.uniforms).set({ _progress: start }).to({ _progress: end }, duration * 1000, easeType).call(function () { - resolve(); - }); - }); - }; - SceneTransition.prototype.transitionComplete = function () { - es.Core._instance._sceneTransition = null; - if (this.onTransitionCompleted) { - this.onTransitionCompleted(); - } - }; - SceneTransition.prototype.loadNextScene = function () { - return __awaiter(this, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (this.onScreenObscured) - this.onScreenObscured(); - if (!this.loadsNewScene) { - this.isNewSceneLoaded = true; - } - _a = es.Core; - return [4, this.sceneLoadAction()]; - case 1: - _a.scene = _b.sent(); - this.isNewSceneLoaded = true; - return [2]; - } - }); - }); - }; - return SceneTransition; - }()); - es.SceneTransition = SceneTransition; -})(es || (es = {})); -var es; -(function (es) { - var FadeTransition = (function (_super) { - __extends(FadeTransition, _super); - function FadeTransition(sceneLoadAction) { - var _this = _super.call(this, sceneLoadAction) || this; - _this.fadeToColor = 0x000000; - _this.fadeOutDuration = 0.4; - _this.fadeEaseType = egret.Ease.quadInOut; - _this.delayBeforeFadeInDuration = 0.1; - _this._alpha = 0; - _this._mask = new egret.Shape(); - return _this; - } - FadeTransition.prototype.onBeginTransition = function () { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - if (!this._mask.parent) - es.Core.scene.stage.addChild(this._mask); - this._mask.graphics.beginFill(this.fadeToColor, 1); - this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this._mask.graphics.endFill(); - egret.Tween.get(this).to({ _alpha: 1 }, this.fadeOutDuration * 1000, this.fadeEaseType) - .call(function () { return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.loadNextScene()]; - case 1: - _a.sent(); - return [2]; - } - }); - }); }).wait(this.delayBeforeFadeInDuration).call(function () { - egret.Tween.get(_this).to({ _alpha: 0 }, _this.fadeOutDuration * 1000, _this.fadeEaseType).call(function () { - _this.transitionComplete(); - }); - }); - return [2]; - }); - }); - }; - FadeTransition.prototype.transitionComplete = function () { - _super.prototype.transitionComplete.call(this); - if (this._mask.parent) - this._mask.parent.removeChild(this._mask); - }; - FadeTransition.prototype.render = function () { - this._mask.graphics.clear(); - this._mask.graphics.beginFill(this.fadeToColor, this._alpha); - this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this._mask.graphics.endFill(); - }; - return FadeTransition; - }(es.SceneTransition)); - es.FadeTransition = FadeTransition; -})(es || (es = {})); -var es; -(function (es) { - var WindTransition = (function (_super) { - __extends(WindTransition, _super); - function WindTransition(sceneLoadAction) { - var _this = _super.call(this, sceneLoadAction) || this; - _this.duration = 1; - _this.easeType = egret.Ease.quadOut; - var vertexSrc = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - "uniform vec2 projectionVector;\n" + - "varying vec2 vTextureCoord;\n" + - "const vec2 center = vec2(-1.0, 1.0);\n" + - "void main(void) {\n" + - " gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - " vTextureCoord = aTextureCoord;\n" + - "}"; - var fragmentSrc = "precision lowp float;\n" + - "varying vec2 vTextureCoord;\n" + - "uniform sampler2D uSampler;\n" + - "uniform float _progress;\n" + - "uniform float _size;\n" + - "uniform float _windSegments;\n" + - "void main(void) {\n" + - "vec2 co = floor(vec2(0.0, vTextureCoord.y * _windSegments));\n" + - "float x = sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453;\n" + - "float r = x - floor(x);\n" + - "float m = smoothstep(0.0, -_size, vTextureCoord.x * (1.0 - _size) + _size * r - (_progress * (1.0 + _size)));\n" + - "vec4 fg = texture2D(uSampler, vTextureCoord);\n" + - "gl_FragColor = mix(fg, vec4(0, 0, 0, 0), m);\n" + - "}"; - _this._windEffect = new egret.CustomFilter(vertexSrc, fragmentSrc, { - _progress: 0, - _size: 0.3, - _windSegments: 100 - }); - _this._mask = new egret.Shape(); - _this._mask.graphics.beginFill(0xFFFFFF, 1); - _this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - _this._mask.graphics.endFill(); - _this._mask.filters = [_this._windEffect]; - es.Core.scene.stage.addChild(_this._mask); - return _this; - } - Object.defineProperty(WindTransition.prototype, "windSegments", { - set: function (value) { - this._windEffect.uniforms._windSegments = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WindTransition.prototype, "size", { - set: function (value) { - this._windEffect.uniforms._size = value; - }, - enumerable: true, - configurable: true - }); - WindTransition.prototype.onBeginTransition = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - this.loadNextScene(); - return [4, this.tickEffectProgressProperty(this._windEffect, this.duration, this.easeType)]; - case 1: - _a.sent(); - this.transitionComplete(); - return [2]; - } - }); - }); - }; - WindTransition.prototype.transitionComplete = function () { - _super.prototype.transitionComplete.call(this); - if (this._mask.parent) - this._mask.parent.removeChild(this._mask); - }; - return WindTransition; - }(es.SceneTransition)); - es.WindTransition = WindTransition; -})(es || (es = {})); -var es; -(function (es) { - var Bezier = (function () { - function Bezier() { - } - Bezier.getPoint = function (p0, p1, p2, t) { - t = es.MathHelper.clamp01(t); - var oneMinusT = 1 - t; - return es.Vector2.add(es.Vector2.add(es.Vector2.multiply(new es.Vector2(oneMinusT * oneMinusT), p0), es.Vector2.multiply(new es.Vector2(2 * oneMinusT * t), p1)), es.Vector2.multiply(new es.Vector2(t * t), p2)); - }; - Bezier.getFirstDerivative = function (p0, p1, p2, t) { - return es.Vector2.add(es.Vector2.multiply(new es.Vector2(2 * (1 - t)), es.Vector2.subtract(p1, p0)), es.Vector2.multiply(new es.Vector2(2 * t), es.Vector2.subtract(p2, p1))); - }; - Bezier.getFirstDerivativeThree = function (start, firstControlPoint, secondControlPoint, end, t) { - t = es.MathHelper.clamp01(t); - var oneMunusT = 1 - t; - return es.Vector2.add(es.Vector2.add(es.Vector2.multiply(new es.Vector2(3 * oneMunusT * oneMunusT), es.Vector2.subtract(firstControlPoint, start)), es.Vector2.multiply(new es.Vector2(6 * oneMunusT * t), es.Vector2.subtract(secondControlPoint, firstControlPoint))), es.Vector2.multiply(new es.Vector2(3 * t * t), es.Vector2.subtract(end, secondControlPoint))); - }; - Bezier.getPointThree = function (start, firstControlPoint, secondControlPoint, end, t) { - t = es.MathHelper.clamp01(t); - var oneMunusT = 1 - t; - return es.Vector2.add(es.Vector2.add(es.Vector2.add(es.Vector2.multiply(new es.Vector2(oneMunusT * oneMunusT * oneMunusT), start), es.Vector2.multiply(new es.Vector2(3 * oneMunusT * oneMunusT * t), firstControlPoint)), es.Vector2.multiply(new es.Vector2(3 * oneMunusT * t * t), secondControlPoint)), es.Vector2.multiply(new es.Vector2(t * t * t), end)); - }; - Bezier.getOptimizedDrawingPoints = function (start, firstCtrlPoint, secondCtrlPoint, end, distanceTolerance) { - if (distanceTolerance === void 0) { distanceTolerance = 1; } - var points = es.ListPool.obtain(); - points.push(start); - this.recursiveGetOptimizedDrawingPoints(start, firstCtrlPoint, secondCtrlPoint, end, points, distanceTolerance); - points.push(end); - return points; - }; - Bezier.recursiveGetOptimizedDrawingPoints = function (start, firstCtrlPoint, secondCtrlPoint, end, points, distanceTolerance) { - var pt12 = es.Vector2.divide(es.Vector2.add(start, firstCtrlPoint), new es.Vector2(2)); - var pt23 = es.Vector2.divide(es.Vector2.add(firstCtrlPoint, secondCtrlPoint), new es.Vector2(2)); - var pt34 = es.Vector2.divide(es.Vector2.add(secondCtrlPoint, end), new es.Vector2(2)); - var pt123 = es.Vector2.divide(es.Vector2.add(pt12, pt23), new es.Vector2(2)); - var pt234 = es.Vector2.divide(es.Vector2.add(pt23, pt34), new es.Vector2(2)); - var pt1234 = es.Vector2.divide(es.Vector2.add(pt123, pt234), new es.Vector2(2)); - var deltaLine = es.Vector2.subtract(end, start); - var d2 = Math.abs(((firstCtrlPoint.x, end.x) * deltaLine.y - (firstCtrlPoint.y - end.y) * deltaLine.x)); - var d3 = Math.abs(((secondCtrlPoint.x - end.x) * deltaLine.y - (secondCtrlPoint.y - end.y) * deltaLine.x)); - if ((d2 + d3) * (d2 + d3) < distanceTolerance * (deltaLine.x * deltaLine.x + deltaLine.y * deltaLine.y)) { - points.push(pt1234); - return; - } - this.recursiveGetOptimizedDrawingPoints(start, pt12, pt123, pt1234, points, distanceTolerance); - this.recursiveGetOptimizedDrawingPoints(pt1234, pt234, pt34, end, points, distanceTolerance); - }; - return Bezier; - }()); - es.Bezier = Bezier; -})(es || (es = {})); -var es; -(function (es) { - var Flags = (function () { - function Flags() { - } - Flags.isFlagSet = function (self, flag) { - return (self & flag) != 0; - }; - Flags.isUnshiftedFlagSet = function (self, flag) { - flag = 1 << flag; - return (self & flag) != 0; - }; - Flags.setFlagExclusive = function (self, flag) { - self.value = 1 << flag; - }; - Flags.setFlag = function (self, flag) { - self.value = (self.value | 1 << flag); - }; - Flags.unsetFlag = function (self, flag) { - flag = 1 << flag; - self.value = (self.value & (~flag)); - }; - Flags.invertFlags = function (self) { - self.value = ~self.value; - }; - return Flags; - }()); - es.Flags = Flags; -})(es || (es = {})); -var es; -(function (es) { - var MathHelper = (function () { - function MathHelper() { - } - MathHelper.toDegrees = function (radians) { - return radians * 57.295779513082320876798154814105; - }; - MathHelper.toRadians = function (degrees) { - return degrees * 0.017453292519943295769236907684886; - }; - MathHelper.map = function (value, leftMin, leftMax, rightMin, rightMax) { - return rightMin + (value - leftMin) * (rightMax - rightMin) / (leftMax - leftMin); - }; - MathHelper.lerp = function (value1, value2, amount) { - return value1 + (value2 - value1) * amount; - }; - MathHelper.clamp = function (value, min, max) { - if (value < min) - return min; - if (value > max) - return max; - return value; - }; - MathHelper.pointOnCirlce = function (circleCenter, radius, angleInDegrees) { - var radians = MathHelper.toRadians(angleInDegrees); - return new es.Vector2(Math.cos(radians) * radians + circleCenter.x, Math.sin(radians) * radians + circleCenter.y); - }; - MathHelper.isEven = function (value) { - return value % 2 == 0; - }; - MathHelper.clamp01 = function (value) { - if (value < 0) - return 0; - if (value > 1) - return 1; - return value; - }; - MathHelper.angleBetweenVectors = function (from, to) { - return Math.atan2(to.y - from.y, to.x - from.x); - }; - MathHelper.incrementWithWrap = function (t, length) { - t++; - if (t == length) - return 0; - return t; - }; - MathHelper.approach = function (start, end, shift) { - if (start < end) - return Math.min(start + shift, end); - return Math.max(start - shift, end); - }; - MathHelper.Epsilon = 0.00001; - MathHelper.Rad2Deg = 57.29578; - MathHelper.Deg2Rad = 0.0174532924; - MathHelper.PiOver2 = Math.PI / 2; - return MathHelper; - }()); - es.MathHelper = MathHelper; -})(es || (es = {})); -var es; -(function (es) { - es.matrixPool = []; - var Matrix2D = (function (_super) { - __extends(Matrix2D, _super); - function Matrix2D() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(Matrix2D.prototype, "m11", { - get: function () { - return this.a; - }, - set: function (value) { - this.a = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2D.prototype, "m12", { - get: function () { - return this.b; - }, - set: function (value) { - this.b = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2D.prototype, "m21", { - get: function () { - return this.c; - }, - set: function (value) { - this.c = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2D.prototype, "m22", { - get: function () { - return this.d; - }, - set: function (value) { - this.d = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2D.prototype, "m31", { - get: function () { - return this.tx; - }, - set: function (value) { - this.tx = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2D.prototype, "m32", { - get: function () { - return this.ty; - }, - set: function (value) { - this.ty = value; - }, - enumerable: true, - configurable: true - }); - Matrix2D.create = function () { - var matrix = es.matrixPool.pop(); - if (!matrix) - matrix = new Matrix2D(); - return matrix; - }; - Matrix2D.prototype.identity = function () { - this.a = this.d = 1; - this.b = this.c = this.tx = this.ty = 0; - return this; - }; - Matrix2D.prototype.translate = function (dx, dy) { - this.tx += dx; - this.ty += dy; - return this; - }; - Matrix2D.prototype.scale = function (sx, sy) { - if (sx !== 1) { - this.a *= sx; - this.c *= sx; - this.tx *= sx; - } - if (sy !== 1) { - this.b *= sy; - this.d *= sy; - this.ty *= sy; - } - return this; - }; - Matrix2D.prototype.rotate = function (angle) { - angle = +angle; - if (angle !== 0) { - angle = angle / DEG_TO_RAD; - var u = Math.cos(angle); - var v = Math.sin(angle); - var ta = this.a; - var tb = this.b; - var tc = this.c; - var td = this.d; - var ttx = this.tx; - var tty = this.ty; - this.a = ta * u - tb * v; - this.b = ta * v + tb * u; - this.c = tc * u - td * v; - this.d = tc * v + td * u; - this.tx = ttx * u - tty * v; - this.ty = ttx * v + tty * u; - } - return this; - }; - Matrix2D.prototype.invert = function () { - this.$invertInto(this); - return this; - }; - Matrix2D.prototype.add = function (matrix) { - this.m11 += matrix.m11; - this.m12 += matrix.m12; - this.m21 += matrix.m21; - this.m22 += matrix.m22; - this.m31 += matrix.m31; - this.m32 += matrix.m32; - return this; - }; - Matrix2D.prototype.substract = function (matrix) { - this.m11 -= matrix.m11; - this.m12 -= matrix.m12; - this.m21 -= matrix.m21; - this.m22 -= matrix.m22; - this.m31 -= matrix.m31; - this.m32 -= matrix.m32; - return this; - }; - Matrix2D.prototype.divide = function (matrix) { - this.m11 /= matrix.m11; - this.m12 /= matrix.m12; - this.m21 /= matrix.m21; - this.m22 /= matrix.m22; - this.m31 /= matrix.m31; - this.m32 /= matrix.m32; - return this; - }; - Matrix2D.prototype.multiply = function (matrix) { - var m11 = (this.m11 * matrix.m11) + (this.m12 * matrix.m21); - var m12 = (this.m11 * matrix.m12) + (this.m12 * matrix.m22); - var m21 = (this.m21 * matrix.m11) + (this.m22 * matrix.m21); - var m22 = (this.m21 * matrix.m12) + (this.m22 * matrix.m22); - var m31 = (this.m31 * matrix.m11) + (this.m32 * matrix.m21) + matrix.m31; - var m32 = (this.m31 * matrix.m12) + (this.m32 * matrix.m22) + matrix.m32; - this.m11 = m11; - this.m12 = m12; - this.m21 = m21; - this.m22 = m22; - this.m31 = m31; - this.m32 = m32; - return this; - }; - Matrix2D.prototype.determinant = function () { - return this.m11 * this.m22 - this.m12 * this.m21; - }; - Matrix2D.prototype.release = function (matrix) { - if (!matrix) - return; - es.matrixPool.push(matrix); - }; - return Matrix2D; - }(egret.Matrix)); - es.Matrix2D = Matrix2D; -})(es || (es = {})); -var es; -(function (es) { - var Rectangle = (function (_super) { - __extends(Rectangle, _super); - function Rectangle() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(Rectangle.prototype, "max", { - get: function () { - return new es.Vector2(this.right, this.bottom); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "center", { - get: function () { - return new es.Vector2(this.x + (this.width / 2), this.y + (this.height / 2)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "location", { - get: function () { - return new es.Vector2(this.x, this.y); - }, - set: function (value) { - this.x = value.x; - this.y = value.y; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "size", { - get: function () { - return new es.Vector2(this.width, this.height); - }, - set: function (value) { - this.width = value.x; - this.height = value.y; - }, - enumerable: true, - configurable: true - }); - Rectangle.fromMinMax = function (minX, minY, maxX, maxY) { - return new Rectangle(minX, minY, maxX - minX, maxY - minY); - }; - Rectangle.rectEncompassingPoints = function (points) { - var minX = Number.POSITIVE_INFINITY; - var minY = Number.POSITIVE_INFINITY; - var maxX = Number.NEGATIVE_INFINITY; - var maxY = Number.NEGATIVE_INFINITY; - for (var i = 0; i < points.length; i++) { - var pt = points[i]; - if (pt.x < minX) - minX = pt.x; - if (pt.x > maxX) - maxX = pt.x; - if (pt.y < minY) - minY = pt.y; - if (pt.y > maxY) - maxY = pt.y; - } - return this.fromMinMax(minX, minY, maxX, maxY); - }; - Rectangle.prototype.intersects = function (value) { - return value.left < this.right && - this.left < value.right && - value.top < this.bottom && - this.top < value.bottom; - }; - Rectangle.prototype.rayIntersects = function (ray, distance) { - distance.value = 0; - var maxValue = Number.MAX_VALUE; - if (Math.abs(ray.direction.x) < 1E-06) { - if ((ray.start.x < this.x) || (ray.start.x > this.x + this.width)) - return false; - } - else { - var num11 = 1 / ray.direction.x; - var num8 = (this.x - ray.start.x) * num11; - var num7 = (this.x + this.width - ray.start.x) * num11; - if (num8 > num7) { - var num14 = num8; - num8 = num7; - num7 = num14; - } - distance.value = Math.max(num8, distance.value); - maxValue = Math.min(num7, maxValue); - if (distance.value > maxValue) - return false; - } - if (Math.abs(ray.direction.y) < 1E-06) { - if ((ray.start.y < this.y) || (ray.start.y > this.y + this.height)) - return false; - } - else { - var num10 = 1 / ray.direction.y; - var num6 = (this.y - ray.start.y) * num10; - var num5 = (this.y + this.height - ray.start.y) * num10; - if (num6 > num5) { - var num13 = num6; - num6 = num5; - num5 = num13; - } - distance.value = Math.max(num6, distance.value); - maxValue = Math.max(num5, maxValue); - if (distance.value > maxValue) - return false; - } - return true; - }; - Rectangle.prototype.containsRect = function (value) { - return ((((this.x <= value.x) && (value.x < (this.x + this.width))) && - (this.y <= value.y)) && - (value.y < (this.y + this.height))); - }; - Rectangle.prototype.contains = function (x, y) { - return ((((this.x <= x) && (x < (this.x + this.width))) && (this.y <= y)) && (y < (this.y + this.height))); - }; - Rectangle.prototype.getHalfSize = function () { - return new es.Vector2(this.width * 0.5, this.height * 0.5); - }; - Rectangle.prototype.getClosestPointOnRectangleBorderToPoint = function (point, edgeNormal) { - edgeNormal = es.Vector2.zero; - var res = new es.Vector2(); - res.x = es.MathHelper.clamp(point.x, this.left, this.right); - res.y = es.MathHelper.clamp(point.y, this.top, this.bottom); - if (this.contains(res.x, res.y)) { - var dl = res.x - this.left; - var dr = this.right - res.x; - var dt = res.y - this.top; - var db = this.bottom - res.y; - var min = Math.min(dl, dr, dt, db); - if (min == dt) { - res.y = this.top; - edgeNormal.y = -1; - } - else if (min == db) { - res.y = this.bottom; - edgeNormal.y = 1; - } - else if (min == dl) { - res.x = this.left; - edgeNormal.x = -1; - } - else { - res.x = this.right; - edgeNormal.x = 1; - } - } - else { - if (res.x == this.left) - edgeNormal.x = -1; - if (res.x == this.right) - edgeNormal.x = 1; - if (res.y == this.top) - edgeNormal.y = -1; - if (res.y == this.bottom) - edgeNormal.y = 1; - } - return res; - }; - Rectangle.prototype.getClosestPointOnBoundsToOrigin = function () { - var max = this.max; - var minDist = Math.abs(this.location.x); - var boundsPoint = new es.Vector2(this.location.x, 0); - if (Math.abs(max.x) < minDist) { - minDist = Math.abs(max.x); - boundsPoint.x = max.x; - boundsPoint.y = 0; - } - if (Math.abs(max.y) < minDist) { - minDist = Math.abs(max.y); - boundsPoint.x = 0; - boundsPoint.y = max.y; - } - if (Math.abs(this.location.y) < minDist) { - minDist = Math.abs(this.location.y); - boundsPoint.x = 0; - boundsPoint.y = this.location.y; - } - return boundsPoint; - }; - Rectangle.prototype.calculateBounds = function (parentPosition, position, origin, scale, rotation, width, height) { - if (rotation == 0) { - this.x = parentPosition.x + position.x - origin.x * scale.x; - this.y = parentPosition.y + position.y - origin.y * scale.y; - this.width = width * scale.x; - this.height = height * scale.y; - } - else { - var worldPosX = parentPosition.x + position.x; - var worldPosY = parentPosition.y + position.y; - this._transformMat = es.Matrix2D.create().translate(-worldPosX - origin.x, -worldPosY - origin.y); - this._tempMat = es.Matrix2D.create().scale(scale.x, scale.y); - this._transformMat = this._transformMat.multiply(this._tempMat); - this._tempMat = es.Matrix2D.create().rotate(rotation); - this._transformMat = this._transformMat.multiply(this._tempMat); - this._tempMat = es.Matrix2D.create().translate(worldPosX, worldPosY); - this._transformMat = this._transformMat.multiply(this._tempMat); - var topLeft = new es.Vector2(worldPosX, worldPosY); - var topRight = new es.Vector2(worldPosX + width, worldPosY); - var bottomLeft = new es.Vector2(worldPosX, worldPosY + height); - var bottomRight = new es.Vector2(worldPosX + width, worldPosY + height); - es.Vector2Ext.transformR(topLeft, this._transformMat, topLeft); - es.Vector2Ext.transformR(topRight, this._transformMat, topRight); - es.Vector2Ext.transformR(bottomLeft, this._transformMat, bottomLeft); - es.Vector2Ext.transformR(bottomRight, this._transformMat, bottomRight); - var minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - var maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - var minY = Math.min(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - var maxY = Math.max(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - this.location = new es.Vector2(minX, minY); - this.width = maxX - minX; - this.height = maxY - minY; - } - }; - return Rectangle; - }(egret.Rectangle)); - es.Rectangle = Rectangle; -})(es || (es = {})); -var es; -(function (es) { - var SubpixelFloat = (function () { - function SubpixelFloat() { - this.remainder = 0; - } - SubpixelFloat.prototype.update = function (amount) { - this.remainder += amount; - var motion = Math.floor(Math.trunc(this.remainder)); - this.remainder -= motion; - amount = motion; - return amount; - }; - SubpixelFloat.prototype.reset = function () { - this.remainder = 0; - }; - return SubpixelFloat; - }()); - es.SubpixelFloat = SubpixelFloat; -})(es || (es = {})); -var es; -(function (es) { - var SubpixelVector2 = (function () { - function SubpixelVector2() { - this._x = new es.SubpixelFloat(); - this._y = new es.SubpixelFloat(); - } - SubpixelVector2.prototype.update = function (amount) { - amount.x = this._x.update(amount.x); - amount.y = this._y.update(amount.y); - }; - SubpixelVector2.prototype.reset = function () { - this._x.reset(); - this._y.reset(); - }; - return SubpixelVector2; - }()); - es.SubpixelVector2 = SubpixelVector2; -})(es || (es = {})); -var es; -(function (es) { - var Vector3 = (function () { - function Vector3(x, y, z) { - this.x = x; - this.y = y; - this.z = z; - } - return Vector3; - }()); - es.Vector3 = Vector3; -})(es || (es = {})); -var es; -(function (es) { - var ColliderTriggerHelper = (function () { - function ColliderTriggerHelper(entity) { - this._activeTriggerIntersections = []; - this._previousTriggerIntersections = []; - this._tempTriggerList = []; - this._entity = entity; - } - ColliderTriggerHelper.prototype.update = function () { - var colliders = this._entity.getComponents(es.Collider); - for (var i = 0; i < colliders.length; i++) { - var collider = colliders[i]; - var neighbors = es.Physics.boxcastBroadphase(collider.bounds, collider.collidesWithLayers); - var _loop_5 = function (j) { - var neighbor = neighbors[j]; - if (!collider.isTrigger && !neighbor.isTrigger) - return "continue"; - if (collider.overlaps(neighbor)) { - var pair_1 = new es.Pair(collider, neighbor); - var shouldReportTriggerEvent = this_1._activeTriggerIntersections.findIndex(function (value) { - return value.first == pair_1.first && value.second == pair_1.second; - }) == -1 && this_1._previousTriggerIntersections.findIndex(function (value) { - return value.first == pair_1.first && value.second == pair_1.second; - }) == -1; - if (shouldReportTriggerEvent) - this_1.notifyTriggerListeners(pair_1, true); - if (!this_1._activeTriggerIntersections.contains(pair_1)) - this_1._activeTriggerIntersections.push(pair_1); - } - }; - var this_1 = this; - for (var j = 0; j < neighbors.length; j++) { - _loop_5(j); - } - } - es.ListPool.free(colliders); - this.checkForExitedColliders(); - }; - ColliderTriggerHelper.prototype.checkForExitedColliders = function () { - var _this = this; - var _loop_6 = function (i) { - var index = this_2._previousTriggerIntersections.findIndex(function (value) { - if (value.first == _this._activeTriggerIntersections[i].first && value.second == _this._activeTriggerIntersections[i].second) - return true; - return false; - }); - if (index != -1) - this_2._previousTriggerIntersections.removeAt(index); - }; - var this_2 = this; - for (var i = 0; i < this._activeTriggerIntersections.length; i++) { - _loop_6(i); - } - for (var i = 0; i < this._previousTriggerIntersections.length; i++) { - this.notifyTriggerListeners(this._previousTriggerIntersections[i], false); - } - this._previousTriggerIntersections.length = 0; - for (var i = 0; i < this._activeTriggerIntersections.length; i++) { - if (!this._previousTriggerIntersections.contains(this._activeTriggerIntersections[i])) { - this._previousTriggerIntersections.push(this._activeTriggerIntersections[i]); - } - } - this._activeTriggerIntersections.length = 0; - }; - ColliderTriggerHelper.prototype.notifyTriggerListeners = function (collisionPair, isEntering) { - collisionPair.first.entity.getComponents("ITriggerListener", this._tempTriggerList); - for (var i = 0; i < this._tempTriggerList.length; i++) { - if (isEntering) { - this._tempTriggerList[i].onTriggerEnter(collisionPair.second, collisionPair.first); - } - else { - this._tempTriggerList[i].onTriggerExit(collisionPair.second, collisionPair.first); - } - this._tempTriggerList.length = 0; - if (collisionPair.second.entity) { - collisionPair.second.entity.getComponents("ITriggerListener", this._tempTriggerList); - for (var i_2 = 0; i_2 < this._tempTriggerList.length; i_2++) { - if (isEntering) { - this._tempTriggerList[i_2].onTriggerEnter(collisionPair.first, collisionPair.second); - } - else { - this._tempTriggerList[i_2].onTriggerExit(collisionPair.first, collisionPair.second); - } - } - this._tempTriggerList.length = 0; - } - } - }; - return ColliderTriggerHelper; - }()); - es.ColliderTriggerHelper = ColliderTriggerHelper; -})(es || (es = {})); -var es; -(function (es) { - var PointSectors; - (function (PointSectors) { - PointSectors[PointSectors["center"] = 0] = "center"; - PointSectors[PointSectors["top"] = 1] = "top"; - PointSectors[PointSectors["bottom"] = 2] = "bottom"; - PointSectors[PointSectors["topLeft"] = 9] = "topLeft"; - PointSectors[PointSectors["topRight"] = 5] = "topRight"; - PointSectors[PointSectors["left"] = 8] = "left"; - PointSectors[PointSectors["right"] = 4] = "right"; - PointSectors[PointSectors["bottomLeft"] = 10] = "bottomLeft"; - PointSectors[PointSectors["bottomRight"] = 6] = "bottomRight"; - })(PointSectors = es.PointSectors || (es.PointSectors = {})); - var Collisions = (function () { - function Collisions() { - } - Collisions.isLineToLine = function (a1, a2, b1, b2) { - var b = es.Vector2.subtract(a2, a1); - var d = es.Vector2.subtract(b2, b1); - var bDotDPerp = b.x * d.y - b.y * d.x; - if (bDotDPerp == 0) - return false; - var c = es.Vector2.subtract(b1, a1); - var t = (c.x * d.y - c.y * d.x) / bDotDPerp; - if (t < 0 || t > 1) - return false; - var u = (c.x * b.y - c.y * b.x) / bDotDPerp; - if (u < 0 || u > 1) - return false; - return true; - }; - Collisions.lineToLineIntersection = function (a1, a2, b1, b2) { - var intersection = new es.Vector2(0, 0); - var b = es.Vector2.subtract(a2, a1); - var d = es.Vector2.subtract(b2, b1); - var bDotDPerp = b.x * d.y - b.y * d.x; - if (bDotDPerp == 0) - return intersection; - var c = es.Vector2.subtract(b1, a1); - var t = (c.x * d.y - c.y * d.x) / bDotDPerp; - if (t < 0 || t > 1) - return intersection; - var u = (c.x * b.y - c.y * b.x) / bDotDPerp; - if (u < 0 || u > 1) - return intersection; - intersection = es.Vector2.add(a1, new es.Vector2(t * b.x, t * b.y)); - return intersection; - }; - Collisions.closestPointOnLine = function (lineA, lineB, closestTo) { - var v = es.Vector2.subtract(lineB, lineA); - var w = es.Vector2.subtract(closestTo, lineA); - var t = es.Vector2.dot(w, v) / es.Vector2.dot(v, v); - t = es.MathHelper.clamp(t, 0, 1); - return es.Vector2.add(lineA, new es.Vector2(v.x * t, v.y * t)); - }; - Collisions.circleToCircle = function (circleCenter1, circleRadius1, circleCenter2, circleRadius2) { - return es.Vector2.distanceSquared(circleCenter1, circleCenter2) < (circleRadius1 + circleRadius2) * (circleRadius1 + circleRadius2); - }; - Collisions.circleToLine = function (circleCenter, radius, lineFrom, lineTo) { - return es.Vector2.distanceSquared(circleCenter, this.closestPointOnLine(lineFrom, lineTo, circleCenter)) < radius * radius; - }; - Collisions.circleToPoint = function (circleCenter, radius, point) { - return es.Vector2.distanceSquared(circleCenter, point) < radius * radius; - }; - Collisions.rectToCircle = function (rect, cPosition, cRadius) { - if (this.rectToPoint(rect.x, rect.y, rect.width, rect.height, cPosition)) - return true; - var edgeFrom = es.Vector2.zero; - var edgeTo = es.Vector2.zero; - var sector = this.getSector(rect.x, rect.y, rect.width, rect.height, cPosition); - if ((sector & PointSectors.top) != 0) { - edgeFrom = new es.Vector2(rect.x, rect.y); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y); - if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) - return true; - } - if ((sector & PointSectors.bottom) != 0) { - edgeFrom = new es.Vector2(rect.x, rect.y + rect.width); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); - if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) - return true; - } - if ((sector & PointSectors.left) != 0) { - edgeFrom = new es.Vector2(rect.x + rect.width, rect.y); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); - if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) - return true; - } - return false; - }; - Collisions.rectToLine = function (rect, lineFrom, lineTo) { - var fromSector = this.getSector(rect.x, rect.y, rect.width, rect.height, lineFrom); - var toSector = this.getSector(rect.x, rect.y, rect.width, rect.height, lineTo); - if (fromSector == PointSectors.center || toSector == PointSectors.center) { - return true; - } - else if ((fromSector & toSector) != 0) { - return false; - } - else { - var both = fromSector | toSector; - var edgeFrom = void 0; - var edgeTo = void 0; - if ((both & PointSectors.top) != 0) { - edgeFrom = new es.Vector2(rect.x, rect.y); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y); - if (this.isLineToLine(edgeFrom, edgeTo, lineFrom, lineTo)) - return true; - } - if ((both & PointSectors.bottom) != 0) { - edgeFrom = new es.Vector2(rect.x, rect.y + rect.height); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); - if (this.isLineToLine(edgeFrom, edgeTo, lineFrom, lineTo)) - return true; - } - if ((both & PointSectors.left) != 0) { - edgeFrom = new es.Vector2(rect.x, rect.y); - edgeTo = new es.Vector2(rect.x, rect.y + rect.height); - if (this.isLineToLine(edgeFrom, edgeTo, lineFrom, lineTo)) - return true; - } - if ((both & PointSectors.right) != 0) { - edgeFrom = new es.Vector2(rect.x + rect.width, rect.y); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); - if (this.isLineToLine(edgeFrom, edgeTo, lineFrom, lineTo)) - return true; - } - } - return false; - }; - Collisions.rectToPoint = function (rX, rY, rW, rH, point) { - return point.x >= rX && point.y >= rY && point.x < rX + rW && point.y < rY + rH; - }; - Collisions.getSector = function (rX, rY, rW, rH, point) { - var sector = PointSectors.center; - if (point.x < rX) - sector |= PointSectors.left; - else if (point.x >= rX + rW) - sector |= PointSectors.right; - if (point.y < rY) - sector |= PointSectors.top; - else if (point.y >= rY + rH) - sector |= PointSectors.bottom; - return sector; - }; - return Collisions; - }()); - es.Collisions = Collisions; -})(es || (es = {})); -var es; -(function (es) { - var RaycastHit = (function () { - function RaycastHit(collider, fraction, distance, point, normal) { - this.fraction = 0; - this.distance = 0; - this.point = es.Vector2.zero; - this.normal = es.Vector2.zero; - this.collider = collider; - this.fraction = fraction; - this.distance = distance; - this.point = point; - this.centroid = es.Vector2.zero; - } - RaycastHit.prototype.setValues = function (collider, fraction, distance, point) { - this.collider = collider; - this.fraction = fraction; - this.distance = distance; - this.point = point; - }; - RaycastHit.prototype.setValuesNonCollider = function (fraction, distance, point, normal) { - this.fraction = fraction; - this.distance = distance; - this.point = point; - this.normal = normal; - }; - RaycastHit.prototype.reset = function () { - this.collider = null; - this.fraction = this.distance = 0; - }; - RaycastHit.prototype.toString = function () { - return "[RaycastHit] fraction: " + this.fraction + ", distance: " + this.distance + ", normal: " + this.normal + ", centroid: " + this.centroid + ", point: " + this.point; - }; - return RaycastHit; - }()); - es.RaycastHit = RaycastHit; -})(es || (es = {})); -var es; -(function (es) { - var Physics = (function () { - function Physics() { - } - Physics.reset = function () { - this._spatialHash = new es.SpatialHash(this.spatialHashCellSize); - }; - Physics.clear = function () { - this._spatialHash.clear(); - }; - Physics.overlapCircleAll = function (center, randius, results, layerMask) { - if (layerMask === void 0) { layerMask = -1; } - if (results.length == 0) { - console.error("An empty results array was passed in. No results will ever be returned."); - return; - } - return this._spatialHash.overlapCircle(center, randius, results, layerMask); - }; - Physics.boxcastBroadphase = function (rect, layerMask) { - if (layerMask === void 0) { layerMask = this.allLayers; } - return this._spatialHash.aabbBroadphase(rect, null, layerMask); - }; - Physics.boxcastBroadphaseExcludingSelf = function (collider, rect, layerMask) { - if (layerMask === void 0) { layerMask = this.allLayers; } - return this._spatialHash.aabbBroadphase(rect, collider, layerMask); - }; - Physics.addCollider = function (collider) { - Physics._spatialHash.register(collider); - }; - Physics.removeCollider = function (collider) { - Physics._spatialHash.remove(collider); - }; - Physics.updateCollider = function (collider) { - this._spatialHash.remove(collider); - this._spatialHash.register(collider); - }; - Physics.linecast = function (start, end, layerMask) { - if (layerMask === void 0) { layerMask = Physics.allLayers; } - this._hitArray[0].reset(); - this.linecastAll(start, end, this._hitArray, layerMask); - return this._hitArray[0]; - }; - Physics.linecastAll = function (start, end, hits, layerMask) { - if (layerMask === void 0) { layerMask = Physics.allLayers; } - if (hits.length == 0) { - console.warn("传入了一个空的hits数组。没有点击会被返回"); - return 0; - } - return this._spatialHash.linecast(start, end, hits, layerMask); - }; - Physics.debugDraw = function (secondsToDisplay) { - this._spatialHash.debugDraw(secondsToDisplay, 2); - }; - Physics.spatialHashCellSize = 100; - Physics.allLayers = -1; - Physics.raycastsHitTriggers = false; - Physics.raycastsStartInColliders = false; - Physics._hitArray = [ - new es.RaycastHit() - ]; - return Physics; - }()); - es.Physics = Physics; -})(es || (es = {})); -var es; -(function (es) { - var Ray2D = (function () { - function Ray2D(position, end) { - this.start = position; - this.end = end; - this.direction = es.Vector2.subtract(this.end, this.start); - } - return Ray2D; - }()); - es.Ray2D = Ray2D; -})(es || (es = {})); -var es; -(function (es) { - var SpatialHash = (function () { - function SpatialHash(cellSize) { - if (cellSize === void 0) { cellSize = 100; } - this.gridBounds = new es.Rectangle(); - this._overlapTestCircle = new es.Circle(0); - this._cellDict = new NumberDictionary(); - this._tempHashSet = []; - this._cellSize = cellSize; - this._inverseCellSize = 1 / this._cellSize; - this._raycastParser = new RaycastResultParser(); - } - SpatialHash.prototype.register = function (collider) { - var bounds = collider.bounds; - collider.registeredPhysicsBounds = bounds; - var p1 = this.cellCoords(bounds.x, bounds.y); - var p2 = this.cellCoords(bounds.right, bounds.bottom); - if (!this.gridBounds.contains(p1.x, p1.y)) { - this.gridBounds = es.RectangleExt.union(this.gridBounds, p1); - } - if (!this.gridBounds.contains(p2.x, p2.y)) { - this.gridBounds = es.RectangleExt.union(this.gridBounds, p2); - } - for (var x = p1.x; x <= p2.x; x++) { - for (var y = p1.y; y <= p2.y; y++) { - var c = this.cellAtPosition(x, y, true); - if (!c.firstOrDefault(function (c) { return c.hashCode == collider.hashCode; })) - c.push(collider); - } - } - }; - SpatialHash.prototype.remove = function (collider) { - var bounds = collider.registeredPhysicsBounds; - var p1 = this.cellCoords(bounds.x, bounds.y); - var p2 = this.cellCoords(bounds.right, bounds.bottom); - for (var x = p1.x; x <= p2.x; x++) { - for (var y = p1.y; y <= p2.y; y++) { - var cell = this.cellAtPosition(x, y); - if (!cell) - console.log("\u4ECE\u4E0D\u5B58\u5728\u78B0\u649E\u5668\u7684\u5355\u5143\u683C\u4E2D\u79FB\u9664\u78B0\u649E\u5668: [" + collider + "]"); - else - cell.remove(collider); - } - } - }; - SpatialHash.prototype.removeWithBruteForce = function (obj) { - this._cellDict.remove(obj); - }; - SpatialHash.prototype.clear = function () { - this._cellDict.clear(); - }; - SpatialHash.prototype.debugDraw = function (secondsToDisplay, textScale) { - if (textScale === void 0) { textScale = 1; } - for (var x = this.gridBounds.x; x <= this.gridBounds.right; x++) { - for (var y = this.gridBounds.y; y <= this.gridBounds.bottom; y++) { - var cell = this.cellAtPosition(x, y); - if (cell && cell.length > 0) - this.debugDrawCellDetails(x, y, cell.length, secondsToDisplay, textScale); - } - } - }; - SpatialHash.prototype.aabbBroadphase = function (bounds, excludeCollider, layerMask) { - this._tempHashSet.length = 0; - var p1 = this.cellCoords(bounds.x, bounds.y); - var p2 = this.cellCoords(bounds.right, bounds.bottom); - for (var x = p1.x; x <= p2.x; x++) { - for (var y = p1.y; y <= p2.y; y++) { - var cell = this.cellAtPosition(x, y); - if (!cell) - continue; - var _loop_7 = function (i) { - var collider = cell[i]; - if (collider == excludeCollider || !es.Flags.isFlagSet(layerMask, collider.physicsLayer.value)) - return "continue"; - if (bounds.intersects(collider.bounds)) { - if (!this_3._tempHashSet.firstOrDefault(function (c) { return c.hashCode == collider.hashCode; })) - this_3._tempHashSet.push(collider); - } - }; - var this_3 = this; - for (var i = 0; i < cell.length; i++) { - _loop_7(i); - } - } - } - return this._tempHashSet; - }; - SpatialHash.prototype.linecast = function (start, end, hits, layerMask) { - var ray = new es.Ray2D(start, end); - this._raycastParser.start(ray, hits, layerMask); - var currentCell = this.cellCoords(start.x, start.y); - var lastCell = this.cellCoords(end.x, end.y); - var stepX = Math.sign(ray.direction.x); - var stepY = Math.sign(ray.direction.y); - if (currentCell.x == lastCell.x) - stepX = 0; - if (currentCell.y == lastCell.y) - stepY = 0; - var xStep = stepX < 0 ? 0 : stepX; - var yStep = stepY < 0 ? 0 : stepY; - var nextBoundaryX = (currentCell.x + xStep) * this._cellSize; - var nextBoundaryY = (currentCell.y + yStep) * this._cellSize; - var tMaxX = ray.direction.x != 0 ? (nextBoundaryX - ray.start.x) / ray.direction.x : Number.MAX_VALUE; - var tMaxY = ray.direction.y != 0 ? (nextBoundaryY - ray.start.y) / ray.direction.y : Number.MAX_VALUE; - var tDeltaX = ray.direction.x != 0 ? this._cellSize / (ray.direction.x * stepX) : Number.MAX_VALUE; - var tDeltaY = ray.direction.y != 0 ? this._cellSize / (ray.direction.y * stepY) : Number.MAX_VALUE; - var cell = this.cellAtPosition(currentCell.x, currentCell.y); - if (cell && this._raycastParser.checkRayIntersection(currentCell.x, currentCell.y, cell)) { - this._raycastParser.reset(); - return this._raycastParser.hitCounter; - } - while (currentCell.x != lastCell.x || currentCell.y != lastCell.y) { - if (tMaxX < tMaxY) { - currentCell.x = Math.floor(es.MathHelper.approach(currentCell.x, lastCell.x, Math.abs(stepX))); - tMaxX += tDeltaX; - } - else { - currentCell.y = Math.floor(es.MathHelper.approach(currentCell.y, lastCell.y, Math.abs(stepY))); - tMaxY += tDeltaY; - } - cell = this.cellAtPosition(currentCell.x, currentCell.y); - if (cell && this._raycastParser.checkRayIntersection(currentCell.x, currentCell.y, cell)) { - this._raycastParser.reset(); - return this._raycastParser.hitCounter; - } - } - this._raycastParser.reset(); - return this._raycastParser.hitCounter; - }; - SpatialHash.prototype.overlapCircle = function (circleCenter, radius, results, layerMask) { - var bounds = new es.Rectangle(circleCenter.x - radius, circleCenter.y - radius, radius * 2, radius * 2); - this._overlapTestCircle.radius = radius; - this._overlapTestCircle.position = circleCenter; - var resultCounter = 0; - var potentials = this.aabbBroadphase(bounds, null, layerMask); - for (var i = 0; i < potentials.length; i++) { - var collider = potentials[i]; - if (collider instanceof es.BoxCollider) { - results[resultCounter] = collider; - resultCounter++; - } - else if (collider instanceof es.CircleCollider) { - if (collider.shape.overlaps(this._overlapTestCircle)) { - results[resultCounter] = collider; - resultCounter++; - } - } - else if (collider instanceof es.PolygonCollider) { - if (collider.shape.overlaps(this._overlapTestCircle)) { - results[resultCounter] = collider; - resultCounter++; - } - } - else { - throw new Error("overlapCircle against this collider type is not implemented!"); - } - if (resultCounter == results.length) - return resultCounter; - } - return resultCounter; - }; - SpatialHash.prototype.cellCoords = function (x, y) { - return new es.Vector2(Math.floor(x * this._inverseCellSize), Math.floor(y * this._inverseCellSize)); - }; - SpatialHash.prototype.cellAtPosition = function (x, y, createCellIfEmpty) { - if (createCellIfEmpty === void 0) { createCellIfEmpty = false; } - var cell = this._cellDict.tryGetValue(x, y); - if (!cell) { - if (createCellIfEmpty) { - cell = []; - this._cellDict.add(x, y, cell); - } - } - return cell; - }; - SpatialHash.prototype.debugDrawCellDetails = function (x, y, cellCount, secondsToDisplay, textScale) { - if (secondsToDisplay === void 0) { secondsToDisplay = 0.5; } - if (textScale === void 0) { textScale = 1; } - }; - return SpatialHash; - }()); - es.SpatialHash = SpatialHash; - var NumberDictionary = (function () { - function NumberDictionary() { - this._store = new Map(); - } - NumberDictionary.prototype.add = function (x, y, list) { - this._store.set(this.getKey(x, y), list); - }; - NumberDictionary.prototype.remove = function (obj) { - this._store.forEach(function (list) { - if (list.contains(obj)) - list.remove(obj); - }); - }; - NumberDictionary.prototype.tryGetValue = function (x, y) { - return this._store.get(this.getKey(x, y)); - }; - NumberDictionary.prototype.getKey = function (x, y) { - return x + "_" + y; - }; - NumberDictionary.prototype.clear = function () { - this._store.clear(); - }; - return NumberDictionary; - }()); - es.NumberDictionary = NumberDictionary; - var RaycastResultParser = (function () { - function RaycastResultParser() { - this._tempHit = new es.RaycastHit(); - this._checkedColliders = []; - this._cellHits = []; - } - RaycastResultParser.prototype.start = function (ray, hits, layerMask) { - this._ray = ray; - this._hits = hits; - this._layerMask = layerMask; - this.hitCounter = 0; - }; - RaycastResultParser.prototype.checkRayIntersection = function (cellX, cellY, cell) { - var fraction = new es.Ref(0); - for (var i = 0; i < cell.length; i++) { - var potential = cell[i]; - if (this._checkedColliders.contains(potential)) - continue; - this._checkedColliders.push(potential); - if (potential.isTrigger && !es.Physics.raycastsHitTriggers) - continue; - if (!es.Flags.isFlagSet(this._layerMask, potential.physicsLayer.value)) - continue; - var colliderBounds = potential.bounds; - if (colliderBounds.rayIntersects(this._ray, fraction) && fraction.value <= 1) { - if (potential.shape.collidesWithLine(this._ray.start, this._ray.end, this._tempHit)) { - if (!es.Physics.raycastsStartInColliders && potential.shape.containsPoint(this._ray.start)) - continue; - this._tempHit.collider = potential; - this._cellHits.push(this._tempHit); - } - } - } - if (this._cellHits.length == 0) - return false; - this._cellHits.sort(RaycastResultParser.compareRaycastHits); - for (var i = 0; i < this._cellHits.length; i++) { - this._hits[this.hitCounter] = this._cellHits[i]; - this.hitCounter++; - if (this.hitCounter == this._hits.length) - return true; - } - return false; - }; - RaycastResultParser.prototype.reset = function () { - this._hits = null; - this._checkedColliders.length = 0; - this._cellHits.length = 0; - }; - RaycastResultParser.compareRaycastHits = function (a, b) { - return a.distance - b.distance; - }; - return RaycastResultParser; - }()); - es.RaycastResultParser = RaycastResultParser; -})(es || (es = {})); -var es; -(function (es) { - var Shape = (function () { - function Shape() { - } - return Shape; - }()); - es.Shape = Shape; -})(es || (es = {})); -var es; -(function (es) { - var Polygon = (function (_super) { - __extends(Polygon, _super); - function Polygon(points, isBox) { - var _this = _super.call(this) || this; - _this._areEdgeNormalsDirty = true; - _this.isUnrotated = true; - _this.setPoints(points); - _this.isBox = isBox; - return _this; - } - Object.defineProperty(Polygon.prototype, "edgeNormals", { - get: function () { - if (this._areEdgeNormalsDirty) - this.buildEdgeNormals(); - return this._edgeNormals; - }, - enumerable: true, - configurable: true - }); - Polygon.prototype.setPoints = function (points) { - this.points = points; - this.recalculateCenterAndEdgeNormals(); - this._originalPoints = []; - for (var i = 0; i < this.points.length; i++) { - this._originalPoints.push(this.points[i]); - } - }; - Polygon.prototype.recalculateCenterAndEdgeNormals = function () { - this._polygonCenter = Polygon.findPolygonCenter(this.points); - this._areEdgeNormalsDirty = true; - }; - Polygon.prototype.buildEdgeNormals = function () { - var totalEdges = this.isBox ? 2 : this.points.length; - if (this._edgeNormals == undefined || this._edgeNormals.length != totalEdges) - this._edgeNormals = new Array(totalEdges); - var p2; - for (var i = 0; i < totalEdges; i++) { - var p1 = this.points[i]; - if (i + 1 >= this.points.length) - p2 = this.points[0]; - else - p2 = this.points[i + 1]; - var perp = es.Vector2Ext.perpendicular(p1, p2); - es.Vector2Ext.normalize(perp); - this._edgeNormals[i] = perp; - } - }; - Polygon.buildSymmetricalPolygon = function (vertCount, radius) { - var verts = new Array(vertCount); - for (var i = 0; i < vertCount; i++) { - var a = 2 * Math.PI * (i / vertCount); - verts[i] = new es.Vector2(Math.cos(a) * radius, Math.sin(a) * radius); - } - return verts; - }; - Polygon.recenterPolygonVerts = function (points) { - var center = this.findPolygonCenter(points); - for (var i = 0; i < points.length; i++) - points[i].subtract(center); - }; - Polygon.findPolygonCenter = function (points) { - var x = 0, y = 0; - for (var i = 0; i < points.length; i++) { - x += points[i].x; - y += points[i].y; - } - return new es.Vector2(x / points.length, y / points.length); - }; - Polygon.getFarthestPointInDirection = function (points, direction) { - var index = 0; - var maxDot = es.Vector2.dot(points[index], direction); - for (var i = 1; i < points.length; i++) { - var dot = es.Vector2.dot(points[i], direction); - if (dot > maxDot) { - maxDot = dot; - index = i; - } - } - return points[index]; - }; - Polygon.getClosestPointOnPolygonToPoint = function (points, point, distanceSquared, edgeNormal) { - distanceSquared.value = Number.MAX_VALUE; - edgeNormal.x = 0; - edgeNormal.y = 0; - var closestPoint = new es.Vector2(0, 0); - var tempDistanceSquared = 0; - for (var i = 0; i < points.length; i++) { - var j = i + 1; - if (j == points.length) - j = 0; - var closest = es.ShapeCollisions.closestPointOnLine(points[i], points[j], point); - tempDistanceSquared = es.Vector2.distanceSquared(point, closest); - if (tempDistanceSquared < distanceSquared.value) { - distanceSquared.value = tempDistanceSquared; - closestPoint = closest; - var line = es.Vector2.subtract(points[j], points[i]); - edgeNormal.x = -line.y; - edgeNormal.y = line.x; - } - } - es.Vector2Ext.normalize(edgeNormal); - return closestPoint; - }; - Polygon.rotatePolygonVerts = function (radians, originalPoints, rotatedPoints) { - var cos = Math.cos(radians); - var sin = Math.sin(radians); - for (var i = 0; i < originalPoints.length; i++) { - var position = originalPoints[i]; - rotatedPoints[i] = new es.Vector2(position.x * cos + position.y * -sin, position.x * sin + position.y * cos); - } - }; - Polygon.prototype.recalculateBounds = function (collider) { - this.center = collider.localOffset; - if (collider.shouldColliderScaleAndRotateWithTransform) { - var hasUnitScale = true; - var tempMat = void 0; - var combinedMatrix = es.Matrix2D.create().translate(-this._polygonCenter.x, -this._polygonCenter.y); - if (!collider.entity.transform.scale.equals(es.Vector2.one)) { - tempMat = es.Matrix2D.create().scale(collider.entity.transform.scale.x, collider.entity.transform.scale.y); - combinedMatrix = combinedMatrix.multiply(tempMat); - hasUnitScale = false; - this.center = es.Vector2.multiply(collider.localOffset, collider.entity.transform.scale); - } - if (collider.entity.transform.rotation != 0) { - tempMat = es.Matrix2D.create().rotate(collider.entity.transform.rotation); - combinedMatrix = combinedMatrix.multiply(tempMat); - var offsetAngle = Math.atan2(collider.localOffset.y, collider.localOffset.x) * es.MathHelper.Rad2Deg; - var offsetLength = hasUnitScale ? collider._localOffsetLength : - es.Vector2.multiply(collider.localOffset, collider.entity.transform.scale).length(); - this.center = es.MathHelper.pointOnCirlce(es.Vector2.zero, offsetLength, collider.entity.transform.rotationDegrees + offsetAngle); - } - tempMat = es.Matrix2D.create().translate(this._polygonCenter.x, this._polygonCenter.y); - combinedMatrix = combinedMatrix.multiply(tempMat); - es.Vector2Ext.transform(this._originalPoints, combinedMatrix, this.points); - this.isUnrotated = collider.entity.transform.rotation == 0; - if (collider._isRotationDirty) - this._areEdgeNormalsDirty = true; - } - this.position = es.Vector2.add(collider.entity.transform.position, this.center); - this.bounds = es.Rectangle.rectEncompassingPoints(this.points); - this.bounds.location.add(this.position); - }; - Polygon.prototype.overlaps = function (other) { - var result = new es.CollisionResult(); - if (other instanceof Polygon) - return es.ShapeCollisions.polygonToPolygon(this, other, result); - if (other instanceof es.Circle) { - if (es.ShapeCollisions.circleToPolygon(other, this, result)) { - result.invertResult(); - return true; - } - return false; - } - throw new Error("overlaps of Pologon to " + other + " are not supported"); - }; - Polygon.prototype.collidesWithShape = function (other, result) { - if (other instanceof Polygon) { - return es.ShapeCollisions.polygonToPolygon(this, other, result); - } - if (other instanceof es.Circle) { - if (es.ShapeCollisions.circleToPolygon(other, this, result)) { - result.invertResult(); - return true; - } - return false; - } - throw new Error("overlaps of Polygon to " + other + " are not supported"); - }; - Polygon.prototype.collidesWithLine = function (start, end, hit) { - return es.ShapeCollisions.lineToPoly(start, end, this, hit); - }; - Polygon.prototype.containsPoint = function (point) { - point.subtract(this.position); - var isInside = false; - for (var i = 0, j = this.points.length - 1; i < this.points.length; j = i++) { - if (((this.points[i].y > point.y) != (this.points[j].y > point.y)) && - (point.x < (this.points[j].x - this.points[i].x) * (point.y - this.points[i].y) / (this.points[j].y - this.points[i].y) + - this.points[i].x)) { - isInside = !isInside; - } - } - return isInside; - }; - Polygon.prototype.pointCollidesWithShape = function (point, result) { - return es.ShapeCollisions.pointToPoly(point, this, result); - }; - return Polygon; - }(es.Shape)); - es.Polygon = Polygon; -})(es || (es = {})); -var es; -(function (es) { - var Box = (function (_super) { - __extends(Box, _super); - function Box(width, height) { - var _this = _super.call(this, Box.buildBox(width, height), true) || this; - _this.width = width; - _this.height = height; - return _this; - } - Box.buildBox = function (width, height) { - var halfWidth = width / 2; - var halfHeight = height / 2; - var verts = new Array(4); - verts[0] = new es.Vector2(-halfWidth, -halfHeight); - verts[1] = new es.Vector2(halfWidth, -halfHeight); - verts[2] = new es.Vector2(halfWidth, halfHeight); - verts[3] = new es.Vector2(-halfWidth, halfHeight); - return verts; - }; - Box.prototype.updateBox = function (width, height) { - this.width = width; - this.height = height; - var halfWidth = width / 2; - var halfHeight = height / 2; - this.points[0] = new es.Vector2(-halfWidth, -halfHeight); - this.points[1] = new es.Vector2(halfWidth, -halfHeight); - this.points[2] = new es.Vector2(halfWidth, halfHeight); - this.points[3] = new es.Vector2(-halfWidth, halfHeight); - for (var i = 0; i < this.points.length; i++) - this._originalPoints[i] = this.points[i]; - }; - Box.prototype.overlaps = function (other) { - if (this.isUnrotated) { - if (other instanceof Box && other.isUnrotated) - return this.bounds.intersects(other.bounds); - if (other instanceof es.Circle) - return es.Collisions.rectToCircle(this.bounds, other.position, other.radius); - } - return _super.prototype.overlaps.call(this, other); - }; - Box.prototype.collidesWithShape = function (other, result) { - if (other instanceof Box && other.isUnrotated) { - return es.ShapeCollisions.boxToBox(this, other, result); - } - return _super.prototype.collidesWithShape.call(this, other, result); - }; - Box.prototype.containsPoint = function (point) { - if (this.isUnrotated) - return this.bounds.contains(point.x, point.y); - return _super.prototype.containsPoint.call(this, point); - }; - Box.prototype.pointCollidesWithShape = function (point, result) { - if (this.isUnrotated) - return es.ShapeCollisions.pointToBox(point, this, result); - return _super.prototype.pointCollidesWithShape.call(this, point, result); - }; - return Box; - }(es.Polygon)); - es.Box = Box; -})(es || (es = {})); -var es; -(function (es) { - var Circle = (function (_super) { - __extends(Circle, _super); - function Circle(radius) { - var _this = _super.call(this) || this; - _this.radius = radius; - _this._originalRadius = radius; - return _this; - } - Circle.prototype.recalculateBounds = function (collider) { - this.center = collider.localOffset; - if (collider.shouldColliderScaleAndRotateWithTransform) { - var scale = collider.entity.transform.scale; - var hasUnitScale = scale.x == 1 && scale.y == 1; - var maxScale = Math.max(scale.x, scale.y); - this.radius = this._originalRadius * maxScale; - if (collider.entity.transform.rotation != 0) { - var offsetAngle = Math.atan2(collider.localOffset.y, collider.localOffset.x) * es.MathHelper.Rad2Deg; - var offsetLength = hasUnitScale ? collider._localOffsetLength : es.Vector2.multiply(collider.localOffset, collider.entity.transform.scale).length(); - this.center = es.MathHelper.pointOnCirlce(es.Vector2.zero, offsetLength, collider.entity.transform.rotationDegrees + offsetAngle); - } - } - this.position = es.Vector2.add(collider.entity.transform.position, this.center); - this.bounds = new es.Rectangle(this.position.x - this.radius, this.position.y - this.radius, this.radius * 2, this.radius * 2); - }; - Circle.prototype.overlaps = function (other) { - var result = new es.CollisionResult(); - if (other instanceof es.Box && other.isUnrotated) - return es.Collisions.rectToCircle(other.bounds, this.position, this.radius); - if (other instanceof Circle) - return es.Collisions.circleToCircle(this.position, this.radius, other.position, other.radius); - if (other instanceof es.Polygon) - return es.ShapeCollisions.circleToPolygon(this, other, result); - throw new Error("overlaps of circle to " + other + " are not supported"); - }; - Circle.prototype.collidesWithShape = function (other, result) { - if (other instanceof es.Box && other.isUnrotated) { - return es.ShapeCollisions.circleToBox(this, other, result); - } - if (other instanceof Circle) { - return es.ShapeCollisions.circleToCircle(this, other, result); - } - if (other instanceof es.Polygon) { - return es.ShapeCollisions.circleToPolygon(this, other, result); - } - throw new Error("Collisions of Circle to " + other + " are not supported"); - }; - Circle.prototype.collidesWithLine = function (start, end, hit) { - return es.ShapeCollisions.lineToCircle(start, end, this, hit); - }; - Circle.prototype.containsPoint = function (point) { - return (es.Vector2.subtract(point, this.position)).lengthSquared() <= this.radius * this.radius; - }; - Circle.prototype.pointCollidesWithShape = function (point, result) { - return es.ShapeCollisions.pointToCircle(point, this, result); - }; - return Circle; - }(es.Shape)); - es.Circle = Circle; -})(es || (es = {})); -var es; -(function (es) { - var CollisionResult = (function () { - function CollisionResult() { - this.normal = es.Vector2.zero; - this.minimumTranslationVector = es.Vector2.zero; - this.point = es.Vector2.zero; - } - CollisionResult.prototype.removeHorizontal = function (deltaMovement) { - if (Math.sign(this.normal.x) != Math.sign(deltaMovement.x) || (deltaMovement.x == 0 && this.normal.x != 0)) { - var responseDistance = this.minimumTranslationVector.length(); - var fix = responseDistance / this.normal.y; - if (Math.abs(this.normal.x) != 1 && Math.abs(fix) < Math.abs(deltaMovement.y * 3)) { - this.minimumTranslationVector = new es.Vector2(0, -fix); - } - } - }; - CollisionResult.prototype.invertResult = function () { - this.minimumTranslationVector = es.Vector2.negate(this.minimumTranslationVector); - this.normal = es.Vector2.negate(this.normal); - return this; - }; - CollisionResult.prototype.toString = function () { - return "[CollisionResult] normal: " + this.normal + ", minimumTranslationVector: " + this.minimumTranslationVector; - }; - return CollisionResult; - }()); - es.CollisionResult = CollisionResult; -})(es || (es = {})); -var es; -(function (es) { - var RealtimeCollisions = (function () { - function RealtimeCollisions() { - } - RealtimeCollisions.intersectMovingCircleBox = function (s, b, movement, time) { - var e = b.bounds; - e.inflate(s.radius, s.radius); - var ray = new es.Ray2D(es.Vector2.subtract(s.position, movement), s.position); - if (!e.rayIntersects(ray, time) && time.value > 1) - return false; - var point = es.Vector2.add(ray.start, es.Vector2.add(ray.direction, new es.Vector2(time.value))); - var u, v = 0; - if (point.x < b.bounds.left) - u |= 1; - if (point.x > b.bounds.right) - v |= 1; - if (point.y < b.bounds.top) - u |= 2; - if (point.y > b.bounds.bottom) - v |= 2; - var m = u + v; - if (m == 3) { - console.log("m == 3. corner " + es.Time.frameCount); - } - if ((m & (m - 1)) == 0) { - return true; - } - return true; - }; - return RealtimeCollisions; - }()); - es.RealtimeCollisions = RealtimeCollisions; -})(es || (es = {})); -var es; -(function (es) { - var ShapeCollisions = (function () { - function ShapeCollisions() { - } - ShapeCollisions.polygonToPolygon = function (first, second, result) { - var isIntersecting = true; - var firstEdges = first.edgeNormals; - var secondEdges = second.edgeNormals; - var minIntervalDistance = Number.POSITIVE_INFINITY; - var translationAxis = new es.Vector2(); - var polygonOffset = es.Vector2.subtract(first.position, second.position); - var axis; - for (var edgeIndex = 0; edgeIndex < firstEdges.length + secondEdges.length; edgeIndex++) { - if (edgeIndex < firstEdges.length) { - axis = firstEdges[edgeIndex]; - } - else { - axis = secondEdges[edgeIndex - firstEdges.length]; - } - var minA = 0; - var minB = 0; - var maxA = 0; - var maxB = 0; - var intervalDist = 0; - var ta = this.getInterval(axis, first, minA, maxA); - minA = ta.min; - minB = ta.max; - var tb = this.getInterval(axis, second, minB, maxB); - minB = tb.min; - maxB = tb.max; - var relativeIntervalOffset = es.Vector2.dot(polygonOffset, axis); - minA += relativeIntervalOffset; - maxA += relativeIntervalOffset; - intervalDist = this.intervalDistance(minA, maxA, minB, maxB); - if (intervalDist > 0) - isIntersecting = false; - if (!isIntersecting) - return false; - intervalDist = Math.abs(intervalDist); - if (intervalDist < minIntervalDistance) { - minIntervalDistance = intervalDist; - translationAxis = axis; - if (es.Vector2.dot(translationAxis, polygonOffset) < 0) - translationAxis = new es.Vector2(-translationAxis); - } - } - result.normal = translationAxis; - result.minimumTranslationVector = es.Vector2.multiply(new es.Vector2(-translationAxis.x, -translationAxis.y), new es.Vector2(minIntervalDistance)); - return true; - }; - ShapeCollisions.intervalDistance = function (minA, maxA, minB, maxB) { - if (minA < minB) - return minB - maxA; - return minA - minB; - }; - ShapeCollisions.getInterval = function (axis, polygon, min, max) { - var dot = es.Vector2.dot(polygon.points[0], axis); - min = max = dot; - for (var i = 1; i < polygon.points.length; i++) { - dot = es.Vector2.dot(polygon.points[i], axis); - if (dot < min) { - min = dot; - } - else if (dot > max) { - max = dot; - } - } - return { min: min, max: max }; - }; - ShapeCollisions.circleToPolygon = function (circle, polygon, result) { - var poly2Circle = es.Vector2.subtract(circle.position, polygon.position); - var distanceSquared = new es.Ref(0); - var closestPoint = es.Polygon.getClosestPointOnPolygonToPoint(polygon.points, poly2Circle, distanceSquared, result.normal); - var circleCenterInsidePoly = polygon.containsPoint(circle.position); - if (distanceSquared.value > circle.radius * circle.radius && !circleCenterInsidePoly) - return false; - var mtv; - if (circleCenterInsidePoly) { - mtv = es.Vector2.multiply(result.normal, new es.Vector2(Math.sqrt(distanceSquared.value) - circle.radius)); - } - else { - if (distanceSquared.value == 0) { - mtv = es.Vector2.multiply(result.normal, new es.Vector2(circle.radius)); - } - else { - var distance = Math.sqrt(distanceSquared.value); - mtv = es.Vector2.multiply(new es.Vector2(-es.Vector2.subtract(poly2Circle, closestPoint)), new es.Vector2((circle.radius - distanceSquared.value) / distance)); - } - } - result.minimumTranslationVector = mtv; - result.point = es.Vector2.add(closestPoint, polygon.position); - return true; - }; - ShapeCollisions.circleToBox = function (circle, box, result) { - var closestPointOnBounds = box.bounds.getClosestPointOnRectangleBorderToPoint(circle.position, result.normal); - if (box.containsPoint(circle.position)) { - result.point = closestPointOnBounds; - var safePlace = es.Vector2.add(closestPointOnBounds, es.Vector2.multiply(result.normal, new es.Vector2(circle.radius))); - result.minimumTranslationVector = es.Vector2.subtract(circle.position, safePlace); - return true; - } - var sqrDistance = es.Vector2.distanceSquared(closestPointOnBounds, circle.position); - if (sqrDistance == 0) { - result.minimumTranslationVector = es.Vector2.multiply(result.normal, new es.Vector2(circle.radius)); - } - else if (sqrDistance <= circle.radius * circle.radius) { - result.normal = es.Vector2.subtract(circle.position, closestPointOnBounds); - var depth = result.normal.length() - circle.radius; - result.point = closestPointOnBounds; - es.Vector2Ext.normalize(result.normal); - result.minimumTranslationVector = es.Vector2.multiply(new es.Vector2(depth), result.normal); - return true; - } - return false; - }; - ShapeCollisions.pointToCircle = function (point, circle, result) { - var distanceSquared = es.Vector2.distanceSquared(point, circle.position); - var sumOfRadii = 1 + circle.radius; - var collided = distanceSquared < sumOfRadii * sumOfRadii; - if (collided) { - result.normal = es.Vector2.normalize(es.Vector2.subtract(point, circle.position)); - var depth = sumOfRadii - Math.sqrt(distanceSquared); - result.minimumTranslationVector = es.Vector2.multiply(new es.Vector2(-depth, -depth), result.normal); - result.point = es.Vector2.add(circle.position, es.Vector2.multiply(result.normal, new es.Vector2(circle.radius, circle.radius))); - return true; - } - return false; - }; - ShapeCollisions.pointToBox = function (point, box, result) { - if (box.containsPoint(point)) { - result.point = box.bounds.getClosestPointOnRectangleBorderToPoint(point, result.normal); - result.minimumTranslationVector = es.Vector2.subtract(point, result.point); - return true; - } - return false; - }; - ShapeCollisions.closestPointOnLine = function (lineA, lineB, closestTo) { - var v = es.Vector2.subtract(lineB, lineA); - var w = es.Vector2.subtract(closestTo, lineA); - var t = es.Vector2.dot(w, v) / es.Vector2.dot(v, v); - t = es.MathHelper.clamp(t, 0, 1); - return es.Vector2.add(lineA, es.Vector2.multiply(v, new es.Vector2(t, t))); - }; - ShapeCollisions.pointToPoly = function (point, poly, result) { - if (poly.containsPoint(point)) { - var distanceSquared = new es.Ref(0); - var closestPoint = es.Polygon.getClosestPointOnPolygonToPoint(poly.points, es.Vector2.subtract(point, poly.position), distanceSquared, result.normal); - result.minimumTranslationVector = es.Vector2.multiply(result.normal, new es.Vector2(Math.sqrt(distanceSquared.value), Math.sqrt(distanceSquared.value))); - result.point = es.Vector2.add(closestPoint, poly.position); - return true; - } - return false; - }; - ShapeCollisions.circleToCircle = function (first, second, result) { - var distanceSquared = es.Vector2.distanceSquared(first.position, second.position); - var sumOfRadii = first.radius + second.radius; - var collided = distanceSquared < sumOfRadii * sumOfRadii; - if (collided) { - result.normal = es.Vector2.normalize(es.Vector2.subtract(first.position, second.position)); - var depth = sumOfRadii - Math.sqrt(distanceSquared); - result.minimumTranslationVector = es.Vector2.multiply(new es.Vector2(-depth), result.normal); - result.point = es.Vector2.add(second.position, es.Vector2.multiply(result.normal, new es.Vector2(second.radius))); - return true; - } - return false; - }; - ShapeCollisions.boxToBox = function (first, second, result) { - var minkowskiDiff = this.minkowskiDifference(first, second); - if (minkowskiDiff.contains(0, 0)) { - result.minimumTranslationVector = minkowskiDiff.getClosestPointOnBoundsToOrigin(); - if (result.minimumTranslationVector.equals(es.Vector2.zero)) - return false; - result.normal = new es.Vector2(-result.minimumTranslationVector.x, -result.minimumTranslationVector.y); - result.normal.normalize(); - return true; - } - return false; - }; - ShapeCollisions.minkowskiDifference = function (first, second) { - var positionOffset = es.Vector2.subtract(first.position, es.Vector2.add(first.bounds.location, es.Vector2.divide(first.bounds.size, new es.Vector2(2)))); - var topLeft = es.Vector2.subtract(es.Vector2.add(first.bounds.location, positionOffset), second.bounds.max); - var fullSize = es.Vector2.add(first.bounds.size, second.bounds.size); - return new es.Rectangle(topLeft.x, topLeft.y, fullSize.x, fullSize.y); - }; - ShapeCollisions.lineToPoly = function (start, end, polygon, hit) { - var normal = es.Vector2.zero; - var intersectionPoint = es.Vector2.zero; - var fraction = Number.MAX_VALUE; - var hasIntersection = false; - for (var j = polygon.points.length - 1, i = 0; i < polygon.points.length; j = i, i++) { - var edge1 = es.Vector2.add(polygon.position, polygon.points[j]); - var edge2 = es.Vector2.add(polygon.position, polygon.points[i]); - var intersection = es.Vector2.zero; - if (this.lineToLine(edge1, edge2, start, end, intersection)) { - hasIntersection = true; - var distanceFraction = (intersection.x - start.x) / (end.x - start.x); - if (Number.isNaN(distanceFraction) || Number.isFinite(distanceFraction)) - distanceFraction = (intersection.y - start.y) / (end.y - start.y); - if (distanceFraction < fraction) { - var edge = es.Vector2.subtract(edge2, edge1); - normal = new es.Vector2(edge.y, -edge.x); - fraction = distanceFraction; - intersectionPoint = intersection; - } - } - } - if (hasIntersection) { - normal.normalize(); - var distance = es.Vector2.distance(start, intersectionPoint); - hit.setValuesNonCollider(fraction, distance, intersectionPoint, normal); - return true; - } - return false; - }; - ShapeCollisions.lineToLine = function (a1, a2, b1, b2, intersection) { - var b = es.Vector2.subtract(a2, a1); - var d = es.Vector2.subtract(b2, b1); - var bDotDPerp = b.x * d.y - b.y * d.x; - if (bDotDPerp == 0) - return false; - var c = es.Vector2.subtract(b1, a1); - var t = (c.x * d.y - c.y * d.x) / bDotDPerp; - if (t < 0 || t > 1) - return false; - var u = (c.x * b.y - c.y * b.x) / bDotDPerp; - if (u < 0 || u > 1) - return false; - intersection = intersection.add(a1).add(es.Vector2.multiply(new es.Vector2(t), b)); - return true; - }; - ShapeCollisions.lineToCircle = function (start, end, s, hit) { - var lineLength = es.Vector2.distance(start, end); - var d = es.Vector2.divide(es.Vector2.subtract(end, start), new es.Vector2(lineLength)); - var m = es.Vector2.subtract(start, s.position); - var b = es.Vector2.dot(m, d); - var c = es.Vector2.dot(m, m) - s.radius * s.radius; - if (c > 0 && b > 0) - return false; - var discr = b * b - c; - if (discr < 0) - return false; - hit.fraction = -b - Math.sqrt(discr); - if (hit.fraction < 0) - hit.fraction = 0; - hit.point = es.Vector2.add(start, es.Vector2.multiply(new es.Vector2(hit.fraction), d)); - hit.distance = es.Vector2.distance(start, hit.point); - hit.normal = es.Vector2.normalize(es.Vector2.subtract(hit.point, s.position)); - hit.fraction = hit.distance / lineLength; - return true; - }; - ShapeCollisions.boxToBoxCast = function (first, second, movement, hit) { - var minkowskiDiff = this.minkowskiDifference(first, second); - if (minkowskiDiff.contains(0, 0)) { - var mtv = minkowskiDiff.getClosestPointOnBoundsToOrigin(); - if (mtv.equals(es.Vector2.zero)) - return false; - hit.normal = new es.Vector2(-mtv.x); - hit.normal.normalize(); - hit.distance = 0; - hit.fraction = 0; - return true; - } - else { - var ray = new es.Ray2D(es.Vector2.zero, new es.Vector2(-movement.x)); - var fraction = new es.Ref(0); - if (minkowskiDiff.rayIntersects(ray, fraction) && fraction.value <= 1) { - hit.fraction = fraction.value; - hit.distance = movement.length() * fraction.value; - hit.normal = new es.Vector2(-movement.x, -movement.y); - hit.normal.normalize(); - hit.centroid = es.Vector2.add(first.bounds.center, es.Vector2.multiply(movement, new es.Vector2(fraction.value))); - return true; - } - } - return false; - }; - return ShapeCollisions; - }()); - es.ShapeCollisions = ShapeCollisions; -})(es || (es = {})); -var es; -(function (es) { - var Particle = (function () { - function Particle() { - this.mass = 1; - this.radius = 0; - this.collidesWithColliders = true; - } - Particle.prototype.applyForce = function (force) { - this.acceleration.add(es.Vector2.divide(force, new es.Vector2(this.mass))); - }; - return Particle; - }()); - es.Particle = Particle; -})(es || (es = {})); -var es; -(function (es) { - var VerletWorld = (function () { - function VerletWorld(simulationBounds) { - if (simulationBounds === void 0) { simulationBounds = null; } - this.gravity = new es.Vector2(0, 980); - this.constraintIterations = 3; - this.maximumStepIterations = 5; - this.allowDragging = true; - this._composites = []; - this._tempCircle = new es.Circle(1); - this._leftOverTime = 0; - this._fixedDeltaTime = 1 / 60; - this._iterationSteps = 0; - this._fixedDeltaTimeSq = 0; - this.simulationBounds = simulationBounds; - this._fixedDeltaTimeSq = Math.pow(this._fixedDeltaTimeSq, 2); - } - VerletWorld.prototype.update = function () { - this.updateTiming(); - if (this.allowDragging) - this.handleDragging(); - for (var iteration = 1; iteration <= this._iterationSteps; iteration++) { - for (var i = this._composites.length - 1; i >= 0; i--) { - var composite = this._composites[i]; - for (var s = 0; s < this.constraintIterations; s++) - composite.solveConstraints(); - composite.updateParticles(this._fixedDeltaTimeSq, this.gravity); - composite.handleConstraintCollisions(); - for (var j = 0; j < composite.particles.length; j++) { - var p = composite.particles[j]; - if (this.simulationBounds) { - this.constrainParticleToBounds(p); - } - if (p.collidesWithColliders) - this.handleCollisions(p, composite.collidesWithLayers); - } - } - } - }; - VerletWorld.prototype.handleCollisions = function (p, collidesWithLayers) { - var collidedCount = es.Physics.overlapCircleAll(p.position, p.radius, VerletWorld._colliders, collidesWithLayers); - for (var i = 0; i < collidedCount; i++) { - var collider = VerletWorld._colliders[i]; - if (collider.isTrigger) - continue; - var collisionResult = new es.CollisionResult(); - if (p.radius < 2) { - if (collider.shape.pointCollidesWithShape(p.position, collisionResult)) { - p.position.subtract(collisionResult.minimumTranslationVector); - } - } - else { - this._tempCircle.radius = p.radius; - this._tempCircle.position = p.position; - if (this._tempCircle.collidesWithShape(collider.shape, collisionResult)) { - p.position.subtract(collisionResult.minimumTranslationVector); - } - } - } - }; - VerletWorld.prototype.constrainParticleToBounds = function (p) { - var tempPos = p.position; - var bounds = this.simulationBounds; - if (p.radius == 0) { - if (tempPos.y > bounds.height) - tempPos.y = bounds.height; - else if (tempPos.y < bounds.y) - tempPos.y = bounds.y; - if (tempPos.x < bounds.x) - tempPos.x = bounds.x; - else if (tempPos.x > bounds.width) - tempPos.x = bounds.width; - } - else { - if (tempPos.y < bounds.y + p.radius) - tempPos.y = 2 * (bounds.y + p.radius) - tempPos.y; - if (tempPos.y > bounds.height - p.radius) - tempPos.y = 2 * (bounds.height - p.radius) - tempPos.y; - if (tempPos.x > bounds.width - p.radius) - tempPos.x = 2 * (bounds.width - p.radius) - tempPos.x; - if (tempPos.x < bounds.x + p.radius) - tempPos.x = 2 * (bounds.x + p.radius) - tempPos.x; - } - p.position = tempPos; - }; - VerletWorld.prototype.updateTiming = function () { - this._leftOverTime += es.Time.deltaTime; - this._iterationSteps = Math.floor(Math.trunc(this._leftOverTime / this._fixedDeltaTime)); - this._leftOverTime -= this._iterationSteps * this._fixedDeltaTime; - this._iterationSteps = Math.min(this._iterationSteps, this.maximumStepIterations); - }; - VerletWorld.prototype.addComposite = function (composite) { - this._composites.push(composite); - return composite; - }; - VerletWorld.prototype.removeComposite = function (composite) { - this._composites.remove(composite); - }; - VerletWorld.prototype.handleDragging = function () { - }; - VerletWorld.prototype.debugRender = function (camera) { - for (var i = 0; i < this._composites.length; i++) - this._composites[i].debugRender(camera); - }; - VerletWorld._colliders = new Array(4); - return VerletWorld; - }()); - es.VerletWorld = VerletWorld; -})(es || (es = {})); -var es; -(function (es) { - var Composite = (function () { - function Composite() { - this.friction = new es.Vector2(0.98, 1); - this.collidesWithLayers = es.Physics.allLayers; - this.particles = []; - this._constraints = []; - } - Composite.prototype.solveConstraints = function () { - for (var i = this._constraints.length - 1; i >= 0; i--) { - this._constraints[i].solve(); - } - }; - Composite.prototype.updateParticles = function (deltaTimeSquared, gravity) { - for (var j = 0; j < this.particles.length; j++) { - var p = this.particles[j]; - if (p.isPinned) { - p.position = p.pinnedPosition; - continue; - } - p.applyForce(es.Vector2.multiply(new es.Vector2(p.mass), gravity)); - var vel = es.Vector2.subtract(p.position, p.lastPosition).multiply(this.friction); - var nextPos = es.Vector2.add(p.position, vel).add(es.Vector2.multiply(new es.Vector2(0.5 * deltaTimeSquared), p.acceleration)); - p.lastPosition = p.position; - p.position = nextPos; - p.acceleration.x = p.acceleration.y = 0; - } - }; - Composite.prototype.handleConstraintCollisions = function () { - for (var i = this._constraints.length - 1; i >= 0; i--) { - if (this._constraints[i].collidesWithColliders) - this._constraints[i].handleCollisions(this.collidesWithLayers); - } - }; - Composite.prototype.debugRender = function (camera) { - }; - return Composite; - }()); - es.Composite = Composite; -})(es || (es = {})); -var es; -(function (es) { - var Constraint = (function () { - function Constraint() { - this.collidesWithColliders = true; - } - Constraint.prototype.handleCollisions = function (collidesWithLayers) { }; - return Constraint; - }()); - es.Constraint = Constraint; -})(es || (es = {})); -var ArrayUtils = (function () { - function ArrayUtils() { - } - ArrayUtils.bubbleSort = function (ary) { - var isExchange = false; - for (var i = 0; i < ary.length; i++) { - isExchange = false; - for (var j = ary.length - 1; j > i; j--) { - if (ary[j] < ary[j - 1]) { - var temp = ary[j]; - ary[j] = ary[j - 1]; - ary[j - 1] = temp; - isExchange = true; - } - } - if (!isExchange) - break; - } - }; - ArrayUtils.insertionSort = function (ary) { - var len = ary.length; - for (var i = 1; i < len; i++) { - var val = ary[i]; - for (var j = i; j > 0 && ary[j - 1] > val; j--) { - ary[j] = ary[j - 1]; - } - ary[j] = val; - } - }; - ArrayUtils.binarySearch = function (ary, value) { - var startIndex = 0; - var endIndex = ary.length; - var sub = (startIndex + endIndex) >> 1; - while (startIndex < endIndex) { - if (value <= ary[sub]) - endIndex = sub; - else if (value >= ary[sub]) - startIndex = sub + 1; - sub = (startIndex + endIndex) >> 1; - } - if (ary[startIndex] == value) - return startIndex; - return -1; - }; - ArrayUtils.findElementIndex = function (ary, num) { - var len = ary.length; - for (var i = 0; i < len; ++i) { - if (ary[i] == num) - return i; - } - return null; - }; - ArrayUtils.getMaxElementIndex = function (ary) { - var matchIndex = 0; - var len = ary.length; - for (var j = 1; j < len; j++) { - if (ary[j] > ary[matchIndex]) - matchIndex = j; - } - return matchIndex; - }; - ArrayUtils.getMinElementIndex = function (ary) { - var matchIndex = 0; - var len = ary.length; - for (var j = 1; j < len; j++) { - if (ary[j] < ary[matchIndex]) - matchIndex = j; - } - return matchIndex; - }; - ArrayUtils.getUniqueAry = function (ary) { - var uAry = []; - var newAry = []; - var count = ary.length; - for (var i = 0; i < count; ++i) { - var value = ary[i]; - if (uAry.indexOf(value) == -1) - uAry.push(value); - } - count = uAry.length; - for (var i = count - 1; i >= 0; --i) { - newAry.unshift(uAry[i]); - } - return newAry; - }; - ArrayUtils.getDifferAry = function (aryA, aryB) { - aryA = this.getUniqueAry(aryA); - aryB = this.getUniqueAry(aryB); - var ary = aryA.concat(aryB); - var uObj = {}; - var newAry = []; - var count = ary.length; - for (var j = 0; j < count; ++j) { - if (!uObj[ary[j]]) { - uObj[ary[j]] = {}; - uObj[ary[j]].count = 0; - uObj[ary[j]].key = ary[j]; - uObj[ary[j]].count++; - } - else { - if (uObj[ary[j]] instanceof Object) { - uObj[ary[j]].count++; - } - } - } - for (var i in uObj) { - if (uObj[i].count != 2) { - newAry.unshift(uObj[i].key); - } - } - return newAry; - }; - ArrayUtils.swap = function (array, index1, index2) { - var temp = array[index1]; - array[index1] = array[index2]; - array[index2] = temp; - }; - ArrayUtils.clearList = function (ary) { - if (!ary) - return; - var length = ary.length; - for (var i = length - 1; i >= 0; i -= 1) { - ary.splice(i, 1); - } - }; - ArrayUtils.cloneList = function (ary) { - if (!ary) - return null; - return ary.slice(0, ary.length); - }; - ArrayUtils.equals = function (ary1, ary2) { - if (ary1 == ary2) - return true; - var length = ary1.length; - if (length != ary2.length) - return false; - while (length--) { - if (ary1[length] != ary2[length]) - return false; - } - return true; - }; - ArrayUtils.insert = function (ary, index, value) { - if (!ary) - return null; - var length = ary.length; - if (index > length) - index = length; - if (index < 0) - index = 0; - if (index == length) - ary.push(value); - else if (index == 0) - ary.unshift(value); - else { - for (var i = length - 1; i >= index; i -= 1) { - ary[i + 1] = ary[i]; - } - ary[index] = value; - } - return value; - }; - return ArrayUtils; -}()); -var es; -(function (es) { - var Base64Utils = (function () { - function Base64Utils() { - } - Object.defineProperty(Base64Utils, "nativeBase64", { - get: function () { - return (typeof (window.atob) === "function"); - }, - enumerable: true, - configurable: true - }); - Base64Utils.decode = function (input) { - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - if (this.nativeBase64) { - return window.atob(input); - } - else { - var output = [], chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0; - while (i < input.length) { - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - output.push(String.fromCharCode(chr1)); - if (enc3 !== 64) { - output.push(String.fromCharCode(chr2)); - } - if (enc4 !== 64) { - output.push(String.fromCharCode(chr3)); - } - } - output = output.join(""); - return output; - } - }; - Base64Utils.encode = function (input) { - input = input.replace(/\r\n/g, "\n"); - if (this.nativeBase64) { - window.btoa(input); - } - else { - var output = [], chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0; - while (i < input.length) { - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } - else if (isNaN(chr3)) { - enc4 = 64; - } - output.push(this._keyStr.charAt(enc1)); - output.push(this._keyStr.charAt(enc2)); - output.push(this._keyStr.charAt(enc3)); - output.push(this._keyStr.charAt(enc4)); - } - output = output.join(""); - return output; - } - }; - Base64Utils.decodeBase64AsArray = function (input, bytes) { - bytes = bytes || 1; - var dec = Base64Utils.decode(input), i, j, len; - var ar = new Uint32Array(dec.length / bytes); - for (i = 0, len = dec.length / bytes; i < len; i++) { - ar[i] = 0; - for (j = bytes - 1; j >= 0; --j) { - ar[i] += dec.charCodeAt((i * bytes) + j) << (j << 3); - } - } - return ar; - }; - Base64Utils.decompress = function (data, decoded, compression) { - throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!"); - }; - Base64Utils.decodeCSV = function (input) { - var entries = input.replace("\n", "").trim().split(","); - var result = []; - for (var i = 0; i < entries.length; i++) { - result.push(+entries[i]); - } - return result; - }; - Base64Utils._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - return Base64Utils; - }()); - es.Base64Utils = Base64Utils; -})(es || (es = {})); -var es; -(function (es) { - var Color = (function () { - function Color(r, g, b, alpha) { - if (((r | g | b | alpha) & 0xFFFFFF00) != 0) { - var clampedR = es.MathHelper.clamp(r, 0, 255); - var clampedG = es.MathHelper.clamp(g, 0, 255); - var clampedB = es.MathHelper.clamp(b, 0, 255); - var clampedA = es.MathHelper.clamp(alpha, 0, 255); - this._packedValue = (clampedA << 24) | (clampedB << 16) | (clampedG << 8) | (clampedR); - } - else { - this._packedValue = (alpha << 24) | (b << 16) | (g << 8) | r; - } - } - Object.defineProperty(Color.prototype, "b", { - get: function () { - return this._packedValue >> 16; - }, - set: function (value) { - this._packedValue = (this._packedValue & 0xff00ffff) | (value << 16); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Color.prototype, "g", { - get: function () { - return this._packedValue >> 8; - }, - set: function (value) { - this._packedValue = (this._packedValue & 0xffff00ff) | (value << 8); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Color.prototype, "r", { - get: function () { - return this._packedValue; - }, - set: function (value) { - this._packedValue = (this._packedValue & 0xffffff00) | value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Color.prototype, "a", { - get: function () { - return this._packedValue >> 24; - }, - set: function (value) { - this._packedValue = (this._packedValue & 0x00ffffff) | (value << 24); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Color.prototype, "packedValue", { - get: function () { - return this._packedValue; - }, - set: function (value) { - this._packedValue = value; - }, - enumerable: true, - configurable: true - }); - Color.prototype.equals = function (other) { - return this._packedValue == other._packedValue; - }; - return Color; - }()); - es.Color = Color; -})(es || (es = {})); -var es; -(function (es) { - var ContentManager = (function () { - function ContentManager() { - this.loadedAssets = new Map(); - } - ContentManager.prototype.loadRes = function (name, local) { - var _this = this; - if (local === void 0) { local = true; } - return new Promise(function (resolve, reject) { - var res = _this.loadedAssets.get(name); - if (res) { - resolve(res); - return; - } - if (local) { - RES.getResAsync(name).then(function (data) { - _this.loadedAssets.set(name, data); - resolve(data); - }).catch(function (err) { - console.error("资源加载错误:", name, err); - reject(err); - }); - } - else { - RES.getResByUrl(name).then(function (data) { - _this.loadedAssets.set(name, data); - resolve(data); - }).catch(function (err) { - console.error("资源加载错误:", name, err); - reject(err); - }); - } - }); - }; - ContentManager.prototype.dispose = function () { - this.loadedAssets.forEach(function (value) { - var assetsToRemove = value; - if (RES.destroyRes(assetsToRemove)) - assetsToRemove.dispose(); - }); - this.loadedAssets.clear(); - }; - return ContentManager; - }()); - es.ContentManager = ContentManager; -})(es || (es = {})); -var es; -(function (es) { - var DrawUtils = (function () { - function DrawUtils() { - } - DrawUtils.getColorMatrix = function (color) { - var colorMatrix = [ - 1, 0, 0, 0, 0, - 0, 1, 0, 0, 0, - 0, 0, 1, 0, 0, - 0, 0, 0, 1, 0 - ]; - colorMatrix[0] = Math.floor(color / 256 / 256) / 255; - colorMatrix[6] = Math.floor(color / 256 % 256) / 255; - colorMatrix[12] = color % 256 / 255; - return new egret.ColorMatrixFilter(colorMatrix); - }; - return DrawUtils; - }()); - es.DrawUtils = DrawUtils; -})(es || (es = {})); -var es; -(function (es) { - var EdgeExt = (function () { - function EdgeExt() { - } - EdgeExt.oppositeEdge = function (self) { - switch (self) { - case es.Edge.bottom: - return es.Edge.top; - case es.Edge.top: - return es.Edge.bottom; - case es.Edge.left: - return es.Edge.right; - case es.Edge.right: - return es.Edge.left; - } - }; - EdgeExt.isHorizontal = function (self) { - return self == es.Edge.right || self == es.Edge.left; - }; - EdgeExt.isVertical = function (self) { - return self == es.Edge.top || self == es.Edge.bottom; - }; - return EdgeExt; - }()); - es.EdgeExt = EdgeExt; -})(es || (es = {})); -var es; -(function (es) { - var FuncPack = (function () { - function FuncPack(func, context) { - this.func = func; - this.context = context; - } - return FuncPack; - }()); - es.FuncPack = FuncPack; - var Emitter = (function () { - function Emitter() { - this._messageTable = new Map(); - } - Emitter.prototype.addObserver = function (eventType, handler, context) { - var list = this._messageTable.get(eventType); - if (!list) { - list = []; - this._messageTable.set(eventType, list); - } - if (list.findIndex(function (funcPack) { return funcPack.func == handler; }) != -1) - console.warn("您试图添加相同的观察者两次"); - list.push(new FuncPack(handler, context)); - }; - Emitter.prototype.removeObserver = function (eventType, handler) { - var messageData = this._messageTable.get(eventType); - var index = messageData.findIndex(function (data) { return data.func == handler; }); - if (index != -1) - messageData.removeAt(index); - }; - Emitter.prototype.emit = function (eventType, data) { - var list = this._messageTable.get(eventType); - if (list) { - for (var i = list.length - 1; i >= 0; i--) - list[i].func.call(list[i].context, data); - } - }; - return Emitter; - }()); - es.Emitter = Emitter; -})(es || (es = {})); -var es; -(function (es) { - var Edge; - (function (Edge) { - Edge[Edge["top"] = 0] = "top"; - Edge[Edge["bottom"] = 1] = "bottom"; - Edge[Edge["left"] = 2] = "left"; - Edge[Edge["right"] = 3] = "right"; - })(Edge = es.Edge || (es.Edge = {})); -})(es || (es = {})); -var es; -(function (es) { - var Enumerable = (function () { - function Enumerable() { - } - Enumerable.repeat = function (element, count) { - var result = []; - while (count--) { - result.push(element); - } - return result; - }; - return Enumerable; - }()); - es.Enumerable = Enumerable; -})(es || (es = {})); -var es; -(function (es) { - var EqualityComparer = (function () { - function EqualityComparer() { - } - EqualityComparer.default = function () { - return new EqualityComparer(); - }; - EqualityComparer.prototype.equals = function (x, y) { - if (typeof x["equals"] == 'function') { - return x["equals"](y); - } - else { - return x === y; - } - }; - return EqualityComparer; - }()); - es.EqualityComparer = EqualityComparer; -})(es || (es = {})); -var es; -(function (es) { - var GlobalManager = (function () { - function GlobalManager() { - } - Object.defineProperty(GlobalManager.prototype, "enabled", { - get: function () { - return this._enabled; - }, - set: function (value) { - this.setEnabled(value); - }, - enumerable: true, - configurable: true - }); - GlobalManager.prototype.setEnabled = function (isEnabled) { - if (this._enabled != isEnabled) { - this._enabled = isEnabled; - if (this._enabled) { - this.onEnabled(); - } - else { - this.onDisabled(); - } - } - }; - GlobalManager.prototype.onEnabled = function () { - }; - GlobalManager.prototype.onDisabled = function () { - }; - GlobalManager.prototype.update = function () { - }; - return GlobalManager; - }()); - es.GlobalManager = GlobalManager; -})(es || (es = {})); -var es; -(function (es) { - var ListPool = (function () { - function ListPool() { - } - ListPool.warmCache = function (cacheCount) { - cacheCount -= this._objectQueue.length; - if (cacheCount > 0) { - for (var i = 0; i < cacheCount; i++) { - this._objectQueue.unshift([]); - } - } - }; - ListPool.trimCache = function (cacheCount) { - while (cacheCount > this._objectQueue.length) - this._objectQueue.shift(); - }; - ListPool.clearCache = function () { - this._objectQueue.length = 0; - }; - ListPool.obtain = function () { - if (this._objectQueue.length > 0) - return this._objectQueue.shift(); - return []; - }; - ListPool.free = function (obj) { - this._objectQueue.unshift(obj); - obj.length = 0; - }; - ListPool._objectQueue = []; - return ListPool; - }()); - es.ListPool = ListPool; -})(es || (es = {})); -var es; -(function (es) { - var NumberExtension = (function () { - function NumberExtension() { - } - NumberExtension.toNumber = function (value) { - if (value == undefined) - return 0; - return Number(value); - }; - return NumberExtension; - }()); - es.NumberExtension = NumberExtension; -})(es || (es = {})); -var es; -(function (es) { - var Pair = (function () { - function Pair(first, second) { - this.first = first; - this.second = second; - } - Pair.prototype.clear = function () { - this.first = this.second = null; - }; - Pair.prototype.equals = function (other) { - return this.first == other.first && this.second == other.second; - }; - return Pair; - }()); - es.Pair = Pair; -})(es || (es = {})); -var es; -(function (es) { - var Pool = (function () { - function Pool() { - } - Pool.warmCache = function (type, cacheCount) { - cacheCount -= this._objectQueue.length; - if (cacheCount > 0) { - for (var i = 0; i < cacheCount; i++) { - this._objectQueue.unshift(new type()); - } - } - }; - Pool.trimCache = function (cacheCount) { - while (cacheCount > this._objectQueue.length) - this._objectQueue.shift(); - }; - Pool.clearCache = function () { - this._objectQueue.length = 0; - }; - Pool.obtain = function (type) { - if (this._objectQueue.length > 0) - return this._objectQueue.shift(); - return new type(); - }; - Pool.free = function (obj) { - this._objectQueue.unshift(obj); - if (egret.is(obj, "IPoolable")) { - obj["reset"](); - } - }; - Pool._objectQueue = []; - return Pool; - }()); - es.Pool = Pool; -})(es || (es = {})); -var RandomUtils = (function () { - function RandomUtils() { - } - RandomUtils.randrange = function (start, stop, step) { - if (step === void 0) { step = 1; } - if (step == 0) - throw new Error('step 不能为 0'); - var width = stop - start; - if (width == 0) - throw new Error('没有可用的范围(' + start + ',' + stop + ')'); - if (width < 0) - width = start - stop; - var n = Math.floor((width + step - 1) / step); - return Math.floor(this.random() * n) * step + Math.min(start, stop); - }; - RandomUtils.randint = function (a, b) { - a = Math.floor(a); - b = Math.floor(b); - if (a > b) - a++; - else - b++; - return this.randrange(a, b); - }; - RandomUtils.randnum = function (a, b) { - return this.random() * (b - a) + a; - }; - RandomUtils.shuffle = function (array) { - array.sort(this._randomCompare); - return array; - }; - RandomUtils.choice = function (sequence) { - if (!sequence.hasOwnProperty("length")) - throw new Error('无法对此对象执行此操作'); - var index = Math.floor(this.random() * sequence.length); - if (sequence instanceof String) - return String(sequence).charAt(index); - else - return sequence[index]; - }; - RandomUtils.sample = function (sequence, num) { - var len = sequence.length; - if (num <= 0 || len < num) - throw new Error("采样数量不够"); - var selected = []; - var indices = []; - for (var i = 0; i < num; i++) { - var index = Math.floor(this.random() * len); - while (indices.indexOf(index) >= 0) - index = Math.floor(this.random() * len); - selected.push(sequence[index]); - indices.push(index); - } - return selected; - }; - RandomUtils.random = function () { - return Math.random(); - }; - RandomUtils.boolean = function (chance) { - if (chance === void 0) { chance = .5; } - return (this.random() < chance) ? true : false; - }; - RandomUtils._randomCompare = function (a, b) { - return (this.random() > .5) ? 1 : -1; - }; - return RandomUtils; -}()); -var es; -(function (es) { - var RectangleExt = (function () { - function RectangleExt() { - } - RectangleExt.getSide = function (rect, edge) { - switch (edge) { - case es.Edge.top: - return rect.top; - case es.Edge.bottom: - return rect.bottom; - case es.Edge.left: - return rect.left; - case es.Edge.right: - return rect.right; - } - }; - RectangleExt.union = function (first, point) { - var rect = new es.Rectangle(point.x, point.y, 0, 0); - var result = new es.Rectangle(); - result.x = Math.min(first.x, rect.x); - result.y = Math.min(first.y, rect.y); - result.width = Math.max(first.right, rect.right) - result.x; - result.height = Math.max(first.bottom, result.bottom) - result.y; - return result; - }; - RectangleExt.getHalfRect = function (rect, edge) { - switch (edge) { - case es.Edge.top: - return new es.Rectangle(rect.x, rect.y, rect.width, rect.height / 2); - case es.Edge.bottom: - return new es.Rectangle(rect.x, rect.y + rect.height / 2, rect.width, rect.height / 2); - case es.Edge.left: - return new es.Rectangle(rect.x, rect.y, rect.width / 2, rect.height); - case es.Edge.right: - return new es.Rectangle(rect.x + rect.width / 2, rect.y, rect.width / 2, rect.height); - } - }; - RectangleExt.getRectEdgePortion = function (rect, edge, size) { - if (size === void 0) { size = 1; } - switch (edge) { - case es.Edge.top: - return new es.Rectangle(rect.x, rect.y, rect.width, size); - case es.Edge.bottom: - return new es.Rectangle(rect.x, rect.y + rect.height - size, rect.width, size); - case es.Edge.left: - return new es.Rectangle(rect.x, rect.y, size, rect.height); - case es.Edge.right: - return new es.Rectangle(rect.x + rect.width - size, rect.y, size, rect.height); - } - }; - RectangleExt.expandSide = function (rect, edge, amount) { - amount = Math.abs(amount); - switch (edge) { - case es.Edge.top: - rect.y -= amount; - rect.height += amount; - break; - case es.Edge.bottom: - rect.height += amount; - break; - case es.Edge.left: - rect.x -= amount; - rect.width += amount; - break; - case es.Edge.right: - rect.width += amount; - break; - } - }; - RectangleExt.contract = function (rect, horizontalAmount, verticalAmount) { - rect.x += horizontalAmount; - rect.y += verticalAmount; - rect.width -= horizontalAmount * 2; - rect.height -= verticalAmount * 2; - }; - return RectangleExt; - }()); - es.RectangleExt = RectangleExt; -})(es || (es = {})); -var es; -(function (es) { - var Ref = (function () { - function Ref(value) { - this.value = value; - } - return Ref; - }()); - es.Ref = Ref; -})(es || (es = {})); -var es; -(function (es) { - var SubpixelNumber = (function () { - function SubpixelNumber() { - } - SubpixelNumber.prototype.update = function (amount) { - this.remainder += amount; - var motion = Math.trunc(this.remainder); - this.remainder -= motion; - return motion; - }; - SubpixelNumber.prototype.reset = function () { - this.remainder = 0; - }; - return SubpixelNumber; - }()); - es.SubpixelNumber = SubpixelNumber; -})(es || (es = {})); -var es; -(function (es) { - var Triangulator = (function () { - function Triangulator() { - this.triangleIndices = []; - this._triPrev = new Array(12); - this._triNext = new Array(12); - } - Triangulator.testPointTriangle = function (point, a, b, c) { - if (es.Vector2Ext.cross(es.Vector2.subtract(point, a), es.Vector2.subtract(b, a)) < 0) - return false; - if (es.Vector2Ext.cross(es.Vector2.subtract(point, b), es.Vector2.subtract(c, b)) < 0) - return false; - if (es.Vector2Ext.cross(es.Vector2.subtract(point, c), es.Vector2.subtract(a, c)) < 0) - return false; - return true; - }; - Triangulator.prototype.triangulate = function (points, arePointsCCW) { - if (arePointsCCW === void 0) { arePointsCCW = true; } - var count = points.length; - this.initialize(count); - var iterations = 0; - var index = 0; - while (count > 3 && iterations < 500) { - iterations++; - var isEar = true; - var a = points[this._triPrev[index]]; - var b = points[index]; - var c = points[this._triNext[index]]; - if (es.Vector2Ext.isTriangleCCW(a, b, c)) { - var k = this._triNext[this._triNext[index]]; - do { - if (Triangulator.testPointTriangle(points[k], a, b, c)) { - isEar = false; - break; - } - k = this._triNext[k]; - } while (k != this._triPrev[index]); - } - else { - isEar = false; - } - if (isEar) { - this.triangleIndices.push(this._triPrev[index]); - this.triangleIndices.push(index); - this.triangleIndices.push(this._triNext[index]); - this._triNext[this._triPrev[index]] = this._triNext[index]; - this._triPrev[this._triNext[index]] = this._triPrev[index]; - count--; - index = this._triPrev[index]; - } - else { - index = this._triNext[index]; - } - } - this.triangleIndices.push(this._triPrev[index]); - this.triangleIndices.push(index); - this.triangleIndices.push(this._triNext[index]); - if (!arePointsCCW) - this.triangleIndices.reverse(); - }; - Triangulator.prototype.initialize = function (count) { - this.triangleIndices.length = 0; - if (this._triNext.length < count) { - this._triNext.reverse(); - this._triNext = new Array(Math.max(this._triNext.length * 2, count)); - } - if (this._triPrev.length < count) { - this._triPrev.reverse(); - this._triPrev = new Array(Math.max(this._triPrev.length * 2, count)); - } - for (var i = 0; i < count; i++) { - this._triPrev[i] = i - 1; - this._triNext[i] = i + 1; - } - this._triPrev[0] = count - 1; - this._triNext[count - 1] = 0; - }; - return Triangulator; - }()); - es.Triangulator = Triangulator; -})(es || (es = {})); -var es; -(function (es) { - var Vector2Ext = (function () { - function Vector2Ext() { - } - Vector2Ext.isTriangleCCW = function (a, center, c) { - return this.cross(es.Vector2.subtract(center, a), es.Vector2.subtract(c, center)) < 0; - }; - Vector2Ext.halfVector = function () { - return new es.Vector2(0.5, 0.5); - }; - Vector2Ext.cross = function (u, v) { - return u.y * v.x - u.x * v.y; - }; - Vector2Ext.perpendicular = function (first, second) { - return new es.Vector2(-1 * (second.y - first.y), second.x - first.x); - }; - Vector2Ext.normalize = function (vec) { - var magnitude = Math.sqrt((vec.x * vec.x) + (vec.y * vec.y)); - if (magnitude > es.MathHelper.Epsilon) { - vec.divide(new es.Vector2(magnitude)); - } - else { - vec.x = vec.y = 0; - } - }; - Vector2Ext.transformA = function (sourceArray, sourceIndex, matrix, destinationArray, destinationIndex, length) { - for (var i = 0; i < length; i++) { - var position = sourceArray[sourceIndex + i]; - var destination = destinationArray[destinationIndex + i]; - destination.x = (position.x * matrix.m11) + (position.y * matrix.m21) + matrix.m31; - destination.y = (position.x * matrix.m12) + (position.y * matrix.m22) + matrix.m32; - destinationArray[destinationIndex + i] = destination; - } - }; - Vector2Ext.transformR = function (position, matrix, result) { - var x = (position.x * matrix.m11) + (position.y * matrix.m21) + matrix.m31; - var y = (position.x * matrix.m12) + (position.y * matrix.m22) + matrix.m32; - result.x = x; - result.y = y; - }; - Vector2Ext.transform = function (sourceArray, matrix, destinationArray) { - this.transformA(sourceArray, 0, matrix, destinationArray, 0, sourceArray.length); - }; - Vector2Ext.round = function (vec) { - return new es.Vector2(Math.round(vec.x), Math.round(vec.y)); - }; - return Vector2Ext; - }()); - es.Vector2Ext = Vector2Ext; -})(es || (es = {})); -var WebGLUtils = (function () { - function WebGLUtils() { - } - WebGLUtils.getContext = function () { - var canvas = document.getElementsByTagName('canvas')[0]; - return canvas.getContext('2d'); - }; - return WebGLUtils; -}()); -var es; -(function (es) { - var Layout = (function () { - function Layout() { - this.clientArea = new es.Rectangle(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this.safeArea = this.clientArea; - } - Layout.prototype.place = function (size, horizontalMargin, verticalMargine, alignment) { - var rc = new es.Rectangle(0, 0, size.x, size.y); - if ((alignment & Alignment.left) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width * horizontalMargin); - } - else if ((alignment & Alignment.right) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width * (1 - horizontalMargin)) - rc.width; - } - else if ((alignment & Alignment.horizontalCenter) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width - rc.width) / 2 + (horizontalMargin * this.clientArea.width); - } - else { - } - if ((alignment & Alignment.top) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height * verticalMargine); - } - else if ((alignment & Alignment.bottom) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height * (1 - verticalMargine)) - rc.height; - } - else if ((alignment & Alignment.verticalCenter) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height - rc.height) / 2 + (verticalMargine * this.clientArea.height); - } - else { - } - if (rc.left < this.safeArea.left) - rc.x = this.safeArea.left; - if (rc.right > this.safeArea.right) - rc.x = this.safeArea.right - rc.width; - if (rc.top < this.safeArea.top) - rc.y = this.safeArea.top; - if (rc.bottom > this.safeArea.bottom) - rc.y = this.safeArea.bottom - rc.height; - return rc; - }; - return Layout; - }()); - es.Layout = Layout; - var Alignment; - (function (Alignment) { - Alignment[Alignment["none"] = 0] = "none"; - Alignment[Alignment["left"] = 1] = "left"; - Alignment[Alignment["right"] = 2] = "right"; - Alignment[Alignment["horizontalCenter"] = 4] = "horizontalCenter"; - Alignment[Alignment["top"] = 8] = "top"; - Alignment[Alignment["bottom"] = 16] = "bottom"; - Alignment[Alignment["verticalCenter"] = 32] = "verticalCenter"; - Alignment[Alignment["topLeft"] = 9] = "topLeft"; - Alignment[Alignment["topRight"] = 10] = "topRight"; - Alignment[Alignment["topCenter"] = 12] = "topCenter"; - Alignment[Alignment["bottomLeft"] = 17] = "bottomLeft"; - Alignment[Alignment["bottomRight"] = 18] = "bottomRight"; - Alignment[Alignment["bottomCenter"] = 20] = "bottomCenter"; - Alignment[Alignment["centerLeft"] = 33] = "centerLeft"; - Alignment[Alignment["centerRight"] = 34] = "centerRight"; - Alignment[Alignment["center"] = 36] = "center"; - })(Alignment = es.Alignment || (es.Alignment = {})); -})(es || (es = {})); -var stopwatch; -(function (stopwatch) { - var Stopwatch = (function () { - function Stopwatch(getSystemTime) { - if (getSystemTime === void 0) { getSystemTime = _defaultSystemTimeGetter; } - this.getSystemTime = getSystemTime; - this._stopDuration = 0; - this._completeSlices = []; - } - Stopwatch.prototype.getState = function () { - if (this._startSystemTime === undefined) { - return State.IDLE; - } - else if (this._stopSystemTime === undefined) { - return State.RUNNING; - } - else { - return State.STOPPED; - } - }; - Stopwatch.prototype.isIdle = function () { - return this.getState() === State.IDLE; - }; - Stopwatch.prototype.isRunning = function () { - return this.getState() === State.RUNNING; - }; - Stopwatch.prototype.isStopped = function () { - return this.getState() === State.STOPPED; - }; - Stopwatch.prototype.slice = function () { - return this.recordPendingSlice(); - }; - Stopwatch.prototype.getCompletedSlices = function () { - return Array.from(this._completeSlices); - }; - Stopwatch.prototype.getCompletedAndPendingSlices = function () { - return this._completeSlices.concat([this.getPendingSlice()]); - }; - Stopwatch.prototype.getPendingSlice = function () { - return this.calculatePendingSlice(); - }; - Stopwatch.prototype.getTime = function () { - return this.caculateStopwatchTime(); - }; - Stopwatch.prototype.reset = function () { - this._startSystemTime = this._pendingSliceStartStopwatchTime = this._stopSystemTime = undefined; - this._stopDuration = 0; - this._completeSlices = []; - }; - Stopwatch.prototype.start = function (forceReset) { - if (forceReset === void 0) { forceReset = false; } - if (forceReset) { - this.reset(); - } - if (this._stopSystemTime !== undefined) { - var systemNow = this.getSystemTime(); - var stopDuration = systemNow - this._stopSystemTime; - this._stopDuration += stopDuration; - this._stopSystemTime = undefined; - } - else if (this._startSystemTime === undefined) { - var systemNow = this.getSystemTime(); - this._startSystemTime = systemNow; - this._pendingSliceStartStopwatchTime = 0; - } - }; - Stopwatch.prototype.stop = function (recordPendingSlice) { - if (recordPendingSlice === void 0) { recordPendingSlice = false; } - if (this._startSystemTime === undefined) { - return 0; - } - var systemTimeOfStopwatchTime = this.getSystemTimeOfCurrentStopwatchTime(); - if (recordPendingSlice) { - this.recordPendingSlice(this.caculateStopwatchTime(systemTimeOfStopwatchTime)); - } - this._stopSystemTime = systemTimeOfStopwatchTime; - return this.getTime(); - }; - Stopwatch.prototype.calculatePendingSlice = function (endStopwatchTime) { - if (this._pendingSliceStartStopwatchTime === undefined) { - return Object.freeze({ startTime: 0, endTime: 0, duration: 0 }); - } - if (endStopwatchTime === undefined) { - endStopwatchTime = this.getTime(); - } - return Object.freeze({ - startTime: this._pendingSliceStartStopwatchTime, - endTime: endStopwatchTime, - duration: endStopwatchTime - this._pendingSliceStartStopwatchTime - }); - }; - Stopwatch.prototype.caculateStopwatchTime = function (endSystemTime) { - if (this._startSystemTime === undefined) - return 0; - if (endSystemTime === undefined) - endSystemTime = this.getSystemTimeOfCurrentStopwatchTime(); - return endSystemTime - this._startSystemTime - this._stopDuration; - }; - Stopwatch.prototype.getSystemTimeOfCurrentStopwatchTime = function () { - return this._stopSystemTime === undefined ? this.getSystemTime() : this._stopSystemTime; - }; - Stopwatch.prototype.recordPendingSlice = function (endStopwatchTime) { - if (this._pendingSliceStartStopwatchTime !== undefined) { - if (endStopwatchTime === undefined) { - endStopwatchTime = this.getTime(); - } - var slice = this.calculatePendingSlice(endStopwatchTime); - this._pendingSliceStartStopwatchTime = slice.endTime; - this._completeSlices.push(slice); - return slice; - } - else { - return this.calculatePendingSlice(); - } - }; - return Stopwatch; - }()); - stopwatch.Stopwatch = Stopwatch; - var State; - (function (State) { - State["IDLE"] = "IDLE"; - State["RUNNING"] = "RUNNING"; - State["STOPPED"] = "STOPPED"; - })(State || (State = {})); - function setDefaultSystemTimeGetter(systemTimeGetter) { - if (systemTimeGetter === void 0) { systemTimeGetter = Date.now; } - _defaultSystemTimeGetter = systemTimeGetter; - } - stopwatch.setDefaultSystemTimeGetter = setDefaultSystemTimeGetter; - var _defaultSystemTimeGetter = Date.now; -})(stopwatch || (stopwatch = {})); -var es; -(function (es) { - var TimeRuler = (function () { - function TimeRuler() { - this.showLog = false; - this.markers = []; - this.stopwacth = new stopwatch.Stopwatch(); - this._markerNameToIdMap = new Map(); - this._rectShape1 = new egret.Shape(); - this._rectShape2 = new egret.Shape(); - this._rectShape3 = new egret.Shape(); - this._rectShape4 = new egret.Shape(); - this._rectShape5 = new egret.Shape(); - this._rectShape6 = new egret.Shape(); - this.logs = new Array(2); - for (var i = 0; i < this.logs.length; ++i) - this.logs[i] = new FrameLog(); - this.sampleFrames = this.targetSampleFrames = 1; - this.width = Math.floor(es.Core.graphicsDevice.viewport.width * 0.8); - es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this); - this.onGraphicsDeviceReset(); - es.Core.Instance.stage.addChild(this._rectShape1); - es.Core.Instance.stage.addChild(this._rectShape2); - es.Core.Instance.stage.addChild(this._rectShape3); - es.Core.Instance.stage.addChild(this._rectShape4); - es.Core.Instance.stage.addChild(this._rectShape5); - es.Core.Instance.stage.addChild(this._rectShape6); - } - Object.defineProperty(TimeRuler, "Instance", { - get: function () { - if (!this._instance) - this._instance = new TimeRuler(); - return this._instance; - }, - enumerable: true, - configurable: true - }); - TimeRuler.prototype.startFrame = function () { - if (isNaN(this._updateCount)) - this._updateCount = 0; - var count = this._updateCount++; - if (this.enabled && (1 < count && count < TimeRuler.maxSampleFrames)) - return; - this.prevLog = this.logs[this.frameCount++ & 0x1]; - this.curLog = this.logs[this.frameCount & 0x1]; - var endFrameTime = this.stopwacth.getTime(); - for (var barIdx = 0; barIdx < this.prevLog.bars.length; ++barIdx) { - var prevBar = this.prevLog.bars[barIdx]; - var nextBar = this.curLog.bars[barIdx]; - for (var nest = 0; nest < prevBar.nestCount; ++nest) { - var markerIdx = prevBar.markerNests[nest]; - prevBar.markers[markerIdx].endTime = endFrameTime; - nextBar.markerNests[nest] = nest; - nextBar.markers[nest].markerId = prevBar.markers[markerIdx].markerId; - nextBar.markers[nest].beginTime = 0; - nextBar.markers[nest].endTime = -1; - nextBar.markers[nest].color = prevBar.markers[markerIdx].color; - } - for (var markerIdx = 0; markerIdx < prevBar.markCount; ++markerIdx) { - var duration = prevBar.markers[markerIdx].endTime - prevBar.markers[markerIdx].beginTime; - var markerId = prevBar.markers[markerIdx].markerId; - var m = this.markers[markerId]; - m.logs[barIdx].color = prevBar.markers[markerIdx].color; - if (!m.logs[barIdx].initialized) { - m.logs[barIdx].min = duration; - m.logs[barIdx].max = duration; - m.logs[barIdx].avg = duration; - m.logs[barIdx].initialized = true; - } - else { - m.logs[barIdx].min = Math.min(m.logs[barIdx].min, duration); - m.logs[barIdx].max = Math.min(m.logs[barIdx].max, duration); - m.logs[barIdx].avg += duration; - m.logs[barIdx].avg *= 0.5; - if (m.logs[barIdx].samples++ >= TimeRuler.logSnapDuration) { - m.logs[barIdx].snapMin = m.logs[barIdx].min; - m.logs[barIdx].snapMax = m.logs[barIdx].max; - m.logs[barIdx].snapAvg = m.logs[barIdx].avg; - m.logs[barIdx].samples = 0; - } - } - } - nextBar.markCount = prevBar.nestCount; - nextBar.nestCount = prevBar.nestCount; - } - this.stopwacth.reset(); - this.stopwacth.start(); - }; - TimeRuler.prototype.beginMark = function (markerName, color, barIndex) { - if (barIndex === void 0) { barIndex = 0; } - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) - throw new Error("barIndex argument out of range"); - var bar = this.curLog.bars[barIndex]; - if (bar.markCount >= TimeRuler.maxSamples) { - throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数"); - } - if (bar.nestCount >= TimeRuler.maxNestCall) { - throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数"); - } - var markerId = this._markerNameToIdMap.get(markerName); - if (isNaN(markerId)) { - markerId = this.markers.length; - this._markerNameToIdMap.set(markerName, markerId); - this.markers.push(new MarkerInfo(markerName)); - } - bar.markerNests[bar.nestCount++] = bar.markCount; - bar.markers[bar.markCount].markerId = markerId; - bar.markers[bar.markCount].color = color; - bar.markers[bar.markCount].beginTime = this.stopwacth.getTime(); - bar.markers[bar.markCount].endTime = -1; - bar.markCount++; - }; - TimeRuler.prototype.endMark = function (markerName, barIndex) { - if (barIndex === void 0) { barIndex = 0; } - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) - throw new Error("barIndex参数超出范围"); - var bar = this.curLog.bars[barIndex]; - if (bar.nestCount <= 0) { - throw new Error("先调用beginMark方法,再调用endMark方法"); - } - var markerId = this._markerNameToIdMap.get(markerName); - if (isNaN(markerId)) { - throw new Error("\u6807\u8BB0 " + markerName + " \u672A\u6CE8\u518C\u3002\u8BF7\u786E\u8BA4\u60A8\u6307\u5B9A\u7684\u540D\u79F0\u4E0E beginMark \u65B9\u6CD5\u4F7F\u7528\u7684\u540D\u79F0\u76F8\u540C"); - } - var markerIdx = bar.markerNests[--bar.nestCount]; - if (bar.markers[markerIdx].markerId != markerId) { - throw new Error("beginMark/endMark方法的调用顺序不正确,beginMark(A),beginMark(B),endMark(B),endMark(A),但你不能像beginMark(A),beginMark(B),endMark(A),endMark(B)这样调用。"); - } - bar.markers[markerIdx].endTime = this.stopwacth.getTime(); - }; - TimeRuler.prototype.getAverageTime = function (barIndex, markerName) { - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) { - throw new Error("barIndex参数超出范围"); - } - var result = 0; - var markerId = this._markerNameToIdMap.get(markerName); - if (markerId) { - result = this.markers[markerId].logs[barIndex].avg; - } - return result; - }; - TimeRuler.prototype.resetLog = function () { - this.markers.forEach(function (markerInfo) { - for (var i = 0; i < markerInfo.logs.length; ++i) { - markerInfo.logs[i].initialized = false; - markerInfo.logs[i].snapMin = 0; - markerInfo.logs[i].snapMax = 0; - markerInfo.logs[i].snapAvg = 0; - markerInfo.logs[i].min = 0; - markerInfo.logs[i].max = 0; - markerInfo.logs[i].avg = 0; - markerInfo.logs[i].samples = 0; - } - }); - }; - TimeRuler.prototype.render = function (position, width) { - if (position === void 0) { position = this._position; } - if (width === void 0) { width = this.width; } - if (!this.showLog) - return; - var height = 0; - var maxTime = 0; - this.prevLog.bars.forEach(function (bar) { - if (bar.markCount > 0) { - height += TimeRuler.barHeight + TimeRuler.barPadding * 2; - maxTime = Math.max(maxTime, bar.markers[bar.markCount - 1].endTime); - } - }); - var frameSpan = 1 / 60 * 1000; - var sampleSpan = this.sampleFrames * frameSpan; - if (maxTime > sampleSpan) { - this._frameAdjust = Math.max(0, this._frameAdjust) + 1; - } - else { - this._frameAdjust = Math.min(0, this._frameAdjust) - 1; - } - if (Math.max(this._frameAdjust) > TimeRuler.autoAdjustDelay) { - this.sampleFrames = Math.min(TimeRuler.maxSampleFrames, this.sampleFrames); - this.sampleFrames = Math.max(this.targetSampleFrames, Math.floor(maxTime / frameSpan) + 1); - this._frameAdjust = 0; - } - var msToPs = width / sampleSpan; - var startY = position.y - (height - TimeRuler.barHeight); - var y = startY; - var rc = new es.Rectangle(position.x, y, width, height); - this._rectShape1.graphics.clear(); - this._rectShape1.graphics.beginFill(0x000000, 128 / 255); - this._rectShape1.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape1.graphics.endFill(); - rc.height = TimeRuler.barHeight; - this._rectShape2.graphics.clear(); - for (var _i = 0, _a = this.prevLog.bars; _i < _a.length; _i++) { - var bar = _a[_i]; - rc.y = y + TimeRuler.barPadding; - if (bar.markCount > 0) { - for (var j = 0; j < bar.markCount; ++j) { - var bt = bar.markers[j].beginTime; - var et = bar.markers[j].endTime; - var sx = Math.floor(position.x + bt * msToPs); - var ex = Math.floor(position.x + et * msToPs); - rc.x = sx; - rc.width = Math.max(ex - sx, 1); - this._rectShape2.graphics.beginFill(bar.markers[j].color); - this._rectShape2.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape2.graphics.endFill(); - } - } - y += TimeRuler.barHeight + TimeRuler.barPadding; - } - rc = new es.Rectangle(position.x, startY, 1, height); - this._rectShape3.graphics.clear(); - for (var t = 1; t < sampleSpan; t += 1) { - rc.x = Math.floor(position.x + t * msToPs); - this._rectShape3.graphics.beginFill(0x808080); - this._rectShape3.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape3.graphics.endFill(); - } - this._rectShape4.graphics.clear(); - for (var i = 0; i <= this.sampleFrames; ++i) { - rc.x = Math.floor(position.x + frameSpan * i * msToPs); - this._rectShape4.graphics.beginFill(0xFFFFFF); - this._rectShape4.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape4.graphics.endFill(); - } - }; - TimeRuler.prototype.onGraphicsDeviceReset = function () { - var layout = new es.Layout(); - this._position = layout.place(new es.Vector2(this.width, TimeRuler.barHeight), 0, 0.01, es.Alignment.bottomCenter).location; - }; - TimeRuler.maxBars = 8; - TimeRuler.maxSamples = 256; - TimeRuler.maxNestCall = 32; - TimeRuler.barHeight = 8; - TimeRuler.maxSampleFrames = 4; - TimeRuler.logSnapDuration = 120; - TimeRuler.barPadding = 2; - TimeRuler.autoAdjustDelay = 30; - return TimeRuler; - }()); - es.TimeRuler = TimeRuler; - var FrameLog = (function () { - function FrameLog() { - this.bars = new Array(TimeRuler.maxBars); - this.bars.fill(new MarkerCollection(), 0, TimeRuler.maxBars); - } - return FrameLog; - }()); - es.FrameLog = FrameLog; - var MarkerCollection = (function () { - function MarkerCollection() { - this.markers = new Array(TimeRuler.maxSamples); - this.markCount = 0; - this.markerNests = new Array(TimeRuler.maxNestCall); - this.nestCount = 0; - this.markers.fill(new Marker(), 0, TimeRuler.maxSamples); - this.markerNests.fill(0, 0, TimeRuler.maxNestCall); - } - return MarkerCollection; - }()); - es.MarkerCollection = MarkerCollection; - var Marker = (function () { - function Marker() { - this.markerId = 0; - this.beginTime = 0; - this.endTime = 0; - this.color = 0x000000; - } - return Marker; - }()); - es.Marker = Marker; - var MarkerInfo = (function () { - function MarkerInfo(name) { - this.logs = new Array(TimeRuler.maxBars); - this.name = name; - this.logs.fill(new MarkerLog(), 0, TimeRuler.maxBars); - } - return MarkerInfo; - }()); - es.MarkerInfo = MarkerInfo; - var MarkerLog = (function () { - function MarkerLog() { - this.snapMin = 0; - this.snapMax = 0; - this.snapAvg = 0; - this.min = 0; - this.max = 0; - this.avg = 0; - this.samples = 0; - this.color = 0x000000; - this.initialized = false; - } - return MarkerLog; - }()); - es.MarkerLog = MarkerLog; -})(es || (es = {})); -var es; -(function (es) { - var Coroutine = (function () { - function Coroutine() { - } - Coroutine.waitForSeconds = function (seconds) { - return WaitForSeconds.waiter.wait(seconds); - }; - return Coroutine; - }()); - es.Coroutine = Coroutine; - var WaitForSeconds = (function () { - function WaitForSeconds() { - } - WaitForSeconds.prototype.wait = function (seconds) { - WaitForSeconds.waiter.waitTime = seconds; - return WaitForSeconds.waiter; - }; - WaitForSeconds.waiter = new WaitForSeconds(); - return WaitForSeconds; - }()); - es.WaitForSeconds = WaitForSeconds; -})(es || (es = {})); -var es; -(function (es) { - var CoroutineImpl = (function () { - function CoroutineImpl() { - this.useUnscaledDeltaTime = false; - } - CoroutineImpl.prototype.stop = function () { - this.isDone = true; - }; - CoroutineImpl.prototype.setUseUnscaledDeltaTime = function (useUnscaledDeltaTime) { - this.useUnscaledDeltaTime = useUnscaledDeltaTime; - return this; - }; - CoroutineImpl.prototype.prepareForuse = function () { - this.isDone = false; - }; - CoroutineImpl.prototype.reset = function () { - this.isDone = true; - this.waitTimer = 0; - this.waitForCoroutine = null; - this.enumerator = null; - this.useUnscaledDeltaTime = false; - }; - return CoroutineImpl; - }()); - es.CoroutineImpl = CoroutineImpl; - var CoroutineManager = (function (_super) { - __extends(CoroutineManager, _super); - function CoroutineManager() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._unblockedCoroutines = []; - _this._shouldRunNextFrame = []; - return _this; - } - CoroutineManager.prototype.startCoroutine = function (enumerator) { - var coroutine = es.Pool.obtain(CoroutineImpl); - coroutine.prepareForuse(); - coroutine.enumerator = enumerator; - var shouldContinueCoroutine = this.tickCoroutine(coroutine); - if (!shouldContinueCoroutine) - return null; - if (this._isInUpdate) - this._shouldRunNextFrame.push(coroutine); - else - this._unblockedCoroutines.push(coroutine); - return coroutine; - }; - CoroutineManager.prototype.update = function () { - this._isInUpdate = true; - for (var i = 0; i < this._unblockedCoroutines.length; i++) { - var coroutine = this._unblockedCoroutines[i]; - if (coroutine.isDone) { - es.Pool.free(coroutine); - continue; - } - if (coroutine.waitForCoroutine != null) { - if (coroutine.waitForCoroutine.isDone) { - coroutine.waitForCoroutine = null; - } - else { - this._shouldRunNextFrame.push(coroutine); - continue; - } - } - if (coroutine.waitTimer > 0) { - coroutine.waitTimer -= coroutine.useUnscaledDeltaTime ? es.Time.unscaledDeltaTime : es.Time.deltaTime; - this._shouldRunNextFrame.push(coroutine); - continue; - } - if (this.tickCoroutine(coroutine)) - this._shouldRunNextFrame.push(coroutine); - } - this._unblockedCoroutines.length = 0; - this._unblockedCoroutines.concat(this._shouldRunNextFrame); - this._shouldRunNextFrame.length = 0; - this._isInUpdate = false; - }; - CoroutineManager.prototype.tickCoroutine = function (coroutine) { - var current = coroutine.enumerator.next(); - if (!current.value || current.done) { - es.Pool.free(coroutine); - return false; - } - if (!current.value) { - return true; - } - if (current.value instanceof es.WaitForSeconds) { - coroutine.waitTimer = current.value.waitTime; - return true; - } - if (current.value instanceof Number) { - console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"); - coroutine.waitTimer = Number(current); - return true; - } - if (current.value instanceof CoroutineImpl) { - coroutine.waitForCoroutine = current.value; - return true; - } - else { - return true; - } - }; - return CoroutineManager; - }(es.GlobalManager)); - es.CoroutineManager = CoroutineManager; -})(es || (es = {})); -var es; -(function (es) { - var TouchState = (function () { - function TouchState() { - this.x = 0; - this.y = 0; - this.touchPoint = -1; - this.touchDown = false; - } - Object.defineProperty(TouchState.prototype, "position", { - get: function () { - return new es.Vector2(this.x, this.y); - }, - enumerable: true, - configurable: true - }); - TouchState.prototype.reset = function () { - this.x = 0; - this.y = 0; - this.touchDown = false; - this.touchPoint = -1; - }; - return TouchState; - }()); - es.TouchState = TouchState; - var Input = (function () { - function Input() { - } - Object.defineProperty(Input, "gameTouchs", { - get: function () { - return this._gameTouchs; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "resolutionScale", { - get: function () { - return this._resolutionScale; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "totalTouchCount", { - get: function () { - return this._totalTouchCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "touchPosition", { - get: function () { - if (!this._gameTouchs[0]) - return es.Vector2.zero; - return this._gameTouchs[0].position; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "maxSupportedTouch", { - get: function () { - return es.Core._instance.stage.maxTouches; - }, - set: function (value) { - es.Core._instance.stage.maxTouches = value; - this.initTouchCache(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "touchPositionDelta", { - get: function () { - var delta = es.Vector2.subtract(this.touchPosition, this._previousTouchState.position); - if (delta.length() > 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - return delta; - }, - enumerable: true, - configurable: true - }); - Input.initialize = function () { - if (this._init) - return; - this._init = true; - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this); - this.initTouchCache(); - }; - Input.update = function () { - KeyboardUtils.update(); - for (var i = 0; i < this._virtualInputs.length; i++) - this._virtualInputs[i].update(); - }; - Input.scaledPosition = function (position) { - var scaledPos = new es.Vector2(position.x - this._resolutionOffset.x, position.y - this._resolutionOffset.y); - return es.Vector2.multiply(scaledPos, this.resolutionScale); - }; - Input.isKeyPressed = function (key) { - return KeyboardUtils.currentKeys.contains(key) && !KeyboardUtils.previousKeys.contains(key); - }; - Input.isKeyPressedBoth = function (keyA, keyB) { - return this.isKeyPressed(keyA) || this.isKeyPressed(keyB); - }; - Input.isKeyDown = function (key) { - return KeyboardUtils.currentKeys.contains(key); - }; - Input.isKeyDownBoth = function (keyA, keyB) { - return this.isKeyDown(keyA) || this.isKeyDown(keyB); - }; - Input.isKeyReleased = function (key) { - return !KeyboardUtils.currentKeys.contains(key) && KeyboardUtils.previousKeys.contains(key); - }; - Input.isKeyReleasedBoth = function (keyA, keyB) { - return this.isKeyReleased(keyA) || this.isKeyReleased(keyB); - }; - Input.initTouchCache = function () { - this._totalTouchCount = 0; - this._touchIndex = 0; - this._gameTouchs.length = 0; - for (var i = 0; i < this.maxSupportedTouch; i++) { - this._gameTouchs.push(new TouchState()); - } - }; - Input.touchBegin = function (evt) { - if (this._touchIndex < this.maxSupportedTouch) { - this._gameTouchs[this._touchIndex].touchPoint = evt.touchPointID; - this._gameTouchs[this._touchIndex].touchDown = evt.touchDown; - this._gameTouchs[this._touchIndex].x = evt.stageX; - this._gameTouchs[this._touchIndex].y = evt.stageY; - if (this._touchIndex == 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - this._touchIndex++; - this._totalTouchCount++; - } - }; - Input.touchMove = function (evt) { - if (evt.touchPointID == this._gameTouchs[0].touchPoint) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); - if (touchIndex != -1) { - var touchData = this._gameTouchs[touchIndex]; - touchData.x = evt.stageX; - touchData.y = evt.stageY; - } - }; - Input.touchEnd = function (evt) { - var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); - if (touchIndex != -1) { - var touchData = this._gameTouchs[touchIndex]; - touchData.reset(); - if (touchIndex == 0) - this._previousTouchState.reset(); - this._totalTouchCount--; - if (this.totalTouchCount == 0) { - this._touchIndex = 0; - } - } - }; - Input.setpreviousTouchState = function (touchState) { - this._previousTouchState = new TouchState(); - this._previousTouchState.x = touchState.position.x; - this._previousTouchState.y = touchState.position.y; - this._previousTouchState.touchPoint = touchState.touchPoint; - this._previousTouchState.touchDown = touchState.touchDown; - }; - Input._init = false; - Input._previousTouchState = new TouchState(); - Input._resolutionOffset = new es.Vector2(); - Input._touchIndex = 0; - Input._gameTouchs = []; - Input._resolutionScale = es.Vector2.one; - Input._totalTouchCount = 0; - Input._virtualInputs = []; - return Input; - }()); - es.Input = Input; -})(es || (es = {})); -var Keys = es.Keys; -var KeyboardUtils = (function () { - function KeyboardUtils() { - } - KeyboardUtils.init = function () { - document.addEventListener("keydown", KeyboardUtils.onKeyDownHandler); - document.addEventListener("keyup", KeyboardUtils.onKeyUpHandler); - }; - KeyboardUtils.update = function () { - KeyboardUtils.previousKeys.length = 0; - for (var _i = 0, _a = KeyboardUtils.currentKeys; _i < _a.length; _i++) { - var key = _a[_i]; - KeyboardUtils.previousKeys.push(key); - KeyboardUtils.currentKeys.remove(key); - } - KeyboardUtils.currentKeys.length = 0; - for (var _b = 0, _c = KeyboardUtils.keyStatusKeys; _b < _c.length; _b++) { - var key = _c[_b]; - KeyboardUtils.currentKeys.push(key); - } - }; - KeyboardUtils.destroy = function () { - KeyboardUtils.currentKeys.length = 0; - document.removeEventListener("keyup", KeyboardUtils.onKeyUpHandler); - document.removeEventListener("keypress", KeyboardUtils.onKeyDownHandler); - }; - KeyboardUtils.onKeyDownHandler = function (event) { - if (!KeyboardUtils.keyStatusKeys.contains(event.keyCode)) - KeyboardUtils.keyStatusKeys.push(event.keyCode); - }; - KeyboardUtils.onKeyUpHandler = function (event) { - if (KeyboardUtils.keyStatusKeys.contains(event.keyCode)) - KeyboardUtils.keyStatusKeys.remove(event.keyCode); - }; - KeyboardUtils.currentKeys = []; - KeyboardUtils.previousKeys = []; - KeyboardUtils.keyStatusKeys = []; - return KeyboardUtils; -}()); -var es; -(function (es) { - var Keys; - (function (Keys) { - Keys[Keys["none"] = 0] = "none"; - Keys[Keys["back"] = 8] = "back"; - Keys[Keys["tab"] = 9] = "tab"; - Keys[Keys["enter"] = 13] = "enter"; - Keys[Keys["capsLock"] = 20] = "capsLock"; - Keys[Keys["escape"] = 27] = "escape"; - Keys[Keys["space"] = 32] = "space"; - Keys[Keys["pageUp"] = 33] = "pageUp"; - Keys[Keys["pageDown"] = 34] = "pageDown"; - Keys[Keys["end"] = 35] = "end"; - Keys[Keys["home"] = 36] = "home"; - Keys[Keys["left"] = 37] = "left"; - Keys[Keys["up"] = 38] = "up"; - Keys[Keys["right"] = 39] = "right"; - Keys[Keys["down"] = 40] = "down"; - Keys[Keys["select"] = 41] = "select"; - Keys[Keys["print"] = 42] = "print"; - Keys[Keys["execute"] = 43] = "execute"; - Keys[Keys["printScreen"] = 44] = "printScreen"; - Keys[Keys["insert"] = 45] = "insert"; - Keys[Keys["delete"] = 46] = "delete"; - Keys[Keys["help"] = 47] = "help"; - Keys[Keys["d0"] = 48] = "d0"; - Keys[Keys["d1"] = 49] = "d1"; - Keys[Keys["d2"] = 50] = "d2"; - Keys[Keys["d3"] = 51] = "d3"; - Keys[Keys["d4"] = 52] = "d4"; - Keys[Keys["d5"] = 53] = "d5"; - Keys[Keys["d6"] = 54] = "d6"; - Keys[Keys["d7"] = 55] = "d7"; - Keys[Keys["d8"] = 56] = "d8"; - Keys[Keys["d9"] = 57] = "d9"; - Keys[Keys["a"] = 65] = "a"; - Keys[Keys["b"] = 66] = "b"; - Keys[Keys["c"] = 67] = "c"; - Keys[Keys["d"] = 68] = "d"; - Keys[Keys["e"] = 69] = "e"; - Keys[Keys["f"] = 70] = "f"; - Keys[Keys["g"] = 71] = "g"; - Keys[Keys["h"] = 72] = "h"; - Keys[Keys["i"] = 73] = "i"; - Keys[Keys["j"] = 74] = "j"; - Keys[Keys["k"] = 75] = "k"; - Keys[Keys["l"] = 76] = "l"; - Keys[Keys["m"] = 77] = "m"; - Keys[Keys["n"] = 78] = "n"; - Keys[Keys["o"] = 79] = "o"; - Keys[Keys["p"] = 80] = "p"; - Keys[Keys["q"] = 81] = "q"; - Keys[Keys["r"] = 82] = "r"; - Keys[Keys["s"] = 83] = "s"; - Keys[Keys["t"] = 84] = "t"; - Keys[Keys["u"] = 85] = "u"; - Keys[Keys["v"] = 86] = "v"; - Keys[Keys["w"] = 87] = "w"; - Keys[Keys["x"] = 88] = "x"; - Keys[Keys["y"] = 89] = "y"; - Keys[Keys["z"] = 90] = "z"; - Keys[Keys["leftWindows"] = 91] = "leftWindows"; - Keys[Keys["rightWindows"] = 92] = "rightWindows"; - Keys[Keys["apps"] = 93] = "apps"; - Keys[Keys["sleep"] = 95] = "sleep"; - Keys[Keys["numPad0"] = 96] = "numPad0"; - Keys[Keys["numPad1"] = 97] = "numPad1"; - Keys[Keys["numPad2"] = 98] = "numPad2"; - Keys[Keys["numPad3"] = 99] = "numPad3"; - Keys[Keys["numPad4"] = 100] = "numPad4"; - Keys[Keys["numPad5"] = 101] = "numPad5"; - Keys[Keys["numPad6"] = 102] = "numPad6"; - Keys[Keys["numPad7"] = 103] = "numPad7"; - Keys[Keys["numPad8"] = 104] = "numPad8"; - Keys[Keys["numPad9"] = 105] = "numPad9"; - Keys[Keys["multiply"] = 106] = "multiply"; - Keys[Keys["add"] = 107] = "add"; - Keys[Keys["seperator"] = 108] = "seperator"; - Keys[Keys["subtract"] = 109] = "subtract"; - Keys[Keys["decimal"] = 110] = "decimal"; - Keys[Keys["divide"] = 111] = "divide"; - Keys[Keys["f1"] = 112] = "f1"; - Keys[Keys["f2"] = 113] = "f2"; - Keys[Keys["f3"] = 114] = "f3"; - Keys[Keys["f4"] = 115] = "f4"; - Keys[Keys["f5"] = 116] = "f5"; - Keys[Keys["f6"] = 117] = "f6"; - Keys[Keys["f7"] = 118] = "f7"; - Keys[Keys["f8"] = 119] = "f8"; - Keys[Keys["f9"] = 120] = "f9"; - Keys[Keys["f10"] = 121] = "f10"; - Keys[Keys["f11"] = 122] = "f11"; - Keys[Keys["f12"] = 123] = "f12"; - Keys[Keys["f13"] = 124] = "f13"; - Keys[Keys["f14"] = 125] = "f14"; - Keys[Keys["f15"] = 126] = "f15"; - Keys[Keys["f16"] = 127] = "f16"; - Keys[Keys["f17"] = 128] = "f17"; - Keys[Keys["f18"] = 129] = "f18"; - Keys[Keys["f19"] = 130] = "f19"; - Keys[Keys["f20"] = 131] = "f20"; - Keys[Keys["f21"] = 132] = "f21"; - Keys[Keys["f22"] = 133] = "f22"; - Keys[Keys["f23"] = 134] = "f23"; - Keys[Keys["f24"] = 135] = "f24"; - Keys[Keys["numLock"] = 144] = "numLock"; - Keys[Keys["scroll"] = 145] = "scroll"; - Keys[Keys["leftShift"] = 160] = "leftShift"; - Keys[Keys["rightShift"] = 161] = "rightShift"; - Keys[Keys["leftControl"] = 162] = "leftControl"; - Keys[Keys["rightControl"] = 163] = "rightControl"; - Keys[Keys["leftAlt"] = 164] = "leftAlt"; - Keys[Keys["rightAlt"] = 165] = "rightAlt"; - Keys[Keys["browserBack"] = 166] = "browserBack"; - Keys[Keys["browserForward"] = 167] = "browserForward"; - })(Keys = es.Keys || (es.Keys = {})); -})(es || (es = {})); -var es; -(function (es) { - var OverlapBehavior; - (function (OverlapBehavior) { - OverlapBehavior[OverlapBehavior["cancelOut"] = 0] = "cancelOut"; - OverlapBehavior[OverlapBehavior["takeOlder"] = 1] = "takeOlder"; - OverlapBehavior[OverlapBehavior["takeNewer"] = 2] = "takeNewer"; - })(OverlapBehavior = es.OverlapBehavior || (es.OverlapBehavior = {})); - var VirtualInput = (function () { - function VirtualInput() { - es.Input._virtualInputs.push(this); - } - VirtualInput.prototype.deregister = function () { - es.Input._virtualInputs.remove(this); - }; - return VirtualInput; - }()); - es.VirtualInput = VirtualInput; - var VirtualInputNode = (function () { - function VirtualInputNode() { - } - VirtualInputNode.prototype.update = function () { }; - return VirtualInputNode; - }()); - es.VirtualInputNode = VirtualInputNode; -})(es || (es = {})); -var es; -(function (es) { - var VirtualIntegerAxis = (function (_super) { - __extends(VirtualIntegerAxis, _super); - function VirtualIntegerAxis() { - var nodes = []; - for (var _i = 0; _i < arguments.length; _i++) { - nodes[_i] = arguments[_i]; - } - var _this = _super.call(this) || this; - _this.nodes = []; - _this.nodes.concat(nodes); - return _this; - } - Object.defineProperty(VirtualIntegerAxis.prototype, "value", { - get: function () { - for (var i = 0; i < this.nodes.length; i++) { - var val = this.nodes[i].value; - if (val != 0) - return Math.sign(val); - } - return 0; - }, - enumerable: true, - configurable: true - }); - VirtualIntegerAxis.prototype.update = function () { - for (var i = 0; i < this.nodes.length; i++) - this.nodes[i].update(); - }; - VirtualIntegerAxis.prototype.addKeyboardKeys = function (overlapBehavior, negative, positive) { - this.nodes.push(new es.KeyboardKeys(overlapBehavior, negative, positive)); - return this; - }; - return VirtualIntegerAxis; - }(es.VirtualInput)); - es.VirtualIntegerAxis = VirtualIntegerAxis; - var VirtualAxisNode = (function (_super) { - __extends(VirtualAxisNode, _super); - function VirtualAxisNode() { - return _super !== null && _super.apply(this, arguments) || this; - } - return VirtualAxisNode; - }(es.VirtualInputNode)); - es.VirtualAxisNode = VirtualAxisNode; -})(es || (es = {})); -var es; -(function (es) { - var VirtualAxis = (function (_super) { - __extends(VirtualAxis, _super); - function VirtualAxis() { - var nodes = []; - for (var _i = 0; _i < arguments.length; _i++) { - nodes[_i] = arguments[_i]; - } - var _this = _super.call(this) || this; - _this.nodes = []; - _this.nodes.concat(nodes); - return _this; - } - Object.defineProperty(VirtualAxis.prototype, "value", { - get: function () { - for (var i = 0; i < this.nodes.length; i++) { - var val = this.nodes[i].value; - if (val != 0) - return val; - } - return 0; - }, - enumerable: true, - configurable: true - }); - VirtualAxis.prototype.update = function () { - for (var i = 0; i < this.nodes.length; i++) - this.nodes[i].update(); - }; - return VirtualAxis; - }(es.VirtualInput)); - es.VirtualAxis = VirtualAxis; - var KeyboardKeys = (function (_super) { - __extends(KeyboardKeys, _super); - function KeyboardKeys(overlapBehavior, negative, positive) { - var _this = _super.call(this) || this; - _this._value = 0; - _this.overlapBehavior = overlapBehavior; - _this.negative = negative; - _this.positive = positive; - return _this; - } - KeyboardKeys.prototype.update = function () { - if (es.Input.isKeyDown(this.positive)) { - if (es.Input.isKeyDown(this.negative)) { - switch (this.overlapBehavior) { - default: - case es.OverlapBehavior.cancelOut: - this._value = 0; - break; - case es.OverlapBehavior.takeNewer: - if (!this._turned) { - this._value *= -1; - this._turned = true; - } - break; - case es.OverlapBehavior.takeOlder: - break; - } - } - else { - this._turned = false; - this._value = 1; - } - } - else if (es.Input.isKeyDown(this.negative)) { - this._turned = false; - this._value = -1; - } - else { - this._turned = false; - this._value = 0; - } - }; - Object.defineProperty(KeyboardKeys.prototype, "value", { - get: function () { - return this._value; - }, - enumerable: true, - configurable: true - }); - return KeyboardKeys; - }(es.VirtualAxisNode)); - es.KeyboardKeys = KeyboardKeys; -})(es || (es = {})); -var es; -(function (es) { - var VirtualButton = (function (_super) { - __extends(VirtualButton, _super); - function VirtualButton(bufferTime) { - if (bufferTime === void 0) { bufferTime = 0; } - var nodes = []; - for (var _i = 1; _i < arguments.length; _i++) { - nodes[_i - 1] = arguments[_i]; - } - var _this = _super.call(this) || this; - _this.nodes = []; - _this.bufferTime = 0; - _this.firstRepeatTime = 0; - _this.mutiRepeatTime = 0; - _this._bufferCounter = 0; - _this._repeatCounter = 0; - _this.nodes = nodes; - _this.bufferTime = bufferTime; - return _this; - } - VirtualButton.prototype.setRepeat = function (firstRepeatTime, mutiRepeatTime) { - if (mutiRepeatTime === void 0) { mutiRepeatTime = firstRepeatTime; } - this.firstRepeatTime = firstRepeatTime; - this.mutiRepeatTime = mutiRepeatTime; - this._willRepeat = this.firstRepeatTime > 0; - if (!this._willRepeat) - this.isRepeating = false; - }; - VirtualButton.prototype.update = function () { - this._bufferCounter -= es.Time.unscaledDeltaTime; - this.isRepeating = false; - var check = false; - for (var i = 0; i < this.nodes.length; i++) { - this.nodes[i].update(); - if (this.nodes[i].isPressed) { - this._bufferCounter = this.bufferTime; - check = true; - } - else if (this.nodes[i].isDown) { - check = true; - } - } - if (!check) { - this._repeatCounter = 0; - this._bufferCounter = 0; - } - else if (this._willRepeat) { - if (this._repeatCounter == 0) { - this._repeatCounter = this.firstRepeatTime; - } - else { - this._repeatCounter -= es.Time.unscaledDeltaTime; - if (this._repeatCounter <= 0) { - this.isRepeating = true; - this._repeatCounter = this.mutiRepeatTime; - } - } - } - }; - Object.defineProperty(VirtualButton.prototype, "isDown", { - get: function () { - for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.isDown) - return true; - } - return false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(VirtualButton.prototype, "isPressed", { - get: function () { - if (this._bufferCounter > 0 || this.isRepeating) - return true; - for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.isPressed) - return true; - } - return false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(VirtualButton.prototype, "isReleased", { - get: function () { - for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.isReleased) - return true; - } - return false; - }, - enumerable: true, - configurable: true - }); - VirtualButton.prototype.consumeBuffer = function () { - this._bufferCounter = 0; - }; - VirtualButton.prototype.addKeyboardKey = function (key) { - this.nodes.push(new KeyboardKey(key)); - return this; - }; - return VirtualButton; - }(es.VirtualInput)); - es.VirtualButton = VirtualButton; - var Node = (function (_super) { - __extends(Node, _super); - function Node() { - return _super !== null && _super.apply(this, arguments) || this; - } - return Node; - }(es.VirtualInputNode)); - es.Node = Node; - var KeyboardKey = (function (_super) { - __extends(KeyboardKey, _super); - function KeyboardKey(key) { - var _this = _super.call(this) || this; - _this.key = key; - return _this; - } - Object.defineProperty(KeyboardKey.prototype, "isDown", { - get: function () { - return es.Input.isKeyDown(this.key); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(KeyboardKey.prototype, "isPressed", { - get: function () { - return es.Input.isKeyPressed(this.key); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(KeyboardKey.prototype, "isReleased", { - get: function () { - return es.Input.isKeyReleased(this.key); - }, - enumerable: true, - configurable: true - }); - return KeyboardKey; - }(Node)); - es.KeyboardKey = KeyboardKey; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var AssetPacker = (function () { - function AssetPacker() { - this.itemsToRaster = []; - this.useCache = false; - this.cacheName = ""; - this._sprites = new Map(); - this.allow4096Textures = false; - } - AssetPacker.prototype.addTextureToPack = function (texture, customID) { - this.itemsToRaster.push(new es.TextureToPack(texture, customID)); - }; - AssetPacker.prototype.process = function (allow4096Textures) { - if (allow4096Textures === void 0) { allow4096Textures = false; } - return __awaiter(this, void 0, void 0, function () { - var cacheExist; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - this.allow4096Textures = allow4096Textures; - if (!this.useCache) return [3, 2]; - if (this.cacheName == "") { - console.error("未指定缓存名称"); - return [2]; - } - return [4, RES.getResByUrl(this.cacheName)]; - case 1: - cacheExist = _a.sent(); - if (!cacheExist) - this.createPack(); - else - this.loadPack(); - return [3, 3]; - case 2: - this.createPack(); - _a.label = 3; - case 3: return [2]; - } - }); - }); - }; - AssetPacker.prototype.loadPack = function () { - return __awaiter(this, void 0, void 0, function () { - var loaderTexture; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, RES.getResByUrl(this.cacheName)]; - case 1: - loaderTexture = _a.sent(); - if (this.onProcessCompleted) - this.onProcessCompleted(); - return [2, loaderTexture]; - } - }); - }); - }; - AssetPacker.prototype.createPack = function () { - var textures = []; - var images = []; - for (var _i = 0, _a = this.itemsToRaster; _i < _a.length; _i++) { - var itemToRaster = _a[_i]; - textures.push(new Bitmap(itemToRaster.texture)); - images.push(itemToRaster.id); - } - var textureSize = this.allow4096Textures ? 4096 : 2048; - var rectangles = []; - for (var i = 0; i < textures.length; i++) { - if (textures[i].width > textureSize || textures[i].height > textureSize) { - throw new Error("一个纹理的大小比图集的大小大"); - } - else { - rectangles.push(new es.Rectangle(0, 0, textures[i].width, textures[i].height)); - } - } - var padding = 1; - var numSpriteSheet = 0; - while (rectangles.length > 0) { - var texture = new egret.RenderTexture(); - var packer = new es.RectanglePacker(textureSize, textureSize, padding); - for (var i = 0; i < rectangles.length; i++) - packer.insertRectangle(Math.floor(rectangles[i].width), Math.floor(rectangles[i].height), i); - packer.packRectangles(); - if (packer.rectangleCount > 0) { - var rect = new es.IntegerRectangle(); - var textureAssets = []; - var garbageRect = []; - var garabeTextures = []; - var garbageImages = []; - for (var j = 0; j < packer.rectangleCount; j++) { - rect = packer.getRectangle(j, rect); - var index = packer.getRectangleId(j); - texture.drawToTexture(textures[index], new es.Rectangle(rect.x, rect.y, rect.width, rect.height)); - var textureAsset = new es.TextureAsset(); - textureAsset.x = rect.x; - textureAsset.y = rect.y; - textureAsset.width = rect.width; - textureAsset.height = rect.height; - textureAsset.name = images[index]; - textureAssets.push(textureAsset); - garbageRect.push(rectangles[index]); - garabeTextures.push(textures[index].texture); - garbageImages.push(images[index]); - } - for (var _b = 0, garbageRect_1 = garbageRect; _b < garbageRect_1.length; _b++) { - var garbage = garbageRect_1[_b]; - rectangles.remove(garbage); - } - var _loop_8 = function (garbage) { - textures.removeAll(function (a) { return a.texture.hashCode == garbage.hashCode; }); - }; - for (var _c = 0, garabeTextures_1 = garabeTextures; _c < garabeTextures_1.length; _c++) { - var garbage = garabeTextures_1[_c]; - _loop_8(garbage); - } - for (var _d = 0, garbageImages_1 = garbageImages; _d < garbageImages_1.length; _d++) { - var garbage = garbageImages_1[_d]; - images.remove(garbage); - } - if (this.cacheName != "") { - texture.saveToFile("image/png", this.cacheName); - ++numSpriteSheet; - } - for (var _e = 0, textureAssets_1 = textureAssets; _e < textureAssets_1.length; _e++) { - var textureAsset = textureAssets_1[_e]; - this._sprites.set(textureAsset.name, texture); - } - } - } - if (this.onProcessCompleted) - this.onProcessCompleted(); - }; - AssetPacker.prototype.dispose = function () { - this._sprites.forEach(function (asset, name) { - asset.dispose(); - RES.destroyRes(name); - }); - this._sprites.clear(); - }; - AssetPacker.prototype.getTexture = function (id) { - return this._sprites.get(id); - }; - return AssetPacker; - }()); - es.AssetPacker = AssetPacker; -})(es || (es = {})); -var es; -(function (es) { - var IntegerRectangle = (function (_super) { - __extends(IntegerRectangle, _super); - function IntegerRectangle() { - return _super !== null && _super.apply(this, arguments) || this; - } - return IntegerRectangle; - }(es.Rectangle)); - es.IntegerRectangle = IntegerRectangle; -})(es || (es = {})); -var es; -(function (es) { - var RectanglePacker = (function () { - function RectanglePacker(width, height, padding) { - if (padding === void 0) { padding = 0; } - this._width = 0; - this._height = 0; - this._padding = 8; - this._packedWidth = 0; - this._packedHeight = 0; - this._insertList = []; - this._insertedRectangles = []; - this._freeAreas = []; - this._newFreeAreas = []; - this._sortableSizeStack = []; - this._rectangleStack = []; - this._outsideRectangle = new es.IntegerRectangle(width + 1, height + 1, 0, 0); - this.reset(width, height, padding); - } - Object.defineProperty(RectanglePacker.prototype, "rectangleCount", { - get: function () { - return this._insertedRectangles.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RectanglePacker.prototype, "packedWidth", { - get: function () { - return this._packedWidth; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RectanglePacker.prototype, "packedHeight", { - get: function () { - return this._packedHeight; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RectanglePacker.prototype, "padding", { - get: function () { - return this._padding; - }, - enumerable: true, - configurable: true - }); - RectanglePacker.prototype.reset = function (width, height, padding) { - if (padding === void 0) { padding = 0; } - while (this._insertedRectangles.length > 0) - this.freeRectangle(this._insertedRectangles.pop()); - while (this._freeAreas.length > 0) - this.freeRectangle(this._freeAreas.pop()); - this._width = width; - this._height = height; - this._packedWidth = 0; - this._packedHeight = 0; - this._freeAreas.push(this.allocateRectangle(0, 0, this._width, this._height)); - while (this._insertedRectangles.length > 0) - this.freeSize(this._insertList.pop()); - this._padding = padding; - }; - RectanglePacker.prototype.insertRectangle = function (width, height, id) { - var sortableSize = this.allocateSize(width, height, id); - this._insertList.push(sortableSize); - }; - RectanglePacker.prototype.packRectangles = function (sort) { - if (sort === void 0) { sort = true; } - if (sort) - this._insertList.sort(function (emp1, emp2) { - return emp1.width - emp2.width; - }); - while (this._insertList.length > 0) { - var sortableSize = this._insertList.pop(); - var width = sortableSize.width; - var height = sortableSize.height; - var index = this.getFreeAreaIndex(width, height); - if (index >= 0) { - var freeArea = this._freeAreas[index]; - var target = this.allocateRectangle(freeArea.x, freeArea.y, width, height); - target.id = sortableSize.id; - this.generateNewFreeAreas(target, this._freeAreas, this._newFreeAreas); - while (this._newFreeAreas.length > 0) - this._freeAreas.push(this._newFreeAreas.pop()); - this._insertedRectangles.push(target); - if (target.right > this._packedWidth) - this._packedWidth = target.right; - if (target.bottom > this._packedHeight) - this._packedHeight = target.bottom; - } - this.freeSize(sortableSize); - } - return this.rectangleCount; - }; - RectanglePacker.prototype.getRectangle = function (index, rectangle) { - var inserted = this._insertedRectangles[index]; - rectangle.x = inserted.x; - rectangle.y = inserted.y; - rectangle.width = inserted.width; - rectangle.height = inserted.height; - return rectangle; - }; - RectanglePacker.prototype.getRectangleId = function (index) { - var inserted = this._insertedRectangles[index]; - return inserted.id; - }; - RectanglePacker.prototype.generateNewFreeAreas = function (target, areas, results) { - var x = target.x; - var y = target.y; - var right = target.right + 1 + this._padding; - var bottom = target.bottom + 1 + this._padding; - var targetWithPadding = null; - if (this._padding == 0) - targetWithPadding = target; - for (var i = areas.length - 1; i >= 0; i--) { - var area = areas[i]; - if (!(x >= area.right || right <= area.x || y >= area.bottom || bottom <= area.y)) { - if (targetWithPadding == null) - targetWithPadding = this.allocateRectangle(target.x, target.y, target.width + this._padding, target.height + this._padding); - this.generateDividedAreas(targetWithPadding, area, results); - var topOfStack = areas.pop(); - if (i < areas.length) { - areas[i] = topOfStack; - } - } - } - if (targetWithPadding != null && targetWithPadding != target) - this.freeRectangle(targetWithPadding); - this.filterSelfSubAreas(results); - }; - RectanglePacker.prototype.filterSelfSubAreas = function (areas) { - for (var i = areas.length - 1; i >= 0; i--) { - var filtered = areas[i]; - for (var j = areas.length - 1; j >= 0; j--) { - if (i != j) { - var area = areas[j]; - if (filtered.x >= area.x && filtered.y >= area.y && filtered.right <= area.right && filtered.bottom <= area.bottom) { - this.freeRectangle(filtered); - var topOfStack = areas.pop(); - if (i < areas.length) { - areas[i] = topOfStack; - } - break; - } - } - } - } - }; - RectanglePacker.prototype.generateDividedAreas = function (divider, area, results) { - var count = 0; - var rightDelta = area.right - divider.right; - if (rightDelta > 0) { - results.push(this.allocateRectangle(divider.right, area.y, rightDelta, area.height)); - count++; - } - var leftDelta = divider.x - area.x; - if (leftDelta > 0) { - results.push(this.allocateRectangle(area.x, area.y, leftDelta, area.height)); - count++; - } - var bottomDelta = area.bottom - divider.bottom; - if (bottomDelta > 0) { - results.push(this.allocateRectangle(area.x, divider.bottom, area.width, bottomDelta)); - count++; - } - var topDelta = divider.y - area.y; - if (topDelta > 0) { - results.push(this.allocateRectangle(area.x, area.y, area.width, topDelta)); - count++; - } - if (count == 0 && (divider.width < area.width || divider.height < area.height)) { - results.push(area); - } - else { - this.freeRectangle(area); - } - }; - RectanglePacker.prototype.getFreeAreaIndex = function (width, height) { - var best = this._outsideRectangle; - var index = -1; - var paddedWidth = width + this._padding; - var paddedHeight = height + this._padding; - var count = this._freeAreas.length; - for (var i = count - 1; i >= 0; i--) { - var free = this._freeAreas[i]; - if (free.x < this._packedWidth || free.y < this.packedHeight) { - if (free.x < best.x && paddedWidth <= free.width && paddedHeight <= free.height) { - index = i; - if ((paddedWidth == free.width && free.width <= free.height && free.right < this._width) || - (paddedHeight == free.height && free.height <= free.width)) { - break; - } - best = free; - } - } - else { - if (free.x < best.x && width <= free.width && height <= free.height) { - index = i; - if ((width == free.width && free.width <= free.height && free.right < this._width) || - (height == free.height && free.height <= free.width)) { - break; - } - best = free; - } - } - } - return index; - }; - RectanglePacker.prototype.allocateSize = function (width, height, id) { - if (this._sortableSizeStack.length > 0) { - var size = this._sortableSizeStack.pop(); - size.width = width; - size.height = height; - size.id = id; - return size; - } - return new es.SortableSize(width, height, id); - }; - RectanglePacker.prototype.freeSize = function (size) { - this._sortableSizeStack.push(size); - }; - RectanglePacker.prototype.allocateRectangle = function (x, y, width, height) { - if (this._rectangleStack.length > 0) { - var rectangle = this._rectangleStack.pop(); - rectangle.x = x; - rectangle.y = y; - rectangle.width = width; - rectangle.height = height; - rectangle.right = x + width; - rectangle.bottom = y + height; - return rectangle; - } - return new es.IntegerRectangle(x, y, width, height); - }; - RectanglePacker.prototype.freeRectangle = function (rectangle) { - this._rectangleStack.push(rectangle); - }; - return RectanglePacker; - }()); - es.RectanglePacker = RectanglePacker; -})(es || (es = {})); -var es; -(function (es) { - var SortableSize = (function () { - function SortableSize(width, height, id) { - this.width = width; - this.height = height; - this.id = id; - } - return SortableSize; - }()); - es.SortableSize = SortableSize; -})(es || (es = {})); -var es; -(function (es) { - var TextureAssets = (function () { - function TextureAssets(assets) { - this.assets = assets; - } - return TextureAssets; - }()); - es.TextureAssets = TextureAssets; - var TextureAsset = (function () { - function TextureAsset() { - } - return TextureAsset; - }()); - es.TextureAsset = TextureAsset; -})(es || (es = {})); -var es; -(function (es) { - var TextureToPack = (function () { - function TextureToPack(texture, id) { - this.texture = texture; - this.id = id; - } - return TextureToPack; - }()); - es.TextureToPack = TextureToPack; -})(es || (es = {})); -var es; -(function (es) { - var Timer = (function () { - function Timer() { - this._timeInSeconds = 0; - this._repeats = false; - this._isDone = false; - this._elapsedTime = 0; - } - Timer.prototype.getContext = function () { - return this.context; - }; - Timer.prototype.reset = function () { - this._elapsedTime = 0; - }; - Timer.prototype.stop = function () { - this._isDone = true; - }; - Timer.prototype.tick = function () { - if (!this._isDone && this._elapsedTime > this._timeInSeconds) { - this._elapsedTime -= this._timeInSeconds; - this._onTime(this); - if (!this._isDone && !this._repeats) - this._isDone = true; - } - this._elapsedTime += es.Time.deltaTime; - return this._isDone; - }; - Timer.prototype.initialize = function (timeInsSeconds, repeats, context, onTime) { - this._timeInSeconds = timeInsSeconds; - this._repeats = repeats; - this.context = context; - this._onTime = onTime; - }; - Timer.prototype.unload = function () { - this.context = null; - this._onTime = null; - }; - return Timer; - }()); - es.Timer = Timer; -})(es || (es = {})); -var es; -(function (es) { - var TimerManager = (function (_super) { - __extends(TimerManager, _super); - function TimerManager() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._timers = []; - return _this; - } - TimerManager.prototype.update = function () { - for (var i = this._timers.length - 1; i >= 0; i--) { - if (this._timers[i].tick()) { - this._timers[i].unload(); - this._timers.removeAt(i); - } - } - }; - TimerManager.prototype.schedule = function (timeInSeconds, repeats, context, onTime) { - var timer = new es.Timer(); - timer.initialize(timeInSeconds, repeats, context, onTime); - this._timers.push(timer); - return timer; - }; - return TimerManager; - }(es.GlobalManager)); - es.TimerManager = TimerManager; -})(es || (es = {})); diff --git a/demo/libs/framework/framework.min.js b/demo/libs/framework/framework.min.js deleted file mode 100644 index 7e1100f6..00000000 --- a/demo/libs/framework/framework.min.js +++ /dev/null @@ -1 +0,0 @@ -window.es={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(s,a)}h((n=n.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,e){var i=t.findIndex(e);return-1==i?null:t[i]}(this,t)},Array.prototype.find=function(t){return function(t,e){return t.firstOrDefault(e)}(this,t)},Array.prototype.where=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return e.call(arguments[2],n,r,t)&&i.push(n),i},[]);for(var i=[],n=0,r=t.length;n=0&&t.splice(i,1)}while(i>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var i=t.findIndex(function(t){return t===e});return i>=0&&(t.splice(i,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,e){t.splice(e,1)}(this,t)},Array.prototype.removeRange=function(t,e){return function(t,e,i){t.splice(e,i)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return i.push(e.call(arguments[2],n,r,t)),i},[]);for(var i=[],n=0,r=t.length;no?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,i){return t.sort(function(t,n){var r=e(t),o=e(n);return i?-i(r,o):r0;){if("break"===u())break}return s?this.recontructPath(a,n,r):null},e.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},e.hasKey=function(e,i){for(var n,r=e.keys();!(n=r.next()).done;){if(n.value instanceof t.Vector2&&i instanceof t.Vector2&&n.value.equals(i))return!0;if(n.value==i)return!0}return!1},e.getKey=function(e,i){for(var n,r,o=e.keys(),s=e.values();n=o.next(),r=s.next(),!n.done;){if(n.value instanceof t.Vector2&&i instanceof t.Vector2&&n.value.equals(i))return r.value;if(n.value==i)return r.value}return null},e}();t.AStarPathfinder=e;var i=function(t){function e(e){var i=t.call(this)||this;return i.data=e,i}return __extends(e,t),e}(t.PriorityQueueNode)}(es||(es={})),function(t){var e=function(){function e(e,i){this.dirs=[new t.Vector2(1,0),new t.Vector2(0,-1),new t.Vector2(-1,0),new t.Vector2(0,1)],this.walls=[],this.weightedNodes=[],this.defaultWeight=1,this.weightedNodeWeight=5,this._neighbors=new Array(4),this._width=e,this._height=i}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x=this._nodes.length?(console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?"),!1):this._nodes[t.queueIndex]==t:(console.error("node cannot be null"),!1)},t.prototype.enqueue=function(t,e){t.priority=e,this._numNodes++,this._nodes[this._numNodes]=t,t.queueIndex=this._numNodes,t.insertionIndex=this._numNodesEverEnqueued++,this.cascadeUp(this._nodes[this._numNodes])},t.prototype.dequeue=function(){var t=this._nodes[1];return this.remove(t),t},t.prototype.remove=function(t){if(t.queueIndex==this._numNodes)return this._nodes[this._numNodes]=null,void this._numNodes--;var e=this._nodes[this._numNodes];this.swap(t,e),delete this._nodes[this._numNodes],this._numNodes--,this.onNodeUpdated(e)},t.prototype.isValidQueue=function(){for(var t=1;t0&&this.hasHigherPriority(t,i)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,i=t.queueIndex;;){e=t;var n=2*i;if(n>this._numNodes){t.queueIndex=i,this._nodes[i]=t;break}var r=this._nodes[n];this.hasHigherPriority(r,e)&&(e=r);var o=n+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=i,this._nodes[i]=t;break}this._nodes[i]=e;var a=e.queueIndex;e.queueIndex=i,i=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var i=this._nodes[e];if(this.hasHigherPriority(i,t))break;this.swap(t,i),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var i=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=i},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===h())break}return o?t.AStarPathfinder.recontructPath(a,i,n):null},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},e}();t.BreadthFirstPathfinder=e}(es||(es={})),function(t){var e=function(){function t(){this.edges=new Map}return t.prototype.addEdgesForNode=function(t,e){return this.edges.set(t,e),this},t.prototype.getNeighbors=function(t){return this.edges.get(t)},t}();t.UnweightedGraph=e}(es||(es={})),function(t){var e=function(){function e(t,e){this.x=0,this.y=0,this.x=t||0,this.y=null!=e?e:this.x}return Object.defineProperty(e,"zero",{get:function(){return new e(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),e.add=function(t,i){var n=new e(0,0);return n.x=t.x+i.x,n.y=t.y+i.y,n},e.divide=function(t,i){var n=new e(0,0);return n.x=t.x/i.x,n.y=t.y/i.y,n},e.multiply=function(t,i){var n=new e(0,0);return n.x=t.x*i.x,n.y=t.y*i.y,n},e.subtract=function(t,i){var n=new e(0,0);return n.x=t.x-i.x,n.y=t.y-i.y,n},e.normalize=function(t){var i=new e(t.x,t.y),n=1/Math.sqrt(i.x*i.x+i.y*i.y);return i.x*=n,i.y*=n,i},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},e.clamp=function(i,n,r){return new e(t.MathHelper.clamp(i.x,n.x,r.x),t.MathHelper.clamp(i.y,n.y,r.y))},e.lerp=function(i,n,r){return new e(t.MathHelper.lerp(i.x,n.x,r),t.MathHelper.lerp(i.y,n.y,r))},e.transform=function(t,i){return new e(t.x*i.m11+t.y*i.m21+i.m31,t.x*i.m12+t.y*i.m22+i.m32)},e.distance=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},e.angle=function(i,n){return i=e.normalize(i),n=e.normalize(n),Math.acos(t.MathHelper.clamp(e.dot(i,n),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){return t.x=-t.x,t.y=-t.y,t},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},e.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},e.prototype.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},e.prototype.normalize=function(){var t=1/Math.sqrt(this.x*this.x+this.y*this.y);this.x*=t,this.y*=t},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.round=function(){return new e(Math.round(this.x),Math.round(this.y))},e.prototype.equals=function(t){return t instanceof e&&(t.x==this.x&&t.y==this.y)},e}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,i,n){void 0===n&&(n=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=i,this._dirs=n?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===u())break}return s?this.recontructPath(a,n,r):null},i.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},i.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},i.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},i}();t.WeightedPathfinder=i}(es||(es={})),function(t){var e=function(){function e(){this._opened=new Array(e.MAX_NODES),this._closed=new Array(e.MAX_NODES)}return e.prototype.clear=function(){for(var e=0;e0},e.prototype.removeOpened=function(t){this._numOpened>0&&(this._opened[this._lastFoundOpened]=this._opened[this._numOpened-1]),this._numOpened--},e.prototype.removeClosed=function(t){this._numClosed>0&&(this._closed[this._lastFoundClosed]=this._closed[this._numClosed-1]),this._numClosed--},e.prototype.isOpen=function(t){return this._opened.indexOf(t)>-1},e.prototype.isClosed=function(t){return this._closed.indexOf(t)>-1},e.prototype.addToOpenList=function(t){this._opened[this._numOpened++]=t},e.prototype.addToClosedList=function(t){this._closed[this._numClosed++]=t},e.prototype.removeCheapestOpenNode=function(){var t=Number.MAX_VALUE;this._lastFoundOpened=-1;for(var e=0;e-1?e:(this._actions.push(t),this._actions.length-1)},e.MAX_CONDITIONS=64,e}();t.ActionPlanner=e}(es||(es={})),function(t){var e=function(){function e(){this._planner=new t.ActionPlanner}return e.prototype.plan=function(e){void 0===e&&(e=!1);var i=null;if(e&&(i=[]),this.actions=this._planner.plan(this.getWorldState(),this.getGoalState(),i),null!=i&&i.length>0){console.log("---- ActionPlanner plan ----"),console.log("plan cost = "+i[i.length-1].costSoFar),console.log(" start\t"+this.getWorldState().describe(this._planner));for(var n=0;n0},e}();t.Agent=e}(es||(es={})),function(t){var e=function(){function e(t,e,i){this.planner=t,this.values=e,this.dontCare=i}return e.create=function(t){return new e(t,0,-1)},e.prototype.set=function(t,e){return"string"==typeof t?this.set(this.planner.findConditionNameIndex(t),e):(this.values=e?this.values|1<0&&(i+=", "),i+=o?r.toUpperCase():r}return i},e}();t.WorldState=e}(es||(es={})),function(t){var e=function(e){function i(){var n=e.call(this)||this;return n._globalManagers=[],n._coroutineManager=new t.CoroutineManager,n._timerManager=new t.TimerManager,n._frameCounterElapsedTime=0,n._frameCounter=0,i._instance=n,i.emitter=new t.Emitter,i.content=new t.ContentManager,n.addEventListener(egret.Event.ADDED_TO_STAGE,n.onAddToStage,n),i.registerGlobalManager(n._coroutineManager),i.registerGlobalManager(n._timerManager),n}return __extends(i,e),Object.defineProperty(i,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(i,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance.addChild(t),this._instance._scene=t,this._instance._scene.begin(),i.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),i.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},i.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},i.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},i.getGlobalManager=function(t){for(var e=0;e=1&&(this._frameCounter=0,this._frameCounterElapsedTime-=1)},i.prototype.endDebugDraw=function(){t.TimeRuler.Instance.endMark("draw"),t.TimeRuler.Instance.render()},i.prototype.onSceneChanged=function(){i.emitter.emit(t.CoreEvents.SceneChanged),t.Time.sceneChanged()},i.prototype.onGraphicsDeviceReset=function(){i.emitter.emit(t.CoreEvents.GraphicsDeviceReset)},i.prototype.initialize=function(){t.Graphics.Instance=new t.Graphics},i.prototype.update=function(){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(i){switch(i.label){case 0:if(t.Time.update(egret.getTimer()),t.Input.update(),!this._scene)return[3,2];for(e=this._globalManagers.length-1;e>=0;e--)this._globalManagers[e].enabled&&this._globalManagers[e].update();return this._sceneTransition&&(!this._sceneTransition||this._sceneTransition.loadsNewScene&&!this._sceneTransition.isNewSceneLoaded)||this._scene.update(),this._nextScene?(this._scene.parent&&this._scene.parent.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),[4,this._scene.begin()]):[3,2];case 1:i.sent(),this.addChild(this._scene),i.label=2;case 2:return[4,this.draw()];case 3:return i.sent(),[2]}})})},i.prototype.onAddToStage=function(){i.graphicsDevice=new t.GraphicsDevice,this.addEventListener(egret.Event.RESIZE,this.onGraphicsDeviceReset,this),this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE,this.onOrientationChanged,this),this.addEventListener(egret.Event.ENTER_FRAME,this.update,this),t.Input.initialize(),KeyboardUtils.init(),this.initialize()},i.debugRenderEndabled=!1,i}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){var e=function(){function t(){}return t.renderableBounds=16776960,t.renderableCenter=10040012,t.colliderBounds=5592405,t.colliderEdge=9109504,t.colliderPosition=16776960,t.colliderCenter=16711680,t}();t.Colors=e;var i=function(){function e(){}return Object.defineProperty(e,"lineSizeMultiplier",{get:function(){return Math.max(Math.ceil(t.Core.scene.x/t.Core.scene.width),1)},enumerable:!0,configurable:!0}),e}();t.Size=i;var n=function(){function e(){}return e.drawHollowRect=function(e,i,n){void 0===n&&(n=0),this._debugDrawItems.push(new t.DebugDrawItem(e,i,n))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var i=this._debugDrawItems.length-1;i>=0;i--){this._debugDrawItems[i].draw(e)&&this._debugDrawItems.removeAt(i)}}},e._debugDrawItems=[],e}();t.Debug=n}(es||(es={})),function(t){var e=function(){function t(){}return t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefaults=e}(es||(es={})),function(t){var e;!function(t){t[t.line=0]="line",t[t.hollowRectangle=1]="hollowRectangle",t[t.pixel=2]="pixel",t[t.text=3]="text"}(e=t.DebugDrawType||(t.DebugDrawType={}));var i=function(){function i(t,i,n){this.rectangle=t,this.color=i,this.duration=n,this.drawType=e.hollowRectangle}return i.prototype.draw=function(i){switch(this.drawType){case e.line:case e.hollowRectangle:case e.pixel:case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},i}();t.DebugDrawItem=i}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e.debugDisplayObject=new egret.DisplayObjectContainer,e._enabled=!0,e._updateOrder=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"transform",{get:function(){return this.entity.transform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this.entity?this.entity.enabled&&this._enabled:this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.onAddedToEntity=function(){},e.prototype.onRemovedFromEntity=function(){},e.prototype.onEntityTransformChanged=function(t){},e.prototype.debugRender=function(t){},e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},e.prototype.setUpdateOrder=function(t){return this._updateOrder!=t&&(this._updateOrder=t),this},e}(egret.HashObject);t.Component=e}(es||(es={})),function(t){!function(t){t[t.GraphicsDeviceReset=0]="GraphicsDeviceReset",t[t.SceneChanged=1]="SceneChanged",t[t.OrientationChanged=2]="OrientationChanged"}(t.CoreEvents||(t.CoreEvents={}))}(es||(es={})),function(t){var e=function(){function e(i){this.updateInterval=1,this._tag=0,this._enabled=!0,this._updateOrder=0,this.components=new t.ComponentList(this),this.transform=new t.Transform(this),this.name=i,this.id=e._idGenerator++,this.componentBits=new t.BitSet}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this._isDestroyed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tag",{get:function(){return this._tag},set:function(t){this.setTag(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform.parent},set:function(t){this.transform.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childCount",{get:function(){return this.transform.childCount},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.transform.position},set:function(t){this.transform.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localPosition",{get:function(){return this.transform.localPosition},set:function(t){this.transform.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(t){this.transform.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationDegrees",{get:function(){return this.transform.rotationDegrees},set:function(t){this.transform.setRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotation",{get:function(){return this.transform.localRotation},set:function(t){this.transform.setLocalRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotationDegrees",{get:function(){return this.transform.localRotationDegrees},set:function(t){this.transform.setLocalRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this.transform.scale},set:function(t){this.transform.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localScale",{get:function(){return this.transform.localScale},set:function(t){this.transform.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldInverseTransform",{get:function(){return this.transform.worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localToWorldTransform",{get:function(){return this.transform.localToWorldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldToLocalTransform",{get:function(){return this.transform.worldToLocalTransform},enumerable:!0,configurable:!0}),e.prototype.onTransformChanged=function(t){this.components.onEntityTransformChanged(t)},e.prototype.setTag=function(t){return this._tag!=t&&(this.scene&&this.scene.entities.removeFromTagList(this),this._tag=t,this.scene&&this.scene.entities.addToTagList(this)),this},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.components.onEntityEnabled():this.components.onEntityDisabled()),this},e.prototype.setUpdateOrder=function(t){if(this._updateOrder!=t)return this._updateOrder=t,this.scene&&(this.scene.entities.markEntityListUnsorted(),this.scene.entities.markTagUnsorted(this.tag)),this},e.prototype.destroy=function(){this._isDestroyed=!0,this.scene.entities.remove(this),this.transform.parent=null;for(var t=this.transform.childCount-1;t>=0;t--){this.transform.getChild(t).entity.destroy()}},e.prototype.detachFromScene=function(){this.scene.entities.remove(this),this.components.deregisterAllComponents();for(var t=0;t=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),this.entityProcessors&&this.entityProcessors.lateUpdate(),this.renderableComponents.updateList()},i.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,n=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=i*Math.acos(t.Vector2.dot(n,t.Vector2.unitY))},n.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},n.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},n.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},n.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},n.prototype.roundPosition=function(){this.position=this._position.round()},n.prototype.updateTransform=function(){this.hierarchyDirty!=e.clean&&(this.parent&&this.parent.updateTransform(),this._localDirty&&(this._localPositionDirty&&(this._translationMatrix=t.Matrix2D.create().translate(this._localPosition.x,this._localPosition.y),this._localPositionDirty=!1),this._localRotationDirty&&(this._rotationMatrix=t.Matrix2D.create().rotate(this._localRotation),this._localRotationDirty=!1),this._localScaleDirty&&(this._scaleMatrix=t.Matrix2D.create().scale(this._localScale.x,this._localScale.y),this._localScaleDirty=!1),this._localTransform=this._scaleMatrix.multiply(this._rotationMatrix),this._localTransform=this._localTransform.multiply(this._translationMatrix),this.parent||(this._worldTransform=this._localTransform,this._rotation=this._localRotation,this._scale=this._localScale,this._worldInverseDirty=!0),this._localDirty=!1),this.parent&&(this._worldTransform=this._localTransform.multiply(this.parent._worldTransform),this._rotation=this._localRotation+this.parent._rotation,this._scale=t.Vector2.multiply(this.parent._scale,this._localScale),this._worldInverseDirty=!0),this._worldToLocalDirty=!0,this._positionDirty=!0,this.hierarchyDirty=e.clean)},n.prototype.setDirty=function(e){if(0==(this.hierarchyDirty&e)){switch(this.hierarchyDirty|=e,e){case t.DirtyType.positionDirty:this.entity.onTransformChanged(transform.Component.position);break;case t.DirtyType.rotationDirty:this.entity.onTransformChanged(transform.Component.rotation);break;case t.DirtyType.scaleDirty:this.entity.onTransformChanged(transform.Component.scale)}this._children||(this._children=[]);for(var i=0;it&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},i.prototype.forceMatrixUpdate=function(){this._areMatrixedDirty=!0},i.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},i.prototype.zoomIn=function(t){this.zoom+=t},i.prototype.zoomOut=function(t){this.zoom-=t},i.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),t.Vector2Ext.transformR(e,this._transformMatrix,e),e},i.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),t.Vector2Ext.transformR(e,this._inverseTransformMatrix,e),e},i.prototype.onSceneRenderTargetSizeChanged=function(e,i){this._isProjectionMatrixDirty=!0;var n=this._origin;this.origin=new t.Vector2(e/2,i/2),this.entity.transform.position.add(t.Vector2.subtract(this._origin,n))},i.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},i.prototype.updateMatrixes=function(){var e;this._areMatrixedDirty&&(this._transformMatrix=t.Matrix2D.create().translate(-this.entity.transform.position.x,-this.entity.transform.position.y),1!=this._zoom&&(e=t.Matrix2D.create().scale(this._zoom,this._zoom),this._transformMatrix=this._transformMatrix.multiply(e)),0!=this.entity.transform.rotation&&(e=t.Matrix2D.create().rotate(this.entity.transform.rotation),this._transformMatrix=this._transformMatrix.multiply(e)),e=t.Matrix2D.create().translate(Math.floor(this._origin.x),Math.floor(this._origin.y)),this._transformMatrix=this._transformMatrix.multiply(e),this._inverseTransformMatrix=this._transformMatrix.invert(),this._areBoundsDirty=!0,this._areMatrixedDirty=!1)},i}(t.Component);t.Camera=e}(es||(es={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._shakeDirection=t.Vector2.zero,i._shakeOffset=t.Vector2.zero,i._shakeIntensity=0,i._shakeDegredation=.95,i}return __extends(i,e),i.prototype.shake=function(e,i,n){void 0===e&&(e=15),void 0===i&&(i=.9),void 0===n&&(n=t.Vector2.zero),this.enabled=!0,this._shakeIntensity=1)&&(i=.95),this._shakeDegredation=i)},i.prototype.update=function(){Math.abs(this._shakeIntensity)>0&&(this._shakeOffset=this._shakeDirection,0!=this._shakeOffset.x||0!=this._shakeOffset.y?this._shakeOffset.normalize():(this._shakeOffset.x=this._shakeOffset.x+Math.random()-.5,this._shakeOffset.y=this._shakeOffset.y+Math.random()-.5),this._shakeOffset.multiply(new t.Vector2(this._shakeIntensity)),this._shakeIntensity*=-this._shakeDegredation,Math.abs(this._shakeIntensity)<=.01&&(this._shakeIntensity=0,this.enabled=!1)),this.entity.scene.camera.position.add(this._shakeOffset)},i}(t.Component);t.CameraShake=e}(es||(es={})),function(t){var e=function(){function t(t){this._type=t,this._cache=[]}return t.prototype.obtain=function(){try{return this._cache.length>0?this._cache.shift():new this._type}catch(t){throw new Error(this._type+t)}},t.prototype.free=function(t){t.reset(),this._cache.push(t)},t}();t.ComponentPool=e}(es||(es={})),function(t){var e;!function(t){t[t.lockOn=0]="lockOn",t[t.cameraWindow=1]="cameraWindow"}(e=t.CameraStyle||(t.CameraStyle={}));var i=function(i){function n(n,r,o){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=e.lockOn);var s=i.call(this)||this;return s.followLerp=.1,s.deadzone=new t.Rectangle,s.focusOffset=t.Vector2.zero,s.mapLockEnabled=!1,s.mapSize=new t.Rectangle,s._desiredPositionDelta=new t.Vector2,s._worldSpaceDeadZone=new t.Rectangle,s.rectShape=new egret.Shape,s._targetEntity=n,s._cameraStyle=o,s.camera=r,s}return __extends(n,i),n.prototype.onAddedToEntity=function(){this.camera||(this.camera=this.entity.scene.camera),this.follow(this._targetEntity,this._cameraStyle),t.Core.emitter.addObserver(t.CoreEvents.GraphicsDeviceReset,this.onGraphicsDeviceReset,this)},n.prototype.onGraphicsDeviceReset=function(){t.Core.schedule(0,!1,this,function(t){var e=t.context;e.follow(e._targetEntity,e._cameraStyle)})},n.prototype.update=function(){var e=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5));this._worldSpaceDeadZone.x=this.camera.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.camera.position.y-e.y*t.Core.scene.scaleY+this.deadzone.y+this.focusOffset.y,this._worldSpaceDeadZone.width=this.deadzone.width,this._worldSpaceDeadZone.height=this.deadzone.height,this._targetEntity&&this.updateFollow(),this.camera.position=t.Vector2.lerp(this.camera.position,t.Vector2.add(this.camera.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.camera.position=this.clampToMapSize(this.camera.position),this.entity.transform.roundPosition())},n.prototype.debugRender=function(t){this.rectShape||this.debugDisplayObject.addChild(this.rectShape),this.rectShape.graphics.clear(),this._cameraStyle==e.lockOn?(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x-5-t.bounds.x,this._worldSpaceDeadZone.y-5-t.bounds.y,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill()):(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x-t.bounds.x,this._worldSpaceDeadZone.y-t.bounds.y,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill())},n.prototype.clampToMapSize=function(e){var i=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),n=new t.Vector2(this.mapSize.width-i.x,this.mapSize.height-i.y);return t.Vector2.clamp(e,i,n)},n.prototype.follow=function(i,n){void 0===n&&(n=e.cameraWindow),this._targetEntity=i,this._cameraStyle=n;var r=this.camera.bounds;switch(this._cameraStyle){case e.cameraWindow:var o=r.width/6,s=r.height/3;this.deadzone=new t.Rectangle((r.width-o)/2,(r.height-s)/2,o,s);break;case e.lockOn:this.deadzone=new t.Rectangle(r.width/2,r.height/2,10,10)}},n.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var i=this._targetEntity.transform.position.x,n=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>i?this._desiredPositionDelta.x=i-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.xn&&(this._desiredPositionDelta.y=n-this._worldSpaceDeadZone.y)}else{if(!this._targetCollider&&(this._targetCollider=this._targetEntity.getComponent(t.Collider),!this._targetCollider))return;var r=this._targetEntity.getComponent(t.Collider).bounds;this._worldSpaceDeadZone.containsRect(r)||(this._worldSpaceDeadZone.left>r.left?this._desiredPositionDelta.x=r.left-this._worldSpaceDeadZone.left:this._worldSpaceDeadZone.rightr.top&&(this._desiredPositionDelta.y=r.top-this._worldSpaceDeadZone.top))}},n.prototype.setCenteredDeadzone=function(e,i){if(this.camera){var n=this.camera.bounds;this.deadzone=new t.Rectangle((n.width-e)/2,(n.height-i)/2,e,i)}else console.error("相机是null。我们不能得到它的边界。请等到该组件添加到实体之后")},n}(t.Component);t.FollowCamera=i}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){return t.updateOrder-e.updateOrder},t}();t.IUpdatableComparer=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Component);t.PooledComponent=e}(es||(es={})),function(t){var e=function(){function e(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.onRemovedFromScene=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled),this},e.prototype.setUpdateOrder=function(e){return this.updateOrder!=e&&(this.updateOrder=e,t.Core.scene._sceneComponents.sort(this.compareTo)),this},e.prototype.compareTo=function(t){return this.updateOrder-t.updateOrder},e}();t.SceneComponent=e}(es||(es={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToEntity=function(){this._triggerHelper=new t.ColliderTriggerHelper(this.entity)},i.prototype.calculateMovement=function(e,i){if(!this.entity.getComponent(t.Collider)||!this._triggerHelper)return!1;for(var n=this.entity.getComponents(t.Collider),r=0;r=2){this.polygonShape.graphics.beginFill(t.Colors.colliderEdge,0),this.polygonShape.graphics.lineStyle(t.Size.lineSizeMultiplier,t.Colors.colliderEdge);for(var n=0;no||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=i.completed,this._elapsedTime=0,this.currentFrame=0,void(this.displayObject.texture=n.sprites[this.currentFrame].texture2D);var a=Math.floor(s/r),h=n.sprites.length;if(h>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var c=h-1;this.currentFrame=c-Math.abs(c-a%(2*c))}else this.currentFrame=a%h;this.displayObject.texture=n.sprites[this.currentFrame].texture2D}},r.prototype.addAnimation=function(t,e){return!this.sprite&&e.sprites.length>0&&this.setSprite(e.sprites[0]),this._animations[t]=e,this},r.prototype.play=function(t,n){void 0===n&&(n=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=i.running,this.displayObject.texture=this.currentAnimation.sprites[0].texture2D,this._elapsedTime=0,this._loopMode=n||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=i.paused},r.prototype.unPause=function(){this.animationState=i.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=i.none},r}(t.SpriteRenderer);t.SpriteAnimator=n}(es||(es={})),function(t){var e=egret.Bitmap,i=function(i){function n(e){void 0===e&&(e=null);var n=i.call(this)||this;n.displayObject=new egret.DisplayObjectContainer,n.displayObjectCache=new Map;for(var r=0,o=e;r>6;0!=(e&t.LONG_MASK)&&i++,this._bits=new Array(i)}return t.prototype.and=function(t){for(var e,i=Math.min(this._bits.length,t._bits.length),n=0;n=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var i=this._bits[e];if(0!=i)if(-1!=i){var n=((i=((i=(i>>1&0x5555555555555400)+(0x5555555555555400&i))>>2&0x3333333333333400)+(0x3333333333333400&i))>>32)+i;t+=((n=((n=(n>>4&252645135)+(252645135&n))>>8&16711935)+(16711935&n))>>16&65535)+(65535&n)}else t+=64}return t},t.prototype.clear=function(t){if(null!=t){var e=t>>6;this.ensure(e),this._bits[e]&=~(1<>6;return!(e>=this._bits.length)&&0!=(this._bits[e]&1<=0;)if(0!=(this._bits[e]&t._bits[e]))return!0;return!1},t.prototype.isEmpty=function(){for(var t=this._bits.length-1;t>=0;t--)if(this._bits[t])return!1;return!0},t.prototype.nextSetBit=function(t){for(var e=t>>6,i=1<>6;this.ensure(i),this._bits[i]|=1<=this._bits.length){var e=new Number[t+1];e=this._bits.copyWithin(0,0,this._bits.length),this._bits=e}},t.LONG_MASK=63,t}();t.BitSet=e}(es||(es={})),function(t){var e=function(){function e(e){this._components=new t.FastList,this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=e}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components.buffer},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(t){this._componentsToRemove.contains(t)&&console.warn("您正在尝试删除一个您已经删除的组件("+t+")"),this._componentsToAdd.contains(t)?this._componentsToAdd.remove(t):this._componentsToRemove.push(t)},e.prototype.removeAllComponents=function(){for(var t=0;t0){for(var i=0;i0){i=0;for(var n=this._componentsToAdd.length;i0){for(var e=0,i=this._entitiesToRemove;e0;){(n=this._addToSceneEntityList.shift()).onAddedToScene()}if(this._entitiesToAdded.length>0)if(this.frameAllocate&&this._entitiesToAdded.length>this.maxAllocate){for(var r=0;r0;)this.perEntityAddToScene();this._isEntityListUnsorted=!0}this._isEntityListUnsorted&&(this._entities.sort(function(t,e){return t.compareTo(e)}),this._isEntityListUnsorted=!1),0==this._addToSceneEntityList.length&&this._unsortedTags.size>0&&(this._unsortedTags.forEach(function(e){t._entityDict.get(e).sort(function(t,e){return t.compareTo(e)})}),this._unsortedTags.clear())},e.prototype.perEntityAddToScene=function(){var t=this._entitiesToAdded.shift();this._addToSceneEntityList.push(t),-1==this._entities.findIndex(function(e){return e.id==t.id})&&(this._entities.push(t),t.scene=this.scene,this.addToTagList(t),this.scene.entityProcessors.onEntityAdded(t))},e.prototype.findEntity=function(t){for(var e=0;ethis._buckets.length){this._buckets=new Array(t.HashHelpers.expandPrime(this._collisions)),this._collisions=0;for(var l=0;l=e?t%e:t},e}();t.FasterDictionary=e;var i=function(){return function(t,e,i){void 0===i&&(i=-1),this.key=t,this.hashcode=e,this.previous=i,this.next=-1}}();t.FastNode=i}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=5),this.length=0,this.buffer=new Array(t)}return e.prototype.clear=function(){this.buffer.length=0,this.length=0},e.prototype.reset=function(){this.length=0},e.prototype.add=function(t){this.length==this.buffer.length&&(this.buffer.length=Math.max(this.buffer.length<<1,10)),this.buffer[this.length++]=t},e.prototype.remove=function(e){for(var i=t.EqualityComparer.default(),n=0;n=this.length)throw new Error("index超出范围!");this.length--,this.buffer.removeAt(t)},e.prototype.contains=function(e){for(var i=t.EqualityComparer.default(),n=0;n=this.buffer.length&&(this.buffer.length=Math.max(this.buffer.length<<1,this.length+t))},e.prototype.addRange=function(t){for(var e=0,i=t;e=t)return i}for(e=1|t;ethis.maxPrimeArrayLength&&this.maxPrimeArrayLength>t?this.maxPrimeArrayLength:this.getPrime(e)},t.getHashCode=function(t){var e,i=0;if(0==(e="object"==typeof t?JSON.stringify(t):t.toString()).length)return i;for(var n=0;n=0;e=this.allSet.nextSetBit(e+1))if(!t.componentBits.get(e))return!1;return!(!this.exclusionSet.isEmpty()&&this.exclusionSet.intersects(t.componentBits))&&!(!this.oneSet.isEmpty()&&!this.oneSet.intersects(t.componentBits))},e.prototype.all=function(){for(var e=this,i=[],n=0;n0){for(var t=0,i=this._unsortedRenderLayers.length;t=e)return t;var n=!1;"-"==t.substr(0,1)&&(n=!0,t=t.substr(1));for(var r=e-i,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,i,n){void 0===n&&(n=!0),e=Math.floor(e),i=Math.floor(i);var r=t.length;e>r&&(e=r);var o,s=e,a=e+i;return n?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-i)+i,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var i=0,n=e.length;i",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,i){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var n=e.$getTextureWidth(),r=e.$getTextureHeight();i||((i=egret.$TempRectangle).x=0,i.y=0,i.width=n,i.height=r),i.x=Math.min(i.x,n-1),i.y=Math.min(i.y,r-1),i.width=Math.min(i.width,n-i.x),i.height=Math.min(i.height,r-i.y);var o=Math.floor(i.width),s=Math.floor(i.height),a=this.sharedCanvas;if(a.style.width=o+"px",a.style.height=s+"px",this.sharedCanvas.width=o,this.sharedCanvas.height=s,"webgl"==egret.Capabilities.renderMode){var h=void 0;e.$renderBuffer?h=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(h=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var c=h.$renderBuffer.getPixels(i.x,i.y,o,s),u=0,l=0,p=0;p=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+i,success:function(t){}}),o},e.getPixel32=function(t,e,i){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,i)},e.getPixels=function(t,e,i,n,r){if(void 0===n&&(n=1),void 0===r&&(r=1),"webgl"==egret.Capabilities.renderMode){var o=void 0;return t.$renderBuffer?o=t:(o=new egret.RenderTexture).drawToTexture(new egret.Bitmap(t)),o.$renderBuffer.getPixels(e,i,n,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,i,n,r).data}catch(t){egret.$error(1039)}},e}();t.TextureUtils=e}(es||(es={})),function(t){var e=function(){function t(){}return t.update=function(t){var e=(t-this._lastTime)/1e3;this.deltaTime=e*this.timeScale,this.unscaledDeltaTime=e,this._timeSinceSceneLoad+=e,this.frameCount++,this._lastTime=t},t.sceneChanged=function(){this._timeSinceSceneLoad=0},t.checkEvery=function(t){return Math.floor(this._timeSinceSceneLoad/t)>Math.floor((this._timeSinceSceneLoad-this.deltaTime)/t)},t.deltaTime=0,t.timeScale=1,t.frameCount=0,t._lastTime=0,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),i=t.getMonth()+1;return parseInt(e+(i<10?"0":"")+i)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,i=e<10?"0":"",n=t.getDate(),r=n<10?"0":"";return parseInt(t.getFullYear()+i+e+r+n)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var i=new Date;i.setTime(t.getTime()),i.setDate(1),i.setMonth(0);var n=i.getFullYear(),r=i.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,i.setDate(i.getDate()-(r-1))):i.setDate(i.getDate()+7-r+1);var s=this.diffDay(t,i,!1);if(s<0)return i.setDate(1),i.setMonth(0),i.setDate(i.getDate()-1),this.weekId(i,!1);var a=s/7,h=Math.floor(a)+1;if(53==h){i.setTime(t.getTime()),i.setDate(i.getDate()-1);var c=i.getDay();if(0==c&&(c=7),e&&(!o||c<4))return i.setFullYear(i.getFullYear()+1),i.setDate(1),i.setMonth(0),this.weekId(i,!1)}return parseInt(n+"00"+(h>9?"":"0")+h)},t.diffDay=function(t,e,i){void 0===i&&(i=!1);var n=(t.getTime()-e.getTime())/864e5;return i?Math.ceil(n):Math.floor(n)},t.getFirstDayOfWeek=function(t){var e=(t=t||new Date).getDay()||7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+1-e,0,0,0,0)},t.getFirstOfDay=function(t){return(t=t||new Date).setHours(0,0,0,0),t},t.getNextFirstOfDay=function(t){return new Date(this.getFirstOfDay(t).getTime()+864e5)},t.formatDate=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();return e+"-"+i+"-"+(n=n<10?"0"+n:n)},t.formatDateTime=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();n=n<10?"0"+n:n;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+i+"-"+n+" "+r+":"+o+":"+(s=s<10?"0"+s:s)},t.parseDate=function(t){var e=Date.parse(t);return isNaN(e)?new Date:new Date(Date.parse(t.replace(/-/g,"/")))},t.secondToTime=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===i&&(i=!0);var n=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=n.toString(),a=r.toString(),h=o.toString();return n<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(h="0"+h),i?s+e+a+e+h:a+e+h},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var i=t.split(e),n=0,r=i.length,o=0;o-1?this.os="iOS":n.indexOf("android")>-1&&(this.os="Android");var r=i.language;r=r.indexOf("zh")>-1?"zh-CN":"en-US",this.language=r}},e}(egret.Capabilities);t.GraphicsCapabilities=e}(es||(es={})),function(t){var e=function(){function e(){this.setup(),this.graphicsCapabilities=new t.GraphicsCapabilities,this.graphicsCapabilities.initialize(this)}return Object.defineProperty(e.prototype,"viewport",{get:function(){return this._viewport},enumerable:!0,configurable:!0}),e.prototype.setup=function(){this._viewport=new t.Viewport(0,0,t.Core._instance.stage.stageWidth,t.Core._instance.stage.stageHeight)},e}();t.GraphicsDevice=e}(es||(es={})),function(t){var e=function(){function e(t,e,i,n){this._x=t,this._y=e,this._width=i,this._height=n,this._minDepth=0,this._maxDepth=1}return Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return 0!=this._height&&0!=this._width?this._width/this._height:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bounds",{get:function(){return new t.Rectangle(this._x,this._y,this._width,this._height)},set:function(t){this._x=t.x,this._y=t.y,this._width=t.width,this._height=t.height},enumerable:!0,configurable:!0}),e}();t.Viewport=e}(es||(es={})),function(t){var e=function(e){function i(){return e.call(this,t.PostProcessor.default_vert,i.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(i,e),i.blur_frag="precision mediump float;\nuniform sampler2D uSampler;\nuniform float screenWidth;\nuniform float screenHeight;\nfloat normpdf(in float x, in float sigma)\n{\nreturn 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n}\nvoid main()\n{\nvec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\nconst int mSize = 11;\nconst int kSize = (mSize - 1)/2;\nfloat kernel[mSize];\nvec3 final_colour = vec3(0.0);\nfloat sigma = 7.0;\nfloat z = 0.0;\nfor (int j = 0; j <= kSize; ++j)\n{\nkernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n}\nfor (int j = 0; j < mSize; ++j)\n{\nz += kernel[j];\n}\nfor (int i = -kSize; i <= kSize; ++i)\n{\nfor (int j = -kSize; j <= kSize; ++j)\n{\nfinal_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n}\n}\ngl_FragColor = vec4(final_colour/(z*z), 1.0);\n}",i}(egret.CustomFilter);t.GaussianBlurEffect=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,e.vertSrc,e.fragmentSrc)||this}return __extends(e,t),e.vertSrc="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e.fragmentSrc="precision lowp float;\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n#define SAMPLE_COUNT 15\nuniform vec2 _sampleOffsets[SAMPLE_COUNT];\nuniform float _sampleWeights[SAMPLE_COUNT];\nvoid main(void) {\nvec4 c = vec4(0, 0, 0, 0);\nfor( int i = 0; i < SAMPLE_COUNT; i++ )\n c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\ngl_FragColor = c;\n}",e}(egret.CustomFilter);t.PolygonLightEffect=e}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=null),this.enabled=!0,this.effect=t}return e.prototype.onAddedToScene=function(e){this.scene=e,this.shape=new egret.Shape,this.shape.graphics.beginFill(16777215,1),this.shape.graphics.drawRect(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),this.shape.graphics.endFill(),e.addChild(this.shape)},e.prototype.process=function(){this.drawFullscreenQuad()},e.prototype.onSceneBackBufferSizeChanged=function(t,e){},e.prototype.unload=function(){this.effect&&(this.effect=null),this.scene.removeChild(this.shape),this.scene=null},e.prototype.drawFullscreenQuad=function(){this.scene.filters=[this.effect]},e.default_vert="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec2 aColor;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\ngl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\nvTextureCoord = aTextureCoord;\nvColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n}",e}();t.PostProcessor=e}(es||(es={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToScene=function(i){e.prototype.onAddedToScene.call(this,i),this.effect=new t.GaussianBlurEffect},i}(t.PostProcessor);t.GaussianBlurPostProcessor=e}(es||(es={})),function(t){var e=function(){function t(t,e){void 0===e&&(e=null),this.renderOrder=0,this.shouldDebugRender=!0,this.camera=e,this.renderOrder=t}return Object.defineProperty(t.prototype,"wantsToRenderToSceneRenderTarget",{get:function(){return!!this.renderTexture},enumerable:!0,configurable:!0}),t.prototype.onAddedToScene=function(t){},t.prototype.unload=function(){},t.prototype.onSceneBackBufferSizeChanged=function(t,e){},t.prototype.compareTo=function(t){return this.renderOrder-t.renderOrder},t.prototype.beginRender=function(t){},t.prototype.renderAfterStateCheck=function(t,e){t.render(e)},t.prototype.debugRender=function(t,e){for(var i=0;i=0&&h=0&&ci?i:t},e.pointOnCirlce=function(i,n,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+i.x,Math.sin(o)*o+i.y)},e.isEven=function(t){return t%2==0},e.clamp01=function(t){return t<0?0:t>1?1:t},e.angleBetweenVectors=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e.incrementWithWrap=function(t,e){return++t==e?0:t},e.approach=function(t,e,i){return tn&&(n=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,i,n,r)},i.prototype.intersects=function(t){return t.leftthis.x+this.width)return!1}else{var n=1/t.direction.x,r=(this.x-t.start.x)*n,o=(this.x+this.width-t.start.x)*n;if(r>o){var s=r;r=o,o=s}if(e.value=Math.max(r,e.value),i=Math.min(o,i),e.value>i)return!1}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return!1}else{var a=1/t.direction.y,h=(this.y-t.start.y)*a,c=(this.y+this.height-t.start.y)*a;if(h>c){var u=h;h=c,c=u}if(e.value=Math.max(h,e.value),i=Math.max(c,i),e.value>i)return!1}return!0},i.prototype.containsRect=function(t){return this.x<=t.x&&t.x1)return!1;var u=(h.x*o.y-h.y*o.x)/a;return!(u<0||u>1)},i.lineToLineIntersection=function(e,i,n,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(i,e),a=t.Vector2.subtract(r,n),h=s.x*a.y-s.y*a.x;if(0==h)return o;var c=t.Vector2.subtract(n,e),u=(c.x*a.y-c.y*a.x)/h;if(u<0||u>1)return o;var l=(c.x*s.y-c.y*s.x)/h;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(u*s.x,u*s.y))},i.closestPointOnLine=function(e,i,n){var r=t.Vector2.subtract(i,e),o=t.Vector2.subtract(n,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,new t.Vector2(r.x*s,r.y*s))},i.circleToCircle=function(e,i,n,r){return t.Vector2.distanceSquared(e,n)<(i+r)*(i+r)},i.circleToLine=function(e,i,n,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(n,r,e))=t&&r.y>=e&&r.x=t+n&&(s|=e.right),o.y=i+r&&(s|=e.bottom),s},i}();t.Collisions=i}(es||(es={})),function(t){var e=function(){function e(e,i,n,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=i,this.distance=n,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,i,n){this.collider=t,this.fraction=e,this.distance=i,this.point=n},e.prototype.setValuesNonCollider=function(t,e,i,n){this.fraction=t,this.distance=e,this.point=i,this.normal=n},e.prototype.reset=function(){this.collider=null,this.fraction=this.distance=0},e.prototype.toString=function(){return"[RaycastHit] fraction: "+this.fraction+", distance: "+this.distance+", normal: "+this.normal+", centroid: "+this.centroid+", point: "+this.point},e}();t.RaycastHit=e}(es||(es={})),function(t){var e=function(){function e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,i,n){if(void 0===n&&(n=-1),0!=i.length)return this._spatialHash.overlapCircle(t,e,i,n);console.error("An empty results array was passed in. No results will ever be returned.")},e.boxcastBroadphase=function(t,e){return void 0===e&&(e=this.allLayers),this._spatialHash.aabbBroadphase(t,null,e)},e.boxcastBroadphaseExcludingSelf=function(t,e,i){return void 0===i&&(i=this.allLayers),this._spatialHash.aabbBroadphase(e,t,i)},e.addCollider=function(t){e._spatialHash.register(t)},e.removeCollider=function(t){e._spatialHash.remove(t)},e.updateCollider=function(t){this._spatialHash.remove(t),this._spatialHash.register(t)},e.linecast=function(t,i,n){return void 0===n&&(n=e.allLayers),this._hitArray[0].reset(),this.linecastAll(t,i,this._hitArray,n),this._hitArray[0]},e.linecastAll=function(t,i,n,r){return void 0===r&&(r=e.allLayers),0==n.length?(console.warn("传入了一个空的hits数组。没有点击会被返回"),0):this._spatialHash.linecast(t,i,n,r)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e._hitArray=[new t.RaycastHit],e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,i){this.start=e,this.end=i,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=100),this.gridBounds=new t.Rectangle,this._overlapTestCircle=new t.Circle(0),this._cellDict=new i,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new n}return e.prototype.register=function(e){var i=e.bounds;e.registeredPhysicsBounds=i;var n=this.cellCoords(i.x,i.y),r=this.cellCoords(i.right,i.bottom);this.gridBounds.contains(n.x,n.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,n)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=n.x;o<=r.x;o++)for(var s=n.y;s<=r.y;s++){var a=this.cellAtPosition(o,s,!0);a.firstOrDefault(function(t){return t.hashCode==e.hashCode})||a.push(e)}},e.prototype.remove=function(t){for(var e=t.registeredPhysicsBounds,i=this.cellCoords(e.x,e.y),n=this.cellCoords(e.right,e.bottom),r=i.x;r<=n.x;r++)for(var o=i.y;o<=n.y;o++){var s=this.cellAtPosition(r,o);s?s.remove(t):console.log("从不存在碰撞器的单元格中移除碰撞器: ["+t+"]")}},e.prototype.removeWithBruteForce=function(t){this._cellDict.remove(t)},e.prototype.clear=function(){this._cellDict.clear()},e.prototype.debugDraw=function(t,e){void 0===e&&(e=1);for(var i=this.gridBounds.x;i<=this.gridBounds.right;i++)for(var n=this.gridBounds.y;n<=this.gridBounds.bottom;n++){var r=this.cellAtPosition(i,n);r&&r.length>0&&this.debugDrawCellDetails(i,n,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,i,n){this._tempHashSet.length=0;for(var r=this.cellCoords(e.x,e.y),o=this.cellCoords(e.right,e.bottom),s=r.x;s<=o.x;s++)for(var a=r.y;a<=o.y;a++){var h=this.cellAtPosition(s,a);if(h)for(var c=function(r){var o=h[r];if(o==i||!t.Flags.isFlagSet(n,o.physicsLayer.value))return"continue";e.intersects(o.bounds)&&(u._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||u._tempHashSet.push(o))},u=this,l=0;l=this.points.length?this.points[0]:this.points[n+1];var o=t.Vector2Ext.perpendicular(r,e);t.Vector2Ext.normalize(o),this._edgeNormals[n]=o}},i.buildSymmetricalPolygon=function(e,i){for(var n=new Array(e),r=0;rr&&(r=s,n=o)}return e[n]},i.getClosestPointOnPolygonToPoint=function(e,i,n,r){n.value=Number.MAX_VALUE,r.x=0,r.y=0;for(var o=new t.Vector2(0,0),s=0,a=0;at.y!=this.points[n].y>t.y&&t.x<(this.points[n].x-this.points[i].x)*(t.y-this.points[i].y)/(this.points[n].y-this.points[i].y)+this.points[i].x&&(e=!e);return e},i.prototype.pointCollidesWithShape=function(e,i){return t.ShapeCollisions.pointToPoly(e,this,i)},i}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function i(t,n){var r=e.call(this,i.buildBox(t,n),!0)||this;return r.width=t,r.height=n,r}return __extends(i,e),i.buildBox=function(e,i){var n=e/2,r=i/2,o=new Array(4);return o[0]=new t.Vector2(-n,-r),o[1]=new t.Vector2(n,-r),o[2]=new t.Vector2(n,r),o[3]=new t.Vector2(-n,r),o},i.prototype.updateBox=function(e,i){this.width=e,this.height=i;var n=e/2,r=i/2;this.points[0]=new t.Vector2(-n,-r),this.points[1]=new t.Vector2(n,-r),this.points[2]=new t.Vector2(n,r),this.points[3]=new t.Vector2(-n,r);for(var o=0;o1)return!1;var a,h=t.Vector2.add(s.start,t.Vector2.add(s.direction,new t.Vector2(r.value))),c=0;h.xi.bounds.right&&(c|=1),h.yi.bounds.bottom&&(c|=2);var u=a+c;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),!0},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,i,n){for(var r,o=!0,s=e.edgeNormals,a=i.edgeNormals,h=Number.POSITIVE_INFINITY,c=new t.Vector2,u=t.Vector2.subtract(e.position,i.position),l=0;l0&&(o=!1),!o)return!1;(g=Math.abs(g))r&&(r=o);return{min:n,max:r}},e.circleToPolygon=function(e,i,n){var r,o=t.Vector2.subtract(e.position,i.position),s=new t.Ref(0),a=t.Polygon.getClosestPointOnPolygonToPoint(i.points,o,s,n.normal),h=i.containsPoint(e.position);if(s.value>e.radius*e.radius&&!h)return!1;if(h)r=t.Vector2.multiply(n.normal,new t.Vector2(Math.sqrt(s.value)-e.radius));else if(0==s.value)r=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else{var c=Math.sqrt(s.value);r=t.Vector2.multiply(new t.Vector2(-t.Vector2.subtract(o,a)),new t.Vector2((e.radius-s.value)/c))}return n.minimumTranslationVector=r,n.point=t.Vector2.add(a,i.position),!0},e.circleToBox=function(e,i,n){var r=i.bounds.getClosestPointOnRectangleBorderToPoint(e.position,n.normal);if(i.containsPoint(e.position)){n.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(n.normal,new t.Vector2(e.radius)));return n.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)n.minimumTranslationVector=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){n.normal=t.Vector2.subtract(e.position,r);var a=n.normal.length()-e.radius;return n.point=r,t.Vector2Ext.normalize(n.normal),n.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),n.normal),!0}return!1},e.pointToCircle=function(e,i,n){var r=t.Vector2.distanceSquared(e,i.position),o=1+i.radius;if(r1)return!1;var l=(c.x*s.y-c.y*s.x)/h;return!(l<0||l>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(u),s)),!0)},e.lineToCircle=function(e,i,n,r){var o=t.Vector2.distance(e,i),s=t.Vector2.divide(t.Vector2.subtract(i,e),new t.Vector2(o)),a=t.Vector2.subtract(e,n.position),h=t.Vector2.dot(a,s),c=t.Vector2.dot(a,a)-n.radius*n.radius;if(c>0&&h>0)return!1;var u=h*h-c;return!(u<0)&&(r.fraction=-h-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,n.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,i,n,r){var o=this.minkowskiDifference(e,i);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-n.x)),h=new t.Ref(0);return!!(o.rayIntersects(a,h)&&h.value<=1)&&(r.fraction=h.value,r.distance=n.length()*h.value,r.normal=new t.Vector2(-n.x,-n.y),r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(n,new t.Vector2(h.value))),!0)},e}();t.ShapeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){this.mass=1,this.radius=0,this.collidesWithColliders=!0}return e.prototype.applyForce=function(e){this.acceleration.add(t.Vector2.divide(e,new t.Vector2(this.mass)))},e}();t.Particle=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=null),this.gravity=new t.Vector2(0,980),this.constraintIterations=3,this.maximumStepIterations=5,this.allowDragging=!0,this._composites=[],this._tempCircle=new t.Circle(1),this._leftOverTime=0,this._fixedDeltaTime=1/60,this._iterationSteps=0,this._fixedDeltaTimeSq=0,this.simulationBounds=e,this._fixedDeltaTimeSq=Math.pow(this._fixedDeltaTimeSq,2)}return e.prototype.update=function(){this.updateTiming(),this.allowDragging&&this.handleDragging();for(var t=1;t<=this._iterationSteps;t++)for(var e=this._composites.length-1;e>=0;e--){for(var i=this._composites[e],n=0;ni.height?e.y=i.height:e.yi.width&&(e.x=i.width)):(e.yi.height-t.radius&&(e.y=2*(i.height-t.radius)-e.y),e.x>i.width-t.radius&&(e.x=2*(i.width-t.radius)-e.x),e.x=0;t--)this._constraints[t].solve()},e.prototype.updateParticles=function(e,i){for(var n=0;n=0;t--)this._constraints[t].collidesWithColliders&&this._constraints[t].handleCollisions(this.collidesWithLayers)},e.prototype.debugRender=function(t){},e}();t.Composite=e}(es||(es={})),function(t){var e=function(){function t(){this.collidesWithColliders=!0}return t.prototype.handleCollisions=function(t){},t}();t.Constraint=e}(es||(es={}));var ArrayUtils=function(){function t(){}return t.bubbleSort=function(t){for(var e=!1,i=0;ii;n--)if(t[n]0&&t[r-1]>n;r--)t[r]=t[r-1];t[r]=n}},t.binarySearch=function(t,e){for(var i=0,n=t.length,r=i+n>>1;i=t[r]&&(i=r+1),r=i+n>>1;return t[i]==e?i:-1},t.findElementIndex=function(t,e){for(var i=t.length,n=0;nt[e]&&(e=n);return e},t.getMinElementIndex=function(t){for(var e=0,i=t.length,n=1;n=0;--r)i.unshift(e[r]);return i},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var i=t.concat(e),n={},r=[],o=i.length,s=0;s=0;e-=1)t.splice(e,1)},t.cloneList=function(t){return t?t.slice(0,t.length):null},t.equals=function(t,e){if(t==e)return!0;var i=t.length;if(i!=e.length)return!1;for(;i--;)if(t[i]!=e[i])return!1;return!0},t.insert=function(t,e,i){if(!t)return null;var n=t.length;if(e>n&&(e=n),e<0&&(e=0),e==n)t.push(i);else if(0==e)t.unshift(i);else{for(var r=n-1;r>=e;r-=1)t[r+1]=t[r];t[e]=i}return i},t}();!function(t){var e=function(){function t(){}return Object.defineProperty(t,"nativeBase64",{get:function(){return"function"==typeof window.atob},enumerable:!0,configurable:!0}),t.decode=function(t){if(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),this.nativeBase64)return window.atob(t);for(var e,i,n,r,o,s,a=[],h=0;h>4,i=(15&r)<<4|(o=this._keyStr.indexOf(t.charAt(h++)))>>2,n=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(h++))),a.push(String.fromCharCode(e)),64!==o&&a.push(String.fromCharCode(i)),64!==s&&a.push(String.fromCharCode(n));return a=a.join("")},t.encode=function(t){if(t=t.replace(/\r\n/g,"\n"),!this.nativeBase64){for(var e,i,n,r,o,s,a,h=[],c=0;c>2,o=(3&e)<<4|(i=t.charCodeAt(c++))>>4,s=(15&i)<<2|(n=t.charCodeAt(c++))>>6,a=63&n,isNaN(i)?s=a=64:isNaN(n)&&(a=64),h.push(this._keyStr.charAt(r)),h.push(this._keyStr.charAt(o)),h.push(this._keyStr.charAt(s)),h.push(this._keyStr.charAt(a));return h=h.join("")}window.btoa(t)},t.decodeBase64AsArray=function(e,i){i=i||1;var n,r,o,s=t.decode(e),a=new Uint32Array(s.length/i);for(n=0,o=s.length/i;n=0;--r)a[n]+=s.charCodeAt(n*i+r)<<(r<<3);return a},t.decompress=function(t,e,i){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},t.decodeCSV=function(t){for(var e=t.replace("\n","").trim().split(","),i=[],n=0;n>16},set:function(t){this._packedValue=4278255615&this._packedValue|t<<16},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this._packedValue>>8},set:function(t){this._packedValue=4294902015&this._packedValue|t<<8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"r",{get:function(){return this._packedValue},set:function(t){this._packedValue=4294967040&this._packedValue|t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a",{get:function(){return this._packedValue>>24},set:function(t){this._packedValue=16777215&this._packedValue|t<<24},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"packedValue",{get:function(){return this._packedValue},set:function(t){this._packedValue=t},enumerable:!0,configurable:!0}),e.prototype.equals=function(t){return this._packedValue==t._packedValue},e}();t.Color=e}(es||(es={})),function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var i=this;return void 0===e&&(e=!0),new Promise(function(n,r){var o=i.loadedAssets.get(t);o?n(o):e?RES.getResAsync(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){var e=t;RES.destroyRes(e)&&e.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function t(){}return t.getColorMatrix=function(t){var e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];return e[0]=Math.floor(t/256/256)/255,e[6]=Math.floor(t/256%256)/255,e[12]=t%256/255,new egret.ColorMatrixFilter(e)},t}();t.DrawUtils=e}(es||(es={})),function(t){var e=function(){function e(){}return e.oppositeEdge=function(e){switch(e){case t.Edge.bottom:return t.Edge.top;case t.Edge.top:return t.Edge.bottom;case t.Edge.left:return t.Edge.right;case t.Edge.right:return t.Edge.left}},e.isHorizontal=function(e){return e==t.Edge.right||e==t.Edge.left},e.isVertical=function(e){return e==t.Edge.top||e==t.Edge.bottom},e}();t.EdgeExt=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var i=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,i,n){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==i})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(i,n))},t.prototype.removeObserver=function(t,e){var i=this._messageTable.get(t),n=i.findIndex(function(t){return t.func==e});-1!=n&&i.removeAt(n)},t.prototype.emit=function(t,e){var i=this._messageTable.get(t);if(i)for(var n=i.length-1;n>=0;n--)i[n].func.call(i[n].context,e)},t}();t.Emitter=i}(es||(es={})),function(t){!function(t){t[t.top=0]="top",t[t.bottom=1]="bottom",t[t.left=2]="left",t[t.right=3]="right"}(t.Edge||(t.Edge={}))}(es||(es={})),function(t){var e=function(){function t(){}return t.repeat=function(t,e){for(var i=[];e--;)i.push(t);return i},t}();t.Enumerable=e}(es||(es={})),function(t){var e=function(){function t(){}return t.default=function(){return new t},t.prototype.equals=function(t,e){return"function"==typeof t.equals?t.equals(e):t===e},t}();t.EqualityComparer=e}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.setEnabled=function(t){this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled())},t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.update=function(){},t}();t.GlobalManager=e}(es||(es={})),function(t){var e=function(){function t(){}return t.warmCache=function(t){if((t-=this._objectQueue.length)>0)for(var e=0;ethis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(){return this._objectQueue.length>0?this._objectQueue.shift():[]},t.free=function(t){this._objectQueue.unshift(t),t.length=0},t._objectQueue=[],t}();t.ListPool=e}(es||(es={})),function(t){var e=function(){function t(){}return t.toNumber=function(t){return null==t?0:Number(t)},t}();t.NumberExtension=e}(es||(es={})),function(t){var e=function(){function t(t,e){this.first=t,this.second=e}return t.prototype.clear=function(){this.first=this.second=null},t.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},t}();t.Pair=e}(es||(es={})),function(t){var e=function(){function t(){}return t.warmCache=function(t,e){if((e-=this._objectQueue.length)>0)for(var i=0;ithis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(t){return this._objectQueue.length>0?this._objectQueue.shift():new t},t.free=function(t){this._objectQueue.unshift(t),egret.is(t,"IPoolable")&&t.reset()},t._objectQueue=[],t}();t.Pool=e}(es||(es={}));var RandomUtils=function(){function t(){}return t.randrange=function(t,e,i){if(void 0===i&&(i=1),0==i)throw new Error("step 不能为 0");var n=e-t;if(0==n)throw new Error("没有可用的范围("+t+","+e+")");n<0&&(n=t-e);var r=Math.floor((n+i-1)/i);return Math.floor(this.random()*r)*i+Math.min(t,e)},t.randint=function(t,e){return(t=Math.floor(t))>(e=Math.floor(e))?t++:e++,this.randrange(t,e)},t.randnum=function(t,e){return this.random()*(e-t)+t},t.shuffle=function(t){return t.sort(this._randomCompare),t},t.choice=function(t){if(!t.hasOwnProperty("length"))throw new Error("无法对此对象执行此操作");var e=Math.floor(this.random()*t.length);return t instanceof String?String(t).charAt(e):t[e]},t.sample=function(t,e){var i=t.length;if(e<=0||i=0;)s=Math.floor(this.random()*i);n.push(t[s]),r.push(s)}return n},t.random=function(){return Math.random()},t.boolean=function(t){return void 0===t&&(t=.5),this.random().5?1:-1},t}();!function(t){var e=function(){function e(){}return e.getSide=function(e,i){switch(i){case t.Edge.top:return e.top;case t.Edge.bottom:return e.bottom;case t.Edge.left:return e.left;case t.Edge.right:return e.right}},e.union=function(e,i){var n=new t.Rectangle(i.x,i.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,n.x),r.y=Math.min(e.y,n.y),r.width=Math.max(e.right,n.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e.getHalfRect=function(e,i){switch(i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,e.height/2);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height/2,e.width,e.height/2);case t.Edge.left:return new t.Rectangle(e.x,e.y,e.width/2,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width/2,e.y,e.width/2,e.height)}},e.getRectEdgePortion=function(e,i,n){switch(void 0===n&&(n=1),i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,n);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-n,e.width,n);case t.Edge.left:return new t.Rectangle(e.x,e.y,n,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-n,e.y,n,e.height)}},e.expandSide=function(e,i,n){switch(n=Math.abs(n),i){case t.Edge.top:e.y-=n,e.height+=n;break;case t.Edge.bottom:e.height+=n;break;case t.Edge.left:e.x-=n,e.width+=n;break;case t.Edge.right:e.width+=n}},e.contract=function(t,e,i){t.x+=e,t.y+=i,t.width-=2*e,t.height-=2*i},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.update=function(t){this.remainder+=t;var e=Math.trunc(this.remainder);return this.remainder-=e,e},t.prototype.reset=function(){this.remainder=0},t}();t.SubpixelNumber=e}(es||(es={})),function(t){var e=function(){function e(){this.triangleIndices=[],this._triPrev=new Array(12),this._triNext=new Array(12)}return e.testPointTriangle=function(e,i,n,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(n,i))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(r,n))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(i,r))<0))},e.prototype.triangulate=function(i,n){void 0===n&&(n=!0);var r=i.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,h=i[this._triPrev[s]],c=i[s],u=i[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(h,c,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(i[l],h,c,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),n||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e.divide(new t.Vector2(i)):e.x=e.y=0},e.transformA=function(t,e,i,n,r,o){for(var s=0;sthis.safeArea.right&&(s.x=this.safeArea.right-s.width),s.topthis.safeArea.bottom&&(s.y=this.safeArea.bottom-s.height),s},i}();t.Layout=i,function(t){t[t.none=0]="none",t[t.left=1]="left",t[t.right=2]="right",t[t.horizontalCenter=4]="horizontalCenter",t[t.top=8]="top",t[t.bottom=16]="bottom",t[t.verticalCenter=32]="verticalCenter",t[t.topLeft=9]="topLeft",t[t.topRight=10]="topRight",t[t.topCenter=12]="topCenter",t[t.bottomLeft=17]="bottomLeft",t[t.bottomRight=18]="bottomRight",t[t.bottomCenter=20]="bottomCenter",t[t.centerLeft=33]="centerLeft",t[t.centerRight=34]="centerRight",t[t.center=36]="center"}(e=t.Alignment||(t.Alignment={}))}(es||(es={})),function(t){var e,i=function(){function t(t){void 0===t&&(t=n),this.getSystemTime=t,this._stopDuration=0,this._completeSlices=[]}return t.prototype.getState=function(){return void 0===this._startSystemTime?e.IDLE:void 0===this._stopSystemTime?e.RUNNING:e.STOPPED},t.prototype.isIdle=function(){return this.getState()===e.IDLE},t.prototype.isRunning=function(){return this.getState()===e.RUNNING},t.prototype.isStopped=function(){return this.getState()===e.STOPPED},t.prototype.slice=function(){return this.recordPendingSlice()},t.prototype.getCompletedSlices=function(){return Array.from(this._completeSlices)},t.prototype.getCompletedAndPendingSlices=function(){return this._completeSlices.concat([this.getPendingSlice()])},t.prototype.getPendingSlice=function(){return this.calculatePendingSlice()},t.prototype.getTime=function(){return this.caculateStopwatchTime()},t.prototype.reset=function(){this._startSystemTime=this._pendingSliceStartStopwatchTime=this._stopSystemTime=void 0,this._stopDuration=0,this._completeSlices=[]},t.prototype.start=function(t){if(void 0===t&&(t=!1),t&&this.reset(),void 0!==this._stopSystemTime){var e=(i=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var i=this.getSystemTime();this._startSystemTime=i,this._pendingSliceStartStopwatchTime=0}},t.prototype.stop=function(t){if(void 0===t&&(t=!1),void 0===this._startSystemTime)return 0;var e=this.getSystemTimeOfCurrentStopwatchTime();return t&&this.recordPendingSlice(this.caculateStopwatchTime(e)),this._stopSystemTime=e,this.getTime()},t.prototype.calculatePendingSlice=function(t){return void 0===this._pendingSliceStartStopwatchTime?Object.freeze({startTime:0,endTime:0,duration:0}):(void 0===t&&(t=this.getTime()),Object.freeze({startTime:this._pendingSliceStartStopwatchTime,endTime:t,duration:t-this._pendingSliceStartStopwatchTime}))},t.prototype.caculateStopwatchTime=function(t){return void 0===this._startSystemTime?0:(void 0===t&&(t=this.getSystemTimeOfCurrentStopwatchTime()),t-this._startSystemTime-this._stopDuration)},t.prototype.getSystemTimeOfCurrentStopwatchTime=function(){return void 0===this._stopSystemTime?this.getSystemTime():this._stopSystemTime},t.prototype.recordPendingSlice=function(t){if(void 0!==this._pendingSliceStartStopwatchTime){void 0===t&&(t=this.getTime());var e=this.calculatePendingSlice(t);return this._pendingSliceStartStopwatchTime=e.endTime,this._completeSlices.push(e),e}return this.calculatePendingSlice()},t}();t.Stopwatch=i,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),n=t};var n=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._rectShape1=new egret.Shape,this._rectShape2=new egret.Shape,this._rectShape3=new egret.Shape,this._rectShape4=new egret.Shape,this._rectShape5=new egret.Shape,this._rectShape6=new egret.Shape,this.logs=new Array(2);for(var e=0;e=e.logSnapDuration&&(u.logs[n].snapMin=u.logs[n].min,u.logs[n].snapMax=u.logs[n].max,u.logs[n].snapAvg=u.logs[n].avg,u.logs[n].samples=0)):(u.logs[n].min=h,u.logs[n].max=h,u.logs[n].avg=h,u.logs[n].initialized=!0)}o.markCount=r.nestCount,o.nestCount=r.nestCount}this.stopwacth.reset(),this.stopwacth.start()}},e.prototype.beginMark=function(t,i,n){if(void 0===n&&(n=0),n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var r=this.curLog.bars[n];if(r.markCount>=e.maxSamples)throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数");if(r.nestCount>=e.maxNestCall)throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数");var s=this._markerNameToIdMap.get(t);isNaN(s)&&(s=this.markers.length,this._markerNameToIdMap.set(t,s),this.markers.push(new o(t))),r.markerNests[r.nestCount++]=r.markCount,r.markers[r.markCount].markerId=s,r.markers[r.markCount].color=i,r.markers[r.markCount].beginTime=this.stopwacth.getTime(),r.markers[r.markCount].endTime=-1,r.markCount++},e.prototype.endMark=function(t,i){if(void 0===i&&(i=0),i<0||i>=e.maxBars)throw new Error("barIndex参数超出范围");var n=this.curLog.bars[i];if(n.nestCount<=0)throw new Error("先调用beginMark方法,再调用endMark方法");var r=this._markerNameToIdMap.get(t);if(isNaN(r))throw new Error("标记 "+t+" 未注册。请确认您指定的名称与 beginMark 方法使用的名称相同");var o=n.markerNests[--n.nestCount];if(n.markers[o].markerId!=r)throw new Error("beginMark/endMark方法的调用顺序不正确,beginMark(A),beginMark(B),endMark(B),endMark(A),但你不能像beginMark(A),beginMark(B),endMark(A),endMark(B)这样调用。");n.markers[o].endTime=this.stopwacth.getTime()},e.prototype.getAverageTime=function(t,i){if(t<0||t>=e.maxBars)throw new Error("barIndex参数超出范围");var n=0,r=this._markerNameToIdMap.get(i);return r&&(n=this.markers[r].logs[t].avg),n},e.prototype.resetLog=function(){this.markers.forEach(function(t){for(var e=0;e0&&(r+=e.barHeight+2*e.barPadding,o=Math.max(o,t.markers[t.markCount-1].endTime))});var s=this.sampleFrames*(1/60*1e3);this._frameAdjust=o>s?Math.max(0,this._frameAdjust)+1:Math.min(0,this._frameAdjust)-1,Math.max(this._frameAdjust)>e.autoAdjustDelay&&(this.sampleFrames=Math.min(e.maxSampleFrames,this.sampleFrames),this.sampleFrames=Math.max(this.targetSampleFrames,Math.floor(o/(1/60*1e3))+1),this._frameAdjust=0);var a=n/s,h=i.y-(r-e.barHeight),c=h,u=new t.Rectangle(i.x,c,n,r);this._rectShape1.graphics.clear(),this._rectShape1.graphics.beginFill(0,128/255),this._rectShape1.graphics.drawRect(u.x,u.y,u.width,u.height),this._rectShape1.graphics.endFill(),u.height=e.barHeight,this._rectShape2.graphics.clear();for(var l=0,p=this.prevLog.bars;l0)for(var f=0;f0?(i.waitTimer-=i.useUnscaledDeltaTime?t.Time.unscaledDeltaTime:t.Time.deltaTime,this._shouldRunNextFrame.push(i)):this.tickCoroutine(i)&&this._shouldRunNextFrame.push(i)}}this._unblockedCoroutines.length=0,this._unblockedCoroutines.concat(this._shouldRunNextFrame),this._shouldRunNextFrame.length=0,this._isInUpdate=!1},n.prototype.tickCoroutine=function(i){var n=i.enumerator.next();return!n.value||n.done?(t.Pool.free(i),!1):!n.value||(n.value instanceof t.WaitForSeconds?(i.waitTimer=n.value.waitTime,!0):n.value instanceof Number?(console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"),i.waitTimer=Number(n),!0):!(n.value instanceof e)||(i.waitForCoroutine=n.value,!0))},n}(t.GlobalManager);t.CoroutineManager=i}(es||(es={})),function(t){var e=function(){function e(){this.x=0,this.y=0,this.touchPoint=-1,this.touchDown=!1}return Object.defineProperty(e.prototype,"position",{get:function(){return new t.Vector2(this.x,this.y)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.x=0,this.y=0,this.touchDown=!1,this.touchPoint=-1},e}();t.TouchState=e;var i=function(){function i(){}return Object.defineProperty(i,"gameTouchs",{get:function(){return this._gameTouchs},enumerable:!0,configurable:!0}),Object.defineProperty(i,"resolutionScale",{get:function(){return this._resolutionScale},enumerable:!0,configurable:!0}),Object.defineProperty(i,"totalTouchCount",{get:function(){return this._totalTouchCount},enumerable:!0,configurable:!0}),Object.defineProperty(i,"touchPosition",{get:function(){return this._gameTouchs[0]?this._gameTouchs[0].position:t.Vector2.zero},enumerable:!0,configurable:!0}),Object.defineProperty(i,"maxSupportedTouch",{get:function(){return t.Core._instance.stage.maxTouches},set:function(e){t.Core._instance.stage.maxTouches=e,this.initTouchCache()},enumerable:!0,configurable:!0}),Object.defineProperty(i,"touchPositionDelta",{get:function(){var e=t.Vector2.subtract(this.touchPosition,this._previousTouchState.position);return e.length()>0&&this.setpreviousTouchState(this._gameTouchs[0]),e},enumerable:!0,configurable:!0}),i.initialize=function(){this._init||(this._init=!0,t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.touchBegin,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.touchMove,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.touchEnd,this),this.initTouchCache())},i.update=function(){KeyboardUtils.update();for(var t=0;t0,this._willRepeat||(this.isRepeating=!1)},i.prototype.update=function(){this._bufferCounter-=t.Time.unscaledDeltaTime,this.isRepeating=!1;for(var e=!1,i=0;i0||this.isRepeating)return!0;for(var t=0,e=this.nodes;ta||i[c].height>a)throw new Error("一个纹理的大小比图集的大小大");h.push(new t.Rectangle(0,0,i[c].width,i[c].height))}for(;h.length>0;){var u=new egret.RenderTexture,l=new t.RectanglePacker(a,a,1);for(c=0;c0){for(var p=new t.IntegerRectangle,d=[],f=[],y=[],g=[],m=0;m0;)this.freeRectangle(this._insertedRectangles.pop());for(;this._freeAreas.length>0;)this.freeRectangle(this._freeAreas.pop());for(this._width=t,this._height=e,this._packedWidth=0,this._packedHeight=0,this._freeAreas.push(this.allocateRectangle(0,0,this._width,this._height));this._insertedRectangles.length>0;)this.freeSize(this._insertList.pop());this._padding=i},e.prototype.insertRectangle=function(t,e,i){var n=this.allocateSize(t,e,i);this._insertList.push(n)},e.prototype.packRectangles=function(t){for(void 0===t&&(t=!0),t&&this._insertList.sort(function(t,e){return t.width-e.width});this._insertList.length>0;){var e=this._insertList.pop(),i=e.width,n=e.height,r=this.getFreeAreaIndex(i,n);if(r>=0){var o=this._freeAreas[r],s=this.allocateRectangle(o.x,o.y,i,n);for(s.id=e.id,this.generateNewFreeAreas(s,this._freeAreas,this._newFreeAreas);this._newFreeAreas.length>0;)this._freeAreas.push(this._newFreeAreas.pop());this._insertedRectangles.push(s),s.right>this._packedWidth&&(this._packedWidth=s.right),s.bottom>this._packedHeight&&(this._packedHeight=s.bottom)}this.freeSize(e)}return this.rectangleCount},e.prototype.getRectangle=function(t,e){var i=this._insertedRectangles[t];return e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height,e},e.prototype.getRectangleId=function(t){return this._insertedRectangles[t].id},e.prototype.generateNewFreeAreas=function(t,e,i){var n=t.x,r=t.y,o=t.right+1+this._padding,s=t.bottom+1+this._padding,a=null;0==this._padding&&(a=t);for(var h=e.length-1;h>=0;h--){var c=e[h];if(!(n>=c.right||o<=c.x||r>=c.bottom||s<=c.y)){null==a&&(a=this.allocateRectangle(t.x,t.y,t.width+this._padding,t.height+this._padding)),this.generateDividedAreas(a,c,i);var u=e.pop();h=0;e--)for(var i=t[e],n=t.length-1;n>=0;n--)if(e!=n){var r=t[n];if(i.x>=r.x&&i.y>=r.y&&i.right<=r.right&&i.bottom<=r.bottom){this.freeRectangle(i);var o=t.pop();e0&&(i.push(this.allocateRectangle(t.right,e.y,r,e.height)),n++);var o=t.x-e.x;o>0&&(i.push(this.allocateRectangle(e.x,e.y,o,e.height)),n++);var s=e.bottom-t.bottom;s>0&&(i.push(this.allocateRectangle(e.x,t.bottom,e.width,s)),n++);var a=t.y-e.y;a>0&&(i.push(this.allocateRectangle(e.x,e.y,e.width,a)),n++),0==n&&(t.width=0;s--){var a=this._freeAreas[s];if(a.x0){var r=this._sortableSizeStack.pop();return r.width=e,r.height=i,r.id=n,r}return new t.SortableSize(e,i,n)},e.prototype.freeSize=function(t){this._sortableSizeStack.push(t)},e.prototype.allocateRectangle=function(e,i,n,r){if(this._rectangleStack.length>0){var o=this._rectangleStack.pop();return o.x=e,o.y=i,o.width=n,o.height=r,o.right=e+n,o.bottom=i+r,o}return new t.IntegerRectangle(e,i,n,r)},e.prototype.freeRectangle=function(t){this._rectangleStack.push(t)},e}();t.RectanglePacker=e}(es||(es={})),function(t){var e=function(){return function(t,e,i){this.width=t,this.height=e,this.id=i}}();t.SortableSize=e}(es||(es={})),function(t){var e=function(){return function(t){this.assets=t}}();t.TextureAssets=e;var i=function(){return function(){}}();t.TextureAsset=i}(es||(es={})),function(t){var e=function(){return function(t,e){this.texture=t,this.id=e}}();t.TextureToPack=e}(es||(es={})),function(t){var e=function(){function e(){this._timeInSeconds=0,this._repeats=!1,this._isDone=!1,this._elapsedTime=0}return e.prototype.getContext=function(){return this.context},e.prototype.reset=function(){this._elapsedTime=0},e.prototype.stop=function(){this._isDone=!0},e.prototype.tick=function(){return!this._isDone&&this._elapsedTime>this._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=t.Time.deltaTime,this._isDone},e.prototype.initialize=function(t,e,i,n){this._timeInSeconds=t,this._repeats=e,this.context=i,this._onTime=n},e.prototype.unload=function(){this.context=null,this._onTime=null},e}();t.Timer=e}(es||(es={})),function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._timers=[],t}return __extends(i,e),i.prototype.update=function(){for(var t=this._timers.length-1;t>=0;t--)this._timers[t].tick()&&(this._timers[t].unload(),this._timers.removeAt(t))},i.prototype.schedule=function(e,i,n,r){var o=new t.Timer;return o.initialize(e,i,n,r),this._timers.push(o),o},i}(t.GlobalManager);t.TimerManager=e}(es||(es={})); \ No newline at end of file diff --git a/demo/libs/framework_tiled/framework_tiled.d.ts b/demo/libs/framework_tiled/framework_tiled.d.ts deleted file mode 100644 index 5edd3974..00000000 --- a/demo/libs/framework_tiled/framework_tiled.d.ts +++ /dev/null @@ -1,357 +0,0 @@ -declare module es { - class TiledMapRenderer extends RenderableComponent { - tiledMap: TmxMap; - physicsLayer: Ref; - layerIndicesToRender: number[]; - private toContainer; - readonly width: number; - readonly height: number; - collisionLayer: TmxLayer; - _shouldCreateColliders: boolean; - _colliders: Collider[]; - constructor(tiledMap: TmxMap, collisionLayerName?: string, shouldCreateColliders?: boolean); - setLayerToRender(layerName: string): void; - setLayersToRender(...layerNames: string[]): void; - private getLayerIndex; - getRowAtWorldPosition(yPos: number): number; - getColumnAtWorldPosition(xPos: number): number; - onEntityTransformChanged(comp: transform.Component): void; - onAddedToEntity(): void; - onRemovedFromEntity(): void; - update(): void; - render(camera: es.Camera): void; - addColliders(): void; - removeColliders(): void; - } -} -declare module es { - class TmxGroup implements ITmxLayer { - map: TmxMap; - offsetX: number; - offsetY: number; - opacity: number; - properties: Map; - visible: boolean; - name: string; - layers: ITmxLayer[]; - tileLayers: TmxLayer[]; - objectGroups: TmxObjectGroup[]; - imageLayers: TmxImageLayer[]; - groups: TmxGroup[]; - } -} -declare module es { - interface ITmxLayer { - offsetX: number; - offsetY: number; - opacity: number; - visible: boolean; - properties: Map; - } -} -declare module es { - class TmxImageLayer implements ITmxLayer { - map: TmxMap; - name: string; - offsetX: number; - offsetY: number; - opacity: number; - properties: Map; - visible: boolean; - width?: number; - height?: number; - image: TmxImage; - } -} -declare module es { - class TmxLayer implements ITmxLayer { - map: TmxMap; - name: string; - opacity: number; - offsetX: number; - offsetY: number; - properties: Map; - visible: boolean; - readonly offset: Vector2; - width: number; - height: number; - tiles: TmxLayerTile[]; - getTileWithGid(gid: number): TmxLayerTile; - getTile(x: number, y: number): TmxLayerTile; - getCollisionRectangles(): Rectangle[]; - findBoundsRect(startX: number, endX: number, startY: number, checkedIndexes?: boolean[]): Rectangle; - } - class TmxLayerTile { - static readonly FLIPPED_HORIZONTALLY_FLAG: number; - static readonly FLIPPED_VERTICALLY_FLAG: number; - tileset: TmxTileset; - gid: number; - x: number; - y: number; - readonly position: Vector2; - horizontalFlip: boolean; - verticalFlip: boolean; - _tilesetTileIndex?: number; - readonly tilesetTile: TmxTilesetTile; - constructor(map: TmxMap, id: number, x: number, y: number); - } -} -declare module es { - class TmxDocument { - tmxDirectory: string; - constructor(); - } - interface ITmxElement { - name: string; - } - class TmxImage { - texture: egret.Bitmap; - bitmap: egret.SpriteSheet; - source: string; - format: string; - data: any; - trans: number; - width: number; - height: number; - dispose(): void; - } -} -declare module es { - class TmxMap extends TmxDocument { - version: string; - tiledVersion: string; - width: number; - height: number; - readonly worldWidth: number; - readonly worldHeight: number; - tileWidth: number; - tileHeight: number; - hexSideLength?: number; - orientation: OrientationType; - staggerAxis: StaggerAxisType; - staggerIndex: StaggerIndexType; - renderOrder: RenderOrderType; - backgroundColor: number; - nextObjectID?: number; - layers: ITmxLayer[]; - tilesets: TmxTileset[]; - tileLayers: TmxLayer[]; - objectGroups: TmxObjectGroup[]; - imageLayers: TmxImageLayer[]; - groups: TmxGroup[]; - properties: Map; - maxTileWidth: number; - maxTileHeight: number; - readonly requiresLargeTileCulling: boolean; - getTilesetForTileGid(gid: number): TmxTileset; - worldToTilePositionX(x: number, clampToTilemapBounds?: boolean): number; - worldToTilePositionY(y: number, clampToTilemapBounds?: boolean): number; - getLayer(name: string): ITmxLayer; - update(): void; - _isDisposed: any; - dispose(disposing?: boolean): void; - } - enum OrientationType { - unknown = 0, - orthogonal = 1, - isometric = 2, - staggered = 3, - hexagonal = 4 - } - enum StaggerAxisType { - x = 0, - y = 1 - } - enum StaggerIndexType { - odd = 0, - even = 1 - } - enum RenderOrderType { - rightDown = 0, - rightUp = 1, - leftDown = 2, - leftUp = 3 - } -} -declare module es { - class TmxObjectGroup implements ITmxLayer { - map: TmxMap; - name: string; - opacity: number; - visible: boolean; - offsetX: number; - offsetY: number; - color: number; - drawOrder: DrawOrderType; - objects: TmxObject[]; - properties: Map; - } - class TmxObject implements ITmxElement { - id: number; - name: string; - shape: egret.Shape; - textField: egret.TextField; - objectType: TmxObjectType; - type: string; - x: number; - y: number; - width: number; - height: number; - rotation: number; - tile: TmxLayerTile; - visible: boolean; - text: TmxText; - points: Vector2[]; - properties: Map; - constructor(); - } - class TmxText { - fontFamily: string; - pixelSize: number; - wrap: boolean; - color: number; - bold: boolean; - italic: boolean; - underline: boolean; - strikeout: boolean; - kerning: boolean; - alignment: TmxAlignment; - value: string; - } - class TmxAlignment { - horizontal: TmxHorizontalAlignment; - vertical: TmxVerticalAlignment; - } - enum TmxObjectType { - basic = 0, - point = 1, - tile = 2, - ellipse = 3, - polygon = 4, - polyline = 5, - text = 6 - } - enum DrawOrderType { - unkownOrder = -1, - TopDown = 0, - IndexOrder = 1 - } - enum TmxHorizontalAlignment { - left = 0, - center = 1, - right = 2, - justify = 3 - } - enum TmxVerticalAlignment { - top = 0, - center = 1, - bottom = 2 - } -} -declare module es { - class TiledMapLoader { - static loadTmxMap(map: TmxMap, filePath: string): Promise; - static loadTmxMapData(map: TmxMap, xMap: any, info: any): Promise; - static parseLayers(container: any, xEle: any, map: TmxMap, width: number, height: number, tmxDirectory: string): Promise; - static loadTmxGroup(group: TmxGroup, map: TmxMap, xGroup: any, width: number, height: number, tmxDirectory: string): Promise; - static loadTmxImageLayer(layer: TmxImageLayer, map: TmxMap, xImageLayer: any, tmxDirectory: string): Promise; - static loadTmxLayer(layer: TmxLayer, map: TmxMap, xLayer: any, width: number, height: number): TmxLayer; - private static updateMaxTileSizes; - static parseOrientationType(type: string): OrientationType; - static parseStaggerAxisType(type: string): StaggerAxisType; - static parseStaggerIndexType(type: string): StaggerIndexType; - static parseRenderOrderType(type: string): RenderOrderType; - static parsePropertyDict(prop: any): Map; - static parseTmxTileset(map: TmxMap, xTileset: any): Promise; - static loadTmxTileset(tileset: TmxTileset, map: TmxMap, xTileset: any, firstGid: number): Promise; - static loadTmxTilesetTile(tile: TmxTilesetTile, tileset: TmxTileset, xTile: any, terrains: TmxTerrain[], tmxDirectory: string): Promise; - static loadTmxAnimationFrame(frame: TmxAnimationFrame, xFrame: any): TmxAnimationFrame; - static loadTmxObjectGroup(group: TmxObjectGroup, map: TmxMap, xObjectGroup: any): TmxObjectGroup; - static loadTmxObject(obj: TmxObject, map: TmxMap, xObject: any): TmxObject; - static loadTmxText(text: TmxText, xText: any): TmxText; - static loadTmxAlignment(alignment: TmxAlignment, xText: any): TmxAlignment; - static parsePoints(xPoints: any): any[]; - static parsePoint(pt: { - x: number; - y: number; - }): Vector2; - static parseTmxTerrain(xTerrain: any): TmxTerrain; - static parseTmxTileOffset(xTileOffset: any): TmxTileOffset; - static loadTmxImage(image: TmxImage, xImage: any, tmxDirectory: string): Promise; - } -} -declare module es { - class TiledRendering { - static renderMap(map: TmxMap, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void; - static renderLayer(layer: TmxLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void; - static renderLayerRenderCamera(layer: ITmxLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number, camerClipBounds: Rectangle): void; - static renderLayerCamera(layer: TmxLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number, camerClipBounds: Rectangle): void; - static renderImageLayer(layer: TmxImageLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void; - static renderObjectGroup(objGroup: TmxObjectGroup, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void; - private static renderTilesetTile; - static renderGroup(group: TmxGroup, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void; - static renderTile(tile: TmxLayerTile, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, tileWidth: number, tileHeight: number, color: egret.ColorMatrixFilter, layerDepth: number): void; - } -} -declare module es { - class TmxTileset extends TmxDocument implements ITmxElement { - map: TmxMap; - firstGid: number; - name: any; - tileWidth: number; - tileHeight: number; - spacing: number; - margin: number; - columns?: number; - tileCount?: number; - tiles: Map; - tileOffset: TmxTileOffset; - properties: Map; - image: TmxImage; - terrains: TmxTerrain[]; - tileRegions: Map; - update(): void; - } - class TmxTileOffset { - x: number; - y: number; - } - class TmxTerrain implements ITmxElement { - name: any; - tile: number; - properties: Map; - } -} -declare module es { - class TmxTilesetTile { - tileset: TmxTileset; - id: number; - terrainEdges: TmxTerrain[]; - probability: number; - type: string; - properties: Map; - image: TmxImage; - objectGroups: TmxObjectGroup[]; - animationFrames: TmxAnimationFrame[]; - readonly currentAnimationFrameGid: number; - _animationElapsedTime: number; - _animationCurrentFrame: number; - isDestructable: boolean; - isSlope: boolean; - isOneWayPlatform: boolean; - slopeTopLeft: number; - slopeTopRight: number; - processProperties(): void; - updateAnimatedTiles(): void; - } - class TmxAnimationFrame { - gid: number; - duration: number; - } -} -declare module es { - class TmxUtils { - static decode(data: any, encoding: any, compression: string): Array; - static color16ToUnit($color: string): number; - } -} diff --git a/demo/libs/framework_tiled/framework_tiled.js b/demo/libs/framework_tiled/framework_tiled.js deleted file mode 100644 index 4290540b..00000000 --- a/demo/libs/framework_tiled/framework_tiled.js +++ /dev/null @@ -1,1575 +0,0 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var es; -(function (es) { - var TiledMapRenderer = (function (_super) { - __extends(TiledMapRenderer, _super); - function TiledMapRenderer(tiledMap, collisionLayerName, shouldCreateColliders) { - if (collisionLayerName === void 0) { collisionLayerName = null; } - if (shouldCreateColliders === void 0) { shouldCreateColliders = true; } - var _this = _super.call(this) || this; - _this.physicsLayer = new es.Ref(1 << 0); - _this.toContainer = false; - _this.tiledMap = tiledMap; - _this._shouldCreateColliders = shouldCreateColliders; - _this.displayObject = new egret.DisplayObjectContainer(); - if (collisionLayerName) { - _this.collisionLayer = tiledMap.tileLayers.find(function (layer) { return layer.name == collisionLayerName; }); - } - return _this; - } - Object.defineProperty(TiledMapRenderer.prototype, "width", { - get: function () { - return this.tiledMap.width * this.tiledMap.tileWidth; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledMapRenderer.prototype, "height", { - get: function () { - return this.tiledMap.height * this.tiledMap.tileHeight; - }, - enumerable: true, - configurable: true - }); - TiledMapRenderer.prototype.setLayerToRender = function (layerName) { - this.layerIndicesToRender = []; - this.layerIndicesToRender[0] = this.getLayerIndex(layerName); - }; - TiledMapRenderer.prototype.setLayersToRender = function () { - var layerNames = []; - for (var _i = 0; _i < arguments.length; _i++) { - layerNames[_i] = arguments[_i]; - } - this.layerIndicesToRender = []; - for (var i = 0; i < layerNames.length; i++) - this.layerIndicesToRender[i] = this.getLayerIndex(layerNames[i]); - }; - TiledMapRenderer.prototype.getLayerIndex = function (layerName) { - var index = 0; - var layerType = this.tiledMap.getLayer(layerName); - for (var layer in this.tiledMap.layers) { - if (this.tiledMap.layers.hasOwnProperty(layer) && - this.tiledMap.layers[layer] == layerType) { - return index; - } - } - return -1; - }; - TiledMapRenderer.prototype.getRowAtWorldPosition = function (yPos) { - yPos -= this.entity.transform.position.y + this._localOffset.y; - return this.tiledMap.worldToTilePositionY(yPos); - }; - TiledMapRenderer.prototype.getColumnAtWorldPosition = function (xPos) { - xPos -= this.entity.transform.position.x + this._localOffset.x; - return this.tiledMap.worldToTilePositionX(xPos); - }; - TiledMapRenderer.prototype.onEntityTransformChanged = function (comp) { - if (this._shouldCreateColliders && comp == transform.Component.position) { - this.removeColliders(); - this.addColliders(); - } - }; - TiledMapRenderer.prototype.onAddedToEntity = function () { - this.addColliders(); - }; - TiledMapRenderer.prototype.onRemovedFromEntity = function () { - this.removeColliders(); - }; - TiledMapRenderer.prototype.update = function () { - this.tiledMap.update(); - }; - TiledMapRenderer.prototype.render = function (camera) { - this.sync(camera); - if (!this.layerIndicesToRender) { - es.TiledRendering.renderMap(this.tiledMap, !this.toContainer ? this.displayObject : null, es.Vector2.add(this.entity.transform.position, this._localOffset), this.transform.scale, this.renderLayer); - } - else { - for (var i = 0; i < this.tiledMap.layers.length; i++) { - if (this.tiledMap.layers[i].visible && this.layerIndicesToRender.contains(i)) - es.TiledRendering.renderLayerRenderCamera(this.tiledMap.layers[i], !this.toContainer ? this.displayObject : null, es.Vector2.add(this.entity.transform.position, this._localOffset), this.transform.scale, this.renderLayer, camera.bounds); - } - } - if (!this.toContainer) { - this.displayObject.cacheAsBitmap = true; - this.toContainer = true; - } - }; - TiledMapRenderer.prototype.addColliders = function () { - if (!this.collisionLayer || !this._shouldCreateColliders) - return; - var collisionRects = this.collisionLayer.getCollisionRectangles(); - this._colliders = []; - for (var i = 0; i < collisionRects.length; i++) { - var collider = new es.BoxCollider(collisionRects[i].x + this._localOffset.x, collisionRects[i].y + this._localOffset.y, collisionRects[i].width, collisionRects[i].height); - collider.physicsLayer = this.physicsLayer; - collider.entity = this.entity; - this._colliders[i] = collider; - es.Physics.addCollider(collider); - } - }; - TiledMapRenderer.prototype.removeColliders = function () { - if (this._colliders == null) - return; - for (var _i = 0, _a = this._colliders; _i < _a.length; _i++) { - var collider = _a[_i]; - es.Physics.removeCollider(collider); - } - this._colliders = null; - }; - return TiledMapRenderer; - }(es.RenderableComponent)); - es.TiledMapRenderer = TiledMapRenderer; -})(es || (es = {})); -var es; -(function (es) { - var TmxGroup = (function () { - function TmxGroup() { - } - return TmxGroup; - }()); - es.TmxGroup = TmxGroup; -})(es || (es = {})); -var es; -(function (es) { - var TmxImageLayer = (function () { - function TmxImageLayer() { - } - return TmxImageLayer; - }()); - es.TmxImageLayer = TmxImageLayer; -})(es || (es = {})); -var es; -(function (es) { - var TmxLayer = (function () { - function TmxLayer() { - } - Object.defineProperty(TmxLayer.prototype, "offset", { - get: function () { - return new es.Vector2(this.offsetX, this.offsetY); - }, - enumerable: true, - configurable: true - }); - TmxLayer.prototype.getTileWithGid = function (gid) { - for (var i = 0; i < this.tiles.length; i++) { - if (this.tiles[i] && this.tiles[i].gid == gid) - return this.tiles[i]; - } - return null; - }; - TmxLayer.prototype.getTile = function (x, y) { - return this.tiles[x + y * this.width]; - }; - TmxLayer.prototype.getCollisionRectangles = function () { - var checkedIndexes = new Array(this.tiles.length); - var rectangles = []; - var startCol = -1; - var index = -1; - for (var y = 0; y < this.map.height; y++) { - for (var x = 0; x < this.map.width; x++) { - index = y * this.map.width + x; - var tile = this.getTile(x, y); - if (tile && !checkedIndexes[index]) { - if (startCol < 0) - startCol = x; - checkedIndexes[index] = true; - } - else if (!tile || checkedIndexes[index] == true) { - if (startCol >= 0) { - rectangles.push(this.findBoundsRect(startCol, x, y, checkedIndexes)); - startCol = -1; - } - } - } - if (startCol >= 0) { - rectangles.push(this.findBoundsRect(startCol, this.map.width, y, checkedIndexes)); - startCol = -1; - } - } - return rectangles; - }; - TmxLayer.prototype.findBoundsRect = function (startX, endX, startY, checkedIndexes) { - var index = -1; - for (var y = startY + 1; y < this.map.height; y++) { - for (var x = startX; x < endX; x++) { - index = y * this.map.width + x; - var tile = this.getTile(x, y); - if (!tile || checkedIndexes[index]) { - for (var _x = startX; _x < x; _x++) { - index = y * this.map.width + _x; - checkedIndexes[index] = false; - } - return new es.Rectangle(startX * this.map.tileWidth, startY * this.map.tileHeight, (endX - startX) * this.map.tileWidth, (y - startY) * this.map.tileHeight); - } - checkedIndexes[index] = true; - } - } - return new es.Rectangle(startX * this.map.tileWidth, startY * this.map.tileHeight, (endX - startX) * this.map.tileWidth, (this.map.height - startY) * this.map.tileHeight); - }; - return TmxLayer; - }()); - es.TmxLayer = TmxLayer; - var TmxLayerTile = (function () { - function TmxLayerTile(map, id, x, y) { - this.x = x; - this.y = y; - var rawGid = id; - var flip; - flip = (rawGid & TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG) != 0; - this.horizontalFlip = flip; - flip = (rawGid & TmxLayerTile.FLIPPED_VERTICALLY_FLAG) != 0; - this.verticalFlip = flip; - rawGid &= ~(TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG | TmxLayerTile.FLIPPED_VERTICALLY_FLAG); - this.gid = Math.floor(rawGid); - this.tileset = map.getTilesetForTileGid(this.gid); - } - Object.defineProperty(TmxLayerTile.prototype, "position", { - get: function () { - return new es.Vector2(this.x, this.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TmxLayerTile.prototype, "tilesetTile", { - get: function () { - if (!this._tilesetTileIndex) { - this._tilesetTileIndex = -1; - if (this.tileset.firstGid <= this.gid) { - var tilesetTile = this.tileset.tiles.get(this.gid - this.tileset.firstGid); - if (tilesetTile) { - this._tilesetTileIndex = this.gid - this.tileset.firstGid; - } - } - } - if (this._tilesetTileIndex < 0) - return null; - return this.tileset.tiles.get(this._tilesetTileIndex); - }, - enumerable: true, - configurable: true - }); - TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG = 0x80000000; - TmxLayerTile.FLIPPED_VERTICALLY_FLAG = 0x40000000; - return TmxLayerTile; - }()); - es.TmxLayerTile = TmxLayerTile; -})(es || (es = {})); -var es; -(function (es) { - var TmxDocument = (function () { - function TmxDocument() { - this.tmxDirectory = "resource/assets/"; - } - return TmxDocument; - }()); - es.TmxDocument = TmxDocument; - var TmxImage = (function () { - function TmxImage() { - } - TmxImage.prototype.dispose = function () { - if (this.bitmap) { - this.bitmap.dispose(); - this.bitmap = null; - } - }; - return TmxImage; - }()); - es.TmxImage = TmxImage; -})(es || (es = {})); -var es; -(function (es) { - var TmxMap = (function (_super) { - __extends(TmxMap, _super); - function TmxMap() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(TmxMap.prototype, "worldWidth", { - get: function () { - return this.width * this.tileWidth; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TmxMap.prototype, "worldHeight", { - get: function () { - return this.height * this.tileHeight; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TmxMap.prototype, "requiresLargeTileCulling", { - get: function () { - return this.maxTileHeight > this.tileHeight || this.maxTileWidth > this.tileWidth; - }, - enumerable: true, - configurable: true - }); - TmxMap.prototype.getTilesetForTileGid = function (gid) { - if (gid == 0) - return null; - for (var i = this.tilesets.length - 1; i >= 0; i--) { - if (this.tilesets[i].firstGid <= gid) - return this.tilesets[i]; - } - console.error("tile gid" + gid + "\u672A\u5728\u4EFB\u4F55tileset\u4E2D\u627E\u5230"); - }; - TmxMap.prototype.worldToTilePositionX = function (x, clampToTilemapBounds) { - if (clampToTilemapBounds === void 0) { clampToTilemapBounds = true; } - var tileX = Math.floor(x / this.tileWidth); - if (!clampToTilemapBounds) - return tileX; - return es.MathHelper.clamp(tileX, 0, this.width - 1); - }; - TmxMap.prototype.worldToTilePositionY = function (y, clampToTilemapBounds) { - if (clampToTilemapBounds === void 0) { clampToTilemapBounds = true; } - var tileY = Math.floor(y / this.tileHeight); - if (!clampToTilemapBounds) - return tileY; - return es.MathHelper.clamp(tileY, 0, this.height - 1); - }; - TmxMap.prototype.getLayer = function (name) { - return this.layers[name]; - }; - TmxMap.prototype.update = function () { - this.tilesets.forEach(function (tileset) { tileset.update(); }); - }; - TmxMap.prototype.dispose = function (disposing) { - if (disposing === void 0) { disposing = true; } - if (!this._isDisposed) { - if (disposing) { - this.tilesets.forEach(function (tileset) { if (tileset.image) - tileset.image.dispose(); }); - this.imageLayers.forEach(function (layer) { if (layer.image) - layer.image.dispose(); }); - } - this._isDisposed = true; - } - }; - return TmxMap; - }(es.TmxDocument)); - es.TmxMap = TmxMap; - var OrientationType; - (function (OrientationType) { - OrientationType[OrientationType["unknown"] = 0] = "unknown"; - OrientationType[OrientationType["orthogonal"] = 1] = "orthogonal"; - OrientationType[OrientationType["isometric"] = 2] = "isometric"; - OrientationType[OrientationType["staggered"] = 3] = "staggered"; - OrientationType[OrientationType["hexagonal"] = 4] = "hexagonal"; - })(OrientationType = es.OrientationType || (es.OrientationType = {})); - var StaggerAxisType; - (function (StaggerAxisType) { - StaggerAxisType[StaggerAxisType["x"] = 0] = "x"; - StaggerAxisType[StaggerAxisType["y"] = 1] = "y"; - })(StaggerAxisType = es.StaggerAxisType || (es.StaggerAxisType = {})); - var StaggerIndexType; - (function (StaggerIndexType) { - StaggerIndexType[StaggerIndexType["odd"] = 0] = "odd"; - StaggerIndexType[StaggerIndexType["even"] = 1] = "even"; - })(StaggerIndexType = es.StaggerIndexType || (es.StaggerIndexType = {})); - var RenderOrderType; - (function (RenderOrderType) { - RenderOrderType[RenderOrderType["rightDown"] = 0] = "rightDown"; - RenderOrderType[RenderOrderType["rightUp"] = 1] = "rightUp"; - RenderOrderType[RenderOrderType["leftDown"] = 2] = "leftDown"; - RenderOrderType[RenderOrderType["leftUp"] = 3] = "leftUp"; - })(RenderOrderType = es.RenderOrderType || (es.RenderOrderType = {})); -})(es || (es = {})); -var es; -(function (es) { - var TmxObjectGroup = (function () { - function TmxObjectGroup() { - } - return TmxObjectGroup; - }()); - es.TmxObjectGroup = TmxObjectGroup; - var TmxObject = (function () { - function TmxObject() { - this.shape = new egret.Shape(); - this.textField = new egret.TextField(); - } - return TmxObject; - }()); - es.TmxObject = TmxObject; - var TmxText = (function () { - function TmxText() { - } - return TmxText; - }()); - es.TmxText = TmxText; - var TmxAlignment = (function () { - function TmxAlignment() { - } - return TmxAlignment; - }()); - es.TmxAlignment = TmxAlignment; - var TmxObjectType; - (function (TmxObjectType) { - TmxObjectType[TmxObjectType["basic"] = 0] = "basic"; - TmxObjectType[TmxObjectType["point"] = 1] = "point"; - TmxObjectType[TmxObjectType["tile"] = 2] = "tile"; - TmxObjectType[TmxObjectType["ellipse"] = 3] = "ellipse"; - TmxObjectType[TmxObjectType["polygon"] = 4] = "polygon"; - TmxObjectType[TmxObjectType["polyline"] = 5] = "polyline"; - TmxObjectType[TmxObjectType["text"] = 6] = "text"; - })(TmxObjectType = es.TmxObjectType || (es.TmxObjectType = {})); - var DrawOrderType; - (function (DrawOrderType) { - DrawOrderType[DrawOrderType["unkownOrder"] = -1] = "unkownOrder"; - DrawOrderType[DrawOrderType["TopDown"] = 0] = "TopDown"; - DrawOrderType[DrawOrderType["IndexOrder"] = 1] = "IndexOrder"; - })(DrawOrderType = es.DrawOrderType || (es.DrawOrderType = {})); - var TmxHorizontalAlignment; - (function (TmxHorizontalAlignment) { - TmxHorizontalAlignment[TmxHorizontalAlignment["left"] = 0] = "left"; - TmxHorizontalAlignment[TmxHorizontalAlignment["center"] = 1] = "center"; - TmxHorizontalAlignment[TmxHorizontalAlignment["right"] = 2] = "right"; - TmxHorizontalAlignment[TmxHorizontalAlignment["justify"] = 3] = "justify"; - })(TmxHorizontalAlignment = es.TmxHorizontalAlignment || (es.TmxHorizontalAlignment = {})); - var TmxVerticalAlignment; - (function (TmxVerticalAlignment) { - TmxVerticalAlignment[TmxVerticalAlignment["top"] = 0] = "top"; - TmxVerticalAlignment[TmxVerticalAlignment["center"] = 1] = "center"; - TmxVerticalAlignment[TmxVerticalAlignment["bottom"] = 2] = "bottom"; - })(TmxVerticalAlignment = es.TmxVerticalAlignment || (es.TmxVerticalAlignment = {})); -})(es || (es = {})); -var es; -(function (es) { - var TiledMapLoader = (function () { - function TiledMapLoader() { - } - TiledMapLoader.loadTmxMap = function (map, filePath) { - var xMap = RES.getRes(filePath); - return this.loadTmxMapData(map, xMap, RES.getResourceInfo(filePath)); - }; - TiledMapLoader.loadTmxMapData = function (map, xMap, info) { - return __awaiter(this, void 0, void 0, function () { - var _i, _a, e, tileset; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - map.version = xMap["version"]; - map.tiledVersion = xMap["tiledversion"]; - map.width = xMap["width"]; - map.height = xMap["height"]; - map.tileWidth = xMap["tilewidth"]; - map.tileHeight = xMap["tileheight"]; - map.hexSideLength = xMap["hexsidelength"]; - map.orientation = this.parseOrientationType(xMap["orientation"]); - map.staggerAxis = this.parseStaggerAxisType(xMap["staggeraxis"]); - map.staggerIndex = this.parseStaggerIndexType(xMap["staggerindex"]); - map.renderOrder = this.parseRenderOrderType(xMap["renderorder"]); - map.nextObjectID = xMap["nextobjectid"]; - map.backgroundColor = es.TmxUtils.color16ToUnit(xMap["color"]); - map.properties = this.parsePropertyDict(xMap["properties"]); - map.maxTileWidth = map.tileWidth; - map.maxTileHeight = map.tileHeight; - map.tmxDirectory = info.root + info.url.replace(".", "_").replace(info.name, ""); - map.tilesets = []; - _i = 0, _a = xMap["tilesets"]; - _b.label = 1; - case 1: - if (!(_i < _a.length)) return [3, 4]; - e = _a[_i]; - return [4, this.parseTmxTileset(map, e)]; - case 2: - tileset = _b.sent(); - map.tilesets.push(tileset); - this.updateMaxTileSizes(tileset); - _b.label = 3; - case 3: - _i++; - return [3, 1]; - case 4: - map.layers = []; - map.tileLayers = []; - map.objectGroups = []; - map.imageLayers = []; - map.groups = []; - this.parseLayers(map, xMap, map, map.width, map.height, map.tmxDirectory); - return [2, map]; - } - }); - }); - }; - TiledMapLoader.parseLayers = function (container, xEle, map, width, height, tmxDirectory) { - return __awaiter(this, void 0, void 0, function () { - var _i, _a, e, layer, _b, tileLayer, objectgroup, imagelayer, newGroup; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _i = 0, _a = ObjectUtils.elements(xEle).where(function (x) { - return x.type == "tilelayer" || x.type == "objectgroup" || x.type == "imagelayer" || x.type == "group"; - }); - _c.label = 1; - case 1: - if (!(_i < _a.length)) return [3, 11]; - e = _a[_i]; - layer = void 0; - _b = e.type; - switch (_b) { - case "tilelayer": return [3, 2]; - case "objectgroup": return [3, 3]; - case "imagelayer": return [3, 4]; - case "group": return [3, 6]; - } - return [3, 8]; - case 2: - tileLayer = this.loadTmxLayer(new es.TmxLayer(), map, e, width, height); - layer = tileLayer; - if (container instanceof es.TmxMap || container instanceof es.TmxGroup) - container.tileLayers.push(tileLayer); - return [3, 9]; - case 3: - objectgroup = this.loadTmxObjectGroup(new es.TmxObjectGroup(), map, e); - layer = objectgroup; - if (container instanceof es.TmxMap || container instanceof es.TmxGroup) - container.objectGroups.push(objectgroup); - return [3, 9]; - case 4: return [4, this.loadTmxImageLayer(new es.TmxImageLayer(), map, e, tmxDirectory)]; - case 5: - imagelayer = _c.sent(); - layer = imagelayer; - if (container instanceof es.TmxMap || container instanceof es.TmxGroup) - container.imageLayers.push(imagelayer); - return [3, 9]; - case 6: return [4, this.loadTmxGroup(new es.TmxGroup(), map, e, width, height, tmxDirectory)]; - case 7: - newGroup = _c.sent(); - layer = newGroup; - if (container instanceof es.TmxMap || container instanceof es.TmxGroup) - container.groups.push(newGroup); - return [3, 9]; - case 8: throw new Error("无效的操作"); - case 9: - if (container instanceof es.TmxMap || container instanceof es.TmxGroup) - container.layers.push(layer); - _c.label = 10; - case 10: - _i++; - return [3, 1]; - case 11: return [2]; - } - }); - }); - }; - TiledMapLoader.loadTmxGroup = function (group, map, xGroup, width, height, tmxDirectory) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - group.map = map; - group.name = xGroup["name"] != undefined ? xGroup["name"] : ""; - group.opacity = xGroup["opacity"] != undefined ? xGroup["opacity"] : 1; - group.visible = xGroup["visible"] != undefined ? xGroup["visible"] : true; - group.offsetX = xGroup["offsetx"] != undefined ? xGroup["offsetx"] : 0; - group.offsetY = xGroup["offsety"] != undefined ? xGroup["offsety"] : 0; - group.properties = this.parsePropertyDict(xGroup["properties"]); - group.layers = []; - group.tileLayers = []; - group.objectGroups = []; - group.imageLayers = []; - group.groups = []; - return [4, this.parseLayers(group, xGroup, map, width, height, tmxDirectory)]; - case 1: - _a.sent(); - return [2, group]; - } - }); - }); - }; - TiledMapLoader.loadTmxImageLayer = function (layer, map, xImageLayer, tmxDirectory) { - return __awaiter(this, void 0, void 0, function () { - var xImage, _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - layer.map = map; - layer.name = xImageLayer["name"]; - layer.width = xImageLayer["width"]; - layer.height = xImageLayer["height"]; - layer.visible = xImageLayer["visible"] != undefined ? xImageLayer["visible"] : true; - layer.opacity = xImageLayer["opacity"] != undefined ? xImageLayer["opacity"] : 1; - layer.offsetX = xImageLayer["offsetx"] != undefined ? xImageLayer["offsetx"] : 0; - layer.offsetY = xImageLayer["offsety"] != undefined ? xImageLayer["offsety"] : 0; - xImage = xImageLayer["image"]; - if (!xImage) return [3, 2]; - _a = layer; - return [4, this.loadTmxImage(new es.TmxImage(), xImage, tmxDirectory)]; - case 1: - _a.image = _b.sent(); - _b.label = 2; - case 2: - layer.properties = this.parsePropertyDict(xImageLayer["properties"]); - return [2, layer]; - } - }); - }); - }; - TiledMapLoader.loadTmxLayer = function (layer, map, xLayer, width, height) { - layer.map = map; - layer.name = xLayer["name"]; - layer.opacity = xLayer["opacity"] != undefined ? xLayer["opacity"] : 1; - layer.visible = xLayer["visible"] != undefined ? xLayer["visible"] : true; - layer.offsetX = xLayer["offsetx"] != undefined ? xLayer["offsetx"] : 0; - layer.offsetY = xLayer["offsety"] != undefined ? xLayer["offsety"] : 0; - layer.width = xLayer["width"]; - layer.height = xLayer["height"]; - var xData = xLayer["data"]; - var encoding = xData["encoding"] != undefined ? xData["encoding"] : "csv"; - layer.tiles = new Array(width * height); - if (encoding == "base64") { - var br = es.TmxUtils.decode(xData.toString(), encoding, xData["compression"]); - var index = 0; - for (var j = 0; j < height; j++) { - for (var i = 0; i < width; i++) { - var gid = br[index]; - layer.tiles[index++] = gid != 0 ? new es.TmxLayerTile(map, gid, i, j) : null; - } - } - } - else if (encoding == "csv") { - var k = 0; - for (var _i = 0, xData_1 = xData; _i < xData_1.length; _i++) { - var s = xData_1[_i]; - var gid = s; - var x = k % width; - var y = k / width; - layer.tiles[k++] = gid != 0 ? new es.TmxLayerTile(map, gid, x, y) : null; - } - } - else if (!encoding) { - var k = 0; - for (var _a = 0, _b = xData["tile"]; _a < _b.length; _a++) { - var e = _b[_a]; - var gid = e["gid"] != undefined ? e["gid"] : 0; - var x = k % width; - var y = k / width; - layer.tiles[k++] = gid != 0 ? new es.TmxLayerTile(map, gid, x, y) : null; - } - } - else { - throw new Error("TmxLayer:未知编码"); - } - layer.properties = TiledMapLoader.parsePropertyDict(xLayer["properties"]); - return layer; - }; - TiledMapLoader.updateMaxTileSizes = function (tileset) { - tileset.tiles.forEach(function (tile) { - if (tile.image) { - if (tile.image.width > tileset.map.maxTileWidth) - tileset.map.maxTileWidth = tile.image.width; - if (tile.image.height > tileset.map.maxTileHeight) - tileset.map.maxTileHeight = tile.image.height; - } - }); - tileset.tileRegions.forEach(function (region) { - var width = region.width; - var height = region.height; - if (width > tileset.map.maxTileWidth) - tileset.map.maxTileWidth = width; - if (width > tileset.map.maxTileHeight) - tileset.map.maxTileHeight = height; - }); - }; - TiledMapLoader.parseOrientationType = function (type) { - if (type == "unknown") - return es.OrientationType.unknown; - if (type == "orthogonal") - return es.OrientationType.orthogonal; - if (type == "isometric") - return es.OrientationType.isometric; - if (type == "staggered") - return es.OrientationType.staggered; - if (type == "hexagonal") - return es.OrientationType.hexagonal; - return es.OrientationType.unknown; - }; - TiledMapLoader.parseStaggerAxisType = function (type) { - if (type == "y") - return es.StaggerAxisType.y; - return es.StaggerAxisType.x; - }; - TiledMapLoader.parseStaggerIndexType = function (type) { - if (type == "even") - return es.StaggerIndexType.even; - return es.StaggerIndexType.odd; - }; - TiledMapLoader.parseRenderOrderType = function (type) { - if (type == "right-up") - return es.RenderOrderType.rightUp; - if (type == "left-down") - return es.RenderOrderType.leftDown; - if (type == "left-up") - return es.RenderOrderType.leftUp; - return es.RenderOrderType.rightDown; - }; - TiledMapLoader.parsePropertyDict = function (prop) { - if (!prop) - return null; - var dict = new Map(); - for (var _i = 0, prop_1 = prop; _i < prop_1.length; _i++) { - var p = prop_1[_i]; - var pname = p["name"]; - var valueAttr = p["value"]; - if (p["type"] == "color") - dict.set(pname, es.TmxUtils.color16ToUnit(valueAttr).toString()); - else - dict.set(pname, valueAttr); - } - return dict; - }; - TiledMapLoader.parseTmxTileset = function (map, xTileset) { - return __awaiter(this, void 0, void 0, function () { - var xFirstGid, firstGid, source, xDocTileset; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - xFirstGid = xTileset["firstgid"]; - firstGid = xFirstGid; - source = xTileset["source"]; - if (!(source != undefined)) return [3, 2]; - source = map.tmxDirectory + source; - return [4, RES.getResByUrl(source).catch(function (err) { - throw new Error(err); - })]; - case 1: - xDocTileset = _a.sent(); - return [2, this.loadTmxTileset(new es.TmxTileset(), map, xDocTileset["tileset"], firstGid)]; - case 2: return [2, this.loadTmxTileset(new es.TmxTileset(), map, xTileset, firstGid)]; - } - }); - }); - }; - TiledMapLoader.loadTmxTileset = function (tileset, map, xTileset, firstGid) { - return __awaiter(this, void 0, void 0, function () { - var xImage, _i, _a, e, _b, _c, _d, t, xTile, tile, id, y, column, x; - return __generator(this, function (_e) { - switch (_e.label) { - case 0: - tileset.map = map; - tileset.firstGid = firstGid; - tileset.name = xTileset["name"]; - tileset.tileWidth = xTileset["tilewidth"]; - tileset.tileHeight = xTileset["tileheight"]; - tileset.spacing = xTileset["spacing"] != undefined ? xTileset["spacing"] : 0; - tileset.margin = xTileset["margin"] != undefined ? xTileset["margin"] : 0; - tileset.columns = xTileset["columns"]; - tileset.tileCount = xTileset["tilecount"]; - tileset.tileOffset = this.parseTmxTileOffset(xTileset["tileoffset"]); - xImage = xTileset["image"]; - if (!xImage) return [3, 2]; - return [4, this.loadTmxImage(new es.TmxImage(), xTileset, map.tmxDirectory).then(function (image) { - tileset.image = image; - }).catch(function (err) { - throw new Error(err); - })]; - case 1: - _e.sent(); - _e.label = 2; - case 2: - tileset.terrains = []; - if (xTileset["terrains"]) - for (_i = 0, _a = xTileset["terrains"]; _i < _a.length; _i++) { - e = _a[_i]; - tileset.terrains.push(this.parseTmxTerrain(e)); - } - tileset.tiles = new Map(); - _b = []; - for (_c in xTileset["tiles"]) - _b.push(_c); - _d = 0; - _e.label = 3; - case 3: - if (!(_d < _b.length)) return [3, 6]; - t = _b[_d]; - if (!xTileset["tiles"].hasOwnProperty(t)) return [3, 5]; - xTile = xTileset["tiles"][t]; - return [4, this.loadTmxTilesetTile(new es.TmxTilesetTile(), tileset, xTile, tileset.terrains, map.tmxDirectory)]; - case 4: - tile = _e.sent(); - tileset.tiles.set(tile.id == undefined ? Number(t) + 1 : tile.id, tile); - _e.label = 5; - case 5: - _d++; - return [3, 3]; - case 6: - tileset.properties = this.parsePropertyDict(xTileset["properties"]); - tileset.tileRegions = new Map(); - if (tileset.image) { - id = firstGid; - for (y = tileset.margin; y < tileset.image.height - tileset.margin; y += tileset.tileHeight + tileset.spacing) { - column = 0; - for (x = tileset.margin; x < tileset.image.width - tileset.margin; x += tileset.tileWidth + tileset.spacing) { - tileset.tileRegions.set(id++, new es.Rectangle(x, y, tileset.tileWidth, tileset.tileHeight)); - if (++column >= tileset.columns) - break; - } - } - } - else { - tileset.tiles.forEach(function (tile, key) { - tileset.tileRegions.set(key, new es.Rectangle(0, 0, tile.image.width, tile.image.height)); - }); - } - return [2, tileset]; - } - }); - }); - }; - TiledMapLoader.loadTmxTilesetTile = function (tile, tileset, xTile, terrains, tmxDirectory) { - return __awaiter(this, void 0, void 0, function () { - var strTerrain, index, _i, strTerrain_1, v, edge, xImage, _a, _b, _c, e, _d, _e, e; - return __generator(this, function (_f) { - switch (_f.label) { - case 0: - tile.tileset = tileset; - tile.id = xTile["id"]; - strTerrain = xTile["terrain"]; - if (strTerrain) { - tile.terrainEdges = new Array(4); - index = 0; - for (_i = 0, strTerrain_1 = strTerrain; _i < strTerrain_1.length; _i++) { - v = strTerrain_1[_i]; - edge = terrains[v]; - tile.terrainEdges[index++] = edge; - } - } - tile.probability = xTile["probability"] != undefined ? xTile["probability"] : 1; - tile.type = xTile["type"]; - xImage = xTile["image"]; - if (!xImage) return [3, 2]; - _a = tile; - return [4, this.loadTmxImage(new es.TmxImage(), xImage, tmxDirectory)]; - case 1: - _a.image = _f.sent(); - _f.label = 2; - case 2: - tile.objectGroups = []; - if (xTile["objectgroup"]) - for (_b = 0, _c = xTile["objectgroup"]; _b < _c.length; _b++) { - e = _c[_b]; - tile.objectGroups.push(this.loadTmxObjectGroup(new es.TmxObjectGroup(), tileset.map, e)); - } - tile.animationFrames = []; - if (xTile["animation"]) { - for (_d = 0, _e = xTile["animation"]["frame"]; _d < _e.length; _d++) { - e = _e[_d]; - tile.animationFrames.push(this.loadTmxAnimationFrame(new es.TmxAnimationFrame(), e)); - } - } - tile.properties = this.parsePropertyDict(xTile["properties"]); - if (tile.properties) - tile.processProperties(); - return [2, tile]; - } - }); - }); - }; - TiledMapLoader.loadTmxAnimationFrame = function (frame, xFrame) { - frame.gid = xFrame["tileid"]; - frame.duration = xFrame["duration"] / 1000; - return frame; - }; - TiledMapLoader.loadTmxObjectGroup = function (group, map, xObjectGroup) { - group.map = map; - group.name = xObjectGroup["name"] != undefined ? xObjectGroup["name"] : ""; - group.color = es.TmxUtils.color16ToUnit(xObjectGroup["color"]); - group.opacity = xObjectGroup["opacity"] != undefined ? xObjectGroup["opacity"] : 1; - group.visible = xObjectGroup["visible"] != undefined ? xObjectGroup["visible"] : true; - group.offsetX = xObjectGroup["offsetx"] != undefined ? xObjectGroup["offsetx"] : 0; - group.offsetY = xObjectGroup["offsety"] != undefined ? xObjectGroup["offsety"] : 0; - var drawOrderDict = new Map(); - drawOrderDict.set("unknown", es.DrawOrderType.unkownOrder); - drawOrderDict.set("topdown", es.DrawOrderType.IndexOrder); - drawOrderDict.set("index", es.DrawOrderType.TopDown); - var drawOrderValue = xObjectGroup["draworder"]; - if (drawOrderValue) - group.drawOrder = drawOrderDict.get(drawOrderValue); - group.objects = []; - for (var _i = 0, _a = xObjectGroup["objects"]; _i < _a.length; _i++) { - var e = _a[_i]; - group.objects.push(this.loadTmxObject(new es.TmxObject(), map, e)); - } - group.properties = this.parsePropertyDict(xObjectGroup["properties"]); - return group; - }; - TiledMapLoader.loadTmxObject = function (obj, map, xObject) { - obj.id = xObject["id"] != undefined ? xObject["id"] : 0; - obj.name = xObject["name"] != undefined ? xObject["name"] : ""; - obj.x = xObject["x"]; - obj.y = xObject["y"]; - obj.width = xObject["width"] != undefined ? xObject["width"] : 0; - obj.height = xObject["height"] != undefined ? xObject["height"] : 0; - obj.type = xObject["type"] != undefined ? xObject["type"] : ""; - obj.visible = xObject["visible"] != undefined ? xObject["visible"] : true; - obj.rotation = xObject["rotation"] != undefined ? xObject["rotation"] : 0; - var xGid = xObject["gid"]; - var xEllipse = xObject["ellipse"]; - var xPolygon = xObject["polygon"]; - var xPolyline = xObject["polyline"]; - var xText = xObject["text"]; - var xPoint = xObject["point"]; - if (xGid) { - obj.tile = new es.TmxLayerTile(map, xGid, Math.round(obj.x), Math.round(obj.y)); - obj.objectType = es.TmxObjectType.tile; - } - else if (xEllipse) { - obj.objectType = es.TmxObjectType.ellipse; - } - else if (xPolygon) { - obj.points = this.parsePoints(xPolygon); - obj.objectType = es.TmxObjectType.polygon; - } - else if (xPolyline) { - obj.points = this.parsePoints(xPolyline); - obj.objectType = es.TmxObjectType.polyline; - } - else if (xText) { - obj.text = this.loadTmxText(new es.TmxText(), xText); - obj.objectType = es.TmxObjectType.text; - } - else if (xPoint) { - obj.objectType = es.TmxObjectType.point; - } - else { - obj.objectType = es.TmxObjectType.basic; - } - obj.properties = this.parsePropertyDict(xObject["properties"]); - return obj; - }; - TiledMapLoader.loadTmxText = function (text, xText) { - text.fontFamily = xText["fontfamily"] != undefined ? xText["fontfamily"] : "sans-serif"; - text.pixelSize = xText["pixelsize"] != undefined ? xText["pixelsize"] : 16; - text.wrap = xText["wrap"] != undefined ? xText["wrap"] : false; - text.color = es.TmxUtils.color16ToUnit(xText["color"]); - text.bold = xText["bold"] ? xText["bold"] : false; - text.italic = xText["italic"] ? xText["italic"] : false; - text.underline = xText["underline"] ? xText["underline"] : false; - text.strikeout = xText["strikeout"] ? xText["strikeout"] : false; - text.kerning = xText["kerning"] ? xText["kerning"] : true; - text.alignment = this.loadTmxAlignment(new es.TmxAlignment(), xText); - text.value = xText; - return text; - }; - TiledMapLoader.loadTmxAlignment = function (alignment, xText) { - function firstLetterToUpperCase(str) { - if (!str || str == "") - return str; - return str[0].toString().toUpperCase() + str.substr(1); - } - var xHorizontal = xText["halign"] != undefined ? xText["halign"] : "left"; - alignment.horizontal = es.TmxHorizontalAlignment[firstLetterToUpperCase(xHorizontal)]; - var xVertical = xText["valign"] != undefined ? xText["valign"] : "top"; - alignment.vertical = es.TmxVerticalAlignment[firstLetterToUpperCase((xVertical))]; - return alignment; - }; - TiledMapLoader.parsePoints = function (xPoints) { - var points = []; - var index = 0; - for (var _i = 0, xPoints_1 = xPoints; _i < xPoints_1.length; _i++) { - var s = xPoints_1[_i]; - points[index++] = this.parsePoint(s); - } - return points; - }; - TiledMapLoader.parsePoint = function (pt) { - return new es.Vector2(pt.x, pt.y); - }; - TiledMapLoader.parseTmxTerrain = function (xTerrain) { - var terrain = new es.TmxTerrain(); - terrain.name = xTerrain["name"]; - terrain.tile = xTerrain["tile"]; - terrain.properties = this.parsePropertyDict(xTerrain["properties"]); - return terrain; - }; - TiledMapLoader.parseTmxTileOffset = function (xTileOffset) { - var tmxTileOffset = new es.TmxTileOffset(); - if (!xTileOffset) { - tmxTileOffset.x = 0; - tmxTileOffset.y = 0; - return tmxTileOffset; - } - tmxTileOffset.x = xTileOffset["x"]; - tmxTileOffset.y = xTileOffset["y"]; - return tmxTileOffset; - }; - TiledMapLoader.loadTmxImage = function (image, xImage, tmxDirectory) { - return __awaiter(this, void 0, void 0, function () { - var xSource, texture; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - xSource = xImage["image"]; - if (xSource != undefined) { - image.source = tmxDirectory + xSource; - } - else { - image.source = tmxDirectory + xImage; - } - return [4, RES.getResByUrl(image.source, null, this, RES.ResourceItem.TYPE_IMAGE).catch(function (err) { - throw new Error(err); - })]; - case 1: - texture = _a.sent(); - image.bitmap = new egret.SpriteSheet(texture); - image.trans = es.TmxUtils.color16ToUnit(xImage["trans"]); - image.width = xImage["imagewidth"] != undefined ? xImage["imagewidth"] : texture.textureWidth; - image.height = xImage["imageheight"] != undefined ? xImage["imageheight"] : texture.textureHeight; - return [2, image]; - } - }); - }); - }; - return TiledMapLoader; - }()); - es.TiledMapLoader = TiledMapLoader; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var TiledRendering = (function () { - function TiledRendering() { - } - TiledRendering.renderMap = function (map, container, position, scale, layerDepth) { - var _this = this; - map.layers.forEach(function (layer) { - if (layer instanceof es.TmxLayer && layer.visible) { - _this.renderLayer(layer, container, position, scale, layerDepth); - } - else if (layer instanceof es.TmxImageLayer && layer.visible) { - _this.renderImageLayer(layer, container, position, scale, layerDepth); - } - else if (layer instanceof es.TmxGroup && layer.visible) { - _this.renderGroup(layer, container, position, scale, layerDepth); - } - else if (layer instanceof es.TmxObjectGroup && layer.visible) { - _this.renderObjectGroup(layer, container, position, scale, layerDepth); - } - }); - }; - TiledRendering.renderLayer = function (layer, container, position, scale, layerDepth) { - if (!layer.visible) - return; - var tileWidth = layer.map.tileWidth * scale.x; - var tileHeight = layer.map.tileHeight * scale.y; - var color = es.DrawUtils.getColorMatrix(0xFFFFFF); - for (var i = 0; i < layer.tiles.length; i++) { - var tile = layer.tiles[i]; - if (!tile) - continue; - this.renderTile(tile, container, position, scale, tileWidth, tileHeight, color, layerDepth); - } - }; - TiledRendering.renderLayerRenderCamera = function (layer, container, position, scale, layerDepth, camerClipBounds) { - if (layer instanceof es.TmxLayer && layer.visible) { - this.renderLayerCamera(layer, container, position, scale, layerDepth, camerClipBounds); - } - else if (layer instanceof es.TmxImageLayer && layer.visible) { - this.renderImageLayer(layer, container, position, scale, layerDepth); - } - else if (layer instanceof es.TmxGroup && layer.visible) { - this.renderGroup(layer, container, position, scale, layerDepth); - } - else if (layer instanceof es.TmxObjectGroup && layer.visible) { - this.renderObjectGroup(layer, container, position, scale, layerDepth); - } - }; - TiledRendering.renderLayerCamera = function (layer, container, position, scale, layerDepth, camerClipBounds) { - if (!layer.visible) - return; - position = position.add(layer.offset); - camerClipBounds.location = camerClipBounds.location.subtract(position); - var tileWidth = layer.map.tileWidth * scale.x; - var tileHeight = layer.map.tileHeight * scale.y; - var minX, minY, maxX, maxY = 0; - if (layer.map.requiresLargeTileCulling) { - minX = layer.map.worldToTilePositionX(camerClipBounds.left - (layer.map.maxTileWidth * scale.x - tileWidth)); - minY = layer.map.worldToTilePositionY(camerClipBounds.top - (layer.map.maxTileHeight * scale.y - tileHeight)); - maxX = layer.map.worldToTilePositionX(camerClipBounds.right + (layer.map.maxTileWidth * scale.x - tileWidth)); - maxY = layer.map.worldToTilePositionY(camerClipBounds.bottom + (layer.map.maxTileHeight * scale.y - tileHeight)); - } - else { - minX = layer.map.worldToTilePositionX(camerClipBounds.left); - minY = layer.map.worldToTilePositionY(camerClipBounds.top); - maxX = layer.map.worldToTilePositionX(camerClipBounds.right); - maxY = layer.map.worldToTilePositionY(camerClipBounds.bottom); - } - var color = es.DrawUtils.getColorMatrix(0xFFFFFF); - for (var y = minY; y <= maxY; y++) { - for (var x = minX; x <= maxX; x++) { - var tile = layer.getTile(x, y); - if (tile) - this.renderTile(tile, container, position, scale, tileWidth, tileHeight, color, layerDepth); - } - } - }; - TiledRendering.renderImageLayer = function (layer, container, position, scale, layerDepth) { - if (!layer.visible) - return; - var color = es.DrawUtils.getColorMatrix(0xFFFFFF); - var pos = es.Vector2.add(position, new es.Vector2(layer.offsetX, layer.offsetY).multiply(scale)); - if (!layer.image.texture.parent) - container.addChild(layer.image.texture); - layer.image.texture.x = pos.x; - layer.image.texture.y = pos.y; - layer.image.texture.scaleX = scale.x; - layer.image.texture.scaleY = scale.y; - layer.image.texture.filters = [color]; - }; - TiledRendering.renderObjectGroup = function (objGroup, container, position, scale, layerDepth) { - if (!objGroup.visible) - return; - function debugRender(obj, pos) { - if (!container) - return; - if (!es.Core.debugRenderEndabled) - return; - if (!obj.textField.parent && obj.name) { - obj.textField.text = obj.name; - obj.textField.size = 12; - obj.textField.fontFamily = "sans-serif"; - if (obj.shape) { - obj.textField.x = pos.x + (obj.shape.getBounds().width - obj.textField.width) / 2 + obj.shape.getBounds().x; - obj.textField.y = pos.y - obj.textField.height - 5 + obj.shape.getBounds().y; - } - else { - obj.textField.x = pos.x + (obj.width - obj.textField.width) / 2; - obj.textField.y = pos.y - obj.textField.height - 5; - } - obj.textField.background = true; - obj.textField.backgroundColor = 0xa0a0a4; - obj.textField.textColor = 0xffffff; - container.addChild(obj.textField); - } - } - for (var object in objGroup.objects) { - var obj = objGroup.objects[object]; - if (!obj.visible) - continue; - if (!es.Core.debugRenderEndabled) { - if (obj.objectType != es.TmxObjectType.tile && obj.objectType != es.TmxObjectType.text) - continue; - } - var pos = es.Vector2.add(position, new es.Vector2(obj.x, obj.y).multiply(scale)); - switch (obj.objectType) { - case es.TmxObjectType.basic: - if (!obj.shape.parent) { - obj.shape.x = obj.x; - obj.shape.y = obj.y; - container.addChild(obj.shape); - obj.shape.graphics.clear(); - obj.shape.graphics.lineStyle(1, 0xa0a0a4); - obj.shape.graphics.beginFill(0x979798, 0.5); - obj.shape.graphics.drawRect(0, 0, obj.width * scale.x, obj.height * scale.y); - obj.shape.graphics.endFill(); - debugRender(obj, pos); - } - break; - case es.TmxObjectType.point: - var size = objGroup.map.tileWidth * 0.5; - pos.x -= size * 0.5; - pos.y -= size * 0.5; - if (!obj.shape.parent) { - obj.shape.x = pos.x; - obj.shape.y = pos.y; - container.addChild(obj.shape); - obj.shape.graphics.clear(); - obj.shape.graphics.lineStyle(1, 0xa0a0a4); - obj.shape.graphics.beginFill(0x979798, 0.5); - obj.shape.graphics.drawCircle(0, 0, 1); - obj.shape.graphics.endFill(); - debugRender(obj, pos); - } - break; - case es.TmxObjectType.tile: - this.renderTilesetTile(objGroup, obj, container, pos, scale, debugRender); - break; - case es.TmxObjectType.ellipse: - pos = new es.Vector2(obj.x + obj.width * 0.5, obj.y + obj.height * 0.5).multiply(scale); - if (!obj.shape.parent) { - obj.shape.x = pos.x; - obj.shape.y = pos.y; - container.addChild(obj.shape); - obj.shape.graphics.clear(); - obj.shape.graphics.lineStyle(1, 0xa0a0a4); - obj.shape.graphics.beginFill(0x979798, 0.5); - obj.shape.graphics.drawCircle(0, 0, obj.width * 0.5); - obj.shape.graphics.endFill(); - debugRender(obj, pos); - } - break; - case es.TmxObjectType.polygon: - case es.TmxObjectType.polyline: - var points = []; - for (var i = 0; i < obj.points.length; i++) - points[i] = es.Vector2.multiply(obj.points[i], scale); - if (!obj.shape.parent && points.length > 0) { - obj.shape.x = pos.x; - obj.shape.y = pos.y; - container.addChild(obj.shape); - obj.shape.graphics.clear(); - obj.shape.graphics.lineStyle(1, 0xa0a0a4); - for (var i = 0; i < points.length; i++) { - if (i == 0) { - obj.shape.graphics.moveTo(points[i].x, points[i].y); - } - else { - obj.shape.graphics.lineTo(points[i].x, points[i].y); - } - } - obj.shape.graphics.endFill(); - debugRender(obj, pos); - } - break; - case es.TmxObjectType.text: - if (!obj.textField.parent) { - obj.textField.x = pos.x; - obj.textField.y = pos.y; - container.addChild(obj.textField); - obj.textField.text = obj.text.value; - obj.textField.textColor = obj.text.color; - obj.textField.bold = obj.text.bold != undefined ? obj.text.bold : false; - obj.textField.italic = obj.text.italic != undefined ? obj.text.italic : false; - obj.textField.size = obj.text.pixelSize; - obj.textField.fontFamily = obj.text.fontFamily; - } - break; - default: - break; - } - } - }; - TiledRendering.renderTilesetTile = function (objGroup, obj, container, pos, scale, debugRender) { - var tileset = objGroup.map.getTilesetForTileGid(obj.tile.gid); - var sourceRect = tileset.tileRegions.get(obj.tile.gid); - if (container) { - if (tileset.image) { - if (obj.tile.horizontalFlip && obj.tile.verticalFlip) { - pos.x += tileset.tileHeight + (sourceRect.height * scale.y - tileset.tileHeight); - pos.y -= (sourceRect.width * scale.x - tileset.tileWidth); - } - else if (obj.tile.horizontalFlip) { - pos.x += tileset.tileWidth + (sourceRect.height * scale.y - tileset.tileHeight); - } - else if (obj.tile.verticalFlip) { - pos.y += (tileset.tileWidth - sourceRect.width * scale.x); - } - else { - pos.y += (tileset.tileHeight - sourceRect.height * scale.y); - } - var texture = tileset.image.bitmap.getTexture("" + obj.tile.gid); - if (!texture) { - texture = tileset.image.bitmap.createTexture("" + obj.tile.gid, sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height); - } - tileset.image.texture = new Bitmap(texture); - container.addChild(tileset.image.texture); - tileset.image.texture.x = pos.x; - tileset.image.texture.y = pos.y; - if (obj.tile.verticalFlip && obj.tile.horizontalFlip) { - tileset.image.texture.scaleX = -1; - tileset.image.texture.scaleY = -1; - } - else if (obj.tile.verticalFlip) { - tileset.image.texture.scaleX = scale.x; - tileset.image.texture.scaleY = -1; - } - else if (obj.tile.horizontalFlip) { - tileset.image.texture.scaleX = -1; - tileset.image.texture.scaleY = scale.y; - } - else { - tileset.image.texture.scaleX = scale.x; - tileset.image.texture.scaleY = scale.y; - } - tileset.image.texture.anchorOffsetX = 0; - tileset.image.texture.anchorOffsetY = 0; - debugRender(obj, pos); - } - else { - var tilesetTile = tileset.tiles.get(obj.tile.gid); - var texture = tilesetTile.image.bitmap.getTexture("" + obj.tile.gid); - if (!texture) { - texture = tilesetTile.image.bitmap.createTexture("" + obj.tile.gid, sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height); - } - pos.y -= obj.height; - tilesetTile.image.texture = new Bitmap(texture); - container.addChild(tilesetTile.image.texture); - tilesetTile.image.texture.width = obj.width; - tilesetTile.image.texture.height = obj.height; - tilesetTile.image.texture.x = pos.x; - tilesetTile.image.texture.y = pos.y; - if (obj.tile.verticalFlip && obj.tile.horizontalFlip) { - tilesetTile.image.texture.scaleX = -1; - tilesetTile.image.texture.scaleY = -1; - } - else if (obj.tile.verticalFlip) { - tilesetTile.image.texture.scaleX = scale.x; - tilesetTile.image.texture.scaleY = -1; - } - else if (obj.tile.horizontalFlip) { - tilesetTile.image.texture.scaleX = -1; - tilesetTile.image.texture.scaleY = scale.y; - } - else { - tilesetTile.image.texture.scaleX = scale.x; - tilesetTile.image.texture.scaleY = scale.y; - } - tilesetTile.image.texture.anchorOffsetX = 0; - tilesetTile.image.texture.anchorOffsetY = 0; - } - } - }; - TiledRendering.renderGroup = function (group, container, position, scale, layerDepth) { - var _this = this; - if (!group.visible) - return; - group.layers.forEach(function (layer) { - if (layer instanceof es.TmxGroup) { - _this.renderGroup(layer, container, position, scale, layerDepth); - } - if (layer instanceof es.TmxObjectGroup) { - _this.renderObjectGroup(layer, container, position, scale, layerDepth); - } - if (layer instanceof es.TmxLayer) { - _this.renderLayer(layer, container, position, scale, layerDepth); - } - if (layer instanceof es.TmxImageLayer) { - _this.renderImageLayer(layer, container, position, scale, layerDepth); - } - }); - }; - TiledRendering.renderTile = function (tile, container, position, scale, tileWidth, tileHeight, color, layerDepth) { - var gid = tile.gid; - var tilesetTile = tile.tilesetTile; - if (tilesetTile && tilesetTile.animationFrames.length > 0) - gid = tilesetTile.currentAnimationFrameGid; - var sourceRect = tile.tileset.tileRegions.get(gid); - var tx = Math.floor(tile.x) * tileWidth; - var ty = Math.floor(tile.y) * tileHeight; - var rotation = 0; - if (tile.horizontalFlip && tile.verticalFlip) { - tx += tileHeight + (sourceRect.height * scale.y - tileHeight); - ty -= (sourceRect.width * scale.x - tileWidth); - } - else if (tile.horizontalFlip) { - tx += tileWidth + (sourceRect.height * scale.y - tileHeight); - } - else if (tile.verticalFlip) { - ty += (tileWidth - sourceRect.width * scale.x); - } - else { - ty += (tileHeight - sourceRect.height * scale.y); - } - var pos = new es.Vector2(tx, ty).add(position); - if (tile.tileset.image) { - if (container) { - var texture = tile.tileset.image.bitmap.getTexture("" + gid); - if (!texture) { - texture = tile.tileset.image.bitmap.createTexture("" + gid, sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height); - } - tile.tileset.image.texture = new Bitmap(texture); - container.addChild(tile.tileset.image.texture); - if (tile.tileset.image.texture.x != pos.x) - tile.tileset.image.texture.x = pos.x; - if (tile.tileset.image.texture.y != pos.y) - tile.tileset.image.texture.y = pos.y; - if (tile.verticalFlip && tile.horizontalFlip) { - tile.tileset.image.texture.scaleX = -1; - tile.tileset.image.texture.scaleY = -1; - } - else if (tile.verticalFlip) { - tile.tileset.image.texture.scaleX = scale.x; - tile.tileset.image.texture.scaleY = -1; - } - else if (tile.horizontalFlip) { - tile.tileset.image.texture.scaleX = -1; - tile.tileset.image.texture.scaleY = scale.y; - } - else { - tile.tileset.image.texture.scaleX = scale.x; - tile.tileset.image.texture.scaleY = scale.y; - } - if (tile.tileset.image.texture.rotation != rotation) - tile.tileset.image.texture.rotation = rotation; - if (tile.tileset.image.texture.anchorOffsetX != 0) - tile.tileset.image.texture.anchorOffsetX = 0; - if (tile.tileset.image.texture.anchorOffsetY != 0) - tile.tileset.image.texture.anchorOffsetY = 0; - } - } - else { - if (tilesetTile.image.texture) { - if (!tilesetTile.image.bitmap.getTexture(gid.toString())) { - tilesetTile.image.texture = new Bitmap(tilesetTile.image.bitmap.createTexture(gid.toString(), sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height)); - container.addChild(tilesetTile.image.texture); - } - tilesetTile.image.texture.x = pos.x; - tilesetTile.image.texture.y = pos.y; - tilesetTile.image.texture.scaleX = scale.x; - tilesetTile.image.texture.scaleY = scale.y; - tilesetTile.image.texture.rotation = rotation; - tilesetTile.image.texture.anchorOffsetX = 0; - tilesetTile.image.texture.anchorOffsetY = 0; - tilesetTile.image.texture.filters = [color]; - } - } - }; - return TiledRendering; - }()); - es.TiledRendering = TiledRendering; -})(es || (es = {})); -var es; -(function (es) { - var TmxTileset = (function (_super) { - __extends(TmxTileset, _super); - function TmxTileset() { - return _super !== null && _super.apply(this, arguments) || this; - } - TmxTileset.prototype.update = function () { - this.tiles.forEach(function (value) { - value.updateAnimatedTiles(); - }); - }; - return TmxTileset; - }(es.TmxDocument)); - es.TmxTileset = TmxTileset; - var TmxTileOffset = (function () { - function TmxTileOffset() { - } - return TmxTileOffset; - }()); - es.TmxTileOffset = TmxTileOffset; - var TmxTerrain = (function () { - function TmxTerrain() { - } - return TmxTerrain; - }()); - es.TmxTerrain = TmxTerrain; -})(es || (es = {})); -var es; -(function (es) { - var TmxTilesetTile = (function () { - function TmxTilesetTile() { - } - Object.defineProperty(TmxTilesetTile.prototype, "currentAnimationFrameGid", { - get: function () { - return this.animationFrames[this._animationCurrentFrame].gid + this.tileset.firstGid; - }, - enumerable: true, - configurable: true - }); - TmxTilesetTile.prototype.processProperties = function () { - var value; - value = this.properties.get("engine.isDestructable"); - if (value) - this.isDestructable = Boolean(value); - value = this.properties.get("engine:isSlope"); - if (value) - this.isSlope = Boolean(value); - value = this.properties.get("engine:isOneWayPlatform"); - if (value) - this.isOneWayPlatform = Boolean(value); - value = this.properties.get("engine:slopeTopLeft"); - if (value) - this.slopeTopLeft = Number(value); - value = this.properties.get("engine:slopeTopRight"); - if (value) - this.slopeTopRight = Number(value); - }; - TmxTilesetTile.prototype.updateAnimatedTiles = function () { - if (this.animationFrames.length == 0) - return; - this._animationElapsedTime += es.Time.deltaTime; - if (this._animationElapsedTime > this.animationFrames[this._animationCurrentFrame].duration) { - this._animationCurrentFrame = es.MathHelper.incrementWithWrap(this._animationCurrentFrame, this.animationFrames.length); - this._animationElapsedTime = 0; - } - }; - return TmxTilesetTile; - }()); - es.TmxTilesetTile = TmxTilesetTile; - var TmxAnimationFrame = (function () { - function TmxAnimationFrame() { - } - return TmxAnimationFrame; - }()); - es.TmxAnimationFrame = TmxAnimationFrame; -})(es || (es = {})); -var es; -(function (es) { - var TmxUtils = (function () { - function TmxUtils() { - } - TmxUtils.decode = function (data, encoding, compression) { - compression = compression || "none"; - encoding = encoding || "none"; - switch (encoding) { - case "base64": - var decoded = es.Base64Utils.decodeBase64AsArray(data, 4); - return (compression === "none") ? decoded : es.Base64Utils.decompress(data, decoded, compression); - case "csv": - return es.Base64Utils.decodeCSV(data); - case "none": - var datas = []; - for (var i = 0; i < data.length; i++) { - datas[i] = +data[i].gid; - } - return datas; - default: - throw new Error("未定义的编码:" + encoding); - } - }; - TmxUtils.color16ToUnit = function ($color) { - if (!$color) - return 0xFFFFFF; - var colorStr = "0x" + $color.slice(1); - return parseInt(colorStr, 16); - }; - return TmxUtils; - }()); - es.TmxUtils = TmxUtils; -})(es || (es = {})); diff --git a/demo/libs/framework_tiled/framework_tiled.min.js b/demo/libs/framework_tiled/framework_tiled.min.js deleted file mode 100644 index 2ff5d590..00000000 --- a/demo/libs/framework_tiled/framework_tiled.min.js +++ /dev/null @@ -1 +0,0 @@ -window.es={},window.__extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}}();var __awaiter=this&&this.__awaiter||function(e,t,i,r){return new(i||(i=Promise))(function(n,a){function o(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){e.done?n(e.value):new i(function(t){t(e.value)}).then(o,s)}l((r=r.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var i,r,n,a,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,r&&(n=2&a[0]?r.return:a[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,a[1])).done)return n;switch(r=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(n=(n=o.trys).length>0&&n[n.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]=0&&(t.push(this.findBoundsRect(i,a,n,e)),i=-1)}i>=0&&(t.push(this.findBoundsRect(i,this.map.width,n,e)),i=-1)}return t},t.prototype.findBoundsRect=function(t,i,r,n){for(var a=-1,o=r+1;othis.tileHeight||this.maxTileWidth>this.tileWidth},enumerable:!0,configurable:!0}),i.prototype.getTilesetForTileGid=function(e){if(0==e)return null;for(var t=this.tilesets.length-1;t>=0;t--)if(this.tilesets[t].firstGid<=e)return this.tilesets[t];console.error("tile gid"+e+"未在任何tileset中找到")},i.prototype.worldToTilePositionX=function(t,i){void 0===i&&(i=!0);var r=Math.floor(t/this.tileWidth);return i?e.MathHelper.clamp(r,0,this.width-1):r},i.prototype.worldToTilePositionY=function(t,i){void 0===i&&(i=!0);var r=Math.floor(t/this.tileHeight);return i?e.MathHelper.clamp(r,0,this.height-1):r},i.prototype.getLayer=function(e){return this.layers[e]},i.prototype.update=function(){this.tilesets.forEach(function(e){e.update()})},i.prototype.dispose=function(e){void 0===e&&(e=!0),this._isDisposed||(e&&(this.tilesets.forEach(function(e){e.image&&e.image.dispose()}),this.imageLayers.forEach(function(e){e.image&&e.image.dispose()})),this._isDisposed=!0)},i}(e.TmxDocument);e.TmxMap=t,function(e){e[e.unknown=0]="unknown",e[e.orthogonal=1]="orthogonal",e[e.isometric=2]="isometric",e[e.staggered=3]="staggered",e[e.hexagonal=4]="hexagonal"}(e.OrientationType||(e.OrientationType={})),function(e){e[e.x=0]="x",e[e.y=1]="y"}(e.StaggerAxisType||(e.StaggerAxisType={})),function(e){e[e.odd=0]="odd",e[e.even=1]="even"}(e.StaggerIndexType||(e.StaggerIndexType={})),function(e){e[e.rightDown=0]="rightDown",e[e.rightUp=1]="rightUp",e[e.leftDown=2]="leftDown",e[e.leftUp=3]="leftUp"}(e.RenderOrderType||(e.RenderOrderType={}))}(es||(es={})),function(e){var t=function(){return function(){}}();e.TmxObjectGroup=t;var i=function(){return function(){this.shape=new egret.Shape,this.textField=new egret.TextField}}();e.TmxObject=i;var r=function(){return function(){}}();e.TmxText=r;var n=function(){return function(){}}();e.TmxAlignment=n,function(e){e[e.basic=0]="basic",e[e.point=1]="point",e[e.tile=2]="tile",e[e.ellipse=3]="ellipse",e[e.polygon=4]="polygon",e[e.polyline=5]="polyline",e[e.text=6]="text"}(e.TmxObjectType||(e.TmxObjectType={})),function(e){e[e.unkownOrder=-1]="unkownOrder",e[e.TopDown=0]="TopDown",e[e.IndexOrder=1]="IndexOrder"}(e.DrawOrderType||(e.DrawOrderType={})),function(e){e[e.left=0]="left",e[e.center=1]="center",e[e.right=2]="right",e[e.justify=3]="justify"}(e.TmxHorizontalAlignment||(e.TmxHorizontalAlignment={})),function(e){e[e.top=0]="top",e[e.center=1]="center",e[e.bottom=2]="bottom"}(e.TmxVerticalAlignment||(e.TmxVerticalAlignment={}))}(es||(es={})),function(e){var t=function(){function t(){}return t.loadTmxMap=function(e,t){var i=RES.getRes(t);return this.loadTmxMapData(e,i,RES.getResourceInfo(t))},t.loadTmxMapData=function(t,i,r){return __awaiter(this,void 0,void 0,function(){var n,a,o,s;return __generator(this,function(l){switch(l.label){case 0:t.version=i.version,t.tiledVersion=i.tiledversion,t.width=i.width,t.height=i.height,t.tileWidth=i.tilewidth,t.tileHeight=i.tileheight,t.hexSideLength=i.hexsidelength,t.orientation=this.parseOrientationType(i.orientation),t.staggerAxis=this.parseStaggerAxisType(i.staggeraxis),t.staggerIndex=this.parseStaggerIndexType(i.staggerindex),t.renderOrder=this.parseRenderOrderType(i.renderorder),t.nextObjectID=i.nextobjectid,t.backgroundColor=e.TmxUtils.color16ToUnit(i.color),t.properties=this.parsePropertyDict(i.properties),t.maxTileWidth=t.tileWidth,t.maxTileHeight=t.tileHeight,t.tmxDirectory=r.root+r.url.replace(".","_").replace(r.name,""),t.tilesets=[],n=0,a=i.tilesets,l.label=1;case 1:return ne.map.maxTileWidth&&(e.map.maxTileWidth=t.image.width),t.image.height>e.map.maxTileHeight&&(e.map.maxTileHeight=t.image.height))}),e.tileRegions.forEach(function(t){var i=t.width,r=t.height;i>e.map.maxTileWidth&&(e.map.maxTileWidth=i),i>e.map.maxTileHeight&&(e.map.maxTileHeight=r)})},t.parseOrientationType=function(t){return"unknown"==t?e.OrientationType.unknown:"orthogonal"==t?e.OrientationType.orthogonal:"isometric"==t?e.OrientationType.isometric:"staggered"==t?e.OrientationType.staggered:"hexagonal"==t?e.OrientationType.hexagonal:e.OrientationType.unknown},t.parseStaggerAxisType=function(t){return"y"==t?e.StaggerAxisType.y:e.StaggerAxisType.x},t.parseStaggerIndexType=function(t){return"even"==t?e.StaggerIndexType.even:e.StaggerIndexType.odd},t.parseRenderOrderType=function(t){return"right-up"==t?e.RenderOrderType.rightUp:"left-down"==t?e.RenderOrderType.leftDown:"left-up"==t?e.RenderOrderType.leftUp:e.RenderOrderType.rightDown},t.parsePropertyDict=function(t){if(!t)return null;for(var i=new Map,r=0,n=t;r=t.columns));x+=t.tileWidth+t.spacing);else t.tiles.forEach(function(i,r){t.tileRegions.set(r,new e.Rectangle(0,0,i.image.width,i.image.height))});return[2,t]}})})},t.loadTmxTilesetTile=function(t,i,r,n,a){return __awaiter(this,void 0,void 0,function(){var o,s,l,h,p,c,u,d,g,m,f,x,y;return __generator(this,function(T){switch(T.label){case 0:if(t.tileset=i,t.id=r.id,o=r.terrain)for(t.terrainEdges=new Array(4),s=0,l=0,h=o;l0){s.shape.x=l.x,s.shape.y=l.y,i.addChild(s.shape),s.shape.graphics.clear(),s.shape.graphics.lineStyle(1,10526884);for(c=0;c0&&(p=c.currentAnimationFrameGid);var u=i.tileset.tileRegions.get(p),d=Math.floor(i.x)*o,g=Math.floor(i.y)*s;i.horizontalFlip&&i.verticalFlip?(d+=s+(u.height*a.y-s),g-=u.width*a.x-o):i.horizontalFlip?d+=o+(u.height*a.y-s):i.verticalFlip?g+=o-u.width*a.x:g+=s-u.height*a.y;var m=new e.Vector2(d,g).add(n);if(i.tileset.image){if(r){var f=i.tileset.image.bitmap.getTexture(""+p);f||(f=i.tileset.image.bitmap.createTexture(""+p,u.x,u.y,u.width,u.height)),i.tileset.image.texture=new t(f),r.addChild(i.tileset.image.texture),i.tileset.image.texture.x!=m.x&&(i.tileset.image.texture.x=m.x),i.tileset.image.texture.y!=m.y&&(i.tileset.image.texture.y=m.y),i.verticalFlip&&i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=-1):i.verticalFlip?(i.tileset.image.texture.scaleX=a.x,i.tileset.image.texture.scaleY=-1):i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=a.y):(i.tileset.image.texture.scaleX=a.x,i.tileset.image.texture.scaleY=a.y),0!=i.tileset.image.texture.rotation&&(i.tileset.image.texture.rotation=0),0!=i.tileset.image.texture.anchorOffsetX&&(i.tileset.image.texture.anchorOffsetX=0),0!=i.tileset.image.texture.anchorOffsetY&&(i.tileset.image.texture.anchorOffsetY=0)}}else c.image.texture&&(c.image.bitmap.getTexture(p.toString())||(c.image.texture=new t(c.image.bitmap.createTexture(p.toString(),u.x,u.y,u.width,u.height)),r.addChild(c.image.texture)),c.image.texture.x=m.x,c.image.texture.y=m.y,c.image.texture.scaleX=a.x,c.image.texture.scaleY=a.y,c.image.texture.rotation=0,c.image.texture.anchorOffsetX=0,c.image.texture.anchorOffsetY=0,c.image.texture.filters=[l])},i}();e.TiledRendering=i}(es||(es={})),function(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.update=function(){this.tiles.forEach(function(e){e.updateAnimatedTiles()})},t}(e.TmxDocument);e.TmxTileset=t;var i=function(){return function(){}}();e.TmxTileOffset=i;var r=function(){return function(){}}();e.TmxTerrain=r}(es||(es={})),function(e){var t=function(){function t(){}return Object.defineProperty(t.prototype,"currentAnimationFrameGid",{get:function(){return this.animationFrames[this._animationCurrentFrame].gid+this.tileset.firstGid},enumerable:!0,configurable:!0}),t.prototype.processProperties=function(){var e;(e=this.properties.get("engine.isDestructable"))&&(this.isDestructable=Boolean(e)),(e=this.properties.get("engine:isSlope"))&&(this.isSlope=Boolean(e)),(e=this.properties.get("engine:isOneWayPlatform"))&&(this.isOneWayPlatform=Boolean(e)),(e=this.properties.get("engine:slopeTopLeft"))&&(this.slopeTopLeft=Number(e)),(e=this.properties.get("engine:slopeTopRight"))&&(this.slopeTopRight=Number(e))},t.prototype.updateAnimatedTiles=function(){0!=this.animationFrames.length&&(this._animationElapsedTime+=e.Time.deltaTime,this._animationElapsedTime>this.animationFrames[this._animationCurrentFrame].duration&&(this._animationCurrentFrame=e.MathHelper.incrementWithWrap(this._animationCurrentFrame,this.animationFrames.length),this._animationElapsedTime=0))},t}();e.TmxTilesetTile=t;var i=function(){return function(){}}();e.TmxAnimationFrame=i}(es||(es={})),function(e){var t=function(){function t(){}return t.decode=function(t,i,r){switch(r=r||"none",i=i||"none"){case"base64":var n=e.Base64Utils.decodeBase64AsArray(t,4);return"none"===r?n:e.Base64Utils.decompress(t,n,r);case"csv":return e.Base64Utils.decodeCSV(t);case"none":for(var a=[],o=0;o - * Before calling this method requires the application of any resource load, we recommend starting at the application entry class (Main) The first call processing. This method is only responsible for acquiring version information, is not responsible for downloaded resources. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取版本信息数据。
- * 这个方法的调用需要在应用程序进行任何资源加载之前,建议在应用程序的入口类(Main)的开始最先进行调用处理。此方法只负责获取版本信息,不负责资源的下载。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - init(): Promise; - /** - * Get the actual URL of the resource file.
- * Because this method needs to be called to control the actual version of the URL have the original resource files were changed, so would like to get the specified resource file the actual URL.
- * In the development and debugging phase, this method will directly return value passed. - * @param url Url used in the game - * @returns Actual loaded url - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取资源文件实际的URL地址。
- * 由于版本控制实际已经对原来的资源文件的URL进行了改变,因此想获取指定资源文件实际的URL时需要调用此方法。
- * 在开发调试阶段,这个方法会直接返回传入的参数值。 - * @param url 游戏中使用的url - * @returns 实际加载的url - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getVirtualUrl(url: string): string; - } - /** - * Manage version control class - * @version Egret 2.4 - * @platform Web,Native - * @event egret.Event.COMPLETE Version control loading is complete when thrown - * @event egret.IOErrorEvent.IO_ERROR Version control failed to load when thrown - * @includeExample extension/version/VersionControl.ts - * @language en_US - */ - /** - * 管理版本控制的类 - * @version Egret 2.4 - * @platform Web,Native - * @event egret.Event.COMPLETE 版本控制加载完成时抛出 - * @event egret.IOErrorEvent.IO_ERROR 版本控制加载失败时抛出 - * @includeExample extension/version/VersionControl.ts - * @language zh_CN - */ - interface VersionController extends IVersionController { - } - /** - * @version Egret 2.4 - * @platform Web,Native - */ - let VersionController: { - /** - * Constructor initialization - * @language en_US - */ - /** - * 初始化构造函数 - * @language zh_CN - */ - new (): VersionController; - }; -} -declare type ResourceRootSelector = () => T; -declare type ResourceNameSelector = (file: string) => string; -declare type ResourceMergerSelector = (file: string) => { - path: string; - alias: string; -}; -declare module RES { - /** - * Get resource information through file path - * @param path file path - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 通过文件路径获取资源信息 - * @param path 文件路径 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResourceInfo(path: string): File | null; - /** - * @private - */ - interface ResourceInfo { - url: string; - type: string; - root: string; - crc32?: string; - size?: number; - extra?: 1 | undefined; - name: string; - soundType?: string; - scale9grid?: string; - groupNames?: string[]; - promise?: Promise; - } - /** - * @private - */ - interface Data { - resourceRoot: string; - mergeSelector: ResourceMergerSelector | null; - fileSystem: FileSystem; - groups: { - [groupName: string]: string[]; - }; - alias: { - [aliasName: string]: string; - }; - loadGroup: string[]; - } - /** - * @class RES.ResourceConfig - * @classdesc - * @private - */ - class ResourceConfig { - config: Data; - constructor(); - init(): Promise; - /** - * 根据组名获取组加载项列表 - * @method RES.ResourceConfig#getGroupByName - * @param name {string} 组名 - * @returns {Array} - */ - getGroupByName(name: string): ResourceInfo[]; - __temp__get__type__via__url(url_or_alias: string): string; - getResourceWithSubkey(key: string): { - r: ResourceInfo; - key: string; - subkey: string; - } | null; - getKeyByAlias(aliasName: string): string; - getResource(path_or_alias: string): ResourceInfo | null; - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或sbuKeys属性的一项或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * 添加一个二级键名到配置列表。 - * @method RES.ResourceConfig#addSubkey - * @param subkey {string} 要添加的二级键名 - * @param name {string} 二级键名所属的资源name属性 - */ - addSubkey(subkey: string, name: string): void; - addAlias(alias: any, key: any): void; - addResourceData(data: { - name: string; - type: string; - url: string; - root?: string; - extra?: 1 | undefined; - }): void; - removeResourceData(data: { - name: string; - type?: string; - url: string; - root?: string; - extra?: 1 | undefined; - }): void; - } -} -declare module RES { - /** - * @class RES.ResourceLoader - * @classdesc - * @private - */ - class ResourceLoader { - /** - * 当前组加载的项总个数,key为groupName - */ - private groupTotalDic; - /** - * 已经加载的项个数,key为groupName - */ - private numLoadedDic; - /** - * 加载失败的组,key为groupName - */ - private groupErrorDic; - private retryTimesDic; - maxRetryTimes: number; - private reporterDic; - private dispatcherDic; - private failedList; - private loadItemErrorDic; - private errorDic; - /** - * 资源优先级队列,key为资源,value为优先级 - */ - private itemListPriorityDic; - /** - * 资源是否在加载 - */ - private itemLoadDic; - private promiseHash; - /** - * 延迟加载队列,getResByUrl ,getResAsync等方法存储队列 - */ - private lazyLoadList; - pushResItem(resInfo: ResourceInfo): Promise; - /** - * 加载队列,存储组的队列 - */ - pushResGroup(list: ResourceInfo[], groupName: string, priority: number, reporter?: PromiseTaskReporter): Promise; - /** - * 更新组的优先级顺序 - * @param list 存储数据的队列 - * @param priority 优先级 - */ - private updatelistPriority(list, priority); - /** - * 搜索单项资源的优先级 - * @param item 单项资源 - */ - private findPriorityInDic(item); - private loadingCount; - /** - * 最大线程数目 - */ - thread: number; - /** - * 加载下一项资源,线程控制 - */ - private loadNextResource(); - /** - * 加载单向资源 - */ - private loadSingleResource(); - /** - * 获取下一个待加载项 - */ - private getOneResourceInfoInGroup(); - /** - * 设置组的加载进度,同时返回当前组是否加载完成 - * @param groupName 组名 - * @param r 加载完成的资源 - */ - private setGroupProgress(groupName, r); - /** - * 加载组的最后一项,同时派发事件 - * @param groupName 组名 - * @param lastError 最后一项是否成功,此项为错误信息 - */ - private loadGroupEnd(groupName, lastError?); - /** - * 删除事件派发器,Promise的缓存,返回事件派发器 - * @param groupName 组名或是root+name - */ - private deleteDispatcher(groupName); - /** - * 加载资源 - * @param r 资源信息 - * @param p 加载处理器 - */ - private loadResource(r, p?); - /** - * 释放资源 - * @param r 资源信息 - */ - unloadResource(r: ResourceInfo): boolean; - } -} -declare module RES { -} -declare module RES { - type GetResAsyncCallback = (value?: any, key?: string) => any; - /** - * Convert the file name of the resource to the Key value used in the project. - * @param url Resource Name. - * @returns The key value used in the project - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 将资源的文件名称转换为项目中所使用的Key值。 - * 在加载合并图集的时候使用,例如图集加载A_json,需要加载对应A_png,这里就是转换的机制 - * 一般项目中无需更改,只有没有使用默认的key和文件对应的需要修改 - * @param url 资源名称。 - * @returns 项目中所用的key值 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function nameSelector(url: any): string; - /** - * Get the read type of the file. - * When using getResByUrl does not specify the type of the read file, it will find the corresponding type according to this method. - * File types not found are loaded by default in binary format - * @param path file path. - * @returns Processor type used to read the file - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文件的读取类型 - * 在使用getResByUrl没有指定读取文件的类型,会根据这个方法寻找对应的类型 - * 没有查找到的文件类型以二进制格式默认加载 - * @param path 文件路径 - * @returns 读取文件所用的Processor类型 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function typeSelector(path: string): string; - /** - * Conduct mapping injection with class definition as the value, Deprecated. - * @deprecated - * @see RES.processor.map - * @language en_US - */ - /** - * 以类定义为值进行映射注入,已废弃。 - * @deprecated - * @see RES.processor.map - * @language zh_CN - */ - function registerAnalyzer(type: string, analyzerClass: any): void; - /** - * Set whether it is compatible mode - * When the value is true, the assetsManager will output the design of Res. When it is false, all the loaded resources will be returned as promises. - * The default is false, run in strict assetsManager mode - * @version Egret 5.2.9 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否为兼容模式 - * 当值为true时,assetsManager会以Res的设计输出,当为false时候,所有的加载资源都会以promise的方式返回 - * 默认是false,以严格assetsManager方式运行 - * @version Egret 5.2.9 - * @platform Web,Native - * @language zh_CN - */ - function setIsCompatible(value: boolean): void; - /** - * Load configuration file and parse. - * @param url The url address of the resource config - * @param resourceRoot The root address of the resource config - * @returns Promise - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 加载配置文件并解析。 - * @param url 资源配置的url地址 - * @param resourceRoot 资源配置的根地址 - * @returns Promise - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function loadConfig(url: string, resourceRoot: string): Promise; - /** - * Load a set of resources according to the group name. - * @param name Group name to load the resource group. - * @param priority Load priority can be negative, the default value is 0. - *
A low priority group must wait for the high priority group to complete the end of the load to start, and the same priority group will be loaded at the same time. - * @param reporter Resource group loading progress prompt - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名加载一组资源。 - * @param name 要加载资源组的组名。 - * @param priority 加载优先级,可以为负数,默认值为 0。 - *
低优先级的组必须等待高优先级组完全加载结束才能开始,同一优先级的组会同时加载。 - * @param reporter 资源组的加载进度提示 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise; - /** - * Check whether a resource group has been loaded. - * @param name Group name。 - * @returns Is loading or not. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 检查某个资源组是否已经加载完成。 - * @param name 组名。 - * @returns 是否正在加载。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function isGroupLoaded(name: string): boolean; - /** - * A list of groups of loading is obtained according to the group name. - * @param name Group name. - * @returns The resource item array of group. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名获取组加载项列表。 - * @param name 组名。 - * @returns 加载项列表。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getGroupByName(name: string): Array; - /** - * Create a custom load resource group, note that this method is valid only after the resource configuration file is loaded. - *
You can monitor the ResourceEvent.CONFIG_COMPLETE event to verify that the configuration is complete. - * @param name Group name to create the load resource group. - * @param keys To be included in the list of key keys, the corresponding configuration file in the name or sbuKeys property one or a resource group name. - * @param override Is the default false for the same name resource group already exists. - * @returns Create success or fail. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - *
可以监听 ResourceEvent.CONFIG_COMPLETE 事件来确认配置加载完成。 - * @param name 要创建的加载资源组的组名。 - * @param keys 要包含的键名列表,key 对应配置文件里的 name 属性或 sbuKeys 属性的一项或一个资源组名。 - * @param override 是否覆盖已经存在的同名资源组,默认 false。 - * @returns 是否创建成功。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * Check whether the configuration file contains the specified resources. - * @param key A sbuKeys attribute or name property in a configuration file. - * @returns Whether you have the specified resource - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 检查配置文件里是否含有指定的资源。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @returns 是否拥有指定资源 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function hasRes(key: string): boolean; - /** - * The synchronization method for obtaining the cache has been loaded with the success of the resource. - *
The type of resource and the corresponding return value types are as follows: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript primary object - *
RES.ResourceItem.TYPE_IMAGE : img Html Object,or egret.BitmapData interface。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. If the incoming parameter is the name of the entire SpriteSheet is returned is {image1: Texture, "image2": Texture}. - *
2. If the incoming is "sheet.image1", the return is a single resource. - *
3. If the incoming is the name of the "image1" single resource, the return is a single resource. - * But if there are two SpriteSheet in a single picture of the same name, the return of the image after the load. - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html Object - *
RES.ResourceItem.TYPE_TEXT : string - * @param key A subKeys attribute or name property in a configuration file. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 同步方式获取缓存的已经加载成功的资源。 - *
资源类型和对应的返回值类型关系如下: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript 原生对象 - *
RES.ResourceItem.TYPE_IMAGE : img Html 对象,或者 egret.BitmapData 接口。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. 如果传入的参数是整个 SpriteSheet 的名称返回的是 {"image1":Texture,"image2":Texture} 这样的格式。 - *
2. 如果传入的是 "sheet.image1",返回的是单个资源。 - *
3. 如果传入的是 "image1" 单个资源的名称,返回的是单个资源。但是如果有两张 SpriteSheet 中有单个图片资源名称相同,返回的是后加载的那个图片资源。 - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html 对象 - *
RES.ResourceItem.TYPE_TEXT : string - * @param key 对应配置文件里的 name 属性或 subKeys 属性的一项。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getRes(key: string): any; - /** - * Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way. - * @param key A sbuKeys attribute or name property in a configuration file. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResAsync(key: string): Promise; - /** - * Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way. - * @param key A sbuKeys attribute or name property in a configuration file. - * @param compFunc Call back function. Example:compFunc(data,key):void. - * @param thisObject This pointer of call back function. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @param compFunc 回调函数。示例:compFunc(data,key):void。 - * @param thisObject 回调函数的 this 引用。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): Promise | void; - /** - * Access to external resources through the full URL. - * @param url The external path to load the file. - * @param compFunc Call back function. Example:compFunc(data,url):void。 - * @param thisObject This pointer of call back function. - * @param type File type (optional). Use the static constants defined in the ResourceItem class. If you do not set the file name extension. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 通过完整URL方式获取外部资源。 - * @param url 要加载文件的外部路径。 - * @param compFunc 回调函数。示例:compFunc(data,url):void。 - * @param thisObject 回调函数的 this 引用。 - * @param type 文件类型(可选)。请使用 ResourceItem 类中定义的静态常量。若不设置将根据文件扩展名生成。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResByUrl(url: string, compFunc?: Function, thisObject?: any, type?: string): Promise; - /** - * Destroy a single resource file or a set of resources to the cache data, to return whether to delete success. - * @param name Name attribute or resource group name of the load item in the configuration file. - * @param force Destruction of a resource group when the other resources groups have the same resource situation whether the resources will be deleted, the default value true. - * @returns Are successful destruction. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @param name 配置文件中加载项的name属性或资源组名。 - * @param force 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值 true。 - * @see #setMaxRetryTimes - * @returns 是否销毁成功。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function destroyRes(name: string, force?: boolean): boolean; - /** - * Sets the maximum number of concurrent load threads, the default value is 4. - * @param thread The number of concurrent loads to be set. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 设置最大并发加载线程数量,默认值是 4。 - * @param thread 要设置的并发加载数。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function setMaxLoadingThread(thread: number): void; - /** - * Sets the number of retry times when the resource failed to load, and the default value is 3. - * @param retry To set the retry count. - * @includeExample extension/resource/Resource.ts - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 设置资源加载失败时的重试次数,默认值是 3。 - * @param retry 要设置的重试次数。 - * @includeExample extension/resource/Resource.ts - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function setMaxRetryTimes(retry: number): void; - /** - * Add event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listener functions for handling events. This function must accept the Event object as its only parameter, and can't return any results, - * As shown in the following example: function (evt:Event):void can have any name. - * @param thisObject The this object that is bound to a function. - * @param useCapture Determine the listener is running on the capture or running on the target and the bubbling phase. Set useCapture to true, - * then the listener in the capture phase processing events, but not in the target or the bubbling phase processing events. - * If useCapture is false, then the listener only in the target or the bubbling phase processing events. - * To listen for events in all three stages, please call addEventListener two times: once the useCapture is set to true, once the useCapture is set to false. - * @param priority Event listener priority. Priority is specified by a 32 - bit integer with a symbol. The higher the number, the higher the priority. - * All listeners with a priority for n will be processed before the -1 n listener. - * If two or more listeners share the same priority, they are processed in accordance with the order of their added. The default priority is 0. - * @see RES.ResourceEvent - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 添加事件侦听器,参考 ResourceEvent 定义的常量。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的 this 对象。 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于目标和冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在目标或冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在目标或冒泡阶段处理事件。 - * 要在所有三个阶段都侦听事件,请调用 addEventListener 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号的 32 位整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see RES.ResourceEvent - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function addEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Remove event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listening function。 - * @param thisObject The this object that is bound to a function. - * @param useCapture Is used to capture, and this property is only valid in the display list. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 移除事件侦听器,参考ResourceEvent定义的常量。 - * @param type 事件名。 - * @param listener 侦听函数。 - * @param thisObject 侦听函数绑定的this对象。 - * @param useCapture 是否使用捕获,这个属性只在显示列表中生效。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function removeEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean): void; - /** - * Adding a custom resource configuration. - * @param data To add configuration. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 自定义添加一项资源配置。 - * @param data 要添加的配置。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function $addResourceData(data: { - name: string; - type: string; - url: string; - }): void; - /** - * Returns the VersionController - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获得版本控制器. - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getVersionController(): VersionController; - /** - * Register the VersionController - * @param vcs The VersionController to register. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 注册版本控制器,通过RES模块加载资源时会从版本控制器获取真实url - * @param vcs 注入的版本控制器。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function registerVersionController(vcs: VersionController): void; - /** - * Convert the address of the loaded resource (via version controller conversion) - * @param url path to the original resource - * @returns converted address - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 转换加载资源的地址(经过版本控制器的转换) - * @param url 原始资源的路径 - * @returns 转换后的地址 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getVirtualUrl(url: any): any; - /** - * @private - */ - class Resource extends egret.EventDispatcher { - vcs: VersionController; - isVcsInit: boolean; - constructor(); - registerVersionController(vcs: VersionController): void; - /** - * 开始加载配置 - * @method RES.loadConfig - */ - loadConfig(): Promise; - /** - * @private - * 版本控制器加载后的加载配置 - */ - private normalLoadConfig; - /** - * 检查某个资源组是否已经加载完成 - * @method RES.isGroupLoaded - * @param name {string} - */ - isGroupLoaded(name: string): boolean; - /** - * 根据组名获取组加载项列表 - * @method RES.getGroupByName - * @param name {string} - */ - getGroupByName(name: string): Array; - /** - * 根据组名加载一组资源 - * @method RES.loadGroup - * @param name {string} - * @param priority {number} - */ - loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise; - private _loadGroup(name, priority?, reporter?); - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * 检查配置文件里是否含有指定的资源 - * @method RES.hasRes - * @param key {string} 对应配置文件里的name属性或subKeys属性的一项。 - * @returns {boolean} - */ - hasRes(key: string): boolean; - /** - * 通过key同步获取资源 - * @method RES.getRes - * @param key {string} - * @returns {any} - */ - getRes(resKey: string): any; - /** - * 通过key异步获取资源 - * @method RES.getResAsync - * @param key {string} - * @param compFunc {Function} 回调函数。示例:compFunc(data,url):void。 - * @param thisObject {any} - */ - getResAsync(key: string): Promise; - getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): Promise; - /** - * 通过url获取资源 - * @method RES.getResByUrl - * @param url {string} - * @param compFunc {Function} - * @param thisObject {any} - * @param type {string} - */ - getResByUrl(url: string, compFunc?: Function, thisObject?: any, type?: string): Promise; - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @method RES.destroyRes - * @param name {string} 配置文件中加载项的name属性或资源组名 - * @param force {boolean} 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值true - * @returns {boolean} - */ - destroyRes(name: string, force?: boolean): boolean; - /** - * 设置最大并发加载线程数量,默认值是4. - * @method RES.setMaxLoadingThread - * @param thread {number} 要设置的并发加载数。 - */ - setMaxLoadingThread(thread: number): void; - /** - * 设置资源加载失败时的重试次数。 - * @param retry 要设置的重试次数。 - */ - setMaxRetryTimes(retry: number): void; - addResourceData(data: { - name: string; - type: string; - url: string; - }): void; - } -} -declare namespace RES { - /** - * Print the memory occupied by the picture. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 对文件路径的一些操作,针对的是 C:/A/B/C/D/example.ts这种格式 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - namespace path { - /** - * Format the file path,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" - * @param filename Incoming file path - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 格式化文件路径,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" - * @param filename 传入的文件路径 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function normalize(filename: string): string; - /** - * Get the file name according to the file path, "C:/A/B/example.ts"=>"example.ts" - * @param filename Incoming file path - * @return File name - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据文件路径得到文件名字,"C:/A/B/example.ts"=>"example.ts" - * @param filename 传入的文件路径 - * @return 文件的名字 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function basename(filename: string): string; - /** - * The path to the folder where the file is located,"C:/A/B/example.ts"=>"C:/A/B" - * @param filename Incoming file path - * @return The address of the folder where the file is located - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 文件所在文件夹路径,"C:/A/B/example.ts"=>"C:/A/B" - * @param filename 传入的文件路径 - * @return 文件所在文件夹的地址 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function dirname(path: string): string; - } -} -declare namespace RES { - /** - * @private - */ - class NativeVersionController implements IVersionController { - private versionInfo; - init(): Promise; - getVirtualUrl(url: string): string; - private getLocalData(filePath); - } -} -declare module RES.processor { - interface Processor { - /** - * Start loading a single resource - * @param host Load the processor, you can use the processor to load resources, directly use http to get the resources back - * @param resource Resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 开始加载单项资源 - * @param host 加载处理器,可以不使用这个处理器加载资源,直接用http获取资源返回即可 - * @param resource 资源的信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - onLoadStart(host: ProcessHost, resource: ResourceInfo): Promise; - /** - * Remove a single resource, usually call host.unload (resource); - * @param host Load the processor - * @param resource Resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 移除单项资源,一般调用host.unload(resource); - * @param host 加载处理器 - * @param resource 资源的信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - onRemoveStart(host: ProcessHost, resource: ResourceInfo): void; - /** - * Get the submap of the merged atlas - * @param host Load the processor - * @param resource Resource information - * @param key The key value of the resource - * @param subkey Collection of subset names - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获取合并图集的子图 - * @param host 加载处理器 - * @param resource 资源的信息 - * @param key 资源的key值 - * @param subkey 子集名称的集合 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - getData?(host: ProcessHost, resource: ResourceInfo, key: string, subkey: string): any; - } - /** - * Register the processor that loads the resource - * @param type Load resource type - * @param processor Loaded processor, an instance that implements the Processor interface - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 注册加载资源的处理器 - * @param type 加载资源类型 - * @param processor 加载的处理器,一个实现Processor接口的实例 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function map(type: string, processor: Processor): void; - /** - * @private - * @param url - * @param file - */ - function getRelativePath(url: string, file: string): string; - var ImageProcessor: Processor; - const KTXTextureProcessor: RES.processor.Processor; - /** - * - */ - function makeEtc1SeperatedAlphaResourceInfo(resource: ResourceInfo): ResourceInfo; - /** - * - */ - const ETC1KTXProcessor: Processor; - var BinaryProcessor: Processor; - var TextProcessor: Processor; - var JsonProcessor: Processor; - var SoundProcessor: Processor; -} -declare module RES { - /** - * The events of resource loading. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源加载事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - class ResourceEvent extends egret.Event { - /** - * Failure event for a load item. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 一个加载项加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static ITEM_LOAD_ERROR: string; - /** - * Configure file to load and parse the completion event. Note: if a configuration file is loaded, it will not be thrown out, and if you want to handle the configuration loading failure, monitor the CONFIG_LOAD_ERROR event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载并解析完成事件。注意:若有配置文件加载失败,将不会抛出此事件,若要处理配置加载失败,请同时监听 CONFIG_LOAD_ERROR 事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static CONFIG_COMPLETE: string; - /** - * Configuration file failed to load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static CONFIG_LOAD_ERROR: string; - /** - * Delay load group resource loading progress event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载进度事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_PROGRESS: string; - /** - * Delay load group resource to complete event. Note: if you have a resource item loading failure, the event will not be thrown, if you want to handle the group load failure, please listen to the GROUP_LOAD_ERROR event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载完成事件。注意:若组内有资源项加载失败,将不会抛出此事件,若要处理组加载失败,请同时监听 GROUP_LOAD_ERROR 事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_COMPLETE: string; - /** - * Delayed load group resource failed event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_LOAD_ERROR: string; - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 5.2 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 5.2 - * @platform Web,Native - * @private - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * File number that has been loaded. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 已经加载的文件数。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - itemsLoaded: number; - /** - * Total file number to load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 要加载的总文件数。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - itemsTotal: number; - /** - * Resource group name. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源组名。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - groupName: string; - /** - * An item of information that is finished by the end of a load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 一次加载项加载结束的项信息对象。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - resItem: ResourceItem; - } -} -declare module RES { - /** - * Resource term. One of the resources arrays in resource.json. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源项。对应 resource.json 中 resources 数组中的一项。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - namespace ResourceItem { - /** - * XML file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * XML 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_XML: string; - /** - * Picture file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 图片文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_IMAGE: string; - /** - * Binary file. - * @version Egret 5.2 - * @platform Web - * @language en_US - */ - /** - * 二进制文件。 - * @version Egret 5.2 - * @platform Web - * @language zh_CN - */ - const TYPE_BIN: string; - /** - * Text file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 文本文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_TEXT: string; - /** - * JSON file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * JSON 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_JSON: string; - /** - * SpriteSheet file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * SpriteSheet 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_SHEET: string; - /** - * BitmapTextSpriteSheet file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapTextSpriteSheet 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_FONT: string; - /** - * Sound file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 声音文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_SOUND: string; - function convertToResItem(r: ResourceInfo): ResourceItem; - } - interface ResourceItem extends ResourceInfo { - /** - * Name of resource term. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 加载项名称。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * URL of resource term. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 要加载的文件地址。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - url: string; - /** - * Type of resource term. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 加载项文件类型。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - type: string; - /** - * The raw data object to be referenced. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的原始数据对象。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - data: ResourceInfo; - crc32?: string; - size?: number; - soundType?: string; - } -} -declare module RES { - /** - * assetsManager underlying storage resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * assetsManager底层存储资源信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - interface File { - url: string; - type: string; - name: string; - root: string; - } - /** - * @private - */ - interface FileSystem { - addFile(data: { - name: string; - type: string; - url: string; - root?: string; - extra?: 1 | undefined; - }): any; - getFile(filename: string): File | null; - profile(): void; - removeFile(filename: string): any; - } -} -declare module RES { - /** - * Print the memory occupied by the picture. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 打印图片所占内存 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function profile(): void; - /** - * @private - */ - interface ProcessHost { - state: { - [index: string]: number; - }; - resourceConfig: ResourceConfig; - load: (resource: ResourceInfo, processor?: string | processor.Processor) => Promise; - unload: (resource: ResourceInfo) => void; - save: (rexource: ResourceInfo, data: any) => void; - get: (resource: ResourceInfo) => any; - remove: (resource: ResourceInfo) => void; - } - /** - * @private - */ - class ResourceManagerError extends Error { - static errorMessage: { - 1001: string; - 1002: string; - 2001: string; - 2002: string; - 2003: string; - 2004: string; - 2005: string; - 2006: string; - }; - /** - * why instanceof e != ResourceManagerError ??? - * see link : https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work - */ - private __resource_manager_error__; - constructor(code: number, replacer?: Object, replacer2?: Object); - } -} -declare namespace RES { - /** - * Resource group loading progress prompt - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源组的加载进度提示 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - interface PromiseTaskReporter { - /** - * Progress callback, asynchronous execution, load number and order have nothing to do - * @param current The number of currently loaded - * @param total Total resources required in the current resource bundle - * @param resItem currently loading resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 进度回调,异步执行,加载数目和顺序无关 - * @param current 当前已经加载数目 - * @param total 当前资源包内需要资源总数 - * @param resItem 当前加载资源信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - onProgress?(current: number, total: number, resItem: ResourceInfo | undefined): void; - } -} diff --git a/demo/libs/modules/assetsmanager/assetsmanager.js b/demo/libs/modules/assetsmanager/assetsmanager.js deleted file mode 100644 index 8a02b53e..00000000 --- a/demo/libs/modules/assetsmanager/assetsmanager.js +++ /dev/null @@ -1,2992 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { -})(RES || (RES = {})); -var RES; -(function (RES) { - /** - * @internal - */ - RES.resourceNameSelector = function (p) { return p; }; - /** - * Get resource information through file path - * @param path file path - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 通过文件路径获取资源信息 - * @param path 文件路径 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResourceInfo(path) { - var result = RES.config.config.fileSystem.getFile(path); - if (!result) { - path = RES.resourceNameSelector(path); - result = RES.config.config.fileSystem.getFile(path); - } - return result; - } - RES.getResourceInfo = getResourceInfo; - var configItem; - /** - * 注册config的相关配置 - * @internal - * @param url config的地址 - * @param root 根路径 - */ - function setConfigURL(url, root) { - var type; - if (url.indexOf(".json") >= 0) { - type = "legacyResourceConfig"; - } - else { - type = "resourceConfig"; - } - configItem = { type: type, root: root, url: url, name: url }; - } - RES.setConfigURL = setConfigURL; - /** - * @class RES.ResourceConfig - * @classdesc - * @private - */ - var ResourceConfig = (function () { - function ResourceConfig() { - } - ResourceConfig.prototype.init = function () { - if (!this.config) { - this.config = { - alias: {}, groups: {}, resourceRoot: configItem.root, - mergeSelector: null, - fileSystem: null, - loadGroup: [] - }; - } - return RES.queue.pushResItem(configItem).catch(function (e) { - if (!RES.isCompatible) { - if (!e.__resource_manager_error__) { - if (e.error) { - console.error(e.error.stack); - } - else { - console.error(e.stack); - } - e = new RES.ResourceManagerError(1002); - } - } - RES.host.remove(configItem); - return Promise.reject(e); - }); - }; - /** - * 根据组名获取组加载项列表 - * @method RES.ResourceConfig#getGroupByName - * @param name {string} 组名 - * @returns {Array} - */ - ResourceConfig.prototype.getGroupByName = function (name) { - var group = this.config.groups[name]; - var result = []; - if (!group) { - return result; - } - for (var _i = 0, group_1 = group; _i < group_1.length; _i++) { - var paramKey = group_1[_i]; - var tempResult = void 0; - tempResult = RES.config.getResourceWithSubkey(paramKey); - if (tempResult == null) { - continue; - } - var r = tempResult.r, key = tempResult.key; - if (r == null) { - /** 加载组里面的资源,可能不存在 */ - throw new RES.ResourceManagerError(2005, key); - continue; - } - if (result.indexOf(r) == -1) { - result.push(r); - } - } - return result; - }; - ResourceConfig.prototype.__temp__get__type__via__url = function (url_or_alias) { - var url = this.config.alias[url_or_alias]; - if (!url) { - url = url_or_alias; - } - if (RES.typeSelector) { - var type = RES.typeSelector(url); - if (!type) { - throw new RES.ResourceManagerError(2004, url); - } - return type; - } - else { - console.warn("RES.mapConfig 并未设置 typeSelector"); - return "unknown"; - } - }; - ResourceConfig.prototype.getResourceWithSubkey = function (key) { - key = this.getKeyByAlias(key); - var index = key.indexOf("#"); - var subkey = ""; - if (index >= 0) { - subkey = key.substr(index + 1); - key = key.substr(0, index); - } - var r = this.getResource(key); - if (!r) { - return null; - } - else { - return { - r: r, key: key, subkey: subkey - }; - } - }; - ResourceConfig.prototype.getKeyByAlias = function (aliasName) { - if (this.config.alias[aliasName]) { - return this.config.alias[aliasName]; - } - else { - return aliasName; - } - }; - ResourceConfig.prototype.getResource = function (path_or_alias) { - var path = this.config.alias[path_or_alias]; - if (!path) { - path = path_or_alias; - } - var r = getResourceInfo(path); - if (!r) { - return null; - } - else { - return r; - } - }; - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或sbuKeys属性的一项或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - ResourceConfig.prototype.createGroup = function (name, keys, override) { - if (override === void 0) { override = false; } - if ((!override && this.config.groups[name]) || !keys || keys.length == 0) { - return false; - } - var group = []; - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - if (this.config.groups[key]) { - var groupInfo = this.config.groups[key]; - group = group.concat(groupInfo); - } - else { - group.push(key); - } - } - this.config.groups[name] = group; - return true; - // var groupDic: any = this.groupDic; - // var group: Array = []; - // var length: number = keys.length; - // for (var i: number = 0; i < length; i++) { - // var key: string = keys[i]; - // var g: Array = groupDic[key]; - // if (g) { - // var len: number = g.length; - // for (var j: number = 0; j < len; j++) { - // var item: any = g[j]; - // if (group.indexOf(item) == -1) - // group.push(item); - // } - // } - // else { - // item = this.keyMap[key]; - // if (item) { - // if (group.indexOf(item) == -1) - // group.push(item); - // } - // else { - // egret.$warn(3200, key); - // } - // } - // } - // if (group.length == 0) - // return false; - // this.groupDic[name] = group; - // return true; - }; - /** - * 添加一个二级键名到配置列表。 - * @method RES.ResourceConfig#addSubkey - * @param subkey {string} 要添加的二级键名 - * @param name {string} 二级键名所属的资源name属性 - */ - ResourceConfig.prototype.addSubkey = function (subkey, name) { - this.addAlias(subkey, name + "#" + subkey); - }; - ResourceConfig.prototype.addAlias = function (alias, key) { - if (this.config.alias[key]) { - key = this.config.alias[key]; - } - this.config.alias[alias] = key; - }; - ResourceConfig.prototype.addResourceData = function (data) { - if (RES.hasRes(data.name)) { - return; - } - if (!data.type) { - data.type = this.__temp__get__type__via__url(data.url); - } - RES.config.config.fileSystem.addFile(data); - }; - ResourceConfig.prototype.removeResourceData = function (data) { - if (!RES.hasRes(data.name)) { - return; - } - RES.config.config.fileSystem.removeFile(data.url); - if (this.config.alias[data.name]) { - delete this.config.alias[data.name]; - } - }; - return ResourceConfig; - }()); - RES.ResourceConfig = ResourceConfig; - __reflect(ResourceConfig.prototype, "RES.ResourceConfig"); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * @class RES.ResourceLoader - * @classdesc - * @private - */ - var ResourceLoader = (function () { - function ResourceLoader() { - /** - * 当前组加载的项总个数,key为groupName - */ - this.groupTotalDic = {}; - /** - * 已经加载的项个数,key为groupName - */ - this.numLoadedDic = {}; - /** - * 加载失败的组,key为groupName - */ - this.groupErrorDic = {}; - this.retryTimesDic = {}; - this.maxRetryTimes = 3; - this.reporterDic = {}; - this.dispatcherDic = {}; - this.failedList = new Array(); - this.loadItemErrorDic = {}; - this.errorDic = {}; - /** - * 资源优先级队列,key为资源,value为优先级 - */ - this.itemListPriorityDic = {}; - /** - * 资源是否在加载 - */ - this.itemLoadDic = {}; - this.promiseHash = {}; - /** - * 延迟加载队列,getResByUrl ,getResAsync等方法存储队列 - */ - this.lazyLoadList = new Array(); - this.loadingCount = 0; - /** - * 最大线程数目 - */ - this.thread = 4; - } - ResourceLoader.prototype.pushResItem = function (resInfo) { - if (this.promiseHash[resInfo.root + resInfo.name]) { - return this.promiseHash[resInfo.root + resInfo.name]; - } - this.lazyLoadList.push(resInfo); - this.itemListPriorityDic[Number.NEGATIVE_INFINITY] = this.lazyLoadList; - this.updatelistPriority(this.lazyLoadList, Number.NEGATIVE_INFINITY); - var dispatcher = new egret.EventDispatcher(); - this.dispatcherDic[resInfo.root + resInfo.name] = dispatcher; - var promise = new Promise(function (resolve, reject) { - dispatcher.addEventListener("complete", function (e) { - resolve(e.data); - }, null); - dispatcher.addEventListener("error", function (e) { - reject(e.data); - }, null); - }); - this.promiseHash[resInfo.root + resInfo.name] = promise; - this.loadNextResource(); - return promise; - }; - /** - * 加载队列,存储组的队列 - */ - ResourceLoader.prototype.pushResGroup = function (list, groupName, priority, reporter) { - if (this.promiseHash[groupName]) { - return this.promiseHash[groupName]; - } - var total = list.length; - for (var i = 0; i < total; i++) { - var resInfo = list[i]; - if (!resInfo.groupNames) { - resInfo.groupNames = []; - } - resInfo.groupNames.push(groupName); - } - this.groupTotalDic[groupName] = list.length; - this.numLoadedDic[groupName] = 0; - this.updatelistPriority(list, priority); - this.reporterDic[groupName] = reporter; - var dispatcher = new egret.EventDispatcher(); - this.dispatcherDic[groupName] = dispatcher; - var promise = new Promise(function (resolve, reject) { - dispatcher.addEventListener("complete", resolve, null); - dispatcher.addEventListener("error", function (e) { - reject(e.data); - }, null); - }); - this.promiseHash[groupName] = promise; - this.loadNextResource(); - return promise; - }; - /** - * 更新组的优先级顺序 - * @param list 存储数据的队列 - * @param priority 优先级 - */ - ResourceLoader.prototype.updatelistPriority = function (list, priority) { - if (this.itemListPriorityDic[priority] == undefined) { - this.itemListPriorityDic[priority] = []; - } - for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { - var item = list_1[_i]; - if (this.itemLoadDic[item.root + item.name] == 1) { - continue; - } - var oldPriority = this.findPriorityInDic(item); - if (oldPriority == undefined) { - this.itemListPriorityDic[priority].push(item); - } - else { - if (oldPriority < priority) { - this.itemListPriorityDic[priority].push(item); - var index = this.itemListPriorityDic[oldPriority].indexOf(item); - this.itemListPriorityDic[oldPriority].splice(index, 1); - } - } - } - }; - /** - * 搜索单项资源的优先级 - * @param item 单项资源 - */ - ResourceLoader.prototype.findPriorityInDic = function (item) { - for (var priority in this.itemListPriorityDic) { - if (this.itemListPriorityDic[priority].indexOf(item) > -1) - return parseInt(priority); - } - return undefined; - }; - /** - * 加载下一项资源,线程控制 - */ - ResourceLoader.prototype.loadNextResource = function () { - while (this.loadingCount < this.thread) { - var isload = this.loadSingleResource(); - if (!isload) { - break; - } - } - }; - /** - * 加载单向资源 - */ - ResourceLoader.prototype.loadSingleResource = function () { - var _this = this; - var r = this.getOneResourceInfoInGroup(); - if (!r) - return false; - this.itemLoadDic[r.root + r.name] = 1; - this.loadingCount++; - this.loadResource(r) - .then(function (response) { - _this.loadingCount--; - delete _this.itemLoadDic[r.root + r.name]; - RES.host.save(r, response); - if (_this.promiseHash[r.root + r.name]) { - var dispatcher = _this.deleteDispatcher(r.root + r.name); - dispatcher.dispatchEventWith("complete", false, response); - } - var groupNames = r.groupNames; - if (groupNames) { - delete r.groupNames; - for (var _i = 0, groupNames_1 = groupNames; _i < groupNames_1.length; _i++) { - var groupName = groupNames_1[_i]; - if (_this.setGroupProgress(groupName, r)) { - _this.loadGroupEnd(groupName); - } - } - } - _this.loadNextResource(); - }).catch(function (error) { - if (!error) { - throw r.name + " load fail"; - } - if (!error.__resource_manager_error__) { - throw error; - } - delete _this.itemLoadDic[r.root + r.name]; - _this.loadingCount--; - delete RES.host.state[r.root + r.name]; - var times = _this.retryTimesDic[r.name] || 1; - if (times > _this.maxRetryTimes) { - delete _this.retryTimesDic[r.name]; - if (_this.promiseHash[r.root + r.name]) { - var dispatcher = _this.deleteDispatcher(r.root + r.name); - dispatcher.dispatchEventWith("error", false, { r: r, error: error }); - } - var groupNames = r.groupNames; - if (groupNames) { - delete r.groupNames; - for (var _i = 0, groupNames_2 = groupNames; _i < groupNames_2.length; _i++) { - var groupName = groupNames_2[_i]; - if (!_this.loadItemErrorDic[groupName]) { - _this.loadItemErrorDic[groupName] = []; - } - if (_this.loadItemErrorDic[groupName].indexOf(r) == -1) { - _this.loadItemErrorDic[groupName].push(r); - } - _this.groupErrorDic[groupName] = true; - if (_this.setGroupProgress(groupName, r)) { - _this.loadGroupEnd(groupName, error); - } - else { - _this.errorDic[groupName] = error; - } - } - } - _this.loadNextResource(); - } - else { - _this.retryTimesDic[r.name] = times + 1; - _this.failedList.push(r); - _this.loadNextResource(); - return; - } - }); - return true; - }; - /** - * 获取下一个待加载项 - */ - ResourceLoader.prototype.getOneResourceInfoInGroup = function () { - if (this.failedList.length > 0) - return this.failedList.shift(); - var maxPriority = Number.NEGATIVE_INFINITY; - for (var p in this.itemListPriorityDic) { - maxPriority = Math.max(maxPriority, p); - } - var list = this.itemListPriorityDic[maxPriority]; - if (!list) { - return undefined; - } - if (list.length == 0) { - delete this.itemListPriorityDic[maxPriority]; - return this.getOneResourceInfoInGroup(); - } - return list.shift(); - }; - /** - * 设置组的加载进度,同时返回当前组是否加载完成 - * @param groupName 组名 - * @param r 加载完成的资源 - */ - ResourceLoader.prototype.setGroupProgress = function (groupName, r) { - var reporter = this.reporterDic[groupName]; - this.numLoadedDic[groupName]++; - var current = this.numLoadedDic[groupName]; - var total = this.groupTotalDic[groupName]; - if (reporter && reporter.onProgress) { - reporter.onProgress(current, total, r); - } - return current == total; - }; - /** - * 加载组的最后一项,同时派发事件 - * @param groupName 组名 - * @param lastError 最后一项是否成功,此项为错误信息 - */ - ResourceLoader.prototype.loadGroupEnd = function (groupName, lastError) { - delete this.groupTotalDic[groupName]; - delete this.numLoadedDic[groupName]; - delete this.reporterDic[groupName]; - var dispatcher = this.deleteDispatcher(groupName); - if (!lastError) { - var groupError = this.groupErrorDic[groupName]; - delete this.groupErrorDic[groupName]; - if (groupError) { - var itemList = this.loadItemErrorDic[groupName]; - delete this.loadItemErrorDic[groupName]; - var error = this.errorDic[groupName]; - delete this.errorDic[groupName]; - dispatcher.dispatchEventWith("error", false, { itemList: itemList, error: error }); - } - else { - dispatcher.dispatchEventWith("complete"); - } - } - else { - delete this.groupErrorDic[groupName]; - var itemList = this.loadItemErrorDic[groupName]; - delete this.loadItemErrorDic[groupName]; - dispatcher.dispatchEventWith("error", false, { itemList: itemList, lastError: lastError }); - } - }; - /** - * 删除事件派发器,Promise的缓存,返回事件派发器 - * @param groupName 组名或是root+name - */ - ResourceLoader.prototype.deleteDispatcher = function (groupName) { - delete this.promiseHash[groupName]; - var dispatcher = this.dispatcherDic[groupName]; - delete this.dispatcherDic[groupName]; - return dispatcher; - }; - /** - * 加载资源 - * @param r 资源信息 - * @param p 加载处理器 - */ - ResourceLoader.prototype.loadResource = function (r, p) { - if (!p) { - if (RES.FEATURE_FLAG.FIX_DUPLICATE_LOAD == 1) { - var s = RES.host.state[r.root + r.name]; - if (s == 2) { - return Promise.resolve(RES.host.get(r)); - } - if (s == 1) { - return r.promise; - } - } - p = RES.processor.isSupport(r); - } - if (!p) { - throw new RES.ResourceManagerError(2001, r.name, r.type); - } - RES.host.state[r.root + r.name] = 1; - var promise = p.onLoadStart(RES.host, r); - r.promise = promise; - return promise; - }; - /** - * 释放资源 - * @param r 资源信息 - */ - ResourceLoader.prototype.unloadResource = function (r) { - var data = RES.host.get(r); - if (!data) { - console.warn("尝试释放不存在的资源:", r.name); - return false; - } - var p = RES.processor.isSupport(r); - if (p) { - p.onRemoveStart(RES.host, r); - RES.host.remove(r); - if (r.extra == 1) { - RES.config.removeResourceData(r); - } - return true; - } - else { - return true; - } - }; - return ResourceLoader; - }()); - RES.ResourceLoader = ResourceLoader; - __reflect(ResourceLoader.prototype, "RES.ResourceLoader"); -})(RES || (RES = {})); -var RES; -(function (RES) { - /** - * Decorator, determine if the parameter is null - * @internal - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 装饰器,判断参数是否为null - * @internal - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - RES.checkNull = function (target, propertyKey, descriptor) { - var method = descriptor.value; - descriptor.value = function () { - var arg = []; - for (var _i = 0; _i < arguments.length; _i++) { - arg[_i] = arguments[_i]; - } - if (!arg[0]) { - console.warn("\u65B9\u6CD5" + propertyKey + "\u7684\u53C2\u6570\u4E0D\u80FD\u4E3Anull"); - return null; - } - else { - return method.apply(this, arg); - } - }; - }; - /** - * 功能开关 - * LOADING_STATE:处理重复加载 - * @internal - */ - RES.FEATURE_FLAG = { - FIX_DUPLICATE_LOAD: 1 - }; - /** - * @internal - */ - var upgrade; - (function (upgrade) { - var _level = "warning"; - function setUpgradeGuideLevel(level) { - _level = level; - } - upgrade.setUpgradeGuideLevel = setUpgradeGuideLevel; - })(upgrade = RES.upgrade || (RES.upgrade = {})); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * Convert the file name of the resource to the Key value used in the project. - * @param url Resource Name. - * @returns The key value used in the project - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 将资源的文件名称转换为项目中所使用的Key值。 - * 在加载合并图集的时候使用,例如图集加载A_json,需要加载对应A_png,这里就是转换的机制 - * 一般项目中无需更改,只有没有使用默认的key和文件对应的需要修改 - * @param url 资源名称。 - * @returns 项目中所用的key值 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function nameSelector(url) { - return RES.path.basename(url).split(".").join("_"); - } - RES.nameSelector = nameSelector; - /** - * Get the read type of the file. - * When using getResByUrl does not specify the type of the read file, it will find the corresponding type according to this method. - * File types not found are loaded by default in binary format - * @param path file path. - * @returns Processor type used to read the file - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文件的读取类型 - * 在使用getResByUrl没有指定读取文件的类型,会根据这个方法寻找对应的类型 - * 没有查找到的文件类型以二进制格式默认加载 - * @param path 文件路径 - * @returns 读取文件所用的Processor类型 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function typeSelector(path) { - var ext = path.substr(path.lastIndexOf(".") + 1); - var type; - switch (ext) { - case RES.ResourceItem.TYPE_XML: - case RES.ResourceItem.TYPE_JSON: - case RES.ResourceItem.TYPE_SHEET: - type = ext; - break; - case "png": - case "jpg": - case "gif": - case "jpeg": - case "bmp": - type = RES.ResourceItem.TYPE_IMAGE; - break; - case "fnt": - type = RES.ResourceItem.TYPE_FONT; - break; - case "txt": - type = RES.ResourceItem.TYPE_TEXT; - break; - case "mp3": - case "ogg": - case "mpeg": - case "wav": - case "m4a": - case "mp4": - case "aiff": - case "wma": - case "mid": - type = RES.ResourceItem.TYPE_SOUND; - break; - case "mergeJson": - case "zip": - case "pvr": - type = ext; - break; - default: - type = RES.ResourceItem.TYPE_BIN; - break; - } - return type; - } - RES.typeSelector = typeSelector; - /** - * Conduct mapping injection with class definition as the value, Deprecated. - * @deprecated - * @see RES.processor.map - * @language en_US - */ - /** - * 以类定义为值进行映射注入,已废弃。 - * @deprecated - * @see RES.processor.map - * @language zh_CN - */ - function registerAnalyzer(type, analyzerClass) { - throw new RES.ResourceManagerError(2002); - } - RES.registerAnalyzer = registerAnalyzer; - /** - * Set whether it is compatible mode - * When the value is true, the assetsManager will output the design of Res. When it is false, all the loaded resources will be returned as promises. - * The default is false, run in strict assetsManager mode - * @version Egret 5.2.9 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否为兼容模式 - * 当值为true时,assetsManager会以Res的设计输出,当为false时候,所有的加载资源都会以promise的方式返回 - * 默认是false,以严格assetsManager方式运行 - * @version Egret 5.2.9 - * @platform Web,Native - * @language zh_CN - */ - function setIsCompatible(value) { - RES.isCompatible = value; - } - RES.setIsCompatible = setIsCompatible; - /** - * @internal - */ - RES.isCompatible = false; - /** - * Load configuration file and parse. - * @param url The url address of the resource config - * @param resourceRoot The root address of the resource config - * @returns Promise - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 加载配置文件并解析。 - * @param url 资源配置的url地址 - * @param resourceRoot 资源配置的根地址 - * @returns Promise - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function loadConfig(url, resourceRoot) { - if (resourceRoot.indexOf('://') >= 0) { - var temp = resourceRoot.split('://'); - resourceRoot = temp[0] + '://' + RES.path.normalize(temp[1] + '/'); - url = url.replace(resourceRoot, ''); - } - else { - resourceRoot = RES.path.normalize(resourceRoot + "/"); - url = url.replace(resourceRoot, ''); - } - RES.setConfigURL(url, resourceRoot); - if (!instance) - instance = new Resource(); - return compatiblePromise(instance.loadConfig()); - } - RES.loadConfig = loadConfig; - function compatiblePromise(promise) { - if (RES.isCompatible) { - promise.catch(function (e) { }).then(); - return undefined; - } - else { - return promise; - } - } - /** - * Load a set of resources according to the group name. - * @param name Group name to load the resource group. - * @param priority Load priority can be negative, the default value is 0. - *
A low priority group must wait for the high priority group to complete the end of the load to start, and the same priority group will be loaded at the same time. - * @param reporter Resource group loading progress prompt - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名加载一组资源。 - * @param name 要加载资源组的组名。 - * @param priority 加载优先级,可以为负数,默认值为 0。 - *
低优先级的组必须等待高优先级组完全加载结束才能开始,同一优先级的组会同时加载。 - * @param reporter 资源组的加载进度提示 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function loadGroup(name, priority, reporter) { - if (priority === void 0) { priority = 0; } - return compatiblePromise(instance.loadGroup(name, priority, reporter)); - } - RES.loadGroup = loadGroup; - /** - * Check whether a resource group has been loaded. - * @param name Group name。 - * @returns Is loading or not. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 检查某个资源组是否已经加载完成。 - * @param name 组名。 - * @returns 是否正在加载。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function isGroupLoaded(name) { - return instance.isGroupLoaded(name); - } - RES.isGroupLoaded = isGroupLoaded; - /** - * A list of groups of loading is obtained according to the group name. - * @param name Group name. - * @returns The resource item array of group. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名获取组加载项列表。 - * @param name 组名。 - * @returns 加载项列表。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getGroupByName(name) { - return instance.getGroupByName(name).map(function (r) { return RES.ResourceItem.convertToResItem(r); }); - } - RES.getGroupByName = getGroupByName; - /** - * Create a custom load resource group, note that this method is valid only after the resource configuration file is loaded. - *
You can monitor the ResourceEvent.CONFIG_COMPLETE event to verify that the configuration is complete. - * @param name Group name to create the load resource group. - * @param keys To be included in the list of key keys, the corresponding configuration file in the name or sbuKeys property one or a resource group name. - * @param override Is the default false for the same name resource group already exists. - * @returns Create success or fail. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - *
可以监听 ResourceEvent.CONFIG_COMPLETE 事件来确认配置加载完成。 - * @param name 要创建的加载资源组的组名。 - * @param keys 要包含的键名列表,key 对应配置文件里的 name 属性或 sbuKeys 属性的一项或一个资源组名。 - * @param override 是否覆盖已经存在的同名资源组,默认 false。 - * @returns 是否创建成功。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function createGroup(name, keys, override) { - if (override === void 0) { override = false; } - return instance.createGroup(name, keys, override); - } - RES.createGroup = createGroup; - /** - * Check whether the configuration file contains the specified resources. - * @param key A sbuKeys attribute or name property in a configuration file. - * @returns Whether you have the specified resource - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 检查配置文件里是否含有指定的资源。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @returns 是否拥有指定资源 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function hasRes(key) { - return instance.hasRes(key); - } - RES.hasRes = hasRes; - /** - * The synchronization method for obtaining the cache has been loaded with the success of the resource. - *
The type of resource and the corresponding return value types are as follows: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript primary object - *
RES.ResourceItem.TYPE_IMAGE : img Html Object,or egret.BitmapData interface。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. If the incoming parameter is the name of the entire SpriteSheet is returned is {image1: Texture, "image2": Texture}. - *
2. If the incoming is "sheet.image1", the return is a single resource. - *
3. If the incoming is the name of the "image1" single resource, the return is a single resource. - * But if there are two SpriteSheet in a single picture of the same name, the return of the image after the load. - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html Object - *
RES.ResourceItem.TYPE_TEXT : string - * @param key A subKeys attribute or name property in a configuration file. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 同步方式获取缓存的已经加载成功的资源。 - *
资源类型和对应的返回值类型关系如下: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript 原生对象 - *
RES.ResourceItem.TYPE_IMAGE : img Html 对象,或者 egret.BitmapData 接口。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. 如果传入的参数是整个 SpriteSheet 的名称返回的是 {"image1":Texture,"image2":Texture} 这样的格式。 - *
2. 如果传入的是 "sheet.image1",返回的是单个资源。 - *
3. 如果传入的是 "image1" 单个资源的名称,返回的是单个资源。但是如果有两张 SpriteSheet 中有单个图片资源名称相同,返回的是后加载的那个图片资源。 - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html 对象 - *
RES.ResourceItem.TYPE_TEXT : string - * @param key 对应配置文件里的 name 属性或 subKeys 属性的一项。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getRes(key) { - return instance.getRes(key); - } - RES.getRes = getRes; - /** - * Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way. - * @param key A sbuKeys attribute or name property in a configuration file. - * @param compFunc Call back function. Example:compFunc(data,key):void. - * @param thisObject This pointer of call back function. - * @see #setMaxRetryTimes - * @example The following code demonstrates how to load a resource via getResAsync - *
-     *       RES.getResAsync("resource/example.json");//Only pass the key value to get the resource
-     *
-     *       RES.getResAsync("resource/example.json", (data) => {
-     *          console.log(data)
-     *       }, this) //Pass in the key value, compFunc and thisObject get the resource, the latter two must appear at the same time
-     * 
- * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @param compFunc 回调函数。示例:compFunc(data,key):void。 - * @param thisObject 回调函数的 this 引用。 - * @see #setMaxRetryTimes - * @example 以下代码演示了如何通过getResAsync加载资源 - *
-     *       RES.getResAsync("resource/example.json");//只传入key值获取资源
-     *
-     *       RES.getResAsync("resource/example.json", (data) => {
-     *          console.log(data)
-     *       }, this) //传入key值,compFunc和thisObject获取资源,后两个必须同时出现
-     * 
- * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResAsync(key, compFunc, thisObject) { - return compatiblePromise(instance.getResAsync.apply(instance, arguments)); - } - RES.getResAsync = getResAsync; - /** - * Access to external resources through the full URL. - * @param url The external path to load the file. - * @param compFunc Call back function. Example:compFunc(data,url):void。 - * @param thisObject This pointer of call back function. - * @param type File type (optional). Use the static constants defined in the ResourceItem class. If you do not set the file name extension. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 通过完整URL方式获取外部资源。 - * @param url 要加载文件的外部路径。 - * @param compFunc 回调函数。示例:compFunc(data,url):void。 - * @param thisObject 回调函数的 this 引用。 - * @param type 文件类型(可选)。请使用 ResourceItem 类中定义的静态常量。若不设置将根据文件扩展名生成。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResByUrl(url, compFunc, thisObject, type) { - if (type === void 0) { type = ""; } - if (!instance) { - var message = egret.sys.tr(3200); - egret.warn(message); - return Promise.reject(message); - } - return compatiblePromise(instance.getResByUrl(url, compFunc, thisObject, type)); - } - RES.getResByUrl = getResByUrl; - /** - * Destroy a single resource file or a set of resources to the cache data, to return whether to delete success. - * @param name Name attribute or resource group name of the load item in the configuration file. - * @param force Destruction of a resource group when the other resources groups have the same resource situation whether the resources will be deleted, the default value true. - * @returns Are successful destruction. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @param name 配置文件中加载项的name属性或资源组名。 - * @param force 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值 true。 - * @see #setMaxRetryTimes - * @returns 是否销毁成功。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function destroyRes(name, force) { - return instance.destroyRes(name, force); - } - RES.destroyRes = destroyRes; - /** - * Sets the maximum number of concurrent load threads, the default value is 4. - * @param thread The number of concurrent loads to be set. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 设置最大并发加载线程数量,默认值是 4。 - * @param thread 要设置的并发加载数。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function setMaxLoadingThread(thread) { - if (!instance) - instance = new Resource(); - instance.setMaxLoadingThread(thread); - } - RES.setMaxLoadingThread = setMaxLoadingThread; - /** - * Sets the number of retry times when the resource failed to load, and the default value is 3. - * @param retry To set the retry count. - * @includeExample extension/resource/Resource.ts - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 设置资源加载失败时的重试次数,默认值是 3。 - * @param retry 要设置的重试次数。 - * @includeExample extension/resource/Resource.ts - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function setMaxRetryTimes(retry) { - instance.setMaxRetryTimes(retry); - } - RES.setMaxRetryTimes = setMaxRetryTimes; - /** - * Add event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listener functions for handling events. This function must accept the Event object as its only parameter, and can't return any results, - * As shown in the following example: function (evt:Event):void can have any name. - * @param thisObject The this object that is bound to a function. - * @param useCapture Determine the listener is running on the capture or running on the target and the bubbling phase. Set useCapture to true, - * then the listener in the capture phase processing events, but not in the target or the bubbling phase processing events. - * If useCapture is false, then the listener only in the target or the bubbling phase processing events. - * To listen for events in all three stages, please call addEventListener two times: once the useCapture is set to true, once the useCapture is set to false. - * @param priority Event listener priority. Priority is specified by a 32 - bit integer with a symbol. The higher the number, the higher the priority. - * All listeners with a priority for n will be processed before the -1 n listener. - * If two or more listeners share the same priority, they are processed in accordance with the order of their added. The default priority is 0. - * @see RES.ResourceEvent - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 添加事件侦听器,参考 ResourceEvent 定义的常量。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的 this 对象。 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于目标和冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在目标或冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在目标或冒泡阶段处理事件。 - * 要在所有三个阶段都侦听事件,请调用 addEventListener 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号的 32 位整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see RES.ResourceEvent - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function addEventListener(type, listener, thisObject, useCapture, priority) { - if (useCapture === void 0) { useCapture = false; } - if (priority === void 0) { priority = 0; } - if (!instance) - instance = new Resource(); - instance.addEventListener(type, listener, thisObject, useCapture, priority); - } - RES.addEventListener = addEventListener; - /** - * Remove event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listening function。 - * @param thisObject The this object that is bound to a function. - * @param useCapture Is used to capture, and this property is only valid in the display list. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 移除事件侦听器,参考ResourceEvent定义的常量。 - * @param type 事件名。 - * @param listener 侦听函数。 - * @param thisObject 侦听函数绑定的this对象。 - * @param useCapture 是否使用捕获,这个属性只在显示列表中生效。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function removeEventListener(type, listener, thisObject, useCapture) { - if (useCapture === void 0) { useCapture = false; } - instance.removeEventListener(type, listener, thisObject, useCapture); - } - RES.removeEventListener = removeEventListener; - /** - * Adding a custom resource configuration. - * @param data To add configuration. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 自定义添加一项资源配置。 - * @param data 要添加的配置。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function $addResourceData(data) { - //这里可能需要其他配置 - instance.addResourceData(data); - } - RES.$addResourceData = $addResourceData; - /** - * Returns the VersionController - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获得版本控制器. - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getVersionController() { - if (!instance) - instance = new Resource(); - return instance.vcs; - } - RES.getVersionController = getVersionController; - /** - * Register the VersionController - * @param vcs The VersionController to register. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 注册版本控制器,通过RES模块加载资源时会从版本控制器获取真实url - * @param vcs 注入的版本控制器。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function registerVersionController(vcs) { - if (!instance) - instance = new Resource(); - instance.registerVersionController(vcs); - } - RES.registerVersionController = registerVersionController; - /** - * Convert the address of the loaded resource (via version controller conversion) - * @param url path to the original resource - * @returns converted address - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 转换加载资源的地址(经过版本控制器的转换) - * @param url 原始资源的路径 - * @returns 转换后的地址 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getVirtualUrl(url) { - if (instance.vcs) { - return instance.vcs.getVirtualUrl(url); - } - else { - return url; - } - } - RES.getVirtualUrl = getVirtualUrl; - /** - * @private - */ - var Resource = (function (_super) { - __extends(Resource, _super); - function Resource() { - var _this = _super.call(this) || this; - _this.isVcsInit = false; - /** - * @private - * 版本控制器加载后的加载配置 - */ - _this.normalLoadConfig = function () { - return RES.config.init().then(function (data) { - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.CONFIG_COMPLETE); - }, function (error) { - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.CONFIG_LOAD_ERROR); - return Promise.reject(error); - }); - }; - if (RES.VersionController) { - _this.vcs = new RES.VersionController(); - } - return _this; - } - Resource.prototype.registerVersionController = function (vcs) { - this.vcs = vcs; - this.isVcsInit = false; - }; - /** - * 开始加载配置 - * @method RES.loadConfig - */ - Resource.prototype.loadConfig = function () { - var _this = this; - if (!this.isVcsInit && this.vcs) { - this.isVcsInit = true; - return this.vcs.init().then(function () { - return _this.normalLoadConfig(); - }); - } - else { - return this.normalLoadConfig(); - } - }; - /** - * 检查某个资源组是否已经加载完成 - * @method RES.isGroupLoaded - * @param name {string} - */ - Resource.prototype.isGroupLoaded = function (name) { - var resources = RES.config.getGroupByName(name); - return resources.every(function (r) { return RES.host.get(r) != null; }); - }; - /** - * 根据组名获取组加载项列表 - * @method RES.getGroupByName - * @param name {string} - */ - Resource.prototype.getGroupByName = function (name) { - return RES.config.getGroupByName(name); - }; - /** - * 根据组名加载一组资源 - * @method RES.loadGroup - * @param name {string} - * @param priority {number} - */ - Resource.prototype.loadGroup = function (name, priority, reporter) { - var _this = this; - if (priority === void 0) { priority = 0; } - var reporterDelegate = { - onProgress: function (current, total, resItem) { - if (reporter && reporter.onProgress) { - reporter.onProgress(current, total, resItem); - } - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.GROUP_PROGRESS, name, resItem, current, total); - } - }; - return this._loadGroup(name, priority, reporterDelegate).then(function (data) { - if (RES.config.config.loadGroup.indexOf(name) == -1) { - RES.config.config.loadGroup.push(name); - } - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.GROUP_COMPLETE, name); - }, function (error) { - if (RES.config.config.loadGroup.indexOf(name) == -1) { - RES.config.config.loadGroup.push(name); - } - if (error.itemList) { - var itemList = error.itemList; - var length_1 = itemList.length; - for (var i = 0; i < length_1; i++) { - var item = itemList[i]; - delete item.promise; - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, name, item); - } - } - if (RES.isCompatible) { - console.warn(error.error.message); - } - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.GROUP_LOAD_ERROR, name); - return Promise.reject(error.error); - }); - }; - Resource.prototype._loadGroup = function (name, priority, reporter) { - if (priority === void 0) { priority = 0; } - var resources = RES.config.getGroupByName(name); - if (resources.length == 0) { - return new Promise(function (resolve, reject) { - reject({ error: new RES.ResourceManagerError(2005, name) }); - }); - } - return RES.queue.pushResGroup(resources, name, priority, reporter); - }; - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - Resource.prototype.createGroup = function (name, keys, override) { - if (override === void 0) { override = false; } - return RES.config.createGroup(name, keys, override); - }; - /** - * 检查配置文件里是否含有指定的资源 - * @method RES.hasRes - * @param key {string} 对应配置文件里的name属性或subKeys属性的一项。 - * @returns {boolean} - */ - Resource.prototype.hasRes = function (key) { - return RES.config.getResourceWithSubkey(key) != null; - }; - /** - * 通过key同步获取资源 - * @method RES.getRes - * @param key {string} - * @returns {any} - */ - Resource.prototype.getRes = function (resKey) { - var result = RES.config.getResourceWithSubkey(resKey); - if (result) { - var r = result.r; - var key = result.key; - var subkey = result.subkey; - var p = RES.processor.isSupport(r); - if (p && p.getData && subkey) { - return p.getData(RES.host, r, key, subkey); - } - else { - return RES.host.get(r); - } - } - else { - return null; - } - }; - Resource.prototype.getResAsync = function (key, compFunc, thisObject) { - var _this = this; - var paramKey = key; - var tempResult = RES.config.getResourceWithSubkey(key); - if (tempResult == null) { - if (compFunc) { - compFunc.call(thisObject, null, paramKey); - } - return Promise.reject(new RES.ResourceManagerError(2006, key)); - } - var data = this.getRes(key); - if (data) { - if (compFunc) { - egret.callLater(function () { - compFunc.call(thisObject, data, paramKey); - }, this); - } - return Promise.resolve(data); - } - var r = tempResult.r, subkey = tempResult.subkey; - return RES.queue.pushResItem(r).then(function (value) { - RES.host.save(r, value); - var p = RES.processor.isSupport(r); - if (p && p.getData && subkey) { - value = p.getData(RES.host, r, key, subkey); - } - if (compFunc) { - compFunc.call(thisObject, value, paramKey); - } - return value; - }, function (error) { - RES.host.remove(r); - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, "", r); - if (compFunc) { - compFunc.call(thisObject, null, paramKey); - return Promise.reject(null); - } - return Promise.reject(error); - }); - }; - /** - * 通过url获取资源 - * @method RES.getResByUrl - * @param url {string} - * @param compFunc {Function} - * @param thisObject {any} - * @param type {string} - */ - Resource.prototype.getResByUrl = function (url, compFunc, thisObject, type) { - var _this = this; - if (type === void 0) { type = ""; } - var r = RES.config.getResource(url); - if (!r) { - if (!type) { - type = RES.config.__temp__get__type__via__url(url); - } - // manager.config.addResourceData({ name: url, url: url }); - r = { name: url, url: url, type: type, root: '', extra: 1 }; - RES.config.addResourceData(r); - r = RES.config.getResource(url); - if (!r) { - throw 'never'; - } - } - return RES.queue.pushResItem(r).then(function (value) { - RES.host.save(r, value); - if (compFunc && r) { - compFunc.call(thisObject, value, r.url); - } - return value; - }, function (error) { - RES.host.remove(r); - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, "", r); - if (compFunc) { - compFunc.call(thisObject, null, url); - return Promise.reject(null); - } - return Promise.reject(error); - }); - }; - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @method RES.destroyRes - * @param name {string} 配置文件中加载项的name属性或资源组名 - * @param force {boolean} 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值true - * @returns {boolean} - */ - Resource.prototype.destroyRes = function (name, force) { - if (force === void 0) { force = true; } - var group = RES.config.getGroupByName(name); - if (group && group.length > 0) { - var index = RES.config.config.loadGroup.indexOf(name); - if (index == -1) { - return false; - } - if (force || (RES.config.config.loadGroup.length == 1 && RES.config.config.loadGroup[0] == name)) { - for (var _i = 0, group_2 = group; _i < group_2.length; _i++) { - var item = group_2[_i]; - RES.queue.unloadResource(item); - } - RES.config.config.loadGroup.splice(index, 1); - } - else { - var removeItemHash = {}; - for (var _a = 0, _b = RES.config.config.loadGroup; _a < _b.length; _a++) { - var groupName = _b[_a]; - for (var key in RES.config.config.groups[groupName]) { - var tmpname = RES.config.config.groups[groupName][key]; - if (removeItemHash[tmpname]) { - removeItemHash[tmpname]++; - } - else { - removeItemHash[tmpname] = 1; - } - } - } - for (var _c = 0, group_3 = group; _c < group_3.length; _c++) { - var item = group_3[_c]; - if (removeItemHash[item.name] && removeItemHash[item.name] == 1) { - RES.queue.unloadResource(item); - } - } - RES.config.config.loadGroup.splice(index, 1); - } - return true; - } - else { - var item = RES.config.getResource(name); - if (item) { - return RES.queue.unloadResource(item); - } - else { - console.warn("\u5728\u5185\u5B58" + name + "\u8D44\u6E90\u4E0D\u5B58\u5728"); - return false; - } - } - }; - /** - * 设置最大并发加载线程数量,默认值是4. - * @method RES.setMaxLoadingThread - * @param thread {number} 要设置的并发加载数。 - */ - Resource.prototype.setMaxLoadingThread = function (thread) { - if (thread < 1) { - thread = 1; - } - RES.queue.thread = thread; - }; - /** - * 设置资源加载失败时的重试次数。 - * @param retry 要设置的重试次数。 - */ - Resource.prototype.setMaxRetryTimes = function (retry) { - retry = Math.max(retry, 0); - RES.queue.maxRetryTimes = retry; - }; - Resource.prototype.addResourceData = function (data) { - data["root"] = ''; - RES.config.addResourceData(data); - }; - __decorate([ - RES.checkNull - ], Resource.prototype, "hasRes", null); - __decorate([ - RES.checkNull - ], Resource.prototype, "getRes", null); - __decorate([ - RES.checkNull - ], Resource.prototype, "getResAsync", null); - __decorate([ - RES.checkNull - ], Resource.prototype, "getResByUrl", null); - return Resource; - }(egret.EventDispatcher)); - RES.Resource = Resource; - __reflect(Resource.prototype, "RES.Resource"); - /** - * Resource单例 - */ - var instance; -})(RES || (RES = {})); -var RES; -(function (RES) { - /** - * Print the memory occupied by the picture. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 对文件路径的一些操作,针对的是 C:/A/B/C/D/example.ts这种格式 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - var path; - (function (path_1) { - /** - * Format the file path,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" - * @param filename Incoming file path - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 格式化文件路径,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" - * @param filename 传入的文件路径 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function normalize(filename) { - var arr = filename.split("/"); - return arr.filter(function (value, index) { return !!value || index == arr.length - 1; }).join("/"); - } - path_1.normalize = normalize; - /** - * Get the file name according to the file path, "C:/A/B/example.ts"=>"example.ts" - * @param filename Incoming file path - * @return File name - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据文件路径得到文件名字,"C:/A/B/example.ts"=>"example.ts" - * @param filename 传入的文件路径 - * @return 文件的名字 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function basename(filename) { - return filename.substr(filename.lastIndexOf("/") + 1); - } - path_1.basename = basename; - /** - * The path to the folder where the file is located,"C:/A/B/example.ts"=>"C:/A/B" - * @param filename Incoming file path - * @return The address of the folder where the file is located - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 文件所在文件夹路径,"C:/A/B/example.ts"=>"C:/A/B" - * @param filename 传入的文件路径 - * @return 文件所在文件夹的地址 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function dirname(path) { - return path.substr(0, path.lastIndexOf("/")); - } - path_1.dirname = dirname; - })(path = RES.path || (RES.path = {})); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * @private - */ - var NativeVersionController = (function () { - function NativeVersionController() { - } - NativeVersionController.prototype.init = function () { - this.versionInfo = this.getLocalData("all.manifest"); - return Promise.resolve(); - }; - NativeVersionController.prototype.getVirtualUrl = function (url) { - return url; - }; - NativeVersionController.prototype.getLocalData = function (filePath) { - if (egret_native.readUpdateFileSync && egret_native.readResourceFileSync) { - //先取更新目录 - var content = egret_native.readUpdateFileSync(filePath); - if (content != null) { - return JSON.parse(content); - } - //再取资源目录 - content = egret_native.readResourceFileSync(filePath); - if (content != null) { - return JSON.parse(content); - } - } - return null; - }; - return NativeVersionController; - }()); - RES.NativeVersionController = NativeVersionController; - __reflect(NativeVersionController.prototype, "RES.NativeVersionController", ["RES.IVersionController"]); - if (egret.Capabilities.runtimeType == egret.RuntimeType.NATIVE) { - RES.VersionController = NativeVersionController; - } -})(RES || (RES = {})); -var RES; -(function (RES) { - var processor; - (function (processor_1) { - /** - * @internal - * @param resource 对应的资源接口,需要type属性 - */ - function isSupport(resource) { - return processor_1._map[resource.type]; - } - processor_1.isSupport = isSupport; - /** - * Register the processor that loads the resource - * @param type Load resource type - * @param processor Loaded processor, an instance that implements the Processor interface - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 注册加载资源的处理器 - * @param type 加载资源类型 - * @param processor 加载的处理器,一个实现Processor接口的实例 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function map(type, processor) { - processor_1._map[type] = processor; - } - processor_1.map = map; - /** - * @internal - */ - function promisify(loader, resource) { - var _this = this; - return new Promise(function (resolve, reject) { - var onSuccess = function () { - var texture = loader['data'] ? loader['data'] : loader['response']; - resolve(texture); - }; - var onError = function () { - var e = new RES.ResourceManagerError(1001, resource.url); - reject(e); - }; - loader.addEventListener(egret.Event.COMPLETE, onSuccess, _this); - loader.addEventListener(egret.IOErrorEvent.IO_ERROR, onError, _this); - }); - } - /** - * @private - * @param url - * @param file - */ - function getRelativePath(url, file) { - if (file.indexOf("://") != -1) { - return file; - } - url = url.split("\\").join("/"); - var params = url.match(/#.*|\?.*/); - var paramUrl = ""; - if (params) { - paramUrl = params[0]; - } - var index = url.lastIndexOf("/"); - if (index != -1) { - url = url.substring(0, index + 1) + file; - } - else { - url = file; - } - return url + paramUrl; - } - processor_1.getRelativePath = getRelativePath; - processor_1.ImageProcessor = { - onLoadStart: function (host, resource) { - var loader = new egret.ImageLoader(); - loader.load(RES.getVirtualUrl(resource.root + resource.url)); - return promisify(loader, resource) - .then(function (bitmapData) { - var texture = new egret.Texture(); - texture._setBitmapData(bitmapData); - var r = host.resourceConfig.getResource(resource.name); - if (r && r.scale9grid) { - var list = r.scale9grid.split(","); - texture["scale9Grid"] = new egret.Rectangle(parseInt(list[0]), parseInt(list[1]), parseInt(list[2]), parseInt(list[3])); - } - return texture; - }); - }, - onRemoveStart: function (host, resource) { - var texture = host.get(resource); - texture.dispose(); - } - }; - processor_1.KTXTextureProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, 'bin').then(function (data) { - if (!data) { - console.error('ktx:' + resource.root + resource.url + ' is null'); - return null; - } - var ktx = new egret.KTXContainer(data, 1); - if (ktx.isInvalid) { - console.error('ktx:' + resource.root + resource.url + ' is invalid'); - return null; - } - // - var bitmapData = new egret.BitmapData(data); - bitmapData.debugCompressedTextureURL = resource.root + resource.url; - bitmapData.format = 'ktx'; - ktx.uploadLevels(bitmapData, false); - // - var texture = new egret.Texture(); - texture._setBitmapData(bitmapData); - var r = host.resourceConfig.getResource(resource.name); - if (r && r.scale9grid) { - var list = r.scale9grid.split(","); - texture["scale9Grid"] = new egret.Rectangle(parseInt(list[0]), parseInt(list[1]), parseInt(list[2]), parseInt(list[3])); - } - // - host.save(resource, texture); - return texture; - }, function (e) { - host.remove(resource); - throw e; - }); - }, - onRemoveStart: function (host, resource) { - var texture = host.get(resource); - if (texture) { - texture.dispose(); - } - } - }; - /** - * - */ - function makeEtc1SeperatedAlphaResourceInfo(resource) { - return { name: resource.name + '_alpha', url: resource['etc1_alpha_url'], type: 'ktx', root: resource.root }; - } - processor_1.makeEtc1SeperatedAlphaResourceInfo = makeEtc1SeperatedAlphaResourceInfo; - /** - * - */ - processor_1.ETC1KTXProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, "ktx").then(function (colorTex) { - if (!colorTex) { - return null; - } - if (resource['etc1_alpha_url']) { - var r_1 = makeEtc1SeperatedAlphaResourceInfo(resource); - return host.load(r_1, "ktx") - .then(function (alphaMaskTex) { - if (colorTex && colorTex.$bitmapData && alphaMaskTex.$bitmapData) { - colorTex.$bitmapData.etcAlphaMask = alphaMaskTex.$bitmapData; - host.save(r_1, alphaMaskTex); - } - else { - host.remove(r_1); - } - return colorTex; - }, function (e) { - host.remove(r_1); - throw e; - }); - } - return colorTex; - }, function (e) { - host.remove(resource); - throw e; - }); - }, - onRemoveStart: function (host, resource) { - var colorTex = host.get(resource); - if (colorTex) { - colorTex.dispose(); - } - if (resource['etc1_alpha_url']) { - var r = makeEtc1SeperatedAlphaResourceInfo(resource); - var alphaMaskTex = host.get(r); - if (alphaMaskTex) { - alphaMaskTex.dispose(); - } - host.unload(r); //这里其实还会再删除一次,不过无所谓了。alphaMaskTex已经显示删除了 - } - } - }; - processor_1.BinaryProcessor = { - onLoadStart: function (host, resource) { - var request = new egret.HttpRequest(); - request.responseType = egret.HttpResponseType.ARRAY_BUFFER; - request.open(RES.getVirtualUrl(resource.root + resource.url), "get"); - request.send(); - return promisify(request, resource); - }, - onRemoveStart: function (host, resource) { - } - }; - processor_1.TextProcessor = { - onLoadStart: function (host, resource) { - var request = new egret.HttpRequest(); - request.responseType = egret.HttpResponseType.TEXT; - request.open(RES.getVirtualUrl(resource.root + resource.url), "get"); - request.send(); - return promisify(request, resource); - }, - onRemoveStart: function (host, resource) { - return true; - } - }; - processor_1.JsonProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, 'text').then(function (text) { - var data = JSON.parse(text); - return data; - }); - }, - onRemoveStart: function (host, request) { - } - }; - /** - * @internal - */ - processor_1.XMLProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, 'text').then(function (text) { - var data = egret.XML.parse(text); - return data; - }); - }, - onRemoveStart: function (host, resource) { - return true; - } - }; - /** - * @internal - */ - processor_1.CommonJSProcessor = { - onLoadStart: function (host, resource) { - // let text = await host.load(resource, 'text'); - return host.load(resource, 'text').then(function (text) { - var f = new Function('require', 'exports', text); - var require = function () { }; - var exports = {}; - try { - f(require, exports); - } - catch (e) { - throw new RES.ResourceManagerError(2003, resource.name, e.message); - } - return exports; - }); - }, - onRemoveStart: function (host, resource) { - } - }; - /** - * @internal - */ - processor_1.SheetProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, "json").then(function (data) { - var r = host.resourceConfig.getResource(RES.nameSelector(data.file)); - if (!r) { - var imageName = getRelativePath(resource.url, data.file); - r = { name: imageName, url: imageName, type: 'image', root: resource.root }; - } - return host.load(r) - .then(function (bitmapData) { - if (!bitmapData) { - return null; - } - var frames = data.frames; - var spriteSheet = new egret.SpriteSheet(bitmapData); - spriteSheet["$resourceInfo"] = r; - for (var subkey in frames) { - var config = frames[subkey]; - var texture = spriteSheet.createTexture(subkey, config.x, config.y, config.w, config.h, config.offX, config.offY, config.sourceW, config.sourceH); - if (config["scale9grid"]) { - var str = config["scale9grid"]; - var list = str.split(","); - texture["scale9Grid"] = new egret.Rectangle(parseInt(list[0]), parseInt(list[1]), parseInt(list[2]), parseInt(list[3])); - } - } - host.save(r, bitmapData); - return spriteSheet; - }, function (e) { - host.remove(r); - throw e; - }); - }); - }, - getData: function (host, resource, key, subkey) { - var data = host.get(resource); - if (data) { - return data.getTexture(subkey); - } - else { - return null; - } - }, - onRemoveStart: function (host, resource) { - var sheet = host.get(resource); - var r = sheet["$resourceInfo"]; - sheet.dispose(); - host.unload(r); - } - }; - var fontGetTexturePath = function (url, fntText) { - var file = ""; - var lines = fntText.split("\n"); - var pngLine = lines[2]; - var index = pngLine.indexOf("file=\""); - if (index != -1) { - pngLine = pngLine.substring(index + 6); - index = pngLine.indexOf("\""); - file = pngLine.substring(0, index); - } - url = url.split("\\").join("/"); - var index = url.lastIndexOf("/"); - if (index != -1) { - url = url.substring(0, index + 1) + file; - } - else { - url = file; - } - return url; - }; - /** - * @internal - */ - processor_1.FontProcessor = { - onLoadStart: function (host, resource) { - // let data: string = await host.load(resource, 'text'); - return host.load(resource, 'text').then(function (data) { - var config; - try { - config = JSON.parse(data); - } - catch (e) { - config = data; - } - var imageName; - if (typeof config === 'string') { - imageName = fontGetTexturePath(resource.url, config); - } - else { - imageName = getRelativePath(resource.url, config.file); - } - var r = host.resourceConfig.getResource(RES.nameSelector(imageName)); - if (!r) { - r = { name: imageName, url: imageName, type: 'image', root: resource.root }; - } - // var texture: egret.Texture = await host.load(r); - return host.load(r).then(function (texture) { - var font = new egret.BitmapFont(texture, config); - font["$resourceInfo"] = r; - // todo refactor - host.save(r, texture); - return font; - }, function (e) { - host.remove(r); - throw e; - }); - }); - }, - onRemoveStart: function (host, resource) { - var font = host.get(resource); - var r = font["$resourceInfo"]; - host.unload(r); - } - }; - processor_1.SoundProcessor = { - onLoadStart: function (host, resource) { - var sound = new egret.Sound(); - sound.load(RES.getVirtualUrl(resource.root + resource.url)); - return promisify(sound, resource).then(function () { - return sound; - }); - }, - onRemoveStart: function (host, resource) { - var sound = host.get(resource); - sound.close(); - } - }; - /** - * @internal - */ - processor_1.MovieClipProcessor = { - onLoadStart: function (host, resource) { - var mcData; - var imageResource; - return host.load(resource, 'json') - .then(function (value) { - mcData = value; - var jsonPath = resource.name; - var imagePath = jsonPath.substring(0, jsonPath.lastIndexOf(".")) + ".png"; - imageResource = host.resourceConfig.getResource(imagePath); - if (!imageResource) { - throw new RES.ResourceManagerError(1001, imagePath); - } - return host.load(imageResource); - }).then(function (value) { - host.save(imageResource, value); - var mcTexture = value; - var mcDataFactory = new egret.MovieClipDataFactory(mcData, mcTexture); - return mcDataFactory; - }); - }, - onRemoveStart: function (host, resource) { - var mcFactory = host.get(resource); - mcFactory.clearCache(); - mcFactory.$spriteSheet.dispose(); - // refactor - var jsonPath = resource.name; - var imagePath = jsonPath.substring(0, jsonPath.lastIndexOf(".")) + ".png"; - var imageResource = host.resourceConfig.getResource(imagePath); - if (imageResource) { - host.unload(imageResource); - } - } - }; - /** - * @internal - */ - processor_1.MergeJSONProcessor = { - onLoadStart: function (host, resource) { - // let data = await host.load(resource, 'json'); - return host.load(resource, 'json').then(function (data) { - for (var key in data) { - RES.config.addSubkey(key, resource.name); - } - return data; - }); - }, - getData: function (host, resource, key, subkey) { - var data = host.get(resource); - if (data) { - return data[subkey]; - } - else { - console.error("missing resource :" + resource.name); - return null; - } - }, - onRemoveStart: function (host, resource) { - } - }; - /** - * @internal - */ - processor_1.LegacyResourceConfigProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, 'json').then(function (data) { - var resConfigData = RES.config.config; - var root = resource.root; - var fileSystem = resConfigData.fileSystem; - if (!fileSystem) { - fileSystem = { - fsData: {}, - getFile: function (filename) { - return fsData[filename]; - }, - addFile: function (data) { - if (!data.type) - data.type = ""; - if (root == undefined) { - data.root = ""; - } - fsData[data.name] = data; - }, - profile: function () { - console.log(fsData); - }, - removeFile: function (filename) { - delete fsData[filename]; - } - }; - resConfigData.fileSystem = fileSystem; - } - var groups = resConfigData.groups; - for (var _i = 0, _a = data.groups; _i < _a.length; _i++) { - var g = _a[_i]; - if (g.keys == "") { - groups[g.name] = []; - } - else { - groups[g.name] = g.keys.split(","); - } - } - var alias = resConfigData.alias; - var fsData = fileSystem['fsData']; - var _loop_1 = function (resource_1) { - fsData[resource_1.name] = resource_1; - fsData[resource_1.name].root = root; - if (resource_1.subkeys) { - resource_1.subkeys.split(",").forEach(function (subkey) { - alias[subkey] = resource_1.name + "#" + subkey; - alias[resource_1.name + "." + subkey] = resource_1.name + "#" + subkey; - }); - // ResourceConfig. - } - }; - for (var _b = 0, _c = data.resources; _b < _c.length; _b++) { - var resource_1 = _c[_b]; - _loop_1(resource_1); - } - host.save(resource, data); - return data; - }); - }, - onRemoveStart: function () { - } - }; - /** - * @internal - */ - processor_1._map = { - "image": processor_1.ImageProcessor, - "json": processor_1.JsonProcessor, - "text": processor_1.TextProcessor, - "xml": processor_1.XMLProcessor, - "sheet": processor_1.SheetProcessor, - "font": processor_1.FontProcessor, - "bin": processor_1.BinaryProcessor, - "commonjs": processor_1.CommonJSProcessor, - "sound": processor_1.SoundProcessor, - "movieclip": processor_1.MovieClipProcessor, - "mergeJson": processor_1.MergeJSONProcessor, - "legacyResourceConfig": processor_1.LegacyResourceConfigProcessor, - "ktx": processor_1.KTXTextureProcessor, - "etc1.ktx": processor_1.ETC1KTXProcessor, - "pvrtc.ktx": processor_1.KTXTextureProcessor, - }; - })(processor = RES.processor || (RES.processor = {})); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * The events of resource loading. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源加载事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - var ResourceEvent = (function (_super) { - __extends(ResourceEvent, _super); - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 5.2 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 5.2 - * @platform Web,Native - * @private - * @language zh_CN - */ - function ResourceEvent(type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - var _this = _super.call(this, type, bubbles, cancelable) || this; - /** - * File number that has been loaded. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 已经加载的文件数。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - _this.itemsLoaded = 0; - /** - * Total file number to load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 要加载的总文件数。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - _this.itemsTotal = 0; - /** - * Resource group name. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源组名。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - _this.groupName = ""; - return _this; - } - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @method RES.ResourceEvent.dispatchResourceEvent - * @param target {egret.IEventDispatcher} - * @param type {string} - * @param groupName {string} - * @param resItem {egret.ResourceItem} - * @param itemsLoaded {number} - * @param itemsTotal {number} - * @internal - * @version Egret 5.2 - * @platform Web,Native - * @language en_CN - */ - ResourceEvent.dispatchResourceEvent = function (target, type, groupName, resItem, itemsLoaded, itemsTotal) { - if (groupName === void 0) { groupName = ""; } - if (resItem === void 0) { resItem = undefined; } - if (itemsLoaded === void 0) { itemsLoaded = 0; } - if (itemsTotal === void 0) { itemsTotal = 0; } - var event = egret.Event.create(ResourceEvent, type); - event.groupName = groupName; - if (resItem) { - event.resItem = RES.ResourceItem.convertToResItem(resItem); - } - event.itemsLoaded = itemsLoaded; - event.itemsTotal = itemsTotal; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Failure event for a load item. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 一个加载项加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.ITEM_LOAD_ERROR = "itemLoadError"; - /** - * Configure file to load and parse the completion event. Note: if a configuration file is loaded, it will not be thrown out, and if you want to handle the configuration loading failure, monitor the CONFIG_LOAD_ERROR event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载并解析完成事件。注意:若有配置文件加载失败,将不会抛出此事件,若要处理配置加载失败,请同时监听 CONFIG_LOAD_ERROR 事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.CONFIG_COMPLETE = "configComplete"; - /** - * Configuration file failed to load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.CONFIG_LOAD_ERROR = "configLoadError"; - /** - * Delay load group resource loading progress event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载进度事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.GROUP_PROGRESS = "groupProgress"; - /** - * Delay load group resource to complete event. Note: if you have a resource item loading failure, the event will not be thrown, if you want to handle the group load failure, please listen to the GROUP_LOAD_ERROR event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载完成事件。注意:若组内有资源项加载失败,将不会抛出此事件,若要处理组加载失败,请同时监听 GROUP_LOAD_ERROR 事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.GROUP_COMPLETE = "groupComplete"; - /** - * Delayed load group resource failed event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.GROUP_LOAD_ERROR = "groupLoadError"; - return ResourceEvent; - }(egret.Event)); - RES.ResourceEvent = ResourceEvent; - __reflect(ResourceEvent.prototype, "RES.ResourceEvent"); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * Resource term. One of the resources arrays in resource.json. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源项。对应 resource.json 中 resources 数组中的一项。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - var ResourceItem; - (function (ResourceItem) { - /** - * XML file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * XML 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_XML = "xml"; - /** - * Picture file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 图片文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_IMAGE = "image"; - /** - * Binary file. - * @version Egret 5.2 - * @platform Web - * @language en_US - */ - /** - * 二进制文件。 - * @version Egret 5.2 - * @platform Web - * @language zh_CN - */ - ResourceItem.TYPE_BIN = "bin"; - /** - * Text file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 文本文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_TEXT = "text"; - /** - * JSON file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * JSON 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_JSON = "json"; - /** - * SpriteSheet file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * SpriteSheet 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_SHEET = "sheet"; - /** - * BitmapTextSpriteSheet file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapTextSpriteSheet 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_FONT = "font"; - /** - * Sound file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 声音文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_SOUND = "sound"; - function convertToResItem(r) { - var name = r.name; - if (!RES.config.config) { - name = r.url; - } - else { - for (var aliasName in RES.config.config.alias) { - if (RES.config.config.alias[aliasName] == r.url) { - name = aliasName; - } - } - } - var result = { - name: name, - url: r.url, - type: r.type, - data: r, - root: r.root - }; - return result; - } - ResourceItem.convertToResItem = convertToResItem; - })(ResourceItem = RES.ResourceItem || (RES.ResourceItem = {})); -})(RES || (RES = {})); -var RES; -(function (RES) { - /** - * @internal - */ - var NewFileSystem = (function () { - function NewFileSystem(data) { - this.data = data; - } - NewFileSystem.prototype.profile = function () { - console.log(this.data); - }; - NewFileSystem.prototype.addFile = function (filename, type) { - if (!type) - type = ""; - filename = RES.path.normalize(filename); - var basefilename = RES.path.basename(filename); - var folder = RES.path.dirname(filename); - if (!this.exists(folder)) { - this.mkdir(folder); - } - var d = this.resolve(folder); - d[basefilename] = { url: filename, type: type }; - }; - NewFileSystem.prototype.getFile = function (filename) { - var result = this.resolve(filename); - if (result) { - result.name = filename; - } - return result; - }; - NewFileSystem.prototype.resolve = function (dirpath) { - if (dirpath == "") { - return this.data; - } - dirpath = RES.path.normalize(dirpath); - var list = dirpath.split("/"); - var current = this.data; - for (var _i = 0, list_2 = list; _i < list_2.length; _i++) { - var f = list_2[_i]; - if (current) { - current = current[f]; - } - else { - return current; - } - } - return current; - }; - NewFileSystem.prototype.mkdir = function (dirpath) { - dirpath = RES.path.normalize(dirpath); - var list = dirpath.split("/"); - var current = this.data; - for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { - var f = list_3[_i]; - if (!current[f]) { - current[f] = {}; - } - current = current[f]; - } - }; - NewFileSystem.prototype.exists = function (dirpath) { - if (dirpath == "") - return true; - dirpath = RES.path.normalize(dirpath); - var list = dirpath.split("/"); - var current = this.data; - for (var _i = 0, list_4 = list; _i < list_4.length; _i++) { - var f = list_4[_i]; - if (!current[f]) { - return false; - } - current = current[f]; - } - return true; - }; - return NewFileSystem; - }()); - RES.NewFileSystem = NewFileSystem; - __reflect(NewFileSystem.prototype, "RES.NewFileSystem"); -})(RES || (RES = {})); -var RES; -(function (RES) { - var __tempCache = {}; - /** - * Print the memory occupied by the picture. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 打印图片所占内存 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function profile() { - RES.config.config.fileSystem.profile(); - console.log(__tempCache); - //todo - var totalImageSize = 0; - for (var key in __tempCache) { - var img = __tempCache[key]; - if (img instanceof egret.Texture) { - totalImageSize += img.$bitmapWidth * img.$bitmapHeight * 4; - } - } - console.log("gpu size : " + (totalImageSize / 1024).toFixed(3) + "kb"); - } - RES.profile = profile; - /** - * @internal - */ - RES.host = { - state: {}, - get resourceConfig() { - return RES.config; - }, - load: function (r, processorName) { - var processor = typeof processorName == 'string' ? RES.processor._map[processorName] : processorName; - return RES.queue["loadResource"](r, processor); - }, - unload: function (r) { return RES.queue.unloadResource(r); }, - save: function (resource, data) { - RES.host.state[resource.root + resource.name] = 2; - delete resource.promise; - __tempCache[resource.root + resource.name] = data; - }, - get: function (resource) { - return __tempCache[resource.root + resource.name]; - }, - remove: function (resource) { - delete RES.host.state[resource.root + resource.name]; - delete __tempCache[resource.root + resource.name]; - } - }; - /** - * @internal - */ - RES.config = new RES.ResourceConfig(); - /** - * @internal - */ - RES.queue = new RES.ResourceLoader(); - /** - * @private - */ - var ResourceManagerError = (function (_super) { - __extends(ResourceManagerError, _super); - function ResourceManagerError(code, replacer, replacer2) { - var _this = _super.call(this) || this; - /** - * why instanceof e != ResourceManagerError ??? - * see link : https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work - */ - _this.__resource_manager_error__ = true; - _this.name = code.toString(); - _this.message = ResourceManagerError.errorMessage[code].replace("{0}", replacer).replace("{1}", replacer2); - return _this; - } - ResourceManagerError.errorMessage = { - 1001: '文件加载失败:{0}', - 1002: "ResourceManager 初始化失败:配置文件加载失败", - 2001: "{0}解析失败,不支持指定解析类型:\'{1}\',请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor", - 2002: "Analyzer 相关API 在 ResourceManager 中不再支持,请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor", - 2003: "{0}解析失败,错误原因:{1}", - 2004: "无法找到文件类型:{0}", - 2005: "RES加载了不存在或空的资源组:\"{0}\"", - 2006: "资源配置文件中无法找到特定的资源:{0}" - }; - return ResourceManagerError; - }(Error)); - RES.ResourceManagerError = ResourceManagerError; - __reflect(ResourceManagerError.prototype, "RES.ResourceManagerError"); -})(RES || (RES = {})); diff --git a/demo/libs/modules/assetsmanager/assetsmanager.min.js b/demo/libs/modules/assetsmanager/assetsmanager.min.js deleted file mode 100644 index bd155e96..00000000 --- a/demo/libs/modules/assetsmanager/assetsmanager.min.js +++ /dev/null @@ -1 +0,0 @@ -var __reflect=this&&this.__reflect||function(e,r,t){e.__class__=r,t?t.push(r):t=[r],e.__types__=e.__types__?t.concat(e.__types__):t},__extends=this&&this.__extends||function(e,r){function t(){this.constructor=e}for(var o in r)r.hasOwnProperty(o)&&(e[o]=r[o]);t.prototype=r.prototype,e.prototype=new t},__decorate=this&&this.__decorate||function(e,r,t,o){var n,i=arguments.length,a=3>i?r:null===o?o=Object.getOwnPropertyDescriptor(r,t):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,r,t,o);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(3>i?n(a):i>3?n(r,t,a):n(r,t))||a);return i>3&&a&&Object.defineProperty(r,t,a),a},RES;!function(e){}(RES||(RES={}));var RES;!function(e){var r=function(){function r(){this.groupTotalDic={},this.numLoadedDic={},this.groupErrorDic={},this.retryTimesDic={},this.maxRetryTimes=3,this.reporterDic={},this.dispatcherDic={},this.failedList=new Array,this.loadItemErrorDic={},this.errorDic={},this.itemListPriorityDic={},this.itemLoadDic={},this.promiseHash={},this.lazyLoadList=new Array,this.loadingCount=0,this.thread=4}return r.prototype.pushResItem=function(e){if(this.promiseHash[e.root+e.name])return this.promiseHash[e.root+e.name];this.lazyLoadList.push(e),this.itemListPriorityDic[Number.NEGATIVE_INFINITY]=this.lazyLoadList,this.updatelistPriority(this.lazyLoadList,Number.NEGATIVE_INFINITY);var r=new egret.EventDispatcher;this.dispatcherDic[e.root+e.name]=r;var t=new Promise(function(e,t){r.addEventListener("complete",function(r){e(r.data)},null),r.addEventListener("error",function(e){t(e.data)},null)});return this.promiseHash[e.root+e.name]=t,this.loadNextResource(),t},r.prototype.pushResGroup=function(e,r,t,o){if(this.promiseHash[r])return this.promiseHash[r];for(var n=e.length,i=0;n>i;i++){var a=e[i];a.groupNames||(a.groupNames=[]),a.groupNames.push(r)}this.groupTotalDic[r]=e.length,this.numLoadedDic[r]=0,this.updatelistPriority(e,t),this.reporterDic[r]=o;var s=new egret.EventDispatcher;this.dispatcherDic[r]=s;var u=new Promise(function(e,r){s.addEventListener("complete",e,null),s.addEventListener("error",function(e){r(e.data)},null)});return this.promiseHash[r]=u,this.loadNextResource(),u},r.prototype.updatelistPriority=function(e,r){void 0==this.itemListPriorityDic[r]&&(this.itemListPriorityDic[r]=[]);for(var t=0,o=e;ti){this.itemListPriorityDic[r].push(n);var a=this.itemListPriorityDic[i].indexOf(n);this.itemListPriorityDic[i].splice(a,1)}}}},r.prototype.findPriorityInDic=function(e){for(var r in this.itemListPriorityDic)if(this.itemListPriorityDic[r].indexOf(e)>-1)return parseInt(r)},r.prototype.loadNextResource=function(){for(;this.loadingCountr.maxRetryTimes))return r.retryTimesDic[t.name]=n+1,r.failedList.push(t),void r.loadNextResource();if(delete r.retryTimesDic[t.name],r.promiseHash[t.root+t.name]){var i=r.deleteDispatcher(t.root+t.name);i.dispatchEventWith("error",!1,{r:t,error:o})}var a=t.groupNames;if(a){delete t.groupNames;for(var s=0,u=a;s0)return this.failedList.shift();var e=Number.NEGATIVE_INFINITY;for(var r in this.itemListPriorityDic)e=Math.max(e,r);var t=this.itemListPriorityDic[e];if(t)return 0==t.length?(delete this.itemListPriorityDic[e],this.getOneResourceInfoInGroup()):t.shift()},r.prototype.setGroupProgress=function(e,r){var t=this.reporterDic[e];this.numLoadedDic[e]++;var o=this.numLoadedDic[e],n=this.groupTotalDic[e];return t&&t.onProgress&&t.onProgress(o,n,r),o==n},r.prototype.loadGroupEnd=function(e,r){delete this.groupTotalDic[e],delete this.numLoadedDic[e],delete this.reporterDic[e];var t=this.deleteDispatcher(e);if(r){delete this.groupErrorDic[e];var o=this.loadItemErrorDic[e];delete this.loadItemErrorDic[e],t.dispatchEventWith("error",!1,{itemList:o,lastError:r})}else{var n=this.groupErrorDic[e];if(delete this.groupErrorDic[e],n){var o=this.loadItemErrorDic[e];delete this.loadItemErrorDic[e];var i=this.errorDic[e];delete this.errorDic[e],t.dispatchEventWith("error",!1,{itemList:o,error:i})}else t.dispatchEventWith("complete")}},r.prototype.deleteDispatcher=function(e){delete this.promiseHash[e];var r=this.dispatcherDic[e];return delete this.dispatcherDic[e],r},r.prototype.loadResource=function(r,t){if(!t){if(1==e.FEATURE_FLAG.FIX_DUPLICATE_LOAD){var o=e.host.state[r.root+r.name];if(2==o)return Promise.resolve(e.host.get(r));if(1==o)return r.promise}t=e.processor.isSupport(r)}if(!t)throw new e.ResourceManagerError(2001,r.name,r.type);e.host.state[r.root+r.name]=1;var n=t.onLoadStart(e.host,r);return r.promise=n,n},r.prototype.unloadResource=function(r){var t=e.host.get(r);if(!t)return console.warn("尝试释放不存在的资源:",r.name),!1;var o=e.processor.isSupport(r);return o?(o.onRemoveStart(e.host,r),e.host.remove(r),1==r.extra&&e.config.removeResourceData(r),!0):!0},r}();e.ResourceLoader=r,__reflect(r.prototype,"RES.ResourceLoader")}(RES||(RES={}));var RES;!function(e){e.checkNull=function(e,r,t){var o=t.value;t.value=function(){for(var e=[],t=0;t=0?"legacyResourceConfig":"resourceConfig",o={type:t,root:r,url:e,name:e}}e.resourceNameSelector=function(e){return e},e.getResourceInfo=r;var o;e.setConfigURL=t;var n=function(){function t(){}return t.prototype.init=function(){return this.config||(this.config={alias:{},groups:{},resourceRoot:o.root,mergeSelector:null,fileSystem:null,loadGroup:[]}),e.queue.pushResItem(o)["catch"](function(r){return e.isCompatible||r.__resource_manager_error__||(r.error?console.error(r.error.stack):console.error(r.stack),r=new e.ResourceManagerError(1002)),e.host.remove(o),Promise.reject(r)})},t.prototype.getGroupByName=function(r){var t=this.config.groups[r],o=[];if(!t)return o;for(var n=0,i=t;n=0&&(t=e.substr(r+1),e=e.substr(0,r));var o=this.getResource(e);return o?{r:o,key:e,subkey:t}:null},t.prototype.getKeyByAlias=function(e){return this.config.alias[e]?this.config.alias[e]:e},t.prototype.getResource=function(e){var t=this.config.alias[e];t||(t=e);var o=r(t);return o?o:null},t.prototype.createGroup=function(e,r,t){if(void 0===t&&(t=!1),!t&&this.config.groups[e]||!r||0==r.length)return!1;for(var o=[],n=0,i=r;n=0){var o=t.split("://");t=o[0]+"://"+e.path.normalize(o[1]+"/"),r=r.replace(t,"")}else t=e.path.normalize(t+"/"),r=r.replace(t,"");return e.setConfigURL(r,t),P||(P=new D),a(P.loadConfig())}function a(r){return e.isCompatible?void r["catch"](function(e){}).then():r}function s(e,r,t){return void 0===r&&(r=0),a(P.loadGroup(e,r,t))}function u(e){return P.isGroupLoaded(e)}function c(r){return P.getGroupByName(r).map(function(r){return e.ResourceItem.convertToResItem(r)})}function l(e,r,t){return void 0===t&&(t=!1),P.createGroup(e,r,t)}function f(e){return P.hasRes(e)}function p(e){return P.getRes(e)}function g(e,r,t){return a(P.getResAsync.apply(P,arguments))}function d(e,r,t,o){if(void 0===o&&(o=""),!P){var n=egret.sys.tr(3200);return egret.warn(n),Promise.reject(n)}return a(P.getResByUrl(e,r,t,o))}function v(e,r){return P.destroyRes(e,r)}function h(e){P||(P=new D),P.setMaxLoadingThread(e)}function m(e){P.setMaxRetryTimes(e)}function R(e,r,t,o,n){void 0===o&&(o=!1),void 0===n&&(n=0),P||(P=new D),P.addEventListener(e,r,t,o,n)}function E(e,r,t,o){void 0===o&&(o=!1),P.removeEventListener(e,r,t,o)}function y(e){P.addResourceData(e)}function _(){return P||(P=new D),P.vcs}function S(e){P||(P=new D),P.registerVersionController(e)}function L(e){return P.vcs?P.vcs.getVirtualUrl(e):e}e.nameSelector=r,e.typeSelector=t,e.registerAnalyzer=o,e.setIsCompatible=n,e.isCompatible=!1,e.loadConfig=i,e.loadGroup=s,e.isGroupLoaded=u,e.getGroupByName=c,e.createGroup=l,e.hasRes=f,e.getRes=p,e.getResAsync=g,e.getResByUrl=d,e.destroyRes=v,e.setMaxLoadingThread=h,e.setMaxRetryTimes=m,e.addEventListener=R,e.removeEventListener=E,e.$addResourceData=y,e.getVersionController=_,e.registerVersionController=S,e.getVirtualUrl=L;var D=function(r){function t(){var t=r.call(this)||this;return t.isVcsInit=!1,t.normalLoadConfig=function(){return e.config.init().then(function(r){e.ResourceEvent.dispatchResourceEvent(t,e.ResourceEvent.CONFIG_COMPLETE)},function(r){return e.ResourceEvent.dispatchResourceEvent(t,e.ResourceEvent.CONFIG_LOAD_ERROR),Promise.reject(r)})},e.VersionController&&(t.vcs=new e.VersionController),t}return __extends(t,r),t.prototype.registerVersionController=function(e){this.vcs=e,this.isVcsInit=!1},t.prototype.loadConfig=function(){var e=this;return!this.isVcsInit&&this.vcs?(this.isVcsInit=!0,this.vcs.init().then(function(){return e.normalLoadConfig()})):this.normalLoadConfig()},t.prototype.isGroupLoaded=function(r){var t=e.config.getGroupByName(r);return t.every(function(r){return null!=e.host.get(r)})},t.prototype.getGroupByName=function(r){return e.config.getGroupByName(r)},t.prototype.loadGroup=function(r,t,o){var n=this;void 0===t&&(t=0);var i={onProgress:function(t,i,a){o&&o.onProgress&&o.onProgress(t,i,a),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_PROGRESS,r,a,t,i)}};return this._loadGroup(r,t,i).then(function(t){-1==e.config.config.loadGroup.indexOf(r)&&e.config.config.loadGroup.push(r),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_COMPLETE,r)},function(t){if(-1==e.config.config.loadGroup.indexOf(r)&&e.config.config.loadGroup.push(r),t.itemList)for(var o=t.itemList,i=o.length,a=0;i>a;a++){var s=o[a];delete s.promise,e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.ITEM_LOAD_ERROR,r,s)}return e.isCompatible&&console.warn(t.error.message),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_LOAD_ERROR,r),Promise.reject(t.error)})},t.prototype._loadGroup=function(r,t,o){void 0===t&&(t=0);var n=e.config.getGroupByName(r);return 0==n.length?new Promise(function(t,o){o({error:new e.ResourceManagerError(2005,r)})}):e.queue.pushResGroup(n,r,t,o)},t.prototype.createGroup=function(r,t,o){return void 0===o&&(o=!1),e.config.createGroup(r,t,o)},t.prototype.hasRes=function(r){return null!=e.config.getResourceWithSubkey(r)},t.prototype.getRes=function(r){var t=e.config.getResourceWithSubkey(r);if(t){var o=t.r,n=t.key,i=t.subkey,a=e.processor.isSupport(o);return a&&a.getData&&i?a.getData(e.host,o,n,i):e.host.get(o)}return null},t.prototype.getResAsync=function(r,t,o){var n=this,i=r,a=e.config.getResourceWithSubkey(r);if(null==a)return t&&t.call(o,null,i),Promise.reject(new e.ResourceManagerError(2006,r));var s=this.getRes(r);if(s)return t&&egret.callLater(function(){t.call(o,s,i)},this),Promise.resolve(s);var u=a.r,c=a.subkey;return e.queue.pushResItem(u).then(function(n){e.host.save(u,n);var a=e.processor.isSupport(u);return a&&a.getData&&c&&(n=a.getData(e.host,u,r,c)),t&&t.call(o,n,i),n},function(r){return e.host.remove(u),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.ITEM_LOAD_ERROR,"",u),t?(t.call(o,null,i),Promise.reject(null)):Promise.reject(r)})},t.prototype.getResByUrl=function(r,t,o,n){var i=this;void 0===n&&(n="");var a=e.config.getResource(r);if(!a&&(n||(n=e.config.__temp__get__type__via__url(r)),a={name:r,url:r,type:n,root:"",extra:1},e.config.addResourceData(a),a=e.config.getResource(r),!a))throw"never";return e.queue.pushResItem(a).then(function(r){return e.host.save(a,r),t&&a&&t.call(o,r,a.url),r},function(n){return e.host.remove(a),e.ResourceEvent.dispatchResourceEvent(i,e.ResourceEvent.ITEM_LOAD_ERROR,"",a),t?(t.call(o,null,r),Promise.reject(null)):Promise.reject(n)})},t.prototype.destroyRes=function(r,t){void 0===t&&(t=!0);var o=e.config.getGroupByName(r);if(o&&o.length>0){var n=e.config.config.loadGroup.indexOf(r);if(-1==n)return!1;if(t||1==e.config.config.loadGroup.length&&e.config.config.loadGroup[0]==r){for(var i=0,a=o;ir&&(r=1),e.queue.thread=r},t.prototype.setMaxRetryTimes=function(r){r=Math.max(r,0),e.queue.maxRetryTimes=r},t.prototype.addResourceData=function(r){r.root="",e.config.addResourceData(r)},__decorate([e.checkNull],t.prototype,"hasRes",null),__decorate([e.checkNull],t.prototype,"getRes",null),__decorate([e.checkNull],t.prototype,"getResAsync",null),__decorate([e.checkNull],t.prototype,"getResByUrl",null),t}(egret.EventDispatcher);e.Resource=D,__reflect(D.prototype,"RES.Resource");var P}(RES||(RES={}));var RES;!function(e){var r;!function(e){function r(e){var r=e.split("/");return r.filter(function(e,t){return!!e||t==r.length-1}).join("/")}function t(e){return e.substr(e.lastIndexOf("/")+1)}function o(e){return e.substr(0,e.lastIndexOf("/"))}e.normalize=r,e.basename=t,e.dirname=o}(r=e.path||(e.path={}))}(RES||(RES={}));var RES;!function(e){function r(){e.config.config.fileSystem.profile(),console.log(t);var r=0;for(var o in t){var n=t[o];n instanceof egret.Texture&&(r+=n.$bitmapWidth*n.$bitmapHeight*4)}console.log("gpu size : "+(r/1024).toFixed(3)+"kb")}var t={};e.profile=r,e.host={state:{},get resourceConfig(){return e.config},load:function(r,t){var o="string"==typeof t?e.processor._map[t]:t;return e.queue.loadResource(r,o)},unload:function(r){return e.queue.unloadResource(r)},save:function(r,o){e.host.state[r.root+r.name]=2,delete r.promise,t[r.root+r.name]=o},get:function(e){return t[e.root+e.name]},remove:function(r){delete e.host.state[r.root+r.name],delete t[r.root+r.name]}},e.config=new e.ResourceConfig,e.queue=new e.ResourceLoader;var o=function(e){function r(t,o,n){var i=e.call(this)||this;return i.__resource_manager_error__=!0,i.name=t.toString(),i.message=r.errorMessage[t].replace("{0}",o).replace("{1}",n),i}return __extends(r,e),r.errorMessage={1001:"文件加载失败:{0}",1002:"ResourceManager 初始化失败:配置文件加载失败",2001:"{0}解析失败,不支持指定解析类型:'{1}',请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor",2002:"Analyzer 相关API 在 ResourceManager 中不再支持,请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor",2003:"{0}解析失败,错误原因:{1}",2004:"无法找到文件类型:{0}",2005:'RES加载了不存在或空的资源组:"{0}"',2006:"资源配置文件中无法找到特定的资源:{0}"},r}(Error);e.ResourceManagerError=o,__reflect(o.prototype,"RES.ResourceManagerError")}(RES||(RES={}));var RES;!function(e){var r;!function(r){function t(e){return r._map[e.type]}function o(e,t){r._map[e]=t}function n(r,t){var o=this;return new Promise(function(n,i){var a=function(){var e=r.data?r.data:r.response;n(e)},s=function(){var r=new e.ResourceManagerError(1001,t.url);i(r)};r.addEventListener(egret.Event.COMPLETE,a,o),r.addEventListener(egret.IOErrorEvent.IO_ERROR,s,o)})}function i(e,r){if(-1!=r.indexOf("://"))return r;e=e.split("\\").join("/");var t=e.match(/#.*|\?.*/),o="";t&&(o=t[0]);var n=e.lastIndexOf("/");return e=-1!=n?e.substring(0,n+1)+r:r,e+o}function a(e){return{name:e.name+"_alpha",url:e.etc1_alpha_url,type:"ktx",root:e.root}}r.isSupport=t,r.map=o,r.getRelativePath=i,r.ImageProcessor={onLoadStart:function(r,t){var o=new egret.ImageLoader;return o.load(e.getVirtualUrl(t.root+t.url)),n(o,t).then(function(e){var o=new egret.Texture;o._setBitmapData(e);var n=r.resourceConfig.getResource(t.name);if(n&&n.scale9grid){var i=n.scale9grid.split(",");o.scale9Grid=new egret.Rectangle(parseInt(i[0]),parseInt(i[1]),parseInt(i[2]),parseInt(i[3]))}return o})},onRemoveStart:function(e,r){var t=e.get(r);t.dispose()}},r.KTXTextureProcessor={onLoadStart:function(e,r){return e.load(r,"bin").then(function(t){if(!t)return console.error("ktx:"+r.root+r.url+" is null"),null;var o=new egret.KTXContainer(t,1);if(o.isInvalid)return console.error("ktx:"+r.root+r.url+" is invalid"),null;var n=new egret.BitmapData(t);n.debugCompressedTextureURL=r.root+r.url,n.format="ktx",o.uploadLevels(n,!1);var i=new egret.Texture;i._setBitmapData(n);var a=e.resourceConfig.getResource(r.name);if(a&&a.scale9grid){var s=a.scale9grid.split(",");i.scale9Grid=new egret.Rectangle(parseInt(s[0]),parseInt(s[1]),parseInt(s[2]),parseInt(s[3]))}return e.save(r,i),i},function(t){throw e.remove(r),t})},onRemoveStart:function(e,r){var t=e.get(r);t&&t.dispose()}},r.makeEtc1SeperatedAlphaResourceInfo=a,r.ETC1KTXProcessor={onLoadStart:function(e,r){return e.load(r,"ktx").then(function(t){if(!t)return null;if(r.etc1_alpha_url){var o=a(r);return e.load(o,"ktx").then(function(r){return t&&t.$bitmapData&&r.$bitmapData?(t.$bitmapData.etcAlphaMask=r.$bitmapData,e.save(o,r)):e.remove(o),t},function(r){throw e.remove(o),r})}return t},function(t){throw e.remove(r),t})},onRemoveStart:function(e,r){var t=e.get(r);if(t&&t.dispose(),r.etc1_alpha_url){var o=a(r),n=e.get(o);n&&n.dispose(),e.unload(o)}}},r.BinaryProcessor={onLoadStart:function(r,t){var o=new egret.HttpRequest;return o.responseType=egret.HttpResponseType.ARRAY_BUFFER,o.open(e.getVirtualUrl(t.root+t.url),"get"),o.send(),n(o,t)},onRemoveStart:function(e,r){}},r.TextProcessor={onLoadStart:function(r,t){var o=new egret.HttpRequest;return o.responseType=egret.HttpResponseType.TEXT,o.open(e.getVirtualUrl(t.root+t.url),"get"),o.send(),n(o,t)},onRemoveStart:function(e,r){return!0}},r.JsonProcessor={onLoadStart:function(e,r){return e.load(r,"text").then(function(e){var r=JSON.parse(e);return r})},onRemoveStart:function(e,r){}},r.XMLProcessor={onLoadStart:function(e,r){return e.load(r,"text").then(function(e){var r=egret.XML.parse(e);return r})},onRemoveStart:function(e,r){return!0}},r.CommonJSProcessor={onLoadStart:function(r,t){return r.load(t,"text").then(function(r){var o=new Function("require","exports",r),n=function(){},i={};try{o(n,i)}catch(a){throw new e.ResourceManagerError(2003,t.name,a.message)}return i})},onRemoveStart:function(e,r){}},r.SheetProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(o){var n=r.resourceConfig.getResource(e.nameSelector(o.file));if(!n){var a=i(t.url,o.file);n={name:a,url:a,type:"image",root:t.root}}return r.load(n).then(function(e){if(!e)return null;var t=o.frames,i=new egret.SpriteSheet(e);i.$resourceInfo=n;for(var a in t){var s=t[a],u=i.createTexture(a,s.x,s.y,s.w,s.h,s.offX,s.offY,s.sourceW,s.sourceH);if(s.scale9grid){var c=s.scale9grid,l=c.split(",");u.scale9Grid=new egret.Rectangle(parseInt(l[0]),parseInt(l[1]),parseInt(l[2]),parseInt(l[3]))}}return r.save(n,e),i},function(e){throw r.remove(n),e})})},getData:function(e,r,t,o){var n=e.get(r);return n?n.getTexture(o):null},onRemoveStart:function(e,r){var t=e.get(r),o=t.$resourceInfo;t.dispose(),e.unload(o)}};var s=function(e,r){var t="",o=r.split("\n"),n=o[2],i=n.indexOf('file="');-1!=i&&(n=n.substring(i+6),i=n.indexOf('"'),t=n.substring(0,i)),e=e.split("\\").join("/");var i=e.lastIndexOf("/");return e=-1!=i?e.substring(0,i+1)+t:t};r.FontProcessor={onLoadStart:function(r,t){return r.load(t,"text").then(function(o){var n;try{n=JSON.parse(o)}catch(a){n=o}var u;u="string"==typeof n?s(t.url,n):i(t.url,n.file);var c=r.resourceConfig.getResource(e.nameSelector(u));return c||(c={name:u,url:u,type:"image",root:t.root}),r.load(c).then(function(e){var t=new egret.BitmapFont(e,n);return t.$resourceInfo=c,r.save(c,e),t},function(e){throw r.remove(c),e})})},onRemoveStart:function(e,r){var t=e.get(r),o=t.$resourceInfo;e.unload(o)}},r.SoundProcessor={onLoadStart:function(r,t){var o=new egret.Sound;return o.load(e.getVirtualUrl(t.root+t.url)),n(o,t).then(function(){return o})},onRemoveStart:function(e,r){var t=e.get(r);t.close()}},r.MovieClipProcessor={onLoadStart:function(r,t){var o,n;return r.load(t,"json").then(function(i){o=i;var a=t.name,s=a.substring(0,a.lastIndexOf("."))+".png";if(n=r.resourceConfig.getResource(s),!n)throw new e.ResourceManagerError(1001,s);return r.load(n)}).then(function(e){r.save(n,e);var t=e,i=new egret.MovieClipDataFactory(o,t);return i})},onRemoveStart:function(e,r){var t=e.get(r);t.clearCache(),t.$spriteSheet.dispose();var o=r.name,n=o.substring(0,o.lastIndexOf("."))+".png",i=e.resourceConfig.getResource(n);i&&e.unload(i)}},r.MergeJSONProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(r){for(var o in r)e.config.addSubkey(o,t.name);return r})},getData:function(e,r,t,o){var n=e.get(r);return n?n[o]:(console.error("missing resource :"+r.name),null)},onRemoveStart:function(e,r){}},r.LegacyResourceConfigProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(o){var n=e.config.config,i=t.root,a=n.fileSystem;a||(a={fsData:{},getFile:function(e){return p[e]},addFile:function(e){e.type||(e.type=""),void 0==i&&(e.root=""),p[e.name]=e},profile:function(){console.log(p)},removeFile:function(e){delete p[e]}},n.fileSystem=a);for(var s=n.groups,u=0,c=o.groups;u { - [key: string]: T; - } - /** - * @private - */ - class DragonBones { - static readonly VERSION: string; - static yDown: boolean; - static debug: boolean; - static debugDraw: boolean; - static webAssembly: boolean; - private readonly _clock; - private readonly _events; - private readonly _objects; - private _eventManager; - constructor(eventManager: IEventDispatcher); - advanceTime(passedTime: number): void; - bufferEvent(value: EventObject): void; - bufferObject(object: BaseObject): void; - readonly clock: WorldClock; - readonly eventManager: IEventDispatcher; - } -} - -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The BaseObject is the base class for all objects in the DragonBones framework. - * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 基础对象,通常 DragonBones 的对象都继承自该类。 - * 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。 - * @version DragonBones 4.5 - * @language zh_CN - */ - abstract class BaseObject { - private static _hashCode; - private static _defaultMaxCount; - private static readonly _maxCountMap; - private static readonly _poolsMap; - private static _returnObject(object); - static toString(): string; - /** - * - Set the maximum cache count of the specify object pool. - * @param objectConstructor - The specify class. (Set all object pools max cache count if not set) - * @param maxCount - Max count. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 设置特定对象池的最大缓存数量。 - * @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量) - * @param maxCount - 最大缓存数量。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; - /** - * - Clear the cached instances of a specify object pool. - * @param objectConstructor - Specify class. (Clear all cached instances if not set) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除特定对象池的缓存实例。 - * @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例) - * @version DragonBones 4.5 - * @language zh_CN - */ - static clearPool(objectConstructor?: (typeof BaseObject) | null): void; - /** - * - Get an instance of the specify class from object pool. - * @param objectConstructor - The specify class. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从对象池中获取特定类的实例。 - * @param objectConstructor - 特定的类。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static borrowObject(objectConstructor: { - new (): T; - }): T; - /** - * - A unique identification number assigned to the object. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 分配给此实例的唯一标识号。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly hashCode: number; - private _isInPool; - protected abstract _onClear(): void; - /** - * - Clear the object and return it back to object pool。 - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除该实例的所有数据并将其返还对象池。 - * @version DragonBones 4.5 - * @language zh_CN - */ - returnToPool(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - 2D Transform matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 转换矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Matrix { - /** - * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - a: number; - /** - * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - b: number; - /** - * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - c: number; - /** - * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - d: number; - /** - * - The distance by which to translate each point along the x axis. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 沿 x 轴平移每个点的距离。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - tx: number; - /** - * - The distance by which to translate each point along the y axis. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 沿 y 轴平移每个点的距离。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - ty: number; - /** - * @private - */ - constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - toString(): string; - /** - * @private - */ - copyFrom(value: Matrix): Matrix; - /** - * @private - */ - copyFromArray(value: Array, offset?: number): Matrix; - /** - * - Convert to unit matrix. - * The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 转换为单位矩阵。 - * 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。 - * @version DragonBones 3.0 - * @language zh_CN - */ - identity(): Matrix; - /** - * - Multiplies the current matrix with another matrix. - * @param value - The matrix that needs to be multiplied. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将当前矩阵与另一个矩阵相乘。 - * @param value - 需要相乘的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - concat(value: Matrix): Matrix; - /** - * - Convert to inverse matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 转换为逆矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - invert(): Matrix; - /** - * - Apply a matrix transformation to a specific point. - * @param x - X coordinate. - * @param y - Y coordinate. - * @param result - The point after the transformation is applied. - * @param delta - Whether to ignore tx, ty's conversion to point. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将矩阵转换应用于特定点。 - * @param x - 横坐标。 - * @param y - 纵坐标。 - * @param result - 应用转换之后的点。 - * @param delta - 是否忽略 tx,ty 对点的转换。 - * @version DragonBones 3.0 - * @language zh_CN - */ - transformPoint(x: number, y: number, result: { - x: number; - y: number; - }, delta?: boolean): void; - /** - * @private - */ - transformRectangle(rectangle: { - x: number; - y: number; - width: number; - height: number; - }, delta?: boolean): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - 2D Transform. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 变换。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Transform { - /** - * @private - */ - static readonly PI: number; - /** - * @private - */ - static readonly PI_D: number; - /** - * @private - */ - static readonly PI_H: number; - /** - * @private - */ - static readonly PI_Q: number; - /** - * @private - */ - static readonly RAD_DEG: number; - /** - * @private - */ - static readonly DEG_RAD: number; - /** - * @private - */ - static normalizeRadian(value: number): number; - /** - * - Horizontal translate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 水平位移。 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - Vertical translate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 垂直位移。 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - Skew. (In radians) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 倾斜。 (以弧度为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - skew: number; - /** - * - rotation. (In radians) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转。 (以弧度为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - rotation: number; - /** - * - Horizontal Scaling. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 水平缩放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - scaleX: number; - /** - * - Vertical scaling. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 垂直缩放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - scaleY: number; - /** - * @private - */ - constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); - toString(): string; - /** - * @private - */ - copyFrom(value: Transform): Transform; - /** - * @private - */ - identity(): Transform; - /** - * @private - */ - add(value: Transform): Transform; - /** - * @private - */ - minus(value: Transform): Transform; - /** - * @private - */ - fromMatrix(matrix: Matrix): Transform; - /** - * @private - */ - toMatrix(matrix: Matrix): Transform; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class ColorTransform { - alphaMultiplier: number; - redMultiplier: number; - greenMultiplier: number; - blueMultiplier: number; - alphaOffset: number; - redOffset: number; - greenOffset: number; - blueOffset: number; - constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); - copyFrom(value: ColorTransform): void; - identity(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The Point object represents a location in a two-dimensional coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Point 对象表示二维坐标系统中的某个位置。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Point { - /** - * - The horizontal coordinate. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 该点的水平坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - The vertical coordinate. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 该点的垂直坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @param x - The horizontal coordinate. - * @param y - The vertical coordinate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 - * @param x - 该对象的x属性值,默认为 0.0。 - * @param y - 该对象的y属性值,默认为 0.0。 - * @version DragonBones 3.0 - * @language zh_CN - */ - constructor(x?: number, y?: number); - /** - * @private - */ - copyFrom(value: Point): void; - /** - * @private - */ - clear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its - * width and its height.
- * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of - * one property has no effect on the others. However, the right and bottom properties are integrally related to those - * four properties. For example, if you change the value of the right property, the value of the width property changes; - * if you change the bottom property, the value of the height property changes. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
- * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Rectangle { - /** - * - The x coordinate of the top-left corner of the rectangle. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形左上角的 x 坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - The y coordinate of the top-left corner of the rectangle. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形左上角的 y 坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - The width of the rectangle, in pixels. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形的宽度(以像素为单位)。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - width: number; - /** - * - 矩形的高度(以像素为单位)。 - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - The height of the rectangle, in pixels. - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - height: number; - /** - * @private - */ - constructor(x?: number, y?: number, width?: number, height?: number); - /** - * @private - */ - copyFrom(value: Rectangle): void; - /** - * @private - */ - clear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The user custom data. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 用户自定义数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - class UserData extends BaseObject { - static toString(): string; - /** - * - The custom int numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly ints: Array; - /** - * - The custom float numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly floats: Array; - /** - * - The custom strings. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly strings: Array; - protected _onClear(): void; - /** - * @internal - */ - addInt(value: number): void; - /** - * @internal - */ - addFloat(value: number): void; - /** - * @internal - */ - addString(value: string): void; - /** - * - Get the custom int number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getInt(index?: number): number; - /** - * - Get the custom float number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getFloat(index?: number): number; - /** - * - Get the custom string. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getString(index?: number): string; - } - /** - * @internal - */ - class ActionData extends BaseObject { - static toString(): string; - type: ActionType; - name: string; - bone: BoneData | null; - slot: SlotData | null; - data: UserData | null; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The DragonBones data. - * A DragonBones data contains multiple armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 龙骨数据。 - * 一个龙骨数据包含多个骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - class DragonBonesData extends BaseObject { - static toString(): string; - /** - * @private - */ - autoSearch: boolean; - /** - * - The animation frame rate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画帧频。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameRate: number; - /** - * - The data version. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 数据版本。 - * @version DragonBones 3.0 - * @language zh_CN - */ - version: string; - /** - * - The DragonBones data name. - * The name is consistent with the DragonBones project name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 龙骨数据名称。 - * 该名称与龙骨项目名保持一致。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - stage: ArmatureData | null; - /** - * @internal - */ - readonly frameIndices: Array; - /** - * @internal - */ - readonly cachedFrames: Array; - /** - * - All armature data names. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的骨架数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly armatureNames: Array; - /** - * @private - */ - readonly armatures: Map; - /** - * @internal - */ - binary: ArrayBuffer; - /** - * @internal - */ - intArray: Int16Array; - /** - * @internal - */ - floatArray: Float32Array; - /** - * @internal - */ - frameIntArray: Int16Array; - /** - * @internal - */ - frameFloatArray: Float32Array; - /** - * @internal - */ - frameArray: Int16Array; - /** - * @internal - */ - timelineArray: Uint16Array; - /** - * @private - */ - userData: UserData | null; - protected _onClear(): void; - /** - * @internal - */ - addArmature(value: ArmatureData): void; - /** - * - Get a specific armature data. - * @param armatureName - The armature data name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param armatureName - 骨架数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getArmature(armatureName: string): ArmatureData | null; - /** - * - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.BaseFactory#removeDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - dispose(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The armature data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class ArmatureData extends BaseObject { - static toString(): string; - /** - * @private - */ - type: ArmatureType; - /** - * - The animation frame rate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画帧率。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameRate: number; - /** - * @private - */ - cacheFrameRate: number; - /** - * @private - */ - scale: number; - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly aabb: Rectangle; - /** - * - The names of all the animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的动画数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animationNames: Array; - /** - * @private - */ - readonly sortedBones: Array; - /** - * @private - */ - readonly sortedSlots: Array; - /** - * @private - */ - readonly defaultActions: Array; - /** - * @private - */ - readonly actions: Array; - /** - * @private - */ - readonly bones: Map; - /** - * @private - */ - readonly slots: Map; - /** - * @private - */ - readonly constraints: Map; - /** - * @private - */ - readonly skins: Map; - /** - * @private - */ - readonly animations: Map; - /** - * - The default skin data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 默认插槽数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - defaultSkin: SkinData | null; - /** - * - The default animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 默认动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - defaultAnimation: AnimationData | null; - /** - * @private - */ - canvas: CanvasData | null; - /** - * @private - */ - userData: UserData | null; - /** - * @private - */ - parent: DragonBonesData; - protected _onClear(): void; - /** - * @internal - */ - sortBones(): void; - /** - * @internal - */ - cacheFrames(frameRate: number): void; - /** - * @internal - */ - setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; - /** - * @internal - */ - getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; - /** - * @internal - */ - addBone(value: BoneData): void; - /** - * @internal - */ - addSlot(value: SlotData): void; - /** - * @internal - */ - addConstraint(value: ConstraintData): void; - /** - * @internal - */ - addSkin(value: SkinData): void; - /** - * @internal - */ - addAnimation(value: AnimationData): void; - /** - * @internal - */ - addAction(value: ActionData, isDefault: boolean): void; - /** - * - Get a specific done data. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼数据。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getBone(boneName: string): BoneData | null; - /** - * - Get a specific slot data. - * @param slotName - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽数据。 - * @param slotName - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlot(slotName: string): SlotData | null; - /** - * @private - */ - getConstraint(constraintName: string): ConstraintData | null; - /** - * - Get a specific skin data. - * @param skinName - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定皮肤数据。 - * @param skinName - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getSkin(skinName: string): SkinData | null; - /** - * @private - */ - getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; - /** - * - Get a specific animation data. - * @param animationName - The animation animationName. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的动画数据。 - * @param animationName - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getAnimation(animationName: string): AnimationData | null; - } - /** - * - The bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class BoneData extends BaseObject { - static toString(): string; - /** - * @private - */ - inheritTranslation: boolean; - /** - * @private - */ - inheritRotation: boolean; - /** - * @private - */ - inheritScale: boolean; - /** - * @private - */ - inheritReflection: boolean; - /** - * @private - */ - type: BoneType; - /** - * - The bone length. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼长度。 - * @version DragonBones 3.0 - * @language zh_CN - */ - length: number; - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly transform: Transform; - /** - * @private - */ - userData: UserData | null; - /** - * - The parent bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 父骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - parent: BoneData | null; - protected _onClear(): void; - } - /** - * @internal - */ - class SurfaceData extends BoneData { - static toString(): string; - segmentX: number; - segmentY: number; - readonly vertices: Array; - protected _onClear(): void; - } - /** - * - The slot data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class SlotData extends BaseObject { - /** - * @internal - */ - static readonly DEFAULT_COLOR: ColorTransform; - /** - * @internal - */ - static createColor(): ColorTransform; - static toString(): string; - /** - * @private - */ - blendMode: BlendMode; - /** - * @private - */ - displayIndex: number; - /** - * @private - */ - zOrder: number; - /** - * - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - color: ColorTransform; - /** - * @private - */ - userData: UserData | null; - /** - * - The parent bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 父骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - parent: BoneData; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class CanvasData extends BaseObject { - static toString(): string; - hasBackground: boolean; - color: number; - x: number; - y: number; - width: number; - height: number; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The skin data, typically a armature data instance contains at least one skinData. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class SkinData extends BaseObject { - static toString(): string; - /** - * - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly displays: Map>; - /** - * @private - */ - parent: ArmatureData; - protected _onClear(): void; - /** - * @internal - */ - addDisplay(slotName: string, value: DisplayData | null): void; - /** - * @private - */ - getDisplay(slotName: string, displayName: string): DisplayData | null; - /** - * @private - */ - getDisplays(slotName: string): Array | null; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - abstract class ConstraintData extends BaseObject { - order: number; - name: string; - type: ConstraintType; - target: BoneData; - root: BoneData; - bone: BoneData | null; - protected _onClear(): void; - } - /** - * @internal - */ - class IKConstraintData extends ConstraintData { - static toString(): string; - scaleEnabled: boolean; - bendPositive: boolean; - weight: number; - protected _onClear(): void; - } - /** - * @internal - */ - class PathConstraintData extends ConstraintData { - static toString(): string; - pathSlot: SlotData; - pathDisplayData: PathDisplayData; - bones: Array; - positionMode: PositionMode; - spacingMode: SpacingMode; - rotateMode: RotateMode; - position: number; - spacing: number; - rotateOffset: number; - rotateMix: number; - translateMix: number; - protected _onClear(): void; - AddBone(value: BoneData): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class VerticesData { - isShared: boolean; - inheritDeform: boolean; - offset: number; - data: DragonBonesData; - weight: WeightData | null; - clear(): void; - shareFrom(value: VerticesData): void; - } - /** - * @internal - */ - abstract class DisplayData extends BaseObject { - type: DisplayType; - name: string; - path: string; - readonly transform: Transform; - parent: SkinData; - protected _onClear(): void; - } - /** - * @internal - */ - class ImageDisplayData extends DisplayData { - static toString(): string; - readonly pivot: Point; - texture: TextureData | null; - protected _onClear(): void; - } - /** - * @internal - */ - class ArmatureDisplayData extends DisplayData { - static toString(): string; - inheritAnimation: boolean; - readonly actions: Array; - armature: ArmatureData | null; - protected _onClear(): void; - /** - * @private - */ - addAction(value: ActionData): void; - } - /** - * @internal - */ - class MeshDisplayData extends DisplayData { - static toString(): string; - readonly vertices: VerticesData; - texture: TextureData | null; - protected _onClear(): void; - } - /** - * @internal - */ - class BoundingBoxDisplayData extends DisplayData { - static toString(): string; - boundingBox: BoundingBoxData | null; - protected _onClear(): void; - } - /** - * @internal - */ - class PathDisplayData extends DisplayData { - static toString(): string; - closed: boolean; - constantSpeed: boolean; - readonly vertices: VerticesData; - readonly curveLengths: Array; - protected _onClear(): void; - } - /** - * @internal - */ - class WeightData extends BaseObject { - static toString(): string; - count: number; - offset: number; - readonly bones: Array; - protected _onClear(): void; - addBone(value: BoneData): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The base class of bounding box data. - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框数据基类。 - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract class BoundingBoxData extends BaseObject { - /** - * - The bounding box type. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框类型。 - * @version DragonBones 5.0 - * @language zh_CN - */ - type: BoundingBoxType; - /** - * @private - */ - color: number; - /** - * @private - */ - width: number; - /** - * @private - */ - height: number; - protected _onClear(): void; - /** - * - Check whether the bounding box contains a specific point. (Local coordinate system) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查边界框是否包含特定点。(本地坐标系) - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract containsPoint(pX: number, pY: number): boolean; - /** - * - Check whether the bounding box intersects a specific segment. (Local coordinate system) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查边界框是否与特定线段相交。(本地坐标系) - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { - x: number; - y: number; - } | null, intersectionPointB: { - x: number; - y: number; - } | null, normalRadians: { - x: number; - y: number; - } | null): number; - } - /** - * - The rectangle bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 矩形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class RectangleBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * - Compute the bit code for a point (x, y) using the clip rectangle - */ - private static _computeOutCode(x, y, xMin, yMin, xMax, yMax); - /** - * @private - */ - static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } - /** - * - The ellipse bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 椭圆边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class EllipseBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * @private - */ - static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } - /** - * - The polygon bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class PolygonBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * @private - */ - static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - /** - * @private - */ - x: number; - /** - * @private - */ - y: number; - /** - * - The polygon vertices. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形顶点。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly vertices: Array; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class AnimationData extends BaseObject { - static toString(): string; - /** - * - FrameIntArray. - * @internal - */ - frameIntOffset: number; - /** - * - FrameFloatArray. - * @internal - */ - frameFloatOffset: number; - /** - * - FrameArray. - * @internal - */ - frameOffset: number; - /** - * - The frame count of the animation. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的帧数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameCount: number; - /** - * - The play times of the animation. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The duration of the animation. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的持续时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - duration: number; - /** - * @private - */ - scale: number; - /** - * - The fade in time of the animation. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的淡入时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - fadeInTime: number; - /** - * @private - */ - cacheFrameRate: number; - /** - * - The animation name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly cachedFrames: Array; - /** - * @private - */ - readonly boneTimelines: Map>; - /** - * @private - */ - readonly surfaceTimelines: Map>; - /** - * @private - */ - readonly slotTimelines: Map>; - /** - * @private - */ - readonly constraintTimelines: Map>; - /** - * @private - */ - readonly animationTimelines: Map>; - /** - * @private - */ - readonly boneCachedFrameIndices: Map>; - /** - * @private - */ - readonly slotCachedFrameIndices: Map>; - /** - * @private - */ - actionTimeline: TimelineData | null; - /** - * @private - */ - zOrderTimeline: TimelineData | null; - /** - * @private - */ - parent: ArmatureData; - protected _onClear(): void; - /** - * @internal - */ - cacheFrames(frameRate: number): void; - /** - * @private - */ - addBoneTimeline(bone: BoneData, timeline: TimelineData): void; - /** - * @private - */ - addSurfaceTimeline(surface: SurfaceData, timeline: TimelineData): void; - /** - * @private - */ - addSlotTimeline(slot: SlotData, timeline: TimelineData): void; - /** - * @private - */ - addConstraintTimeline(constraint: ConstraintData, timeline: TimelineData): void; - /** - * @private - */ - addAnimationTimeline(timelineName: string, timeline: TimelineData): void; - /** - * @private - */ - getBoneTimelines(timelineName: string): Array | null; - /** - * @private - */ - getSurfaceTimelines(timelineName: string): Array | null; - /** - * @private - */ - getSlotTimelines(timelineName: string): Array | null; - /** - * @private - */ - getConstraintTimelines(timelineName: string): Array | null; - /** - * @private - */ - getAnimationTimelines(timelineName: string): Array | null; - /** - * @private - */ - getBoneCachedFrameIndices(boneName: string): Array | null; - /** - * @private - */ - getSlotCachedFrameIndices(slotName: string): Array | null; - } - /** - * @internal - */ - class TimelineData extends BaseObject { - static toString(): string; - type: TimelineType; - offset: number; - frameIndicesOffset: number; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The animation config is used to describe all the information needed to play an animation state. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画配置用来描述播放一个动画状态所需要的全部信息。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - class AnimationConfig extends BaseObject { - static toString(): string; - /** - * @private - */ - pauseFadeOut: boolean; - /** - * - Fade out the pattern of other animation states when the animation state is fade in. - * This property is typically used to specify the substitution of multiple animation states blend. - * @default dragonBones.AnimationFadeOutMode.All - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 淡入动画状态时淡出其他动画状态的模式。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @default dragonBones.AnimationFadeOutMode.All - * @version DragonBones 5.0 - * @language zh_CN - */ - fadeOutMode: AnimationFadeOutMode; - /** - * @private - */ - fadeOutTweenType: TweenType; - /** - * @private - */ - fadeOutTime: number; - /** - * @private - */ - pauseFadeIn: boolean; - /** - * @private - */ - actionEnabled: boolean; - /** - * @private - */ - additiveBlending: boolean; - /** - * - Whether the animation state has control over the display property of the slots. - * Sometimes blend a animation state does not want it to control the display properties of the slots, - * especially if other animation state are controlling the display properties of the slots. - * @default true - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态是否对插槽的显示对象属性有控制权。 - * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, - * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 - * @default true - * @version DragonBones 5.0 - * @language zh_CN - */ - displayControl: boolean; - /** - * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. - * This property should usually be set to false when blend multiple animation states. - * @default true - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 - * 通常在混合多个动画状态时应该将该属性设置为 false。 - * @default true - * @version DragonBones 5.1 - * @language zh_CN - */ - resetToPose: boolean; - /** - * @private - */ - fadeInTweenType: TweenType; - /** - * - The play times. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The blend layer. - * High layer animation state will get the blend weight first. - * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合图层。 - * 图层高的动画状态会优先获取混合权重。 - * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - layer: number; - /** - * - The start time of play. (In seconds) - * @default 0.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 播放的开始时间。 (以秒为单位) - * @default 0.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - position: number; - /** - * - The duration of play. - * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 播放的持续时间。 - * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - duration: number; - /** - * - The play speed. - * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. - * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度。 - * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 - * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - /** - * - The blend weight. - * @default 1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合权重。 - * @default 1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - weight: number; - /** - * - The fade in time. - * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 淡入时间。 - * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - fadeInTime: number; - /** - * - The auto fade out time when the animation state play completed. - * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态播放完成后的自动淡出时间。 - * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - autoFadeOutTime: number; - /** - * - The name of the animation state. (Can be different from the name of the animation data) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态名称。 (可以不同于动画数据) - * @version DragonBones 5.0 - * @language zh_CN - */ - name: string; - /** - * - The animation data name. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画数据名称。 - * @version DragonBones 5.0 - * @language zh_CN - */ - animation: string; - /** - * - The blend group name of the animation state. - * This property is typically used to specify the substitution of multiple animation states blend. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合组名称。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - group: string; - /** - * @private - */ - readonly boneMask: Array; - protected _onClear(): void; - /** - * @private - */ - clear(): void; - /** - * @private - */ - copyFrom(value: AnimationConfig): void; - /** - * @private - */ - containsBoneMask(boneName: string): boolean; - /** - * @private - */ - addBoneMask(armature: Armature, boneName: string, recursive?: boolean): void; - /** - * @private - */ - removeBoneMask(armature: Armature, boneName: string, recursive?: boolean): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class TextureAtlasData extends BaseObject { - /** - * @private - */ - autoSearch: boolean; - /** - * @private - */ - width: number; - /** - * @private - */ - height: number; - /** - * @private - */ - scale: number; - /** - * - The texture atlas name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * - The image path of the texture atlas. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集图片路径。 - * @version DragonBones 3.0 - * @language zh_CN - */ - imagePath: string; - /** - * @private - */ - readonly textures: Map; - protected _onClear(): void; - /** - * @private - */ - copyFrom(value: TextureAtlasData): void; - /** - * @internal - */ - abstract createTexture(): TextureData; - /** - * @internal - */ - addTexture(value: TextureData): void; - /** - * @private - */ - getTexture(textureName: string): TextureData | null; - } - /** - * @internal - */ - abstract class TextureData extends BaseObject { - static createRectangle(): Rectangle; - rotated: boolean; - name: string; - readonly region: Rectangle; - parent: TextureAtlasData; - frame: Rectangle | null; - protected _onClear(): void; - copyFrom(value: TextureData): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class DeformVertices extends BaseObject { - static toString(): string; - verticesDirty: boolean; - readonly vertices: Array; - readonly bones: Array; - verticesData: VerticesData | null; - protected _onClear(): void; - init(verticesDataValue: VerticesData | null, armature: Armature): void; - isBonesUpdate(): boolean; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The armature proxy interface, the docking engine needs to implement it concretely. - * @see dragonBones.Armature - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 骨架代理接口,对接的引擎需要对其进行具体实现。 - * @see dragonBones.Armature - * @version DragonBones 5.0 - * @language zh_CN - */ - interface IArmatureProxy extends IEventDispatcher { - /** - * @internal - */ - dbInit(armature: Armature): void; - /** - * @internal - */ - dbClear(): void; - /** - * @internal - */ - dbUpdate(): void; - /** - * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) - * @example - *
-         *     removeChild(armatureDisplay);
-         *     armatureDisplay.dispose();
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 释放该实例和骨架。 (骨架会回收到对象池) - * @example - *
-         *     removeChild(armatureDisplay);
-         *     armatureDisplay.dispose();
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - dispose(disposeProxy: boolean): void; - /** - * - The armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly armature: Armature; - /** - * - The animation player. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animation: Animation; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - Armature is the core of the skeleton animation system. - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架是骨骼动画系统的核心。 - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - class Armature extends BaseObject implements IAnimatable { - static toString(): string; - private static _onSortSlots(a, b); - /** - * - Whether to inherit the animation control of the parent armature. - * True to try to have the child armature play an animation with the same name when the parent armature play the animation. - * @default true - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 是否继承父骨架的动画控制。 - * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 - * @default true - * @version DragonBones 4.5 - * @language zh_CN - */ - inheritAnimation: boolean; - /** - * @private - */ - userData: any; - private _lockUpdate; - private _slotsDirty; - private _zOrderDirty; - private _flipX; - private _flipY; - /** - * @internal - */ - _cacheFrameIndex: number; - private readonly _bones; - private readonly _slots; - /** - * @internal - */ - readonly _constraints: Array; - private readonly _actions; - /** - * @internal - */ - _armatureData: ArmatureData; - private _animation; - private _proxy; - private _display; - /** - * @internal - */ - _replaceTextureAtlasData: TextureAtlasData | null; - private _replacedTexture; - /** - * @internal - */ - _dragonBones: DragonBones; - private _clock; - /** - * @internal - */ - _parent: Slot | null; - protected _onClear(): void; - /** - * @internal - */ - _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; - /** - * @internal - */ - _addBone(value: Bone): void; - /** - * @internal - */ - _addSlot(value: Slot): void; - /** - * @internal - */ - _addConstraint(value: Constraint): void; - /** - * @internal - */ - _bufferAction(action: EventObject, append: boolean): void; - /** - * - Dispose the armature. (Return to the object pool) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 释放骨架。 (回收到对象池) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - dispose(): void; - /** - * @internal - */ - init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; - /** - * @inheritDoc - */ - advanceTime(passedTime: number): void; - /** - * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. - * @param boneName - The bone name. (If not set, all bones will be update) - * @param updateSlot - Whether to update the bone's slots. (Default: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 - * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) - * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; - /** - * - Check whether a specific point is inside a custom bounding box in a slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在某个插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - containsPoint(x: number, y: number): Slot | null; - /** - * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 - * @version DragonBones 5.0 - * @language zh_CN - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): Slot | null; - /** - * - Get a specific bone. - * @param name - The bone name. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼。 - * @param name - 骨骼名称。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBone(name: string): Bone | null; - /** - * - Get a specific bone by the display. - * @param display - The display object. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的骨骼。 - * @param display - 显示对象。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBoneByDisplay(display: any): Bone | null; - /** - * - Get a specific slot. - * @param name - The slot name. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽。 - * @param name - 插槽名称。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlot(name: string): Slot | null; - /** - * - Get a specific slot by the display. - * @param display - The display object. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的插槽。 - * @param display - 显示对象。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlotByDisplay(display: any): Slot | null; - /** - * - Get all bones. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBones(): Array; - /** - * - Get all slots. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlots(): Array; - /** - * - Whether to flip the armature horizontally. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架水平翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - flipX: boolean; - /** - * - Whether to flip the armature vertically. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架垂直翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - flipY: boolean; - /** - * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. - * There is a certain amount of memory overhead to improve performance by caching animation data in memory. - * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. - * When the animation cache is turned on, some features will fail, such as the offset property of bone. - * @example - *
-         *     armature.cacheFrameRate = 24;
-         * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 - * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 - * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 - * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 - * @example - *
-         *     armature.cacheFrameRate = 24;
-         * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language zh_CN - */ - cacheFrameRate: number; - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - The armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly armatureData: ArmatureData; - /** - * - The animation player. - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animation: Animation; - /** - * @pivate - */ - readonly proxy: IArmatureProxy; - /** - * - The EventDispatcher instance of the armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架的 EventDispatcher 实例。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly eventDispatcher: IEventDispatcher; - /** - * - The display container. - * The display of the slot is displayed as the parent. - * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 显示容器实例。 - * 插槽的显示对象都会以此显示容器为父级。 - * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly display: any; - /** - * @private - */ - replacedTexture: any; - /** - * @inheritDoc - */ - clock: WorldClock | null; - /** - * - Get the parent slot which the armature belongs to. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架所属的父插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly parent: Slot | null; - /** - * @deprecated - * @private - */ - replaceTexture(texture: any): void; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - hasEventListener(type: EventStringType): boolean; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - addEventListener(type: EventStringType, listener: Function, target: any): void; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - removeEventListener(type: EventStringType, listener: Function, target: any): void; - /** - * - Deprecated, please refer to {@link #cacheFrameRate}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - enableAnimationCache(frameRate: number): void; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - getDisplay(): any; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The base class of the transform object. - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 变换对象的基类。 - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language zh_CN - */ - abstract class TransformObject extends BaseObject { - protected static readonly _helpMatrix: Matrix; - protected static readonly _helpTransform: Transform; - protected static readonly _helpPoint: Point; - /** - * - A matrix relative to the armature coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly globalTransformMatrix: Matrix; - /** - * - A transform relative to the armature coordinate system. - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的变换。 - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly global: Transform; - /** - * - The offset transform relative to the armature or the parent bone coordinate system. - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架或父骨骼坐标系的偏移变换。 - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly offset: Transform; - /** - * @private - */ - origin: Transform | null; - /** - * @private - */ - userData: any; - protected _globalDirty: boolean; - /** - * @internal - */ - _armature: Armature; - /** - */ - protected _onClear(): void; - /** - * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, - * some engines do not rely on these attributes to update rendering, such as Egret. - * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 - * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - updateGlobalTransform(): void; - /** - * - The armature to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的骨架。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly armature: Armature; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - Bone is one of the most important logical units in the armature animation system, - * and is responsible for the realization of translate, rotation, scaling in the animations. - * A armature can contain multiple bones. - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 - * 一个骨架中可以包含多个骨骼。 - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - class Bone extends TransformObject { - static toString(): string; - /** - * - The offset mode. - * @see #offset - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 偏移模式。 - * @see #offset - * @version DragonBones 5.5 - * @language zh_CN - */ - offsetMode: OffsetMode; - /** - * @internal - */ - readonly animationPose: Transform; - /** - * @internal - */ - _transformDirty: boolean; - /** - * @internal - */ - _childrenTransformDirty: boolean; - protected _localDirty: boolean; - /** - * @internal - */ - _hasConstraint: boolean; - protected _visible: boolean; - protected _cachedFrameIndex: number; - /** - * @internal - */ - readonly _blendState: BlendState; - /** - * @internal - */ - _boneData: BoneData; - /** - * @private - */ - protected _parent: Bone | null; - /** - * @internal - */ - _cachedFrameIndices: Array | null; - protected _onClear(): void; - protected _updateGlobalTransformMatrix(isCache: boolean): void; - /** - * @internal - */ - init(boneData: BoneData, armatureValue: Armature): void; - /** - * @internal - */ - update(cacheFrameIndex: number): void; - /** - * @internal - */ - updateByConstraint(): void; - /** - * - Forces the bone to update the transform in the next frame. - * When the bone is not animated or its animation state is finished, the bone will not continue to update, - * and when the skeleton must be updated for some reason, the method needs to be called explicitly. - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制骨骼在下一帧更新变换。 - * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - invalidUpdate(): void; - /** - * - Check whether the bone contains a specific bone. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查该骨骼是否包含特定的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - contains(value: Bone): boolean; - /** - * - The bone data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly boneData: BoneData; - /** - * - The visible of all slots in the bone. - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 此骨骼所有插槽的可见。 - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language zh_CN - */ - visible: boolean; - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly parent: Bone | null; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getBones()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getBones()}。 - * @deprecated - * @language zh_CN - */ - getBones(): Array; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getSlots()}。 - * @deprecated - * @language zh_CN - */ - getSlots(): Array; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getSlot()}。 - * @deprecated - * @language zh_CN - */ - readonly slot: Slot | null; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class Surface extends Bone { - static toString(): string; - private _dX; - private _dY; - private _k; - private _kX; - private _kY; - readonly _vertices: Array; - readonly _deformVertices: Array; - /** - * - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y - */ - private readonly _hullCache; - /** - * - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] - */ - private readonly _matrixCahce; - protected _onClear(): void; - private _getAffineTransform(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown); - private _updateVertices(); - protected _updateGlobalTransformMatrix(isCache: boolean): void; - _getGlobalTransformMatrix(x: number, y: number): Matrix; - /** - * @internal - * @private - */ - init(surfaceData: SurfaceData, armatureValue: Armature): void; - /** - * @internal - */ - update(cacheFrameIndex: number): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The slot attached to the armature, controls the display status and properties of the display object. - * A bone can contain multiple slots. - * A slot can contain multiple display objects, displaying only one of the display objects at a time, - * but you can toggle the display object into frame animation while the animation is playing. - * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, - * and a custom other display object. - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 - * 一个骨骼上可以包含多个插槽。 - * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 - * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class Slot extends TransformObject { - /** - * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. - * @default null - * @see dragonBones.AnimationState#displayControl - * @see dragonBones.AnimationState#name - * @see dragonBones.AnimationState#group - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 - * @default null - * @see dragonBones.AnimationState#displayControl - * @see dragonBones.AnimationState#name - * @see dragonBones.AnimationState#group - * @version DragonBones 4.5 - * @language zh_CN - */ - displayController: string | null; - protected _displayDirty: boolean; - protected _zOrderDirty: boolean; - protected _visibleDirty: boolean; - protected _blendModeDirty: boolean; - /** - * @internal - */ - _colorDirty: boolean; - protected _transformDirty: boolean; - protected _visible: boolean; - protected _blendMode: BlendMode; - protected _displayIndex: number; - protected _animationDisplayIndex: number; - /** - * @internal - */ - _zOrder: number; - protected _cachedFrameIndex: number; - /** - * @internal - */ - _pivotX: number; - /** - * @internal - */ - _pivotY: number; - protected readonly _localMatrix: Matrix; - /** - * @internal - */ - readonly _colorTransform: ColorTransform; - protected readonly _displayDatas: Array; - protected readonly _displayList: Array; - /** - * @internal - */ - _slotData: SlotData; - protected _rawDisplayDatas: Array | null; - /** - * @internal - */ - _displayData: DisplayData | null; - protected _boundingBoxData: BoundingBoxData | null; - protected _textureData: TextureData | null; - /** - * @internal - */ - _deformVertices: DeformVertices | null; - protected _rawDisplay: any; - protected _meshDisplay: any; - protected _display: any; - protected _childArmature: Armature | null; - /** - * @private - */ - protected _parent: Bone; - /** - * @internal - */ - _cachedFrameIndices: Array | null; - protected _onClear(): void; - protected abstract _initDisplay(value: any, isRetain: boolean): void; - protected abstract _disposeDisplay(value: any, isRelease: boolean): void; - protected abstract _onUpdateDisplay(): void; - protected abstract _addDisplay(): void; - protected abstract _replaceDisplay(value: any): void; - protected abstract _removeDisplay(): void; - protected abstract _updateZOrder(): void; - /** - * @internal - */ - abstract _updateVisible(): void; - protected abstract _updateBlendMode(): void; - protected abstract _updateColor(): void; - protected abstract _updateFrame(): void; - protected abstract _updateMesh(): void; - /** - * @internal - */ - abstract _updateGlueMesh(): void; - protected abstract _updateTransform(): void; - protected abstract _identityTransform(): void; - /** - * - Support default skin data. - */ - protected _getDefaultRawDisplayData(displayIndex: number): DisplayData | null; - protected _updateDisplayData(): void; - protected _updateDisplay(): void; - protected _updateGlobalTransformMatrix(isCache: boolean): void; - /** - * @internal - */ - _setDisplayIndex(value: number, isAnimation?: boolean): boolean; - /** - * @internal - */ - _setZorder(value: number): boolean; - /** - * @internal - */ - _setColor(value: ColorTransform): boolean; - /** - * @internal - */ - _setDisplayList(value: Array | null): boolean; - /** - * @internal - */ - init(slotData: SlotData, armatureValue: Armature, rawDisplay: any, meshDisplay: any): void; - /** - * @internal - */ - update(cacheFrameIndex: number): void; - /** - * @private - */ - updateTransformAndMatrix(): void; - /** - * @private - */ - replaceDisplayData(value: DisplayData | null, displayIndex?: number): void; - /** - * - Check whether a specific point is inside a custom bounding box in the slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - containsPoint(x: number, y: number): boolean; - /** - * - Check whether a specific segment intersects a custom bounding box for the slot. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] - * @version DragonBones 5.0 - * @language zh_CN - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - /** - * - Forces the slot to update the state of the display object in the next frame. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 强制插槽在下一帧更新显示对象的状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - invalidUpdate(): void; - /** - * - The visible of slot's display object. - * @default true - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 插槽的显示对象的可见。 - * @default true - * @version DragonBones 5.6 - * @language zh_CN - */ - visible: boolean; - /** - * - The index of the display object displayed in the display list. - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     slot.displayIndex = 3;
-         *     slot.displayController = "none";
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 此时显示的显示对象在显示列表中的索引。 - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     slot.displayIndex = 3;
-         *     slot.displayController = "none";
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - displayIndex: number; - /** - * - The slot name. - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - Contains a display list of display objects or child armatures. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 包含显示对象或子骨架的显示列表。 - * @version DragonBones 3.0 - * @language zh_CN - */ - displayList: Array; - /** - * - The slot data. - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 插槽数据。 - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly slotData: SlotData; - /** - * @private - */ - rawDisplayDatas: Array | null; - /** - * @private - */ - readonly displayData: DisplayData | null; - /** - * - The custom bounding box data for the slot at current time. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 插槽此时的自定义包围盒数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly boundingBoxData: BoundingBoxData | null; - /** - * @private - */ - readonly rawDisplay: any; - /** - * @private - */ - readonly meshDisplay: any; - /** - * - The display object that the slot displays at this time. - * @example - *
-         *     let slot = armature.getSlot("text");
-         *     slot.display = new yourEngine.TextField();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的显示对象。 - * @example - *
-         *     let slot = armature.getSlot("text");
-         *     slot.display = new yourEngine.TextField();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - display: any; - /** - * - The child armature that the slot displayed at current time. - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         * let prevChildArmature = slot.childArmature;
-         * if (prevChildArmature) {
-         * prevChildArmature.dispose();
-         *     }
-         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的子骨架。 - * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         * let prevChildArmature = slot.childArmature;
-         * if (prevChildArmature) {
-         * prevChildArmature.dispose();
-         *     }
-         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - childArmature: Armature | null; - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly parent: Bone; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - getDisplay(): any; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - setDisplay(value: any): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - abstract class Constraint extends BaseObject { - protected static readonly _helpMatrix: Matrix; - protected static readonly _helpTransform: Transform; - protected static readonly _helpPoint: Point; - /** - * - For timeline state. - * @internal - */ - _constraintData: ConstraintData; - protected _armature: Armature; - /** - * - For sort bones. - * @internal - */ - _target: Bone; - /** - * - For sort bones. - * @internal - */ - _root: Bone; - protected _bone: Bone | null; - protected _onClear(): void; - abstract init(constraintData: ConstraintData, armature: Armature): void; - abstract update(): void; - abstract invalidUpdate(): void; - readonly name: string; - } - /** - * @internal - */ - class IKConstraint extends Constraint { - static toString(): string; - private _scaleEnabled; - /** - * - For timeline state. - * @internal - */ - _bendPositive: boolean; - /** - * - For timeline state. - * @internal - */ - _weight: number; - protected _onClear(): void; - private _computeA(); - private _computeB(); - init(constraintData: ConstraintData, armature: Armature): void; - update(): void; - invalidUpdate(): void; - } - /** - * @internal - */ - class PathConstraint extends Constraint { - dirty: boolean; - pathOffset: number; - position: number; - spacing: number; - rotateOffset: number; - rotateMix: number; - translateMix: number; - private _pathSlot; - private _bones; - private _spaces; - private _positions; - private _curves; - private _boneLengths; - private _pathGlobalVertices; - private _segments; - static toString(): string; - protected _onClear(): void; - protected _updatePathVertices(verticesData: VerticesData): void; - protected _computeVertices(start: number, count: number, offset: number, out: Array): void; - protected _computeBezierCurve(pathDisplayDta: PathDisplayData, spaceCount: number, tangents: boolean, percentPosition: boolean, percentSpacing: boolean): void; - private addCurvePosition(t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents); - init(constraintData: ConstraintData, armature: Armature): void; - update(): void; - invalidUpdate(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - Play animation interface. (Both Armature and Wordclock implement the interface) - * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. - * @see dragonBones.WorldClock - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) - * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 - * @see dragonBones.WorldClock - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - interface IAnimatable { - /** - * - Advance time. - * @param passedTime - Passed time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 更新时间。 - * @param passedTime - 前进的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - advanceTime(passedTime: number): void; - /** - * - The Wordclock instance to which the current belongs. - * @example - *
-         *     armature.clock = factory.clock; // Add armature to clock.
-         *     armature.clock = null; // Remove armature from clock.
-         * 
- * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 当前所属的 WordClock 实例。 - * @example - *
-         *     armature.clock = factory.clock; // 将骨架添加到时钟。
-         *     armature.clock = null; // 将骨架从时钟移除。
-         * 
- * @version DragonBones 5.0 - * @language zh_CN - */ - clock: WorldClock | null; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - class WorldClock implements IAnimatable { - /** - * - Current time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - time: number; - /** - * - The play speed, used to control animation speed-shift play. - * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度,用于控制动画变速播放。 - * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - private _systemTime; - private readonly _animatebles; - private _clock; - /** - * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. - * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 - * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 - * @version DragonBones 3.0 - * @language zh_CN - */ - constructor(time?: number); - /** - * - Advance time for all IAnimatable instances. - * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 为所有的 IAnimatable 实例更新时间。 - * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - advanceTime(passedTime: number): void; - /** - * - Check whether contains a specific instance of IAnimatable. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - contains(value: IAnimatable): boolean; - /** - * - Add IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - add(value: IAnimatable): void; - /** - * - Removes a specified IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - remove(value: IAnimatable): void; - /** - * - Clear all IAnimatable instances. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 清除所有的 IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - clear(): void; - /** - * @inheritDoc - */ - clock: WorldClock | null; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#clock}。 - * @deprecated - * @language zh_CN - */ - static readonly clock: WorldClock; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The animation player is used to play the animation data and manage the animation states. - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器用来播放动画数据和管理动画状态。 - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - class Animation extends BaseObject { - static toString(): string; - /** - * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - private _lockUpdate; - private _animationDirty; - private _inheritTimeScale; - private readonly _animationNames; - private readonly _animationStates; - private readonly _animations; - private _armature; - private _animationConfig; - private _lastAnimationState; - protected _onClear(): void; - private _fadeOut(animationConfig); - /** - * @internal - */ - init(armature: Armature): void; - /** - * @internal - */ - advanceTime(passedTime: number): void; - /** - * - Clear all animations states. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除所有的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - reset(): void; - /** - * - Pause a specific animation state. - * @param animationName - The name of animation state. (If not set, it will pause all animations) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停指定动画状态的播放。 - * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - stop(animationName?: string | null): void; - /** - * - Play animation with a specific animation config. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @param animationConfig - The animation config. - * @returns The playing animation state. - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 通过指定的动画配置来播放动画。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @param animationConfig - 动画配置。 - * @returns 播放的动画状态。 - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - playConfig(animationConfig: AnimationConfig): AnimationState | null; - /** - * - Play a specific animation. - * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) - * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放指定动画。 - * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - play(animationName?: string | null, playTimes?: number): AnimationState | null; - /** - * - Fade in a specific animation. - * @param animationName - The name of animation data. - * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) - * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) - * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) - * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 淡入播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) - * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) - * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; - /** - * - Play a specific animation from the specific time. - * @param animationName - The name of animation data. - * @param time - The start time point of playing. (In seconds) - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定时间开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param time - 播放开始的时间。 (以秒为单位) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; - /** - * - Play a specific animation from the specific frame. - * @param animationName - The name of animation data. - * @param frame - The start frame of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定帧开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param frame - 播放开始的帧数。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; - /** - * - Play a specific animation from the specific progress. - * @param animationName - The name of animation data. - * @param progress - The start progress value of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定进度开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param progress - 开始播放的进度。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific time. - * @param animationName - The name of animation data. - * @param time - The stop time. (In seconds) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定时间停止指定动画播放 - * @param animationName - 动画数据名称。 - * @param time - 停止的时间。 (以秒为单位) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific frame. - * @param animationName - The name of animation data. - * @param frame - The stop frame. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定帧停止指定动画的播放 - * @param animationName - 动画数据名称。 - * @param frame - 停止的帧数。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific progress. - * @param animationName - The name of animation data. - * @param progress - The stop progress value. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定的进度停止指定的动画播放。 - * @param animationName - 动画数据名称。 - * @param progress - 停止进度。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; - /** - * - Get a specific animation state. - * @param animationName - The name of animation state. - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取指定的动画状态 - * @param animationName - 动画状态名称。 - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - getState(animationName: string): AnimationState | null; - /** - * - Check whether a specific animation data is included. - * @param animationName - The name of animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含指定的动画数据 - * @param animationName - 动画数据名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - hasAnimation(animationName: string): boolean; - /** - * - Get all the animation states. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取所有的动画状态 - * @version DragonBones 5.1 - * @language zh_CN - */ - getStates(): Array; - /** - * - Check whether there is an animation state is playing - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否有动画状态正在播放 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isPlaying: boolean; - /** - * - Check whether all the animation states' playing were finished. - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否所有的动画状态均已播放完毕。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isCompleted: boolean; - /** - * - The name of the last playing animation state. - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态名称 - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly lastAnimationName: string; - /** - * - The name of all animation data - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有动画数据的名称 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly animationNames: Array; - /** - * - All animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有的动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - animations: Map; - /** - * - An AnimationConfig instance that can be used quickly. - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 一个可以快速使用的动画配置实例。 - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly animationConfig: AnimationConfig; - /** - * - The last playing animation state - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly lastAnimationState: AnimationState | null; - /** - * - Deprecated, please refer to {@link #play()} {@link #fadeIn()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #play()} {@link #fadeIn()}。 - * @deprecated - * @language zh_CN - */ - gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; - /** - * - Deprecated, please refer to {@link #gotoAndStopByTime()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #gotoAndStopByTime()}。 - * @deprecated - * @language zh_CN - */ - gotoAndStop(animationName: string, time?: number): AnimationState | null; - /** - * - Deprecated, please refer to {@link #animationNames}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #animationNames}。 - * @deprecated - * @language zh_CN - */ - readonly animationList: Array; - /** - * - Deprecated, please refer to {@link #animationNames}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #animationNames}。 - * @deprecated - * @language zh_CN - */ - readonly animationDataList: Array; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The animation state is generated when the animation data is played. - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画状态由播放动画数据时产生。 - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - class AnimationState extends BaseObject { - static toString(): string; - /** - * @private - */ - actionEnabled: boolean; - /** - * @private - */ - additiveBlending: boolean; - /** - * - Whether the animation state has control over the display object properties of the slots. - * Sometimes blend a animation state does not want it to control the display object properties of the slots, - * especially if other animation state are controlling the display object properties of the slots. - * @default true - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态是否对插槽的显示对象属性有控制权。 - * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, - * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 - * @default true - * @version DragonBones 5.0 - * @language zh_CN - */ - displayControl: boolean; - /** - * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. - * This property should usually be set to false when blend multiple animation states. - * @default true - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 - * 通常在混合多个动画状态时应该将该属性设置为 false。 - * @default true - * @version DragonBones 5.1 - * @language zh_CN - */ - resetToPose: boolean; - /** - * - The play times. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The blend layer. - * High layer animation state will get the blend weight first. - * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合图层。 - * 图层高的动画状态会优先获取混合权重。 - * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - layer: number; - /** - * - The play speed. - * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. - * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度。 - * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 - * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - /** - * - The blend weight. - * @default 1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合权重。 - * @default 1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - weight: number; - /** - * - The auto fade out time when the animation state play completed. - * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态播放完成后的自动淡出时间。 - * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - autoFadeOutTime: number; - /** - * @private - */ - fadeTotalTime: number; - /** - * - The name of the animation state. (Can be different from the name of the animation data) - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态名称。 (可以不同于动画数据) - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - name: string; - /** - * - The blend group name of the animation state. - * This property is typically used to specify the substitution of multiple animation states blend. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合组名称。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - group: string; - private _timelineDirty; - /** - * - xx: Play Enabled, Fade Play Enabled - * @internal - */ - _playheadState: number; - /** - * -1: Fade in, 0: Fade complete, 1: Fade out; - * @internal - */ - _fadeState: number; - /** - * -1: Fade start, 0: Fading, 1: Fade complete; - * @internal - */ - _subFadeState: number; - /** - * @internal - */ - _position: number; - /** - * @internal - */ - _duration: number; - private _fadeTime; - private _time; - /** - * @internal - */ - _fadeProgress: number; - /** - * @internal - */ - _weightResult: number; - /** - * @internal - */ - readonly _blendState: BlendState; - private readonly _boneMask; - private readonly _boneTimelines; - private readonly _surfaceTimelines; - private readonly _slotTimelines; - private readonly _constraintTimelines; - private readonly _animationTimelines; - private readonly _poseTimelines; - private readonly _bonePoses; - /** - * @internal - */ - _animationData: AnimationData; - private _armature; - /** - * @internal - */ - _actionTimeline: ActionTimelineState; - private _zOrderTimeline; - /** - * @internal - */ - _parent: AnimationState; - protected _onClear(): void; - private _updateTimelines(); - private _updateBoneAndSlotTimelines(); - private _advanceFadeTime(passedTime); - /** - * @internal - */ - init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; - /** - * @internal - */ - advanceTime(passedTime: number, cacheFrameRate: number): void; - /** - * - Continue play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 继续播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - play(): void; - /** - * - Stop play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - stop(): void; - /** - * - Fade out the animation state. - * @param fadeOutTime - The fade out time. (In seconds) - * @param pausePlayhead - Whether to pause the animation playing when fade out. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 淡出动画状态。 - * @param fadeOutTime - 淡出时间。 (以秒为单位) - * @param pausePlayhead - 淡出时是否暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; - /** - * - Check if a specific bone mask is included. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - containsBoneMask(boneName: string): boolean; - /** - * - Add a specific bone mask. - * @param boneName - The bone name. - * @param recursive - Whether or not to add a mask to the bone's sub-bone. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加特定的骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - addBoneMask(boneName: string, recursive?: boolean): void; - /** - * - Remove the mask of a specific bone. - * @param boneName - The bone name. - * @param recursive - Whether to remove the bone's sub-bone mask. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除特定骨骼的遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否删除该骨骼的子骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - removeBoneMask(boneName: string, recursive?: boolean): void; - /** - * - Remove all bone masks. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除所有骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - removeAllBoneMask(): void; - /** - * - Whether the animation state is fading in. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡入。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeIn: boolean; - /** - * - Whether the animation state is fading out. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡出。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeOut: boolean; - /** - * - Whether the animation state is fade completed. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否淡入或淡出完毕。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeComplete: boolean; - /** - * - Whether the animation state is playing. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否正在播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isPlaying: boolean; - /** - * - Whether the animation state is play completed. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否播放完毕。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isCompleted: boolean; - /** - * - The times has been played. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 已经循环播放的次数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly currentPlayTimes: number; - /** - * - The total time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 总播放时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly totalTime: number; - /** - * - The time is currently playing. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前播放的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - currentTime: number; - /** - * - The animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animationData: AnimationData; - } - /** - * @internal - */ - class BonePose extends BaseObject { - static toString(): string; - readonly current: Transform; - readonly delta: Transform; - readonly result: Transform; - protected _onClear(): void; - } - /** - * @internal - */ - class BlendState { - dirty: boolean; - layer: number; - leftWeight: number; - layerWeight: number; - blendWeight: number; - /** - * -1: First blending, 0: No blending, 1: Blending. - */ - update(weight: number, p_layer: number): number; - clear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - const enum TweenState { - None = 0, - Once = 1, - Always = 2, - } - /** - * @internal - */ - abstract class TimelineState extends BaseObject { - /** - * -1: start, 0: play, 1: complete; - */ - playState: number; - currentPlayTimes: number; - currentTime: number; - protected _tweenState: TweenState; - protected _frameRate: number; - protected _frameValueOffset: number; - protected _frameCount: number; - protected _frameOffset: number; - protected _frameIndex: number; - protected _frameRateR: number; - protected _position: number; - protected _duration: number; - protected _timeScale: number; - protected _timeOffset: number; - protected _dragonBonesData: DragonBonesData; - protected _animationData: AnimationData; - protected _timelineData: TimelineData | null; - protected _armature: Armature; - protected _animationState: AnimationState; - protected _actionTimeline: TimelineState; - protected _frameArray: Array | Int16Array; - protected _frameIntArray: Array | Int16Array; - protected _frameFloatArray: Array | Int16Array; - protected _timelineArray: Array | Uint16Array; - protected _frameIndices: Array; - protected _onClear(): void; - protected abstract _onArriveAtFrame(): void; - protected abstract _onUpdateFrame(): void; - protected _setCurrentTime(passedTime: number): boolean; - init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; - fadeOut(): void; - update(passedTime: number): void; - } - /** - * @internal - */ - abstract class TweenTimelineState extends TimelineState { - private static _getEasingValue(tweenType, progress, easing); - private static _getEasingCurveValue(progress, samples, count, offset); - protected _tweenType: TweenType; - protected _curveCount: number; - protected _framePosition: number; - protected _frameDurationR: number; - protected _tweenProgress: number; - protected _tweenEasing: number; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - } - /** - * @internal - */ - abstract class BoneTimelineState extends TweenTimelineState { - bone: Bone; - bonePose: BonePose; - protected _onClear(): void; - blend(state: number): void; - } - /** - * @internal - */ - abstract class SlotTimelineState extends TweenTimelineState { - slot: Slot; - protected _onClear(): void; - } - /** - * @internal - */ - abstract class ConstraintTimelineState extends TweenTimelineState { - constraint: Constraint; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class ActionTimelineState extends TimelineState { - static toString(): string; - private _onCrossFrame(frameIndex); - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - update(passedTime: number): void; - setCurrentTime(value: number): void; - } - /** - * @internal - */ - class ZOrderTimelineState extends TimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - } - /** - * @internal - */ - class BoneAllTimelineState extends BoneTimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - fadeOut(): void; - } - /** - * @internal - */ - class BoneTranslateTimelineState extends BoneTimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - } - /** - * @internal - */ - class BoneRotateTimelineState extends BoneTimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - fadeOut(): void; - } - /** - * @internal - */ - class BoneScaleTimelineState extends BoneTimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - } - /** - * @internal - */ - class SurfaceTimelineState extends TweenTimelineState { - static toString(): string; - surface: Surface; - private _frameFloatOffset; - private _valueCount; - private _deformCount; - private _valueOffset; - private readonly _current; - private readonly _delta; - private readonly _result; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; - blend(state: number): void; - } - /** - * @internal - */ - class SlotDislayTimelineState extends SlotTimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - } - /** - * @internal - */ - class SlotColorTimelineState extends SlotTimelineState { - static toString(): string; - private _dirty; - private readonly _current; - private readonly _delta; - private readonly _result; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - fadeOut(): void; - update(passedTime: number): void; - } - /** - * @internal - */ - class DeformTimelineState extends SlotTimelineState { - static toString(): string; - vertexOffset: number; - private _dirty; - private _frameFloatOffset; - private _valueCount; - private _deformCount; - private _valueOffset; - private readonly _current; - private readonly _delta; - private readonly _result; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; - fadeOut(): void; - update(passedTime: number): void; - } - /** - * @internal - */ - class IKConstraintTimelineState extends ConstraintTimelineState { - static toString(): string; - private _current; - private _delta; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - } - /** - * @internal - */ - class AnimationTimelineState extends TweenTimelineState { - static toString(): string; - animationState: AnimationState; - private readonly _floats; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - blend(state: number): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The properties of the object carry basic information about an event, - * which are passed as parameter or parameter's parameter to event listeners when an event occurs. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 - * @version DragonBones 4.5 - * @language zh_CN - */ - class EventObject extends BaseObject { - /** - * - Animation start play. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画开始播放。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly START: string; - /** - * - Animation loop play complete once. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画循环播放完成一次。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly LOOP_COMPLETE: string; - /** - * - Animation play complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画播放完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly COMPLETE: string; - /** - * - Animation fade in start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_IN: string; - /** - * - Animation fade in complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_IN_COMPLETE: string; - /** - * - Animation fade out start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_OUT: string; - /** - * - Animation fade out complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_OUT_COMPLETE: string; - /** - * - Animation frame event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FRAME_EVENT: string; - /** - * - Animation frame sound event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧声音事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly SOUND_EVENT: string; - /** - * @internal - * @private - */ - static actionDataToInstance(data: ActionData, instance: EventObject, armature: Armature): void; - static toString(): string; - /** - * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) - * @version DragonBones 4.5 - * @language zh_CN - */ - time: number; - /** - * - The event type。 - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件类型。 - * @version DragonBones 4.5 - * @language zh_CN - */ - type: EventStringType; - /** - * - The event name. (The frame event name or the frame sound name) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件名称。 (帧事件的名称或帧声音的名称) - * @version DragonBones 4.5 - * @language zh_CN - */ - name: string; - /** - * - The armature that dispatch the event. - * @see dragonBones.Armature - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的骨架。 - * @see dragonBones.Armature - * @version DragonBones 4.5 - * @language zh_CN - */ - armature: Armature; - /** - * - The bone that dispatch the event. - * @see dragonBones.Bone - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 4.5 - * @language zh_CN - */ - bone: Bone | null; - /** - * - The slot that dispatch the event. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - slot: Slot | null; - /** - * - The animation state that dispatch the event. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - animationState: AnimationState; - /** - * @private - */ - actionData: ActionData | null; - /** - * @private - */ - /** - * - The custom data. - * @see dragonBones.CustomData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义数据。 - * @see dragonBones.CustomData - * @version DragonBones 5.0 - * @language zh_CN - */ - data: UserData | null; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @private - */ - type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; - /** - * - The event dispatcher interface. - * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件派发接口。 - * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 - * @version DragonBones 4.5 - * @language zh_CN - */ - interface IEventDispatcher { - /** - * - Checks whether the object has any listeners registered for a specific type of event。 - * @param type - Event type. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 检查是否为特定的事件类型注册了任何侦听器。 - * @param type - 事件类型。 - * @version DragonBones 4.5 - * @language zh_CN - */ - hasDBEventListener(type: EventStringType): boolean; - /** - * - Dispatches an event into the event flow. - * @param type - Event type. - * @param eventObject - Event object. - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 分派特定的事件到事件流中。 - * @param type - 事件类型。 - * @param eventObject - 事件数据。 - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language zh_CN - */ - dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; - /** - * - Add an event listener object so that the listener receives notification of an event. - * @param type - Event type. - * @param listener - Event listener. - * @param thisObject - The listener function's "this". - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 - * @param type - 事件类型。 - * @param listener - 事件侦听器。 - * @param thisObject - 侦听函数绑定的 this 对象。 - * @version DragonBones 4.5 - * @language zh_CN - */ - addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; - /** - * - Removes a listener from the object. - * @param type - Event type. - * @param listener - Event listener. - * @param thisObject - The listener function's "this". - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 删除特定事件类型的侦听器。 - * @param type - 事件类型。 - * @param listener - 事件侦听器。 - * @param thisObject - 侦听函数绑定的 this 对象。 - * @version DragonBones 4.5 - * @language zh_CN - */ - removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; - /** - * - Deprecated, please refer to {@link #hasDBEventListener()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #hasDBEventListener()}。 - * @deprecated - * @language zh_CN - */ - hasEvent(type: EventStringType): boolean; - /** - * - Deprecated, please refer to {@link #addDBEventListener()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #addDBEventListener()}。 - * @deprecated - * @language zh_CN - */ - addEvent(type: EventStringType, listener: Function, thisObject: any): void; - /** - * - Deprecated, please refer to {@link #removeDBEventListener()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #removeDBEventListener()}。 - * @deprecated - * @language zh_CN - */ - removeEvent(type: EventStringType, listener: Function, thisObject: any): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - abstract class DataParser { - protected static readonly DATA_VERSION_2_3: string; - protected static readonly DATA_VERSION_3_0: string; - protected static readonly DATA_VERSION_4_0: string; - protected static readonly DATA_VERSION_4_5: string; - protected static readonly DATA_VERSION_5_0: string; - protected static readonly DATA_VERSION_5_5: string; - protected static readonly DATA_VERSION: string; - protected static readonly DATA_VERSIONS: Array; - protected static readonly TEXTURE_ATLAS: string; - protected static readonly SUB_TEXTURE: string; - protected static readonly FORMAT: string; - protected static readonly IMAGE_PATH: string; - protected static readonly WIDTH: string; - protected static readonly HEIGHT: string; - protected static readonly ROTATED: string; - protected static readonly FRAME_X: string; - protected static readonly FRAME_Y: string; - protected static readonly FRAME_WIDTH: string; - protected static readonly FRAME_HEIGHT: string; - protected static readonly DRADON_BONES: string; - protected static readonly USER_DATA: string; - protected static readonly ARMATURE: string; - protected static readonly BONE: string; - protected static readonly SURFACE: string; - protected static readonly SLOT: string; - protected static readonly CONSTRAINT: string; - protected static readonly IK: string; - protected static readonly PATH_CONSTRAINT: string; - protected static readonly SKIN: string; - protected static readonly DISPLAY: string; - protected static readonly ANIMATION: string; - protected static readonly Z_ORDER: string; - protected static readonly FFD: string; - protected static readonly FRAME: string; - protected static readonly TRANSLATE_FRAME: string; - protected static readonly ROTATE_FRAME: string; - protected static readonly SCALE_FRAME: string; - protected static readonly DISPLAY_FRAME: string; - protected static readonly COLOR_FRAME: string; - protected static readonly DEFAULT_ACTIONS: string; - protected static readonly ACTIONS: string; - protected static readonly EVENTS: string; - protected static readonly INTS: string; - protected static readonly FLOATS: string; - protected static readonly STRINGS: string; - protected static readonly CANVAS: string; - protected static readonly TRANSFORM: string; - protected static readonly PIVOT: string; - protected static readonly AABB: string; - protected static readonly COLOR: string; - protected static readonly VERSION: string; - protected static readonly COMPATIBLE_VERSION: string; - protected static readonly FRAME_RATE: string; - protected static readonly TYPE: string; - protected static readonly SUB_TYPE: string; - protected static readonly NAME: string; - protected static readonly PARENT: string; - protected static readonly TARGET: string; - protected static readonly STAGE: string; - protected static readonly SHARE: string; - protected static readonly PATH: string; - protected static readonly LENGTH: string; - protected static readonly DISPLAY_INDEX: string; - protected static readonly BLEND_MODE: string; - protected static readonly INHERIT_TRANSLATION: string; - protected static readonly INHERIT_ROTATION: string; - protected static readonly INHERIT_SCALE: string; - protected static readonly INHERIT_REFLECTION: string; - protected static readonly INHERIT_ANIMATION: string; - protected static readonly INHERIT_DEFORM: string; - protected static readonly SEGMENT_X: string; - protected static readonly SEGMENT_Y: string; - protected static readonly BEND_POSITIVE: string; - protected static readonly CHAIN: string; - protected static readonly WEIGHT: string; - protected static readonly FADE_IN_TIME: string; - protected static readonly PLAY_TIMES: string; - protected static readonly SCALE: string; - protected static readonly OFFSET: string; - protected static readonly POSITION: string; - protected static readonly DURATION: string; - protected static readonly TWEEN_EASING: string; - protected static readonly TWEEN_ROTATE: string; - protected static readonly TWEEN_SCALE: string; - protected static readonly CLOCK_WISE: string; - protected static readonly CURVE: string; - protected static readonly SOUND: string; - protected static readonly EVENT: string; - protected static readonly ACTION: string; - protected static readonly X: string; - protected static readonly Y: string; - protected static readonly SKEW_X: string; - protected static readonly SKEW_Y: string; - protected static readonly SCALE_X: string; - protected static readonly SCALE_Y: string; - protected static readonly VALUE: string; - protected static readonly ROTATE: string; - protected static readonly SKEW: string; - protected static readonly ALPHA_OFFSET: string; - protected static readonly RED_OFFSET: string; - protected static readonly GREEN_OFFSET: string; - protected static readonly BLUE_OFFSET: string; - protected static readonly ALPHA_MULTIPLIER: string; - protected static readonly RED_MULTIPLIER: string; - protected static readonly GREEN_MULTIPLIER: string; - protected static readonly BLUE_MULTIPLIER: string; - protected static readonly UVS: string; - protected static readonly VERTICES: string; - protected static readonly TRIANGLES: string; - protected static readonly WEIGHTS: string; - protected static readonly SLOT_POSE: string; - protected static readonly BONE_POSE: string; - protected static readonly GLUE_WEIGHTS: string; - protected static readonly GLUE_MESHES: string; - protected static readonly BONES: string; - protected static readonly POSITION_MODE: string; - protected static readonly SPACING_MODE: string; - protected static readonly ROTATE_MODE: string; - protected static readonly SPACING: string; - protected static readonly ROTATE_OFFSET: string; - protected static readonly ROTATE_MIX: string; - protected static readonly TRANSLATE_MIX: string; - protected static readonly TARGET_DISPLAY: string; - protected static readonly CLOSED: string; - protected static readonly CONSTANT_SPEED: string; - protected static readonly VERTEX_COUNT: string; - protected static readonly LENGTHS: string; - protected static readonly GOTO_AND_PLAY: string; - protected static readonly DEFAULT_NAME: string; - protected static _getArmatureType(value: string): ArmatureType; - protected static _getBoneType(value: string): BoneType; - protected static _getDisplayType(value: string): DisplayType; - protected static _getBoundingBoxType(value: string): BoundingBoxType; - protected static _getActionType(value: string): ActionType; - protected static _getBlendMode(value: string): BlendMode; - protected static _getPositionMode(value: string): PositionMode; - protected static _getSpacingMode(value: string): SpacingMode; - protected static _getRotateMode(value: string): RotateMode; - abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; - abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - static parseDragonBonesData(rawData: any): DragonBonesData | null; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - static parseTextureAtlasData(rawData: any, scale?: number): any; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class ObjectDataParser extends DataParser { - protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; - protected static _getNumber(rawData: any, key: string, defaultValue: number): number; - protected static _getString(rawData: any, key: string, defaultValue: string): string; - protected _rawTextureAtlasIndex: number; - protected readonly _rawBones: Array; - protected _data: DragonBonesData; - protected _armature: ArmatureData; - protected _bone: BoneData; - protected _surface: SurfaceData; - protected _slot: SlotData; - protected _skin: SkinData; - protected _mesh: MeshDisplayData; - protected _animation: AnimationData; - protected _timeline: TimelineData; - protected _rawTextureAtlases: Array | null; - private _defaultColorOffset; - private _prevClockwise; - private _prevRotation; - private readonly _helpMatrixA; - private readonly _helpMatrixB; - private readonly _helpTransform; - private readonly _helpColorTransform; - private readonly _helpPoint; - private readonly _helpArray; - private readonly _intArray; - private readonly _floatArray; - private readonly _frameIntArray; - private readonly _frameFloatArray; - private readonly _frameArray; - private readonly _timelineArray; - private readonly _cacheRawMeshes; - private readonly _cacheMeshes; - private readonly _actionFrames; - private readonly _weightSlotPose; - private readonly _weightBonePoses; - private readonly _cacheBones; - private readonly _slotChildActions; - private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); - private _samplingEasingCurve(curve, samples); - private _parseActionDataInFrame(rawData, frameStart, bone, slot); - private _mergeActionFrame(rawData, frameStart, type, bone, slot); - protected _parseArmature(rawData: any, scale: number): ArmatureData; - protected _parseBone(rawData: any): BoneData; - protected _parseIKConstraint(rawData: any): ConstraintData | null; - protected _parsePathConstraint(rawData: any): ConstraintData | null; - protected _parseSlot(rawData: any, zOrder: number): SlotData; - protected _parseSkin(rawData: any): SkinData; - protected _parseDisplay(rawData: any): DisplayData | null; - protected _parsePath(rawData: any, display: PathDisplayData): void; - protected _parsePivot(rawData: any, display: ImageDisplayData): void; - protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; - protected _parseMeshGlue(rawData: any, mesh: MeshDisplayData): void; - protected _parseBoundingBox(rawData: any): BoundingBoxData | null; - protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; - protected _parseAnimation(rawData: any): AnimationData; - protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; - protected _parseBoneTimeline(rawData: any): void; - protected _parseSlotTimeline(rawData: any): void; - protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; - protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSurfaceFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; - protected _parseTransform(rawData: any, transform: Transform, scale: number): void; - protected _parseColorTransform(rawData: any, color: ColorTransform): void; - protected _parseArray(rawData: any): void; - protected _modifyArray(): void; - parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; - parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; - private static _objectDataParserInstance; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - static getInstance(): ObjectDataParser; - } - /** - * @internal - */ - class ActionFrame { - frameStart: number; - readonly actions: Array; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class BinaryDataParser extends ObjectDataParser { - private _binaryOffset; - private _binary; - private _intArrayBuffer; - private _floatArrayBuffer; - private _frameIntArrayBuffer; - private _frameFloatArrayBuffer; - private _frameArrayBuffer; - private _timelineArrayBuffer; - private _inRange(a, min, max); - private _decodeUTF8(data); - private _getUTF16Key(value); - private _parseBinaryTimeline(type, offset, timelineData?); - private _parseVertices(rawData, vertices); - protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; - protected _parsePath(rawData: any, path: PathDisplayData): void; - protected _parseAnimation(rawData: any): AnimationData; - protected _parseArray(rawData: any): void; - parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; - private static _binaryDataParserInstance; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - static getInstance(): BinaryDataParser; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) - * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. - * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) - * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 - * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class BaseFactory { - protected static _objectParser: ObjectDataParser; - protected static _binaryParser: BinaryDataParser; - /** - * @private - */ - autoSearch: boolean; - protected readonly _dragonBonesDataMap: Map; - protected readonly _textureAtlasDataMap: Map>; - protected _dragonBones: DragonBones; - protected _dataParser: DataParser; - /** - * - Create a factory instance. (typically only one global factory instance is required) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) - * @version DragonBones 3.0 - * @language zh_CN - */ - constructor(dataParser?: DataParser | null); - protected _isSupportMesh(): boolean; - protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; - protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; - protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; - /** - * @private - */ - protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; - protected _buildConstraints(dataPackage: BuildArmaturePackage, armature: Armature): void; - protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: DisplayData): Armature | null; - protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; - protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; - protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; - protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; - /** - * - Parse the raw data to a DragonBonesData instance and cache it to the factory. - * @param rawData - The raw data. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for all armatures. (Default: 1.0) - * @returns DragonBonesData instance - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 - * @param rawData - 原始数据。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) - * @returns DragonBonesData 实例 - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language zh_CN - */ - parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; - /** - * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. - * @param rawData - The raw texture atlas data. - * @param textureAtlas - The texture atlas object. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for the map set. (Default: 1.0) - * @returns TextureAtlasData instance - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 - * @param rawData - 原始贴图集数据。 - * @param textureAtlas - 贴图集对象。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) - * @returns TextureAtlasData 实例 - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language zh_CN - */ - parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; - /** - * @private - */ - updateTextureAtlasData(name: string, textureAtlases: Array): void; - /** - * - Get a specific DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @returns DragonBonesData instance - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 DragonBonesData 实例。 - * @param name - DragonBonesData 实例的缓存名称。 - * @returns DragonBonesData 实例 - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - getDragonBonesData(name: string): DragonBonesData | null; - /** - * - Cache a DragonBonesData instance to the factory. - * @param data - The DragonBonesData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 DragonBonesData 实例缓存到工厂中。 - * @param data - DragonBonesData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - addDragonBonesData(data: DragonBonesData, name?: string | null): void; - /** - * - Remove a DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @param disposeData - Whether to dispose data. (Default: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 DragonBonesData 实例。 - * @param name - DragonBonesData 实例缓存名称。 - * @param disposeData - 是否释放数据。 (默认: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - removeDragonBonesData(name: string, disposeData?: boolean): void; - /** - * - Get a list of specific TextureAtlasData instances. - * @param name - The TextureAtlasData cahce name. - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 TextureAtlasData 实例列表。 - * @param name - TextureAtlasData 实例缓存名称。 - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - getTextureAtlasData(name: string): Array | null; - /** - * - Cache a TextureAtlasData instance to the factory. - * @param data - The TextureAtlasData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 TextureAtlasData 实例缓存到工厂中。 - * @param data - TextureAtlasData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; - /** - * - Remove a TextureAtlasData instance. - * @param name - The TextureAtlasData instance cache name. - * @param disposeData - Whether to dispose data. - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 TextureAtlasData 实例。 - * @param name - TextureAtlasData 实例的缓存名称。 - * @param disposeData - 是否释放数据。 - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - removeTextureAtlasData(name: string, disposeData?: boolean): void; - /** - * - Get a specific armature data. - * @param name - The armature data name. - * @param dragonBonesName - The cached name for DragonbonesData instance. - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param name - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language zh_CN - */ - getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; - /** - * - Clear all cached DragonBonesData instances and TextureAtlasData instances. - * @param disposeData - Whether to dispose data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 - * @param disposeData - 是否释放数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - clear(disposeData?: boolean): void; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. - * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature. - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 - * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架。 - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; - /** - * @private - */ - replaceDisplay(slot: Slot, displayData: DisplayData, displayIndex?: number): void; - /** - * - Replaces the current display data for a particular slot with a specific display data. - * Specify display data with "dragonBonesName/armatureName/slotName/displayName". - * @param dragonBonesName - The DragonBonesData instance cache name. - * @param armatureName - The armature data name. - * @param slotName - The slot data name. - * @param displayName - The display data name. - * @param slot - The slot. - * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 - * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @param armatureName - 骨架数据名称。 - * @param slotName - 插槽数据名称。 - * @param displayName - 显示对象数据名称。 - * @param slot - 插槽。 - * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; - /** - * @private - */ - replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; - /** - * - Share specific skin data with specific armature. - * @param armature - The armature. - * @param skin - The skin data. - * @param isOverride - Whether it completely override the original skin. (Default: false) - * @param exclude - A list of slot names that do not need to be replace. - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 将特定的皮肤数据共享给特定的骨架使用。 - * @param armature - 骨架。 - * @param skin - 皮肤数据。 - * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) - * @param exclude - 不需要被替换的插槽名称列表。 - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language zh_CN - */ - replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; - /** - * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. - * This enables you to make a armature template so that other armature without animations can share it's animations. - * @param armature - The armtaure. - * @param armatureData - The armature data. - * @param isOverride - Whether to completely overwrite the original animation. (Default: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 - * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 - * @param armature - 骨架。 - * @param armatureData - 骨架数据。 - * @param isOverride - 是否完全覆盖原来的动画。(默认: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language zh_CN - */ - replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; - /** - * @private - */ - getAllDragonBonesData(): Map; - /** - * @private - */ - getAllTextureAtlasData(): Map>; - /** - * - An Worldclock instance updated by engine. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 由引擎驱动的 WorldClock 实例。 - * @version DragonBones 5.7 - * @language zh_CN - */ - readonly clock: WorldClock; - /** - * @private - */ - readonly dragonBones: DragonBones; - /** - * - Deprecated, please refer to {@link #replaceSkin}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #replaceSkin}。 - * @deprecated - * @language zh_CN - */ - changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): boolean; - /** - * - Deprecated, please refer to {@link #replaceAnimation}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #replaceAnimation}。 - * @deprecated - * @language zh_CN - */ - copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, replaceOriginalAnimation?: boolean): boolean; - } - /** - * @internal - */ - class BuildArmaturePackage { - dataName: string; - textureAtlasName: string; - data: DragonBonesData; - armature: ArmatureData; - skin: SkinData | null; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The egret texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class EgretTextureAtlasData extends TextureAtlasData { - static toString(): string; - /** - * @internal - */ - disposeEnabled: boolean; - private _renderTexture; - protected _onClear(): void; - /** - * @inheritDoc - */ - createTexture(): TextureData; - /** - * - The Egret texture. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 贴图。 - * @version DragonBones 3.0 - * @language zh_CN - */ - renderTexture: egret.Texture | null; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#removeTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#removeTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - dispose(): void; - /** - * - Deprecated, please refer to {@link #renderTexture}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #renderTexture}。 - * @deprecated - * @language zh_CN - */ - readonly texture: egret.Texture | null; - } - /** - * @internal - */ - class EgretTextureData extends TextureData { - static toString(): string; - renderTexture: egret.Texture | null; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The egret event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - Egret 事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - class EgretEvent extends egret.Event { - /** - * - The event object. - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象。 - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly eventObject: EventObject; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - readonly animationName: string; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#armature}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#armature}。 - * @deprecated - * @language zh_CN - */ - readonly armature: Armature; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#bone}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#bone}。 - * @deprecated - * @language zh_CN - */ - readonly bone: Bone | null; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#slot}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#slot}。 - * @deprecated - * @language zh_CN - */ - readonly slot: Slot | null; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - readonly animationState: AnimationState | null; - /** - * Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#name}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#name}。 - * @deprecated - * @language zh_CN - */ - readonly frameLabel: string; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#name}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#name}。 - * @deprecated - * @language zh_CN - */ - readonly sound: string; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - readonly movementID: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.START}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.START}。 - * @deprecated - * @language zh_CN - */ - static START: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.LOOP_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.LOOP_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - static LOOP_COMPLETE: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.COMPLETE}。 - * @deprecated - * @language zh_CN - */ - static COMPLETE: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_IN}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_IN}。 - * @deprecated - * @language zh_CN - */ - static FADE_IN: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_IN_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_IN_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - static FADE_IN_COMPLETE: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_OUT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_OUT}。 - * @deprecated - * @language zh_CN - */ - static FADE_OUT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_OUT_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_OUT_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - static FADE_OUT_COMPLETE: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - static FRAME_EVENT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.SOUND_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.SOUND_EVENT}。 - * @deprecated - * @language zh_CN - */ - static SOUND_EVENT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - static ANIMATION_FRAME_EVENT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - static BONE_FRAME_EVENT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - static MOVEMENT_FRAME_EVENT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.SOUND_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.SOUND_EVENT}。 - * @deprecated - * @language zh_CN - */ - static SOUND: string; - } - /** - * @inheritDoc - */ - class EgretArmatureDisplay extends egret.DisplayObjectContainer implements IArmatureProxy { - private static _cleanBeforeRender(); - /** - * @private - */ - debugDraw: boolean; - /** - * @internal - */ - _batchEnabled: boolean; - /** - * @internal - */ - _childDirty: boolean; - private _debugDraw; - private _armature; - private _bounds; - private _debugDrawer; - /** - * @inheritDoc - */ - dbInit(armature: Armature): void; - /** - * @inheritDoc - */ - dbClear(): void; - /** - * @inheritDoc - */ - dbUpdate(): void; - /** - * @inheritDoc - */ - dispose(disposeProxy?: boolean): void; - /** - * @inheritDoc - */ - dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; - /** - * @inheritDoc - */ - hasDBEventListener(type: EventStringType): boolean; - /** - * @inheritDoc - */ - addDBEventListener(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; - /** - * @inheritDoc - */ - removeDBEventListener(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; - /** - * - Disable the batch. - * Batch rendering for performance reasons, the boundary properties of the render object are not updated. - * This will not correctly obtain the wide-height properties of the rendered object and the transformation properties of its internal display objects, - * which can turn off batch rendering if you need to use these properties. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 关闭批次渲染。 - * 批次渲染出于性能考虑,不会更新渲染对象的边界属性。 - * 这样将无法正确获得渲染对象的宽高属性以及其内部显示对象的变换属性,如果需要使用这些属性,可以关闭批次渲染。 - * @version DragonBones 5.1 - * @language zh_CN - */ - disableBatch(): void; - /** - * @inheritDoc - */ - readonly armature: Armature; - /** - * @inheritDoc - */ - readonly animation: Animation; - /** - * @inheritDoc - */ - $measureContentBounds(bounds: egret.Rectangle): void; - /** - * @inheritDoc - */ - hasEvent(type: EventStringType): boolean; - /** - * @inheritDoc - */ - addEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; - /** - * @inheritDoc - */ - removeEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#clock} {@link dragonBones.BaseFactory#clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#clock} {@link dragonBones.BaseFactory#clock}。 - * @deprecated - * @language zh_CN - */ - advanceTimeBySelf(on: boolean): void; - } - /** - * 已废弃,请参考 {@link dragonBones.Armature}。 - * @deprecated - * @language zh_CN - */ - type FastArmature = Armature; - /** - * 已废弃,请参考 {@link dragonBones.Bone}。 - * @deprecated - * @language zh_CN - */ - type FastBone = Bone; - /** - * 已废弃,请参考 {@link dragonBones.Slot}。 - * @deprecated - * @language zh_CN - */ - type FastSlot = Slot; - /** - * 已废弃,请参考 {@link dragonBones.Animation}。 - * @deprecated - * @language zh_CN - */ - type FastAnimation = Animation; - /** - * 已废弃,请参考 {@link dragonBones.AnimationState}。 - * @deprecated - * @language zh_CN - */ - type FastAnimationState = AnimationState; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - class Event extends EgretEvent { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - class ArmatureEvent extends EgretEvent { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - class AnimationEvent extends EgretEvent { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - class FrameEvent extends EgretEvent { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - class SoundEvent extends EgretEvent { - } - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - class EgretTextureAtlas extends EgretTextureAtlasData { - static toString(): string; - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - constructor(texture: egret.Texture, rawData: any, scale?: number); - } - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - class EgretSheetAtlas extends EgretTextureAtlas { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretFactory#soundEventManager}。 - * @deprecated - * @language zh_CN - */ - class SoundEventManager { - /** - * 已废弃,请参考 {@link dragonBones.EgretFactory#soundEventManager}。 - * @deprecated - * @language zh_CN - */ - static getInstance(): EgretArmatureDisplay; - } - /** - * 已废弃,请参考 {@link dragonBones.Armature#cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - class AnimationCacheManager { - /** - * 已废弃,请参考 {@link dragonBones.Armature#cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - constructor(); - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The egret slot. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 插槽。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class EgretSlot extends Slot { - static toString(): string; - /** - * - Whether to update the transform properties of the display object. - * For better performance, the transform properties of display object (x, y, rotation, ScaleX, ScaleX) are not updated and need to be set to true if these properties need to be accessed correctly. - * @default false - * @version DragonBones 3.0 - * @language zh_CN - */ - /** - * - 是否更新显示对象的变换属性。 - * 为了更好的性能, 默认并不会更新显示对象的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 - * @default false - * @version DragonBones 3.0 - * @language zh_CN - */ - transformUpdateEnabled: boolean; - private _armatureDisplay; - private _renderDisplay; - private _colorFilter; - /** - * @inheritDoc - */ - init(slotData: SlotData, armatureValue: Armature, rawDisplay: any, meshDisplay: any): void; - protected _onClear(): void; - protected _initDisplay(value: any, isRetain: boolean): void; - protected _disposeDisplay(value: any, isRelease: boolean): void; - protected _onUpdateDisplay(): void; - protected _addDisplay(): void; - protected _replaceDisplay(value: any): void; - protected _removeDisplay(): void; - protected _updateZOrder(): void; - /** - * @internal - */ - _updateVisible(): void; - protected _updateBlendMode(): void; - protected _updateColor(): void; - protected _updateFrame(): void; - protected _updateMesh(): void; - /** - * @internal - */ - _updateGlueMesh(): void; - protected _updateTransform(): void; - protected _identityTransform(): void; - private _updateTransformV4(); - private _updateTransformV5(); - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - const isV5: boolean; - /** - * - The Egret factory. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 工厂。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class EgretFactory extends BaseFactory { - private static _time; - private static _dragonBonesInstance; - private static _factory; - private static _clockHandler(time); - /** - * - A global factory instance that can be used directly. - * @version DragonBones 4.7 - * @language en_US - */ - /** - * - 一个可以直接使用的全局工厂实例。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static readonly factory: EgretFactory; - /** - * @inheritDoc - */ - constructor(dataParser?: DataParser | null); - protected _isSupportMesh(): boolean; - protected _buildTextureAtlasData(textureAtlasData: EgretTextureAtlasData | null, textureAtlas: egret.Texture | HTMLImageElement | null): EgretTextureAtlasData; - protected _buildArmature(dataPackage: BuildArmaturePackage): Armature; - protected _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. - * Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. - * The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature display container. - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - *
-         *     let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
-         * 
- * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架,并用 {@link #clock} 更新该骨架。 - * 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 - * 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架的显示容器。 - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - *
-         *     let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
-         * 
- * @language zh_CN - */ - buildArmatureDisplay(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): EgretArmatureDisplay | null; - /** - * - Create the display object with the specified texture. - * @param textureName - The texture data name. - * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建带有指定贴图的显示对象。 - * @param textureName - 贴图数据名称。 - * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) - * @version DragonBones 3.0 - * @language zh_CN - */ - getTextureDisplay(textureName: string, textureAtlasName?: string | null): egret.Bitmap | null; - /** - * - A global sound event manager. - * Sound events can be listened to uniformly from the manager. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 全局声音事件管理器。 - * 声音事件可以从该管理器统一侦听。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly soundEventManager: EgretArmatureDisplay; - /** - * - Deprecated, please refer to {@link #clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #clock}。 - * @deprecated - * @language zh_CN - */ - static readonly clock: WorldClock; - /** - * - Deprecated, please refer to {@link #addDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #addDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - addSkeletonData(dragonBonesData: DragonBonesData, dragonBonesName?: string | null): void; - /** - * - Deprecated, please refer to {@link #getDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #getDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - getSkeletonData(dragonBonesName: string): DragonBonesData | null; - /** - * - Deprecated, please refer to {@link #removeDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #removeDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - removeSkeletonData(dragonBonesName: string): void; - /** - * - Deprecated, please refer to {@link #addTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #addTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - addTextureAtlas(textureAtlasData: TextureAtlasData, dragonBonesName?: string | null): void; - /** - * - Deprecated, please refer to {@link #getTextureAtlas()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #getTextureAtlas()}。 - * @deprecated - * @language zh_CN - */ - getTextureAtlas(dragonBonesName: string): TextureAtlasData[] | null; - /** - * - Deprecated, please refer to {@link #removeTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #removeTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - removeTextureAtlas(dragonBonesName: string): void; - /** - * - Deprecated, please refer to {@link #buildArmature()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #buildArmature()}。 - * @deprecated - * @language zh_CN - */ - buildFastArmature(armatureName: string, dragonBonesName?: string, skinName?: string): FastArmature | null; - /** - * - Deprecated, please refer to {@link #clear()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #clear()}。 - * @deprecated - * @language zh_CN - */ - dispose(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare const _super: any; -declare namespace dragonBones { - /** - * 是否包含指定名称的动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function hasMovieGroup(groupName: string): boolean; - /** - * 添加动画组。 - * @param groupData 动画二进制数据。 - * @param textureAtlas 贴图集或贴图集列表。 - * @param groupName 为动画组指定一个名称,如果未设置,则使用数据中的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function addMovieGroup(groupData: ArrayBuffer, textureAtlas: egret.Texture | egret.Texture[], groupName?: string | null): void; - /** - * 移除动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function removeMovieGroup(groupName: string): void; - /** - * 移除所有的动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function removeAllMovieGroup(): void; - /** - * 创建一个动画。 - * @param movieName 动画的名称。 - * @param groupName 动画组的名称,如果未设置,将检索所有的动画组,当多个动画组中包含同名的动画时,可能无法创建出准确的动画。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function buildMovie(movieName: string, groupName?: string | null): Movie | null; - /** - * 获取指定动画组内包含的所有动画名称。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function getMovieNames(groupName: string): string[] | null; - /** - * 动画事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - class MovieEvent extends egret.Event { - /** - * 动画剪辑开始播放。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static START: string; - /** - * 动画剪辑循环播放一次完成。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static LOOP_COMPLETE: string; - /** - * 动画剪辑播放完成。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static COMPLETE: string; - /** - * 动画剪辑帧事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static FRAME_EVENT: string; - /** - * 动画剪辑声音事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static SOUND_EVENT: string; - /** - * 事件名称。 (帧标签的名称或声音的名称) - * @version DragonBones 4.7 - * @language zh_CN - */ - name: string; - /** - * 发出事件的插槽名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - slotName: string; - /** - * 发出事件的动画剪辑名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - clipName: string; - /** - * 发出事件的动画。 - * @version DragonBones 4.7 - * @language zh_CN - */ - movie: Movie; - /** - * @private - */ - constructor(type: string); - /** - * @private - */ - readonly armature: any; - /** - * @private - */ - readonly bone: any; - /** - * @private - */ - readonly animationState: any; - /** - * @private - */ - readonly frameLabel: any; - /** - * @private - */ - readonly movementID: any; - } - /** - * 通过读取缓存的二进制动画数据来更新动画,具有良好的运行性能,同时对内存的占用也非常低。 - * @see dragonBones.buildMovie - * @version DragonBones 4.7 - * @language zh_CN - */ - class Movie extends egret.DisplayObjectContainer implements IAnimatable { - private static _cleanBeforeRender(); - /** - * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1 - * @version DragonBones 4.7 - * @language zh_CN - */ - timeScale: number; - /** - * 动画剪辑的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * (当再次播放其他动画剪辑时,此值将被重置为 1) - * @default 1 - * @version DragonBones 4.7 - * @language zh_CN - */ - clipTimeScale: number; - private _batchEnabled; - private _isLockDispose; - private _isDelayDispose; - private _isStarted; - private _isPlaying; - private _isReversing; - private _isCompleted; - private _playTimes; - private _time; - private _currentTime; - private _currentPlayTimes; - private _cacheFrameIndex; - private _frameSize; - private _cacheRectangle; - private _clock; - private _groupConfig; - private _config; - private _clipConfig; - private _currentFrameConfig; - private _clipArray; - private _clipNames; - private _slots; - private _childMovies; - constructor(createMovieHelper: any); - private _configToEvent(config, event); - private _onCrossFrame(frameConfig); - private _updateSlotBlendMode(slot); - private _updateSlotColor(slot, aM, rM, gM, bM, aO, rO, gO, bO); - private _updateSlotDisplay(slot); - private _getSlot(name); - /** - * @inheritDoc - */ - $render(): void; - /** - * @inheritDoc - */ - $updateRenderNode(): void; - /** - * @inheritDoc - */ - $measureContentBounds(bounds: egret.Rectangle): void; - /** - * @inheritDoc - */ - $doAddChild(child: egret.DisplayObject, index: number, notifyListeners?: boolean): egret.DisplayObject; - /** - * @inheritDoc - */ - $doRemoveChild(index: number, notifyListeners?: boolean): egret.DisplayObject; - /** - * 释放动画。 - * @version DragonBones 3.0 - * @language zh_CN - */ - dispose(): void; - /** - * @inheritDoc - */ - advanceTime(passedTime: number): void; - /** - * 播放动画剪辑。 - * @param clipName 动画剪辑的名称,如果未设置,则播放默认动画剪辑,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画剪辑。 - * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 4.7 - * @language zh_CN - */ - play(clipName?: string | null, playTimes?: number): void; - /** - * 暂停播放动画。 - * @version DragonBones 4.7 - * @language zh_CN - */ - stop(): void; - /** - * 从指定时间播放动画。 - * @param clipName 动画剪辑的名称。 - * @param time 指定时间。(以秒为单位) - * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 5.0 - * @language zh_CN - */ - gotoAndPlay(clipName: string | null | undefined, time: number, playTimes?: number): void; - /** - * 将动画停止到指定时间。 - * @param clipName 动画剪辑的名称。 - * @param time 指定时间。(以秒为单位) - * @version DragonBones 5.0 - * @language zh_CN - */ - gotoAndStop(clipName: string | null | undefined, time: number): void; - /** - * 是否包含指定动画剪辑。 - * @param clipName 动画剪辑的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - hasClip(clipName: string): boolean; - /** - * 动画剪辑是否处正在播放。 - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly isPlaying: boolean; - /** - * 动画剪辑是否均播放完毕。 - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly isComplete: boolean; - /** - * 当前动画剪辑的播放时间。 (以秒为单位) - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly currentTime: number; - /** - * 当前动画剪辑的总时间。 (以秒为单位) - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly totalTime: number; - /** - * 当前动画剪辑的播放次数。 - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly currentPlayTimes: number; - /** - * 当前动画剪辑需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly playTimes: number; - readonly groupName: string; - /** - * 正在播放的动画剪辑名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly clipName: string; - /** - * 所有动画剪辑的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly clipNames: string[]; - /** - * @inheritDoc - */ - clock: WorldClock | null; - /** - * 已废弃,请参考 {@link dragonBones.Movie#clock} {@link dragonBones.Movie#clock} {@link dragonBones.EgretFactory#clock}。 - * @deprecated - * @language zh_CN - */ - advanceTimeBySelf(on: boolean): void; - /** - * @private - */ - readonly display: any; - /** - * @private - */ - readonly animation: any; - /** - * @private - */ - readonly armature: any; - /** - * @private - */ - getAnimation(): any; - /** - * @private - */ - getArmature(): any; - /** - * @private - */ - getDisplay(): any; - /** - * @private - */ - hasAnimation(name: string): boolean; - /** - * @private - */ - invalidUpdate(...args: any[]): void; - /** - * @private - */ - readonly lastAnimationName: string; - /** - * @private - */ - readonly animationNames: string[]; - /** - * @private - */ - readonly animationList: string[]; - } -} diff --git a/demo/libs/modules/dragonBones/dragonBones.js b/demo/libs/modules/dragonBones/dragonBones.js deleted file mode 100644 index 59091a98..00000000 --- a/demo/libs/modules/dragonBones/dragonBones.js +++ /dev/null @@ -1,18213 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var dragonBones; -(function (dragonBones) { -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @private - */ - var DragonBones = /** @class */ (function () { - function DragonBones(eventManager) { - this._clock = new dragonBones.WorldClock(); - this._events = []; - this._objects = []; - this._eventManager = null; - this._eventManager = eventManager; - console.info("DragonBones: " + DragonBones.VERSION + "\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/"); - } - DragonBones.prototype.advanceTime = function (passedTime) { - if (this._objects.length > 0) { - for (var _i = 0, _a = this._objects; _i < _a.length; _i++) { - var object = _a[_i]; - object.returnToPool(); - } - this._objects.length = 0; - } - this._clock.advanceTime(passedTime); - if (this._events.length > 0) { - for (var i = 0; i < this._events.length; ++i) { - var eventObject = this._events[i]; - var armature = eventObject.armature; - if (armature._armatureData !== null) { - armature.eventDispatcher.dispatchDBEvent(eventObject.type, eventObject); - if (eventObject.type === dragonBones.EventObject.SOUND_EVENT) { - this._eventManager.dispatchDBEvent(eventObject.type, eventObject); - } - } - this.bufferObject(eventObject); - } - this._events.length = 0; - } - }; - DragonBones.prototype.bufferEvent = function (value) { - if (this._events.indexOf(value) < 0) { - this._events.push(value); - } - }; - DragonBones.prototype.bufferObject = function (object) { - if (this._objects.indexOf(object) < 0) { - this._objects.push(object); - } - }; - Object.defineProperty(DragonBones.prototype, "clock", { - get: function () { - return this._clock; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DragonBones.prototype, "eventManager", { - get: function () { - return this._eventManager; - }, - enumerable: true, - configurable: true - }); - DragonBones.VERSION = "5.6.300"; - DragonBones.yDown = true; - DragonBones.debug = false; - DragonBones.debugDraw = false; - DragonBones.webAssembly = false; - return DragonBones; - }()); - dragonBones.DragonBones = DragonBones; -})(dragonBones || (dragonBones = {})); -// -if (typeof global === "undefined") { - var global = window; -} -// -if (!console.warn) { - console.warn = function () { }; -} -if (!console.assert) { - console.assert = function () { }; -} -// -if (!Date.now) { - Date.now = function now() { - return new Date().getTime(); - }; -} -// Weixin can not support typescript extends. -var __extends = function (t, e) { - function r() { - this.constructor = t; - } - for (var i in e) { - if (e.hasOwnProperty(i)) { - t[i] = e[i]; - } - } - r.prototype = e.prototype, t.prototype = new r(); -}; -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The BaseObject is the base class for all objects in the DragonBones framework. - * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 基础对象,通常 DragonBones 的对象都继承自该类。 - * 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。 - * @version DragonBones 4.5 - * @language zh_CN - */ - var BaseObject = /** @class */ (function () { - function BaseObject() { - /** - * - A unique identification number assigned to the object. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 分配给此实例的唯一标识号。 - * @version DragonBones 4.5 - * @language zh_CN - */ - this.hashCode = BaseObject._hashCode++; - this._isInPool = false; - } - BaseObject._returnObject = function (object) { - var classType = String(object.constructor); - var maxCount = classType in BaseObject._maxCountMap ? BaseObject._maxCountMap[classType] : BaseObject._defaultMaxCount; - var pool = BaseObject._poolsMap[classType] = BaseObject._poolsMap[classType] || []; - if (pool.length < maxCount) { - if (!object._isInPool) { - object._isInPool = true; - pool.push(object); - } - else { - console.warn("The object is already in the pool."); - } - } - else { - } - }; - BaseObject.toString = function () { - throw new Error(); - }; - /** - * - Set the maximum cache count of the specify object pool. - * @param objectConstructor - The specify class. (Set all object pools max cache count if not set) - * @param maxCount - Max count. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 设置特定对象池的最大缓存数量。 - * @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量) - * @param maxCount - 最大缓存数量。 - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseObject.setMaxCount = function (objectConstructor, maxCount) { - if (maxCount < 0 || maxCount !== maxCount) { - maxCount = 0; - } - if (objectConstructor !== null) { - var classType = String(objectConstructor); - var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; - if (pool !== null && pool.length > maxCount) { - pool.length = maxCount; - } - BaseObject._maxCountMap[classType] = maxCount; - } - else { - BaseObject._defaultMaxCount = maxCount; - for (var classType in BaseObject._poolsMap) { - var pool = BaseObject._poolsMap[classType]; - if (pool.length > maxCount) { - pool.length = maxCount; - } - if (classType in BaseObject._maxCountMap) { - BaseObject._maxCountMap[classType] = maxCount; - } - } - } - }; - /** - * - Clear the cached instances of a specify object pool. - * @param objectConstructor - Specify class. (Clear all cached instances if not set) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除特定对象池的缓存实例。 - * @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例) - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseObject.clearPool = function (objectConstructor) { - if (objectConstructor === void 0) { objectConstructor = null; } - if (objectConstructor !== null) { - var classType = String(objectConstructor); - var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; - if (pool !== null && pool.length > 0) { - pool.length = 0; - } - } - else { - for (var k in BaseObject._poolsMap) { - var pool = BaseObject._poolsMap[k]; - pool.length = 0; - } - } - }; - /** - * - Get an instance of the specify class from object pool. - * @param objectConstructor - The specify class. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从对象池中获取特定类的实例。 - * @param objectConstructor - 特定的类。 - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseObject.borrowObject = function (objectConstructor) { - var classType = String(objectConstructor); - var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; - if (pool !== null && pool.length > 0) { - var object_1 = pool.pop(); - object_1._isInPool = false; - return object_1; - } - var object = new objectConstructor(); - object._onClear(); - return object; - }; - /** - * - Clear the object and return it back to object pool。 - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除该实例的所有数据并将其返还对象池。 - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseObject.prototype.returnToPool = function () { - this._onClear(); - BaseObject._returnObject(this); - }; - BaseObject._hashCode = 0; - BaseObject._defaultMaxCount = 3000; - BaseObject._maxCountMap = {}; - BaseObject._poolsMap = {}; - return BaseObject; - }()); - dragonBones.BaseObject = BaseObject; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - 2D Transform matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 转换矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var Matrix = /** @class */ (function () { - /** - * @private - */ - function Matrix(a, b, c, d, tx, ty) { - if (a === void 0) { a = 1.0; } - if (b === void 0) { b = 0.0; } - if (c === void 0) { c = 0.0; } - if (d === void 0) { d = 1.0; } - if (tx === void 0) { tx = 0.0; } - if (ty === void 0) { ty = 0.0; } - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.tx = tx; - this.ty = ty; - } - Matrix.prototype.toString = function () { - return "[object dragonBones.Matrix] a:" + this.a + " b:" + this.b + " c:" + this.c + " d:" + this.d + " tx:" + this.tx + " ty:" + this.ty; - }; - /** - * @private - */ - Matrix.prototype.copyFrom = function (value) { - this.a = value.a; - this.b = value.b; - this.c = value.c; - this.d = value.d; - this.tx = value.tx; - this.ty = value.ty; - return this; - }; - /** - * @private - */ - Matrix.prototype.copyFromArray = function (value, offset) { - if (offset === void 0) { offset = 0; } - this.a = value[offset]; - this.b = value[offset + 1]; - this.c = value[offset + 2]; - this.d = value[offset + 3]; - this.tx = value[offset + 4]; - this.ty = value[offset + 5]; - return this; - }; - /** - * - Convert to unit matrix. - * The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 转换为单位矩阵。 - * 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。 - * @version DragonBones 3.0 - * @language zh_CN - */ - Matrix.prototype.identity = function () { - this.a = this.d = 1.0; - this.b = this.c = 0.0; - this.tx = this.ty = 0.0; - return this; - }; - /** - * - Multiplies the current matrix with another matrix. - * @param value - The matrix that needs to be multiplied. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将当前矩阵与另一个矩阵相乘。 - * @param value - 需要相乘的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - Matrix.prototype.concat = function (value) { - var aA = this.a * value.a; - var bA = 0.0; - var cA = 0.0; - var dA = this.d * value.d; - var txA = this.tx * value.a + value.tx; - var tyA = this.ty * value.d + value.ty; - if (this.b !== 0.0 || this.c !== 0.0) { - aA += this.b * value.c; - bA += this.b * value.d; - cA += this.c * value.a; - dA += this.c * value.b; - } - if (value.b !== 0.0 || value.c !== 0.0) { - bA += this.a * value.b; - cA += this.d * value.c; - txA += this.ty * value.c; - tyA += this.tx * value.b; - } - this.a = aA; - this.b = bA; - this.c = cA; - this.d = dA; - this.tx = txA; - this.ty = tyA; - return this; - }; - /** - * - Convert to inverse matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 转换为逆矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - Matrix.prototype.invert = function () { - var aA = this.a; - var bA = this.b; - var cA = this.c; - var dA = this.d; - var txA = this.tx; - var tyA = this.ty; - if (bA === 0.0 && cA === 0.0) { - this.b = this.c = 0.0; - if (aA === 0.0 || dA === 0.0) { - this.a = this.b = this.tx = this.ty = 0.0; - } - else { - aA = this.a = 1.0 / aA; - dA = this.d = 1.0 / dA; - this.tx = -aA * txA; - this.ty = -dA * tyA; - } - return this; - } - var determinant = aA * dA - bA * cA; - if (determinant === 0.0) { - this.a = this.d = 1.0; - this.b = this.c = 0.0; - this.tx = this.ty = 0.0; - return this; - } - determinant = 1.0 / determinant; - var k = this.a = dA * determinant; - bA = this.b = -bA * determinant; - cA = this.c = -cA * determinant; - dA = this.d = aA * determinant; - this.tx = -(k * txA + cA * tyA); - this.ty = -(bA * txA + dA * tyA); - return this; - }; - /** - * - Apply a matrix transformation to a specific point. - * @param x - X coordinate. - * @param y - Y coordinate. - * @param result - The point after the transformation is applied. - * @param delta - Whether to ignore tx, ty's conversion to point. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将矩阵转换应用于特定点。 - * @param x - 横坐标。 - * @param y - 纵坐标。 - * @param result - 应用转换之后的点。 - * @param delta - 是否忽略 tx,ty 对点的转换。 - * @version DragonBones 3.0 - * @language zh_CN - */ - Matrix.prototype.transformPoint = function (x, y, result, delta) { - if (delta === void 0) { delta = false; } - result.x = this.a * x + this.c * y; - result.y = this.b * x + this.d * y; - if (!delta) { - result.x += this.tx; - result.y += this.ty; - } - }; - /** - * @private - */ - Matrix.prototype.transformRectangle = function (rectangle, delta) { - if (delta === void 0) { delta = false; } - var a = this.a; - var b = this.b; - var c = this.c; - var d = this.d; - var tx = delta ? 0.0 : this.tx; - var ty = delta ? 0.0 : this.ty; - var x = rectangle.x; - var y = rectangle.y; - var xMax = x + rectangle.width; - var yMax = y + rectangle.height; - var x0 = a * x + c * y + tx; - var y0 = b * x + d * y + ty; - var x1 = a * xMax + c * y + tx; - var y1 = b * xMax + d * y + ty; - var x2 = a * xMax + c * yMax + tx; - var y2 = b * xMax + d * yMax + ty; - var x3 = a * x + c * yMax + tx; - var y3 = b * x + d * yMax + ty; - var tmp = 0.0; - if (x0 > x1) { - tmp = x0; - x0 = x1; - x1 = tmp; - } - if (x2 > x3) { - tmp = x2; - x2 = x3; - x3 = tmp; - } - rectangle.x = Math.floor(x0 < x2 ? x0 : x2); - rectangle.width = Math.ceil((x1 > x3 ? x1 : x3) - rectangle.x); - if (y0 > y1) { - tmp = y0; - y0 = y1; - y1 = tmp; - } - if (y2 > y3) { - tmp = y2; - y2 = y3; - y3 = tmp; - } - rectangle.y = Math.floor(y0 < y2 ? y0 : y2); - rectangle.height = Math.ceil((y1 > y3 ? y1 : y3) - rectangle.y); - }; - return Matrix; - }()); - dragonBones.Matrix = Matrix; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - 2D Transform. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 变换。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var Transform = /** @class */ (function () { - /** - * @private - */ - function Transform(x, y, skew, rotation, scaleX, scaleY) { - if (x === void 0) { x = 0.0; } - if (y === void 0) { y = 0.0; } - if (skew === void 0) { skew = 0.0; } - if (rotation === void 0) { rotation = 0.0; } - if (scaleX === void 0) { scaleX = 1.0; } - if (scaleY === void 0) { scaleY = 1.0; } - this.x = x; - this.y = y; - this.skew = skew; - this.rotation = rotation; - this.scaleX = scaleX; - this.scaleY = scaleY; - } - /** - * @private - */ - Transform.normalizeRadian = function (value) { - value = (value + Math.PI) % (Math.PI * 2.0); - value += value > 0.0 ? -Math.PI : Math.PI; - return value; - }; - Transform.prototype.toString = function () { - return "[object dragonBones.Transform] x:" + this.x + " y:" + this.y + " skewX:" + this.skew * 180.0 / Math.PI + " skewY:" + this.rotation * 180.0 / Math.PI + " scaleX:" + this.scaleX + " scaleY:" + this.scaleY; - }; - /** - * @private - */ - Transform.prototype.copyFrom = function (value) { - this.x = value.x; - this.y = value.y; - this.skew = value.skew; - this.rotation = value.rotation; - this.scaleX = value.scaleX; - this.scaleY = value.scaleY; - return this; - }; - /** - * @private - */ - Transform.prototype.identity = function () { - this.x = this.y = 0.0; - this.skew = this.rotation = 0.0; - this.scaleX = this.scaleY = 1.0; - return this; - }; - /** - * @private - */ - Transform.prototype.add = function (value) { - this.x += value.x; - this.y += value.y; - this.skew += value.skew; - this.rotation += value.rotation; - this.scaleX *= value.scaleX; - this.scaleY *= value.scaleY; - return this; - }; - /** - * @private - */ - Transform.prototype.minus = function (value) { - this.x -= value.x; - this.y -= value.y; - this.skew -= value.skew; - this.rotation -= value.rotation; - this.scaleX /= value.scaleX; - this.scaleY /= value.scaleY; - return this; - }; - /** - * @private - */ - Transform.prototype.fromMatrix = function (matrix) { - var backupScaleX = this.scaleX, backupScaleY = this.scaleY; - var PI_Q = Transform.PI_Q; - this.x = matrix.tx; - this.y = matrix.ty; - this.rotation = Math.atan(matrix.b / matrix.a); - var skewX = Math.atan(-matrix.c / matrix.d); - this.scaleX = (this.rotation > -PI_Q && this.rotation < PI_Q) ? matrix.a / Math.cos(this.rotation) : matrix.b / Math.sin(this.rotation); - this.scaleY = (skewX > -PI_Q && skewX < PI_Q) ? matrix.d / Math.cos(skewX) : -matrix.c / Math.sin(skewX); - if (backupScaleX >= 0.0 && this.scaleX < 0.0) { - this.scaleX = -this.scaleX; - this.rotation = this.rotation - Math.PI; - } - if (backupScaleY >= 0.0 && this.scaleY < 0.0) { - this.scaleY = -this.scaleY; - skewX = skewX - Math.PI; - } - this.skew = skewX - this.rotation; - return this; - }; - /** - * @private - */ - Transform.prototype.toMatrix = function (matrix) { - if (this.rotation === 0.0) { - matrix.a = 1.0; - matrix.b = 0.0; - } - else { - matrix.a = Math.cos(this.rotation); - matrix.b = Math.sin(this.rotation); - } - if (this.skew === 0.0) { - matrix.c = -matrix.b; - matrix.d = matrix.a; - } - else { - matrix.c = -Math.sin(this.skew + this.rotation); - matrix.d = Math.cos(this.skew + this.rotation); - } - if (this.scaleX !== 1.0) { - matrix.a *= this.scaleX; - matrix.b *= this.scaleX; - } - if (this.scaleY !== 1.0) { - matrix.c *= this.scaleY; - matrix.d *= this.scaleY; - } - matrix.tx = this.x; - matrix.ty = this.y; - return this; - }; - /** - * @private - */ - Transform.PI = Math.PI; - /** - * @private - */ - Transform.PI_D = Math.PI * 2.0; - /** - * @private - */ - Transform.PI_H = Math.PI / 2.0; - /** - * @private - */ - Transform.PI_Q = Math.PI / 4.0; - /** - * @private - */ - Transform.RAD_DEG = 180.0 / Math.PI; - /** - * @private - */ - Transform.DEG_RAD = Math.PI / 180.0; - return Transform; - }()); - dragonBones.Transform = Transform; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var ColorTransform = /** @class */ (function () { - function ColorTransform(alphaMultiplier, redMultiplier, greenMultiplier, blueMultiplier, alphaOffset, redOffset, greenOffset, blueOffset) { - if (alphaMultiplier === void 0) { alphaMultiplier = 1.0; } - if (redMultiplier === void 0) { redMultiplier = 1.0; } - if (greenMultiplier === void 0) { greenMultiplier = 1.0; } - if (blueMultiplier === void 0) { blueMultiplier = 1.0; } - if (alphaOffset === void 0) { alphaOffset = 0; } - if (redOffset === void 0) { redOffset = 0; } - if (greenOffset === void 0) { greenOffset = 0; } - if (blueOffset === void 0) { blueOffset = 0; } - this.alphaMultiplier = alphaMultiplier; - this.redMultiplier = redMultiplier; - this.greenMultiplier = greenMultiplier; - this.blueMultiplier = blueMultiplier; - this.alphaOffset = alphaOffset; - this.redOffset = redOffset; - this.greenOffset = greenOffset; - this.blueOffset = blueOffset; - } - ColorTransform.prototype.copyFrom = function (value) { - this.alphaMultiplier = value.alphaMultiplier; - this.redMultiplier = value.redMultiplier; - this.greenMultiplier = value.greenMultiplier; - this.blueMultiplier = value.blueMultiplier; - this.alphaOffset = value.alphaOffset; - this.redOffset = value.redOffset; - this.greenOffset = value.greenOffset; - this.blueOffset = value.blueOffset; - }; - ColorTransform.prototype.identity = function () { - this.alphaMultiplier = this.redMultiplier = this.greenMultiplier = this.blueMultiplier = 1.0; - this.alphaOffset = this.redOffset = this.greenOffset = this.blueOffset = 0; - }; - return ColorTransform; - }()); - dragonBones.ColorTransform = ColorTransform; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The Point object represents a location in a two-dimensional coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Point 对象表示二维坐标系统中的某个位置。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var Point = /** @class */ (function () { - /** - * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @param x - The horizontal coordinate. - * @param y - The vertical coordinate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 - * @param x - 该对象的x属性值,默认为 0.0。 - * @param y - 该对象的y属性值,默认为 0.0。 - * @version DragonBones 3.0 - * @language zh_CN - */ - function Point(x, y) { - if (x === void 0) { x = 0.0; } - if (y === void 0) { y = 0.0; } - this.x = x; - this.y = y; - } - /** - * @private - */ - Point.prototype.copyFrom = function (value) { - this.x = value.x; - this.y = value.y; - }; - /** - * @private - */ - Point.prototype.clear = function () { - this.x = this.y = 0.0; - }; - return Point; - }()); - dragonBones.Point = Point; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its - * width and its height.
- * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of - * one property has no effect on the others. However, the right and bottom properties are integrally related to those - * four properties. For example, if you change the value of the right property, the value of the width property changes; - * if you change the bottom property, the value of the height property changes. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
- * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var Rectangle = /** @class */ (function () { - /** - * @private - */ - function Rectangle(x, y, width, height) { - if (x === void 0) { x = 0.0; } - if (y === void 0) { y = 0.0; } - if (width === void 0) { width = 0.0; } - if (height === void 0) { height = 0.0; } - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - /** - * @private - */ - Rectangle.prototype.copyFrom = function (value) { - this.x = value.x; - this.y = value.y; - this.width = value.width; - this.height = value.height; - }; - /** - * @private - */ - Rectangle.prototype.clear = function () { - this.x = this.y = 0.0; - this.width = this.height = 0.0; - }; - return Rectangle; - }()); - dragonBones.Rectangle = Rectangle; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The user custom data. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 用户自定义数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - var UserData = /** @class */ (function (_super) { - __extends(UserData, _super); - function UserData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - The custom int numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - _this.ints = []; - /** - * - The custom float numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - _this.floats = []; - /** - * - The custom strings. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - _this.strings = []; - return _this; - } - UserData.toString = function () { - return "[class dragonBones.UserData]"; - }; - UserData.prototype._onClear = function () { - this.ints.length = 0; - this.floats.length = 0; - this.strings.length = 0; - }; - /** - * @internal - */ - UserData.prototype.addInt = function (value) { - this.ints.push(value); - }; - /** - * @internal - */ - UserData.prototype.addFloat = function (value) { - this.floats.push(value); - }; - /** - * @internal - */ - UserData.prototype.addString = function (value) { - this.strings.push(value); - }; - /** - * - Get the custom int number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - UserData.prototype.getInt = function (index) { - if (index === void 0) { index = 0; } - return index >= 0 && index < this.ints.length ? this.ints[index] : 0; - }; - /** - * - Get the custom float number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - UserData.prototype.getFloat = function (index) { - if (index === void 0) { index = 0; } - return index >= 0 && index < this.floats.length ? this.floats[index] : 0.0; - }; - /** - * - Get the custom string. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - UserData.prototype.getString = function (index) { - if (index === void 0) { index = 0; } - return index >= 0 && index < this.strings.length ? this.strings[index] : ""; - }; - return UserData; - }(dragonBones.BaseObject)); - dragonBones.UserData = UserData; - /** - * @internal - */ - var ActionData = /** @class */ (function (_super) { - __extends(ActionData, _super); - function ActionData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.data = null; // - return _this; - } - ActionData.toString = function () { - return "[class dragonBones.ActionData]"; - }; - ActionData.prototype._onClear = function () { - if (this.data !== null) { - this.data.returnToPool(); - } - this.type = 0 /* Play */; - this.name = ""; - this.bone = null; - this.slot = null; - this.data = null; - }; - return ActionData; - }(dragonBones.BaseObject)); - dragonBones.ActionData = ActionData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The DragonBones data. - * A DragonBones data contains multiple armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 龙骨数据。 - * 一个龙骨数据包含多个骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - var DragonBonesData = /** @class */ (function (_super) { - __extends(DragonBonesData, _super); - function DragonBonesData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @internal - */ - _this.frameIndices = []; - /** - * @internal - */ - _this.cachedFrames = []; - /** - * - All armature data names. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的骨架数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.armatureNames = []; - /** - * @private - */ - _this.armatures = {}; - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - DragonBonesData.toString = function () { - return "[class dragonBones.DragonBonesData]"; - }; - DragonBonesData.prototype._onClear = function () { - for (var k in this.armatures) { - this.armatures[k].returnToPool(); - delete this.armatures[k]; - } - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.autoSearch = false; - this.frameRate = 0; - this.version = ""; - this.name = ""; - this.stage = null; - this.frameIndices.length = 0; - this.cachedFrames.length = 0; - this.armatureNames.length = 0; - //this.armatures.clear(); - this.binary = null; // - this.intArray = null; // - this.floatArray = null; // - this.frameIntArray = null; // - this.frameFloatArray = null; // - this.frameArray = null; // - this.timelineArray = null; // - this.userData = null; - }; - /** - * @internal - */ - DragonBonesData.prototype.addArmature = function (value) { - if (value.name in this.armatures) { - console.warn("Same armature: " + value.name); - return; - } - value.parent = this; - this.armatures[value.name] = value; - this.armatureNames.push(value.name); - }; - /** - * - Get a specific armature data. - * @param armatureName - The armature data name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param armatureName - 骨架数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - DragonBonesData.prototype.getArmature = function (armatureName) { - return armatureName in this.armatures ? this.armatures[armatureName] : null; - }; - /** - * - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.BaseFactory#removeDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - DragonBonesData.prototype.dispose = function () { - console.warn("已废弃"); - this.returnToPool(); - }; - return DragonBonesData; - }(dragonBones.BaseObject)); - dragonBones.DragonBonesData = DragonBonesData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The armature data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var ArmatureData = /** @class */ (function (_super) { - __extends(ArmatureData, _super); - function ArmatureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.aabb = new dragonBones.Rectangle(); - /** - * - The names of all the animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的动画数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.animationNames = []; - /** - * @private - */ - _this.sortedBones = []; - /** - * @private - */ - _this.sortedSlots = []; - /** - * @private - */ - _this.defaultActions = []; - /** - * @private - */ - _this.actions = []; - /** - * @private - */ - _this.bones = {}; - /** - * @private - */ - _this.slots = {}; - /** - * @private - */ - _this.constraints = {}; - /** - * @private - */ - _this.skins = {}; - /** - * @private - */ - _this.animations = {}; - /** - * @private - */ - _this.canvas = null; // Initial value. - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - ArmatureData.toString = function () { - return "[class dragonBones.ArmatureData]"; - }; - ArmatureData.prototype._onClear = function () { - for (var _i = 0, _a = this.defaultActions; _i < _a.length; _i++) { - var action = _a[_i]; - action.returnToPool(); - } - for (var _b = 0, _c = this.actions; _b < _c.length; _b++) { - var action = _c[_b]; - action.returnToPool(); - } - for (var k in this.bones) { - this.bones[k].returnToPool(); - delete this.bones[k]; - } - for (var k in this.slots) { - this.slots[k].returnToPool(); - delete this.slots[k]; - } - for (var k in this.constraints) { - this.constraints[k].returnToPool(); - delete this.constraints[k]; - } - for (var k in this.skins) { - this.skins[k].returnToPool(); - delete this.skins[k]; - } - for (var k in this.animations) { - this.animations[k].returnToPool(); - delete this.animations[k]; - } - if (this.canvas !== null) { - this.canvas.returnToPool(); - } - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.type = 0 /* Armature */; - this.frameRate = 0; - this.cacheFrameRate = 0; - this.scale = 1.0; - this.name = ""; - this.aabb.clear(); - this.animationNames.length = 0; - this.sortedBones.length = 0; - this.sortedSlots.length = 0; - this.defaultActions.length = 0; - this.actions.length = 0; - // this.bones.clear(); - // this.slots.clear(); - // this.constraints.clear(); - // this.skins.clear(); - // this.animations.clear(); - this.defaultSkin = null; - this.defaultAnimation = null; - this.canvas = null; - this.userData = null; - this.parent = null; // - }; - /** - * @internal - */ - ArmatureData.prototype.sortBones = function () { - var total = this.sortedBones.length; - if (total <= 0) { - return; - } - var sortHelper = this.sortedBones.concat(); - var index = 0; - var count = 0; - this.sortedBones.length = 0; - while (count < total) { - var bone = sortHelper[index++]; - if (index >= total) { - index = 0; - } - if (this.sortedBones.indexOf(bone) >= 0) { - continue; - } - var flag = false; - for (var k in this.constraints) { - var constraint = this.constraints[k]; - if (constraint.root === bone && this.sortedBones.indexOf(constraint.target) < 0) { - flag = true; - break; - } - } - if (flag) { - continue; - } - if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { - continue; - } - this.sortedBones.push(bone); - count++; - } - }; - /** - * @internal - */ - ArmatureData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0) { - return; - } - this.cacheFrameRate = frameRate; - for (var k in this.animations) { - this.animations[k].cacheFrames(this.cacheFrameRate); - } - }; - /** - * @internal - */ - ArmatureData.prototype.setCacheFrame = function (globalTransformMatrix, transform) { - var dataArray = this.parent.cachedFrames; - var arrayOffset = dataArray.length; - dataArray.length += 10; - dataArray[arrayOffset] = globalTransformMatrix.a; - dataArray[arrayOffset + 1] = globalTransformMatrix.b; - dataArray[arrayOffset + 2] = globalTransformMatrix.c; - dataArray[arrayOffset + 3] = globalTransformMatrix.d; - dataArray[arrayOffset + 4] = globalTransformMatrix.tx; - dataArray[arrayOffset + 5] = globalTransformMatrix.ty; - dataArray[arrayOffset + 6] = transform.rotation; - dataArray[arrayOffset + 7] = transform.skew; - dataArray[arrayOffset + 8] = transform.scaleX; - dataArray[arrayOffset + 9] = transform.scaleY; - return arrayOffset; - }; - /** - * @internal - */ - ArmatureData.prototype.getCacheFrame = function (globalTransformMatrix, transform, arrayOffset) { - var dataArray = this.parent.cachedFrames; - globalTransformMatrix.a = dataArray[arrayOffset]; - globalTransformMatrix.b = dataArray[arrayOffset + 1]; - globalTransformMatrix.c = dataArray[arrayOffset + 2]; - globalTransformMatrix.d = dataArray[arrayOffset + 3]; - globalTransformMatrix.tx = dataArray[arrayOffset + 4]; - globalTransformMatrix.ty = dataArray[arrayOffset + 5]; - transform.rotation = dataArray[arrayOffset + 6]; - transform.skew = dataArray[arrayOffset + 7]; - transform.scaleX = dataArray[arrayOffset + 8]; - transform.scaleY = dataArray[arrayOffset + 9]; - transform.x = globalTransformMatrix.tx; - transform.y = globalTransformMatrix.ty; - }; - /** - * @internal - */ - ArmatureData.prototype.addBone = function (value) { - if (value.name in this.bones) { - console.warn("Same bone: " + value.name); - return; - } - this.bones[value.name] = value; - this.sortedBones.push(value); - }; - /** - * @internal - */ - ArmatureData.prototype.addSlot = function (value) { - if (value.name in this.slots) { - console.warn("Same slot: " + value.name); - return; - } - this.slots[value.name] = value; - this.sortedSlots.push(value); - }; - /** - * @internal - */ - ArmatureData.prototype.addConstraint = function (value) { - if (value.name in this.constraints) { - console.warn("Same constraint: " + value.name); - return; - } - this.constraints[value.name] = value; - }; - /** - * @internal - */ - ArmatureData.prototype.addSkin = function (value) { - if (value.name in this.skins) { - console.warn("Same skin: " + value.name); - return; - } - value.parent = this; - this.skins[value.name] = value; - if (this.defaultSkin === null) { - this.defaultSkin = value; - } - if (value.name === "default") { - this.defaultSkin = value; - } - }; - /** - * @internal - */ - ArmatureData.prototype.addAnimation = function (value) { - if (value.name in this.animations) { - console.warn("Same animation: " + value.name); - return; - } - value.parent = this; - this.animations[value.name] = value; - this.animationNames.push(value.name); - if (this.defaultAnimation === null) { - this.defaultAnimation = value; - } - }; - /** - * @internal - */ - ArmatureData.prototype.addAction = function (value, isDefault) { - if (isDefault) { - this.defaultActions.push(value); - } - else { - this.actions.push(value); - } - }; - /** - * - Get a specific done data. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼数据。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getBone = function (boneName) { - return boneName in this.bones ? this.bones[boneName] : null; - }; - /** - * - Get a specific slot data. - * @param slotName - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽数据。 - * @param slotName - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getSlot = function (slotName) { - return slotName in this.slots ? this.slots[slotName] : null; - }; - /** - * @private - */ - ArmatureData.prototype.getConstraint = function (constraintName) { - return constraintName in this.constraints ? this.constraints[constraintName] : null; - }; - /** - * - Get a specific skin data. - * @param skinName - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定皮肤数据。 - * @param skinName - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getSkin = function (skinName) { - return skinName in this.skins ? this.skins[skinName] : null; - }; - /** - * @private - */ - ArmatureData.prototype.getMesh = function (skinName, slotName, meshName) { - var skin = this.getSkin(skinName); - if (skin === null) { - return null; - } - return skin.getDisplay(slotName, meshName); - }; - /** - * - Get a specific animation data. - * @param animationName - The animation animationName. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的动画数据。 - * @param animationName - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getAnimation = function (animationName) { - return animationName in this.animations ? this.animations[animationName] : null; - }; - return ArmatureData; - }(dragonBones.BaseObject)); - dragonBones.ArmatureData = ArmatureData; - /** - * - The bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var BoneData = /** @class */ (function (_super) { - __extends(BoneData, _super); - function BoneData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.transform = new dragonBones.Transform(); - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - BoneData.toString = function () { - return "[class dragonBones.BoneData]"; - }; - BoneData.prototype._onClear = function () { - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.inheritTranslation = false; - this.inheritRotation = false; - this.inheritScale = false; - this.inheritReflection = false; - this.type = 0 /* Bone */; - this.length = 0.0; - this.name = ""; - this.transform.identity(); - this.userData = null; - this.parent = null; - }; - return BoneData; - }(dragonBones.BaseObject)); - dragonBones.BoneData = BoneData; - /** - * @internal - */ - var SurfaceData = /** @class */ (function (_super) { - __extends(SurfaceData, _super); - function SurfaceData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.vertices = []; - return _this; - } - SurfaceData.toString = function () { - return "[class dragonBones.SurfaceData]"; - }; - SurfaceData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 1 /* Surface */; - this.segmentX = 0; - this.segmentY = 0; - this.vertices.length = 0; - }; - return SurfaceData; - }(BoneData)); - dragonBones.SurfaceData = SurfaceData; - /** - * - The slot data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var SlotData = /** @class */ (function (_super) { - __extends(SlotData, _super); - function SlotData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.color = null; // Initial value. - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - /** - * @internal - */ - SlotData.createColor = function () { - return new dragonBones.ColorTransform(); - }; - SlotData.toString = function () { - return "[class dragonBones.SlotData]"; - }; - SlotData.prototype._onClear = function () { - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.blendMode = 0 /* Normal */; - this.displayIndex = 0; - this.zOrder = 0; - this.name = ""; - this.color = null; // - this.userData = null; - this.parent = null; // - }; - /** - * @internal - */ - SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); - return SlotData; - }(dragonBones.BaseObject)); - dragonBones.SlotData = SlotData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var CanvasData = /** @class */ (function (_super) { - __extends(CanvasData, _super); - function CanvasData() { - return _super !== null && _super.apply(this, arguments) || this; - } - CanvasData.toString = function () { - return "[class dragonBones.CanvasData]"; - }; - CanvasData.prototype._onClear = function () { - this.hasBackground = false; - this.color = 0x000000; - this.x = 0; - this.y = 0; - this.width = 0; - this.height = 0; - }; - return CanvasData; - }(dragonBones.BaseObject)); - dragonBones.CanvasData = CanvasData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The skin data, typically a armature data instance contains at least one skinData. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var SkinData = /** @class */ (function (_super) { - __extends(SkinData, _super); - function SkinData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.displays = {}; - return _this; - } - SkinData.toString = function () { - return "[class dragonBones.SkinData]"; - }; - SkinData.prototype._onClear = function () { - for (var k in this.displays) { - var slotDisplays = this.displays[k]; - for (var _i = 0, slotDisplays_1 = slotDisplays; _i < slotDisplays_1.length; _i++) { - var display = slotDisplays_1[_i]; - if (display !== null) { - display.returnToPool(); - } - } - delete this.displays[k]; - } - this.name = ""; - // this.displays.clear(); - this.parent = null; // - }; - /** - * @internal - */ - SkinData.prototype.addDisplay = function (slotName, value) { - if (!(slotName in this.displays)) { - this.displays[slotName] = []; - } - if (value !== null) { - value.parent = this; - } - var slotDisplays = this.displays[slotName]; // TODO clear prev - slotDisplays.push(value); - }; - /** - * @private - */ - SkinData.prototype.getDisplay = function (slotName, displayName) { - var slotDisplays = this.getDisplays(slotName); - if (slotDisplays !== null) { - for (var _i = 0, slotDisplays_2 = slotDisplays; _i < slotDisplays_2.length; _i++) { - var display = slotDisplays_2[_i]; - if (display !== null && display.name === displayName) { - return display; - } - } - } - return null; - }; - /** - * @private - */ - SkinData.prototype.getDisplays = function (slotName) { - if (!(slotName in this.displays)) { - return null; - } - return this.displays[slotName]; - }; - return SkinData; - }(dragonBones.BaseObject)); - dragonBones.SkinData = SkinData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var ConstraintData = /** @class */ (function (_super) { - __extends(ConstraintData, _super); - function ConstraintData() { - return _super !== null && _super.apply(this, arguments) || this; - } - ConstraintData.prototype._onClear = function () { - this.order = 0; - this.name = ""; - this.type = 0 /* IK */; - this.target = null; // - this.root = null; // - this.bone = null; - }; - return ConstraintData; - }(dragonBones.BaseObject)); - dragonBones.ConstraintData = ConstraintData; - /** - * @internal - */ - var IKConstraintData = /** @class */ (function (_super) { - __extends(IKConstraintData, _super); - function IKConstraintData() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraintData.toString = function () { - return "[class dragonBones.IKConstraintData]"; - }; - IKConstraintData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.scaleEnabled = false; - this.bendPositive = false; - this.weight = 1.0; - }; - return IKConstraintData; - }(ConstraintData)); - dragonBones.IKConstraintData = IKConstraintData; - /** - * @internal - */ - var PathConstraintData = /** @class */ (function (_super) { - __extends(PathConstraintData, _super); - function PathConstraintData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.bones = []; - return _this; - } - PathConstraintData.toString = function () { - return "[class dragonBones.PathConstraintData]"; - }; - PathConstraintData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.pathSlot = null; - this.pathDisplayData = null; - this.bones.length = 0; - this.positionMode = 0 /* Fixed */; - this.spacingMode = 1 /* Fixed */; - this.rotateMode = 1 /* Chain */; - this.position = 0.0; - this.spacing = 0.0; - this.rotateOffset = 0.0; - this.rotateMix = 0.0; - this.translateMix = 0.0; - }; - PathConstraintData.prototype.AddBone = function (value) { - this.bones.push(value); - }; - return PathConstraintData; - }(ConstraintData)); - dragonBones.PathConstraintData = PathConstraintData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var VerticesData = /** @class */ (function () { - function VerticesData() { - this.weight = null; // Initial value. - } - VerticesData.prototype.clear = function () { - if (!this.isShared && this.weight !== null) { - this.weight.returnToPool(); - } - this.isShared = false; - this.inheritDeform = false; - this.offset = 0; - this.data = null; - this.weight = null; - }; - VerticesData.prototype.shareFrom = function (value) { - this.isShared = true; - this.offset = value.offset; - this.weight = value.weight; - }; - return VerticesData; - }()); - dragonBones.VerticesData = VerticesData; - /** - * @internal - */ - var DisplayData = /** @class */ (function (_super) { - __extends(DisplayData, _super); - function DisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.transform = new dragonBones.Transform(); - return _this; - } - DisplayData.prototype._onClear = function () { - this.name = ""; - this.path = ""; - this.transform.identity(); - this.parent = null; // - }; - return DisplayData; - }(dragonBones.BaseObject)); - dragonBones.DisplayData = DisplayData; - /** - * @internal - */ - var ImageDisplayData = /** @class */ (function (_super) { - __extends(ImageDisplayData, _super); - function ImageDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.pivot = new dragonBones.Point(); - return _this; - } - ImageDisplayData.toString = function () { - return "[class dragonBones.ImageDisplayData]"; - }; - ImageDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 0 /* Image */; - this.pivot.clear(); - this.texture = null; - }; - return ImageDisplayData; - }(DisplayData)); - dragonBones.ImageDisplayData = ImageDisplayData; - /** - * @internal - */ - var ArmatureDisplayData = /** @class */ (function (_super) { - __extends(ArmatureDisplayData, _super); - function ArmatureDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.actions = []; - return _this; - } - ArmatureDisplayData.toString = function () { - return "[class dragonBones.ArmatureDisplayData]"; - }; - ArmatureDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - for (var _i = 0, _a = this.actions; _i < _a.length; _i++) { - var action = _a[_i]; - action.returnToPool(); - } - this.type = 1 /* Armature */; - this.inheritAnimation = false; - this.actions.length = 0; - this.armature = null; - }; - /** - * @private - */ - ArmatureDisplayData.prototype.addAction = function (value) { - this.actions.push(value); - }; - return ArmatureDisplayData; - }(DisplayData)); - dragonBones.ArmatureDisplayData = ArmatureDisplayData; - /** - * @internal - */ - var MeshDisplayData = /** @class */ (function (_super) { - __extends(MeshDisplayData, _super); - function MeshDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.vertices = new VerticesData(); - return _this; - } - MeshDisplayData.toString = function () { - return "[class dragonBones.MeshDisplayData]"; - }; - MeshDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 2 /* Mesh */; - this.vertices.clear(); - this.texture = null; - }; - return MeshDisplayData; - }(DisplayData)); - dragonBones.MeshDisplayData = MeshDisplayData; - /** - * @internal - */ - var BoundingBoxDisplayData = /** @class */ (function (_super) { - __extends(BoundingBoxDisplayData, _super); - function BoundingBoxDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.boundingBox = null; // Initial value. - return _this; - } - BoundingBoxDisplayData.toString = function () { - return "[class dragonBones.BoundingBoxDisplayData]"; - }; - BoundingBoxDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.boundingBox !== null) { - this.boundingBox.returnToPool(); - } - this.type = 3 /* BoundingBox */; - this.boundingBox = null; - }; - return BoundingBoxDisplayData; - }(DisplayData)); - dragonBones.BoundingBoxDisplayData = BoundingBoxDisplayData; - /** - * @internal - */ - var PathDisplayData = /** @class */ (function (_super) { - __extends(PathDisplayData, _super); - function PathDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.vertices = new VerticesData(); - _this.curveLengths = []; - return _this; - } - PathDisplayData.toString = function () { - return "[class dragonBones.PathDisplayData]"; - }; - PathDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 4 /* Path */; - this.closed = false; - this.constantSpeed = false; - this.vertices.clear(); - this.curveLengths.length = 0; - }; - return PathDisplayData; - }(DisplayData)); - dragonBones.PathDisplayData = PathDisplayData; - /** - * @internal - */ - var WeightData = /** @class */ (function (_super) { - __extends(WeightData, _super); - function WeightData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.bones = []; - return _this; - } - WeightData.toString = function () { - return "[class dragonBones.WeightData]"; - }; - WeightData.prototype._onClear = function () { - this.count = 0; - this.offset = 0; - this.bones.length = 0; - }; - WeightData.prototype.addBone = function (value) { - this.bones.push(value); - }; - return WeightData; - }(dragonBones.BaseObject)); - dragonBones.WeightData = WeightData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The base class of bounding box data. - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框数据基类。 - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language zh_CN - */ - var BoundingBoxData = /** @class */ (function (_super) { - __extends(BoundingBoxData, _super); - function BoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoundingBoxData.prototype._onClear = function () { - this.color = 0x000000; - this.width = 0.0; - this.height = 0.0; - }; - return BoundingBoxData; - }(dragonBones.BaseObject)); - dragonBones.BoundingBoxData = BoundingBoxData; - /** - * - The rectangle bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 矩形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var RectangleBoundingBoxData = /** @class */ (function (_super) { - __extends(RectangleBoundingBoxData, _super); - function RectangleBoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - RectangleBoundingBoxData.toString = function () { - return "[class dragonBones.RectangleBoundingBoxData]"; - }; - /** - * - Compute the bit code for a point (x, y) using the clip rectangle - */ - RectangleBoundingBoxData._computeOutCode = function (x, y, xMin, yMin, xMax, yMax) { - var code = 0 /* InSide */; // initialised as being inside of [[clip window]] - if (x < xMin) { - code |= 1 /* Left */; - } - else if (x > xMax) { - code |= 2 /* Right */; - } - if (y < yMin) { - code |= 4 /* Top */; - } - else if (y > yMax) { - code |= 8 /* Bottom */; - } - return code; - }; - /** - * @private - */ - RectangleBoundingBoxData.rectangleIntersectsSegment = function (xA, yA, xB, yB, xMin, yMin, xMax, yMax, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var inSideA = xA > xMin && xA < xMax && yA > yMin && yA < yMax; - var inSideB = xB > xMin && xB < xMax && yB > yMin && yB < yMax; - if (inSideA && inSideB) { - return -1; - } - var intersectionCount = 0; - var outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); - var outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); - while (true) { - if ((outcode0 | outcode1) === 0) { - intersectionCount = 2; - break; - } - else if ((outcode0 & outcode1) !== 0) { - break; - } - // failed both tests, so calculate the line segment to clip - // from an outside point to an intersection with clip edge - var x = 0.0; - var y = 0.0; - var normalRadian = 0.0; - // At least one endpoint is outside the clip rectangle; pick it. - var outcodeOut = outcode0 !== 0 ? outcode0 : outcode1; - // Now find the intersection point; - if ((outcodeOut & 4 /* Top */) !== 0) { - x = xA + (xB - xA) * (yMin - yA) / (yB - yA); - y = yMin; - if (normalRadians !== null) { - normalRadian = -Math.PI * 0.5; - } - } - else if ((outcodeOut & 8 /* Bottom */) !== 0) { - x = xA + (xB - xA) * (yMax - yA) / (yB - yA); - y = yMax; - if (normalRadians !== null) { - normalRadian = Math.PI * 0.5; - } - } - else if ((outcodeOut & 2 /* Right */) !== 0) { - y = yA + (yB - yA) * (xMax - xA) / (xB - xA); - x = xMax; - if (normalRadians !== null) { - normalRadian = 0; - } - } - else if ((outcodeOut & 1 /* Left */) !== 0) { - y = yA + (yB - yA) * (xMin - xA) / (xB - xA); - x = xMin; - if (normalRadians !== null) { - normalRadian = Math.PI; - } - } - // Now we move outside point to intersection point to clip - // and get ready for next pass. - if (outcodeOut === outcode0) { - xA = x; - yA = y; - outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); - if (normalRadians !== null) { - normalRadians.x = normalRadian; - } - } - else { - xB = x; - yB = y; - outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); - if (normalRadians !== null) { - normalRadians.y = normalRadian; - } - } - } - if (intersectionCount) { - if (inSideA) { - intersectionCount = 2; // 10 - if (intersectionPointA !== null) { - intersectionPointA.x = xB; - intersectionPointA.y = yB; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = xB; - } - if (normalRadians !== null) { - normalRadians.x = normalRadians.y + Math.PI; - } - } - else if (inSideB) { - intersectionCount = 1; // 01 - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA; - intersectionPointB.y = yA; - } - if (normalRadians !== null) { - normalRadians.y = normalRadians.x + Math.PI; - } - } - else { - intersectionCount = 3; // 11 - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = yB; - } - } - } - return intersectionCount; - }; - RectangleBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 0 /* Rectangle */; - }; - /** - * @inheritDoc - */ - RectangleBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var widthH = this.width * 0.5; - if (pX >= -widthH && pX <= widthH) { - var heightH = this.height * 0.5; - if (pY >= -heightH && pY <= heightH) { - return true; - } - } - return false; - }; - /** - * @inheritDoc - */ - RectangleBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var widthH = this.width * 0.5; - var heightH = this.height * 0.5; - var intersectionCount = RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, -widthH, -heightH, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians); - return intersectionCount; - }; - return RectangleBoundingBoxData; - }(BoundingBoxData)); - dragonBones.RectangleBoundingBoxData = RectangleBoundingBoxData; - /** - * - The ellipse bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 椭圆边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var EllipseBoundingBoxData = /** @class */ (function (_super) { - __extends(EllipseBoundingBoxData, _super); - function EllipseBoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - EllipseBoundingBoxData.toString = function () { - return "[class dragonBones.EllipseData]"; - }; - /** - * @private - */ - EllipseBoundingBoxData.ellipseIntersectsSegment = function (xA, yA, xB, yB, xC, yC, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var d = widthH / heightH; - var dd = d * d; - yA *= d; - yB *= d; - var dX = xB - xA; - var dY = yB - yA; - var lAB = Math.sqrt(dX * dX + dY * dY); - var xD = dX / lAB; - var yD = dY / lAB; - var a = (xC - xA) * xD + (yC - yA) * yD; - var aa = a * a; - var ee = xA * xA + yA * yA; - var rr = widthH * widthH; - var dR = rr - ee + aa; - var intersectionCount = 0; - if (dR >= 0.0) { - var dT = Math.sqrt(dR); - var sA = a - dT; - var sB = a + dT; - var inSideA = sA < 0.0 ? -1 : (sA <= lAB ? 0 : 1); - var inSideB = sB < 0.0 ? -1 : (sB <= lAB ? 0 : 1); - var sideAB = inSideA * inSideB; - if (sideAB < 0) { - return -1; - } - else if (sideAB === 0) { - if (inSideA === -1) { - intersectionCount = 2; // 10 - xB = xA + sB * xD; - yB = (yA + sB * yD) / d; - if (intersectionPointA !== null) { - intersectionPointA.x = xB; - intersectionPointA.y = yB; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = yB; - } - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yB / rr * dd, xB / rr); - normalRadians.y = normalRadians.x + Math.PI; - } - } - else if (inSideB === 1) { - intersectionCount = 1; // 01 - xA = xA + sA * xD; - yA = (yA + sA * yD) / d; - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA; - intersectionPointB.y = yA; - } - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yA / rr * dd, xA / rr); - normalRadians.y = normalRadians.x + Math.PI; - } - } - else { - intersectionCount = 3; // 11 - if (intersectionPointA !== null) { - intersectionPointA.x = xA + sA * xD; - intersectionPointA.y = (yA + sA * yD) / d; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(intersectionPointA.y / rr * dd, intersectionPointA.x / rr); - } - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA + sB * xD; - intersectionPointB.y = (yA + sB * yD) / d; - if (normalRadians !== null) { - normalRadians.y = Math.atan2(intersectionPointB.y / rr * dd, intersectionPointB.x / rr); - } - } - } - } - } - return intersectionCount; - }; - EllipseBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 1 /* Ellipse */; - }; - /** - * @inheritDoc - */ - EllipseBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var widthH = this.width * 0.5; - if (pX >= -widthH && pX <= widthH) { - var heightH = this.height * 0.5; - if (pY >= -heightH && pY <= heightH) { - pY *= widthH / heightH; - return Math.sqrt(pX * pX + pY * pY) <= widthH; - } - } - return false; - }; - /** - * @inheritDoc - */ - EllipseBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var intersectionCount = EllipseBoundingBoxData.ellipseIntersectsSegment(xA, yA, xB, yB, 0.0, 0.0, this.width * 0.5, this.height * 0.5, intersectionPointA, intersectionPointB, normalRadians); - return intersectionCount; - }; - return EllipseBoundingBoxData; - }(BoundingBoxData)); - dragonBones.EllipseBoundingBoxData = EllipseBoundingBoxData; - /** - * - The polygon bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var PolygonBoundingBoxData = /** @class */ (function (_super) { - __extends(PolygonBoundingBoxData, _super); - function PolygonBoundingBoxData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - The polygon vertices. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形顶点。 - * @version DragonBones 5.1 - * @language zh_CN - */ - _this.vertices = []; - return _this; - } - PolygonBoundingBoxData.toString = function () { - return "[class dragonBones.PolygonBoundingBoxData]"; - }; - /** - * @private - */ - PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - if (xA === xB) { - xA = xB + 0.000001; - } - if (yA === yB) { - yA = yB + 0.000001; - } - var count = vertices.length; - var dXAB = xA - xB; - var dYAB = yA - yB; - var llAB = xA * yB - yA * xB; - var intersectionCount = 0; - var xC = vertices[count - 2]; - var yC = vertices[count - 1]; - var dMin = 0.0; - var dMax = 0.0; - var xMin = 0.0; - var yMin = 0.0; - var xMax = 0.0; - var yMax = 0.0; - for (var i = 0; i < count; i += 2) { - var xD = vertices[i]; - var yD = vertices[i + 1]; - if (xC === xD) { - xC = xD + 0.0001; - } - if (yC === yD) { - yC = yD + 0.0001; - } - var dXCD = xC - xD; - var dYCD = yC - yD; - var llCD = xC * yD - yC * xD; - var ll = dXAB * dYCD - dYAB * dXCD; - var x = (llAB * dXCD - dXAB * llCD) / ll; - if (((x >= xC && x <= xD) || (x >= xD && x <= xC)) && (dXAB === 0.0 || (x >= xA && x <= xB) || (x >= xB && x <= xA))) { - var y = (llAB * dYCD - dYAB * llCD) / ll; - if (((y >= yC && y <= yD) || (y >= yD && y <= yC)) && (dYAB === 0.0 || (y >= yA && y <= yB) || (y >= yB && y <= yA))) { - if (intersectionPointB !== null) { - var d = x - xA; - if (d < 0.0) { - d = -d; - } - if (intersectionCount === 0) { - dMin = d; - dMax = d; - xMin = x; - yMin = y; - xMax = x; - yMax = y; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - normalRadians.y = normalRadians.x; - } - } - else { - if (d < dMin) { - dMin = d; - xMin = x; - yMin = y; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - } - } - if (d > dMax) { - dMax = d; - xMax = x; - yMax = y; - if (normalRadians !== null) { - normalRadians.y = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - } - } - } - intersectionCount++; - } - else { - xMin = x; - yMin = y; - xMax = x; - yMax = y; - intersectionCount++; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - normalRadians.y = normalRadians.x; - } - break; - } - } - } - xC = xD; - yC = yD; - } - if (intersectionCount === 1) { - if (intersectionPointA !== null) { - intersectionPointA.x = xMin; - intersectionPointA.y = yMin; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xMin; - intersectionPointB.y = yMin; - } - if (normalRadians !== null) { - normalRadians.y = normalRadians.x + Math.PI; - } - } - else if (intersectionCount > 1) { - intersectionCount++; - if (intersectionPointA !== null) { - intersectionPointA.x = xMin; - intersectionPointA.y = yMin; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xMax; - intersectionPointB.y = yMax; - } - } - return intersectionCount; - }; - PolygonBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 2 /* Polygon */; - this.x = 0.0; - this.y = 0.0; - this.vertices.length = 0; - }; - /** - * @inheritDoc - */ - PolygonBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var isInSide = false; - if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) { - for (var i = 0, l = this.vertices.length, iP = l - 2; i < l; i += 2) { - var yA = this.vertices[iP + 1]; - var yB = this.vertices[i + 1]; - if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { - var xA = this.vertices[iP]; - var xB = this.vertices[i]; - if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { - isInSide = !isInSide; - } - } - iP = i; - } - } - return isInSide; - }; - /** - * @inheritDoc - */ - PolygonBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var intersectionCount = 0; - if (RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, this.x, this.y, this.x + this.width, this.y + this.height, null, null, null) !== 0) { - intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, intersectionPointA, intersectionPointB, normalRadians); - } - return intersectionCount; - }; - return PolygonBoundingBoxData; - }(BoundingBoxData)); - dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var AnimationData = /** @class */ (function (_super) { - __extends(AnimationData, _super); - function AnimationData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.cachedFrames = []; - /** - * @private - */ - _this.boneTimelines = {}; - /** - * @private - */ - _this.surfaceTimelines = {}; - /** - * @private - */ - _this.slotTimelines = {}; - /** - * @private - */ - _this.constraintTimelines = {}; - /** - * @private - */ - _this.animationTimelines = {}; - /** - * @private - */ - _this.boneCachedFrameIndices = {}; - /** - * @private - */ - _this.slotCachedFrameIndices = {}; - /** - * @private - */ - _this.actionTimeline = null; // Initial value. - /** - * @private - */ - _this.zOrderTimeline = null; // Initial value. - return _this; - } - AnimationData.toString = function () { - return "[class dragonBones.AnimationData]"; - }; - AnimationData.prototype._onClear = function () { - for (var k in this.boneTimelines) { - for (var _i = 0, _a = this.boneTimelines[k]; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.returnToPool(); - } - delete this.boneTimelines[k]; - } - for (var k in this.surfaceTimelines) { - for (var _b = 0, _c = this.surfaceTimelines[k]; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.returnToPool(); - } - delete this.surfaceTimelines[k]; - } - for (var k in this.slotTimelines) { - for (var _d = 0, _e = this.slotTimelines[k]; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.returnToPool(); - } - delete this.slotTimelines[k]; - } - for (var k in this.constraintTimelines) { - for (var _f = 0, _g = this.constraintTimelines[k]; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.returnToPool(); - } - delete this.constraintTimelines[k]; - } - for (var k in this.animationTimelines) { - for (var _h = 0, _j = this.animationTimelines[k]; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.returnToPool(); - } - delete this.animationTimelines[k]; - } - for (var k in this.boneCachedFrameIndices) { - delete this.boneCachedFrameIndices[k]; - } - for (var k in this.slotCachedFrameIndices) { - delete this.slotCachedFrameIndices[k]; - } - if (this.actionTimeline !== null) { - this.actionTimeline.returnToPool(); - } - if (this.zOrderTimeline !== null) { - this.zOrderTimeline.returnToPool(); - } - this.frameIntOffset = 0; - this.frameFloatOffset = 0; - this.frameOffset = 0; - this.frameCount = 0; - this.playTimes = 0; - this.duration = 0.0; - this.scale = 1.0; - this.fadeInTime = 0.0; - this.cacheFrameRate = 0.0; - this.name = ""; - this.cachedFrames.length = 0; - // this.boneTimelines.clear(); - // this.surfaceTimelines.clear(); - // this.slotTimelines.clear(); - // this.constraintTimelines.clear(); - // this.animationTimelines.clear(); - // this.boneCachedFrameIndices.clear(); - // this.slotCachedFrameIndices.clear(); - this.actionTimeline = null; - this.zOrderTimeline = null; - this.parent = null; // - }; - /** - * @internal - */ - AnimationData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0.0) { - return; - } - this.cacheFrameRate = Math.max(Math.ceil(frameRate * this.scale), 1.0); - var cacheFrameCount = Math.ceil(this.cacheFrameRate * this.duration) + 1; // Cache one more frame. - this.cachedFrames.length = cacheFrameCount; - for (var i = 0, l = this.cacheFrames.length; i < l; ++i) { - this.cachedFrames[i] = false; - } - for (var _i = 0, _a = this.parent.sortedBones; _i < _a.length; _i++) { - var bone = _a[_i]; - var indices = new Array(cacheFrameCount); - for (var i = 0, l = indices.length; i < l; ++i) { - indices[i] = -1; - } - this.boneCachedFrameIndices[bone.name] = indices; - } - for (var _b = 0, _c = this.parent.sortedSlots; _b < _c.length; _b++) { - var slot = _c[_b]; - var indices = new Array(cacheFrameCount); - for (var i = 0, l = indices.length; i < l; ++i) { - indices[i] = -1; - } - this.slotCachedFrameIndices[slot.name] = indices; - } - }; - /** - * @private - */ - AnimationData.prototype.addBoneTimeline = function (bone, timeline) { - var timelines = bone.name in this.boneTimelines ? this.boneTimelines[bone.name] : (this.boneTimelines[bone.name] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addSurfaceTimeline = function (surface, timeline) { - var timelines = surface.name in this.surfaceTimelines ? this.surfaceTimelines[surface.name] : (this.surfaceTimelines[surface.name] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addSlotTimeline = function (slot, timeline) { - var timelines = slot.name in this.slotTimelines ? this.slotTimelines[slot.name] : (this.slotTimelines[slot.name] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addConstraintTimeline = function (constraint, timeline) { - var timelines = constraint.name in this.constraintTimelines ? this.constraintTimelines[constraint.name] : (this.constraintTimelines[constraint.name] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addAnimationTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : (this.animationTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.getBoneTimelines = function (timelineName) { - return timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSurfaceTimelines = function (timelineName) { - return timelineName in this.surfaceTimelines ? this.surfaceTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSlotTimelines = function (timelineName) { - return timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getConstraintTimelines = function (timelineName) { - return timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getAnimationTimelines = function (timelineName) { - return timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getBoneCachedFrameIndices = function (boneName) { - return boneName in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[boneName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSlotCachedFrameIndices = function (slotName) { - return slotName in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[slotName] : null; - }; - return AnimationData; - }(dragonBones.BaseObject)); - dragonBones.AnimationData = AnimationData; - /** - * @internal - */ - var TimelineData = /** @class */ (function (_super) { - __extends(TimelineData, _super); - function TimelineData() { - return _super !== null && _super.apply(this, arguments) || this; - } - TimelineData.toString = function () { - return "[class dragonBones.TimelineData]"; - }; - TimelineData.prototype._onClear = function () { - this.type = 10 /* BoneAll */; - this.offset = 0; - this.frameIndicesOffset = -1; - }; - return TimelineData; - }(dragonBones.BaseObject)); - dragonBones.TimelineData = TimelineData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The animation config is used to describe all the information needed to play an animation state. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画配置用来描述播放一个动画状态所需要的全部信息。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - var AnimationConfig = /** @class */ (function (_super) { - __extends(AnimationConfig, _super); - function AnimationConfig() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.boneMask = []; - return _this; - } - AnimationConfig.toString = function () { - return "[class dragonBones.AnimationConfig]"; - }; - AnimationConfig.prototype._onClear = function () { - this.pauseFadeOut = true; - this.fadeOutMode = 4 /* All */; - this.fadeOutTweenType = 1 /* Line */; - this.fadeOutTime = -1.0; - this.actionEnabled = true; - this.additiveBlending = false; - this.displayControl = true; - this.pauseFadeIn = true; - this.resetToPose = true; - this.fadeInTweenType = 1 /* Line */; - this.playTimes = -1; - this.layer = 0; - this.position = 0.0; - this.duration = -1.0; - this.timeScale = -100.0; - this.weight = 1.0; - this.fadeInTime = -1.0; - this.autoFadeOutTime = -1.0; - this.name = ""; - this.animation = ""; - this.group = ""; - this.boneMask.length = 0; - }; - /** - * @private - */ - AnimationConfig.prototype.clear = function () { - this._onClear(); - }; - /** - * @private - */ - AnimationConfig.prototype.copyFrom = function (value) { - this.pauseFadeOut = value.pauseFadeOut; - this.fadeOutMode = value.fadeOutMode; - this.autoFadeOutTime = value.autoFadeOutTime; - this.fadeOutTweenType = value.fadeOutTweenType; - this.actionEnabled = value.actionEnabled; - this.additiveBlending = value.additiveBlending; - this.displayControl = value.displayControl; - this.pauseFadeIn = value.pauseFadeIn; - this.resetToPose = value.resetToPose; - this.playTimes = value.playTimes; - this.layer = value.layer; - this.position = value.position; - this.duration = value.duration; - this.timeScale = value.timeScale; - this.fadeInTime = value.fadeInTime; - this.fadeOutTime = value.fadeOutTime; - this.fadeInTweenType = value.fadeInTweenType; - this.weight = value.weight; - this.name = value.name; - this.animation = value.animation; - this.group = value.group; - this.boneMask.length = value.boneMask.length; - for (var i = 0, l = this.boneMask.length; i < l; ++i) { - this.boneMask[i] = value.boneMask[i]; - } - }; - /** - * @private - */ - AnimationConfig.prototype.containsBoneMask = function (boneName) { - return this.boneMask.length === 0 || this.boneMask.indexOf(boneName) >= 0; - }; - /** - * @private - */ - AnimationConfig.prototype.addBoneMask = function (armature, boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var currentBone = armature.getBone(boneName); - if (currentBone === null) { - return; - } - if (this.boneMask.indexOf(boneName) < 0) { - this.boneMask.push(boneName); - } - if (recursive) { - for (var _i = 0, _a = armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - if (this.boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { - this.boneMask.push(bone.name); - } - } - } - }; - /** - * @private - */ - AnimationConfig.prototype.removeBoneMask = function (armature, boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var index = this.boneMask.indexOf(boneName); - if (index >= 0) { - this.boneMask.splice(index, 1); - } - if (recursive) { - var currentBone = armature.getBone(boneName); - if (currentBone !== null) { - if (this.boneMask.length > 0) { - for (var _i = 0, _a = armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - var index_1 = this.boneMask.indexOf(bone.name); - if (index_1 >= 0 && currentBone.contains(bone)) { - this.boneMask.splice(index_1, 1); - } - } - } - else { - for (var _b = 0, _c = armature.getBones(); _b < _c.length; _b++) { - var bone = _c[_b]; - if (bone === currentBone) { - continue; - } - if (!currentBone.contains(bone)) { - this.boneMask.push(bone.name); - } - } - } - } - } - }; - return AnimationConfig; - }(dragonBones.BaseObject)); - dragonBones.AnimationConfig = AnimationConfig; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var TextureAtlasData = /** @class */ (function (_super) { - __extends(TextureAtlasData, _super); - function TextureAtlasData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.textures = {}; - return _this; - } - TextureAtlasData.prototype._onClear = function () { - for (var k in this.textures) { - this.textures[k].returnToPool(); - delete this.textures[k]; - } - this.autoSearch = false; - this.width = 0; - this.height = 0; - this.scale = 1.0; - // this.textures.clear(); - this.name = ""; - this.imagePath = ""; - }; - /** - * @private - */ - TextureAtlasData.prototype.copyFrom = function (value) { - this.autoSearch = value.autoSearch; - this.scale = value.scale; - this.width = value.width; - this.height = value.height; - this.name = value.name; - this.imagePath = value.imagePath; - for (var k in this.textures) { - this.textures[k].returnToPool(); - delete this.textures[k]; - } - // this.textures.clear(); - for (var k in value.textures) { - var texture = this.createTexture(); - texture.copyFrom(value.textures[k]); - this.textures[k] = texture; - } - }; - /** - * @internal - */ - TextureAtlasData.prototype.addTexture = function (value) { - if (value.name in this.textures) { - console.warn("Same texture: " + value.name); - return; - } - value.parent = this; - this.textures[value.name] = value; - }; - /** - * @private - */ - TextureAtlasData.prototype.getTexture = function (textureName) { - return textureName in this.textures ? this.textures[textureName] : null; - }; - return TextureAtlasData; - }(dragonBones.BaseObject)); - dragonBones.TextureAtlasData = TextureAtlasData; - /** - * @internal - */ - var TextureData = /** @class */ (function (_super) { - __extends(TextureData, _super); - function TextureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.region = new dragonBones.Rectangle(); - _this.frame = null; // Initial value. - return _this; - } - TextureData.createRectangle = function () { - return new dragonBones.Rectangle(); - }; - TextureData.prototype._onClear = function () { - this.rotated = false; - this.name = ""; - this.region.clear(); - this.parent = null; // - this.frame = null; - }; - TextureData.prototype.copyFrom = function (value) { - this.rotated = value.rotated; - this.name = value.name; - this.region.copyFrom(value.region); - this.parent = value.parent; - if (this.frame === null && value.frame !== null) { - this.frame = TextureData.createRectangle(); - } - else if (this.frame !== null && value.frame === null) { - this.frame = null; - } - if (this.frame !== null && value.frame !== null) { - this.frame.copyFrom(value.frame); - } - }; - return TextureData; - }(dragonBones.BaseObject)); - dragonBones.TextureData = TextureData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var DeformVertices = /** @class */ (function (_super) { - __extends(DeformVertices, _super); - function DeformVertices() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.vertices = []; - _this.bones = []; - return _this; - } - DeformVertices.toString = function () { - return "[class dragonBones.DeformVertices]"; - }; - DeformVertices.prototype._onClear = function () { - this.verticesDirty = false; - this.vertices.length = 0; - this.bones.length = 0; - this.verticesData = null; - }; - DeformVertices.prototype.init = function (verticesDataValue, armature) { - this.verticesData = verticesDataValue; - if (this.verticesData !== null) { - var vertexCount = 0; - if (this.verticesData.weight !== null) { - vertexCount = this.verticesData.weight.count * 2; - } - else { - vertexCount = this.verticesData.data.intArray[this.verticesData.offset + 0 /* MeshVertexCount */] * 2; - } - this.verticesDirty = true; - this.vertices.length = vertexCount; - this.bones.length = 0; - // - for (var i = 0, l = this.vertices.length; i < l; ++i) { - this.vertices[i] = 0.0; - } - if (this.verticesData.weight !== null) { - for (var i = 0, l = this.verticesData.weight.bones.length; i < l; ++i) { - var bone = armature.getBone(this.verticesData.weight.bones[i].name); - this.bones.push(bone); - } - } - } - else { - this.verticesDirty = false; - this.vertices.length = 0; - this.bones.length = 0; - this.verticesData = null; - } - }; - DeformVertices.prototype.isBonesUpdate = function () { - for (var _i = 0, _a = this.bones; _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone !== null && bone._childrenTransformDirty) { - return true; - } - } - return false; - }; - return DeformVertices; - }(dragonBones.BaseObject)); - dragonBones.DeformVertices = DeformVertices; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones_1) { - /** - * - Armature is the core of the skeleton animation system. - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架是骨骼动画系统的核心。 - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - var Armature = /** @class */ (function (_super) { - __extends(Armature, _super); - function Armature() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._bones = []; - _this._slots = []; - /** - * @internal - */ - _this._constraints = []; - _this._actions = []; - _this._animation = null; // Initial value. - _this._proxy = null; // Initial value. - /** - * @internal - */ - _this._replaceTextureAtlasData = null; // Initial value. - _this._clock = null; // Initial value. - return _this; - } - Armature.toString = function () { - return "[class dragonBones.Armature]"; - }; - Armature._onSortSlots = function (a, b) { - return a._zOrder > b._zOrder ? 1 : -1; - }; - Armature.prototype._onClear = function () { - if (this._clock !== null) { - this._clock.remove(this); - } - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - bone.returnToPool(); - } - for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { - var slot = _c[_b]; - slot.returnToPool(); - } - for (var _d = 0, _e = this._constraints; _d < _e.length; _d++) { - var constraint = _e[_d]; - constraint.returnToPool(); - } - for (var _f = 0, _g = this._actions; _f < _g.length; _f++) { - var action = _g[_f]; - action.returnToPool(); - } - if (this._animation !== null) { - this._animation.returnToPool(); - } - if (this._proxy !== null) { - this._proxy.dbClear(); - } - if (this._replaceTextureAtlasData !== null) { - this._replaceTextureAtlasData.returnToPool(); - } - this.inheritAnimation = true; - this.userData = null; - this._lockUpdate = false; - this._slotsDirty = true; - this._zOrderDirty = false; - this._flipX = false; - this._flipY = false; - this._cacheFrameIndex = -1; - this._bones.length = 0; - this._slots.length = 0; - this._constraints.length = 0; - this._actions.length = 0; - this._armatureData = null; // - this._animation = null; // - this._proxy = null; // - this._display = null; - this._replaceTextureAtlasData = null; - this._replacedTexture = null; - this._dragonBones = null; // - this._clock = null; - this._parent = null; - }; - /** - * @internal - */ - Armature.prototype._sortZOrder = function (slotIndices, offset) { - var slotDatas = this._armatureData.sortedSlots; - var isOriginal = slotIndices === null; - if (this._zOrderDirty || !isOriginal) { - for (var i = 0, l = slotDatas.length; i < l; ++i) { - var slotIndex = isOriginal ? i : slotIndices[offset + i]; - if (slotIndex < 0 || slotIndex >= l) { - continue; - } - var slotData = slotDatas[slotIndex]; - var slot = this.getSlot(slotData.name); - if (slot !== null) { - slot._setZorder(i); - } - } - this._slotsDirty = true; - this._zOrderDirty = !isOriginal; - } - }; - /** - * @internal - */ - Armature.prototype._addBone = function (value) { - if (this._bones.indexOf(value) < 0) { - this._bones.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._addSlot = function (value) { - if (this._slots.indexOf(value) < 0) { - this._slots.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._addConstraint = function (value) { - if (this._constraints.indexOf(value) < 0) { - this._constraints.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._bufferAction = function (action, append) { - if (this._actions.indexOf(action) < 0) { - if (append) { - this._actions.push(action); - } - else { - this._actions.unshift(action); - } - } - }; - /** - * - Dispose the armature. (Return to the object pool) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 释放骨架。 (回收到对象池) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.dispose = function () { - if (this._armatureData !== null) { - this._lockUpdate = true; - this._dragonBones.bufferObject(this); - } - }; - /** - * @internal - */ - Armature.prototype.init = function (armatureData, proxy, display, dragonBones) { - if (this._armatureData !== null) { - return; - } - this._armatureData = armatureData; - this._animation = dragonBones_1.BaseObject.borrowObject(dragonBones_1.Animation); - this._proxy = proxy; - this._display = display; - this._dragonBones = dragonBones; - this._proxy.dbInit(this); - this._animation.init(this); - this._animation.animations = this._armatureData.animations; - }; - /** - * @inheritDoc - */ - Armature.prototype.advanceTime = function (passedTime) { - if (this._lockUpdate) { - return; - } - if (this._armatureData === null) { - console.warn("The armature has been disposed."); - return; - } - else if (this._armatureData.parent === null) { - console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear()."); - return; - } - var prevCacheFrameIndex = this._cacheFrameIndex; - // Update animation. - this._animation.advanceTime(passedTime); - // Sort slots. - if (this._slotsDirty) { - this._slotsDirty = false; - this._slots.sort(Armature._onSortSlots); - } - // Update bones and slots. - if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== prevCacheFrameIndex) { - var i = 0, l = 0; - for (i = 0, l = this._bones.length; i < l; ++i) { - this._bones[i].update(this._cacheFrameIndex); - } - for (i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i].update(this._cacheFrameIndex); - } - } - // Do actions. - if (this._actions.length > 0) { - this._lockUpdate = true; - for (var _i = 0, _a = this._actions; _i < _a.length; _i++) { - var action = _a[_i]; - var actionData = action.actionData; - if (actionData !== null) { - if (actionData.type === 0 /* Play */) { - if (action.slot !== null) { - var childArmature = action.slot.childArmature; - if (childArmature !== null) { - childArmature.animation.fadeIn(actionData.name); - } - } - else if (action.bone !== null) { - for (var _b = 0, _c = this.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - if (slot.parent === action.bone) { - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.animation.fadeIn(actionData.name); - } - } - } - } - else { - this._animation.fadeIn(actionData.name); - } - } - } - action.returnToPool(); - } - this._actions.length = 0; - this._lockUpdate = false; - } - this._proxy.dbUpdate(); - }; - /** - * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. - * @param boneName - The bone name. (If not set, all bones will be update) - * @param updateSlot - Whether to update the bone's slots. (Default: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 - * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) - * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.invalidUpdate = function (boneName, updateSlot) { - if (boneName === void 0) { boneName = null; } - if (updateSlot === void 0) { updateSlot = false; } - if (boneName !== null && boneName.length > 0) { - var bone = this.getBone(boneName); - if (bone !== null) { - bone.invalidUpdate(); - if (updateSlot) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === bone) { - slot.invalidUpdate(); - } - } - } - } - } - else { - for (var _b = 0, _c = this._bones; _b < _c.length; _b++) { - var bone = _c[_b]; - bone.invalidUpdate(); - } - if (updateSlot) { - for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { - var slot = _e[_d]; - slot.invalidUpdate(); - } - } - } - }; - /** - * - Check whether a specific point is inside a custom bounding box in a slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在某个插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Armature.prototype.containsPoint = function (x, y) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.containsPoint(x, y)) { - return slot; - } - } - return null; - }; - /** - * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Armature.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var isV = xA === xB; - var dMin = 0.0; - var dMax = 0.0; - var intXA = 0.0; - var intYA = 0.0; - var intXB = 0.0; - var intYB = 0.0; - var intAN = 0.0; - var intBN = 0.0; - var intSlotA = null; - var intSlotB = null; - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); - if (intersectionCount > 0) { - if (intersectionPointA !== null || intersectionPointB !== null) { - if (intersectionPointA !== null) { - var d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA; - if (d < 0.0) { - d = -d; - } - if (intSlotA === null || d < dMin) { - dMin = d; - intXA = intersectionPointA.x; - intYA = intersectionPointA.y; - intSlotA = slot; - if (normalRadians) { - intAN = normalRadians.x; - } - } - } - if (intersectionPointB !== null) { - var d = intersectionPointB.x - xA; - if (d < 0.0) { - d = -d; - } - if (intSlotB === null || d > dMax) { - dMax = d; - intXB = intersectionPointB.x; - intYB = intersectionPointB.y; - intSlotB = slot; - if (normalRadians !== null) { - intBN = normalRadians.y; - } - } - } - } - else { - intSlotA = slot; - break; - } - } - } - if (intSlotA !== null && intersectionPointA !== null) { - intersectionPointA.x = intXA; - intersectionPointA.y = intYA; - if (normalRadians !== null) { - normalRadians.x = intAN; - } - } - if (intSlotB !== null && intersectionPointB !== null) { - intersectionPointB.x = intXB; - intersectionPointB.y = intYB; - if (normalRadians !== null) { - normalRadians.y = intBN; - } - } - return intSlotA; - }; - /** - * - Get a specific bone. - * @param name - The bone name. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼。 - * @param name - 骨骼名称。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBone = function (name) { - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone.name === name) { - return bone; - } - } - return null; - }; - /** - * - Get a specific bone by the display. - * @param display - The display object. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的骨骼。 - * @param display - 显示对象。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBoneByDisplay = function (display) { - var slot = this.getSlotByDisplay(display); - return slot !== null ? slot.parent : null; - }; - /** - * - Get a specific slot. - * @param name - The slot name. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽。 - * @param name - 插槽名称。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlot = function (name) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.name === name) { - return slot; - } - } - return null; - }; - /** - * - Get a specific slot by the display. - * @param display - The display object. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的插槽。 - * @param display - 显示对象。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlotByDisplay = function (display) { - if (display !== null) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.display === display) { - return slot; - } - } - } - return null; - }; - /** - * - Get all bones. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBones = function () { - return this._bones; - }; - /** - * - Get all slots. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlots = function () { - return this._slots; - }; - Object.defineProperty(Armature.prototype, "flipX", { - /** - * - Whether to flip the armature horizontally. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架水平翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - get: function () { - return this._flipX; - }, - set: function (value) { - if (this._flipX === value) { - return; - } - this._flipX = value; - this.invalidUpdate(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "flipY", { - /** - * - Whether to flip the armature vertically. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架垂直翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - get: function () { - return this._flipY; - }, - set: function (value) { - if (this._flipY === value) { - return; - } - this._flipY = value; - this.invalidUpdate(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "cacheFrameRate", { - /** - * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. - * There is a certain amount of memory overhead to improve performance by caching animation data in memory. - * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. - * When the animation cache is turned on, some features will fail, such as the offset property of bone. - * @example - *
-             *     armature.cacheFrameRate = 24;
-             * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 - * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 - * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 - * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 - * @example - *
-             *     armature.cacheFrameRate = 24;
-             * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._armatureData.cacheFrameRate; - }, - set: function (value) { - if (this._armatureData.cacheFrameRate !== value) { - this._armatureData.cacheFrames(value); - // Set child armature frameRate. - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.cacheFrameRate = value; - } - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "name", { - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._armatureData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "armatureData", { - /** - * - The armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._armatureData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "animation", { - /** - * - The animation player. - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._animation; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "proxy", { - /** - * @pivate - */ - get: function () { - return this._proxy; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "eventDispatcher", { - /** - * - The EventDispatcher instance of the armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架的 EventDispatcher 实例。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._proxy; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "display", { - /** - * - The display container. - * The display of the slot is displayed as the parent. - * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 显示容器实例。 - * 插槽的显示对象都会以此显示容器为父级。 - * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._display; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "replacedTexture", { - /** - * @private - */ - get: function () { - return this._replacedTexture; - }, - set: function (value) { - if (this._replacedTexture === value) { - return; - } - if (this._replaceTextureAtlasData !== null) { - this._replaceTextureAtlasData.returnToPool(); - this._replaceTextureAtlasData = null; - } - this._replacedTexture = value; - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - slot.invalidUpdate(); - slot.update(-1); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - if (this._clock !== null) { - this._clock.remove(this); - } - this._clock = value; - if (this._clock) { - this._clock.add(this); - } - // Update childArmature clock. - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.clock = this._clock; - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "parent", { - /** - * - Get the parent slot which the armature belongs to. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架所属的父插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * @deprecated - * @private - */ - Armature.prototype.replaceTexture = function (texture) { - this.replacedTexture = texture; - }; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.hasEventListener = function (type) { - console.warn("Deprecated."); - return this._proxy.hasDBEventListener(type); - }; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.addEventListener = function (type, listener, target) { - console.warn("Deprecated."); - this._proxy.addDBEventListener(type, listener, target); - }; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.removeEventListener = function (type, listener, target) { - console.warn("Deprecated."); - this._proxy.removeDBEventListener(type, listener, target); - }; - /** - * - Deprecated, please refer to {@link #cacheFrameRate}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.enableAnimationCache = function (frameRate) { - console.warn("Deprecated."); - this.cacheFrameRate = frameRate; - }; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.getDisplay = function () { - return this._display; - }; - return Armature; - }(dragonBones_1.BaseObject)); - dragonBones_1.Armature = Armature; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The base class of the transform object. - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 变换对象的基类。 - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language zh_CN - */ - var TransformObject = /** @class */ (function (_super) { - __extends(TransformObject, _super); - function TransformObject() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - A matrix relative to the armature coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.globalTransformMatrix = new dragonBones.Matrix(); - /** - * - A transform relative to the armature coordinate system. - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的变换。 - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.global = new dragonBones.Transform(); - /** - * - The offset transform relative to the armature or the parent bone coordinate system. - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架或父骨骼坐标系的偏移变换。 - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.offset = new dragonBones.Transform(); - return _this; - } - /** - */ - TransformObject.prototype._onClear = function () { - this.globalTransformMatrix.identity(); - this.global.identity(); - this.offset.identity(); - this.origin = null; - this.userData = null; - this._globalDirty = false; - this._armature = null; // - }; - /** - * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, - * some engines do not rely on these attributes to update rendering, such as Egret. - * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 - * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - TransformObject.prototype.updateGlobalTransform = function () { - if (this._globalDirty) { - this._globalDirty = false; - this.global.fromMatrix(this.globalTransformMatrix); - } - }; - Object.defineProperty(TransformObject.prototype, "armature", { - /** - * - The armature to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的骨架。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._armature; - }, - enumerable: true, - configurable: true - }); - TransformObject._helpMatrix = new dragonBones.Matrix(); - TransformObject._helpTransform = new dragonBones.Transform(); - TransformObject._helpPoint = new dragonBones.Point(); - return TransformObject; - }(dragonBones.BaseObject)); - dragonBones.TransformObject = TransformObject; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - Bone is one of the most important logical units in the armature animation system, - * and is responsible for the realization of translate, rotation, scaling in the animations. - * A armature can contain multiple bones. - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 - * 一个骨架中可以包含多个骨骼。 - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - var Bone = /** @class */ (function (_super) { - __extends(Bone, _super); - function Bone() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @internal - */ - _this.animationPose = new dragonBones.Transform(); - /** - * @internal - */ - _this._blendState = new dragonBones.BlendState(); - return _this; - } - Bone.toString = function () { - return "[class dragonBones.Bone]"; - }; - Bone.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.offsetMode = 1 /* Additive */; - this.animationPose.identity(); - this._transformDirty = false; - this._childrenTransformDirty = false; - this._localDirty = true; - this._hasConstraint = false; - this._visible = true; - this._cachedFrameIndex = -1; - this._blendState.clear(); - this._boneData = null; // - this._parent = null; // - this._cachedFrameIndices = null; - }; - Bone.prototype._updateGlobalTransformMatrix = function (isCache) { - // For typescript. - var boneData = this._boneData; - var global = this.global; - var globalTransformMatrix = this.globalTransformMatrix; - var origin = this.origin; - var offset = this.offset; - var animationPose = this.animationPose; - var parent = this._parent; // - var flipX = this._armature.flipX; - var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; - var inherit = parent !== null; - var rotation = 0.0; - if (this.offsetMode === 1 /* Additive */) { - if (origin !== null) { - // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); - global.x = origin.x + offset.x + animationPose.x; - global.y = origin.y + offset.y + animationPose.y; - global.skew = origin.skew + offset.skew + animationPose.skew; - global.rotation = origin.rotation + offset.rotation + animationPose.rotation; - global.scaleX = origin.scaleX * offset.scaleX * animationPose.scaleX; - global.scaleY = origin.scaleY * offset.scaleY * animationPose.scaleY; - } - else { - global.copyFrom(offset).add(animationPose); - } - } - else if (this.offsetMode === 0 /* None */) { - if (origin !== null) { - global.copyFrom(origin).add(animationPose); - } - else { - global.copyFrom(animationPose); - } - } - else { - inherit = false; - global.copyFrom(offset); - } - if (inherit) { - var parentMatrix = parent._boneData.type === 0 /* Bone */ ? parent.globalTransformMatrix : parent._getGlobalTransformMatrix(global.x, global.y); - if (boneData.inheritScale) { - if (!boneData.inheritRotation) { - parent.updateGlobalTransform(); - if (flipX && flipY) { - rotation = global.rotation - (parent.global.rotation + Math.PI); - } - else if (flipX) { - rotation = global.rotation + parent.global.rotation + Math.PI; - } - else if (flipY) { - rotation = global.rotation + parent.global.rotation; - } - else { - rotation = global.rotation - parent.global.rotation; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - globalTransformMatrix.concat(parentMatrix); - if (boneData.inheritTranslation) { - global.x = globalTransformMatrix.tx; - global.y = globalTransformMatrix.ty; - } - else { - globalTransformMatrix.tx = global.x; - globalTransformMatrix.ty = global.y; - } - if (isCache) { - global.fromMatrix(globalTransformMatrix); - } - else { - this._globalDirty = true; - } - } - else { - if (boneData.inheritTranslation) { - var x = global.x; - var y = global.y; - global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - global.y = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; - } - else { - if (flipX) { - global.x = -global.x; - } - if (flipY) { - global.y = -global.y; - } - } - if (boneData.inheritRotation) { - parent.updateGlobalTransform(); - if (parent.global.scaleX < 0.0) { - rotation = global.rotation + parent.global.rotation + Math.PI; - } - else { - rotation = global.rotation + parent.global.rotation; - } - if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { - rotation -= global.rotation * 2.0; - if (flipX !== flipY || boneData.inheritReflection) { - global.skew += Math.PI; - } - } - global.rotation = rotation; - } - else if (flipX || flipY) { - if (flipX && flipY) { - rotation = global.rotation + Math.PI; - } - else { - if (flipX) { - rotation = Math.PI - global.rotation; - } - else { - rotation = -global.rotation; - } - global.skew += Math.PI; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - } - } - else { - if (flipX || flipY) { - if (flipX) { - global.x = -global.x; - } - if (flipY) { - global.y = -global.y; - } - if (flipX && flipY) { - rotation = global.rotation + Math.PI; - } - else { - if (flipX) { - rotation = Math.PI - global.rotation; - } - else { - rotation = -global.rotation; - } - global.skew += Math.PI; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - } - }; - /** - * @internal - */ - Bone.prototype.init = function (boneData, armatureValue) { - if (this._boneData !== null) { - return; - } - this._boneData = boneData; - this._armature = armatureValue; - if (this._boneData.parent !== null) { - this._parent = this._armature.getBone(this._boneData.parent.name); - } - this._armature._addBone(this); - // - this.origin = this._boneData.transform; - }; - /** - * @internal - */ - Bone.prototype.update = function (cacheFrameIndex) { - this._blendState.dirty = false; - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else { - if (this._hasConstraint) { - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - } - else { - if (this._hasConstraint) { - for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { - var constraint = _c[_b]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - if (this._transformDirty) { - this._transformDirty = false; - this._childrenTransformDirty = true; - // - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - if (this._localDirty) { - this._updateGlobalTransformMatrix(isCache); - } - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - // - } - else if (this._childrenTransformDirty) { - this._childrenTransformDirty = false; - } - this._localDirty = true; - }; - /** - * @internal - */ - Bone.prototype.updateByConstraint = function () { - if (this._localDirty) { - this._localDirty = false; - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { - this._updateGlobalTransformMatrix(true); - } - this._transformDirty = true; - } - }; - /** - * - Forces the bone to update the transform in the next frame. - * When the bone is not animated or its animation state is finished, the bone will not continue to update, - * and when the skeleton must be updated for some reason, the method needs to be called explicitly. - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制骨骼在下一帧更新变换。 - * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Bone.prototype.invalidUpdate = function () { - this._transformDirty = true; - }; - /** - * - Check whether the bone contains a specific bone. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查该骨骼是否包含特定的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Bone.prototype.contains = function (value) { - if (value === this) { - return false; - } - var ancestor = value; - while (ancestor !== this && ancestor !== null) { - ancestor = ancestor.parent; - } - return ancestor === this; - }; - Object.defineProperty(Bone.prototype, "boneData", { - /** - * - The bone data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._boneData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "visible", { - /** - * - The visible of all slots in the bone. - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 此骨骼所有插槽的可见。 - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible === value) { - return; - } - this._visible = value; - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === this) { - slot._updateVisible(); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "name", { - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._boneData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "parent", { - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getBones()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getBones()}。 - * @deprecated - * @language zh_CN - */ - Bone.prototype.getBones = function () { - console.warn("Deprecated."); - var bones = new Array(); - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone.parent === this) { - bones.push(bone); - } - } - return bones; - }; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getSlots()}。 - * @deprecated - * @language zh_CN - */ - Bone.prototype.getSlots = function () { - console.warn("Deprecated."); - var slots = new Array(); - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === this) { - slots.push(slot); - } - } - return slots; - }; - Object.defineProperty(Bone.prototype, "slot", { - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getSlot()}。 - * @deprecated - * @language zh_CN - */ - get: function () { - console.warn("Deprecated."); - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === this) { - return slot; - } - } - return null; - }, - enumerable: true, - configurable: true - }); - return Bone; - }(dragonBones.TransformObject)); - dragonBones.Bone = Bone; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var Surface = /** @class */ (function (_super) { - __extends(Surface, _super); - function Surface() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._vertices = []; - _this._deformVertices = []; - /** - * - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y - */ - _this._hullCache = []; - /** - * - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] - */ - _this._matrixCahce = []; - return _this; - } - Surface.toString = function () { - return "[class dragonBones.Surface]"; - }; - Surface.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._dX = 0.0; - this._dY = 0.0; - this._k = 0.0; - this._kX = 0.0; - this._kY = 0.0; - this._vertices.length = 0; - this._deformVertices.length = 0; - this._matrixCahce.length = 0; - this._hullCache.length = 0; - }; - Surface.prototype._getAffineTransform = function (x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown) { - var dabX = bX - aX; - var dabY = bY - aY; - var dacX = cX - aX; - var dacY = cY - aY; - transform.rotation = Math.atan2(dabY, dabX); - transform.skew = Math.atan2(dacY, dacX) - Math.PI * 0.5 - transform.rotation; - if (isDown) { - transform.rotation += Math.PI; - } - transform.scaleX = Math.sqrt(dabX * dabX + dabY * dabY) / lX; - transform.scaleY = Math.sqrt(dacX * dacX + dacY * dacY) / lY; - transform.toMatrix(matrix); - transform.x = matrix.tx = aX - (matrix.a * x + matrix.c * y); - transform.y = matrix.ty = aY - (matrix.b * x + matrix.d * y); - }; - Surface.prototype._updateVertices = function () { - var originalVertices = this._boneData.vertices; - var vertices = this._vertices; - var animationVertices = this._deformVertices; - if (this._parent !== null) { - if (this._parent._boneData.type === 1 /* Surface */) { - for (var i = 0, l = originalVertices.length; i < l; i += 2) { - var x = originalVertices[i] + animationVertices[i]; - var y = originalVertices[i + 1] + animationVertices[i]; - var matrix = this._parent._getGlobalTransformMatrix(x, y); - // - vertices[i] = matrix.a * x + matrix.c * y + matrix.tx; - vertices[i + 1] = matrix.b * x + matrix.d * y + matrix.ty; - } - } - else { - var parentMatrix = this._parent.globalTransformMatrix; - for (var i = 0, l = originalVertices.length; i < l; i += 2) { - var x = originalVertices[i] + animationVertices[i]; - var y = originalVertices[i + 1] + animationVertices[i + 1]; - // - vertices[i] = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - vertices[i + 1] = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; - } - } - } - else { - for (var i = 0, l = originalVertices.length; i < l; i += 2) { - vertices[i] = originalVertices[i] + animationVertices[i]; - vertices[i + 1] = originalVertices[i + 1] + animationVertices[i + 1]; - } - } - }; - Surface.prototype._updateGlobalTransformMatrix = function (isCache) { - // tslint:disable-next-line:no-unused-expression - isCache; - var segmentXD = this._boneData.segmentX * 2; - var lastIndex = this._vertices.length - 2; - var lA = 200.0; - // - var raX = this._vertices[0]; - var raY = this._vertices[1]; - var rbX = this._vertices[segmentXD]; - var rbY = this._vertices[segmentXD + 1]; - var rcX = this._vertices[lastIndex]; - var rcY = this._vertices[lastIndex + 1]; - var rdX = this._vertices[lastIndex - segmentXD]; - var rdY = this._vertices[lastIndex - segmentXD + 1]; - // - var dacX = raX + (rcX - raX) * 0.5; - var dacY = raY + (rcY - raY) * 0.5; - var dbdX = rbX + (rdX - rbX) * 0.5; - var dbdY = rbY + (rdY - rbY) * 0.5; - var aX = dacX + (dbdX - dacX) * 0.5; - var aY = dacY + (dbdY - dacY) * 0.5; - var bX = rbX + (rcX - rbX) * 0.5; - var bY = rbY + (rcY - rbY) * 0.5; - var cX = rdX + (rcX - rdX) * 0.5; - var cY = rdY + (rcY - rdY) * 0.5; - // - this._globalDirty = false; - this._getAffineTransform(0.0, 0.0, lA, lA, aX, aY, bX, bY, cX, cY, this.global, this.globalTransformMatrix, false); - }; - Surface.prototype._getGlobalTransformMatrix = function (x, y) { - var lB = 1000.0; - if (x < -lB || lB < x || y < -lB || lB < y) { - return this.globalTransformMatrix; - } - var isDown = false; - var lA = 200.0; - var surfaceData = this._boneData; - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var segmentXD = surfaceData.segmentX * 2; - var dX = this._dX; - var dY = this._dY; - var indexX = Math.floor((x + lA) / dX); // -1 ~ segmentX - 1 - var indexY = Math.floor((y + lA) / dY); // -1 ~ segmentY - 1 - var matrixIndex = 0; - var pX = indexX * dX - lA; - var pY = indexY * dY - lA; - var matrices = this._matrixCahce; - var helpMatrix = Surface._helpMatrix; - if (x < -lA) { - if (y < -lA || y >= lA) { - return this.globalTransformMatrix; - } - // Left. - isDown = y > this._kX * (x + lA) + pY; - matrixIndex = ((segmentX * (segmentY + 1) + segmentX * 2 + segmentY + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (this._matrixCahce[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexY * (segmentXD + 2); - var ddX = this._hullCache[4]; - var ddY = this._hullCache[5]; - var sX = this._hullCache[2] - (segmentY - indexY) * ddX; - var sY = this._hullCache[3] - (segmentY - indexY) * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(-lA, pY + dY, lB - lA, dY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(-lB, pY, lB - lA, dY, sX, sY, vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (x >= lA) { - if (y < -lA || y >= lA) { - return this.globalTransformMatrix; - } - // Right. - isDown = y > this._kX * (x - lB) + pY; - matrixIndex = ((segmentX * (segmentY + 1) + segmentX + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (this._matrixCahce[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = (indexY + 1) * (segmentXD + 2) - 2; - var ddX = this._hullCache[4]; - var ddY = this._hullCache[5]; - var sX = this._hullCache[0] + indexY * ddX; - var sY = this._hullCache[1] + indexY * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(lB, pY + dY, lB - lA, dY, sX + ddX, sY + ddY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX, sY, Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(lA, pY, lB - lA, dY, vertices[vertexIndex], vertices[vertexIndex + 1], sX, sY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (y < -lA) { - if (x < -lA || x >= lA) { - return this.globalTransformMatrix; - } - // Up. - isDown = y > this._kY * (x - pX - dX) - lB; - matrixIndex = (segmentX * (segmentY + 1) + indexX * 2 + (isDown ? 1 : 0)) * 7; - if (this._matrixCahce[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexX * 2; - var ddX = this._hullCache[10]; - var ddY = this._hullCache[11]; - var sX = this._hullCache[8] + indexX * ddX; - var sY = this._hullCache[9] + indexX * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, -lA, dX, lB - lA, vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, -lB, dX, lB - lA, sX, sY, sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (y >= lA) { - if (x < -lA || x >= lA) { - return this.globalTransformMatrix; - } - // Down - isDown = y > this._kY * (x - pX - dX) + lA; - matrixIndex = ((segmentX * (segmentY + 1) + segmentX + segmentY + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (this._matrixCahce[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = segmentY * (segmentXD + 2) + indexX * 2; - var ddX = this._hullCache[10]; - var ddY = this._hullCache[11]; - var sX = this._hullCache[6] - (segmentX - indexX) * ddX; - var sY = this._hullCache[7] - (segmentX - indexX) * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, lB, dX, lB - lA, sX + ddX, sY + ddY, sX, sY, vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, lA, dX, lB - lA, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], sX, sY, Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else { - isDown = y > this._k * (x - pX - dX) + pY; - matrixIndex = ((segmentX * indexY + indexX) * 2 + (isDown ? 1 : 0)) * 7; - if (this._matrixCahce[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexX * 2 + indexY * (segmentXD + 2); - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, pY + dY, dX, dY, vertices[vertexIndex + segmentXD + 4], vertices[vertexIndex + segmentXD + 5], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, pY, dX, dY, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - return helpMatrix; - }; - /** - * @internal - * @private - */ - Surface.prototype.init = function (surfaceData, armatureValue) { - if (this._boneData !== null) { - return; - } - _super.prototype.init.call(this, surfaceData, armatureValue); - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var vertexCount = surfaceData.vertices.length; - var lB = 1000.0; - var lA = 200.0; - // - this._dX = lA * 2.0 / segmentX; - this._dY = lA * 2.0 / segmentY; - this._k = -this._dY / this._dX; - this._kX = -this._dY / (lB - lA); - this._kY = -(lB - lA) / this._dX; - this._vertices.length = vertexCount; - this._deformVertices.length = vertexCount; - this._matrixCahce.length = (segmentX * segmentY + segmentX * 2 + segmentY * 2) * 2 * 7; - this._hullCache.length = 10; - for (var i = 0; i < vertexCount; ++i) { - this._deformVertices[i] = 0.0; - } - }; - /** - * @internal - */ - Surface.prototype.update = function (cacheFrameIndex) { - this._blendState.dirty = false; - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else { - if (this._hasConstraint) { - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - } - else { - if (this._hasConstraint) { - for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { - var constraint = _c[_b]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - if (this._transformDirty) { - this._transformDirty = false; - this._childrenTransformDirty = true; - // - for (var i = 0, l = this._matrixCahce.length; i < l; i += 7) { - this._matrixCahce[i] = -1.0; - } - // - this._updateVertices(); - // - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - if (this._localDirty) { - this._updateGlobalTransformMatrix(isCache); - } - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - // Update hull vertices. - var lB = 1000.0; - var lA = 200.0; - var ddX = 2 * this.global.x; - var ddY = 2 * this.global.y; - // - var helpPoint = Surface._helpPoint; - this.globalTransformMatrix.transformPoint(lB, -lA, helpPoint); - this._hullCache[0] = helpPoint.x; - this._hullCache[1] = helpPoint.y; - this._hullCache[2] = ddX - helpPoint.x; - this._hullCache[3] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint(0.0, this._dY, helpPoint, true); - this._hullCache[4] = helpPoint.x; - this._hullCache[5] = helpPoint.y; - // - this.globalTransformMatrix.transformPoint(lA, lB, helpPoint); - this._hullCache[6] = helpPoint.x; - this._hullCache[7] = helpPoint.y; - this._hullCache[8] = ddX - helpPoint.x; - this._hullCache[9] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint(this._dX, 0.0, helpPoint, true); - this._hullCache[10] = helpPoint.x; - this._hullCache[11] = helpPoint.y; - } - else if (this._childrenTransformDirty) { - this._childrenTransformDirty = false; - } - this._localDirty = true; - }; - return Surface; - }(dragonBones.Bone)); - dragonBones.Surface = Surface; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The slot attached to the armature, controls the display status and properties of the display object. - * A bone can contain multiple slots. - * A slot can contain multiple display objects, displaying only one of the display objects at a time, - * but you can toggle the display object into frame animation while the animation is playing. - * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, - * and a custom other display object. - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 - * 一个骨骼上可以包含多个插槽。 - * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 - * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language zh_CN - */ - var Slot = /** @class */ (function (_super) { - __extends(Slot, _super); - function Slot() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._localMatrix = new dragonBones.Matrix(); - /** - * @internal - */ - _this._colorTransform = new dragonBones.ColorTransform(); - _this._displayDatas = []; - _this._displayList = []; - /** - * @internal - */ - _this._deformVertices = null; - _this._rawDisplay = null; // Initial value. - _this._meshDisplay = null; // Initial value. - return _this; - } - Slot.prototype._onClear = function () { - _super.prototype._onClear.call(this); - var disposeDisplayList = []; - for (var _i = 0, _a = this._displayList; _i < _a.length; _i++) { - var eachDisplay = _a[_i]; - if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && - disposeDisplayList.indexOf(eachDisplay) < 0) { - disposeDisplayList.push(eachDisplay); - } - } - for (var _b = 0, disposeDisplayList_1 = disposeDisplayList; _b < disposeDisplayList_1.length; _b++) { - var eachDisplay = disposeDisplayList_1[_b]; - if (eachDisplay instanceof dragonBones.Armature) { - eachDisplay.dispose(); - } - else { - this._disposeDisplay(eachDisplay, true); - } - } - if (this._deformVertices !== null) { - this._deformVertices.returnToPool(); - } - if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { - this._disposeDisplay(this._meshDisplay, false); - } - if (this._rawDisplay !== null) { - this._disposeDisplay(this._rawDisplay, false); - } - this.displayController = null; - this._displayDirty = false; - this._zOrderDirty = false; - this._blendModeDirty = false; - this._colorDirty = false; - this._transformDirty = false; - this._visible = true; - this._blendMode = 0 /* Normal */; - this._displayIndex = -1; - this._animationDisplayIndex = -1; - this._zOrder = 0; - this._cachedFrameIndex = -1; - this._pivotX = 0.0; - this._pivotY = 0.0; - this._localMatrix.identity(); - this._colorTransform.identity(); - this._displayList.length = 0; - this._displayDatas.length = 0; - this._slotData = null; // - this._rawDisplayDatas = null; - this._displayData = null; - this._boundingBoxData = null; - this._textureData = null; - this._deformVertices = null; - this._rawDisplay = null; - this._meshDisplay = null; - this._display = null; - this._childArmature = null; - this._parent = null; // - this._cachedFrameIndices = null; - }; - /** - * - Support default skin data. - */ - Slot.prototype._getDefaultRawDisplayData = function (displayIndex) { - var defaultSkin = this._armature._armatureData.defaultSkin; - if (defaultSkin !== null) { - var defaultRawDisplayDatas = defaultSkin.getDisplays(this._slotData.name); - if (defaultRawDisplayDatas !== null) { - return displayIndex < defaultRawDisplayDatas.length ? defaultRawDisplayDatas[displayIndex] : null; - } - } - return null; - }; - Slot.prototype._updateDisplayData = function () { - var prevDisplayData = this._displayData; - var prevVerticesData = this._deformVertices !== null ? this._deformVertices.verticesData : null; - var prevTextureData = this._textureData; - var rawDisplayData = null; - var currentVerticesData = null; - this._displayData = null; - this._boundingBoxData = null; - this._textureData = null; - if (this._displayIndex >= 0) { - if (this._rawDisplayDatas !== null) { - rawDisplayData = this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; - } - if (rawDisplayData === null) { - rawDisplayData = this._getDefaultRawDisplayData(this._displayIndex); - } - if (this._displayIndex < this._displayDatas.length) { - this._displayData = this._displayDatas[this._displayIndex]; - } - } - if (this._displayData !== null) { - if (this._displayData.type === 2 /* Mesh */) { - currentVerticesData = this._displayData.vertices; - } - else if (this._displayData.type === 4 /* Path */) { - currentVerticesData = this._displayData.vertices; - } - else if (rawDisplayData !== null) { - if (rawDisplayData.type === 2 /* Mesh */) { - currentVerticesData = rawDisplayData.vertices; - } - else if (rawDisplayData.type === 4 /* Path */) { - currentVerticesData = rawDisplayData.vertices; - } - } - if (this._displayData.type === 3 /* BoundingBox */) { - this._boundingBoxData = this._displayData.boundingBox; - } - else if (rawDisplayData !== null) { - if (rawDisplayData.type === 3 /* BoundingBox */) { - this._boundingBoxData = rawDisplayData.boundingBox; - } - } - if (this._displayData.type === 0 /* Image */) { - this._textureData = this._displayData.texture; - } - else if (this._displayData.type === 2 /* Mesh */) { - this._textureData = this._displayData.texture; - } - } - if (this._displayData !== prevDisplayData || currentVerticesData !== prevVerticesData || this._textureData !== prevTextureData) { - // Update pivot offset. - if (currentVerticesData === null && this._textureData !== null) { - var imageDisplayData = this._displayData; - var scale = this._textureData.parent.scale * this._armature._armatureData.scale; - var frame = this._textureData.frame; - this._pivotX = imageDisplayData.pivot.x; - this._pivotY = imageDisplayData.pivot.y; - var rect = frame !== null ? frame : this._textureData.region; - var width = rect.width; - var height = rect.height; - if (this._textureData.rotated && frame === null) { - width = rect.height; - height = rect.width; - } - this._pivotX *= width * scale; - this._pivotY *= height * scale; - if (frame !== null) { - this._pivotX += frame.x * scale; - this._pivotY += frame.y * scale; - } - // Update replace pivot. TODO - if (this._displayData !== null && rawDisplayData !== null && this._displayData !== rawDisplayData) { - rawDisplayData.transform.toMatrix(Slot._helpMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); - this._pivotX -= Slot._helpPoint.x; - this._pivotY -= Slot._helpPoint.y; - this._displayData.transform.toMatrix(Slot._helpMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); - this._pivotX += Slot._helpPoint.x; - this._pivotY += Slot._helpPoint.y; - } - if (!dragonBones.DragonBones.yDown) { - this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY; - } - } - else { - this._pivotX = 0.0; - this._pivotY = 0.0; - } - // Update original transform. - if (rawDisplayData !== null) { - this.origin = rawDisplayData.transform; - } - else if (this._displayData !== null) { - this.origin = this._displayData.transform; - } - else { - this.origin = null; - } - // Update vertices. - if (currentVerticesData !== prevVerticesData) { - if (this._deformVertices === null) { - this._deformVertices = dragonBones.BaseObject.borrowObject(dragonBones.DeformVertices); - } - this._deformVertices.init(currentVerticesData, this._armature); - } - else if (this._deformVertices !== null && this._textureData !== prevTextureData) { - this._deformVertices.verticesDirty = true; - } - this._displayDirty = true; - this._transformDirty = true; - } - }; - Slot.prototype._updateDisplay = function () { - var prevDisplay = this._display !== null ? this._display : this._rawDisplay; - var prevChildArmature = this._childArmature; - // Update display and child armature. - if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { - this._display = this._displayList[this._displayIndex]; - if (this._display !== null && this._display instanceof dragonBones.Armature) { - this._childArmature = this._display; - this._display = this._childArmature.display; - } - else { - this._childArmature = null; - } - } - else { - this._display = null; - this._childArmature = null; - } - // Update display. - var currentDisplay = this._display !== null ? this._display : this._rawDisplay; - if (currentDisplay !== prevDisplay) { - this._onUpdateDisplay(); - this._replaceDisplay(prevDisplay); - this._transformDirty = true; - this._visibleDirty = true; - this._blendModeDirty = true; - this._colorDirty = true; - } - // Update frame. - if (currentDisplay === this._rawDisplay || currentDisplay === this._meshDisplay) { - this._updateFrame(); - } - // Update child armature. - if (this._childArmature !== prevChildArmature) { - if (prevChildArmature !== null) { - prevChildArmature._parent = null; // Update child armature parent. - prevChildArmature.clock = null; - if (prevChildArmature.inheritAnimation) { - prevChildArmature.animation.reset(); - } - } - if (this._childArmature !== null) { - this._childArmature._parent = this; // Update child armature parent. - this._childArmature.clock = this._armature.clock; - if (this._childArmature.inheritAnimation) { - if (this._childArmature.cacheFrameRate === 0) { - var cacheFrameRate = this._armature.cacheFrameRate; - if (cacheFrameRate !== 0) { - this._childArmature.cacheFrameRate = cacheFrameRate; - } - } - // Child armature action. - var actions = null; - if (this._displayData !== null && this._displayData.type === 1 /* Armature */) { - actions = this._displayData.actions; - } - else if (this._displayIndex >= 0 && this._rawDisplayDatas !== null) { - var rawDisplayData = this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; - if (rawDisplayData === null) { - rawDisplayData = this._getDefaultRawDisplayData(this._displayIndex); - } - if (rawDisplayData !== null && rawDisplayData.type === 1 /* Armature */) { - actions = rawDisplayData.actions; - } - } - if (actions !== null && actions.length > 0) { - for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { - var action = actions_1[_i]; - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - eventObject.slot = this; - this._armature._bufferAction(eventObject, false); - } - } - else { - this._childArmature.animation.play(); - } - } - } - } - }; - Slot.prototype._updateGlobalTransformMatrix = function (isCache) { - var parentMatrix = this._parent._boneData.type === 0 /* Bone */ ? this._parent.globalTransformMatrix : this._parent._getGlobalTransformMatrix(this.global.x, this.global.y); - this.globalTransformMatrix.copyFrom(this._localMatrix); - this.globalTransformMatrix.concat(parentMatrix); - if (isCache) { - this.global.fromMatrix(this.globalTransformMatrix); - } - else { - this._globalDirty = true; - } - }; - /** - * @internal - */ - Slot.prototype._setDisplayIndex = function (value, isAnimation) { - if (isAnimation === void 0) { isAnimation = false; } - if (isAnimation) { - if (this._animationDisplayIndex === value) { - return false; - } - this._animationDisplayIndex = value; - } - if (this._displayIndex === value) { - return false; - } - this._displayIndex = value; - this._displayDirty = true; - this._updateDisplayData(); - return this._displayDirty; - }; - /** - * @internal - */ - Slot.prototype._setZorder = function (value) { - if (this._zOrder === value) { - //return false; - } - this._zOrder = value; - this._zOrderDirty = true; - return this._zOrderDirty; - }; - /** - * @internal - */ - Slot.prototype._setColor = function (value) { - this._colorTransform.copyFrom(value); - this._colorDirty = true; - return this._colorDirty; - }; - /** - * @internal - */ - Slot.prototype._setDisplayList = function (value) { - if (value !== null && value.length > 0) { - if (this._displayList.length !== value.length) { - this._displayList.length = value.length; - } - for (var i = 0, l = value.length; i < l; ++i) { - var eachDisplay = value[i]; - if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && - !(eachDisplay instanceof dragonBones.Armature) && this._displayList.indexOf(eachDisplay) < 0) { - this._initDisplay(eachDisplay, true); - } - this._displayList[i] = eachDisplay; - } - } - else if (this._displayList.length > 0) { - this._displayList.length = 0; - } - if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { - this._displayDirty = this._display !== this._displayList[this._displayIndex]; - } - else { - this._displayDirty = this._display !== null; - } - this._updateDisplayData(); - return this._displayDirty; - }; - /** - * @internal - */ - Slot.prototype.init = function (slotData, armatureValue, rawDisplay, meshDisplay) { - if (this._slotData !== null) { - return; - } - this._slotData = slotData; - // - this._visibleDirty = true; - this._blendModeDirty = true; - this._colorDirty = true; - this._blendMode = this._slotData.blendMode; - this._zOrder = this._slotData.zOrder; - this._colorTransform.copyFrom(this._slotData.color); - this._rawDisplay = rawDisplay; - this._meshDisplay = meshDisplay; - // - this._armature = armatureValue; - // - var slotParent = this._armature.getBone(this._slotData.parent.name); - if (slotParent !== null) { - this._parent = slotParent; - } - else { - // Never; - } - this._armature._addSlot(this); - // - this._initDisplay(this._rawDisplay, false); - if (this._rawDisplay !== this._meshDisplay) { - this._initDisplay(this._meshDisplay, false); - } - this._onUpdateDisplay(); - this._addDisplay(); - }; - /** - * @internal - */ - Slot.prototype.update = function (cacheFrameIndex) { - if (this._displayDirty) { - this._displayDirty = false; - this._updateDisplay(); - // TODO remove slot offset. - if (this._transformDirty) { - if (this.origin !== null) { - this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); - } - else { - this.global.copyFrom(this.offset).toMatrix(this._localMatrix); - } - } - } - if (this._zOrderDirty) { - this._zOrderDirty = false; - this._updateZOrder(); - } - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else if (this._transformDirty || this._parent._childrenTransformDirty) { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - else if (this._transformDirty || this._parent._childrenTransformDirty) { - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - if (this._display === null) { - return; - } - if (this._visibleDirty) { - this._visibleDirty = false; - this._updateVisible(); - } - if (this._blendModeDirty) { - this._blendModeDirty = false; - this._updateBlendMode(); - } - if (this._colorDirty) { - this._colorDirty = false; - this._updateColor(); - } - if (this._deformVertices !== null && this._deformVertices.verticesData !== null && this._display === this._meshDisplay) { - var isSkinned = this._deformVertices.verticesData.weight !== null; - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - if (this._deformVertices.verticesDirty || - (isSkinned && this._deformVertices.isBonesUpdate()) || - (isSurface && this._parent._childrenTransformDirty)) { - this._deformVertices.verticesDirty = false; - this._updateMesh(); - } - if (isSkinned || isSurface) { - return; - } - } - if (this._transformDirty) { - this._transformDirty = false; - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - this._updateGlobalTransformMatrix(isCache); - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - this._updateTransform(); - } - }; - /** - * @private - */ - Slot.prototype.updateTransformAndMatrix = function () { - if (this._transformDirty) { - this._transformDirty = false; - this._updateGlobalTransformMatrix(false); - } - }; - /** - * @private - */ - Slot.prototype.replaceDisplayData = function (value, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - if (displayIndex < 0) { - if (this._displayIndex < 0) { - displayIndex = 0; - } - else { - displayIndex = this._displayIndex; - } - } - if (this._displayDatas.length <= displayIndex) { - this._displayDatas.length = displayIndex + 1; - for (var i = 0, l = this._displayDatas.length; i < l; ++i) { - if (!this._displayDatas[i]) { - this._displayDatas[i] = null; - } - } - } - this._displayDatas[displayIndex] = value; - }; - /** - * - Check whether a specific point is inside a custom bounding box in the slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Slot.prototype.containsPoint = function (x, y) { - if (this._boundingBoxData === null) { - return false; - } - this.updateTransformAndMatrix(); - Slot._helpMatrix.copyFrom(this.globalTransformMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(x, y, Slot._helpPoint); - return this._boundingBoxData.containsPoint(Slot._helpPoint.x, Slot._helpPoint.y); - }; - /** - * - Check whether a specific segment intersects a custom bounding box for the slot. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] - * @version DragonBones 5.0 - * @language zh_CN - */ - Slot.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - if (this._boundingBoxData === null) { - return 0; - } - this.updateTransformAndMatrix(); - Slot._helpMatrix.copyFrom(this.globalTransformMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(xA, yA, Slot._helpPoint); - xA = Slot._helpPoint.x; - yA = Slot._helpPoint.y; - Slot._helpMatrix.transformPoint(xB, yB, Slot._helpPoint); - xB = Slot._helpPoint.x; - yB = Slot._helpPoint.y; - var intersectionCount = this._boundingBoxData.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); - if (intersectionCount > 0) { - if (intersectionCount === 1 || intersectionCount === 2) { - if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); - if (intersectionPointB !== null) { - intersectionPointB.x = intersectionPointA.x; - intersectionPointB.y = intersectionPointA.y; - } - } - else if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); - } - } - else { - if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); - } - if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); - } - } - if (normalRadians !== null) { - this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.x), Math.sin(normalRadians.x), Slot._helpPoint, true); - normalRadians.x = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); - this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.y), Math.sin(normalRadians.y), Slot._helpPoint, true); - normalRadians.y = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); - } - } - return intersectionCount; - }; - /** - * - Forces the slot to update the state of the display object in the next frame. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 强制插槽在下一帧更新显示对象的状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Slot.prototype.invalidUpdate = function () { - this._displayDirty = true; - this._transformDirty = true; - }; - Object.defineProperty(Slot.prototype, "visible", { - /** - * - The visible of slot's display object. - * @default true - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 插槽的显示对象的可见。 - * @default true - * @version DragonBones 5.6 - * @language zh_CN - */ - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible === value) { - return; - } - this._visible = value; - this._updateVisible(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayIndex", { - /** - * - The index of the display object displayed in the display list. - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     slot.displayIndex = 3;
-             *     slot.displayController = "none";
-             * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 此时显示的显示对象在显示列表中的索引。 - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     slot.displayIndex = 3;
-             *     slot.displayController = "none";
-             * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._displayIndex; - }, - set: function (value) { - if (this._setDisplayIndex(value)) { - this.update(-1); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "name", { - /** - * - The slot name. - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._slotData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayList", { - /** - * - Contains a display list of display objects or child armatures. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 包含显示对象或子骨架的显示列表。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._displayList.concat(); - }, - set: function (value) { - var backupDisplayList = this._displayList.concat(); // Copy. - var disposeDisplayList = new Array(); - if (this._setDisplayList(value)) { - this.update(-1); - } - // Release replaced displays. - for (var _i = 0, backupDisplayList_1 = backupDisplayList; _i < backupDisplayList_1.length; _i++) { - var eachDisplay = backupDisplayList_1[_i]; - if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && - this._displayList.indexOf(eachDisplay) < 0 && - disposeDisplayList.indexOf(eachDisplay) < 0) { - disposeDisplayList.push(eachDisplay); - } - } - for (var _a = 0, disposeDisplayList_2 = disposeDisplayList; _a < disposeDisplayList_2.length; _a++) { - var eachDisplay = disposeDisplayList_2[_a]; - if (eachDisplay instanceof dragonBones.Armature) { - // (eachDisplay as Armature).dispose(); - } - else { - this._disposeDisplay(eachDisplay, true); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "slotData", { - /** - * - The slot data. - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 插槽数据。 - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._slotData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "rawDisplayDatas", { - /** - * @private - */ - get: function () { - return this._rawDisplayDatas; - }, - set: function (value) { - if (this._rawDisplayDatas === value) { - return; - } - this._displayDirty = true; - this._rawDisplayDatas = value; - if (this._rawDisplayDatas !== null) { - this._displayDatas.length = this._rawDisplayDatas.length; - for (var i = 0, l = this._displayDatas.length; i < l; ++i) { - var rawDisplayData = this._rawDisplayDatas[i]; - if (rawDisplayData === null) { - rawDisplayData = this._getDefaultRawDisplayData(i); - } - this._displayDatas[i] = rawDisplayData; - } - } - else { - this._displayDatas.length = 0; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayData", { - /** - * @private - */ - get: function () { - return this._displayData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "boundingBoxData", { - /** - * - The custom bounding box data for the slot at current time. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 插槽此时的自定义包围盒数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - get: function () { - return this._boundingBoxData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "rawDisplay", { - /** - * @private - */ - get: function () { - return this._rawDisplay; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "meshDisplay", { - /** - * @private - */ - get: function () { - return this._meshDisplay; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "display", { - /** - * - The display object that the slot displays at this time. - * @example - *
-             *     let slot = armature.getSlot("text");
-             *     slot.display = new yourEngine.TextField();
-             * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的显示对象。 - * @example - *
-             *     let slot = armature.getSlot("text");
-             *     slot.display = new yourEngine.TextField();
-             * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._display; - }, - set: function (value) { - if (this._display === value) { - return; - } - var displayListLength = this._displayList.length; - if (this._displayIndex < 0 && displayListLength === 0) { - this._displayIndex = 0; - } - if (this._displayIndex < 0) { - return; - } - else { - var replaceDisplayList = this.displayList; // Copy. - if (displayListLength <= this._displayIndex) { - replaceDisplayList.length = this._displayIndex + 1; - } - replaceDisplayList[this._displayIndex] = value; - this.displayList = replaceDisplayList; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "childArmature", { - /** - * - The child armature that the slot displayed at current time. - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             * let prevChildArmature = slot.childArmature;
-             * if (prevChildArmature) {
-             * prevChildArmature.dispose();
-             *     }
-             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-             * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的子骨架。 - * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             * let prevChildArmature = slot.childArmature;
-             * if (prevChildArmature) {
-             * prevChildArmature.dispose();
-             *     }
-             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-             * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._childArmature; - }, - set: function (value) { - if (this._childArmature === value) { - return; - } - this.display = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "parent", { - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Slot.prototype.getDisplay = function () { - return this._display; - }; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Slot.prototype.setDisplay = function (value) { - this.display = value; - }; - return Slot; - }(dragonBones.TransformObject)); - dragonBones.Slot = Slot; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var Constraint = /** @class */ (function (_super) { - __extends(Constraint, _super); - function Constraint() { - return _super !== null && _super.apply(this, arguments) || this; - } - Constraint.prototype._onClear = function () { - this._armature = null; // - this._target = null; // - this._root = null; // - this._bone = null; - }; - Object.defineProperty(Constraint.prototype, "name", { - get: function () { - return this._constraintData.name; - }, - enumerable: true, - configurable: true - }); - Constraint._helpMatrix = new dragonBones.Matrix(); - Constraint._helpTransform = new dragonBones.Transform(); - Constraint._helpPoint = new dragonBones.Point(); - return Constraint; - }(dragonBones.BaseObject)); - dragonBones.Constraint = Constraint; - /** - * @internal - */ - var IKConstraint = /** @class */ (function (_super) { - __extends(IKConstraint, _super); - function IKConstraint() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraint.toString = function () { - return "[class dragonBones.IKConstraint]"; - }; - IKConstraint.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._scaleEnabled = false; - this._bendPositive = false; - this._weight = 1.0; - this._constraintData = null; - }; - IKConstraint.prototype._computeA = function () { - var ikGlobal = this._target.global; - var global = this._root.global; - var globalTransformMatrix = this._root.globalTransformMatrix; - var radian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); - if (global.scaleX < 0.0) { - radian += Math.PI; - } - global.rotation += dragonBones.Transform.normalizeRadian(radian - global.rotation) * this._weight; - global.toMatrix(globalTransformMatrix); - }; - IKConstraint.prototype._computeB = function () { - var boneLength = this._bone._boneData.length; - var parent = this._root; - var ikGlobal = this._target.global; - var parentGlobal = parent.global; - var global = this._bone.global; - var globalTransformMatrix = this._bone.globalTransformMatrix; - var x = globalTransformMatrix.a * boneLength; - var y = globalTransformMatrix.b * boneLength; - var lLL = x * x + y * y; - var lL = Math.sqrt(lLL); - var dX = global.x - parentGlobal.x; - var dY = global.y - parentGlobal.y; - var lPP = dX * dX + dY * dY; - var lP = Math.sqrt(lPP); - var rawRadian = global.rotation; - var rawParentRadian = parentGlobal.rotation; - var rawRadianA = Math.atan2(dY, dX); - dX = ikGlobal.x - parentGlobal.x; - dY = ikGlobal.y - parentGlobal.y; - var lTT = dX * dX + dY * dY; - var lT = Math.sqrt(lTT); - var radianA = 0.0; - if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { - radianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); - if (lL + lP <= lT) { - } - else if (lP < lL) { - radianA += Math.PI; - } - } - else { - var h = (lPP - lLL + lTT) / (2.0 * lTT); - var r = Math.sqrt(lPP - h * h * lTT) / lT; - var hX = parentGlobal.x + (dX * h); - var hY = parentGlobal.y + (dY * h); - var rX = -dY * r; - var rY = dX * r; - var isPPR = false; - var parentParent = parent.parent; - if (parentParent !== null) { - var parentParentMatrix = parentParent.globalTransformMatrix; - isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0.0; - } - if (isPPR !== this._bendPositive) { - global.x = hX - rX; - global.y = hY - rY; - } - else { - global.x = hX + rX; - global.y = hY + rY; - } - radianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); - } - var dR = dragonBones.Transform.normalizeRadian(radianA - rawRadianA); - parentGlobal.rotation = rawParentRadian + dR * this._weight; - parentGlobal.toMatrix(parent.globalTransformMatrix); - // - var currentRadianA = rawRadianA + dR * this._weight; - global.x = parentGlobal.x + Math.cos(currentRadianA) * lP; - global.y = parentGlobal.y + Math.sin(currentRadianA) * lP; - // - var radianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); - if (global.scaleX < 0.0) { - radianB += Math.PI; - } - global.rotation = parentGlobal.rotation + rawRadian - rawParentRadian + dragonBones.Transform.normalizeRadian(radianB - dR - rawRadian) * this._weight; - global.toMatrix(globalTransformMatrix); - }; - IKConstraint.prototype.init = function (constraintData, armature) { - if (this._constraintData !== null) { - return; - } - this._constraintData = constraintData; - this._armature = armature; - this._target = this._armature.getBone(this._constraintData.target.name); - this._root = this._armature.getBone(this._constraintData.root.name); - this._bone = this._constraintData.bone !== null ? this._armature.getBone(this._constraintData.bone.name) : null; - { - var ikConstraintData = this._constraintData; - this._scaleEnabled = ikConstraintData.scaleEnabled; - this._bendPositive = ikConstraintData.bendPositive; - this._weight = ikConstraintData.weight; - } - this._root._hasConstraint = true; - }; - IKConstraint.prototype.update = function () { - this._root.updateByConstraint(); - if (this._bone !== null) { - this._bone.updateByConstraint(); - this._computeB(); - } - else { - this._computeA(); - } - }; - IKConstraint.prototype.invalidUpdate = function () { - this._root.invalidUpdate(); - if (this._bone !== null) { - this._bone.invalidUpdate(); - } - }; - return IKConstraint; - }(Constraint)); - dragonBones.IKConstraint = IKConstraint; - /** - * @internal - */ - var PathConstraint = /** @class */ (function (_super) { - __extends(PathConstraint, _super); - function PathConstraint() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._bones = []; - _this._spaces = []; - _this._positions = []; - _this._curves = []; - _this._boneLengths = []; - _this._pathGlobalVertices = []; - _this._segments = [10]; - return _this; - } - PathConstraint.toString = function () { - return "[class dragonBones.PathConstraint]"; - }; - PathConstraint.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.dirty = false; - this.pathOffset = 0; - this.position = 0.0; - this.spacing = 0.0; - this.rotateOffset = 0.0; - this.rotateMix = 1.0; - this.translateMix = 1.0; - this._pathSlot = null; - this._bones.length = 0; - this._spaces.length = 0; - this._positions.length = 0; - this._curves.length = 0; - this._boneLengths.length = 0; - this._pathGlobalVertices.length = 0; - }; - PathConstraint.prototype._updatePathVertices = function (verticesData) { - //计算曲线的节点数据 - var armature = this._armature; - var dragonBonesData = armature.armatureData.parent; - var scale = armature.armatureData.scale; - var intArray = dragonBonesData.intArray; - var floatArray = dragonBonesData.floatArray; - var pathOffset = verticesData.offset; - var pathVertexCount = intArray[pathOffset + 0 /* PathVertexCount */]; - var pathVertexOffset = intArray[pathOffset + 2 /* PathFloatOffset */]; - this._pathGlobalVertices.length = pathVertexCount * 2; - var weightData = verticesData.weight; - //没有骨骼约束我,那节点只受自己的Bone控制 - if (weightData === null) { - var parentBone = this._pathSlot.parent; - parentBone.updateByConstraint(); - var matrix = parentBone.globalTransformMatrix; - for (var i = 0, iV_1 = pathVertexOffset; i < pathVertexCount; i += 2) { - var vx = floatArray[iV_1++] * scale; - var vy = floatArray[iV_1++] * scale; - var x = matrix.a * vx + matrix.c * vy + matrix.tx; - var y = matrix.b * vx + matrix.d * vy + matrix.ty; - // - this._pathGlobalVertices[i] = x; - this._pathGlobalVertices[i + 1] = y; - } - return; - } - //有骨骼约束我,那我的节点受骨骼权重控制 - var bones = this._pathSlot._deformVertices.bones; - var weightBoneCount = weightData.bones.length; - var weightOffset = weightData.offset; - var floatOffset = intArray[weightOffset + 1 /* WeigthFloatOffset */]; - var iV = floatOffset; - var iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount; - for (var i = 0, iW = 0; i < pathVertexCount; i++) { - var vertexBoneCount = intArray[iB++]; // - var xG = 0.0, yG = 0.0; - for (var ii = 0, ll = vertexBoneCount; ii < ll; ii++) { - var boneIndex = intArray[iB++]; - var bone = bones[boneIndex]; - if (bone === null) { - continue; - } - bone.updateByConstraint(); - var matrix = bone.globalTransformMatrix; - var weight = floatArray[iV++]; - var vx = floatArray[iV++] * scale; - var vy = floatArray[iV++] * scale; - xG += (matrix.a * vx + matrix.c * vy + matrix.tx) * weight; - yG += (matrix.b * vx + matrix.d * vy + matrix.ty) * weight; - } - this._pathGlobalVertices[iW++] = xG; - this._pathGlobalVertices[iW++] = yG; - } - }; - PathConstraint.prototype._computeVertices = function (start, count, offset, out) { - //TODO优化 - for (var i = offset, iW = start; i < count; i += 2) { - out[i] = this._pathGlobalVertices[iW++]; - out[i + 1] = this._pathGlobalVertices[iW++]; - } - }; - PathConstraint.prototype._computeBezierCurve = function (pathDisplayDta, spaceCount, tangents, percentPosition, percentSpacing) { - //计算当前的骨骼在曲线上的位置 - var armature = this._armature; - var intArray = armature.armatureData.parent.intArray; - var vertexCount = intArray[pathDisplayDta.vertices.offset + 0 /* PathVertexCount */]; - var positions = this._positions; - var spaces = this._spaces; - var isClosed = pathDisplayDta.closed; - var curveVertices = Array(); - var verticesLength = vertexCount * 2; - var curveCount = verticesLength / 6; - var preCurve = -1; - var position = this.position; - positions.length = spaceCount * 3 + 2; - var pathLength = 0.0; - //不需要匀速运动,效率高些 - if (!pathDisplayDta.constantSpeed) { - var lenghts = pathDisplayDta.curveLengths; - curveCount -= isClosed ? 1 : 2; - pathLength = lenghts[curveCount]; - if (percentPosition) { - position *= pathLength; - } - if (percentSpacing) { - for (var i = 0; i < spaceCount; i++) { - spaces[i] *= pathLength; - } - } - curveVertices.length = 8; - for (var i = 0, o = 0, curve = 0; i < spaceCount; i++, o += 3) { - var space = spaces[i]; - position += space; - if (isClosed) { - position %= pathLength; - if (position < 0) { - position += pathLength; - } - curve = 0; - } - else if (position < 0) { - //TODO - continue; - } - else if (position > pathLength) { - //TODO - continue; - } - var percent = 0.0; - for (;; curve++) { - var len = lenghts[curve]; - if (position > len) { - continue; - } - if (curve === 0) { - percent = position / len; - } - else { - var preLen = lenghts[curve - 1]; - percent = (position - preLen) / (len - preLen); - } - break; - } - if (curve !== preCurve) { - preCurve = curve; - if (isClosed && curve === curveCount) { - //计算曲线 - this._computeVertices(verticesLength - 4, 4, 0, curveVertices); - this._computeVertices(0, 4, 4, curveVertices); - } - else { - this._computeVertices(curve * 6 + 2, 8, 0, curveVertices); - } - } - // - this.addCurvePosition(percent, curveVertices[0], curveVertices[1], curveVertices[2], curveVertices[3], curveVertices[4], curveVertices[5], curveVertices[6], curveVertices[7], positions, o, tangents); - } - return; - } - //匀速的 - if (isClosed) { - verticesLength += 2; - curveVertices.length = vertexCount; - this._computeVertices(2, verticesLength - 4, 0, curveVertices); - this._computeVertices(0, 2, verticesLength - 4, curveVertices); - curveVertices[verticesLength - 2] = curveVertices[0]; - curveVertices[verticesLength - 1] = curveVertices[1]; - } - else { - curveCount--; - verticesLength -= 4; - curveVertices.length = verticesLength; - this._computeVertices(2, verticesLength, 0, curveVertices); - } - // - var curves = new Array(curveCount); - pathLength = 0; - var x1 = curveVertices[0], y1 = curveVertices[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; - var tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy; - for (var i = 0, w = 2; i < curveCount; i++, w += 6) { - cx1 = curveVertices[w]; - cy1 = curveVertices[w + 1]; - cx2 = curveVertices[w + 2]; - cy2 = curveVertices[w + 3]; - x2 = curveVertices[w + 4]; - y2 = curveVertices[w + 5]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; - tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - curves[i] = pathLength; - x1 = x2; - y1 = y2; - } - if (percentPosition) { - position *= pathLength; - } - if (percentSpacing) { - for (var i = 0; i < spaceCount; i++) { - spaces[i] *= pathLength; - } - } - var segments = this._segments; - var curveLength = 0; - for (var i = 0, o = 0, curve = 0, segment = 0; i < spaceCount; i++, o += 3) { - var space = spaces[i]; - position += space; - var p = position; - if (isClosed) { - p %= pathLength; - if (p < 0) - p += pathLength; - curve = 0; - } - else if (p < 0) { - continue; - } - else if (p > pathLength) { - continue; - } - // Determine curve containing position. - for (;; curve++) { - var length_1 = curves[curve]; - if (p > length_1) - continue; - if (curve === 0) - p /= length_1; - else { - var prev = curves[curve - 1]; - p = (p - prev) / (length_1 - prev); - } - break; - } - if (curve !== preCurve) { - preCurve = curve; - var ii = curve * 6; - x1 = curveVertices[ii]; - y1 = curveVertices[ii + 1]; - cx1 = curveVertices[ii + 2]; - cy1 = curveVertices[ii + 3]; - cx2 = curveVertices[ii + 4]; - cy2 = curveVertices[ii + 5]; - x2 = curveVertices[ii + 6]; - y2 = curveVertices[ii + 7]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.03; - tmpy = (y1 - cy1 * 2 + cy2) * 0.03; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; - curveLength = Math.sqrt(dfx * dfx + dfy * dfy); - segments[0] = curveLength; - for (ii = 1; ii < 8; ii++) { - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[ii] = curveLength; - } - dfx += ddfx; - dfy += ddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[8] = curveLength; - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[9] = curveLength; - segment = 0; - } - // Weight by segment length. - p *= curveLength; - for (;; segment++) { - var length_2 = segments[segment]; - if (p > length_2) - continue; - if (segment === 0) - p /= length_2; - else { - var prev = segments[segment - 1]; - p = segment + (p - prev) / (length_2 - prev); - } - break; - } - this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, positions, o, tangents); - } - }; - //Calculates a point on the curve, for a given t value between 0 and 1. - PathConstraint.prototype.addCurvePosition = function (t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents) { - if (t === 0) { - out[offset] = x1; - out[offset + 1] = y1; - out[offset + 2] = 0; - return; - } - if (t === 1) { - out[offset] = x2; - out[offset + 1] = y2; - out[offset + 2] = 0; - return; - } - var mt = 1 - t; - var mt2 = mt * mt; - var t2 = t * t; - var a = mt2 * mt; - var b = mt2 * t * 3; - var c = mt * t2 * 3; - var d = t * t2; - var x = a * x1 + b * cx1 + c * cx2 + d * x2; - var y = a * y1 + b * cy1 + c * cy2 + d * y2; - out[offset] = x; - out[offset + 1] = y; - if (tangents) { - //Calculates the curve tangent at the specified t value - out[offset + 2] = Math.atan2(y - (a * y1 + b * cy1 + c * cy2), x - (a * x1 + b * cx1 + c * cx2)); - } - else { - out[offset + 2] = 0; - } - }; - PathConstraint.prototype.init = function (constraintData, armature) { - this._constraintData = constraintData; - this._armature = armature; - var data = constraintData; - this.pathOffset = data.pathDisplayData.vertices.offset; - // - this.position = data.position; - this.spacing = data.spacing; - this.rotateOffset = data.rotateOffset; - this.rotateMix = data.rotateMix; - this.translateMix = data.translateMix; - // - this._root = this._armature.getBone(data.root.name); - this._target = this._armature.getBone(data.target.name); - this._pathSlot = this._armature.getSlot(data.pathSlot.name); - for (var i = 0, l = data.bones.length; i < l; i++) { - var bone = this._armature.getBone(data.bones[i].name); - if (bone !== null) { - this._bones.push(bone); - } - } - if (data.rotateMode === 2 /* ChainScale */) { - this._boneLengths.length = this._bones.length; - } - this._root._hasConstraint = true; - }; - PathConstraint.prototype.update = function () { - var pathSlot = this._pathSlot; - if (pathSlot._deformVertices === null || - pathSlot._deformVertices.verticesData === null || - pathSlot._deformVertices.verticesData.offset !== this.pathOffset) { - return; - } - var constraintData = this._constraintData; - var pathDisplayData = pathSlot._displayData; // TODO - // - //曲线节点数据改变:父亲bone改变,权重bones改变,变形顶点改变 - var isPathVerticeDirty = false; - var deformVertices = pathSlot._deformVertices; - if (this._root._childrenTransformDirty) { - this._updatePathVertices(pathDisplayData.vertices); - isPathVerticeDirty = true; - } - else if (deformVertices !== null && (deformVertices.verticesDirty || deformVertices.isBonesUpdate())) { - this._updatePathVertices(pathDisplayData.vertices); - deformVertices.verticesDirty = false; - isPathVerticeDirty = true; - } - if (!isPathVerticeDirty && !this.dirty) { - return; - } - // - var positionMode = constraintData.positionMode; - var spacingMode = constraintData.spacingMode; - var rotateMode = constraintData.rotateMode; - var bones = this._bones; - var isLengthMode = spacingMode === 0 /* Length */; - var isChainScaleMode = rotateMode === 2 /* ChainScale */; - var isTangentMode = rotateMode === 0 /* Tangent */; - var boneCount = bones.length; - var spacesCount = isTangentMode ? boneCount : boneCount + 1; - var spacing = this.spacing; - var spaces = this._spaces; - spaces.length = spacesCount; - //计曲线间隔和长度 - if (isChainScaleMode || isLengthMode) { - //Bone改变和spacing改变触发 - spaces[0] = 0; - for (var i = 0, l = spacesCount - 1; i < l; i++) { - var bone = bones[i]; - bone.updateByConstraint(); - var boneLength = bone._boneData.length; - var matrix = bone.globalTransformMatrix; - var x = boneLength * matrix.a; - var y = boneLength * matrix.b; - var len = Math.sqrt(x * x + y * y); - if (isChainScaleMode) { - this._boneLengths[i] = len; - } - spaces[i + 1] = (boneLength + spacing) * len / boneLength; - } - } - else { - for (var i = 0; i < spacesCount; i++) { - spaces[i] = spacing; - } - } - // - this._computeBezierCurve(pathDisplayData, spacesCount, isTangentMode, positionMode === 1 /* Percent */, spacingMode === 2 /* Percent */); - //根据新的节点数据重新采样 - var positions = this._positions; - var rotateOffset = this.rotateOffset; - var boneX = positions[0], boneY = positions[1]; - var tip; - if (rotateOffset === 0) { - tip = rotateMode === 1 /* Chain */; - } - else { - tip = false; - var bone = pathSlot.parent; - if (bone !== null) { - var matrix = bone.globalTransformMatrix; - rotateOffset *= matrix.a * matrix.d - matrix.b * matrix.c > 0 ? dragonBones.Transform.DEG_RAD : -dragonBones.Transform.DEG_RAD; - } - } - // - var rotateMix = this.rotateMix; - var translateMix = this.translateMix; - for (var i = 0, p = 3; i < boneCount; i++, p += 3) { - var bone = bones[i]; - bone.updateByConstraint(); - var matrix = bone.globalTransformMatrix; - matrix.tx += (boneX - matrix.tx) * translateMix; - matrix.ty += (boneY - matrix.ty) * translateMix; - var x = positions[p], y = positions[p + 1]; - var dx = x - boneX, dy = y - boneY; - if (isChainScaleMode) { - var lenght = this._boneLengths[i]; - var s = (Math.sqrt(dx * dx + dy * dy) / lenght - 1) * rotateMix + 1; - matrix.a *= s; - matrix.b *= s; - } - boneX = x; - boneY = y; - if (rotateMix > 0) { - var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, r = void 0, cos = void 0, sin = void 0; - if (isTangentMode) { - r = positions[p - 1]; - } - else { - r = Math.atan2(dy, dx); - } - r -= Math.atan2(b, a); - if (tip) { - cos = Math.cos(r); - sin = Math.sin(r); - var length_3 = bone._boneData.length; - boneX += (length_3 * (cos * a - sin * b) - dx) * rotateMix; - boneY += (length_3 * (sin * a + cos * b) - dy) * rotateMix; - } - else { - r += rotateOffset; - } - if (r > dragonBones.Transform.PI) { - r -= dragonBones.Transform.PI_D; - } - else if (r < -dragonBones.Transform.PI) { - r += dragonBones.Transform.PI_D; - } - r *= rotateMix; - cos = Math.cos(r); - sin = Math.sin(r); - matrix.a = cos * a - sin * b; - matrix.b = sin * a + cos * b; - matrix.c = cos * c - sin * d; - matrix.d = sin * c + cos * d; - } - bone.global.fromMatrix(matrix); - } - this.dirty = false; - }; - PathConstraint.prototype.invalidUpdate = function () { - }; - return PathConstraint; - }(Constraint)); - dragonBones.PathConstraint = PathConstraint; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - var WorldClock = /** @class */ (function () { - /** - * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. - * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 - * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 - * @version DragonBones 3.0 - * @language zh_CN - */ - function WorldClock(time) { - if (time === void 0) { time = 0.0; } - /** - * - Current time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - this.time = 0.0; - /** - * - The play speed, used to control animation speed-shift play. - * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度,用于控制动画变速播放。 - * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - this.timeScale = 1.0; - this._systemTime = 0.0; - this._animatebles = []; - this._clock = null; - this.time = time; - this._systemTime = new Date().getTime() * 0.001; - } - /** - * - Advance time for all IAnimatable instances. - * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 为所有的 IAnimatable 实例更新时间。 - * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.advanceTime = function (passedTime) { - if (passedTime !== passedTime) { - passedTime = 0.0; - } - var currentTime = Date.now() * 0.001; - if (passedTime < 0.0) { - passedTime = currentTime - this._systemTime; - } - this._systemTime = currentTime; - if (this.timeScale !== 1.0) { - passedTime *= this.timeScale; - } - if (passedTime === 0.0) { - return; - } - if (passedTime < 0.0) { - this.time -= passedTime; - } - else { - this.time += passedTime; - } - var i = 0, r = 0, l = this._animatebles.length; - for (; i < l; ++i) { - var animatable = this._animatebles[i]; - if (animatable !== null) { - if (r > 0) { - this._animatebles[i - r] = animatable; - this._animatebles[i] = null; - } - animatable.advanceTime(passedTime); - } - else { - r++; - } - } - if (r > 0) { - l = this._animatebles.length; - for (; i < l; ++i) { - var animateble = this._animatebles[i]; - if (animateble !== null) { - this._animatebles[i - r] = animateble; - } - else { - r++; - } - } - this._animatebles.length -= r; - } - }; - /** - * - Check whether contains a specific instance of IAnimatable. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.contains = function (value) { - if (value === this) { - return false; - } - var ancestor = value; - while (ancestor !== this && ancestor !== null) { - ancestor = ancestor.clock; - } - return ancestor === this; - }; - /** - * - Add IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.add = function (value) { - if (this._animatebles.indexOf(value) < 0) { - this._animatebles.push(value); - value.clock = this; - } - }; - /** - * - Removes a specified IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.remove = function (value) { - var index = this._animatebles.indexOf(value); - if (index >= 0) { - this._animatebles[index] = null; - value.clock = null; - } - }; - /** - * - Clear all IAnimatable instances. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 清除所有的 IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.clear = function () { - for (var _i = 0, _a = this._animatebles; _i < _a.length; _i++) { - var animatable = _a[_i]; - if (animatable !== null) { - animatable.clock = null; - } - } - }; - Object.defineProperty(WorldClock.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - if (this._clock !== null) { - this._clock.remove(this); - } - this._clock = value; - if (this._clock !== null) { - this._clock.add(this); - } - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#clock}。 - * @deprecated - * @language zh_CN - */ - WorldClock.clock = new WorldClock(); - return WorldClock; - }()); - dragonBones.WorldClock = WorldClock; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The animation player is used to play the animation data and manage the animation states. - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器用来播放动画数据和管理动画状态。 - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - var Animation = /** @class */ (function (_super) { - __extends(Animation, _super); - function Animation() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._animationNames = []; - _this._animationStates = []; - _this._animations = {}; - _this._animationConfig = null; // Initial value. - return _this; - } - Animation.toString = function () { - return "[class dragonBones.Animation]"; - }; - Animation.prototype._onClear = function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.returnToPool(); - } - for (var k in this._animations) { - delete this._animations[k]; - } - if (this._animationConfig !== null) { - this._animationConfig.returnToPool(); - } - this.timeScale = 1.0; - this._lockUpdate = false; - this._animationDirty = false; - this._inheritTimeScale = 1.0; - this._animationNames.length = 0; - this._animationStates.length = 0; - //this._animations.clear(); - this._armature = null; // - this._animationConfig = null; // - this._lastAnimationState = null; - }; - Animation.prototype._fadeOut = function (animationConfig) { - switch (animationConfig.fadeOutMode) { - case 1 /* SameLayer */: - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (animationState._parent !== null) { - continue; - } - if (animationState.layer === animationConfig.layer) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 2 /* SameGroup */: - for (var _b = 0, _c = this._animationStates; _b < _c.length; _b++) { - var animationState = _c[_b]; - if (animationState._parent !== null) { - continue; - } - if (animationState.group === animationConfig.group) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 3 /* SameLayerAndGroup */: - for (var _d = 0, _e = this._animationStates; _d < _e.length; _d++) { - var animationState = _e[_d]; - if (animationState._parent !== null) { - continue; - } - if (animationState.layer === animationConfig.layer && - animationState.group === animationConfig.group) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 4 /* All */: - for (var _f = 0, _g = this._animationStates; _f < _g.length; _f++) { - var animationState = _g[_f]; - if (animationState._parent !== null) { - continue; - } - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - break; - case 0 /* None */: - case 5 /* Single */: - default: - break; - } - }; - /** - * @internal - */ - Animation.prototype.init = function (armature) { - if (this._armature !== null) { - return; - } - this._armature = armature; - this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); - }; - /** - * @internal - */ - Animation.prototype.advanceTime = function (passedTime) { - if (passedTime < 0.0) { - passedTime = -passedTime; - } - if (this._armature.inheritAnimation && this._armature._parent !== null) { - this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale; - } - else { - this._inheritTimeScale = this.timeScale; - } - if (this._inheritTimeScale !== 1.0) { - passedTime *= this._inheritTimeScale; - } - var animationStateCount = this._animationStates.length; - if (animationStateCount === 1) { - var animationState = this._animationStates[0]; - if (animationState._fadeState > 0 && animationState._subFadeState > 0) { - this._armature._dragonBones.bufferObject(animationState); - this._animationStates.length = 0; - this._lastAnimationState = null; - } - else { - var animationData = animationState._animationData; - var cacheFrameRate = animationData.cacheFrameRate; - if (this._animationDirty && cacheFrameRate > 0.0) { - this._animationDirty = false; - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); - } - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - var rawDisplayDatas = slot.rawDisplayDatas; - if (rawDisplayDatas !== null && rawDisplayDatas.length > 0) { - var rawDsplayData = rawDisplayDatas[0]; - if (rawDsplayData !== null) { - if (rawDsplayData.parent === this._armature.armatureData.defaultSkin) { - slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); - continue; - } - } - } - slot._cachedFrameIndices = null; - } - } - animationState.advanceTime(passedTime, cacheFrameRate); - } - } - else if (animationStateCount > 1) { - for (var i = 0, r = 0; i < animationStateCount; ++i) { - var animationState = this._animationStates[i]; - if (animationState._fadeState > 0 && animationState._subFadeState > 0) { - r++; - this._armature._dragonBones.bufferObject(animationState); - this._animationDirty = true; - if (this._lastAnimationState === animationState) { - this._lastAnimationState = null; - } - } - else { - if (r > 0) { - this._animationStates[i - r] = animationState; - } - animationState.advanceTime(passedTime, 0.0); - } - if (i === animationStateCount - 1 && r > 0) { - this._animationStates.length -= r; - if (this._lastAnimationState === null && this._animationStates.length > 0) { - this._lastAnimationState = this._animationStates[this._animationStates.length - 1]; - } - } - } - this._armature._cacheFrameIndex = -1; - } - else { - this._armature._cacheFrameIndex = -1; - } - }; - /** - * - Clear all animations states. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除所有的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.reset = function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.returnToPool(); - } - this._animationDirty = false; - this._animationConfig.clear(); - this._animationStates.length = 0; - this._lastAnimationState = null; - }; - /** - * - Pause a specific animation state. - * @param animationName - The name of animation state. (If not set, it will pause all animations) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停指定动画状态的播放。 - * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.stop = function (animationName) { - if (animationName === void 0) { animationName = null; } - if (animationName !== null) { - var animationState = this.getState(animationName); - if (animationState !== null) { - animationState.stop(); - } - } - else { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.stop(); - } - } - }; - /** - * - Play animation with a specific animation config. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @param animationConfig - The animation config. - * @returns The playing animation state. - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 通过指定的动画配置来播放动画。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @param animationConfig - 动画配置。 - * @returns 播放的动画状态。 - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - Animation.prototype.playConfig = function (animationConfig) { - var animationName = animationConfig.animation; - if (!(animationName in this._animations)) { - console.warn("Non-existent animation.\n", "DragonBones name: " + this._armature.armatureData.parent.name, "Armature name: " + this._armature.name, "Animation name: " + animationName); - return null; - } - var animationData = this._animations[animationName]; - if (animationConfig.fadeOutMode === 5 /* Single */) { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState_1 = _a[_i]; - if (animationState_1._animationData === animationData) { - return animationState_1; - } - } - } - if (this._animationStates.length === 0) { - animationConfig.fadeInTime = 0.0; - } - else if (animationConfig.fadeInTime < 0.0) { - animationConfig.fadeInTime = animationData.fadeInTime; - } - if (animationConfig.fadeOutTime < 0.0) { - animationConfig.fadeOutTime = animationConfig.fadeInTime; - } - if (animationConfig.timeScale <= -100.0) { - animationConfig.timeScale = 1.0 / animationData.scale; - } - if (animationData.frameCount > 1) { - if (animationConfig.position < 0.0) { - animationConfig.position %= animationData.duration; - animationConfig.position = animationData.duration - animationConfig.position; - } - else if (animationConfig.position === animationData.duration) { - animationConfig.position -= 0.000001; // Play a little time before end. - } - else if (animationConfig.position > animationData.duration) { - animationConfig.position %= animationData.duration; - } - if (animationConfig.duration > 0.0 && animationConfig.position + animationConfig.duration > animationData.duration) { - animationConfig.duration = animationData.duration - animationConfig.position; - } - if (animationConfig.playTimes < 0) { - animationConfig.playTimes = animationData.playTimes; - } - } - else { - animationConfig.playTimes = 1; - animationConfig.position = 0.0; - if (animationConfig.duration > 0.0) { - animationConfig.duration = 0.0; - } - } - if (animationConfig.duration === 0.0) { - animationConfig.duration = -1.0; - } - this._fadeOut(animationConfig); - var animationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); - animationState.init(this._armature, animationData, animationConfig); - this._animationDirty = true; - this._armature._cacheFrameIndex = -1; - if (this._animationStates.length > 0) { - var added = false; - for (var i = 0, l = this._animationStates.length; i < l; ++i) { - if (animationState.layer > this._animationStates[i].layer) { - added = true; - this._animationStates.splice(i, 0, animationState); - break; - } - else if (i !== l - 1 && animationState.layer > this._animationStates[i + 1].layer) { - added = true; - this._animationStates.splice(i + 1, 0, animationState); - break; - } - } - if (!added) { - this._animationStates.push(animationState); - } - } - else { - this._animationStates.push(animationState); - } - // Child armature play same name animation. - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - var childArmature = slot.childArmature; - if (childArmature !== null && childArmature.inheritAnimation && - childArmature.animation.hasAnimation(animationName) && - childArmature.animation.getState(animationName) === null) { - childArmature.animation.fadeIn(animationName); // - } - } - var isLocked = false; - for (var k in animationData.animationTimelines) { - if (!this._lockUpdate) { - isLocked = true; - this._lockUpdate = true; - } - var childAnimatiionState = this.fadeIn(k, animationConfig.fadeInTime, 1, animationState.layer, null, 0 /* None */); - if (childAnimatiionState !== null) { - childAnimatiionState.resetToPose = false; - childAnimatiionState._parent = animationState; - childAnimatiionState.stop(); - } - } - if (isLocked) { - this._lockUpdate = false; - } - if (!this._lockUpdate) { - if (animationConfig.fadeInTime <= 0.0) { - this._armature.advanceTime(0.0); - } - this._lastAnimationState = animationState; - } - return animationState; - }; - /** - * - Play a specific animation. - * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) - * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放指定动画。 - * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.play = function (animationName, playTimes) { - if (animationName === void 0) { animationName = null; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName !== null ? animationName : ""; - if (animationName !== null && animationName.length > 0) { - this.playConfig(this._animationConfig); - } - else if (this._lastAnimationState === null) { - var defaultAnimation = this._armature.armatureData.defaultAnimation; - if (defaultAnimation !== null) { - this._animationConfig.animation = defaultAnimation.name; - this.playConfig(this._animationConfig); - } - } - else if (!this._lastAnimationState.isPlaying && !this._lastAnimationState.isCompleted) { - this._lastAnimationState.play(); - } - else { - this._animationConfig.animation = this._lastAnimationState.name; - this.playConfig(this._animationConfig); - } - return this._lastAnimationState; - }; - /** - * - Fade in a specific animation. - * @param animationName - The name of animation data. - * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) - * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) - * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) - * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 淡入播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) - * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) - * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.fadeIn = function (animationName, fadeInTime, playTimes, layer, group, fadeOutMode) { - if (fadeInTime === void 0) { fadeInTime = -1.0; } - if (playTimes === void 0) { playTimes = -1; } - if (layer === void 0) { layer = 0; } - if (group === void 0) { group = null; } - if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } - this._animationConfig.clear(); - this._animationConfig.fadeOutMode = fadeOutMode; - this._animationConfig.playTimes = playTimes; - this._animationConfig.layer = layer; - this._animationConfig.fadeInTime = fadeInTime; - this._animationConfig.animation = animationName; - this._animationConfig.group = group !== null ? group : ""; - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific time. - * @param animationName - The name of animation data. - * @param time - The start time point of playing. (In seconds) - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定时间开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param time - 播放开始的时间。 (以秒为单位) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByTime = function (animationName, time, playTimes) { - if (time === void 0) { time = 0.0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.position = time; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific frame. - * @param animationName - The name of animation data. - * @param frame - The start frame of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定帧开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param frame - 播放开始的帧数。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByFrame = function (animationName, frame, playTimes) { - if (frame === void 0) { frame = 0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - var animationData = animationName in this._animations ? this._animations[animationName] : null; - if (animationData !== null) { - this._animationConfig.position = animationData.duration * frame / animationData.frameCount; - } - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific progress. - * @param animationName - The name of animation data. - * @param progress - The start progress value of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定进度开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param progress - 开始播放的进度。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByProgress = function (animationName, progress, playTimes) { - if (progress === void 0) { progress = 0.0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - var animationData = animationName in this._animations ? this._animations[animationName] : null; - if (animationData !== null) { - this._animationConfig.position = animationData.duration * (progress > 0.0 ? progress : 0.0); - } - return this.playConfig(this._animationConfig); - }; - /** - * - Stop a specific animation at the specific time. - * @param animationName - The name of animation data. - * @param time - The stop time. (In seconds) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定时间停止指定动画播放 - * @param animationName - 动画数据名称。 - * @param time - 停止的时间。 (以秒为单位) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByTime = function (animationName, time) { - if (time === void 0) { time = 0.0; } - var animationState = this.gotoAndPlayByTime(animationName, time, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Stop a specific animation at the specific frame. - * @param animationName - The name of animation data. - * @param frame - The stop frame. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定帧停止指定动画的播放 - * @param animationName - 动画数据名称。 - * @param frame - 停止的帧数。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByFrame = function (animationName, frame) { - if (frame === void 0) { frame = 0; } - var animationState = this.gotoAndPlayByFrame(animationName, frame, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Stop a specific animation at the specific progress. - * @param animationName - The name of animation data. - * @param progress - The stop progress value. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定的进度停止指定的动画播放。 - * @param animationName - 动画数据名称。 - * @param progress - 停止进度。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByProgress = function (animationName, progress) { - if (progress === void 0) { progress = 0.0; } - var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Get a specific animation state. - * @param animationName - The name of animation state. - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取指定的动画状态 - * @param animationName - 动画状态名称。 - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.getState = function (animationName) { - var i = this._animationStates.length; - while (i--) { - var animationState = this._animationStates[i]; - if (animationState.name === animationName) { - return animationState; - } - } - return null; - }; - /** - * - Check whether a specific animation data is included. - * @param animationName - The name of animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含指定的动画数据 - * @param animationName - 动画数据名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.hasAnimation = function (animationName) { - return animationName in this._animations; - }; - /** - * - Get all the animation states. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取所有的动画状态 - * @version DragonBones 5.1 - * @language zh_CN - */ - Animation.prototype.getStates = function () { - return this._animationStates; - }; - Object.defineProperty(Animation.prototype, "isPlaying", { - /** - * - Check whether there is an animation state is playing - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否有动画状态正在播放 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (animationState.isPlaying) { - return true; - } - } - return false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "isCompleted", { - /** - * - Check whether all the animation states' playing were finished. - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否所有的动画状态均已播放完毕。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (!animationState.isCompleted) { - return false; - } - } - return this._animationStates.length > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "lastAnimationName", { - /** - * - The name of the last playing animation state. - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态名称 - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._lastAnimationState !== null ? this._lastAnimationState.name : ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationNames", { - /** - * - The name of all animation data - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有动画数据的名称 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._animationNames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animations", { - /** - * - All animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有的动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._animations; - }, - set: function (value) { - if (this._animations === value) { - return; - } - this._animationNames.length = 0; - for (var k in this._animations) { - delete this._animations[k]; - } - for (var k in value) { - this._animationNames.push(k); - this._animations[k] = value[k]; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationConfig", { - /** - * - An AnimationConfig instance that can be used quickly. - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 一个可以快速使用的动画配置实例。 - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language zh_CN - */ - get: function () { - this._animationConfig.clear(); - return this._animationConfig; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "lastAnimationState", { - /** - * - The last playing animation state - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._lastAnimationState; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #play()} {@link #fadeIn()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #play()} {@link #fadeIn()}。 - * @deprecated - * @language zh_CN - */ - Animation.prototype.gotoAndPlay = function (animationName, fadeInTime, duration, playTimes, layer, group, fadeOutMode, pauseFadeOut, pauseFadeIn) { - if (fadeInTime === void 0) { fadeInTime = -1; } - if (duration === void 0) { duration = -1; } - if (playTimes === void 0) { playTimes = -1; } - if (layer === void 0) { layer = 0; } - if (group === void 0) { group = null; } - if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } - if (pauseFadeOut === void 0) { pauseFadeOut = true; } - if (pauseFadeIn === void 0) { pauseFadeIn = true; } - console.warn("Deprecated."); - // tslint:disable-next-line:no-unused-expression - pauseFadeOut; - // tslint:disable-next-line:no-unused-expression - pauseFadeIn; - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.fadeOutMode = fadeOutMode; - this._animationConfig.playTimes = playTimes; - this._animationConfig.layer = layer; - this._animationConfig.fadeInTime = fadeInTime; - this._animationConfig.animation = animationName; - this._animationConfig.group = group !== null ? group : ""; - var animationData = this._animations[animationName]; - if (animationData && duration > 0.0) { - this._animationConfig.timeScale = animationData.duration / duration; - } - return this.playConfig(this._animationConfig); - }; - /** - * - Deprecated, please refer to {@link #gotoAndStopByTime()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #gotoAndStopByTime()}。 - * @deprecated - * @language zh_CN - */ - Animation.prototype.gotoAndStop = function (animationName, time) { - if (time === void 0) { time = 0; } - console.warn("Deprecated."); - return this.gotoAndStopByTime(animationName, time); - }; - Object.defineProperty(Animation.prototype, "animationList", { - /** - * - Deprecated, please refer to {@link #animationNames}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #animationNames}。 - * @deprecated - * @language zh_CN - */ - get: function () { - console.warn("Deprecated."); - return this._animationNames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationDataList", { - /** - * - Deprecated, please refer to {@link #animationNames}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #animationNames}。 - * @deprecated - * @language zh_CN - */ - get: function () { - console.warn("Deprecated."); - var list = []; - for (var i = 0, l = this._animationNames.length; i < l; ++i) { - list.push(this._animations[this._animationNames[i]]); - } - return list; - }, - enumerable: true, - configurable: true - }); - return Animation; - }(dragonBones.BaseObject)); - dragonBones.Animation = Animation; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The animation state is generated when the animation data is played. - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画状态由播放动画数据时产生。 - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - var AnimationState = /** @class */ (function (_super) { - __extends(AnimationState, _super); - function AnimationState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @internal - */ - _this._blendState = new BlendState(); - _this._boneMask = []; - _this._boneTimelines = []; - _this._surfaceTimelines = []; - _this._slotTimelines = []; - _this._constraintTimelines = []; - _this._animationTimelines = []; - _this._poseTimelines = []; - _this._bonePoses = {}; - /** - * @internal - */ - _this._actionTimeline = null; // Initial value. - _this._zOrderTimeline = null; // Initial value. - /** - * @internal - */ - _this._parent = null; // Initial value. - return _this; - } - AnimationState.toString = function () { - return "[class dragonBones.AnimationState]"; - }; - AnimationState.prototype._onClear = function () { - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.returnToPool(); - } - for (var _b = 0, _c = this._surfaceTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.returnToPool(); - } - for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.returnToPool(); - } - for (var _f = 0, _g = this._constraintTimelines; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.returnToPool(); - } - for (var _h = 0, _j = this._animationTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.returnToPool(); - } - for (var k in this._bonePoses) { - this._bonePoses[k].returnToPool(); - delete this._bonePoses[k]; - } - if (this._actionTimeline !== null) { - this._actionTimeline.returnToPool(); - } - if (this._zOrderTimeline !== null) { - this._zOrderTimeline.returnToPool(); - } - this.actionEnabled = false; - this.additiveBlending = false; - this.displayControl = false; - this.resetToPose = false; - this.playTimes = 1; - this.layer = 0; - this.timeScale = 1.0; - this.weight = 1.0; - this.autoFadeOutTime = 0.0; - this.fadeTotalTime = 0.0; - this.name = ""; - this.group = ""; - this._timelineDirty = 2; - this._playheadState = 0; - this._fadeState = -1; - this._subFadeState = -1; - this._position = 0.0; - this._duration = 0.0; - this._fadeTime = 0.0; - this._time = 0.0; - this._fadeProgress = 0.0; - this._weightResult = 0.0; - this._blendState.clear(); - this._boneMask.length = 0; - this._boneTimelines.length = 0; - this._surfaceTimelines.length = 0; - this._slotTimelines.length = 0; - this._constraintTimelines.length = 0; - this._animationTimelines.length = 0; - this._poseTimelines.length = 0; - // this._bonePoses.clear(); - this._animationData = null; // - this._armature = null; // - this._actionTimeline = null; // - this._zOrderTimeline = null; - this._parent = null; // - }; - AnimationState.prototype._updateTimelines = function () { - { - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - var timelineDatas = this._animationData.getConstraintTimelines(constraint.name); - if (timelineDatas !== null) { - for (var _b = 0, timelineDatas_1 = timelineDatas; _b < timelineDatas_1.length; _b++) { - var timelineData = timelineDatas_1[_b]; - switch (timelineData.type) { - case 30 /* IKConstraint */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); - timeline.constraint = constraint; - timeline.init(this._armature, this, timelineData); - this._constraintTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); - timeline.constraint = constraint; - timeline.init(this._armature, this, null); - this._constraintTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - { - for (var _c = 0, _d = this._armature.animation.getStates(); _c < _d.length; _c++) { - var animationState = _d[_c]; - if (animationState._parent !== this) { - continue; - } - var timelineDatas = this._animationData.getAnimationTimelines(animationState.name); - if (timelineDatas === null) { - continue; - } - for (var _e = 0, timelineDatas_2 = timelineDatas; _e < timelineDatas_2.length; _e++) { - var timelineData = timelineDatas_2[_e]; - switch (timelineData.type) { - case 40 /* AnimationTime */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineState); - timeline.animationState = animationState; - timeline.init(this._armature, this, timelineData); - this._animationTimelines.push(timeline); - break; - } - default: - break; - } - } - } - } - }; - AnimationState.prototype._updateBoneAndSlotTimelines = function () { - { - var boneTimelines = {}; - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - var timelineName = timeline.bone.name; - if (!(timelineName in boneTimelines)) { - boneTimelines[timelineName] = []; - } - boneTimelines[timelineName].push(timeline); - } - for (var _b = 0, _c = this._armature.getBones(); _b < _c.length; _b++) { - var bone = _c[_b]; - var timelineName = bone.name; - if (!this.containsBoneMask(timelineName)) { - continue; - } - if (timelineName in boneTimelines) { - delete boneTimelines[timelineName]; - } - else if (bone._boneData.type === 0 /* Bone */) { - var timelineDatas = this._animationData.getBoneTimelines(timelineName); - var bonePose = timelineName in this._bonePoses ? this._bonePoses[timelineName] : (this._bonePoses[timelineName] = dragonBones.BaseObject.borrowObject(BonePose)); - if (timelineDatas !== null) { - for (var _d = 0, timelineDatas_3 = timelineDatas; _d < timelineDatas_3.length; _d++) { - var timelineData = timelineDatas_3[_d]; - switch (timelineData.type) { - case 10 /* BoneAll */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); - timeline.bone = bone; - timeline.bonePose = bonePose; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 11 /* BoneTranslate */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTranslateTimelineState); - timeline.bone = bone; - timeline.bonePose = bonePose; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 12 /* BoneRotate */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneRotateTimelineState); - timeline.bone = bone; - timeline.bonePose = bonePose; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 13 /* BoneScale */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneScaleTimelineState); - timeline.bone = bone; - timeline.bonePose = bonePose; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); - timeline.bone = bone; - timeline.bonePose = bonePose; - timeline.init(this._armature, this, null); - this._boneTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - else if (bone._boneData.type === 1 /* Surface */) { - var timelineDatas = this._animationData.getSurfaceTimelines(timelineName); - if (timelineDatas !== null) { - for (var _e = 0, timelineDatas_4 = timelineDatas; _e < timelineDatas_4.length; _e++) { - var timelineData = timelineDatas_4[_e]; - switch (timelineData.type) { - case 50 /* Surface */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); - timeline.surface = bone; - timeline.init(this._armature, this, timelineData); - this._surfaceTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); - timeline.surface = bone; - timeline.init(this._armature, this, null); - this._surfaceTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - for (var k in boneTimelines) { - for (var _f = 0, _g = boneTimelines[k]; _f < _g.length; _f++) { - var timeline = _g[_f]; - this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1); - timeline.returnToPool(); - } - } - } - { - var slotTimelines = {}; - var ffdFlags = []; - for (var _h = 0, _j = this._slotTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - var timelineName = timeline.slot.name; - if (!(timelineName in slotTimelines)) { - slotTimelines[timelineName] = []; - } - slotTimelines[timelineName].push(timeline); - } - for (var _k = 0, _l = this._armature.getSlots(); _k < _l.length; _k++) { - var slot = _l[_k]; - var boneName = slot.parent.name; - if (!this.containsBoneMask(boneName)) { - continue; - } - var timelineName = slot.name; - var timelineDatas = this._animationData.getSlotTimelines(timelineName); - if (timelineName in slotTimelines) { - delete slotTimelines[timelineName]; - } - else { - var displayIndexFlag = false; - var colorFlag = false; - ffdFlags.length = 0; - if (timelineDatas !== null) { - for (var _m = 0, timelineDatas_5 = timelineDatas; _m < timelineDatas_5.length; _m++) { - var timelineData = timelineDatas_5[_m]; - switch (timelineData.type) { - case 20 /* SlotDisplay */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayTimelineState); - timeline.slot = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - displayIndexFlag = true; - break; - } - case 21 /* SlotColor */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); - timeline.slot = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - colorFlag = true; - break; - } - case 22 /* SlotDeform */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); - timeline.slot = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - ffdFlags.push(timeline.vertexOffset); - break; - } - default: - break; - } - } - } - if (this.resetToPose) { - if (!displayIndexFlag) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayTimelineState); - timeline.slot = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - if (!colorFlag) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); - timeline.slot = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - if (slot.rawDisplayDatas !== null) { - for (var _o = 0, _p = slot.rawDisplayDatas; _o < _p.length; _o++) { - var displayData = _p[_o]; - if (displayData !== null && displayData.type === 2 /* Mesh */) { - var meshOffset = displayData.vertices.offset; - if (ffdFlags.indexOf(meshOffset) < 0) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); - timeline.vertexOffset = meshOffset; // - timeline.slot = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - } - } - } - } - for (var k in slotTimelines) { - for (var _q = 0, _r = slotTimelines[k]; _q < _r.length; _q++) { - var timeline = _r[_q]; - this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1); - timeline.returnToPool(); - } - } - } - }; - AnimationState.prototype._advanceFadeTime = function (passedTime) { - var isFadeOut = this._fadeState > 0; - if (this._subFadeState < 0) { - this._subFadeState = 0; - var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; - if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = eventType; - eventObject.armature = this._armature; - eventObject.animationState = this; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - if (passedTime < 0.0) { - passedTime = -passedTime; - } - this._fadeTime += passedTime; - if (this._fadeTime >= this.fadeTotalTime) { - this._subFadeState = 1; - this._fadeProgress = isFadeOut ? 0.0 : 1.0; - } - else if (this._fadeTime > 0.0) { - this._fadeProgress = isFadeOut ? (1.0 - this._fadeTime / this.fadeTotalTime) : (this._fadeTime / this.fadeTotalTime); - } - else { - this._fadeProgress = isFadeOut ? 1.0 : 0.0; - } - if (this._subFadeState > 0) { - if (!isFadeOut) { - this._playheadState |= 1; // x1 - this._fadeState = 0; - } - var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; - if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = eventType; - eventObject.armature = this._armature; - eventObject.animationState = this; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - }; - /** - * @internal - */ - AnimationState.prototype.init = function (armature, animationData, animationConfig) { - if (this._armature !== null) { - return; - } - this._armature = armature; - this._animationData = animationData; - // - this.resetToPose = animationConfig.resetToPose; - this.additiveBlending = animationConfig.additiveBlending; - this.displayControl = animationConfig.displayControl; - this.actionEnabled = animationConfig.actionEnabled; - this.layer = animationConfig.layer; - this.playTimes = animationConfig.playTimes; - this.timeScale = animationConfig.timeScale; - this.fadeTotalTime = animationConfig.fadeInTime; - this.autoFadeOutTime = animationConfig.autoFadeOutTime; - this.weight = animationConfig.weight; - this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; - this.group = animationConfig.group; - if (animationConfig.pauseFadeIn) { - this._playheadState = 2; // 10 - } - else { - this._playheadState = 3; // 11 - } - if (animationConfig.duration < 0.0) { - this._position = 0.0; - this._duration = this._animationData.duration; - if (animationConfig.position !== 0.0) { - if (this.timeScale >= 0.0) { - this._time = animationConfig.position; - } - else { - this._time = animationConfig.position - this._duration; - } - } - else { - this._time = 0.0; - } - } - else { - this._position = animationConfig.position; - this._duration = animationConfig.duration; - this._time = 0.0; - } - if (this.timeScale < 0.0 && this._time === 0.0) { - this._time = -0.000001; // Turn to end. - } - if (this.fadeTotalTime <= 0.0) { - this._fadeProgress = 0.999999; // Make different. - } - if (animationConfig.boneMask.length > 0) { - this._boneMask.length = animationConfig.boneMask.length; - for (var i = 0, l = this._boneMask.length; i < l; ++i) { - this._boneMask[i] = animationConfig.boneMask[i]; - } - } - this._actionTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ActionTimelineState); - this._actionTimeline.init(this._armature, this, this._animationData.actionTimeline); - this._actionTimeline.currentTime = this._time; - if (this._actionTimeline.currentTime < 0.0) { - this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime; - } - if (this._animationData.zOrderTimeline !== null) { - this._zOrderTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ZOrderTimelineState); - this._zOrderTimeline.init(this._armature, this, this._animationData.zOrderTimeline); - } - }; - /** - * @internal - */ - AnimationState.prototype.advanceTime = function (passedTime, cacheFrameRate) { - this._blendState.dirty = false; - // Update fade time. - if (this._fadeState !== 0 || this._subFadeState !== 0) { - this._advanceFadeTime(passedTime); - } - // Update time. - if (this._playheadState === 3) { - if (this.timeScale !== 1.0) { - passedTime *= this.timeScale; - } - this._time += passedTime; - } - // Update timeline. - if (this._timelineDirty !== 0) { - if (this._timelineDirty === 2) { - this._updateTimelines(); - } - this._timelineDirty = 0; - this._updateBoneAndSlotTimelines(); - } - if (this.weight === 0.0) { - return; - } - var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; - var isUpdateTimeline = true; - var isUpdateBoneTimeline = true; - var time = this._time; - this._weightResult = this.weight * this._fadeProgress; - if (this._parent !== null) { - this._weightResult *= this._parent._weightResult / this._parent._fadeProgress; - } - if (this._actionTimeline.playState <= 0) { - this._actionTimeline.update(time); // Update main timeline. - } - if (isCacheEnabled) { - var internval = cacheFrameRate * 2.0; - this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; - } - if (this._zOrderTimeline !== null && this._zOrderTimeline.playState <= 0) { - this._zOrderTimeline.update(time); - } - if (isCacheEnabled) { - var cacheFrameIndex = Math.floor(this._actionTimeline.currentTime * cacheFrameRate); // uint - if (this._armature._cacheFrameIndex === cacheFrameIndex) { - isUpdateTimeline = false; - isUpdateBoneTimeline = false; - } - else { - this._armature._cacheFrameIndex = cacheFrameIndex; - if (this._animationData.cachedFrames[cacheFrameIndex]) { - isUpdateBoneTimeline = false; - } - else { - this._animationData.cachedFrames[cacheFrameIndex] = true; - } - } - } - if (isUpdateTimeline) { - if (isUpdateBoneTimeline) { - for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { - var timeline = this._boneTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - if (i === l - 1 || timeline.bone !== this._boneTimelines[i + 1].bone) { - var state = timeline.bone._blendState.update(this._weightResult, this.layer); - if (state !== 0) { - timeline.blend(state); - } - } - } - } - for (var i = 0, l = this._surfaceTimelines.length; i < l; ++i) { - var timeline = this._surfaceTimelines[i]; - var state = timeline.surface._blendState.update(this._weightResult, this.layer); - if (timeline.playState <= 0) { - timeline.update(time); - } - if (state !== 0) { - timeline.blend(state); - } - } - if (this.displayControl) { - for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { - var timeline = this._slotTimelines[i]; - var displayController = timeline.slot.displayController; - if (displayController === null || - displayController === this.name || - displayController === this.group) { - if (timeline.playState <= 0) { - timeline.update(time); - } - } - } - } - for (var i = 0, l = this._constraintTimelines.length; i < l; ++i) { - var timeline = this._constraintTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - } - for (var i = 0, l = this._animationTimelines.length; i < l; ++i) { - var timeline = this._animationTimelines[i]; - var state = timeline.animationState._blendState.update(this._weightResult, this.layer); - if (timeline.playState <= 0) { - timeline.update(time); - } - if (state !== 0) { - timeline.blend(state); - } - } - } - if (this._fadeState === 0) { - if (this._subFadeState > 0) { - this._subFadeState = 0; - if (this._poseTimelines.length > 0) { - for (var _i = 0, _a = this._poseTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - if (timeline instanceof dragonBones.BoneTimelineState) { - this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1); - } - else if (timeline instanceof dragonBones.SurfaceTimelineState) { - this._surfaceTimelines.splice(this._surfaceTimelines.indexOf(timeline), 1); - } - else if (timeline instanceof dragonBones.SlotTimelineState) { - this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1); - } - else if (timeline instanceof dragonBones.ConstraintTimelineState) { - this._constraintTimelines.splice(this._constraintTimelines.indexOf(timeline), 1); - } - timeline.returnToPool(); - } - this._poseTimelines.length = 0; - } - } - if (this._actionTimeline.playState > 0) { - if (this.autoFadeOutTime >= 0.0) { - this.fadeOut(this.autoFadeOutTime); - } - } - } - }; - /** - * - Continue play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 继续播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.play = function () { - this._playheadState = 3; // 11 - }; - /** - * - Stop play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.stop = function () { - this._playheadState &= 1; // 0x - }; - /** - * - Fade out the animation state. - * @param fadeOutTime - The fade out time. (In seconds) - * @param pausePlayhead - Whether to pause the animation playing when fade out. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 淡出动画状态。 - * @param fadeOutTime - 淡出时间。 (以秒为单位) - * @param pausePlayhead - 淡出时是否暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.fadeOut = function (fadeOutTime, pausePlayhead) { - if (pausePlayhead === void 0) { pausePlayhead = true; } - if (fadeOutTime < 0.0) { - fadeOutTime = 0.0; - } - if (pausePlayhead) { - this._playheadState &= 2; // x0 - } - if (this._fadeState > 0) { - if (fadeOutTime > this.fadeTotalTime - this._fadeTime) { - return; - } - } - else { - this._fadeState = 1; - this._subFadeState = -1; - if (fadeOutTime <= 0.0 || this._fadeProgress <= 0.0) { - this._fadeProgress = 0.000001; // Modify fade progress to different value. - } - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.fadeOut(); - } - for (var _b = 0, _c = this._surfaceTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.fadeOut(); - } - for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.fadeOut(); - } - for (var _f = 0, _g = this._constraintTimelines; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.fadeOut(); - } - for (var _h = 0, _j = this._animationTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.animationState.fadeOut(fadeOutTime, pausePlayhead); - timeline.fadeOut(); - } - } - this.displayControl = false; // - this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; - this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); - }; - /** - * - Check if a specific bone mask is included. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.containsBoneMask = function (boneName) { - return this._boneMask.length === 0 || this._boneMask.indexOf(boneName) >= 0; - }; - /** - * - Add a specific bone mask. - * @param boneName - The bone name. - * @param recursive - Whether or not to add a mask to the bone's sub-bone. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加特定的骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.addBoneMask = function (boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var currentBone = this._armature.getBone(boneName); - if (currentBone === null) { - return; - } - if (this._boneMask.indexOf(boneName) < 0) { - this._boneMask.push(boneName); - } - if (recursive) { - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { - this._boneMask.push(bone.name); - } - } - } - this._timelineDirty = 1; - }; - /** - * - Remove the mask of a specific bone. - * @param boneName - The bone name. - * @param recursive - Whether to remove the bone's sub-bone mask. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除特定骨骼的遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否删除该骨骼的子骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.removeBoneMask = function (boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var index = this._boneMask.indexOf(boneName); - if (index >= 0) { - this._boneMask.splice(index, 1); - } - if (recursive) { - var currentBone = this._armature.getBone(boneName); - if (currentBone !== null) { - var bones = this._armature.getBones(); - if (this._boneMask.length > 0) { - for (var _i = 0, bones_1 = bones; _i < bones_1.length; _i++) { - var bone = bones_1[_i]; - var index_2 = this._boneMask.indexOf(bone.name); - if (index_2 >= 0 && currentBone.contains(bone)) { - this._boneMask.splice(index_2, 1); - } - } - } - else { - for (var _a = 0, bones_2 = bones; _a < bones_2.length; _a++) { - var bone = bones_2[_a]; - if (bone === currentBone) { - continue; - } - if (!currentBone.contains(bone)) { - this._boneMask.push(bone.name); - } - } - } - } - } - this._timelineDirty = 1; - }; - /** - * - Remove all bone masks. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除所有骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.removeAllBoneMask = function () { - this._boneMask.length = 0; - this._timelineDirty = 1; - }; - Object.defineProperty(AnimationState.prototype, "isFadeIn", { - /** - * - Whether the animation state is fading in. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡入。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState < 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isFadeOut", { - /** - * - Whether the animation state is fading out. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡出。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isFadeComplete", { - /** - * - Whether the animation state is fade completed. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否淡入或淡出完毕。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState === 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isPlaying", { - /** - * - Whether the animation state is playing. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否正在播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return (this._playheadState & 2) !== 0 && this._actionTimeline.playState <= 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isCompleted", { - /** - * - Whether the animation state is play completed. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否播放完毕。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.playState > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { - /** - * - The times has been played. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 已经循环播放的次数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.currentPlayTimes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "totalTime", { - /** - * - The total time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 总播放时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._duration; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "currentTime", { - /** - * - The time is currently playing. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前播放的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.currentTime; - }, - set: function (value) { - var currentPlayTimes = this._actionTimeline.currentPlayTimes - (this._actionTimeline.playState > 0 ? 1 : 0); - if (value < 0 || this._duration < value) { - value = (value % this._duration) + currentPlayTimes * this._duration; - if (value < 0) { - value += this._duration; - } - } - if (this.playTimes > 0 && currentPlayTimes === this.playTimes - 1 && value === this._duration) { - value = this._duration - 0.000001; - } - if (this._time === value) { - return; - } - this._time = value; - this._actionTimeline.setCurrentTime(this._time); - if (this._zOrderTimeline !== null) { - this._zOrderTimeline.playState = -1; - } - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.playState = -1; - } - for (var _b = 0, _c = this._slotTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.playState = -1; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "animationData", { - /** - * - The animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._animationData; - }, - enumerable: true, - configurable: true - }); - return AnimationState; - }(dragonBones.BaseObject)); - dragonBones.AnimationState = AnimationState; - /** - * @internal - */ - var BonePose = /** @class */ (function (_super) { - __extends(BonePose, _super); - function BonePose() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.current = new dragonBones.Transform(); - _this.delta = new dragonBones.Transform(); - _this.result = new dragonBones.Transform(); - return _this; - } - BonePose.toString = function () { - return "[class dragonBones.BonePose]"; - }; - BonePose.prototype._onClear = function () { - this.current.identity(); - this.delta.identity(); - this.result.identity(); - }; - return BonePose; - }(dragonBones.BaseObject)); - dragonBones.BonePose = BonePose; - /** - * @internal - */ - var BlendState = /** @class */ (function () { - function BlendState() { - } - /** - * -1: First blending, 0: No blending, 1: Blending. - */ - BlendState.prototype.update = function (weight, p_layer) { - if (this.dirty) { - if (this.leftWeight > 0.0) { - if (this.layer !== p_layer) { - if (this.layerWeight >= this.leftWeight) { - this.leftWeight = 0.0; - return 0; - } - else { - this.layer = p_layer; - this.leftWeight -= this.layerWeight; - this.layerWeight = 0.0; - } - } - } - else { - return 0; - } - weight *= this.leftWeight; - this.layerWeight += weight; - this.blendWeight = weight; - return 2; - } - this.dirty = true; - this.layer = p_layer; - this.layerWeight = weight; - this.leftWeight = 1.0; - this.blendWeight = weight; - return 1; - }; - BlendState.prototype.clear = function () { - this.dirty = false; - this.layer = 0; - this.leftWeight = 0.0; - this.layerWeight = 0.0; - this.blendWeight = 0.0; - }; - return BlendState; - }()); - dragonBones.BlendState = BlendState; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var TimelineState = /** @class */ (function (_super) { - __extends(TimelineState, _super); - function TimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - TimelineState.prototype._onClear = function () { - this.playState = -1; - this.currentPlayTimes = -1; - this.currentTime = -1.0; - this._tweenState = 0 /* None */; - this._frameRate = 0; - this._frameValueOffset = 0; - this._frameCount = 0; - this._frameOffset = 0; - this._frameIndex = -1; - this._frameRateR = 0.0; - this._position = 0.0; - this._duration = 0.0; - this._timeScale = 1.0; - this._timeOffset = 0.0; - this._dragonBonesData = null; // - this._animationData = null; // - this._timelineData = null; // - this._armature = null; // - this._animationState = null; // - this._actionTimeline = null; // - this._frameArray = null; // - this._frameIntArray = null; // - this._frameFloatArray = null; // - this._timelineArray = null; // - this._frameIndices = null; // - }; - TimelineState.prototype._setCurrentTime = function (passedTime) { - var prevState = this.playState; - var prevPlayTimes = this.currentPlayTimes; - var prevTime = this.currentTime; - if (this._actionTimeline !== null && this._frameCount <= 1) { - this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; - this.currentPlayTimes = 1; - this.currentTime = this._actionTimeline.currentTime; - } - else if (this._actionTimeline === null || this._timeScale !== 1.0 || this._timeOffset !== 0.0) { - var playTimes = this._animationState.playTimes; - var totalTime = playTimes * this._duration; - passedTime *= this._timeScale; - if (this._timeOffset !== 0.0) { - passedTime += this._timeOffset * this._animationData.duration; - } - if (playTimes > 0 && (passedTime >= totalTime || passedTime <= -totalTime)) { - if (this.playState <= 0 && this._animationState._playheadState === 3) { - this.playState = 1; - } - this.currentPlayTimes = playTimes; - if (passedTime < 0.0) { - this.currentTime = 0.0; - } - else { - this.currentTime = this._duration + 0.000001; // Precision problem - } - } - else { - if (this.playState !== 0 && this._animationState._playheadState === 3) { - this.playState = 0; - } - if (passedTime < 0.0) { - passedTime = -passedTime; - this.currentPlayTimes = Math.floor(passedTime / this._duration); - this.currentTime = this._duration - (passedTime % this._duration); - } - else { - this.currentPlayTimes = Math.floor(passedTime / this._duration); - this.currentTime = passedTime % this._duration; - } - } - this.currentTime += this._position; - } - else { - this.playState = this._actionTimeline.playState; - this.currentPlayTimes = this._actionTimeline.currentPlayTimes; - this.currentTime = this._actionTimeline.currentTime; - } - if (this.currentPlayTimes === prevPlayTimes && this.currentTime === prevTime) { - return false; - } - // Clear frame flag when timeline start or loopComplete. - if ((prevState < 0 && this.playState !== prevState) || - (this.playState <= 0 && this.currentPlayTimes !== prevPlayTimes)) { - this._frameIndex = -1; - } - return true; - }; - TimelineState.prototype.init = function (armature, animationState, timelineData) { - this._armature = armature; - this._animationState = animationState; - this._timelineData = timelineData; - this._actionTimeline = this._animationState._actionTimeline; - if (this === this._actionTimeline) { - this._actionTimeline = null; // - } - this._animationData = this._animationState._animationData; - this._frameRate = this._animationData.parent.frameRate; - this._frameRateR = 1.0 / this._frameRate; - this._position = this._animationState._position; - this._duration = this._animationState._duration; - this._dragonBonesData = this._animationData.parent.parent; // May by the animation data is not belone to this armature data. - if (this._timelineData !== null) { - this._frameIntArray = this._dragonBonesData.frameIntArray; - this._frameFloatArray = this._dragonBonesData.frameFloatArray; - this._frameArray = this._dragonBonesData.frameArray; - this._timelineArray = this._dragonBonesData.timelineArray; - this._frameIndices = this._dragonBonesData.frameIndices; - this._frameCount = this._timelineArray[this._timelineData.offset + 2 /* TimelineKeyFrameCount */]; - this._frameValueOffset = this._timelineArray[this._timelineData.offset + 4 /* TimelineFrameValueOffset */]; - this._timeScale = 100.0 / this._timelineArray[this._timelineData.offset + 0 /* TimelineScale */]; - this._timeOffset = this._timelineArray[this._timelineData.offset + 1 /* TimelineOffset */] * 0.01; - } - }; - TimelineState.prototype.fadeOut = function () { }; - TimelineState.prototype.update = function (passedTime) { - if (this._setCurrentTime(passedTime)) { - if (this._frameCount > 1) { - var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint - var frameIndex = this._frameIndices[this._timelineData.frameIndicesOffset + timelineFrameIndex]; - if (this._frameIndex !== frameIndex) { - this._frameIndex = frameIndex; - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; - this._onArriveAtFrame(); - } - } - else if (this._frameIndex < 0) { - this._frameIndex = 0; - if (this._timelineData !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; - } - this._onArriveAtFrame(); - } - if (this._tweenState !== 0 /* None */) { - this._onUpdateFrame(); - } - } - }; - return TimelineState; - }(dragonBones.BaseObject)); - dragonBones.TimelineState = TimelineState; - /** - * @internal - */ - var TweenTimelineState = /** @class */ (function (_super) { - __extends(TweenTimelineState, _super); - function TweenTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - TweenTimelineState._getEasingValue = function (tweenType, progress, easing) { - var value = progress; - switch (tweenType) { - case 3 /* QuadIn */: - value = Math.pow(progress, 2.0); - break; - case 4 /* QuadOut */: - value = 1.0 - Math.pow(1.0 - progress, 2.0); - break; - case 5 /* QuadInOut */: - value = 0.5 * (1.0 - Math.cos(progress * Math.PI)); - break; - } - return (value - progress) * easing + progress; - }; - TweenTimelineState._getEasingCurveValue = function (progress, samples, count, offset) { - if (progress <= 0.0) { - return 0.0; - } - else if (progress >= 1.0) { - return 1.0; - } - var segmentCount = count + 1; // + 2 - 1 - var valueIndex = Math.floor(progress * segmentCount); - var fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; - var toValue = (valueIndex === segmentCount - 1) ? 10000.0 : samples[offset + valueIndex]; - return (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)) * 0.0001; - }; - TweenTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._tweenType = 0 /* None */; - this._curveCount = 0; - this._framePosition = 0.0; - this._frameDurationR = 0.0; - this._tweenProgress = 0.0; - this._tweenEasing = 0.0; - }; - TweenTimelineState.prototype._onArriveAtFrame = function () { - if (this._frameCount > 1 && - (this._frameIndex !== this._frameCount - 1 || - this._animationState.playTimes === 0 || - this._animationState.currentPlayTimes < this._animationState.playTimes - 1)) { - this._tweenType = this._frameArray[this._frameOffset + 1 /* FrameTweenType */]; // TODO recode ture tween type. - this._tweenState = this._tweenType === 0 /* None */ ? 1 /* Once */ : 2 /* Always */; - if (this._tweenType === 2 /* Curve */) { - this._curveCount = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */]; - } - else if (this._tweenType !== 0 /* None */ && this._tweenType !== 1 /* Line */) { - this._tweenEasing = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] * 0.01; - } - this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; - if (this._frameIndex === this._frameCount - 1) { - this._frameDurationR = 1.0 / (this._animationData.duration - this._framePosition); - } - else { - var nextFrameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex + 1]; - var frameDuration = this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition; - if (frameDuration > 0) { - this._frameDurationR = 1.0 / frameDuration; - } - else { - this._frameDurationR = 0.0; - } - } - } - else { - this._tweenState = 1 /* Once */; - } - }; - TweenTimelineState.prototype._onUpdateFrame = function () { - if (this._tweenState === 2 /* Always */) { - this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; - if (this._tweenType === 2 /* Curve */) { - this._tweenProgress = TweenTimelineState._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + 3 /* FrameCurveSamples */); - } - else if (this._tweenType !== 1 /* Line */) { - this._tweenProgress = TweenTimelineState._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing); - } - } - else { - this._tweenProgress = 0.0; - } - }; - return TweenTimelineState; - }(TimelineState)); - dragonBones.TweenTimelineState = TweenTimelineState; - /** - * @internal - */ - var BoneTimelineState = /** @class */ (function (_super) { - __extends(BoneTimelineState, _super); - function BoneTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.bone = null; // - this.bonePose = null; // - }; - BoneTimelineState.prototype.blend = function (state) { - var blendWeight = this.bone._blendState.blendWeight; - var animationPose = this.bone.animationPose; - var result = this.bonePose.result; - if (state === 2) { - animationPose.x += result.x * blendWeight; - animationPose.y += result.y * blendWeight; - animationPose.rotation += result.rotation * blendWeight; - animationPose.skew += result.skew * blendWeight; - animationPose.scaleX += (result.scaleX - 1.0) * blendWeight; - animationPose.scaleY += (result.scaleY - 1.0) * blendWeight; - } - else if (blendWeight !== 1.0) { - animationPose.x = result.x * blendWeight; - animationPose.y = result.y * blendWeight; - animationPose.rotation = result.rotation * blendWeight; - animationPose.skew = result.skew * blendWeight; - animationPose.scaleX = (result.scaleX - 1.0) * blendWeight + 1.0; - animationPose.scaleY = (result.scaleY - 1.0) * blendWeight + 1.0; - } - else { - animationPose.x = result.x; - animationPose.y = result.y; - animationPose.rotation = result.rotation; - animationPose.skew = result.skew; - animationPose.scaleX = result.scaleX; - animationPose.scaleY = result.scaleY; - } - if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { - this.bone._transformDirty = true; - } - }; - return BoneTimelineState; - }(TweenTimelineState)); - dragonBones.BoneTimelineState = BoneTimelineState; - /** - * @internal - */ - var SlotTimelineState = /** @class */ (function (_super) { - __extends(SlotTimelineState, _super); - function SlotTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SlotTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.slot = null; // - }; - return SlotTimelineState; - }(TweenTimelineState)); - dragonBones.SlotTimelineState = SlotTimelineState; - /** - * @internal - */ - var ConstraintTimelineState = /** @class */ (function (_super) { - __extends(ConstraintTimelineState, _super); - function ConstraintTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ConstraintTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.constraint = null; // - }; - return ConstraintTimelineState; - }(TweenTimelineState)); - dragonBones.ConstraintTimelineState = ConstraintTimelineState; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var ActionTimelineState = /** @class */ (function (_super) { - __extends(ActionTimelineState, _super); - function ActionTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ActionTimelineState.toString = function () { - return "[class dragonBones.ActionTimelineState]"; - }; - ActionTimelineState.prototype._onCrossFrame = function (frameIndex) { - var eventDispatcher = this._armature.eventDispatcher; - if (this._animationState.actionEnabled) { - var frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + frameIndex]; - var actionCount = this._frameArray[frameOffset + 1]; - var actions = this._animationData.parent.actions; // May be the animaton data not belong to this armature data. - for (var i = 0; i < actionCount; ++i) { - var actionIndex = this._frameArray[frameOffset + 2 + i]; - var action = actions[actionIndex]; - if (action.type === 0 /* Play */) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - eventObject.time = this._frameArray[frameOffset] / this._frameRate; - eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - this._armature._bufferAction(eventObject, true); - } - else { - var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; - if (action.type === 11 /* Sound */ || eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - eventObject.time = this._frameArray[frameOffset] / this._frameRate; - eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - this._armature._dragonBones.bufferEvent(eventObject); - } - } - } - } - }; - ActionTimelineState.prototype._onArriveAtFrame = function () { }; - ActionTimelineState.prototype._onUpdateFrame = function () { }; - ActionTimelineState.prototype.update = function (passedTime) { - var prevState = this.playState; - var prevPlayTimes = this.currentPlayTimes; - var prevTime = this.currentTime; - if (this._setCurrentTime(passedTime)) { - var eventDispatcher = this._armature.eventDispatcher; - if (prevState < 0) { - if (this.playState !== prevState) { - if (this._animationState.displayControl && this._animationState.resetToPose) { - this._armature._sortZOrder(null, 0); - } - prevPlayTimes = this.currentPlayTimes; - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.START)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = dragonBones.EventObject.START; - eventObject.armature = this._armature; - eventObject.animationState = this._animationState; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - else { - return; - } - } - var isReverse = this._animationState.timeScale < 0.0; - var loopCompleteEvent = null; - var completeEvent = null; - if (this.currentPlayTimes !== prevPlayTimes) { - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.LOOP_COMPLETE)) { - loopCompleteEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - loopCompleteEvent.type = dragonBones.EventObject.LOOP_COMPLETE; - loopCompleteEvent.armature = this._armature; - loopCompleteEvent.animationState = this._animationState; - } - if (this.playState > 0) { - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.COMPLETE)) { - completeEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - completeEvent.type = dragonBones.EventObject.COMPLETE; - completeEvent.armature = this._armature; - completeEvent.animationState = this._animationState; - } - } - } - if (this._frameCount > 1) { - var timelineData = this._timelineData; - var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint - var frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; - if (this._frameIndex !== frameIndex) { - var crossedFrameIndex = this._frameIndex; - this._frameIndex = frameIndex; - if (this._timelineArray !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; - if (isReverse) { - if (crossedFrameIndex < 0) { - var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; - if (this.currentPlayTimes === prevPlayTimes) { - if (crossedFrameIndex === frameIndex) { - crossedFrameIndex = -1; - } - } - } - while (crossedFrameIndex >= 0) { - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this._position <= framePosition && - framePosition <= this._position + this._duration) { - this._onCrossFrame(crossedFrameIndex); - } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - if (crossedFrameIndex > 0) { - crossedFrameIndex--; - } - else { - crossedFrameIndex = this._frameCount - 1; - } - if (crossedFrameIndex === frameIndex) { - break; - } - } - } - else { - if (crossedFrameIndex < 0) { - var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { - if (prevTime <= framePosition) { - if (crossedFrameIndex > 0) { - crossedFrameIndex--; - } - else { - crossedFrameIndex = this._frameCount - 1; - } - } - else if (crossedFrameIndex === frameIndex) { - crossedFrameIndex = -1; - } - } - } - while (crossedFrameIndex >= 0) { - if (crossedFrameIndex < this._frameCount - 1) { - crossedFrameIndex++; - } - else { - crossedFrameIndex = 0; - } - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this._position <= framePosition && - framePosition <= this._position + this._duration) { - this._onCrossFrame(crossedFrameIndex); - } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - if (crossedFrameIndex === frameIndex) { - break; - } - } - } - } - } - } - else if (this._frameIndex < 0) { - this._frameIndex = 0; - if (this._timelineData !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; - // Arrive at frame. - var framePosition = this._frameArray[this._frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { - if (prevTime <= framePosition) { - this._onCrossFrame(this._frameIndex); - } - } - else if (this._position <= framePosition) { - if (!isReverse && loopCompleteEvent !== null) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - this._onCrossFrame(this._frameIndex); - } - } - } - if (loopCompleteEvent !== null) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - } - if (completeEvent !== null) { - this._armature._dragonBones.bufferEvent(completeEvent); - } - } - }; - ActionTimelineState.prototype.setCurrentTime = function (value) { - this._setCurrentTime(value); - this._frameIndex = -1; - }; - return ActionTimelineState; - }(dragonBones.TimelineState)); - dragonBones.ActionTimelineState = ActionTimelineState; - /** - * @internal - */ - var ZOrderTimelineState = /** @class */ (function (_super) { - __extends(ZOrderTimelineState, _super); - function ZOrderTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ZOrderTimelineState.toString = function () { - return "[class dragonBones.ZOrderTimelineState]"; - }; - ZOrderTimelineState.prototype._onArriveAtFrame = function () { - if (this.playState >= 0) { - var count = this._frameArray[this._frameOffset + 1]; - if (count > 0) { - this._armature._sortZOrder(this._frameArray, this._frameOffset + 2); - } - else { - this._armature._sortZOrder(null, 0); - } - } - }; - ZOrderTimelineState.prototype._onUpdateFrame = function () { }; - return ZOrderTimelineState; - }(dragonBones.TimelineState)); - dragonBones.ZOrderTimelineState = ZOrderTimelineState; - /** - * @internal - */ - var BoneAllTimelineState = /** @class */ (function (_super) { - __extends(BoneAllTimelineState, _super); - function BoneAllTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneAllTimelineState.toString = function () { - return "[class dragonBones.BoneAllTimelineState]"; - }; - BoneAllTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 6; // ...(timeline value offset)|xxxxxx|xxxxxx|(Value offset)xxxxx|(Next offset)xxxxx|xxxxxx|xxxxxx|... - var scale = this._armature._armatureData.scale; - var frameFloatArray = this._frameFloatArray; - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.x = frameFloatArray[valueOffset++] * scale; - current.y = frameFloatArray[valueOffset++] * scale; - current.rotation = frameFloatArray[valueOffset++]; - current.skew = frameFloatArray[valueOffset++]; - current.scaleX = frameFloatArray[valueOffset++]; - current.scaleY = frameFloatArray[valueOffset++]; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; // + 0 * 6 - } - delta.x = frameFloatArray[valueOffset++] * scale - current.x; - delta.y = frameFloatArray[valueOffset++] * scale - current.y; - delta.rotation = frameFloatArray[valueOffset++] - current.rotation; - delta.skew = frameFloatArray[valueOffset++] - current.skew; - delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; - delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; - } - else { - delta.x = 0.0; - delta.y = 0.0; - delta.rotation = 0.0; - delta.skew = 0.0; - delta.scaleX = 0.0; - delta.scaleY = 0.0; - } - } - else { - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.x = 0.0; - current.y = 0.0; - current.rotation = 0.0; - current.skew = 0.0; - current.scaleX = 1.0; - current.scaleY = 1.0; - delta.x = 0.0; - delta.y = 0.0; - delta.rotation = 0.0; - delta.skew = 0.0; - delta.scaleX = 0.0; - delta.scaleY = 0.0; - } - }; - BoneAllTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var current = this.bonePose.current; - var delta = this.bonePose.delta; - var result = this.bonePose.result; - this.bone._transformDirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - result.x = current.x + delta.x * this._tweenProgress; - result.y = current.y + delta.y * this._tweenProgress; - result.rotation = current.rotation + delta.rotation * this._tweenProgress; - result.skew = current.skew + delta.skew * this._tweenProgress; - result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; - result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; - }; - BoneAllTimelineState.prototype.fadeOut = function () { - var result = this.bonePose.result; - result.rotation = dragonBones.Transform.normalizeRadian(result.rotation); - result.skew = dragonBones.Transform.normalizeRadian(result.skew); - }; - return BoneAllTimelineState; - }(dragonBones.BoneTimelineState)); - dragonBones.BoneAllTimelineState = BoneAllTimelineState; - /** - * @internal - */ - var BoneTranslateTimelineState = /** @class */ (function (_super) { - __extends(BoneTranslateTimelineState, _super); - function BoneTranslateTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneTranslateTimelineState.toString = function () { - return "[class dragonBones.BoneTranslateTimelineState]"; - }; - BoneTranslateTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 2; - var scale = this._armature._armatureData.scale; - var frameFloatArray = this._frameFloatArray; - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.x = frameFloatArray[valueOffset++] * scale; - current.y = frameFloatArray[valueOffset++] * scale; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; // + 0 * 2 - } - delta.x = frameFloatArray[valueOffset++] * scale - current.x; - delta.y = frameFloatArray[valueOffset++] * scale - current.y; - } - else { - delta.x = 0.0; - delta.y = 0.0; - } - } - else { - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.x = 0.0; - current.y = 0.0; - delta.x = 0.0; - delta.y = 0.0; - } - }; - BoneTranslateTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var current = this.bonePose.current; - var delta = this.bonePose.delta; - var result = this.bonePose.result; - this.bone._transformDirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - result.x = (current.x + delta.x * this._tweenProgress); - result.y = (current.y + delta.y * this._tweenProgress); - }; - return BoneTranslateTimelineState; - }(dragonBones.BoneTimelineState)); - dragonBones.BoneTranslateTimelineState = BoneTranslateTimelineState; - /** - * @internal - */ - var BoneRotateTimelineState = /** @class */ (function (_super) { - __extends(BoneRotateTimelineState, _super); - function BoneRotateTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneRotateTimelineState.toString = function () { - return "[class dragonBones.BoneRotateTimelineState]"; - }; - BoneRotateTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 2; - var frameFloatArray = this._frameFloatArray; - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.rotation = frameFloatArray[valueOffset++]; - current.skew = frameFloatArray[valueOffset++]; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; // + 0 * 2 - delta.rotation = dragonBones.Transform.normalizeRadian(frameFloatArray[valueOffset++] - current.rotation); - } - else { - delta.rotation = frameFloatArray[valueOffset++] - current.rotation; - } - delta.skew = frameFloatArray[valueOffset++] - current.skew; - } - else { - delta.rotation = 0.0; - delta.skew = 0.0; - } - } - else { - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.rotation = 0.0; - current.skew = 0.0; - delta.rotation = 0.0; - delta.skew = 0.0; - } - }; - BoneRotateTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var current = this.bonePose.current; - var delta = this.bonePose.delta; - var result = this.bonePose.result; - this.bone._transformDirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - result.rotation = current.rotation + delta.rotation * this._tweenProgress; - result.skew = current.skew + delta.skew * this._tweenProgress; - }; - BoneRotateTimelineState.prototype.fadeOut = function () { - var result = this.bonePose.result; - result.rotation = dragonBones.Transform.normalizeRadian(result.rotation); - result.skew = dragonBones.Transform.normalizeRadian(result.skew); - }; - return BoneRotateTimelineState; - }(dragonBones.BoneTimelineState)); - dragonBones.BoneRotateTimelineState = BoneRotateTimelineState; - /** - * @internal - */ - var BoneScaleTimelineState = /** @class */ (function (_super) { - __extends(BoneScaleTimelineState, _super); - function BoneScaleTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneScaleTimelineState.toString = function () { - return "[class dragonBones.BoneScaleTimelineState]"; - }; - BoneScaleTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 2; - var frameFloatArray = this._frameFloatArray; - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.scaleX = frameFloatArray[valueOffset++]; - current.scaleY = frameFloatArray[valueOffset++]; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; // + 0 * 2 - } - delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; - delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; - } - else { - delta.scaleX = 0.0; - delta.scaleY = 0.0; - } - } - else { - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.scaleX = 1.0; - current.scaleY = 1.0; - delta.scaleX = 0.0; - delta.scaleY = 0.0; - } - }; - BoneScaleTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var current = this.bonePose.current; - var delta = this.bonePose.delta; - var result = this.bonePose.result; - this.bone._transformDirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; - result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; - }; - return BoneScaleTimelineState; - }(dragonBones.BoneTimelineState)); - dragonBones.BoneScaleTimelineState = BoneScaleTimelineState; - /** - * @internal - */ - var SurfaceTimelineState = /** @class */ (function (_super) { - __extends(SurfaceTimelineState, _super); - function SurfaceTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._current = []; - _this._delta = []; - _this._result = []; - return _this; - } - SurfaceTimelineState.toString = function () { - return "[class dragonBones.SurfaceTimelineState]"; - }; - SurfaceTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.surface = null; - this._frameFloatOffset = 0; - this._valueCount = 0; - this._deformCount = 0; - this._valueOffset = 0; - this._current.length = 0; - this._delta.length = 0; - this._result.length = 0; - }; - SurfaceTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; - var scale = this._armature._armatureData.scale; - var frameFloatArray = this._frameFloatArray; - if (this._tweenState === 2 /* Always */) { - var nextValueOffset = valueOffset + this._valueCount; - if (this._frameIndex === this._frameCount - 1) { - nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; - } - for (var i = 0; i < this._valueCount; ++i) { - this._delta[i] = frameFloatArray[nextValueOffset + i] * scale - (this._current[i] = frameFloatArray[valueOffset + i] * scale); - } - } - else { - for (var i = 0; i < this._valueCount; ++i) { - this._current[i] = frameFloatArray[valueOffset + i] * scale; - } - } - } - else { - for (var i = 0; i < this._valueCount; ++i) { - this._current[i] = 0.0; - } - } - }; - SurfaceTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - this.surface._transformDirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - for (var i = 0; i < this._valueCount; ++i) { - this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; - } - }; - SurfaceTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - if (this._timelineData !== null) { - var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; - this._deformCount = this._frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._valueCount = this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; - this._valueOffset = this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; - this._frameFloatOffset = this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; - } - else { - this._deformCount = this.surface._deformVertices.length; - this._valueCount = this._deformCount; - this._valueOffset = 0; - this._frameFloatOffset = 0; - } - this._current.length = this._valueCount; - this._delta.length = this._valueCount; - this._result.length = this._valueCount; - for (var i = 0; i < this._valueCount; ++i) { - this._delta[i] = 0.0; - } - }; - SurfaceTimelineState.prototype.blend = function (state) { - var blendWeight = this.surface._blendState.blendWeight; - var result = this.surface._deformVertices; - for (var i = 0; i < this._deformCount; ++i) { - var value = 0.0; - if (i < this._valueOffset) { - value = this._frameFloatArray[this._frameFloatOffset + i]; - } - else if (i < this._valueOffset + this._valueCount) { - value = this._result[i - this._valueOffset]; - } - else { - value = this._frameFloatArray[this._frameFloatOffset + i - this._valueCount]; - } - if (state === 2) { - result[i] += value * blendWeight; - } - else if (blendWeight !== 1.0) { - result[i] = value * blendWeight; - } - else { - result[i] = value; - } - } - if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { - this.surface._transformDirty = true; - } - }; - return SurfaceTimelineState; - }(dragonBones.TweenTimelineState)); - dragonBones.SurfaceTimelineState = SurfaceTimelineState; - /** - * @internal - */ - var SlotDislayTimelineState = /** @class */ (function (_super) { - __extends(SlotDislayTimelineState, _super); - function SlotDislayTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SlotDislayTimelineState.toString = function () { - return "[class dragonBones.SlotDislayTimelineState]"; - }; - SlotDislayTimelineState.prototype._onArriveAtFrame = function () { - if (this.playState >= 0) { - var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : this.slot._slotData.displayIndex; - if (this.slot.displayIndex !== displayIndex) { - this.slot._setDisplayIndex(displayIndex, true); - } - } - }; - return SlotDislayTimelineState; - }(dragonBones.SlotTimelineState)); - dragonBones.SlotDislayTimelineState = SlotDislayTimelineState; - /** - * @internal - */ - var SlotColorTimelineState = /** @class */ (function (_super) { - __extends(SlotColorTimelineState, _super); - function SlotColorTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._current = [0, 0, 0, 0, 0, 0, 0, 0]; - _this._delta = [0, 0, 0, 0, 0, 0, 0, 0]; - _this._result = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; - return _this; - } - SlotColorTimelineState.toString = function () { - return "[class dragonBones.SlotColorTimelineState]"; - }; - SlotColorTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._dirty = false; - }; - SlotColorTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var intArray = this._dragonBonesData.intArray; - var frameIntArray = this._frameIntArray; - var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 1; // ...(timeline value offset)|x|x|(Value offset)|(Next offset)|x|x|... - var colorOffset = frameIntArray[valueOffset]; - if (colorOffset < 0) { - colorOffset += 65536; // Fixed out of bouds bug. - } - this._current[0] = intArray[colorOffset++]; - this._current[1] = intArray[colorOffset++]; - this._current[2] = intArray[colorOffset++]; - this._current[3] = intArray[colorOffset++]; - this._current[4] = intArray[colorOffset++]; - this._current[5] = intArray[colorOffset++]; - this._current[6] = intArray[colorOffset++]; - this._current[7] = intArray[colorOffset++]; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; - } - else { - colorOffset = frameIntArray[valueOffset + 1 * 1]; - } - if (colorOffset < 0) { - colorOffset += 65536; // Fixed out of bouds bug. - } - this._delta[0] = intArray[colorOffset++] - this._current[0]; - this._delta[1] = intArray[colorOffset++] - this._current[1]; - this._delta[2] = intArray[colorOffset++] - this._current[2]; - this._delta[3] = intArray[colorOffset++] - this._current[3]; - this._delta[4] = intArray[colorOffset++] - this._current[4]; - this._delta[5] = intArray[colorOffset++] - this._current[5]; - this._delta[6] = intArray[colorOffset++] - this._current[6]; - this._delta[7] = intArray[colorOffset++] - this._current[7]; - } - } - else { - var color = this.slot._slotData.color; - this._current[0] = color.alphaMultiplier * 100.0; - this._current[1] = color.redMultiplier * 100.0; - this._current[2] = color.greenMultiplier * 100.0; - this._current[3] = color.blueMultiplier * 100.0; - this._current[4] = color.alphaOffset; - this._current[5] = color.redOffset; - this._current[6] = color.greenOffset; - this._current[7] = color.blueOffset; - } - }; - SlotColorTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - this._dirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - this._result[0] = (this._current[0] + this._delta[0] * this._tweenProgress) * 0.01; - this._result[1] = (this._current[1] + this._delta[1] * this._tweenProgress) * 0.01; - this._result[2] = (this._current[2] + this._delta[2] * this._tweenProgress) * 0.01; - this._result[3] = (this._current[3] + this._delta[3] * this._tweenProgress) * 0.01; - this._result[4] = this._current[4] + this._delta[4] * this._tweenProgress; - this._result[5] = this._current[5] + this._delta[5] * this._tweenProgress; - this._result[6] = this._current[6] + this._delta[6] * this._tweenProgress; - this._result[7] = this._current[7] + this._delta[7] * this._tweenProgress; - }; - SlotColorTimelineState.prototype.fadeOut = function () { - this._tweenState = 0 /* None */; - this._dirty = false; - }; - SlotColorTimelineState.prototype.update = function (passedTime) { - _super.prototype.update.call(this, passedTime); - // Fade animation. - if (this._tweenState !== 0 /* None */ || this._dirty) { - var result = this.slot._colorTransform; - if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { - if (result.alphaMultiplier !== this._result[0] || - result.redMultiplier !== this._result[1] || - result.greenMultiplier !== this._result[2] || - result.blueMultiplier !== this._result[3] || - result.alphaOffset !== this._result[4] || - result.redOffset !== this._result[5] || - result.greenOffset !== this._result[6] || - result.blueOffset !== this._result[7]) { - var fadeProgress = Math.pow(this._animationState._fadeProgress, 4); - result.alphaMultiplier += (this._result[0] - result.alphaMultiplier) * fadeProgress; - result.redMultiplier += (this._result[1] - result.redMultiplier) * fadeProgress; - result.greenMultiplier += (this._result[2] - result.greenMultiplier) * fadeProgress; - result.blueMultiplier += (this._result[3] - result.blueMultiplier) * fadeProgress; - result.alphaOffset += (this._result[4] - result.alphaOffset) * fadeProgress; - result.redOffset += (this._result[5] - result.redOffset) * fadeProgress; - result.greenOffset += (this._result[6] - result.greenOffset) * fadeProgress; - result.blueOffset += (this._result[7] - result.blueOffset) * fadeProgress; - this.slot._colorDirty = true; - } - } - else if (this._dirty) { - this._dirty = false; - if (result.alphaMultiplier !== this._result[0] || - result.redMultiplier !== this._result[1] || - result.greenMultiplier !== this._result[2] || - result.blueMultiplier !== this._result[3] || - result.alphaOffset !== this._result[4] || - result.redOffset !== this._result[5] || - result.greenOffset !== this._result[6] || - result.blueOffset !== this._result[7]) { - result.alphaMultiplier = this._result[0]; - result.redMultiplier = this._result[1]; - result.greenMultiplier = this._result[2]; - result.blueMultiplier = this._result[3]; - result.alphaOffset = this._result[4]; - result.redOffset = this._result[5]; - result.greenOffset = this._result[6]; - result.blueOffset = this._result[7]; - this.slot._colorDirty = true; - } - } - } - }; - return SlotColorTimelineState; - }(dragonBones.SlotTimelineState)); - dragonBones.SlotColorTimelineState = SlotColorTimelineState; - /** - * @internal - */ - var DeformTimelineState = /** @class */ (function (_super) { - __extends(DeformTimelineState, _super); - function DeformTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._current = []; - _this._delta = []; - _this._result = []; - return _this; - } - DeformTimelineState.toString = function () { - return "[class dragonBones.DeformTimelineState]"; - }; - DeformTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.vertexOffset = 0; - this._dirty = false; - this._frameFloatOffset = 0; - this._valueCount = 0; - this._deformCount = 0; - this._valueOffset = 0; - this._current.length = 0; - this._delta.length = 0; - this._result.length = 0; - }; - DeformTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; - var scale = this._armature._armatureData.scale; - var frameFloatArray = this._frameFloatArray; - if (this._tweenState === 2 /* Always */) { - var nextValueOffset = valueOffset + this._valueCount; - if (this._frameIndex === this._frameCount - 1) { - nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; - } - for (var i = 0; i < this._valueCount; ++i) { - this._delta[i] = frameFloatArray[nextValueOffset + i] * scale - (this._current[i] = frameFloatArray[valueOffset + i] * scale); - } - } - else { - for (var i = 0; i < this._valueCount; ++i) { - this._current[i] = frameFloatArray[valueOffset + i] * scale; - } - } - } - else { - for (var i = 0; i < this._valueCount; ++i) { - this._current[i] = 0.0; - } - } - }; - DeformTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - this._dirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - for (var i = 0; i < this._valueCount; ++i) { - this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; - } - }; - DeformTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - if (this._timelineData !== null) { - var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; - this.vertexOffset = this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */]; - if (this.vertexOffset < 0) { - this.vertexOffset += 65536; // Fixed out of bouds bug. - } - this._deformCount = this._frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._valueCount = this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; - this._valueOffset = this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; - this._frameFloatOffset = this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; - } - else { - var deformVertices = this.slot._deformVertices; - this._deformCount = deformVertices !== null ? deformVertices.vertices.length : 0; - this._valueCount = this._deformCount; - this._valueOffset = 0; - this._frameFloatOffset = 0; - } - this._current.length = this._valueCount; - this._delta.length = this._valueCount; - this._result.length = this._valueCount; - for (var i = 0; i < this._valueCount; ++i) { - this._delta[i] = 0.0; - } - }; - DeformTimelineState.prototype.fadeOut = function () { - this._tweenState = 0 /* None */; - this._dirty = false; - }; - DeformTimelineState.prototype.update = function (passedTime) { - var deformVertices = this.slot._deformVertices; - if (deformVertices === null || deformVertices.verticesData === null || deformVertices.verticesData.offset !== this.vertexOffset) { - return; - } - _super.prototype.update.call(this, passedTime); - // Fade animation. - if (this._tweenState !== 0 /* None */ || this._dirty) { - var result = deformVertices.vertices; - if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { - var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); - for (var i = 0; i < this._deformCount; ++i) { - if (i < this._valueOffset) { - result[i] += (this._frameFloatArray[this._frameFloatOffset + i] - result[i]) * fadeProgress; - } - else if (i < this._valueOffset + this._valueCount) { - result[i] += (this._result[i - this._valueOffset] - result[i]) * fadeProgress; - } - else { - result[i] += (this._frameFloatArray[this._frameFloatOffset + i - this._valueCount] - result[i]) * fadeProgress; - } - } - deformVertices.verticesDirty = true; - } - else if (this._dirty) { - this._dirty = false; - for (var i = 0; i < this._deformCount; ++i) { - if (i < this._valueOffset) { - result[i] = this._frameFloatArray[this._frameFloatOffset + i]; - } - else if (i < this._valueOffset + this._valueCount) { - result[i] = this._result[i - this._valueOffset]; - } - else { - result[i] = this._frameFloatArray[this._frameFloatOffset + i - this._valueCount]; - } - } - deformVertices.verticesDirty = true; - } - } - }; - return DeformTimelineState; - }(dragonBones.SlotTimelineState)); - dragonBones.DeformTimelineState = DeformTimelineState; - /** - * @internal - */ - var IKConstraintTimelineState = /** @class */ (function (_super) { - __extends(IKConstraintTimelineState, _super); - function IKConstraintTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraintTimelineState.toString = function () { - return "[class dragonBones.IKConstraintTimelineState]"; - }; - IKConstraintTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._current = 0.0; - this._delta = 0.0; - }; - IKConstraintTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - var ikConstraint = this.constraint; - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 2; - var frameIntArray = this._frameIntArray; - var bendPositive = frameIntArray[valueOffset++] !== 0; - this._current = frameIntArray[valueOffset++] * 0.01; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameIntOffset + this._frameValueOffset; // + 0 * 2 - } - this._delta = frameIntArray[valueOffset + 1] * 0.01 - this._current; - } - else { - this._delta = 0.0; - } - ikConstraint._bendPositive = bendPositive; - } - else { - var ikConstraintData = ikConstraint._constraintData; - this._current = ikConstraintData.weight; - this._delta = 0.0; - ikConstraint._bendPositive = ikConstraintData.bendPositive; - } - ikConstraint.invalidUpdate(); - }; - IKConstraintTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - var ikConstraint = this.constraint; - ikConstraint._weight = this._current + this._delta * this._tweenProgress; - ikConstraint.invalidUpdate(); - // TODO fade update. - }; - return IKConstraintTimelineState; - }(dragonBones.ConstraintTimelineState)); - dragonBones.IKConstraintTimelineState = IKConstraintTimelineState; - /** - * @internal - */ - var AnimationTimelineState = /** @class */ (function (_super) { - __extends(AnimationTimelineState, _super); - function AnimationTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._floats = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; - return _this; - } - AnimationTimelineState.toString = function () { - return "[class dragonBones.AnimationTimelineState]"; - }; - AnimationTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.animationState = null; - }; - AnimationTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { - return; - } - var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 2; - var frameRateR = 1.0 / this.animationState._animationData.parent.frameRate; - var frameIntArray = this._frameIntArray; - this._floats[0] = frameIntArray[valueOffset++] * frameRateR; - this._floats[3] = frameIntArray[valueOffset++] * 0.01; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameIntOffset + this._frameValueOffset; // + 0 * 2 - } - this._floats[1] = frameIntArray[valueOffset++] * frameRateR - this._floats[0]; - this._floats[4] = frameIntArray[valueOffset++] * 0.01 - this._floats[3]; - } - else { - this._floats[1] = 0.0; - this._floats[4] = 0.0; - } - }; - AnimationTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - if (this._floats[0] >= 0.0) { - this._floats[2] = this._floats[0] + this._floats[1] * this._tweenProgress; - } - this._floats[5] = this._floats[3] + this._floats[4] * this._tweenProgress; - }; - AnimationTimelineState.prototype.blend = function (state) { - var animationState = this.animationState; - var blendWeight = animationState._blendState.blendWeight; - if (state === 2) { - animationState.weight += this._floats[5] * blendWeight; - animationState.currentTime += this._floats[2] * blendWeight; - } - else { - animationState.weight = this._floats[5] * blendWeight; - animationState.currentTime = this._floats[2] * blendWeight; - } - }; - return AnimationTimelineState; - }(dragonBones.TweenTimelineState)); - dragonBones.AnimationTimelineState = AnimationTimelineState; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The properties of the object carry basic information about an event, - * which are passed as parameter or parameter's parameter to event listeners when an event occurs. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 - * @version DragonBones 4.5 - * @language zh_CN - */ - var EventObject = /** @class */ (function (_super) { - __extends(EventObject, _super); - function EventObject() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @internal - * @private - */ - EventObject.actionDataToInstance = function (data, instance, armature) { - if (data.type === 0 /* Play */) { - instance.type = EventObject.FRAME_EVENT; - } - else { - instance.type = data.type === 10 /* Frame */ ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; - } - instance.name = data.name; - instance.armature = armature; - instance.actionData = data; - instance.data = data.data; - if (data.bone !== null) { - instance.bone = armature.getBone(data.bone.name); - } - if (data.slot !== null) { - instance.slot = armature.getSlot(data.slot.name); - } - }; - EventObject.toString = function () { - return "[class dragonBones.EventObject]"; - }; - EventObject.prototype._onClear = function () { - this.time = 0.0; - this.type = ""; - this.name = ""; - this.armature = null; - this.bone = null; - this.slot = null; - this.animationState = null; - this.actionData = null; - this.data = null; - }; - /** - * - Animation start play. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画开始播放。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.START = "start"; - /** - * - Animation loop play complete once. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画循环播放完成一次。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.LOOP_COMPLETE = "loopComplete"; - /** - * - Animation play complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画播放完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.COMPLETE = "complete"; - /** - * - Animation fade in start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_IN = "fadeIn"; - /** - * - Animation fade in complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_IN_COMPLETE = "fadeInComplete"; - /** - * - Animation fade out start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_OUT = "fadeOut"; - /** - * - Animation fade out complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; - /** - * - Animation frame event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FRAME_EVENT = "frameEvent"; - /** - * - Animation frame sound event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧声音事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.SOUND_EVENT = "soundEvent"; - return EventObject; - }(dragonBones.BaseObject)); - dragonBones.EventObject = EventObject; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var DataParser = /** @class */ (function () { - function DataParser() { - } - DataParser._getArmatureType = function (value) { - switch (value.toLowerCase()) { - case "stage": - return 2 /* Stage */; - case "armature": - return 0 /* Armature */; - case "movieclip": - return 1 /* MovieClip */; - default: - return 0 /* Armature */; - } - }; - DataParser._getBoneType = function (value) { - switch (value.toLowerCase()) { - case "bone": - return 0 /* Bone */; - case "surface": - return 1 /* Surface */; - default: - return 0 /* Bone */; - } - }; - DataParser._getDisplayType = function (value) { - switch (value.toLowerCase()) { - case "image": - return 0 /* Image */; - case "mesh": - return 2 /* Mesh */; - case "armature": - return 1 /* Armature */; - case "boundingbox": - return 3 /* BoundingBox */; - case "path": - return 4 /* Path */; - default: - return 0 /* Image */; - } - }; - DataParser._getBoundingBoxType = function (value) { - switch (value.toLowerCase()) { - case "rectangle": - return 0 /* Rectangle */; - case "ellipse": - return 1 /* Ellipse */; - case "polygon": - return 2 /* Polygon */; - default: - return 0 /* Rectangle */; - } - }; - DataParser._getActionType = function (value) { - switch (value.toLowerCase()) { - case "play": - return 0 /* Play */; - case "frame": - return 10 /* Frame */; - case "sound": - return 11 /* Sound */; - default: - return 0 /* Play */; - } - }; - DataParser._getBlendMode = function (value) { - switch (value.toLowerCase()) { - case "normal": - return 0 /* Normal */; - case "add": - return 1 /* Add */; - case "alpha": - return 2 /* Alpha */; - case "darken": - return 3 /* Darken */; - case "difference": - return 4 /* Difference */; - case "erase": - return 5 /* Erase */; - case "hardlight": - return 6 /* HardLight */; - case "invert": - return 7 /* Invert */; - case "layer": - return 8 /* Layer */; - case "lighten": - return 9 /* Lighten */; - case "multiply": - return 10 /* Multiply */; - case "overlay": - return 11 /* Overlay */; - case "screen": - return 12 /* Screen */; - case "subtract": - return 13 /* Subtract */; - default: - return 0 /* Normal */; - } - }; - DataParser._getPositionMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "percent": - return 1 /* Percent */; - case "fixed": - return 0 /* Fixed */; - default: - return 1 /* Percent */; - } - }; - DataParser._getSpacingMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "length": - return 0 /* Length */; - case "percent": - return 2 /* Percent */; - case "fixed": - return 1 /* Fixed */; - default: - return 0 /* Length */; - } - }; - DataParser._getRotateMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "tangent": - return 0 /* Tangent */; - case "chain": - return 1 /* Chain */; - case "chainscale": - return 2 /* ChainScale */; - default: - return 0 /* Tangent */; - } - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - DataParser.parseDragonBonesData = function (rawData) { - console.warn("Deprecated."); - if (rawData instanceof ArrayBuffer) { - return dragonBones.BinaryDataParser.getInstance().parseDragonBonesData(rawData); - } - else { - return dragonBones.ObjectDataParser.getInstance().parseDragonBonesData(rawData); - } - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - DataParser.parseTextureAtlasData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.warn("已废弃"); - var textureAtlasData = {}; - var subTextureList = rawData[DataParser.SUB_TEXTURE]; - for (var i = 0, len = subTextureList.length; i < len; i++) { - var subTextureObject = subTextureList[i]; - var subTextureName = subTextureObject[DataParser.NAME]; - var subTextureRegion = new dragonBones.Rectangle(); - var subTextureFrame = null; - subTextureRegion.x = subTextureObject[DataParser.X] / scale; - subTextureRegion.y = subTextureObject[DataParser.Y] / scale; - subTextureRegion.width = subTextureObject[DataParser.WIDTH] / scale; - subTextureRegion.height = subTextureObject[DataParser.HEIGHT] / scale; - if (DataParser.FRAME_WIDTH in subTextureObject) { - subTextureFrame = new dragonBones.Rectangle(); - subTextureFrame.x = subTextureObject[DataParser.FRAME_X] / scale; - subTextureFrame.y = subTextureObject[DataParser.FRAME_Y] / scale; - subTextureFrame.width = subTextureObject[DataParser.FRAME_WIDTH] / scale; - subTextureFrame.height = subTextureObject[DataParser.FRAME_HEIGHT] / scale; - } - textureAtlasData[subTextureName] = { region: subTextureRegion, frame: subTextureFrame, rotated: false }; - } - return textureAtlasData; - }; - DataParser.DATA_VERSION_2_3 = "2.3"; - DataParser.DATA_VERSION_3_0 = "3.0"; - DataParser.DATA_VERSION_4_0 = "4.0"; - DataParser.DATA_VERSION_4_5 = "4.5"; - DataParser.DATA_VERSION_5_0 = "5.0"; - DataParser.DATA_VERSION_5_5 = "5.5"; - DataParser.DATA_VERSION = DataParser.DATA_VERSION_5_5; - DataParser.DATA_VERSIONS = [ - DataParser.DATA_VERSION_4_0, - DataParser.DATA_VERSION_4_5, - DataParser.DATA_VERSION_5_0, - DataParser.DATA_VERSION_5_5 - ]; - DataParser.TEXTURE_ATLAS = "textureAtlas"; - DataParser.SUB_TEXTURE = "SubTexture"; - DataParser.FORMAT = "format"; - DataParser.IMAGE_PATH = "imagePath"; - DataParser.WIDTH = "width"; - DataParser.HEIGHT = "height"; - DataParser.ROTATED = "rotated"; - DataParser.FRAME_X = "frameX"; - DataParser.FRAME_Y = "frameY"; - DataParser.FRAME_WIDTH = "frameWidth"; - DataParser.FRAME_HEIGHT = "frameHeight"; - DataParser.DRADON_BONES = "dragonBones"; - DataParser.USER_DATA = "userData"; - DataParser.ARMATURE = "armature"; - DataParser.BONE = "bone"; - DataParser.SURFACE = "surface"; - DataParser.SLOT = "slot"; - DataParser.CONSTRAINT = "constraint"; - DataParser.IK = "ik"; - DataParser.PATH_CONSTRAINT = "path"; - DataParser.SKIN = "skin"; - DataParser.DISPLAY = "display"; - DataParser.ANIMATION = "animation"; - DataParser.Z_ORDER = "zOrder"; - DataParser.FFD = "ffd"; - DataParser.FRAME = "frame"; - DataParser.TRANSLATE_FRAME = "translateFrame"; - DataParser.ROTATE_FRAME = "rotateFrame"; - DataParser.SCALE_FRAME = "scaleFrame"; - DataParser.DISPLAY_FRAME = "displayFrame"; - DataParser.COLOR_FRAME = "colorFrame"; - DataParser.DEFAULT_ACTIONS = "defaultActions"; - DataParser.ACTIONS = "actions"; - DataParser.EVENTS = "events"; - DataParser.INTS = "ints"; - DataParser.FLOATS = "floats"; - DataParser.STRINGS = "strings"; - DataParser.CANVAS = "canvas"; - DataParser.TRANSFORM = "transform"; - DataParser.PIVOT = "pivot"; - DataParser.AABB = "aabb"; - DataParser.COLOR = "color"; - DataParser.VERSION = "version"; - DataParser.COMPATIBLE_VERSION = "compatibleVersion"; - DataParser.FRAME_RATE = "frameRate"; - DataParser.TYPE = "type"; - DataParser.SUB_TYPE = "subType"; - DataParser.NAME = "name"; - DataParser.PARENT = "parent"; - DataParser.TARGET = "target"; - DataParser.STAGE = "stage"; - DataParser.SHARE = "share"; - DataParser.PATH = "path"; - DataParser.LENGTH = "length"; - DataParser.DISPLAY_INDEX = "displayIndex"; - DataParser.BLEND_MODE = "blendMode"; - DataParser.INHERIT_TRANSLATION = "inheritTranslation"; - DataParser.INHERIT_ROTATION = "inheritRotation"; - DataParser.INHERIT_SCALE = "inheritScale"; - DataParser.INHERIT_REFLECTION = "inheritReflection"; - DataParser.INHERIT_ANIMATION = "inheritAnimation"; - DataParser.INHERIT_DEFORM = "inheritDeform"; - DataParser.SEGMENT_X = "segmentX"; - DataParser.SEGMENT_Y = "segmentY"; - DataParser.BEND_POSITIVE = "bendPositive"; - DataParser.CHAIN = "chain"; - DataParser.WEIGHT = "weight"; - DataParser.FADE_IN_TIME = "fadeInTime"; - DataParser.PLAY_TIMES = "playTimes"; - DataParser.SCALE = "scale"; - DataParser.OFFSET = "offset"; - DataParser.POSITION = "position"; - DataParser.DURATION = "duration"; - DataParser.TWEEN_EASING = "tweenEasing"; - DataParser.TWEEN_ROTATE = "tweenRotate"; - DataParser.TWEEN_SCALE = "tweenScale"; - DataParser.CLOCK_WISE = "clockwise"; - DataParser.CURVE = "curve"; - DataParser.SOUND = "sound"; - DataParser.EVENT = "event"; - DataParser.ACTION = "action"; - DataParser.X = "x"; - DataParser.Y = "y"; - DataParser.SKEW_X = "skX"; - DataParser.SKEW_Y = "skY"; - DataParser.SCALE_X = "scX"; - DataParser.SCALE_Y = "scY"; - DataParser.VALUE = "value"; - DataParser.ROTATE = "rotate"; - DataParser.SKEW = "skew"; - DataParser.ALPHA_OFFSET = "aO"; - DataParser.RED_OFFSET = "rO"; - DataParser.GREEN_OFFSET = "gO"; - DataParser.BLUE_OFFSET = "bO"; - DataParser.ALPHA_MULTIPLIER = "aM"; - DataParser.RED_MULTIPLIER = "rM"; - DataParser.GREEN_MULTIPLIER = "gM"; - DataParser.BLUE_MULTIPLIER = "bM"; - DataParser.UVS = "uvs"; - DataParser.VERTICES = "vertices"; - DataParser.TRIANGLES = "triangles"; - DataParser.WEIGHTS = "weights"; - DataParser.SLOT_POSE = "slotPose"; - DataParser.BONE_POSE = "bonePose"; - DataParser.GLUE_WEIGHTS = "glueWeights"; - DataParser.GLUE_MESHES = "glueMeshes"; - DataParser.BONES = "bones"; - DataParser.POSITION_MODE = "positionMode"; - DataParser.SPACING_MODE = "spacingMode"; - DataParser.ROTATE_MODE = "rotateMode"; - DataParser.SPACING = "spacing"; - DataParser.ROTATE_OFFSET = "rotateOffset"; - DataParser.ROTATE_MIX = "rotateMix"; - DataParser.TRANSLATE_MIX = "translateMix"; - DataParser.TARGET_DISPLAY = "targetDisplay"; - DataParser.CLOSED = "closed"; - DataParser.CONSTANT_SPEED = "constantSpeed"; - DataParser.VERTEX_COUNT = "vertexCount"; - DataParser.LENGTHS = "lengths"; - DataParser.GOTO_AND_PLAY = "gotoAndPlay"; - DataParser.DEFAULT_NAME = "default"; - return DataParser; - }()); - dragonBones.DataParser = DataParser; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var ObjectDataParser = /** @class */ (function (_super) { - __extends(ObjectDataParser, _super); - function ObjectDataParser() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._rawTextureAtlasIndex = 0; - _this._rawBones = []; - _this._data = null; // - _this._armature = null; // - _this._bone = null; // - _this._surface = null; // - _this._slot = null; // - _this._skin = null; // - _this._mesh = null; // - _this._animation = null; // - _this._timeline = null; // - _this._rawTextureAtlases = null; - _this._defaultColorOffset = -1; - _this._prevClockwise = 0; - _this._prevRotation = 0.0; - _this._helpMatrixA = new dragonBones.Matrix(); - _this._helpMatrixB = new dragonBones.Matrix(); - _this._helpTransform = new dragonBones.Transform(); - _this._helpColorTransform = new dragonBones.ColorTransform(); - _this._helpPoint = new dragonBones.Point(); - _this._helpArray = []; - _this._intArray = []; - _this._floatArray = []; - _this._frameIntArray = []; - _this._frameFloatArray = []; - _this._frameArray = []; - _this._timelineArray = []; - _this._cacheRawMeshes = []; - _this._cacheMeshes = []; - _this._actionFrames = []; - _this._weightSlotPose = {}; - _this._weightBonePoses = {}; - _this._cacheBones = {}; - _this._slotChildActions = {}; - return _this; - } - ObjectDataParser._getBoolean = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - var type = typeof value; - if (type === "boolean") { - return value; - } - else if (type === "string") { - switch (value) { - case "0": - case "NaN": - case "": - case "false": - case "null": - case "undefined": - return false; - default: - return true; - } - } - else { - return !!value; - } - } - return defaultValue; - }; - ObjectDataParser._getNumber = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - if (value === null || value === "NaN") { - return defaultValue; - } - return +value || 0; - } - return defaultValue; - }; - ObjectDataParser._getString = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - var type = typeof value; - if (type === "string") { - if (dragonBones.DragonBones.webAssembly) { - for (var i = 0, l = value.length; i < l; ++i) { - if (value.charCodeAt(i) > 255) { - return encodeURI(value); - } - } - } - return value; - } - return String(value); - } - return defaultValue; - }; - ObjectDataParser.prototype._getCurvePoint = function (x1, y1, x2, y2, x3, y3, x4, y4, t, result) { - var l_t = 1.0 - t; - var powA = l_t * l_t; - var powB = t * t; - var kA = l_t * powA; - var kB = 3.0 * t * powA; - var kC = 3.0 * l_t * powB; - var kD = t * powB; - result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; - result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; - }; - ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { - var curveCount = curve.length; - var stepIndex = -2; - for (var i = 0, l = samples.length; i < l; ++i) { - var t = (i + 1) / (l + 1); // float - while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) { - stepIndex += 6; - } - var isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; - var x1 = isInCurve ? curve[stepIndex] : 0.0; - var y1 = isInCurve ? curve[stepIndex + 1] : 0.0; - var x2 = curve[stepIndex + 2]; - var y2 = curve[stepIndex + 3]; - var x3 = curve[stepIndex + 4]; - var y3 = curve[stepIndex + 5]; - var x4 = isInCurve ? curve[stepIndex + 6] : 1.0; - var y4 = isInCurve ? curve[stepIndex + 7] : 1.0; - var lower = 0.0; - var higher = 1.0; - while (higher - lower > 0.0001) { - var percentage = (higher + lower) * 0.5; - this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); - if (t - this._helpPoint.x > 0.0) { - lower = percentage; - } - else { - higher = percentage; - } - } - samples[i] = this._helpPoint.y; - } - }; - ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { - if (dragonBones.DataParser.EVENT in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); - } - if (dragonBones.DataParser.SOUND in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); - } - if (dragonBones.DataParser.ACTION in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.ACTION], frameStart, 0 /* Play */, bone, slot); - } - if (dragonBones.DataParser.EVENTS in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); - } - if (dragonBones.DataParser.ACTIONS in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); - } - }; - ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { - var actionOffset = dragonBones.DragonBones.webAssembly ? this._armature.actions.size() : this._armature.actions.length; - var actions = this._parseActionData(rawData, type, bone, slot); - var frameIndex = 0; - var frame = null; - for (var _i = 0, actions_2 = actions; _i < actions_2.length; _i++) { - var action = actions_2[_i]; - this._armature.addAction(action, false); - } - if (this._actionFrames.length === 0) { - frame = new ActionFrame(); - frame.frameStart = 0; - this._actionFrames.push(frame); - frame = null; - } - for (var _a = 0, _b = this._actionFrames; _a < _b.length; _a++) { - var eachFrame = _b[_a]; - if (eachFrame.frameStart === frameStart) { - frame = eachFrame; - break; - } - else if (eachFrame.frameStart > frameStart) { - break; - } - frameIndex++; - } - if (frame === null) { - frame = new ActionFrame(); - frame.frameStart = frameStart; - this._actionFrames.splice(frameIndex + 1, 0, frame); - } - for (var i = 0; i < actions.length; ++i) { - frame.actions.push(actionOffset + i); - } - }; - ObjectDataParser.prototype._parseArmature = function (rawData, scale) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); - armature.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - armature.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, this._data.frameRate); - armature.scale = scale; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - armature.type = dragonBones.DataParser._getArmatureType(rawData[dragonBones.DataParser.TYPE]); - } - else { - armature.type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Armature */); - } - if (armature.frameRate === 0) { - armature.frameRate = 24; - } - this._armature = armature; - if (dragonBones.DataParser.CANVAS in rawData) { - var rawCanvas = rawData[dragonBones.DataParser.CANVAS]; - var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); - if (dragonBones.DataParser.COLOR in rawCanvas) { - canvas.hasBackground = true; - } - else { - canvas.hasBackground = false; - } - canvas.color = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.COLOR, 0); - canvas.x = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.X, 0) * armature.scale; - canvas.y = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.Y, 0) * armature.scale; - canvas.width = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.WIDTH, 0) * armature.scale; - canvas.height = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.HEIGHT, 0) * armature.scale; - armature.canvas = canvas; - } - if (dragonBones.DataParser.AABB in rawData) { - var rawAABB = rawData[dragonBones.DataParser.AABB]; - armature.aabb.x = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.X, 0.0) * armature.scale; - armature.aabb.y = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.Y, 0.0) * armature.scale; - armature.aabb.width = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.WIDTH, 0.0) * armature.scale; - armature.aabb.height = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.HEIGHT, 0.0) * armature.scale; - } - if (dragonBones.DataParser.BONE in rawData) { - var rawBones = rawData[dragonBones.DataParser.BONE]; - for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { - var rawBone = rawBones_1[_i]; - var parentName = ObjectDataParser._getString(rawBone, dragonBones.DataParser.PARENT, ""); - var bone = this._parseBone(rawBone); - if (parentName.length > 0) { - var parent_1 = armature.getBone(parentName); - if (parent_1 !== null) { - bone.parent = parent_1; - } - else { - if (!(parentName in this._cacheBones)) { - this._cacheBones[parentName] = []; - } - this._cacheBones[parentName].push(bone); - } - } - if (bone.name in this._cacheBones) { - for (var _a = 0, _b = this._cacheBones[bone.name]; _a < _b.length; _a++) { - var child = _b[_a]; - child.parent = bone; - } - delete this._cacheBones[bone.name]; - } - armature.addBone(bone); - this._rawBones.push(bone); // Cache raw bones sort. - } - } - if (dragonBones.DataParser.IK in rawData) { - var rawIKS = rawData[dragonBones.DataParser.IK]; - for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { - var rawIK = rawIKS_1[_c]; - var constraint = this._parseIKConstraint(rawIK); - if (constraint) { - armature.addConstraint(constraint); - } - } - } - armature.sortBones(); - if (dragonBones.DataParser.SLOT in rawData) { - var zOrder = 0; - var rawSlots = rawData[dragonBones.DataParser.SLOT]; - for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { - var rawSlot = rawSlots_1[_d]; - armature.addSlot(this._parseSlot(rawSlot, zOrder++)); - } - } - if (dragonBones.DataParser.SKIN in rawData) { - var rawSkins = rawData[dragonBones.DataParser.SKIN]; - for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { - var rawSkin = rawSkins_1[_e]; - armature.addSkin(this._parseSkin(rawSkin)); - } - } - if (dragonBones.DataParser.PATH_CONSTRAINT in rawData) { - var rawPaths = rawData[dragonBones.DataParser.PATH_CONSTRAINT]; - for (var _f = 0, rawPaths_1 = rawPaths; _f < rawPaths_1.length; _f++) { - var rawPath = rawPaths_1[_f]; - var constraint = this._parsePathConstraint(rawPath); - if (constraint) { - armature.addConstraint(constraint); - } - } - } - for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { - var rawMeshData = this._cacheRawMeshes[i]; - if (!(dragonBones.DataParser.GLUE_WEIGHTS in rawMeshData) || !(dragonBones.DataParser.GLUE_MESHES in rawMeshData)) { - continue; - } - this._parseMeshGlue(rawMeshData, this._cacheMeshes[i]); - } - for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { - var rawData_1 = this._cacheRawMeshes[i]; - var shareName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SHARE, ""); - if (shareName.length === 0) { - continue; - } - var skinName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); - if (skinName.length === 0) { - skinName = dragonBones.DataParser.DEFAULT_NAME; - } - var shareMesh = armature.getMesh(skinName, "", shareName); // TODO slot; - if (shareMesh === null) { - continue; // Error. - } - var mesh = this._cacheMeshes[i]; - mesh.vertices.shareFrom(shareMesh.vertices); - } - if (dragonBones.DataParser.ANIMATION in rawData) { - var rawAnimations = rawData[dragonBones.DataParser.ANIMATION]; - for (var _g = 0, rawAnimations_1 = rawAnimations; _g < rawAnimations_1.length; _g++) { - var rawAnimation = rawAnimations_1[_g]; - var animation = this._parseAnimation(rawAnimation); - armature.addAnimation(animation); - } - } - if (dragonBones.DataParser.DEFAULT_ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.DEFAULT_ACTIONS], 0 /* Play */, null, null); - for (var _h = 0, actions_3 = actions; _h < actions_3.length; _h++) { - var action = actions_3[_h]; - armature.addAction(action, true); - if (action.type === 0 /* Play */) { - var animation = armature.getAnimation(action.name); - if (animation !== null) { - armature.defaultAnimation = animation; - } - } - } - } - if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - for (var _j = 0, actions_4 = actions; _j < actions_4.length; _j++) { - var action = actions_4[_j]; - armature.addAction(action, false); - } - } - // Clear helper. - this._rawBones.length = 0; - this._cacheRawMeshes.length = 0; - this._cacheMeshes.length = 0; - this._armature = null; - for (var k in this._weightSlotPose) { - delete this._weightSlotPose[k]; - } - for (var k in this._weightBonePoses) { - delete this._weightBonePoses[k]; - } - for (var k in this._cacheBones) { - delete this._cacheBones[k]; - } - for (var k in this._slotChildActions) { - delete this._slotChildActions[k]; - } - return armature; - }; - ObjectDataParser.prototype._parseBone = function (rawData) { - var type = 0 /* Bone */; - var scale = this._armature.scale; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - type = dragonBones.DataParser._getBoneType(rawData[dragonBones.DataParser.TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Bone */); - } - if (type === 0 /* Bone */) { - var bone = dragonBones.BaseObject.borrowObject(dragonBones.BoneData); - bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_TRANSLATION, true); - bone.inheritRotation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_ROTATION, true); - bone.inheritScale = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_SCALE, true); - bone.inheritReflection = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_REFLECTION, true); - bone.length = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.LENGTH, 0) * scale; - bone.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], bone.transform, scale); - } - return bone; - } - var surface = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceData); - surface.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - surface.segmentX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_X, 0); - surface.segmentY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_Y, 0); - surface.vertices.length = (surface.segmentX + 1) * (surface.segmentY + 1) * 2; - if (dragonBones.DataParser.VERTICES in rawData) { - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - for (var i = 0, l = surface.vertices.length; i < l; ++i) { - if (i < rawVertices.length) { - surface.vertices[i] = rawVertices[i] * scale; - } - else { - surface.vertices[i] = 0.0; - } - } - } - return surface; - }; - ObjectDataParser.prototype._parseIKConstraint = function (rawData) { - var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.BONE, "")); - if (bone === null) { - return null; - } - var target = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); - if (target === null) { - return null; - } - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); - constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.SCALE, false); - constraint.bendPositive = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true); - constraint.weight = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0); - constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - constraint.type = 0 /* IK */; - constraint.target = target; - var chain = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CHAIN, 0); - if (chain > 0 && bone.parent !== null) { - constraint.root = bone.parent; - constraint.bone = bone; - } - else { - constraint.root = bone; - constraint.bone = null; - } - return constraint; - }; - ObjectDataParser.prototype._parsePathConstraint = function (rawData) { - var target = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); - if (target === null) { - return null; - } - var defaultSkin = this._armature.defaultSkin; - if (defaultSkin === null) { - return null; - } - //TODO - var targetDisplay = defaultSkin.getDisplay(target.name, ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET_DISPLAY, target.name)); - if (targetDisplay === null || !(targetDisplay instanceof dragonBones.PathDisplayData)) { - return null; - } - var bones = rawData[dragonBones.DataParser.BONES]; - if (bones === null || bones.length === 0) { - return null; - } - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraintData); - constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - constraint.type = 1 /* Path */; - constraint.pathSlot = target; - constraint.pathDisplayData = targetDisplay; - constraint.target = target.parent; - constraint.positionMode = dragonBones.DataParser._getPositionMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.POSITION_MODE, "")); - constraint.spacingMode = dragonBones.DataParser._getSpacingMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.SPACING_MODE, "")); - constraint.rotateMode = dragonBones.DataParser._getRotateMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.ROTATE_MODE, "")); - constraint.position = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.POSITION, 0); - constraint.spacing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SPACING, 0); - constraint.rotateOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_OFFSET, 0); - constraint.rotateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_MIX, 1); - constraint.translateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TRANSLATE_MIX, 1); - // - for (var _i = 0, bones_3 = bones; _i < bones_3.length; _i++) { - var boneName = bones_3[_i]; - var bone = this._armature.getBone(boneName); - if (bone !== null) { - constraint.AddBone(bone); - if (constraint.root === null) { - constraint.root = bone; - } - } - } - return constraint; - }; - ObjectDataParser.prototype._parseSlot = function (rawData, zOrder) { - var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); - slot.displayIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); - slot.zOrder = zOrder; - slot.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.PARENT, "")); // - if (dragonBones.DataParser.BLEND_MODE in rawData && typeof rawData[dragonBones.DataParser.BLEND_MODE] === "string") { - slot.blendMode = dragonBones.DataParser._getBlendMode(rawData[dragonBones.DataParser.BLEND_MODE]); - } - else { - slot.blendMode = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLEND_MODE, 0 /* Normal */); - } - if (dragonBones.DataParser.COLOR in rawData) { - slot.color = dragonBones.SlotData.createColor(); - this._parseColorTransform(rawData[dragonBones.DataParser.COLOR], slot.color); - } - else { - slot.color = dragonBones.SlotData.DEFAULT_COLOR; - } - if (dragonBones.DataParser.ACTIONS in rawData) { - this._slotChildActions[slot.name] = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - } - return slot; - }; - ObjectDataParser.prototype._parseSkin = function (rawData) { - var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); - skin.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (skin.name.length === 0) { - skin.name = dragonBones.DataParser.DEFAULT_NAME; - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawSlots = rawData[dragonBones.DataParser.SLOT]; - this._skin = skin; - for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { - var rawSlot = rawSlots_2[_i]; - var slotName = ObjectDataParser._getString(rawSlot, dragonBones.DataParser.NAME, ""); - var slot = this._armature.getSlot(slotName); - if (slot !== null) { - this._slot = slot; - if (dragonBones.DataParser.DISPLAY in rawSlot) { - var rawDisplays = rawSlot[dragonBones.DataParser.DISPLAY]; - for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { - var rawDisplay = rawDisplays_1[_a]; - if (rawDisplay) { - skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); - } - else { - skin.addDisplay(slotName, null); - } - } - } - this._slot = null; // - } - } - this._skin = null; // - } - return skin; - }; - ObjectDataParser.prototype._parseDisplay = function (rawData) { - var name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - var path = ObjectDataParser._getString(rawData, dragonBones.DataParser.PATH, ""); - var type = 0 /* Image */; - var display = null; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - type = dragonBones.DataParser._getDisplayType(rawData[dragonBones.DataParser.TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, type); - } - switch (type) { - case 0 /* Image */: - var imageDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); - imageDisplay.name = name; - imageDisplay.path = path.length > 0 ? path : name; - this._parsePivot(rawData, imageDisplay); - break; - case 1 /* Armature */: - var armatureDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); - armatureDisplay.name = name; - armatureDisplay.path = path.length > 0 ? path : name; - armatureDisplay.inheritAnimation = true; - if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - for (var _i = 0, actions_5 = actions; _i < actions_5.length; _i++) { - var action = actions_5[_i]; - armatureDisplay.addAction(action); - } - } - else if (this._slot.name in this._slotChildActions) { - var displays = this._skin.getDisplays(this._slot.name); - if (displays === null ? this._slot.displayIndex === 0 : this._slot.displayIndex === displays.length) { - for (var _a = 0, _b = this._slotChildActions[this._slot.name]; _a < _b.length; _a++) { - var action = _b[_a]; - armatureDisplay.addAction(action); - } - delete this._slotChildActions[this._slot.name]; - } - } - break; - case 2 /* Mesh */: - var meshDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); - meshDisplay.vertices.inheritDeform = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_DEFORM, true); - meshDisplay.name = name; - meshDisplay.path = path.length > 0 ? path : name; - meshDisplay.vertices.data = this._data; - if (dragonBones.DataParser.SHARE in rawData) { - this._cacheRawMeshes.push(rawData); - this._cacheMeshes.push(meshDisplay); - } - else { - this._parseMesh(rawData, meshDisplay); - } - if ((dragonBones.DataParser.GLUE_WEIGHTS in rawData) && (dragonBones.DataParser.GLUE_MESHES in rawData)) { - this._cacheRawMeshes.push(rawData); - this._cacheMeshes.push(meshDisplay); - } - break; - case 3 /* BoundingBox */: - var boundingBox = this._parseBoundingBox(rawData); - if (boundingBox !== null) { - var boundingBoxDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); - boundingBoxDisplay.name = name; - boundingBoxDisplay.path = path.length > 0 ? path : name; - boundingBoxDisplay.boundingBox = boundingBox; - } - break; - case 4 /* Path */: - var rawCurveLengths = rawData[dragonBones.DataParser.LENGTHS]; - var pathDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.PathDisplayData); - pathDisplay.closed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CLOSED, false); - pathDisplay.constantSpeed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CONSTANT_SPEED, false); - pathDisplay.name = name; - pathDisplay.path = path.length > 0 ? path : name; - pathDisplay.vertices.data = this._data; - pathDisplay.curveLengths.length = rawCurveLengths.length; - for (var i = 0, l = rawCurveLengths.length; i < l; ++i) { - pathDisplay.curveLengths[i] = rawCurveLengths[i]; - } - this._parsePath(rawData, pathDisplay); - break; - } - if (display !== null && dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], display.transform, this._armature.scale); - } - return display; - }; - ObjectDataParser.prototype._parsePath = function (rawData, display) { - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var vertexCount = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VERTEX_COUNT, 0); // uint - var vertexOffset = this._floatArray.length; - var pathOffset = this._intArray.length; - display.vertices.offset = pathOffset; - this._intArray.length += 1 + 1; - this._intArray[pathOffset + 0 /* PathVertexCount */] = vertexCount; - this._intArray[pathOffset + 2 /* PathFloatOffset */] = vertexOffset; - if (!(dragonBones.DataParser.WEIGHTS in rawData)) { - this._floatArray.length += rawVertices.length; - for (var i = 0, l = rawVertices.length; i < l; ++i) { - this._floatArray[vertexOffset + i] = rawVertices[i]; - } - } - else { - var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; - var rawBones = rawData[dragonBones.DataParser.BONES]; - var weightBoneCount = rawBones.length; - var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; // uint - var weightOffset = this._intArray.length; - var floatOffset = this._floatArray.length; - var sortedBones = this._armature.sortedBones; - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - weight.count = weightCount; - weight.offset = weightOffset; - this._intArray.length += 1 + 1 + weightBoneCount + vertexCount + weightCount; - // - this._intArray[weightOffset + 0 /* WeigthBoneCount */] = weightBoneCount; - this._intArray[weightOffset + 1 /* WeigthFloatOffset */] = floatOffset; - for (var i = 0; i < weightBoneCount; i++) { - var rawBoneIndex = rawBones[i]; - var bone = this._rawBones[rawBoneIndex]; - weight.addBone(bone); - this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); - } - this._floatArray.length += weightCount * 3; - for (var i = 0, iW = 0, iV = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iF = floatOffset; i < weightCount; i++) { - var boneCount = rawWeights[iW++]; - this._intArray[iB++] = boneCount; - for (var j = 0; j < boneCount; j++) { - var boneIndex = rawWeights[iW++]; - var boneWeight = rawWeights[iW++]; - var x = rawVertices[iV++]; - var y = rawVertices[iV++]; - this._intArray[iB++] = rawBones.indexOf(boneIndex); - this._floatArray[iF++] = boneWeight; - this._floatArray[iF++] = x; - this._floatArray[iF++] = y; - } - } - display.vertices.weight = weight; - } - }; - ObjectDataParser.prototype._parsePivot = function (rawData, display) { - if (dragonBones.DataParser.PIVOT in rawData) { - var rawPivot = rawData[dragonBones.DataParser.PIVOT]; - display.pivot.x = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.X, 0.0); - display.pivot.y = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.Y, 0.0); - } - else { - display.pivot.x = 0.5; - display.pivot.y = 0.5; - } - }; - ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var rawUVs = rawData[dragonBones.DataParser.UVS]; - var rawTriangles = rawData[dragonBones.DataParser.TRIANGLES]; - var vertexCount = Math.floor(rawVertices.length / 2); // uint - var triangleCount = Math.floor(rawTriangles.length / 3); // uint - var vertexOffset = this._floatArray.length; - var uvOffset = vertexOffset + vertexCount * 2; - var meshOffset = this._intArray.length; - var meshName = this._skin.name + "_" + this._slot.name + "_" + mesh.name; // Cache pose data. - mesh.vertices.offset = meshOffset; - this._intArray.length += 1 + 1 + 1 + 1 + triangleCount * 3; - this._intArray[meshOffset + 0 /* MeshVertexCount */] = vertexCount; - this._intArray[meshOffset + 1 /* MeshTriangleCount */] = triangleCount; - this._intArray[meshOffset + 2 /* MeshFloatOffset */] = vertexOffset; - for (var i = 0, l = triangleCount * 3; i < l; ++i) { - this._intArray[meshOffset + 4 /* MeshVertexIndices */ + i] = rawTriangles[i]; - } - this._floatArray.length += vertexCount * 2 + vertexCount * 2; - for (var i = 0, l = vertexCount * 2; i < l; ++i) { - this._floatArray[vertexOffset + i] = rawVertices[i]; - this._floatArray[uvOffset + i] = rawUVs[i]; - } - if (dragonBones.DataParser.WEIGHTS in rawData) { - var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; - var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; - var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; - var sortedBones = this._armature.sortedBones; - var weightBoneIndices = new Array(); - var weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint - var floatOffset = this._floatArray.length; - var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; // uint - var weightOffset = this._intArray.length; - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - weight.count = weightCount; - weight.offset = weightOffset; - weightBoneIndices.length = weightBoneCount; - this._intArray.length += 1 + 1 + weightBoneCount + vertexCount + weightCount; - this._intArray[weightOffset + 1 /* WeigthFloatOffset */] = floatOffset; - for (var i = 0; i < weightBoneCount; ++i) { - var rawBoneIndex = rawBonePoses[i * 7]; // uint - var bone = this._rawBones[rawBoneIndex]; - weight.addBone(bone); - weightBoneIndices[i] = rawBoneIndex; - this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); - } - this._floatArray.length += weightCount * 3; - this._helpMatrixA.copyFromArray(rawSlotPose, 0); - for (var i = 0, iW = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { - var iD = i * 2; - var vertexBoneCount = this._intArray[iB++] = rawWeights[iW++]; // uint - var x = this._floatArray[vertexOffset + iD]; - var y = this._floatArray[vertexOffset + iD + 1]; - this._helpMatrixA.transformPoint(x, y, this._helpPoint); - x = this._helpPoint.x; - y = this._helpPoint.y; - for (var j = 0; j < vertexBoneCount; ++j) { - var rawBoneIndex = rawWeights[iW++]; // uint - var boneIndex = weightBoneIndices.indexOf(rawBoneIndex); - this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); - this._helpMatrixB.invert(); - this._helpMatrixB.transformPoint(x, y, this._helpPoint); - this._intArray[iB++] = boneIndex; - this._floatArray[iV++] = rawWeights[iW++]; - this._floatArray[iV++] = this._helpPoint.x; - this._floatArray[iV++] = this._helpPoint.y; - } - } - mesh.vertices.weight = weight; - this._weightSlotPose[meshName] = rawSlotPose; - this._weightBonePoses[meshName] = rawBonePoses; - } - }; - ObjectDataParser.prototype._parseMeshGlue = function (rawData, mesh) { - rawData; - mesh; - // const rawWeights = rawData[DataParser.GLUE_WEIGHTS] as Array; - // const rawMeshes = rawData[DataParser.GLUE_MESHES] as Array; - // mesh.glue = BaseObject.borrowObject(GlueData); - // mesh.glue.weights.length = rawWeights.length; - // for (let i = 0, l = rawWeights.length; i < l; ++i) { - // mesh.glue.weights[i] = rawWeights[i]; - // } - // for (let i = 0, l = rawMeshes.length; i < l; i += 3) { - // const glueMesh = this._armature.getMesh(rawMeshes[i], rawMeshes[i + 1], rawMeshes[i + 2]); - // mesh.glue.addMesh(glueMesh); - // } - }; - ObjectDataParser.prototype._parseBoundingBox = function (rawData) { - var boundingBox = null; - var type = 0 /* Rectangle */; - if (dragonBones.DataParser.SUB_TYPE in rawData && typeof rawData[dragonBones.DataParser.SUB_TYPE] === "string") { - type = dragonBones.DataParser._getBoundingBoxType(rawData[dragonBones.DataParser.SUB_TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SUB_TYPE, type); - } - switch (type) { - case 0 /* Rectangle */: - boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); - break; - case 1 /* Ellipse */: - boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); - break; - case 2 /* Polygon */: - boundingBox = this._parsePolygonBoundingBox(rawData); - break; - } - if (boundingBox !== null) { - boundingBox.color = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.COLOR, 0x000000); - if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { - boundingBox.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0.0); - boundingBox.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0.0); - } - } - return boundingBox; - }; - ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { - var polygonBoundingBox = dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); - if (dragonBones.DataParser.VERTICES in rawData) { - var scale = this._armature.scale; - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var vertices = polygonBoundingBox.vertices; - if (dragonBones.DragonBones.webAssembly) { - vertices.resize(rawVertices.length, 0.0); - } - else { - vertices.length = rawVertices.length; - } - for (var i = 0, l = rawVertices.length; i < l; i += 2) { - var x = rawVertices[i] * scale; - var y = rawVertices[i + 1] * scale; - if (dragonBones.DragonBones.webAssembly) { - vertices.set(i, x); - vertices.set(i + 1, y); - } - else { - vertices[i] = x; - vertices[i + 1] = y; - } - // AABB. - if (i === 0) { - polygonBoundingBox.x = x; - polygonBoundingBox.y = y; - polygonBoundingBox.width = x; - polygonBoundingBox.height = y; - } - else { - if (x < polygonBoundingBox.x) { - polygonBoundingBox.x = x; - } - else if (x > polygonBoundingBox.width) { - polygonBoundingBox.width = x; - } - if (y < polygonBoundingBox.y) { - polygonBoundingBox.y = y; - } - else if (y > polygonBoundingBox.height) { - polygonBoundingBox.height = y; - } - } - } - polygonBoundingBox.width -= polygonBoundingBox.x; - polygonBoundingBox.height -= polygonBoundingBox.y; - } - else { - console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug."); - } - return polygonBoundingBox; - }; - ObjectDataParser.prototype._parseAnimation = function (rawData) { - var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); - animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 1), 1); - animation.playTimes = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); - animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); - animation.scale = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); - animation.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (animation.name.length === 0) { - animation.name = dragonBones.DataParser.DEFAULT_NAME; - } - animation.frameIntOffset = this._frameIntArray.length; - animation.frameFloatOffset = this._frameFloatArray.length; - animation.frameOffset = this._frameArray.length; - this._animation = animation; - if (dragonBones.DataParser.FRAME in rawData) { - var rawFrames = rawData[dragonBones.DataParser.FRAME]; - var keyFrameCount = rawFrames.length; - if (keyFrameCount > 0) { - for (var i = 0, frameStart = 0; i < keyFrameCount; ++i) { - var rawFrame = rawFrames[i]; - this._parseActionDataInFrame(rawFrame, frameStart, null, null); - frameStart += ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); - } - } - } - if (dragonBones.DataParser.Z_ORDER in rawData) { - this._animation.zOrderTimeline = this._parseTimeline(rawData[dragonBones.DataParser.Z_ORDER], null, dragonBones.DataParser.FRAME, 1 /* ZOrder */, false, false, 0, this._parseZOrderFrame); - } - if (dragonBones.DataParser.BONE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.BONE]; - for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { - var rawTimeline = rawTimelines_1[_i]; - this._parseBoneTimeline(rawTimeline); - } - } - if (dragonBones.DataParser.SURFACE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.SURFACE]; - for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { - var rawTimeline = rawTimelines_2[_a]; - var surfaceName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - this._surface = this._armature.getBone(surfaceName); - if (this._surface === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 50 /* Surface */, false, true, 0, this._parseSurfaceFrame); - if (timeline !== null) { - this._animation.addSurfaceTimeline(this._surface, timeline); - } - this._surface = null; // - } - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.SLOT]; - for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { - var rawTimeline = rawTimelines_3[_b]; - this._parseSlotTimeline(rawTimeline); - } - } - if (dragonBones.DataParser.FFD in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.FFD]; - for (var _c = 0, rawTimelines_4 = rawTimelines; _c < rawTimelines_4.length; _c++) { - var rawTimeline = rawTimelines_4[_c]; - var skinName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); - var slotName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SLOT, ""); - var displayName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - if (skinName.length === 0) { - skinName = dragonBones.DataParser.DEFAULT_NAME; - } - this._slot = this._armature.getSlot(slotName); - this._mesh = this._armature.getMesh(skinName, slotName, displayName); - if (this._slot === null || this._mesh === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 22 /* SlotDeform */, false, true, 0, this._parseSlotFFDFrame); - if (timeline !== null) { - this._animation.addSlotTimeline(this._slot, timeline); - } - this._slot = null; // - this._mesh = null; // - } - } - if (dragonBones.DataParser.IK in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.IK]; - for (var _d = 0, rawTimelines_5 = rawTimelines; _d < rawTimelines_5.length; _d++) { - var rawTimeline = rawTimelines_5[_d]; - var constraintName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var constraint = this._armature.getConstraint(constraintName); - if (constraint === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 30 /* IKConstraint */, true, false, 2, this._parseIKConstraintFrame); - if (timeline !== null) { - this._animation.addConstraintTimeline(constraint, timeline); - } - } - } - if (dragonBones.DataParser.ANIMATION in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.ANIMATION]; - for (var _e = 0, rawTimelines_6 = rawTimelines; _e < rawTimelines_6.length; _e++) { - var rawTimeline = rawTimelines_6[_e]; - var animationName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 40 /* AnimationTime */, true, false, 2, this._parseAnimationFrame); - if (timeline !== null) { - this._animation.addAnimationTimeline(animationName, timeline); - } - } - } - if (this._actionFrames.length > 0) { - this._animation.actionTimeline = this._parseTimeline(null, this._actionFrames, "", 0 /* Action */, false, false, 0, this._parseActionFrame); - this._actionFrames.length = 0; - } - this._animation = null; // - return animation; - }; - ObjectDataParser.prototype._parseTimeline = function (rawData, rawFrames, framesKey, type, addIntOffset, addFloatOffset, frameValueCount, frameParser) { - if (rawData !== null && framesKey.length > 0 && framesKey in rawData) { - rawFrames = rawData[framesKey]; - } - if (rawFrames === null) { - return null; - } - var keyFrameCount = rawFrames.length; - if (keyFrameCount === 0) { - return null; - } - var frameIntArrayLength = this._frameIntArray.length; - var frameFloatArrayLength = this._frameFloatArray.length; - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); - var timelineOffset = this._timelineArray.length; - this._timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; - if (rawData !== null) { - this._timelineArray[timelineOffset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0) * 100); - this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0.0) * 100); - } - else { - this._timelineArray[timelineOffset + 0 /* TimelineScale */] = 100; - this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = 0; - } - this._timelineArray[timelineOffset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; - this._timelineArray[timelineOffset + 3 /* TimelineFrameValueCount */] = frameValueCount; - if (addIntOffset) { - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; - } - else if (addFloatOffset) { - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; - } - else { - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = 0; - } - this._timeline = timeline; - timeline.type = type; - timeline.offset = timelineOffset; - if (keyFrameCount === 1) { - timeline.frameIndicesOffset = -1; - this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; - } - else { - var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. - var frameIndices = this._data.frameIndices; - var frameIndicesOffset = 0; - if (dragonBones.DragonBones.webAssembly) { - frameIndicesOffset = frameIndices.size(); - frameIndices.resize(frameIndicesOffset + totalFrameCount, 0); - } - else { - frameIndicesOffset = frameIndices.length; - frameIndices.length += totalFrameCount; - } - timeline.frameIndicesOffset = frameIndicesOffset; - for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { - if (frameStart + frameCount <= i && iK < keyFrameCount) { - var rawFrame = rawFrames[iK]; - frameStart = i; // frame.frameStart; - if (iK === keyFrameCount - 1) { - frameCount = this._animation.frameCount - frameStart; - } - else { - if (rawFrame instanceof ActionFrame) { - frameCount = this._actionFrames[iK + 1].frameStart - frameStart; - } - else { - frameCount = ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); - } - } - this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; - iK++; - } - if (dragonBones.DragonBones.webAssembly) { - frameIndices.set(frameIndicesOffset + i, iK - 1); - } - else { - frameIndices[frameIndicesOffset + i] = iK - 1; - } - } - } - this._timeline = null; // - return timeline; - }; - ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { - var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); - if (bone === null) { - return; - } - this._bone = bone; - this._slot = this._armature.getSlot(this._bone.name); - if (dragonBones.DataParser.TRANSLATE_FRAME in rawData) { - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.TRANSLATE_FRAME, 11 /* BoneTranslate */, false, true, 2, this._parseBoneTranslateFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone, timeline); - } - } - if (dragonBones.DataParser.ROTATE_FRAME in rawData) { - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.ROTATE_FRAME, 12 /* BoneRotate */, false, true, 2, this._parseBoneRotateFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone, timeline); - } - } - if (dragonBones.DataParser.SCALE_FRAME in rawData) { - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.SCALE_FRAME, 13 /* BoneScale */, false, true, 2, this._parseBoneScaleFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone, timeline); - } - } - if (dragonBones.DataParser.FRAME in rawData) { - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 10 /* BoneAll */, false, true, 6, this._parseBoneAllFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone, timeline); - } - } - this._bone = null; // - this._slot = null; // - }; - ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { - var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); - if (slot === null) { - return; - } - this._slot = slot; - // Display timeline. - var displayTimeline = null; - if (dragonBones.DataParser.DISPLAY_FRAME in rawData) { - displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.DISPLAY_FRAME, 20 /* SlotDisplay */, false, false, 0, this._parseSlotDisplayFrame); - } - else { - displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 20 /* SlotDisplay */, false, false, 0, this._parseSlotDisplayFrame); - } - if (displayTimeline !== null) { - this._animation.addSlotTimeline(slot, displayTimeline); - } - var colorTimeline = null; - if (dragonBones.DataParser.COLOR_FRAME in rawData) { - colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.COLOR_FRAME, 21 /* SlotColor */, true, false, 1, this._parseSlotColorFrame); - } - else { - colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 21 /* SlotColor */, true, false, 1, this._parseSlotColorFrame); - } - if (colorTimeline !== null) { - this._animation.addSlotTimeline(slot, colorTimeline); - } - this._slot = null; // - }; - ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount) { - // tslint:disable-next-line:no-unused-expression - rawData; - // tslint:disable-next-line:no-unused-expression - frameCount; - var frameOffset = this._frameArray.length; - this._frameArray.length += 1; - this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; - return frameOffset; - }; - ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - if (frameCount > 0) { - if (dragonBones.DataParser.CURVE in rawData) { - var sampleCount = frameCount + 1; - this._helpArray.length = sampleCount; - this._samplingEasingCurve(rawData[dragonBones.DataParser.CURVE], this._helpArray); - this._frameArray.length += 1 + 1 + this._helpArray.length; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = sampleCount; - for (var i = 0; i < sampleCount; ++i) { - this._frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); - } - } - else { - var noTween = -2.0; - var tweenEasing = noTween; - if (dragonBones.DataParser.TWEEN_EASING in rawData) { - tweenEasing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_EASING, noTween); - } - if (tweenEasing === noTween) { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; - } - else if (tweenEasing === 0.0) { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; - } - else if (tweenEasing < 0.0) { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); - } - else if (tweenEasing <= 1.0) { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); - } - else { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); - } - } - } - else { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseActionFrame = function (frame, frameStart, frameCount) { - // tslint:disable-next-line:no-unused-expression - frameCount; - var frameOffset = this._frameArray.length; - var actionCount = frame.actions.length; - this._frameArray.length += 1 + 1 + actionCount; - this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; - this._frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. - for (var i = 0; i < actionCount; ++i) { - this._frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - if (dragonBones.DataParser.Z_ORDER in rawData) { - var rawZOrder = rawData[dragonBones.DataParser.Z_ORDER]; - if (rawZOrder.length > 0) { - var slotCount = this._armature.sortedSlots.length; - var unchanged = new Array(slotCount - rawZOrder.length / 2); - var zOrders = new Array(slotCount); - for (var i_1 = 0; i_1 < unchanged.length; ++i_1) { - unchanged[i_1] = 0; - } - for (var i_2 = 0; i_2 < slotCount; ++i_2) { - zOrders[i_2] = -1; - } - var originalIndex = 0; - var unchangedIndex = 0; - for (var i_3 = 0, l = rawZOrder.length; i_3 < l; i_3 += 2) { - var slotIndex = rawZOrder[i_3]; - var zOrderOffset = rawZOrder[i_3 + 1]; - while (originalIndex !== slotIndex) { - unchanged[unchangedIndex++] = originalIndex++; - } - var index = originalIndex + zOrderOffset; - zOrders[index] = originalIndex++; - } - while (originalIndex < slotCount) { - unchanged[unchangedIndex++] = originalIndex++; - } - this._frameArray.length += 1 + slotCount; - this._frameArray[frameOffset + 1] = slotCount; - var i = slotCount; - while (i--) { - if (zOrders[i] === -1) { - this._frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex] || 0; - } - else { - this._frameArray[frameOffset + 2 + i] = zOrders[i] || 0; - } - } - return frameOffset; - } - } - this._frameArray.length += 1; - this._frameArray[frameOffset + 1] = 0; - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneAllFrame = function (rawData, frameStart, frameCount) { - this._helpTransform.identity(); - if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], this._helpTransform, 1.0); - } - // Modify rotation. - var rotation = this._helpTransform.rotation; - if (frameStart !== 0) { - if (this._prevClockwise === 0) { - rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); - } - else { - if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { - this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; - } - rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; - } - } - this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_ROTATE, 0.0); - this._prevRotation = rotation; - // - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 6; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.x; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.y; - this._frameFloatArray[frameFloatOffset++] = rotation; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; - this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneTranslateFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneRotateFrame = function (rawData, frameStart, frameCount) { - // Modify rotation. - var rotation = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD; - if (frameStart !== 0) { - if (this._prevClockwise === 0) { - rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); - } - else { - if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { - this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; - } - rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; - } - } - this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CLOCK_WISE, 0); - this._prevRotation = rotation; - // - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = rotation; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD; - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneScaleFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 1.0); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 1.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseSurfaceFrame = function (rawData, frameStart, frameCount) { - var frameFloatOffset = this._frameFloatArray.length; - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint - var vertexCount = this._surface.vertices.length / 2; // uint - var x = 0.0; - var y = 0.0; - this._frameFloatArray.length += vertexCount * 2; - for (var i = 0; i < vertexCount * 2; i += 2) { - if (i < offset || i - offset >= rawVertices.length) { - x = 0.0; - } - else { - x = rawVertices[i - offset]; - } - if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { - y = 0.0; - } - else { - y = rawVertices[i + 1 - offset]; - } - this._frameFloatArray[frameFloatOffset + i] = x; - this._frameFloatArray[frameFloatOffset + i + 1] = y; - } - if (frameStart === 0) { - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = 0; // - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; - this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotDisplayFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - this._frameArray.length += 1; - if (dragonBones.DataParser.VALUE in rawData) { - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); - } - else { - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); - } - this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var colorOffset = -1; - if (dragonBones.DataParser.VALUE in rawData || dragonBones.DataParser.COLOR in rawData) { - var rawColor = dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : rawData[dragonBones.DataParser.COLOR]; - for (var k in rawColor) { - // tslint:disable-next-line:no-unused-expression - k; - this._parseColorTransform(rawColor, this._helpColorTransform); - colorOffset = this._intArray.length; - this._intArray.length += 8; - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); - colorOffset -= 8; - break; - } - } - if (colorOffset < 0) { - if (this._defaultColorOffset < 0) { - this._defaultColorOffset = colorOffset = this._intArray.length; - this._intArray.length += 8; - this._intArray[colorOffset++] = 100; - this._intArray[colorOffset++] = 100; - this._intArray[colorOffset++] = 100; - this._intArray[colorOffset++] = 100; - this._intArray[colorOffset++] = 0; - this._intArray[colorOffset++] = 0; - this._intArray[colorOffset++] = 0; - this._intArray[colorOffset++] = 0; - } - colorOffset = this._defaultColorOffset; - } - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1; - this._frameIntArray[frameIntOffset] = colorOffset; - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotFFDFrame = function (rawData, frameStart, frameCount) { - var frameFloatOffset = this._frameFloatArray.length; - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var rawVertices = dragonBones.DataParser.VERTICES in rawData ? rawData[dragonBones.DataParser.VERTICES] : null; - var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint - var vertexCount = this._intArray[this._mesh.vertices.offset + 0 /* MeshVertexCount */]; - var meshName = this._mesh.parent.name + "_" + this._slot.name + "_" + this._mesh.name; - var weight = this._mesh.vertices.weight; - var x = 0.0; - var y = 0.0; - var iB = 0; - var iV = 0; - if (weight !== null) { - var rawSlotPose = this._weightSlotPose[meshName]; - this._helpMatrixA.copyFromArray(rawSlotPose, 0); - this._frameFloatArray.length += weight.count * 2; - iB = weight.offset + 2 /* WeigthBoneIndices */ + weight.bones.length; - } - else { - this._frameFloatArray.length += vertexCount * 2; - } - for (var i = 0; i < vertexCount * 2; i += 2) { - if (rawVertices === null) { - x = 0.0; - y = 0.0; - } - else { - if (i < offset || i - offset >= rawVertices.length) { - x = 0.0; - } - else { - x = rawVertices[i - offset]; - } - if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { - y = 0.0; - } - else { - y = rawVertices[i + 1 - offset]; - } - } - if (weight !== null) { - var rawBonePoses = this._weightBonePoses[meshName]; - var vertexBoneCount = this._intArray[iB++]; - this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); - x = this._helpPoint.x; - y = this._helpPoint.y; - for (var j = 0; j < vertexBoneCount; ++j) { - var boneIndex = this._intArray[iB++]; - this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); - this._helpMatrixB.invert(); - this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); - this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; - this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; - } - } - else { - this._frameFloatArray[frameFloatOffset + i] = x; - this._frameFloatArray[frameFloatOffset + i + 1] = y; - } - } - if (frameStart === 0) { - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._mesh.vertices.offset; - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; - this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseIKConstraintFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 2; - this._frameIntArray[frameIntOffset++] = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true) ? 1 : 0; - this._frameIntArray[frameIntOffset++] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0) * 100.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseAnimationFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 2; - this._frameIntArray[frameIntOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); - this._frameIntArray[frameIntOffset++] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0) * 100.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseActionData = function (rawData, type, bone, slot) { - var actions = new Array(); - if (typeof rawData === "string") { - var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - action.type = type; - action.name = rawData; - action.bone = bone; - action.slot = slot; - actions.push(action); - } - else if (rawData instanceof Array) { - for (var _i = 0, rawData_2 = rawData; _i < rawData_2.length; _i++) { - var rawAction = rawData_2[_i]; - var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - if (dragonBones.DataParser.GOTO_AND_PLAY in rawAction) { - action.type = 0 /* Play */; - action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.GOTO_AND_PLAY, ""); - } - else { - if (dragonBones.DataParser.TYPE in rawAction && typeof rawAction[dragonBones.DataParser.TYPE] === "string") { - action.type = dragonBones.DataParser._getActionType(rawAction[dragonBones.DataParser.TYPE]); - } - else { - action.type = ObjectDataParser._getNumber(rawAction, dragonBones.DataParser.TYPE, type); - } - action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.NAME, ""); - } - if (dragonBones.DataParser.BONE in rawAction) { - var boneName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.BONE, ""); - action.bone = this._armature.getBone(boneName); - } - else { - action.bone = bone; - } - if (dragonBones.DataParser.SLOT in rawAction) { - var slotName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.SLOT, ""); - action.slot = this._armature.getSlot(slotName); - } - else { - action.slot = slot; - } - var userData = null; - if (dragonBones.DataParser.INTS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawInts = rawAction[dragonBones.DataParser.INTS]; - for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { - var rawValue = rawInts_1[_a]; - userData.addInt(rawValue); - } - } - if (dragonBones.DataParser.FLOATS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawFloats = rawAction[dragonBones.DataParser.FLOATS]; - for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { - var rawValue = rawFloats_1[_b]; - userData.addFloat(rawValue); - } - } - if (dragonBones.DataParser.STRINGS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawStrings = rawAction[dragonBones.DataParser.STRINGS]; - for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { - var rawValue = rawStrings_1[_c]; - userData.addString(rawValue); - } - } - action.data = userData; - actions.push(action); - } - } - return actions; - }; - ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { - transform.x = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0) * scale; - transform.y = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0) * scale; - if (dragonBones.DataParser.ROTATE in rawData || dragonBones.DataParser.SKEW in rawData) { - transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); - transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); - } - else if (dragonBones.DataParser.SKEW_X in rawData || dragonBones.DataParser.SKEW_Y in rawData) { - transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); - transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; - } - transform.scaleX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_X, 1.0); - transform.scaleY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_Y, 1.0); - }; - ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { - color.alphaMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_MULTIPLIER, 100) * 0.01; - color.redMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_MULTIPLIER, 100) * 0.01; - color.greenMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_MULTIPLIER, 100) * 0.01; - color.blueMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_MULTIPLIER, 100) * 0.01; - color.alphaOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_OFFSET, 0); - color.redOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_OFFSET, 0); - color.greenOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_OFFSET, 0); - color.blueOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_OFFSET, 0); - }; - ObjectDataParser.prototype._parseArray = function (rawData) { - // tslint:disable-next-line:no-unused-expression - rawData; - this._intArray.length = 0; - this._floatArray.length = 0; - this._frameIntArray.length = 0; - this._frameFloatArray.length = 0; - this._frameArray.length = 0; - this._timelineArray.length = 0; - }; - ObjectDataParser.prototype._modifyArray = function () { - // Align. - if ((this._intArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._intArray.push(0); - } - if ((this._frameIntArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._frameIntArray.push(0); - } - if ((this._frameArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._frameArray.push(0); - } - if ((this._timelineArray.length % Uint16Array.BYTES_PER_ELEMENT) !== 0) { - this._timelineArray.push(0); - } - var l1 = this._intArray.length * Int16Array.BYTES_PER_ELEMENT; - var l2 = this._floatArray.length * Float32Array.BYTES_PER_ELEMENT; - var l3 = this._frameIntArray.length * Int16Array.BYTES_PER_ELEMENT; - var l4 = this._frameFloatArray.length * Float32Array.BYTES_PER_ELEMENT; - var l5 = this._frameArray.length * Int16Array.BYTES_PER_ELEMENT; - var l6 = this._timelineArray.length * Uint16Array.BYTES_PER_ELEMENT; - var lTotal = l1 + l2 + l3 + l4 + l5 + l6; - if (dragonBones.DragonBones.webAssembly) { - var shareBuffer = dragonBones.webAssemblyModule.HEAP16.buffer; - var bufferPointer = dragonBones.webAssemblyModule._malloc(lTotal); - var intArray = new Int16Array(shareBuffer, bufferPointer, this._intArray.length); - var floatArray = new Float32Array(shareBuffer, bufferPointer + l1, this._floatArray.length); - var frameIntArray = new Int16Array(shareBuffer, bufferPointer + l1 + l2, this._frameIntArray.length); - var frameFloatArray = new Float32Array(shareBuffer, bufferPointer + l1 + l2 + l3, this._frameFloatArray.length); - var frameArray = new Int16Array(shareBuffer, bufferPointer + l1 + l2 + l3 + l4, this._frameArray.length); - var timelineArray = new Uint16Array(shareBuffer, bufferPointer + l1 + l2 + l3 + l4 + l5, this._timelineArray.length); - for (var i = 0, l = this._intArray.length; i < l; ++i) { - intArray[i] = this._intArray[i]; - } - for (var i = 0, l = this._floatArray.length; i < l; ++i) { - floatArray[i] = this._floatArray[i]; - } - for (var i = 0, l = this._frameIntArray.length; i < l; ++i) { - frameIntArray[i] = this._frameIntArray[i]; - } - for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) { - frameFloatArray[i] = this._frameFloatArray[i]; - } - for (var i = 0, l = this._frameArray.length; i < l; ++i) { - frameArray[i] = this._frameArray[i]; - } - for (var i = 0, l = this._timelineArray.length; i < l; ++i) { - timelineArray[i] = this._timelineArray[i]; - } - dragonBones.webAssemblyModule.setDataBinary(this._data, bufferPointer, l1, l2, l3, l4, l5, l6); - } - else { - var binary = new ArrayBuffer(lTotal); - var intArray = new Int16Array(binary, 0, this._intArray.length); - var floatArray = new Float32Array(binary, l1, this._floatArray.length); - var frameIntArray = new Int16Array(binary, l1 + l2, this._frameIntArray.length); - var frameFloatArray = new Float32Array(binary, l1 + l2 + l3, this._frameFloatArray.length); - var frameArray = new Int16Array(binary, l1 + l2 + l3 + l4, this._frameArray.length); - var timelineArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5, this._timelineArray.length); - for (var i = 0, l = this._intArray.length; i < l; ++i) { - intArray[i] = this._intArray[i]; - } - for (var i = 0, l = this._floatArray.length; i < l; ++i) { - floatArray[i] = this._floatArray[i]; - } - for (var i = 0, l = this._frameIntArray.length; i < l; ++i) { - frameIntArray[i] = this._frameIntArray[i]; - } - for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) { - frameFloatArray[i] = this._frameFloatArray[i]; - } - for (var i = 0, l = this._frameArray.length; i < l; ++i) { - frameArray[i] = this._frameArray[i]; - } - for (var i = 0, l = this._timelineArray.length; i < l; ++i) { - timelineArray[i] = this._timelineArray[i]; - } - this._data.binary = binary; - this._data.intArray = intArray; - this._data.floatArray = floatArray; - this._data.frameIntArray = frameIntArray; - this._data.frameFloatArray = frameFloatArray; - this._data.frameArray = frameArray; - this._data.timelineArray = timelineArray; - } - this._defaultColorOffset = -1; - }; - ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.assert(rawData !== null && rawData !== undefined, "Data error."); - var version = ObjectDataParser._getString(rawData, dragonBones.DataParser.VERSION, ""); - var compatibleVersion = ObjectDataParser._getString(rawData, dragonBones.DataParser.COMPATIBLE_VERSION, ""); - if (dragonBones.DataParser.DATA_VERSIONS.indexOf(version) >= 0 || - dragonBones.DataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { - var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); - data.version = version; - data.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - data.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, 24); - if (data.frameRate === 0) { - data.frameRate = 24; - } - if (dragonBones.DataParser.ARMATURE in rawData) { - this._data = data; - this._parseArray(rawData); - var rawArmatures = rawData[dragonBones.DataParser.ARMATURE]; - for (var _i = 0, rawArmatures_1 = rawArmatures; _i < rawArmatures_1.length; _i++) { - var rawArmature = rawArmatures_1[_i]; - data.addArmature(this._parseArmature(rawArmature, scale)); - } - if (!this._data.binary) { - this._modifyArray(); - } - if (dragonBones.DataParser.STAGE in rawData) { - data.stage = data.getArmature(ObjectDataParser._getString(rawData, dragonBones.DataParser.STAGE, "")); - } - else if (data.armatureNames.length > 0) { - data.stage = data.getArmature(data.armatureNames[0]); - } - this._data = null; - } - if (dragonBones.DataParser.TEXTURE_ATLAS in rawData) { - this._rawTextureAtlases = rawData[dragonBones.DataParser.TEXTURE_ATLAS]; - } - return data; - } - else { - console.assert(false, "Nonsupport data version: " + version + "\n" + - "Please convert DragonBones data to support version.\n" + - "Read more: https://github.com/DragonBones/Tools/"); - } - return null; - }; - ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { - if (scale === void 0) { scale = 1.0; } - console.assert(rawData !== undefined); - if (rawData === null) { - if (this._rawTextureAtlases === null || this._rawTextureAtlases.length === 0) { - return false; - } - var rawTextureAtlas = this._rawTextureAtlases[this._rawTextureAtlasIndex++]; - this.parseTextureAtlasData(rawTextureAtlas, textureAtlasData, scale); - if (this._rawTextureAtlasIndex >= this._rawTextureAtlases.length) { - this._rawTextureAtlasIndex = 0; - this._rawTextureAtlases = null; - } - return true; - } - // Texture format. - textureAtlasData.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0); - textureAtlasData.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0); - textureAtlasData.scale = scale === 1.0 ? (1.0 / ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0)) : scale; - textureAtlasData.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - textureAtlasData.imagePath = ObjectDataParser._getString(rawData, dragonBones.DataParser.IMAGE_PATH, ""); - if (dragonBones.DataParser.SUB_TEXTURE in rawData) { - var rawTextures = rawData[dragonBones.DataParser.SUB_TEXTURE]; - for (var i = 0, l = rawTextures.length; i < l; ++i) { - var rawTexture = rawTextures[i]; - var textureData = textureAtlasData.createTexture(); - textureData.rotated = ObjectDataParser._getBoolean(rawTexture, dragonBones.DataParser.ROTATED, false); - textureData.name = ObjectDataParser._getString(rawTexture, dragonBones.DataParser.NAME, ""); - textureData.region.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.X, 0.0); - textureData.region.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.Y, 0.0); - textureData.region.width = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.WIDTH, 0.0); - textureData.region.height = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.HEIGHT, 0.0); - var frameWidth = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_WIDTH, -1.0); - var frameHeight = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_HEIGHT, -1.0); - if (frameWidth > 0.0 && frameHeight > 0.0) { - textureData.frame = dragonBones.TextureData.createRectangle(); - textureData.frame.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_X, 0.0); - textureData.frame.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_Y, 0.0); - textureData.frame.width = frameWidth; - textureData.frame.height = frameHeight; - } - textureAtlasData.addTexture(textureData); - } - } - return true; - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - ObjectDataParser.getInstance = function () { - if (ObjectDataParser._objectDataParserInstance === null) { - ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); - } - return ObjectDataParser._objectDataParserInstance; - }; - ObjectDataParser._objectDataParserInstance = null; - return ObjectDataParser; - }(dragonBones.DataParser)); - dragonBones.ObjectDataParser = ObjectDataParser; - /** - * @internal - */ - var ActionFrame = /** @class */ (function () { - function ActionFrame() { - this.frameStart = 0; - this.actions = []; - } - return ActionFrame; - }()); - dragonBones.ActionFrame = ActionFrame; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var BinaryDataParser = /** @class */ (function (_super) { - __extends(BinaryDataParser, _super); - function BinaryDataParser() { - return _super !== null && _super.apply(this, arguments) || this; - } - BinaryDataParser.prototype._inRange = function (a, min, max) { - return min <= a && a <= max; - }; - BinaryDataParser.prototype._decodeUTF8 = function (data) { - var EOF_byte = -1; - var EOF_code_point = -1; - var FATAL_POINT = 0xFFFD; - var pos = 0; - var result = ""; - var code_point; - var utf8_code_point = 0; - var utf8_bytes_needed = 0; - var utf8_bytes_seen = 0; - var utf8_lower_boundary = 0; - while (data.length > pos) { - var _byte = data[pos++]; - if (_byte === EOF_byte) { - if (utf8_bytes_needed !== 0) { - code_point = FATAL_POINT; - } - else { - code_point = EOF_code_point; - } - } - else { - if (utf8_bytes_needed === 0) { - if (this._inRange(_byte, 0x00, 0x7F)) { - code_point = _byte; - } - else { - if (this._inRange(_byte, 0xC2, 0xDF)) { - utf8_bytes_needed = 1; - utf8_lower_boundary = 0x80; - utf8_code_point = _byte - 0xC0; - } - else if (this._inRange(_byte, 0xE0, 0xEF)) { - utf8_bytes_needed = 2; - utf8_lower_boundary = 0x800; - utf8_code_point = _byte - 0xE0; - } - else if (this._inRange(_byte, 0xF0, 0xF4)) { - utf8_bytes_needed = 3; - utf8_lower_boundary = 0x10000; - utf8_code_point = _byte - 0xF0; - } - else { - } - utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); - code_point = null; - } - } - else if (!this._inRange(_byte, 0x80, 0xBF)) { - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - pos--; - code_point = _byte; - } - else { - utf8_bytes_seen += 1; - utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); - if (utf8_bytes_seen !== utf8_bytes_needed) { - code_point = null; - } - else { - var cp = utf8_code_point; - var lower_boundary = utf8_lower_boundary; - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - if (this._inRange(cp, lower_boundary, 0x10FFFF) && !this._inRange(cp, 0xD800, 0xDFFF)) { - code_point = cp; - } - else { - code_point = _byte; - } - } - } - } - //Decode string - if (code_point !== null && code_point !== EOF_code_point) { - if (code_point <= 0xFFFF) { - if (code_point > 0) - result += String.fromCharCode(code_point); - } - else { - code_point -= 0x10000; - result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); - result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); - } - } - } - return result; - }; - BinaryDataParser.prototype._getUTF16Key = function (value) { - for (var i = 0, l = value.length; i < l; ++i) { - if (value.charCodeAt(i) > 255) { - return encodeURI(value); - } - } - return value; - }; - BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { - if (timelineData === void 0) { timelineData = null; } - var timeline = timelineData !== null ? timelineData : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); - timeline.type = type; - timeline.offset = offset; - this._timeline = timeline; - var keyFrameCount = this._timelineArrayBuffer[timeline.offset + 2 /* TimelineKeyFrameCount */]; - if (keyFrameCount === 1) { - timeline.frameIndicesOffset = -1; - } - else { - var frameIndicesOffset = 0; - var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. - var frameIndices = this._data.frameIndices; - if (dragonBones.DragonBones.webAssembly) { - frameIndicesOffset = frameIndices.size(); - frameIndices.resize(frameIndicesOffset + totalFrameCount, 0); - } - else { - frameIndicesOffset = frameIndices.length; - frameIndices.length += totalFrameCount; - } - timeline.frameIndicesOffset = frameIndicesOffset; - for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { - if (frameStart + frameCount <= i && iK < keyFrameCount) { - frameStart = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; - if (iK === keyFrameCount - 1) { - frameCount = this._animation.frameCount - frameStart; - } - else { - frameCount = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; - } - iK++; - } - if (dragonBones.DragonBones.webAssembly) { - frameIndices.set(frameIndicesOffset + i, iK - 1); - } - else { - frameIndices[frameIndicesOffset + i] = iK - 1; - } - } - } - this._timeline = null; // - return timeline; - }; - BinaryDataParser.prototype._parseVertices = function (rawData, vertices) { - vertices.offset = rawData[dragonBones.DataParser.OFFSET]; - var weightOffset = this._intArrayBuffer[vertices.offset + 3 /* MeshWeightOffset */]; - if (weightOffset >= 0) { - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - var vertexCount = this._intArrayBuffer[vertices.offset + 0 /* MeshVertexCount */]; - var boneCount = this._intArrayBuffer[weightOffset + 0 /* WeigthBoneCount */]; - weight.offset = weightOffset; - for (var i = 0; i < boneCount; ++i) { - var boneIndex = this._intArrayBuffer[weightOffset + 2 /* WeigthBoneIndices */ + i]; - weight.addBone(this._rawBones[boneIndex]); - } - var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; - var weightCount = 0; - for (var i = 0, l = vertexCount; i < l; ++i) { - var vertexBoneCount = this._intArrayBuffer[boneIndicesOffset++]; - weightCount += vertexBoneCount; - boneIndicesOffset += vertexBoneCount; - } - weight.count = weightCount; - vertices.weight = weight; - } - }; - BinaryDataParser.prototype._parseMesh = function (rawData, mesh) { - this._parseVertices(rawData, mesh.vertices); - }; - BinaryDataParser.prototype._parsePath = function (rawData, path) { - this._parseVertices(rawData, path.vertices); - }; - BinaryDataParser.prototype._parseAnimation = function (rawData) { - var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); - animation.frameCount = Math.max(dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 1), 1); - animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); - animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); - animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); - animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (animation.name.length === 0) { - animation.name = dragonBones.DataParser.DEFAULT_NAME; - } - // Offsets. - var offsets = rawData[dragonBones.DataParser.OFFSET]; - animation.frameIntOffset = offsets[0]; - animation.frameFloatOffset = offsets[1]; - animation.frameOffset = offsets[2]; - this._animation = animation; - if (dragonBones.DataParser.ACTION in rawData) { - animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.DataParser.ACTION]); - } - if (dragonBones.DataParser.Z_ORDER in rawData) { - animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.DataParser.Z_ORDER]); - } - if (dragonBones.DataParser.BONE in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.BONE]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - if (dragonBones.DragonBones.webAssembly) { - k = this._getUTF16Key(k); - } - var bone = this._armature.getBone(k); - if (bone === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addBoneTimeline(bone, timeline); - } - } - } - if (dragonBones.DataParser.SURFACE in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.SURFACE]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - if (dragonBones.DragonBones.webAssembly) { - k = this._getUTF16Key(k); - } - var surface = this._armature.getBone(k); - if (surface === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addSurfaceTimeline(surface, timeline); - } - } - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.SLOT]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - if (dragonBones.DragonBones.webAssembly) { - k = this._getUTF16Key(k); - } - var slot = this._armature.getSlot(k); - if (slot === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addSlotTimeline(slot, timeline); - } - } - } - if (dragonBones.DataParser.CONSTRAINT in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.CONSTRAINT]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - if (dragonBones.DragonBones.webAssembly) { - k = this._getUTF16Key(k); - } - var constraint = this._armature.getConstraint(k); - if (constraint === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addConstraintTimeline(constraint, timeline); - } - } - } - if (dragonBones.DataParser.ANIMATION in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.ANIMATION]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - if (dragonBones.DragonBones.webAssembly) { - k = this._getUTF16Key(k); - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addAnimationTimeline(k, timeline); - } - } - } - this._animation = null; - return animation; - }; - BinaryDataParser.prototype._parseArray = function (rawData) { - var offsets = rawData[dragonBones.DataParser.OFFSET]; - var l1 = offsets[1]; - var l2 = offsets[3]; - var l3 = offsets[5]; - var l4 = offsets[7]; - var l5 = offsets[9]; - var l6 = offsets[11]; - var intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], l1 / Int16Array.BYTES_PER_ELEMENT); - var floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], l2 / Float32Array.BYTES_PER_ELEMENT); - var frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], l3 / Int16Array.BYTES_PER_ELEMENT); - var frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], l4 / Float32Array.BYTES_PER_ELEMENT); - var frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], l5 / Int16Array.BYTES_PER_ELEMENT); - var timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], l6 / Uint16Array.BYTES_PER_ELEMENT); - if (dragonBones.DragonBones.webAssembly) { - var lTotal = l1 + l2 + l3 + l4 + l5 + l6; - var bufferPointer = dragonBones.webAssemblyModule._malloc(lTotal); - var rawArray = new Uint8Array(this._binary, this._binaryOffset, lTotal / Uint8Array.BYTES_PER_ELEMENT); - var copyArray = new Uint8Array(dragonBones.webAssemblyModule.HEAP16.buffer, bufferPointer, rawArray.length); - for (var i = 0, l = rawArray.length; i < l; ++i) { - copyArray[i] = rawArray[i]; - } - dragonBones.webAssemblyModule.setDataBinary(this._data, bufferPointer, l1, l2, l3, l4, l5, l6); - this._intArrayBuffer = intArray; - this._floatArrayBuffer = floatArray; - this._frameIntArrayBuffer = frameIntArray; - this._frameFloatArrayBuffer = frameFloatArray; - this._frameArrayBuffer = frameArray; - this._timelineArrayBuffer = timelineArray; - } - else { - this._data.binary = this._binary; - this._data.intArray = this._intArrayBuffer = intArray; - this._data.floatArray = this._floatArrayBuffer = floatArray; - this._data.frameIntArray = this._frameIntArrayBuffer = frameIntArray; - this._data.frameFloatArray = this._frameFloatArrayBuffer = frameFloatArray; - this._data.frameArray = this._frameArrayBuffer = frameArray; - this._data.timelineArray = this._timelineArrayBuffer = timelineArray; - } - }; - BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer, "Data error."); - var tag = new Uint8Array(rawData, 0, 8); - if (tag[0] !== "D".charCodeAt(0) || - tag[1] !== "B".charCodeAt(0) || - tag[2] !== "D".charCodeAt(0) || - tag[3] !== "T".charCodeAt(0)) { - console.assert(false, "Nonsupport data."); - return null; - } - var headerLength = new Uint32Array(rawData, 8, 1)[0]; - var headerBytes = new Uint8Array(rawData, 8 + 4, headerLength); - var headerString = this._decodeUTF8(headerBytes); - var header = JSON.parse(headerString); - // - this._binaryOffset = 8 + 4 + headerLength; - this._binary = rawData; - return _super.prototype.parseDragonBonesData.call(this, header, scale); - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - BinaryDataParser.getInstance = function () { - if (BinaryDataParser._binaryDataParserInstance === null) { - BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); - } - return BinaryDataParser._binaryDataParserInstance; - }; - BinaryDataParser._binaryDataParserInstance = null; - return BinaryDataParser; - }(dragonBones.ObjectDataParser)); - dragonBones.BinaryDataParser = BinaryDataParser; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) - * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. - * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) - * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 - * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - var BaseFactory = /** @class */ (function () { - /** - * - Create a factory instance. (typically only one global factory instance is required) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) - * @version DragonBones 3.0 - * @language zh_CN - */ - function BaseFactory(dataParser) { - if (dataParser === void 0) { dataParser = null; } - /** - * @private - */ - this.autoSearch = false; - this._dragonBonesDataMap = {}; - this._textureAtlasDataMap = {}; - this._dragonBones = null; - this._dataParser = null; - if (BaseFactory._objectParser === null) { - BaseFactory._objectParser = new dragonBones.ObjectDataParser(); - } - if (BaseFactory._binaryParser === null) { - BaseFactory._binaryParser = new dragonBones.BinaryDataParser(); - } - this._dataParser = dataParser !== null ? dataParser : BaseFactory._objectParser; - } - BaseFactory.prototype._isSupportMesh = function () { - return true; - }; - BaseFactory.prototype._getTextureData = function (textureAtlasName, textureName) { - if (textureAtlasName in this._textureAtlasDataMap) { - for (var _i = 0, _a = this._textureAtlasDataMap[textureAtlasName]; _i < _a.length; _i++) { - var textureAtlasData = _a[_i]; - var textureData = textureAtlasData.getTexture(textureName); - if (textureData !== null) { - return textureData; - } - } - } - if (this.autoSearch) { - for (var k in this._textureAtlasDataMap) { - for (var _b = 0, _c = this._textureAtlasDataMap[k]; _b < _c.length; _b++) { - var textureAtlasData = _c[_b]; - if (textureAtlasData.autoSearch) { - var textureData = textureAtlasData.getTexture(textureName); - if (textureData !== null) { - return textureData; - } - } - } - } - } - return null; - }; - BaseFactory.prototype._fillBuildArmaturePackage = function (dataPackage, dragonBonesName, armatureName, skinName, textureAtlasName) { - var dragonBonesData = null; - var armatureData = null; - if (dragonBonesName.length > 0) { - if (dragonBonesName in this._dragonBonesDataMap) { - dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; - armatureData = dragonBonesData.getArmature(armatureName); - } - } - if (armatureData === null && (dragonBonesName.length === 0 || this.autoSearch)) { - for (var k in this._dragonBonesDataMap) { - dragonBonesData = this._dragonBonesDataMap[k]; - if (dragonBonesName.length === 0 || dragonBonesData.autoSearch) { - armatureData = dragonBonesData.getArmature(armatureName); - if (armatureData !== null) { - dragonBonesName = k; - break; - } - } - } - } - if (armatureData !== null) { - dataPackage.dataName = dragonBonesName; - dataPackage.textureAtlasName = textureAtlasName; - dataPackage.data = dragonBonesData; - dataPackage.armature = armatureData; - dataPackage.skin = null; - if (skinName.length > 0) { - dataPackage.skin = armatureData.getSkin(skinName); - if (dataPackage.skin === null && this.autoSearch) { - for (var k in this._dragonBonesDataMap) { - var skinDragonBonesData = this._dragonBonesDataMap[k]; - var skinArmatureData = skinDragonBonesData.getArmature(skinName); - if (skinArmatureData !== null) { - dataPackage.skin = skinArmatureData.defaultSkin; - break; - } - } - } - } - if (dataPackage.skin === null) { - dataPackage.skin = armatureData.defaultSkin; - } - return true; - } - return false; - }; - BaseFactory.prototype._buildBones = function (dataPackage, armature) { - for (var _i = 0, _a = dataPackage.armature.sortedBones; _i < _a.length; _i++) { - var boneData = _a[_i]; - var bone = dragonBones.BaseObject.borrowObject(boneData.type === 0 /* Bone */ ? dragonBones.Bone : dragonBones.Surface); - bone.init(boneData, armature); - } - }; - /** - * @private - */ - BaseFactory.prototype._buildSlots = function (dataPackage, armature) { - var currentSkin = dataPackage.skin; - var defaultSkin = dataPackage.armature.defaultSkin; - if (currentSkin === null || defaultSkin === null) { - return; - } - var skinSlots = {}; - for (var k in defaultSkin.displays) { - var displays = defaultSkin.getDisplays(k); - skinSlots[k] = displays; - } - if (currentSkin !== defaultSkin) { - for (var k in currentSkin.displays) { - var displays = currentSkin.getDisplays(k); - skinSlots[k] = displays; - } - } - for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { - var slotData = _a[_i]; - var displayDatas = slotData.name in skinSlots ? skinSlots[slotData.name] : null; - var slot = this._buildSlot(dataPackage, slotData, armature); - slot.rawDisplayDatas = displayDatas; - if (displayDatas !== null) { - var displayList = new Array(); - // for (const displayData of displays) - for (var i = 0, l = dragonBones.DragonBones.webAssembly ? displayDatas.size() : displayDatas.length; i < l; ++i) { - var displayData = dragonBones.DragonBones.webAssembly ? displayDatas.get(i) : displayDatas[i]; - if (displayData !== null) { - displayList.push(this._getSlotDisplay(dataPackage, displayData, null, slot)); - } - else { - displayList.push(null); - } - } - slot._setDisplayList(displayList); - } - slot._setDisplayIndex(slotData.displayIndex, true); - } - }; - BaseFactory.prototype._buildConstraints = function (dataPackage, armature) { - var constraints = dataPackage.armature.constraints; - for (var k in constraints) { - var constraintData = constraints[k]; - // TODO more constraint type. - switch (constraintData.type) { - case 0 /* IK */: - var ikConstraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); - ikConstraint.init(constraintData, armature); - armature._addConstraint(ikConstraint); - break; - case 1 /* Path */: - var pathConstraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraint); - pathConstraint.init(constraintData, armature); - armature._addConstraint(pathConstraint); - break; - default: - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); - constraint.init(constraintData, armature); - armature._addConstraint(constraint); - break; - } - } - }; - BaseFactory.prototype._buildChildArmature = function (dataPackage, slot, displayData) { - // tslint:disable-next-line:no-unused-expression - slot; - return this.buildArmature(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage !== null ? dataPackage.textureAtlasName : ""); - }; - BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, rawDisplayData, slot) { - var dataName = dataPackage !== null ? dataPackage.dataName : displayData.parent.parent.parent.name; - var display = null; - switch (displayData.type) { - case 0 /* Image */: { - var imageDisplayData = displayData; - if (imageDisplayData.texture === null) { - imageDisplayData.texture = this._getTextureData(dataName, displayData.path); - } - else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { - imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path); - } - if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */ && this._isSupportMesh()) { - display = slot.meshDisplay; - } - else { - display = slot.rawDisplay; - } - break; - } - case 2 /* Mesh */: { - var meshDisplayData = displayData; - if (meshDisplayData.texture === null) { - meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); - } - else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { - meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path); - } - if (this._isSupportMesh()) { - display = slot.meshDisplay; - } - else { - display = slot.rawDisplay; - } - break; - } - case 1 /* Armature */: { - var armatureDisplayData = displayData; - var childArmature = this._buildChildArmature(dataPackage, slot, displayData); - if (childArmature !== null) { - childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; - if (!childArmature.inheritAnimation) { - var actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; - if (actions.length > 0) { - for (var _i = 0, actions_6 = actions; _i < actions_6.length; _i++) { - var action = actions_6[_i]; - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - dragonBones.EventObject.actionDataToInstance(action, eventObject, slot.armature); - eventObject.slot = slot; - slot.armature._bufferAction(eventObject, false); - } - } - else { - childArmature.animation.play(); - } - } - armatureDisplayData.armature = childArmature.armatureData; // - } - display = childArmature; - break; - } - case 3 /* BoundingBox */: - break; - default: - break; - } - return display; - }; - /** - * - Parse the raw data to a DragonBonesData instance and cache it to the factory. - * @param rawData - The raw data. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for all armatures. (Default: 1.0) - * @returns DragonBonesData instance - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 - * @param rawData - 原始数据。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) - * @returns DragonBonesData 实例 - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.parseDragonBonesData = function (rawData, name, scale) { - if (name === void 0) { name = null; } - if (scale === void 0) { scale = 1.0; } - var dataParser = rawData instanceof ArrayBuffer ? BaseFactory._binaryParser : this._dataParser; - var dragonBonesData = dataParser.parseDragonBonesData(rawData, scale); - while (true) { - var textureAtlasData = this._buildTextureAtlasData(null, null); - if (dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { - this.addTextureAtlasData(textureAtlasData, name); - } - else { - textureAtlasData.returnToPool(); - break; - } - } - if (dragonBonesData !== null) { - this.addDragonBonesData(dragonBonesData, name); - } - return dragonBonesData; - }; - /** - * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. - * @param rawData - The raw texture atlas data. - * @param textureAtlas - The texture atlas object. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for the map set. (Default: 1.0) - * @returns TextureAtlasData instance - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 - * @param rawData - 原始贴图集数据。 - * @param textureAtlas - 贴图集对象。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) - * @returns TextureAtlasData 实例 - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { - if (name === void 0) { name = null; } - if (scale === void 0) { scale = 1.0; } - var textureAtlasData = this._buildTextureAtlasData(null, null); - this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); - this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); - this.addTextureAtlasData(textureAtlasData, name); - return textureAtlasData; - }; - /** - * @private - */ - BaseFactory.prototype.updateTextureAtlasData = function (name, textureAtlases) { - var textureAtlasDatas = this.getTextureAtlasData(name); - if (textureAtlasDatas !== null) { - for (var i = 0, l = textureAtlasDatas.length; i < l; ++i) { - if (i < textureAtlases.length) { - this._buildTextureAtlasData(textureAtlasDatas[i], textureAtlases[i]); - } - } - } - }; - /** - * - Get a specific DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @returns DragonBonesData instance - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 DragonBonesData 实例。 - * @param name - DragonBonesData 实例的缓存名称。 - * @returns DragonBonesData 实例 - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.getDragonBonesData = function (name) { - return (name in this._dragonBonesDataMap) ? this._dragonBonesDataMap[name] : null; - }; - /** - * - Cache a DragonBonesData instance to the factory. - * @param data - The DragonBonesData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 DragonBonesData 实例缓存到工厂中。 - * @param data - DragonBonesData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.addDragonBonesData = function (data, name) { - if (name === void 0) { name = null; } - name = name !== null ? name : data.name; - if (name in this._dragonBonesDataMap) { - if (this._dragonBonesDataMap[name] === data) { - return; - } - console.warn("Can not add same name data: " + name); - return; - } - this._dragonBonesDataMap[name] = data; - }; - /** - * - Remove a DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @param disposeData - Whether to dispose data. (Default: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 DragonBonesData 实例。 - * @param name - DragonBonesData 实例缓存名称。 - * @param disposeData - 是否释放数据。 (默认: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.removeDragonBonesData = function (name, disposeData) { - if (disposeData === void 0) { disposeData = true; } - if (name in this._dragonBonesDataMap) { - if (disposeData) { - this._dragonBones.bufferObject(this._dragonBonesDataMap[name]); - } - delete this._dragonBonesDataMap[name]; - } - }; - /** - * - Get a list of specific TextureAtlasData instances. - * @param name - The TextureAtlasData cahce name. - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 TextureAtlasData 实例列表。 - * @param name - TextureAtlasData 实例缓存名称。 - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.getTextureAtlasData = function (name) { - return (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : null; - }; - /** - * - Cache a TextureAtlasData instance to the factory. - * @param data - The TextureAtlasData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 TextureAtlasData 实例缓存到工厂中。 - * @param data - TextureAtlasData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.addTextureAtlasData = function (data, name) { - if (name === void 0) { name = null; } - name = name !== null ? name : data.name; - var textureAtlasList = (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : (this._textureAtlasDataMap[name] = []); - if (textureAtlasList.indexOf(data) < 0) { - textureAtlasList.push(data); - } - }; - /** - * - Remove a TextureAtlasData instance. - * @param name - The TextureAtlasData instance cache name. - * @param disposeData - Whether to dispose data. - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 TextureAtlasData 实例。 - * @param name - TextureAtlasData 实例的缓存名称。 - * @param disposeData - 是否释放数据。 - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.removeTextureAtlasData = function (name, disposeData) { - if (disposeData === void 0) { disposeData = true; } - if (name in this._textureAtlasDataMap) { - var textureAtlasDataList = this._textureAtlasDataMap[name]; - if (disposeData) { - for (var _i = 0, textureAtlasDataList_1 = textureAtlasDataList; _i < textureAtlasDataList_1.length; _i++) { - var textureAtlasData = textureAtlasDataList_1[_i]; - this._dragonBones.bufferObject(textureAtlasData); - } - } - delete this._textureAtlasDataMap[name]; - } - }; - /** - * - Get a specific armature data. - * @param name - The armature data name. - * @param dragonBonesName - The cached name for DragonbonesData instance. - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param name - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language zh_CN - */ - BaseFactory.prototype.getArmatureData = function (name, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - var dataPackage = new BuildArmaturePackage(); - if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, "", "")) { - return null; - } - return dataPackage.armature; - }; - /** - * - Clear all cached DragonBonesData instances and TextureAtlasData instances. - * @param disposeData - Whether to dispose data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 - * @param disposeData - 是否释放数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.clear = function (disposeData) { - if (disposeData === void 0) { disposeData = true; } - for (var k in this._dragonBonesDataMap) { - if (disposeData) { - this._dragonBones.bufferObject(this._dragonBonesDataMap[k]); - } - delete this._dragonBonesDataMap[k]; - } - for (var k in this._textureAtlasDataMap) { - if (disposeData) { - var textureAtlasDataList = this._textureAtlasDataMap[k]; - for (var _i = 0, textureAtlasDataList_2 = textureAtlasDataList; _i < textureAtlasDataList_2.length; _i++) { - var textureAtlasData = textureAtlasDataList_2[_i]; - this._dragonBones.bufferObject(textureAtlasData); - } - } - delete this._textureAtlasDataMap[k]; - } - }; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. - * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature. - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 - * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架。 - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - if (textureAtlasName === void 0) { textureAtlasName = ""; } - var dataPackage = new BuildArmaturePackage(); - if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, skinName || "", textureAtlasName || "")) { - console.warn("No armature data: " + armatureName + ", " + (dragonBonesName !== null ? dragonBonesName : "")); - return null; - } - var armature = this._buildArmature(dataPackage); - this._buildBones(dataPackage, armature); - this._buildSlots(dataPackage, armature); - this._buildConstraints(dataPackage, armature); - armature.invalidUpdate(null, true); - armature.advanceTime(0.0); // Update armature pose. - return armature; - }; - /** - * @private - */ - BaseFactory.prototype.replaceDisplay = function (slot, displayData, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - if (displayIndex < 0) { - displayIndex = slot.displayIndex; - } - if (displayIndex < 0) { - displayIndex = 0; - } - slot.replaceDisplayData(displayData, displayIndex); - var displayList = slot.displayList; // Copy. - if (displayList.length <= displayIndex) { - displayList.length = displayIndex + 1; - for (var i = 0, l = displayList.length; i < l; ++i) { - if (!displayList[i]) { - displayList[i] = null; - } - } - } - if (displayData !== null) { - var rawDisplayDatas = slot.rawDisplayDatas; - var rawDisplayData = null; - if (rawDisplayDatas) { - if (dragonBones.DragonBones.webAssembly) { - if (displayIndex < rawDisplayDatas.size()) { - rawDisplayData = rawDisplayDatas.get(displayIndex); - } - } - else { - if (displayIndex < rawDisplayDatas.length) { - rawDisplayData = rawDisplayDatas[displayIndex]; - } - } - } - displayList[displayIndex] = this._getSlotDisplay(null, displayData, rawDisplayData, slot); - } - else { - displayList[displayIndex] = null; - } - slot.displayList = displayList; - }; - /** - * - Replaces the current display data for a particular slot with a specific display data. - * Specify display data with "dragonBonesName/armatureName/slotName/displayName". - * @param dragonBonesName - The DragonBonesData instance cache name. - * @param armatureName - The armature data name. - * @param slotName - The slot data name. - * @param displayName - The display data name. - * @param slot - The slot. - * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 - * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @param armatureName - 骨架数据名称。 - * @param slotName - 插槽数据名称。 - * @param displayName - 显示对象数据名称。 - * @param slot - 插槽。 - * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); - if (!armatureData || !armatureData.defaultSkin) { - return false; - } - var displayData = armatureData.defaultSkin.getDisplay(slotName, displayName); - if (!displayData) { - return false; - } - this.replaceDisplay(slot, displayData, displayIndex); - return true; - }; - /** - * @private - */ - BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { - var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); - if (!armatureData || !armatureData.defaultSkin) { - return false; - } - var displays = armatureData.defaultSkin.getDisplays(slotName); - if (!displays) { - return false; - } - var displayIndex = 0; - // for (const displayData of displays) - for (var i = 0, l = dragonBones.DragonBones.webAssembly ? displays.size() : displays.length; i < l; ++i) { - var displayData = dragonBones.DragonBones.webAssembly ? displays.get(i) : displays[i]; - this.replaceDisplay(slot, displayData, displayIndex++); - } - return true; - }; - /** - * - Share specific skin data with specific armature. - * @param armature - The armature. - * @param skin - The skin data. - * @param isOverride - Whether it completely override the original skin. (Default: false) - * @param exclude - A list of slot names that do not need to be replace. - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 将特定的皮肤数据共享给特定的骨架使用。 - * @param armature - 骨架。 - * @param skin - 皮肤数据。 - * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) - * @param exclude - 不需要被替换的插槽名称列表。 - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language zh_CN - */ - BaseFactory.prototype.replaceSkin = function (armature, skin, isOverride, exclude) { - if (isOverride === void 0) { isOverride = false; } - if (exclude === void 0) { exclude = null; } - var success = false; - var defaultSkin = skin.parent.defaultSkin; - for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (exclude !== null && exclude.indexOf(slot.name) >= 0) { - continue; - } - var displays = skin.getDisplays(slot.name); - if (!displays) { - if (defaultSkin !== null && skin !== defaultSkin) { - displays = defaultSkin.getDisplays(slot.name); - } - if (!displays) { - if (isOverride) { - slot.rawDisplayDatas = null; - slot.displayList = []; // - } - continue; - } - } - var displayCount = dragonBones.DragonBones.webAssembly ? displays.size() : displays.length; - var displayList = slot.displayList; // Copy. - displayList.length = displayCount; // Modify displayList length. - for (var i = 0, l = displayCount; i < l; ++i) { - var displayData = dragonBones.DragonBones.webAssembly ? displays.get(i) : displays[i]; - if (displayData !== null) { - displayList[i] = this._getSlotDisplay(null, displayData, null, slot); - } - else { - displayList[i] = null; - } - } - success = true; - slot.rawDisplayDatas = displays; - slot.displayList = displayList; - } - return success; - }; - /** - * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. - * This enables you to make a armature template so that other armature without animations can share it's animations. - * @param armature - The armtaure. - * @param armatureData - The armature data. - * @param isOverride - Whether to completely overwrite the original animation. (Default: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 - * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 - * @param armature - 骨架。 - * @param armatureData - 骨架数据。 - * @param isOverride - 是否完全覆盖原来的动画。(默认: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language zh_CN - */ - BaseFactory.prototype.replaceAnimation = function (armature, armatureData, isOverride) { - if (isOverride === void 0) { isOverride = true; } - var skinData = armatureData.defaultSkin; - if (skinData === null) { - return false; - } - if (isOverride) { - armature.animation.animations = armatureData.animations; - } - else { - var rawAnimations = armature.animation.animations; - var animations = {}; - for (var k in rawAnimations) { - animations[k] = rawAnimations[k]; - } - for (var k in armatureData.animations) { - animations[k] = armatureData.animations[k]; - } - armature.animation.animations = animations; - } - for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - var index = 0; - for (var _b = 0, _c = slot.displayList; _b < _c.length; _b++) { - var display = _c[_b]; - if (display instanceof dragonBones.Armature) { - var displayDatas = skinData.getDisplays(slot.name); - if (displayDatas !== null && index < (dragonBones.DragonBones.webAssembly ? displayDatas.size() : displayDatas.length)) { - var displayData = dragonBones.DragonBones.webAssembly ? displayDatas.get(index) : displayDatas[index]; - if (displayData !== null && displayData.type === 1 /* Armature */) { - var childArmatureData = this.getArmatureData(displayData.path, displayData.parent.parent.parent.name); - if (childArmatureData) { - this.replaceAnimation(display, childArmatureData, isOverride); - } - } - } - } - index++; - } - } - return true; - }; - /** - * @private - */ - BaseFactory.prototype.getAllDragonBonesData = function () { - return this._dragonBonesDataMap; - }; - /** - * @private - */ - BaseFactory.prototype.getAllTextureAtlasData = function () { - return this._textureAtlasDataMap; - }; - Object.defineProperty(BaseFactory.prototype, "clock", { - /** - * - An Worldclock instance updated by engine. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 由引擎驱动的 WorldClock 实例。 - * @version DragonBones 5.7 - * @language zh_CN - */ - get: function () { - return this._dragonBones.clock; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BaseFactory.prototype, "dragonBones", { - /** - * @private - */ - get: function () { - return this._dragonBones; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #replaceSkin}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #replaceSkin}。 - * @deprecated - * @language zh_CN - */ - BaseFactory.prototype.changeSkin = function (armature, skin, exclude) { - if (exclude === void 0) { exclude = null; } - return this.replaceSkin(armature, skin, false, exclude); - }; - /** - * - Deprecated, please refer to {@link #replaceAnimation}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #replaceAnimation}。 - * @deprecated - * @language zh_CN - */ - BaseFactory.prototype.copyAnimationsToArmature = function (toArmature, fromArmatreName, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation) { - if (fromSkinName === void 0) { fromSkinName = ""; } - if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = ""; } - if (replaceOriginalAnimation === void 0) { replaceOriginalAnimation = true; } - // tslint:disable-next-line:no-unused-expression - fromSkinName; - var armatureData = this.getArmatureData(fromArmatreName, fromDragonBonesDataName); - if (!armatureData) { - return false; - } - return this.replaceAnimation(toArmature, armatureData, replaceOriginalAnimation); - }; - BaseFactory._objectParser = null; - BaseFactory._binaryParser = null; - return BaseFactory; - }()); - dragonBones.BaseFactory = BaseFactory; - /** - * @internal - */ - var BuildArmaturePackage = /** @class */ (function () { - function BuildArmaturePackage() { - this.dataName = ""; - this.textureAtlasName = ""; - this.skin = null; - } - return BuildArmaturePackage; - }()); - dragonBones.BuildArmaturePackage = BuildArmaturePackage; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The egret texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var EgretTextureAtlasData = /** @class */ (function (_super) { - __extends(EgretTextureAtlasData, _super); - function EgretTextureAtlasData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._renderTexture = null; // Initial value. - return _this; - } - EgretTextureAtlasData.toString = function () { - return "[class dragonBones.EgretTextureAtlasData]"; - }; - EgretTextureAtlasData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.disposeEnabled && this._renderTexture !== null) { - this._renderTexture.dispose(); - } - this.disposeEnabled = false; - this._renderTexture = null; - }; - /** - * @inheritDoc - */ - EgretTextureAtlasData.prototype.createTexture = function () { - return dragonBones.BaseObject.borrowObject(EgretTextureData); - }; - Object.defineProperty(EgretTextureAtlasData.prototype, "renderTexture", { - /** - * - The Egret texture. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 贴图。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._renderTexture; - }, - set: function (value) { - if (this._renderTexture === value) { - return; - } - this._renderTexture = value; - if (this._renderTexture !== null) { - var bitmapData = this._renderTexture.bitmapData; - var textureAtlasWidth = this.width > 0.0 ? this.width : bitmapData.width; - var textureAtlasHeight = this.height > 0.0 ? this.height : bitmapData.height; - for (var k in this.textures) { - var scale = egret.$TextureScaleFactor; - var textureData = this.textures[k]; - var subTextureWidth = textureData.region.width; - var subTextureHeight = textureData.region.height; - if (textureData.renderTexture === null) { - textureData.renderTexture = new egret.Texture(); - } - textureData.renderTexture.bitmapData = bitmapData; - if (textureData.rotated) { - textureData.renderTexture.$initData(textureData.region.x * scale, textureData.region.y * scale, subTextureHeight * scale, subTextureWidth * scale, 0, 0, subTextureHeight * scale, subTextureWidth * scale, textureAtlasWidth, textureAtlasHeight, textureData.rotated); - } - else { - textureData.renderTexture.$initData(textureData.region.x * scale, textureData.region.y * scale, subTextureWidth * scale, subTextureHeight * scale, 0, 0, subTextureWidth * scale, subTextureHeight * scale, textureAtlasWidth, textureAtlasHeight); - } - } - } - else { - for (var k in this.textures) { - var textureData = this.textures[k]; - textureData.renderTexture = null; - } - } - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#removeTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#removeTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - EgretTextureAtlasData.prototype.dispose = function () { - console.warn("已废弃。"); - this.returnToPool(); - }; - Object.defineProperty(EgretTextureAtlasData.prototype, "texture", { - /** - * - Deprecated, please refer to {@link #renderTexture}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #renderTexture}。 - * @deprecated - * @language zh_CN - */ - get: function () { - console.warn("已废弃。"); - return this.renderTexture; - }, - enumerable: true, - configurable: true - }); - return EgretTextureAtlasData; - }(dragonBones.TextureAtlasData)); - dragonBones.EgretTextureAtlasData = EgretTextureAtlasData; - /** - * @internal - */ - var EgretTextureData = /** @class */ (function (_super) { - __extends(EgretTextureData, _super); - function EgretTextureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.renderTexture = null; // Initial value. - return _this; - } - EgretTextureData.toString = function () { - return "[class dragonBones.EgretTextureData]"; - }; - EgretTextureData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.renderTexture !== null) { - //this.renderTexture.dispose(false); - //this.renderTexture.dispose(); - } - this.renderTexture = null; - }; - return EgretTextureData; - }(dragonBones.TextureData)); - dragonBones.EgretTextureData = EgretTextureData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The egret event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - Egret 事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - var EgretEvent = /** @class */ (function (_super) { - __extends(EgretEvent, _super); - function EgretEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(EgretEvent.prototype, "eventObject", { - /** - * - The event object. - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象。 - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this.data; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "animationName", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - get: function () { - var animationState = this.eventObject.animationState; - return animationState !== null ? animationState.name : ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "armature", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#armature}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#armature}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.armature; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "bone", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#bone}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#bone}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.bone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "slot", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#slot}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#slot}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.slot; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "animationState", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.animationState; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "frameLabel", { - /** - * Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#name}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#name}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "sound", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#name}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#name}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "movementID", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.animationName; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.START}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.START}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.START = dragonBones.EventObject.START; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.LOOP_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.LOOP_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.LOOP_COMPLETE = dragonBones.EventObject.LOOP_COMPLETE; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.COMPLETE}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.COMPLETE = dragonBones.EventObject.COMPLETE; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_IN}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_IN}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.FADE_IN = dragonBones.EventObject.FADE_IN; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_IN_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_IN_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.FADE_IN_COMPLETE = dragonBones.EventObject.FADE_IN_COMPLETE; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_OUT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_OUT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.FADE_OUT = dragonBones.EventObject.FADE_OUT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_OUT_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_OUT_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.FADE_OUT_COMPLETE = dragonBones.EventObject.FADE_OUT_COMPLETE; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.SOUND_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.SOUND_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.SOUND_EVENT = dragonBones.EventObject.SOUND_EVENT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.ANIMATION_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.BONE_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.MOVEMENT_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.SOUND_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.SOUND_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.SOUND = dragonBones.EventObject.SOUND_EVENT; - return EgretEvent; - }(egret.Event)); - dragonBones.EgretEvent = EgretEvent; - /** - * @inheritDoc - */ - var EgretArmatureDisplay = /** @class */ (function (_super) { - __extends(EgretArmatureDisplay, _super); - function EgretArmatureDisplay() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.debugDraw = false; - /** - * @internal - */ - _this._batchEnabled = !(global["nativeRender"] || global["bricks"]); // - /** - * @internal - */ - _this._childDirty = true; - _this._debugDraw = false; - _this._armature = null; // - _this._bounds = null; - _this._debugDrawer = null; - return _this; - } - EgretArmatureDisplay._cleanBeforeRender = function () { }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.dbInit = function (armature) { - this._armature = armature; - if (this._batchEnabled) { - this.$renderNode = new egret.sys.GroupNode(); - this.$renderNode.cleanBeforeRender = EgretArmatureDisplay._cleanBeforeRender; - } - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.dbClear = function () { - this._armature = null; - this._bounds = null; - this._debugDrawer = null; - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.dbUpdate = function () { - var drawed = dragonBones.DragonBones.debugDraw || this.debugDraw; - if (drawed || this._debugDraw) { - this._debugDraw = drawed; - if (this._debugDraw) { - if (this._debugDrawer === null) { - this._debugDrawer = new egret.Sprite(); - } - if (this._debugDrawer.parent !== this) { - this.addChild(this._debugDrawer); - } - var boneStep = 2.0; - var graphics = this._debugDrawer.graphics; - graphics.clear(); - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone.boneData.type === 0 /* Bone */) { - var boneLength = Math.max(bone.boneData.length, boneStep); - var startX = bone.globalTransformMatrix.tx; - var startY = bone.globalTransformMatrix.ty; - var aX = startX - bone.globalTransformMatrix.a * boneStep; - var aY = startY - bone.globalTransformMatrix.b * boneStep; - var bX = startX + bone.globalTransformMatrix.a * boneLength; - var bY = startY + bone.globalTransformMatrix.b * boneLength; - var cX = startX + aY - startY; - var cY = startY + aX - startX; - var dX = startX - aY + startY; - var dY = startY - aX + startX; - // - graphics.lineStyle(2.0, 0x00FFFF, 0.7); - graphics.moveTo(aX, aY); - graphics.lineTo(bX, bY); - graphics.moveTo(cX, cY); - graphics.lineTo(dX, dY); - } - else { - var surface = bone; - var surfaceData = surface._boneData; - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var vertices = surface._vertices; - graphics.lineStyle(2.0, 0xFFFF00, 0.7); - for (var iY = 0; iY < segmentY; ++iY) { - for (var iX = 0; iX < segmentX; ++iX) { - var vertexIndex = (iX + iY * (segmentX + 1)) * 2; - var x = vertices[vertexIndex]; - var y = vertices[vertexIndex + 1]; - graphics.moveTo(x, y); - graphics.lineTo(vertices[vertexIndex + 2], vertices[vertexIndex + 3]); - graphics.moveTo(x, y); - graphics.lineTo(vertices[vertexIndex + (segmentX + 1) * 2], vertices[vertexIndex + (segmentX + 1) * 2 + 1]); - if (iX === segmentX - 1) { - graphics.moveTo(vertices[vertexIndex + 2], vertices[vertexIndex + 3]); - graphics.lineTo(vertices[vertexIndex + (segmentX + 2) * 2], vertices[vertexIndex + (segmentX + 2) * 2 + 1]); - } - if (iY === segmentY - 1) { - graphics.moveTo(vertices[vertexIndex + (segmentX + 1) * 2], vertices[vertexIndex + (segmentX + 1) * 2 + 1]); - graphics.lineTo(vertices[vertexIndex + (segmentX + 2) * 2], vertices[vertexIndex + (segmentX + 2) * 2 + 1]); - } - } - } - } - } - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - var boundingBoxData = slot.boundingBoxData; - if (boundingBoxData !== null) { - var child = this._debugDrawer.getChildByName(slot.name); - if (child === null) { - child = new egret.Shape(); - child.name = slot.name; - this._debugDrawer.addChild(child); - } - child.graphics.clear(); - child.graphics.lineStyle(2.0, 0xFF00FF, 0.7); - switch (boundingBoxData.type) { - case 0 /* Rectangle */: - child.graphics.drawRect(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height); - break; - case 1 /* Ellipse */: - child.graphics.drawEllipse(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height); - break; - case 2 /* Polygon */: - var vertices = boundingBoxData.vertices; - for (var i = 0; i < vertices.length; i += 2) { - var x = vertices[i]; - var y = vertices[i + 1]; - if (i === 0) { - child.graphics.moveTo(x, y); - } - else { - child.graphics.lineTo(x, y); - } - } - child.graphics.lineTo(vertices[0], vertices[1]); - break; - default: - break; - } - slot.updateTransformAndMatrix(); - slot.updateGlobalTransform(); - child.$setMatrix(slot.globalTransformMatrix, false); - } - else { - var child = this._debugDrawer.getChildByName(slot.name); - if (child !== null) { - this._debugDrawer.removeChild(child); - } - } - } - } - else if (this._debugDrawer !== null && this._debugDrawer.parent === this) { - this.removeChild(this._debugDrawer); - } - } - if (!dragonBones.isV5 && this._batchEnabled && this._childDirty) { - this.$invalidateContentBounds(); - } - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.dispose = function (disposeProxy) { - if (disposeProxy === void 0) { disposeProxy = true; } - // tslint:disable-next-line:no-unused-expression - disposeProxy; - if (this._armature !== null) { - this._armature.dispose(); - this._armature = null; - } - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.dispatchDBEvent = function (type, eventObject) { - var event = egret.Event.create(EgretEvent, type); - event.data = eventObject; - _super.prototype.dispatchEvent.call(this, event); - egret.Event.release(event); - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.hasDBEventListener = function (type) { - return this.hasEventListener(type); - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.addDBEventListener = function (type, listener, target) { - this.addEventListener(type, listener, target); - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.removeDBEventListener = function (type, listener, target) { - this.removeEventListener(type, listener, target); - }; - /** - * - Disable the batch. - * Batch rendering for performance reasons, the boundary properties of the render object are not updated. - * This will not correctly obtain the wide-height properties of the rendered object and the transformation properties of its internal display objects, - * which can turn off batch rendering if you need to use these properties. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 关闭批次渲染。 - * 批次渲染出于性能考虑,不会更新渲染对象的边界属性。 - * 这样将无法正确获得渲染对象的宽高属性以及其内部显示对象的变换属性,如果需要使用这些属性,可以关闭批次渲染。 - * @version DragonBones 5.1 - * @language zh_CN - */ - EgretArmatureDisplay.prototype.disableBatch = function () { - if (!this._batchEnabled || !this._armature) { - return; - } - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - // (slot as EgretSlot).transformUpdateEnabled = true; - var display = ((slot._deformVertices && slot._deformVertices.verticesData) ? slot.meshDisplay : slot.rawDisplay); - if (!slot.display && display === slot.meshDisplay) { - display = slot.rawDisplay; - } - var node = display.$renderNode; - // Transform. - if (node.matrix) { - display.$setMatrix(slot.globalTransformMatrix, false); - } - // ZOrder. - this.addChild(display); - } - this._batchEnabled = false; - this.$renderNode.cleanBeforeRender = null; - this.$renderNode = null; - this.armature.invalidUpdate(null, true); - }; - Object.defineProperty(EgretArmatureDisplay.prototype, "armature", { - /** - * @inheritDoc - */ - get: function () { - return this._armature; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretArmatureDisplay.prototype, "animation", { - /** - * @inheritDoc - */ - get: function () { - return this._armature.animation; - }, - enumerable: true, - configurable: true - }); - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.$measureContentBounds = function (bounds) { - if (this._batchEnabled && this._armature) { - if (this._childDirty) { - this._childDirty = false; - var isFirst = true; - var helpRectangle = new egret.Rectangle(); - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - var display = slot.display; - if (!display || !display.$renderNode || !display.$renderNode.image) { - continue; - } - var matrix = display.$renderNode.matrix; - if (display === slot.meshDisplay) { - var vertices = display.$renderNode.vertices; - if (vertices && vertices.length > 0) { - helpRectangle.setTo(999999.0, 999999.0, -999999.0, -999999.0); - for (var i = 0, l = vertices.length; i < l; i += 2) { - var x = vertices[i]; - var y = vertices[i + 1]; - if (helpRectangle.x > x) - helpRectangle.x = x; - if (helpRectangle.width < x) - helpRectangle.width = x; - if (helpRectangle.y > y) - helpRectangle.y = y; - if (helpRectangle.height < y) - helpRectangle.height = y; - } - helpRectangle.width -= helpRectangle.x; - helpRectangle.height -= helpRectangle.y; - } - else { - continue; - } - } - else { - var displayData = slot.displayData; - if (displayData && displayData instanceof dragonBones.ImageDisplayData && displayData.texture) { - var scale = displayData.texture.parent.scale; - helpRectangle.x = 0; - helpRectangle.y = 0; - helpRectangle.width = displayData.texture.region.width * scale; - helpRectangle.height = displayData.texture.region.height * scale; - } - else { - continue; - } - } - matrix.$transformBounds(helpRectangle); - var left = helpRectangle.x; - var top_1 = helpRectangle.y; - var right = helpRectangle.x + helpRectangle.width; - var bottom = helpRectangle.y + helpRectangle.height; - if (isFirst) { - isFirst = false; - bounds.x = left; - bounds.y = top_1; - bounds.width = right; - bounds.height = bottom; - } - else { - if (left < bounds.x) { - bounds.x = left; - } - if (top_1 < bounds.y) { - bounds.y = top_1; - } - if (right > bounds.width) { - bounds.width = right; - } - if (bottom > bounds.height) { - bounds.height = bottom; - } - } - } - bounds.width -= bounds.x; - bounds.height -= bounds.y; - if (dragonBones.isV5) { - if (this._bounds === null) { - this._bounds = new egret.Rectangle(); - } - this._bounds.copyFrom(bounds); - } - } - else if (dragonBones.isV5) { - if (this._bounds === null) { - this._bounds = new egret.Rectangle(); - } - bounds.copyFrom(this._bounds); - } - return bounds; // V5 - } - return _super.prototype.$measureContentBounds.call(this, bounds); // V5 - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.hasEvent = function (type) { - return this.hasDBEventListener(type); - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.addEvent = function (type, listener, target) { - this.addDBEventListener(type, listener, target); - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.removeEvent = function (type, listener, target) { - this.removeDBEventListener(type, listener, target); - }; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#clock} {@link dragonBones.BaseFactory#clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#clock} {@link dragonBones.BaseFactory#clock}。 - * @deprecated - * @language zh_CN - */ - EgretArmatureDisplay.prototype.advanceTimeBySelf = function (on) { - if (on) { - this._armature.clock = dragonBones.EgretFactory.factory.clock; - } - else { - this._armature.clock = null; - } - }; - return EgretArmatureDisplay; - }(egret.DisplayObjectContainer)); - dragonBones.EgretArmatureDisplay = EgretArmatureDisplay; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - var Event = /** @class */ (function (_super) { - __extends(Event, _super); - function Event() { - return _super !== null && _super.apply(this, arguments) || this; - } - return Event; - }(EgretEvent)); - dragonBones.Event = Event; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - var ArmatureEvent = /** @class */ (function (_super) { - __extends(ArmatureEvent, _super); - function ArmatureEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return ArmatureEvent; - }(EgretEvent)); - dragonBones.ArmatureEvent = ArmatureEvent; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - var AnimationEvent = /** @class */ (function (_super) { - __extends(AnimationEvent, _super); - function AnimationEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return AnimationEvent; - }(EgretEvent)); - dragonBones.AnimationEvent = AnimationEvent; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - var FrameEvent = /** @class */ (function (_super) { - __extends(FrameEvent, _super); - function FrameEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return FrameEvent; - }(EgretEvent)); - dragonBones.FrameEvent = FrameEvent; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - var SoundEvent = /** @class */ (function (_super) { - __extends(SoundEvent, _super); - function SoundEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return SoundEvent; - }(EgretEvent)); - dragonBones.SoundEvent = SoundEvent; - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - var EgretTextureAtlas = /** @class */ (function (_super) { - __extends(EgretTextureAtlas, _super); - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - function EgretTextureAtlas(texture, rawData, scale) { - if (scale === void 0) { scale = 1; } - var _this = _super.call(this) || this; - console.warn("已废弃"); - _this._onClear(); - dragonBones.ObjectDataParser.getInstance().parseTextureAtlasData(rawData, _this, scale); - _this.renderTexture = texture; - return _this; - } - EgretTextureAtlas.toString = function () { - return "[class dragonBones.EgretTextureAtlas]"; - }; - return EgretTextureAtlas; - }(dragonBones.EgretTextureAtlasData)); - dragonBones.EgretTextureAtlas = EgretTextureAtlas; - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - var EgretSheetAtlas = /** @class */ (function (_super) { - __extends(EgretSheetAtlas, _super); - function EgretSheetAtlas() { - return _super !== null && _super.apply(this, arguments) || this; - } - return EgretSheetAtlas; - }(EgretTextureAtlas)); - dragonBones.EgretSheetAtlas = EgretSheetAtlas; - /** - * 已废弃,请参考 {@link dragonBones.EgretFactory#soundEventManager}。 - * @deprecated - * @language zh_CN - */ - var SoundEventManager = /** @class */ (function () { - function SoundEventManager() { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretFactory#soundEventManager}。 - * @deprecated - * @language zh_CN - */ - SoundEventManager.getInstance = function () { - console.warn("已废弃"); - return dragonBones.EgretFactory.factory.soundEventManager; - }; - return SoundEventManager; - }()); - dragonBones.SoundEventManager = SoundEventManager; - /** - * 已废弃,请参考 {@link dragonBones.Armature#cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - var AnimationCacheManager = /** @class */ (function () { - /** - * 已废弃,请参考 {@link dragonBones.Armature#cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - function AnimationCacheManager() { - console.warn("已废弃"); - } - return AnimationCacheManager; - }()); - dragonBones.AnimationCacheManager = AnimationCacheManager; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The egret slot. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 插槽。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var EgretSlot = /** @class */ (function (_super) { - __extends(EgretSlot, _super); - function EgretSlot() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - Whether to update the transform properties of the display object. - * For better performance, the transform properties of display object (x, y, rotation, ScaleX, ScaleX) are not updated and need to be set to true if these properties need to be accessed correctly. - * @default false - * @version DragonBones 3.0 - * @language zh_CN - */ - /** - * - 是否更新显示对象的变换属性。 - * 为了更好的性能, 默认并不会更新显示对象的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 - * @default false - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.transformUpdateEnabled = false; - _this._armatureDisplay = null; - _this._renderDisplay = null; - _this._colorFilter = null; - return _this; - } - EgretSlot.toString = function () { - return "[class dragonBones.EgretSlot]"; - }; - /** - * @inheritDoc - */ - EgretSlot.prototype.init = function (slotData, armatureValue, rawDisplay, meshDisplay) { - _super.prototype.init.call(this, slotData, armatureValue, rawDisplay, meshDisplay); - if (dragonBones.isV5) { - this._updateTransform = this._updateTransformV5; - } - else { - this._updateTransform = this._updateTransformV4; - } - }; - EgretSlot.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._armatureDisplay = null; // - this._renderDisplay = null; // - this._colorFilter = null; - }; - EgretSlot.prototype._initDisplay = function (value, isRetain) { - // tslint:disable-next-line:no-unused-expression - value; - // tslint:disable-next-line:no-unused-expression - isRetain; - }; - EgretSlot.prototype._disposeDisplay = function (value, isRelease) { - // tslint:disable-next-line:no-unused-expression - value; - // tslint:disable-next-line:no-unused-expression - isRelease; - }; - EgretSlot.prototype._onUpdateDisplay = function () { - this._armatureDisplay = this._armature.display; - this._renderDisplay = (this._display !== null ? this._display : this._rawDisplay); - if (dragonBones.isV5 && this._armatureDisplay._batchEnabled) { - if (this._renderDisplay === this._rawDisplay && !(this._renderDisplay.$renderNode instanceof egret.sys.BitmapNode)) { - this._renderDisplay.$renderNode = new egret.sys.BitmapNode(); // 默认是 sys.NormalBitmapNode 没有矩阵,需要替换成 egret.sys.BitmapNode。 - } - } - if (this._armatureDisplay._batchEnabled) { - if (this._renderDisplay !== this._rawDisplay && this._renderDisplay !== this._meshDisplay) { - this._armatureDisplay.disableBatch(); - } - else { - var node = this._renderDisplay.$renderNode; - if (!node.matrix) { - node.matrix = new egret.Matrix(); - } - } - } - }; - EgretSlot.prototype._addDisplay = function () { - if (this._armatureDisplay._batchEnabled) { - this._armatureDisplay.$renderNode.addNode(this._renderDisplay.$renderNode); - } - else { - this._armatureDisplay.addChild(this._renderDisplay); - } - }; - EgretSlot.prototype._replaceDisplay = function (value) { - var prevDisplay = value; - if (this._armatureDisplay._batchEnabled) { - var nodes = this._armatureDisplay.$renderNode.drawData; - nodes[nodes.indexOf(prevDisplay.$renderNode)] = this._renderDisplay.$renderNode; - } - else { - this._armatureDisplay.addChild(this._renderDisplay); - this._armatureDisplay.swapChildren(this._renderDisplay, prevDisplay); - this._armatureDisplay.removeChild(prevDisplay); - } - }; - EgretSlot.prototype._removeDisplay = function () { - if (this._armatureDisplay._batchEnabled) { - var nodes = this._armatureDisplay.$renderNode.drawData; - nodes.splice(nodes.indexOf(this._renderDisplay.$renderNode), 1); - } - else { - this._renderDisplay.parent.removeChild(this._renderDisplay); - } - }; - EgretSlot.prototype._updateZOrder = function () { - if (this._armatureDisplay._batchEnabled) { - var nodes = this._armatureDisplay.$renderNode.drawData; - nodes[this._zOrder] = this._renderDisplay.$renderNode; - } - else { - var index = this._armatureDisplay.getChildIndex(this._renderDisplay); - if (index === this._zOrder) { - return; - } - this._armatureDisplay.addChildAt(this._renderDisplay, this._zOrder); - } - }; - /** - * @internal - */ - EgretSlot.prototype._updateVisible = function () { - var visible = this._parent.visible && this._visible; - if (this._armatureDisplay._batchEnabled) { - var node = this._renderDisplay.$renderNode; - node.alpha = visible ? 1.0 : 0.0; - } - else { - this._renderDisplay.visible = visible; - } - }; - EgretSlot.prototype._updateBlendMode = function () { - switch (this._blendMode) { - case 0 /* Normal */: - this._renderDisplay.blendMode = egret.BlendMode.NORMAL; - break; - case 1 /* Add */: - this._renderDisplay.blendMode = egret.BlendMode.ADD; - break; - case 5 /* Erase */: - this._renderDisplay.blendMode = egret.BlendMode.ERASE; - break; - default: - break; - } - if (this._armatureDisplay._batchEnabled) { - var node = this._renderDisplay.$renderNode; - node.blendMode = egret.sys.blendModeToNumber(this._renderDisplay.blendMode); - } - }; - EgretSlot.prototype._updateColor = function () { - if (this._colorTransform.redMultiplier !== 1.0 || - this._colorTransform.greenMultiplier !== 1.0 || - this._colorTransform.blueMultiplier !== 1.0 || - this._colorTransform.redOffset !== 0 || - this._colorTransform.greenOffset !== 0 || - this._colorTransform.blueOffset !== 0 || - this._colorTransform.alphaOffset !== 0) { - if (this._colorFilter === null) { - this._colorFilter = new egret.ColorMatrixFilter(); - } - var colorMatrix = this._colorFilter.matrix; - colorMatrix[0] = this._colorTransform.redMultiplier; - colorMatrix[6] = this._colorTransform.greenMultiplier; - colorMatrix[12] = this._colorTransform.blueMultiplier; - colorMatrix[18] = this._colorTransform.alphaMultiplier; - colorMatrix[4] = this._colorTransform.redOffset; - colorMatrix[9] = this._colorTransform.greenOffset; - colorMatrix[14] = this._colorTransform.blueOffset; - colorMatrix[19] = this._colorTransform.alphaOffset; - this._colorFilter.matrix = colorMatrix; - if (this._armatureDisplay._batchEnabled) { - var node = this._renderDisplay.$renderNode; - node.filter = this._colorFilter; - node.alpha = 1.0; - } - var filters = this._renderDisplay.filters; - if (!filters) { - filters = []; - } - if (filters.indexOf(this._colorFilter) < 0) { - filters.push(this._colorFilter); - } - this._renderDisplay.filters = filters; - this._renderDisplay.alpha = 1.0; - } - else { - if (this._armatureDisplay._batchEnabled) { - var node = this._renderDisplay.$renderNode; - node.filter = null; - node.alpha = this._colorTransform.alphaMultiplier; - } - this._renderDisplay.filters = null; - this._renderDisplay.alpha = this._colorTransform.alphaMultiplier; - } - }; - EgretSlot.prototype._updateFrame = function () { - var currentVerticesData = (this._deformVertices !== null && this._display === this._meshDisplay) ? this._deformVertices.verticesData : null; - var currentTextureData = this._textureData; - if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { - if (this._armature.replacedTexture !== null && this._rawDisplayDatas !== null && this._rawDisplayDatas.indexOf(this._displayData) >= 0) { - var currentTextureAtlasData = currentTextureData.parent; - if (this._armature._replaceTextureAtlasData === null) { - currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.EgretTextureAtlasData); - currentTextureAtlasData.copyFrom(currentTextureData.parent); - currentTextureAtlasData.renderTexture = this._armature.replacedTexture; - this._armature._replaceTextureAtlasData = currentTextureAtlasData; - } - else { - currentTextureAtlasData = this._armature._replaceTextureAtlasData; - } - currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name); - } - if (currentTextureData.renderTexture !== null) { - if (currentVerticesData !== null) { - var data = currentVerticesData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[currentVerticesData.offset + 0 /* MeshVertexCount */]; - var triangleCount = intArray[currentVerticesData.offset + 1 /* MeshTriangleCount */]; - var vertexOffset = intArray[currentVerticesData.offset + 2 /* MeshFloatOffset */]; - if (vertexOffset < 0) { - vertexOffset += 65536; // Fixed out of bouds bug. - } - var uvOffset = vertexOffset + vertexCount * 2; - var scale = this._armature._armatureData.scale; - var meshDisplay = this._renderDisplay; - var meshNode = meshDisplay.$renderNode; - meshNode.uvs.length = vertexCount * 2; - meshNode.vertices.length = vertexCount * 2; - meshNode.indices.length = triangleCount * 3; - for (var i = 0, l = vertexCount * 2; i < l; ++i) { - meshNode.vertices[i] = floatArray[vertexOffset + i] * scale; - meshNode.uvs[i] = floatArray[uvOffset + i]; - } - for (var i = 0; i < triangleCount * 3; ++i) { - meshNode.indices[i] = intArray[currentVerticesData.offset + 4 /* MeshVertexIndices */ + i]; - } - if (this._armatureDisplay._batchEnabled) { - var texture = currentTextureData.renderTexture; - var node = this._renderDisplay.$renderNode; - egret.sys.RenderNode.prototype.cleanBeforeRender.call(node); - node.image = texture.bitmapData; - if (dragonBones.isV5) { - node.drawMesh(texture.$bitmapX, texture.$bitmapY, texture.$bitmapWidth, texture.$bitmapHeight, texture.$offsetX, texture.$offsetY, texture.textureWidth, texture.textureHeight); - node.imageWidth = texture.$sourceWidth; - node.imageHeight = texture.$sourceHeight; - } - else { - var textureV4 = texture; - node.drawMesh(textureV4._bitmapX, textureV4._bitmapY, textureV4._bitmapWidth, textureV4._bitmapHeight, textureV4._offsetX, textureV4._offsetY, textureV4.textureWidth, textureV4.textureHeight); - node.imageWidth = textureV4._sourceWidth; - node.imageHeight = textureV4._sourceHeight; - } - this._blendModeDirty = true; - this._colorDirty = true; - } - meshDisplay.texture = currentTextureData.renderTexture; - meshDisplay.anchorOffsetX = this._pivotX; - meshDisplay.anchorOffsetY = this._pivotY; - meshDisplay.$updateVertices(); - if (!dragonBones.isV5) { - meshDisplay.$invalidateTransform(); - } - var isSkinned = currentVerticesData.weight !== null; - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - if (isSkinned || isSurface) { - this._identityTransform(); - } - } - else { - var scale = currentTextureData.parent.scale * this._armature._armatureData.scale; - var textureWidth = (currentTextureData.rotated ? currentTextureData.region.height : currentTextureData.region.width) * scale; - var textureHeight = (currentTextureData.rotated ? currentTextureData.region.width : currentTextureData.region.height) * scale; - var normalDisplay_1 = this._renderDisplay; - var texture = currentTextureData.renderTexture; - normalDisplay_1.texture = texture; - if (this._armatureDisplay._batchEnabled) { - var node = this._renderDisplay.$renderNode; - egret.sys.RenderNode.prototype.cleanBeforeRender.call(node); - node.image = texture.bitmapData; - if (dragonBones.isV5) { - node.drawImage(texture.$bitmapX, texture.$bitmapY, texture.$bitmapWidth, texture.$bitmapHeight, texture.$offsetX, texture.$offsetY, textureWidth, textureHeight); - node.imageWidth = texture.$sourceWidth; - node.imageHeight = texture.$sourceHeight; - } - else { - var textureV4 = texture; - node.drawImage(textureV4._bitmapX, textureV4._bitmapY, textureV4._bitmapWidth, textureV4._bitmapHeight, textureV4._offsetX, textureV4._offsetY, textureWidth, textureHeight); - node.imageWidth = textureV4._sourceWidth; - node.imageHeight = textureV4._sourceHeight; - } - this._blendModeDirty = true; - this._colorDirty = true; - } - else { - normalDisplay_1.width = textureWidth; - normalDisplay_1.height = textureHeight; - } - normalDisplay_1.anchorOffsetX = this._pivotX; - normalDisplay_1.anchorOffsetY = this._pivotY; - } - this._visibleDirty = true; - return; - } - } - if (this._armatureDisplay._batchEnabled) { - this._renderDisplay.$renderNode.image = null; - } - var normalDisplay = this._renderDisplay; - normalDisplay.texture = null; - normalDisplay.x = 0.0; - normalDisplay.y = 0.0; - normalDisplay.visible = false; - }; - EgretSlot.prototype._updateMesh = function () { - var scale = this._armature._armatureData.scale; - var deformVertices = this._deformVertices.vertices; - var bones = this._deformVertices.bones; - var verticesData = this._deformVertices.verticesData; - var weightData = verticesData.weight; - var hasDeform = deformVertices.length > 0 && verticesData.inheritDeform; - var meshDisplay = this._renderDisplay; - var meshNode = meshDisplay.$renderNode; - if (weightData !== null) { - var data = verticesData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[verticesData.offset + 0 /* MeshVertexCount */]; - var weightFloatOffset = intArray[weightData.offset + 1 /* WeigthFloatOffset */]; - if (weightFloatOffset < 0) { - weightFloatOffset += 65536; // Fixed out of bouds bug. - } - for (var i = 0, iD = 0, iB = weightData.offset + 2 /* WeigthBoneIndices */ + bones.length, iV = weightFloatOffset, iF = 0; i < vertexCount; ++i) { - var boneCount = intArray[iB++]; - var xG = 0.0, yG = 0.0; - for (var j = 0; j < boneCount; ++j) { - var boneIndex = intArray[iB++]; - var bone = bones[boneIndex]; - if (bone !== null) { - var matrix = bone.globalTransformMatrix; - var weight = floatArray[iV++]; - var xL = floatArray[iV++] * scale; - var yL = floatArray[iV++] * scale; - if (hasDeform) { - xL += deformVertices[iF++]; - yL += deformVertices[iF++]; - } - xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; - yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; - } - } - meshNode.vertices[iD++] = xG; - meshNode.vertices[iD++] = yG; - } - meshDisplay.$updateVertices(); - if (!dragonBones.isV5) { - meshDisplay.$invalidateTransform(); - } - } - else if (hasDeform) { - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - var data = verticesData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[verticesData.offset + 0 /* MeshVertexCount */]; - var vertexOffset = intArray[verticesData.offset + 2 /* MeshFloatOffset */]; - if (vertexOffset < 0) { - vertexOffset += 65536; // Fixed out of bouds bug. - } - for (var i = 0, l = vertexCount * 2; i < l; i += 2) { - var x = floatArray[vertexOffset + i] * scale + deformVertices[i]; - var y = floatArray[vertexOffset + i + 1] * scale + deformVertices[i + 1]; - if (isSurface) { - var matrix = this._parent._getGlobalTransformMatrix(x, y); - meshNode.vertices[i] = matrix.a * x + matrix.c * y + matrix.tx; - meshNode.vertices[i + 1] = matrix.b * x + matrix.d * y + matrix.ty; - } - else { - meshNode.vertices[i] = x; - meshNode.vertices[i + 1] = y; - } - } - meshDisplay.$updateVertices(); - if (!dragonBones.isV5) { - meshDisplay.$invalidateTransform(); - } - } - if (this._armatureDisplay._batchEnabled) { - this._armatureDisplay._childDirty = true; - } - }; - /** - * @internal - */ - EgretSlot.prototype._updateGlueMesh = function () { - }; - EgretSlot.prototype._updateTransform = function () { - throw new Error(); - }; - EgretSlot.prototype._identityTransform = function () { - if (this._armatureDisplay._batchEnabled) { - this._armatureDisplay._childDirty = true; - var displayMatrix = this._renderDisplay.$renderNode.matrix; - displayMatrix.a = 1.0; - displayMatrix.b = 0.0; - displayMatrix.c = 0.0; - displayMatrix.d = 1.0; - displayMatrix.tx = 0.0; - displayMatrix.ty = 0.0; - } - else { - egret.$TempMatrix.identity(); - this._renderDisplay.$setMatrix(egret.$TempMatrix, this.transformUpdateEnabled); - } - }; - EgretSlot.prototype._updateTransformV4 = function () { - var globalTransformMatrix = this.globalTransformMatrix; - if (this._armatureDisplay._batchEnabled) { - this._armatureDisplay._childDirty = true; - var displayMatrix = this._renderDisplay.$renderNode.matrix; - displayMatrix.a = globalTransformMatrix.a; - displayMatrix.b = globalTransformMatrix.b; - displayMatrix.c = globalTransformMatrix.c; - displayMatrix.d = globalTransformMatrix.d; - displayMatrix.tx = this.globalTransformMatrix.tx - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); - displayMatrix.ty = this.globalTransformMatrix.ty - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); - } - else if (this.transformUpdateEnabled) { - this._renderDisplay.$setMatrix(globalTransformMatrix, true); - } - else { - var values = this._renderDisplay.$DisplayObject; - var displayMatrix = values[6]; - displayMatrix.a = this.globalTransformMatrix.a; - displayMatrix.b = this.globalTransformMatrix.b; - displayMatrix.c = this.globalTransformMatrix.c; - displayMatrix.d = this.globalTransformMatrix.d; - displayMatrix.tx = this.globalTransformMatrix.tx; - displayMatrix.ty = this.globalTransformMatrix.ty; - this._renderDisplay.$removeFlags(8); - this._renderDisplay.$invalidatePosition(); - } - }; - EgretSlot.prototype._updateTransformV5 = function () { - var globalTransformMatrix = this.globalTransformMatrix; - if (this._armatureDisplay._batchEnabled) { - this._armatureDisplay._childDirty = true; - var displayMatrix = this._renderDisplay.$renderNode.matrix; - displayMatrix.a = globalTransformMatrix.a; - displayMatrix.b = globalTransformMatrix.b; - displayMatrix.c = globalTransformMatrix.c; - displayMatrix.d = globalTransformMatrix.d; - displayMatrix.tx = this.globalTransformMatrix.tx - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); - displayMatrix.ty = this.globalTransformMatrix.ty - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); - } - else { - this._renderDisplay.$setMatrix(globalTransformMatrix, this.transformUpdateEnabled); - } - }; - return EgretSlot; - }(dragonBones.Slot)); - dragonBones.EgretSlot = EgretSlot; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - dragonBones.isV5 = Number(egret.Capabilities.engineVersion.substr(0, 3)) >= 5.1; - /** - * - The Egret factory. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 工厂。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var EgretFactory = /** @class */ (function (_super) { - __extends(EgretFactory, _super); - /** - * @inheritDoc - */ - function EgretFactory(dataParser) { - if (dataParser === void 0) { dataParser = null; } - var _this = _super.call(this, dataParser) || this; - if (EgretFactory._dragonBonesInstance === null) { - // - var eventManager = new dragonBones.EgretArmatureDisplay(); - EgretFactory._dragonBonesInstance = new dragonBones.DragonBones(eventManager); - EgretFactory._time = egret.getTimer() * 0.001; - egret.startTick(EgretFactory._clockHandler, EgretFactory); - } - _this._dragonBones = EgretFactory._dragonBonesInstance; - return _this; - } - EgretFactory._clockHandler = function (time) { - time *= 0.001; - var passedTime = time - this._time; - EgretFactory._dragonBonesInstance.advanceTime(passedTime); - this._time = time; - return false; - }; - Object.defineProperty(EgretFactory, "factory", { - /** - * - A global factory instance that can be used directly. - * @version DragonBones 4.7 - * @language en_US - */ - /** - * - 一个可以直接使用的全局工厂实例。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - if (EgretFactory._factory === null) { - EgretFactory._factory = new EgretFactory(); - } - return EgretFactory._factory; - }, - enumerable: true, - configurable: true - }); - EgretFactory.prototype._isSupportMesh = function () { - if (egret.Capabilities.renderMode === "webgl" || egret.Capabilities.runtimeType === egret.RuntimeType.NATIVE) { - return true; - } - console.warn("Canvas can not support mesh, please change renderMode to webgl."); - return false; - }; - EgretFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { - if (textureAtlasData !== null) { - if (textureAtlas instanceof egret.Texture) { - textureAtlasData.renderTexture = textureAtlas; - } - else { - var egretTexture = new egret.Texture(); - egretTexture.bitmapData = new egret.BitmapData(textureAtlas); - textureAtlasData.disposeEnabled = true; - textureAtlasData.renderTexture = egretTexture; - } - } - else { - textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.EgretTextureAtlasData); - } - return textureAtlasData; - }; - EgretFactory.prototype._buildArmature = function (dataPackage) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); - var armatureDisplay = new dragonBones.EgretArmatureDisplay(); - armature.init(dataPackage.armature, armatureDisplay, armatureDisplay, this._dragonBones); - return armature; - }; - EgretFactory.prototype._buildSlot = function (dataPackage, slotData, armature) { - // tslint:disable-next-line:no-unused-expression - dataPackage; - var slot = dragonBones.BaseObject.borrowObject(dragonBones.EgretSlot); - slot.init(slotData, armature, new egret.Bitmap(), new egret.Mesh()); - return slot; - }; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. - * Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. - * The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature display container. - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - *
-         *     let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
-         * 
- * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架,并用 {@link #clock} 更新该骨架。 - * 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 - * 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架的显示容器。 - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - *
-         *     let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
-         * 
- * @language zh_CN - */ - EgretFactory.prototype.buildArmatureDisplay = function (armatureName, dragonBonesName, skinName, textureAtlasName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - if (textureAtlasName === void 0) { textureAtlasName = ""; } - var armature = this.buildArmature(armatureName, dragonBonesName || "", skinName || "", textureAtlasName || ""); - if (armature !== null) { - this._dragonBones.clock.add(armature); - return armature.display; - } - return null; - }; - /** - * - Create the display object with the specified texture. - * @param textureName - The texture data name. - * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建带有指定贴图的显示对象。 - * @param textureName - 贴图数据名称。 - * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) - * @version DragonBones 3.0 - * @language zh_CN - */ - EgretFactory.prototype.getTextureDisplay = function (textureName, textureAtlasName) { - if (textureAtlasName === void 0) { textureAtlasName = null; } - var textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName); - if (textureData !== null && textureData.renderTexture !== null) { - var texture = textureData.renderTexture; - var bitmap = new egret.Bitmap(texture); - bitmap.width = texture.textureWidth * textureData.parent.scale; - bitmap.height = texture.textureHeight * textureData.parent.scale; - return bitmap; - } - return null; - }; - Object.defineProperty(EgretFactory.prototype, "soundEventManager", { - /** - * - A global sound event manager. - * Sound events can be listened to uniformly from the manager. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 全局声音事件管理器。 - * 声音事件可以从该管理器统一侦听。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._dragonBones.eventManager; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretFactory, "clock", { - /** - * - Deprecated, please refer to {@link #clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #clock}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return EgretFactory.factory.clock; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #addDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #addDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.addSkeletonData = function (dragonBonesData, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - console.warn("已废弃"); - this.addDragonBonesData(dragonBonesData, dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #getDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #getDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.getSkeletonData = function (dragonBonesName) { - console.warn("已废弃"); - return this.getDragonBonesData(dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #removeDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #removeDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.removeSkeletonData = function (dragonBonesName) { - console.warn("已废弃"); - this.removeDragonBonesData(dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #addTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #addTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.addTextureAtlas = function (textureAtlasData, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - console.warn("已废弃"); - this.addTextureAtlasData(textureAtlasData, dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #getTextureAtlas()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #getTextureAtlas()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.getTextureAtlas = function (dragonBonesName) { - console.warn("已废弃"); - return this.getTextureAtlasData(dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #removeTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #removeTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.removeTextureAtlas = function (dragonBonesName) { - console.warn("已废弃"); - this.removeTextureAtlasData(dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #buildArmature()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #buildArmature()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.buildFastArmature = function (armatureName, dragonBonesName, skinName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - console.warn("已废弃"); - return this.buildArmature(armatureName, dragonBonesName || "", skinName || ""); - }; - /** - * - Deprecated, please refer to {@link #clear()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #clear()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.dispose = function () { - console.warn("已废弃"); - this.clear(); - }; - EgretFactory._time = 0.0; - EgretFactory._dragonBonesInstance = null; - EgretFactory._factory = null; - return EgretFactory; - }(dragonBones.BaseFactory)); - dragonBones.EgretFactory = EgretFactory; -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @private - */ - var _helpRectangle = new egret.Rectangle(); - /** - * @private - */ - var _helpMatrix = new egret.Matrix(); - /** - * @private - */ - var _groupConfigMap = {}; - /** - * @private - */ - function _findObjectInArray(array, name) { - for (var i = 0, l = array.length; i < l; ++i) { - var data = array[i]; - if (data.name === name) { - return data; - } - } - return null; - } - /** - * @private - */ - function _fillCreateMovieHelper(createMovieHelper) { - if (createMovieHelper.groupName) { - var groupConfig = _groupConfigMap[createMovieHelper.groupName]; - if (groupConfig) { - var movieConfig = _findObjectInArray(groupConfig.movie || groupConfig.animation, createMovieHelper.movieName); - if (movieConfig) { - createMovieHelper.groupConfig = groupConfig; - createMovieHelper.movieConfig = movieConfig; - return true; - } - } - } - if (!createMovieHelper.groupName) { - for (var groupName in _groupConfigMap) { - var groupConfig = _groupConfigMap[groupName]; - if (!createMovieHelper.groupName) { - var movieConfig = _findObjectInArray(groupConfig.movie || groupConfig.animation, createMovieHelper.movieName); - if (movieConfig) { - createMovieHelper.groupName = groupName; - createMovieHelper.groupConfig = groupConfig; - createMovieHelper.movieConfig = movieConfig; - return true; - } - } - } - } - return false; - } - /** - * 是否包含指定名称的动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function hasMovieGroup(groupName) { - return groupName in _groupConfigMap; - } - dragonBones.hasMovieGroup = hasMovieGroup; - /** - * 添加动画组。 - * @param groupData 动画二进制数据。 - * @param textureAtlas 贴图集或贴图集列表。 - * @param groupName 为动画组指定一个名称,如果未设置,则使用数据中的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function addMovieGroup(groupData, textureAtlas, groupName) { - if (groupName === void 0) { groupName = null; } - if (groupData) { - var byteArray = new egret.ByteArray(groupData); - byteArray.endian = egret.Endian.LITTLE_ENDIAN; - byteArray.position = 8; // TODO format - var groupConfig = JSON.parse(byteArray.readUTF()); - groupConfig.offset = byteArray.position; - groupConfig.arrayBuffer = groupData; - groupConfig.textures = []; - var p = groupConfig.offset % 4; - if (p) { - groupConfig.offset += 4 - p; - } - for (var i = 0, l = groupConfig.position.length; i < l; i += 3) { - switch (i / 3) { - case 1: - groupConfig.displayFrameArray = new Int16Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); - break; - case 2: - groupConfig.rectangleArray = new Float32Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); - break; - case 3: - groupConfig.transformArray = new Float32Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); - break; - case 4: - groupConfig.colorArray = new Int16Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); - break; - } - } - groupName = groupName || groupConfig.name; - if (_groupConfigMap[groupName]) { - console.warn("Replace group: " + groupName); - } - _groupConfigMap[groupName] = groupConfig; - // - if (textureAtlas instanceof Array) { - for (var i = 0, l = textureAtlas.length; i < l; ++i) { - var texture = textureAtlas[i]; - groupConfig.textures.push(texture); - } - } - else { - groupConfig.textures.push(textureAtlas); - } - } - else { - throw new Error(); - } - } - dragonBones.addMovieGroup = addMovieGroup; - /** - * 移除动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function removeMovieGroup(groupName) { - var groupConfig = _groupConfigMap[groupName]; - if (groupConfig) { - delete _groupConfigMap[groupName]; - } - } - dragonBones.removeMovieGroup = removeMovieGroup; - /** - * 移除所有的动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function removeAllMovieGroup() { - for (var i in _groupConfigMap) { - delete _groupConfigMap[i]; - } - } - dragonBones.removeAllMovieGroup = removeAllMovieGroup; - /** - * 创建一个动画。 - * @param movieName 动画的名称。 - * @param groupName 动画组的名称,如果未设置,将检索所有的动画组,当多个动画组中包含同名的动画时,可能无法创建出准确的动画。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function buildMovie(movieName, groupName) { - if (groupName === void 0) { groupName = null; } - var createMovieHelper = { movieName: movieName, groupName: groupName }; - if (_fillCreateMovieHelper(createMovieHelper)) { - var movie = new Movie(createMovieHelper); - movie.clock = dragonBones.EgretFactory.factory.clock; - return movie; - } - else { - console.warn("No movie named: " + movieName); - } - return null; - } - dragonBones.buildMovie = buildMovie; - /** - * 获取指定动画组内包含的所有动画名称。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function getMovieNames(groupName) { - var groupConfig = _groupConfigMap[groupName]; - if (groupConfig) { - var movieNameGroup = []; - var movie = groupConfig.movie || groupConfig.animation; - for (var i = 0, l = movie.length; i < l; ++i) { - movieNameGroup.push(movie[i].name); - } - return movieNameGroup; - } - else { - console.warn("No group named: " + groupName); - } - return null; - } - dragonBones.getMovieNames = getMovieNames; - /** - * 动画事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - var MovieEvent = /** @class */ (function (_super) { - __extends(MovieEvent, _super); - /** - * @private - */ - function MovieEvent(type) { - var _this = _super.call(this, type) || this; - /** - * 事件名称。 (帧标签的名称或声音的名称) - * @version DragonBones 4.7 - * @language zh_CN - */ - _this.name = ""; - /** - * 发出事件的插槽名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - _this.slotName = ""; - /** - * 发出事件的动画剪辑名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - _this.clipName = ""; - return _this; - } - Object.defineProperty(MovieEvent.prototype, "armature", { - //========================================= // 兼容旧数据 - /** - * @private - */ - get: function () { - return this.movie; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieEvent.prototype, "bone", { - /** - * @private - */ - get: function () { - return null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieEvent.prototype, "animationState", { - /** - * @private - */ - get: function () { - return { name: this.clipName }; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieEvent.prototype, "frameLabel", { - /** - * @private - */ - get: function () { - return this.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieEvent.prototype, "movementID", { - /** - * @private - */ - get: function () { - return this.clipName; - }, - enumerable: true, - configurable: true - }); - /** - * 动画剪辑开始播放。 - * @version DragonBones 4.7 - * @language zh_CN - */ - MovieEvent.START = "start"; - /** - * 动画剪辑循环播放一次完成。 - * @version DragonBones 4.7 - * @language zh_CN - */ - MovieEvent.LOOP_COMPLETE = "loopComplete"; - /** - * 动画剪辑播放完成。 - * @version DragonBones 4.7 - * @language zh_CN - */ - MovieEvent.COMPLETE = "complete"; - /** - * 动画剪辑帧事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - MovieEvent.FRAME_EVENT = "frameEvent"; - /** - * 动画剪辑声音事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - MovieEvent.SOUND_EVENT = "soundEvent"; - return MovieEvent; - }(egret.Event)); - dragonBones.MovieEvent = MovieEvent; - /** - * @private - */ - var MovieSlot = /** @class */ (function (_super) { - __extends(MovieSlot, _super); - function MovieSlot(slotConfig) { - var _this = _super.call(this) || this; - _this.displayIndex = -1; - _this.colorIndex = -1; - _this.transformIndex = -1; - _this.rawDisplay = new egret.Bitmap(); - _this.childMovies = {}; - _this.displayConfig = null; - _this.childMovie = null; - _this.colorFilter = null; - _this.display = _this.rawDisplay; - _this.config = slotConfig; - _this.rawDisplay.name = _this.config.name; - if (!_this.config.blendMode) { - _this.config.blendMode = 0 /* Normal */; - } - return _this; - } - MovieSlot.prototype.dispose = function () { - this.rawDisplay = null; - this.childMovies = null; - this.config = null; - this.displayConfig = null; - this.display = null; - this.childMovie = null; - this.colorFilter = null; - }; - return MovieSlot; - }(egret.HashObject)); - /** - * 通过读取缓存的二进制动画数据来更新动画,具有良好的运行性能,同时对内存的占用也非常低。 - * @see dragonBones.buildMovie - * @version DragonBones 4.7 - * @language zh_CN - */ - var Movie = /** @class */ (function (_super) { - __extends(Movie, _super); - function Movie(createMovieHelper) { - var _this = _super.call(this) || this; - /** - * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1 - * @version DragonBones 4.7 - * @language zh_CN - */ - _this.timeScale = 1; - /** - * 动画剪辑的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * (当再次播放其他动画剪辑时,此值将被重置为 1) - * @default 1 - * @version DragonBones 4.7 - * @language zh_CN - */ - _this.clipTimeScale = 1; - _this._batchEnabled = true; - _this._isLockDispose = false; - _this._isDelayDispose = false; - _this._isStarted = false; - _this._isPlaying = false; - _this._isReversing = false; - _this._isCompleted = false; - _this._playTimes = 0; - _this._time = 0; - _this._currentTime = 0; - _this._currentPlayTimes = 0; - _this._cacheFrameIndex = 0; - _this._frameSize = 0; - _this._cacheRectangle = null; - _this._clock = null; - _this._currentFrameConfig = null; - _this._clipNames = []; - _this._slots = []; - _this._childMovies = []; - _this._groupConfig = createMovieHelper.groupConfig; - _this._config = createMovieHelper.movieConfig; - _this._batchEnabled = !(_this._config.isNested || _this._config.hasChildAnimation); - if (_this._batchEnabled) { - _this.$renderNode = new egret.sys.GroupNode(); - _this.$renderNode.cleanBeforeRender = Movie._cleanBeforeRender; - } - _this._clipNames.length = 0; - for (var i = 0, l = _this._config.clip.length; i < l; ++i) { - _this._clipNames.push(_this._config.clip[i].name); - } - for (var i = 0, l = _this._config.slot.length; i < l; ++i) { - var slot = new MovieSlot(_this._config.slot[i]); - _this._updateSlotBlendMode(slot); - _this._slots.push(slot); - if (_this._batchEnabled) { - _this.$renderNode.addNode(slot.rawDisplay.$renderNode); - } - else { - _this.addChild(slot.rawDisplay); - } - } - _this._frameSize = (1 + 1) * _this._slots.length; // displayFrame, transformFrame. - _this.name = _this._config.name; - _this.play(); - _this.advanceTime(0.000001); - _this.stop(); - return _this; - } - Movie._cleanBeforeRender = function () { }; - Movie.prototype._configToEvent = function (config, event) { - event.movie = this; - event.clipName = this._clipConfig.name; - event.name = config.name; - event.slotName = config.slot || ""; - }; - Movie.prototype._onCrossFrame = function (frameConfig) { - for (var i = 0, l = frameConfig.actionAndEvent.length; i < l; ++i) { - var actionAndEvent = frameConfig.actionAndEvent[i]; - if (actionAndEvent) { - switch (actionAndEvent.type) { - case 11 /* Sound */: - if (dragonBones.EgretFactory.factory.soundEventManager.hasEventListener(MovieEvent.SOUND_EVENT)) { - var event_1 = egret.Event.create(MovieEvent, MovieEvent.SOUND_EVENT); - this._configToEvent(actionAndEvent, event_1); - dragonBones.EgretFactory.factory.soundEventManager.dispatchEvent(event_1); - egret.Event.release(event_1); - } - break; - case 10 /* Frame */: - if (this.hasEventListener(MovieEvent.FRAME_EVENT)) { - var event_2 = egret.Event.create(MovieEvent, MovieEvent.FRAME_EVENT); - this._configToEvent(actionAndEvent, event_2); - this.dispatchEvent(event_2); - egret.Event.release(event_2); - } - break; - case 0 /* Play */: - if (actionAndEvent.slot) { - var slot = this._getSlot(actionAndEvent.slot); - if (slot && slot.childMovie) { - slot.childMovie.play(actionAndEvent.name); - } - } - else { - this.play(actionAndEvent.name); - } - break; - } - } - } - }; - Movie.prototype._updateSlotBlendMode = function (slot) { - var blendMode = ""; - switch (slot.config.blendMode) { - case 0 /* Normal */: - blendMode = egret.BlendMode.NORMAL; - break; - case 1 /* Add */: - blendMode = egret.BlendMode.ADD; - break; - case 5 /* Erase */: - blendMode = egret.BlendMode.ERASE; - break; - default: - break; - } - if (blendMode) { - if (this._batchEnabled) { - // RenderNode display. - slot.display.$renderNode.blendMode = egret.sys.blendModeToNumber(blendMode); - } - else { - // Classic display. - slot.display.blendMode = blendMode; - } - } - }; - Movie.prototype._updateSlotColor = function (slot, aM, rM, gM, bM, aO, rO, gO, bO) { - if (rM !== 1 || - gM !== 1 || - bM !== 1 || - rO !== 0 || - gO !== 0 || - bO !== 0 || - aO !== 0) { - if (!slot.colorFilter) { - slot.colorFilter = new egret.ColorMatrixFilter(); - } - var colorMatrix = slot.colorFilter.matrix; - colorMatrix[0] = rM; - colorMatrix[6] = gM; - colorMatrix[12] = bM; - colorMatrix[18] = aM; - colorMatrix[4] = rO; - colorMatrix[9] = gO; - colorMatrix[14] = bO; - colorMatrix[19] = aO; - slot.colorFilter.matrix = colorMatrix; - if (this._batchEnabled) { - // RenderNode display. - slot.display.$renderNode.filter = slot.colorFilter; - slot.display.$renderNode.alpha = 1.0; - } - else { - // Classic display. - var filters = slot.display.filters; - if (!filters) { - filters = []; - } - if (filters.indexOf(slot.colorFilter) < 0) { - filters.push(slot.colorFilter); - } - slot.display.filters = filters; - slot.display.$setAlpha(1.0); - } - } - else { - if (slot.colorFilter) { - slot.colorFilter = null; - } - if (this._batchEnabled) { - // RenderNode display. - slot.display.$renderNode.filter = null; - slot.display.$renderNode.alpha = aM; - } - else { - // Classic display. - slot.display.filters = null; - slot.display.$setAlpha(aM); - } - } - }; - Movie.prototype._updateSlotDisplay = function (slot) { - var prevDisplay = slot.display || slot.rawDisplay; - var prevChildMovie = slot.childMovie; - if (slot.displayIndex >= 0) { - slot.displayConfig = this._groupConfig.display[slot.displayIndex]; - if (slot.displayConfig.type === 1 /* Armature */) { - var childMovie = slot.displayConfig.name in slot.childMovies ? slot.childMovies[slot.displayConfig.name] : null; - if (!childMovie) { - childMovie = buildMovie(slot.displayConfig.name, this._groupConfig.name); - if (childMovie) { - slot.childMovies[slot.displayConfig.name] = childMovie; - } - } - if (childMovie) { - slot.display = childMovie; - slot.childMovie = childMovie; - } - else { - slot.display = slot.rawDisplay; - slot.childMovie = null; - } - } - else { - slot.display = slot.rawDisplay; - slot.childMovie = null; - } - } - else { - slot.displayConfig = null; - slot.display = slot.rawDisplay; - slot.childMovie = null; - } - if (slot.display !== prevDisplay) { - if (prevDisplay) { - this.addChild(slot.display); - this.swapChildren(slot.display, prevDisplay); - this.removeChild(prevDisplay); - } - // Update blendMode. - this._updateSlotBlendMode(slot); - } - // Update frame. - if (slot.display === slot.rawDisplay) { - if (slot.displayConfig && slot.displayConfig.regionIndex !== null && slot.displayConfig.regionIndex !== undefined) { - if (!slot.displayConfig.texture) { - var textureAtlasTexture = this._groupConfig.textures[slot.displayConfig.textureIndex || 0]; - var regionIndex = slot.displayConfig.regionIndex * 4; - var x = this._groupConfig.rectangleArray[regionIndex]; - var y = this._groupConfig.rectangleArray[regionIndex + 1]; - var width = this._groupConfig.rectangleArray[regionIndex + 2]; - var height = this._groupConfig.rectangleArray[regionIndex + 3]; - slot.displayConfig.texture = new egret.Texture(); - slot.displayConfig.texture.bitmapData = textureAtlasTexture.bitmapData; - slot.displayConfig.texture.$initData(x, y, Math.min(width, textureAtlasTexture.textureWidth - x), Math.min(height, textureAtlasTexture.textureHeight - y), 0, 0, Math.min(width, textureAtlasTexture.textureWidth - x), Math.min(height, textureAtlasTexture.textureHeight - y), textureAtlasTexture.textureWidth, textureAtlasTexture.textureHeight); - } - if (this._batchEnabled) { - // RenderNode display. - var texture = slot.displayConfig.texture; - var bitmapNode = slot.rawDisplay.$renderNode; - egret.sys.RenderNode.prototype.cleanBeforeRender.call(slot.rawDisplay.$renderNode); - bitmapNode.image = texture.bitmapData; - if (dragonBones.isV5) { - bitmapNode.drawImage(texture.$bitmapX, texture.$bitmapY, texture.$bitmapWidth, texture.$bitmapHeight, texture.$offsetX, texture.$offsetY, texture.textureWidth, texture.textureHeight); - bitmapNode.imageWidth = texture._sourceWidth; - bitmapNode.imageHeight = texture._sourceHeight; - } - else { - var textureV4 = texture; - bitmapNode.drawImage(textureV4._bitmapX, textureV4._bitmapY, textureV4._bitmapWidth, textureV4._bitmapHeight, textureV4._offsetX, textureV4._offsetY, texture.textureWidth, texture.textureHeight); - bitmapNode.imageWidth = textureV4._sourceWidth; - bitmapNode.imageHeight = textureV4._sourceHeight; - } - } - else { - // Classic display. - slot.rawDisplay.visible = true; - slot.rawDisplay.$setBitmapData(slot.displayConfig.texture); - } - } - else { - if (this._batchEnabled) { - // RenderNode display. - slot.rawDisplay.$renderNode.image = null; - } - else { - // Classic display. - slot.rawDisplay.visible = false; - slot.rawDisplay.$setBitmapData(null); - } - } - } - // Update child movie. - if (slot.childMovie !== prevChildMovie) { - if (prevChildMovie) { - prevChildMovie.stop(); - this._childMovies.slice(this._childMovies.indexOf(prevChildMovie), 1); - } - if (slot.childMovie) { - if (this._childMovies.indexOf(slot.childMovie) < 0) { - this._childMovies.push(slot.childMovie); - } - if (slot.config.action) { - slot.childMovie.play(slot.config.action); - } - else { - slot.childMovie.play(slot.childMovie._config.action); - } - } - } - }; - Movie.prototype._getSlot = function (name) { - for (var i = 0, l = this._slots.length; i < l; ++i) { - var slot = this._slots[i]; - if (slot.config.name === name) { - return slot; - } - } - return null; - }; - /** - * @inheritDoc - */ - Movie.prototype.$render = function () { - if (this._batchEnabled) { - // RenderNode display. - } - else { - // Classic display. - _super.prototype.$render.call(this); - } - }; - /** - * @inheritDoc - */ - Movie.prototype.$updateRenderNode = function () { - if (this._batchEnabled) { - // RenderNode display. - } - else { - // Classic display. - _super.prototype.$updateRenderNode.call(this); - } - }; - /** - * @inheritDoc - */ - Movie.prototype.$measureContentBounds = function (bounds) { - if (this._batchEnabled && this._cacheRectangle) { - // RenderNode display. - bounds.setTo(this._cacheRectangle.x, this._cacheRectangle.y, this._cacheRectangle.width - this._cacheRectangle.x, this._cacheRectangle.height - this._cacheRectangle.y); - } - else { - // Classic display. - _super.prototype.$measureContentBounds.call(this, bounds); - } - }; - /** - * @inheritDoc - */ - Movie.prototype.$doAddChild = function (child, index, notifyListeners) { - if (this._batchEnabled) { - // RenderNode display. - console.warn("Can not add child."); - return null; - } - // Classic display. - return _super.prototype.$doAddChild.call(this, child, index, notifyListeners); - }; - /** - * @inheritDoc - */ - Movie.prototype.$doRemoveChild = function (index, notifyListeners) { - if (this._batchEnabled) { - // RenderNode display. - console.warn("Can not remove child."); - return null; - } - // Classic display. - return _super.prototype.$doRemoveChild.call(this, index, notifyListeners); - }; - /** - * 释放动画。 - * @version DragonBones 3.0 - * @language zh_CN - */ - Movie.prototype.dispose = function () { - if (this._isLockDispose) { - this._isDelayDispose = true; - } - else { - if (this._clock) { - this._clock.remove(this); - } - if (this._slots) { - for (var i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i].dispose(); - } - } - this._isPlaying = false; - this._cacheRectangle = null; - this._clock = null; - this._groupConfig = null; - this._config = null; - this._clipConfig = null; - this._currentFrameConfig = null; - this._clipArray = null; - this._clipNames = null; - this._slots = null; - this._childMovies = null; - } - }; - /** - * @inheritDoc - */ - Movie.prototype.advanceTime = function (passedTime) { - if (this._isPlaying) { - this._isLockDispose = true; - if (passedTime < 0) { - passedTime = -passedTime; - } - passedTime *= this.timeScale; - this._time += passedTime * this.clipTimeScale; - // Modify time. - var duration = this._clipConfig.duration; - var totalTime = duration * this._playTimes; - var currentTime = this._time; - var currentPlayTimes = this._currentPlayTimes; - if (this._playTimes > 0 && (currentTime >= totalTime || currentTime <= -totalTime)) { - this._isCompleted = true; - currentPlayTimes = this._playTimes; - if (currentTime < 0) { - currentTime = 0; - } - else { - currentTime = duration; - } - } - else { - this._isCompleted = false; - if (currentTime < 0) { - currentPlayTimes = Math.floor(-currentTime / duration); - currentTime = duration - (-currentTime % duration); - } - else { - currentPlayTimes = Math.floor(currentTime / duration); - currentTime %= duration; - } - if (this._playTimes > 0 && currentPlayTimes > this._playTimes) { - currentPlayTimes = this._playTimes; - } - } - if (this._currentTime === currentTime) { - return; - } - var cacheFrameIndex = Math.floor(currentTime * this._clipConfig.cacheTimeToFrameScale); - if (this._cacheFrameIndex !== cacheFrameIndex) { - this._cacheFrameIndex = cacheFrameIndex; - var displayFrameArray = this._groupConfig.displayFrameArray; - var transformArray = this._groupConfig.transformArray; - var colorArray = this._groupConfig.colorArray; - // - var isFirst = true; - var hasDisplay = false; - var needCacheRectangle = false; - var prevCacheRectangle = this._cacheRectangle; - this._cacheRectangle = this._clipConfig.cacheRectangles[this._cacheFrameIndex]; - if (this._batchEnabled && !this._cacheRectangle) { - needCacheRectangle = true; - this._cacheRectangle = new egret.Rectangle(); - this._clipConfig.cacheRectangles[this._cacheFrameIndex] = this._cacheRectangle; - } - // Update slots. - for (var i = 0, l = this._slots.length; i < l; ++i) { - var slot = this._slots[i]; - var clipFrameIndex = this._frameSize * this._cacheFrameIndex + i * 2; - if (clipFrameIndex >= this._clipArray.length) { - clipFrameIndex = this._frameSize * (this._cacheFrameIndex - 1) + i * 2; - } - var displayFrameIndex = this._clipArray[clipFrameIndex] * 2; - if (displayFrameIndex >= 0) { - var displayIndex = displayFrameArray[displayFrameIndex]; - var colorIndex = displayFrameArray[displayFrameIndex + 1] * 8; - var transformIndex = this._clipArray[clipFrameIndex + 1] * 6; - var colorChange = false; - if (slot.displayIndex !== displayIndex) { - slot.displayIndex = displayIndex; - colorChange = true; - this._updateSlotDisplay(slot); - } - if (slot.colorIndex !== colorIndex || colorChange) { - slot.colorIndex = colorIndex; - if (slot.colorIndex >= 0) { - this._updateSlotColor(slot, colorArray[colorIndex] * 0.01, colorArray[colorIndex + 1] * 0.01, colorArray[colorIndex + 2] * 0.01, colorArray[colorIndex + 3] * 0.01, colorArray[colorIndex + 4], colorArray[colorIndex + 5], colorArray[colorIndex + 6], colorArray[colorIndex + 7]); - } - else { - this._updateSlotColor(slot, 1, 1, 1, 1, 0, 0, 0, 0); - } - } - hasDisplay = true; - if (slot.transformIndex !== transformIndex) { - slot.transformIndex = transformIndex; - if (this._batchEnabled) { - // RenderNode display. - var matrix = slot.display.$renderNode.matrix; - if (!matrix) { - matrix = slot.display.$renderNode.matrix = new egret.Matrix(); - } - matrix.a = transformArray[transformIndex]; - matrix.b = transformArray[transformIndex + 1]; - matrix.c = transformArray[transformIndex + 2]; - matrix.d = transformArray[transformIndex + 3]; - matrix.tx = transformArray[transformIndex + 4]; - matrix.ty = transformArray[transformIndex + 5]; - } - else { - // Classic display. - _helpMatrix.a = transformArray[transformIndex]; - _helpMatrix.b = transformArray[transformIndex + 1]; - _helpMatrix.c = transformArray[transformIndex + 2]; - _helpMatrix.d = transformArray[transformIndex + 3]; - _helpMatrix.tx = transformArray[transformIndex + 4]; - _helpMatrix.ty = transformArray[transformIndex + 5]; - slot.display.$setMatrix(_helpMatrix); - } - } - // - if (this._batchEnabled && needCacheRectangle && slot.displayConfig) { - // RenderNode display. - var matrix = slot.display.$renderNode.matrix; - _helpRectangle.x = 0; - _helpRectangle.y = 0; - _helpRectangle.width = slot.displayConfig.texture.textureWidth; - _helpRectangle.height = slot.displayConfig.texture.textureHeight; - matrix.$transformBounds(_helpRectangle); - if (isFirst) { - isFirst = false; - this._cacheRectangle.x = _helpRectangle.x; - this._cacheRectangle.width = _helpRectangle.x + _helpRectangle.width; - this._cacheRectangle.y = _helpRectangle.y; - this._cacheRectangle.height = _helpRectangle.y + _helpRectangle.height; - } - else { - this._cacheRectangle.x = Math.min(this._cacheRectangle.x, _helpRectangle.x); - this._cacheRectangle.width = Math.max(this._cacheRectangle.width, _helpRectangle.x + _helpRectangle.width); - this._cacheRectangle.y = Math.min(this._cacheRectangle.y, _helpRectangle.y); - this._cacheRectangle.height = Math.max(this._cacheRectangle.height, _helpRectangle.y + _helpRectangle.height); - } - } - } - else if (slot.displayIndex !== -1) { - slot.displayIndex = -1; - this._updateSlotDisplay(slot); - } - } - // - if (this._cacheRectangle) { - if (hasDisplay && needCacheRectangle && isFirst && prevCacheRectangle) { - this._cacheRectangle.x = prevCacheRectangle.x; - this._cacheRectangle.y = prevCacheRectangle.y; - this._cacheRectangle.width = prevCacheRectangle.width; - this._cacheRectangle.height = prevCacheRectangle.height; - } - if (!dragonBones.isV5) { - this.$invalidateContentBounds(); - } - } - } - if (this._isCompleted) { - this._isPlaying = false; - } - if (!this._isStarted) { - this._isStarted = true; - if (this.hasEventListener(MovieEvent.START)) { - var event_3 = egret.Event.create(MovieEvent, MovieEvent.START); - event_3.movie = this; - event_3.clipName = this._clipConfig.name; - event_3.name = ""; - event_3.slotName = ""; - this.dispatchEvent(event_3); - } - } - this._isReversing = this._currentTime > currentTime && this._currentPlayTimes === currentPlayTimes; - this._currentTime = currentTime; - // Action and event. - var frameCount = this._clipConfig.frame ? this._clipConfig.frame.length : 0; - if (frameCount > 0) { - var currentFrameIndex = Math.floor(this._currentTime * this._config.frameRate); - var currentFrameConfig = this._groupConfig.frame[this._clipConfig.frame[currentFrameIndex]]; - if (this._currentFrameConfig !== currentFrameConfig) { - if (frameCount > 1) { - var crossedFrameConfig = this._currentFrameConfig; - this._currentFrameConfig = currentFrameConfig; - if (!crossedFrameConfig) { - var prevFrameIndex = Math.floor(this._currentTime * this._config.frameRate); - crossedFrameConfig = this._groupConfig.frame[this._clipConfig.frame[prevFrameIndex]]; - if (this._isReversing) { - } - else { - if (this._currentTime <= crossedFrameConfig.position || - this._currentPlayTimes !== currentPlayTimes) { - crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.prev]; - } - } - } - if (this._isReversing) { - while (crossedFrameConfig !== currentFrameConfig) { - this._onCrossFrame(crossedFrameConfig); - crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.prev]; - } - } - else { - while (crossedFrameConfig !== currentFrameConfig) { - crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.next]; - this._onCrossFrame(crossedFrameConfig); - } - } - } - else { - this._currentFrameConfig = currentFrameConfig; - if (this._currentFrameConfig) { - this._onCrossFrame(this._currentFrameConfig); - } - } - } - } - if (this._currentPlayTimes !== currentPlayTimes) { - this._currentPlayTimes = currentPlayTimes; - if (this.hasEventListener(MovieEvent.LOOP_COMPLETE)) { - var event_4 = egret.Event.create(MovieEvent, MovieEvent.LOOP_COMPLETE); - event_4.movie = this; - event_4.clipName = this._clipConfig.name; - event_4.name = ""; - event_4.slotName = ""; - this.dispatchEvent(event_4); - egret.Event.release(event_4); - } - if (this._isCompleted && this.hasEventListener(MovieEvent.COMPLETE)) { - var event_5 = egret.Event.create(MovieEvent, MovieEvent.COMPLETE); - event_5.movie = this; - event_5.clipName = this._clipConfig.name; - event_5.name = ""; - event_5.slotName = ""; - this.dispatchEvent(event_5); - egret.Event.release(event_5); - } - } - } - this._isLockDispose = false; - if (this._isDelayDispose) { - this.dispose(); - } - }; - /** - * 播放动画剪辑。 - * @param clipName 动画剪辑的名称,如果未设置,则播放默认动画剪辑,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画剪辑。 - * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 4.7 - * @language zh_CN - */ - Movie.prototype.play = function (clipName, playTimes) { - if (clipName === void 0) { clipName = null; } - if (playTimes === void 0) { playTimes = -1; } - if (clipName) { - var clipConfig = null; - for (var i = 0, l = this._config.clip.length; i < l; ++i) { - var data = this._config.clip[i]; - if (data.name === clipName) { - clipConfig = data; - } - } - if (clipConfig) { - this._clipConfig = clipConfig; - this._clipArray = new Int16Array(this._groupConfig.arrayBuffer, this._groupConfig.offset + this._groupConfig.position[0] + this._clipConfig.p, this._clipConfig.s / this._groupConfig.position[2]); - if (!this._clipConfig.cacheRectangles) { - this._clipConfig.cacheRectangles = []; - } - this._isPlaying = true; - this._isStarted = false; - this._isCompleted = false; - if (playTimes < 0 || playTimes !== playTimes) { - this._playTimes = this._clipConfig.playTimes; - } - else { - this._playTimes = playTimes; - } - this._time = 0; - this._currentTime = 0; - this._currentPlayTimes = 0; - this._cacheFrameIndex = -1; - this._currentFrameConfig = null; - this._cacheRectangle = null; - this.clipTimeScale = 1 / this._clipConfig.scale; - } - else { - console.warn("No clip in movie.", this._config.name, clipName); - } - } - else if (this._clipConfig) { - if (this._isPlaying || this._isCompleted) { - this.play(this._clipConfig.name, this._playTimes); - } - else { - this._isPlaying = true; - } - // playTimes - } - else if (this._config.action) { - this.play(this._config.action, playTimes); - } - }; - /** - * 暂停播放动画。 - * @version DragonBones 4.7 - * @language zh_CN - */ - Movie.prototype.stop = function () { - this._isPlaying = false; - }; - /** - * 从指定时间播放动画。 - * @param clipName 动画剪辑的名称。 - * @param time 指定时间。(以秒为单位) - * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 5.0 - * @language zh_CN - */ - Movie.prototype.gotoAndPlay = function (clipName, time, playTimes) { - if (clipName === void 0) { clipName = null; } - if (playTimes === void 0) { playTimes = -1; } - time %= this._clipConfig.duration; - if (time < 0) { - time += this._clipConfig.duration; - } - this.play(clipName, playTimes); - this._time = time; - this._currentTime = time; - }; - /** - * 将动画停止到指定时间。 - * @param clipName 动画剪辑的名称。 - * @param time 指定时间。(以秒为单位) - * @version DragonBones 5.0 - * @language zh_CN - */ - Movie.prototype.gotoAndStop = function (clipName, time) { - if (clipName === void 0) { clipName = null; } - time %= this._clipConfig.duration; - if (time < 0) { - time += this._clipConfig.duration; - } - this.play(clipName, 1); - this._time = time; - this._currentTime = time; - this.advanceTime(0.001); - this.stop(); - }; - /** - * 是否包含指定动画剪辑。 - * @param clipName 动画剪辑的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - Movie.prototype.hasClip = function (clipName) { - for (var i = 0, l = this._config.clip.length; i < l; ++i) { - var clip = this._config.clip[i]; - if (clip.name === clipName) { - return true; - } - } - return false; - }; - Object.defineProperty(Movie.prototype, "isPlaying", { - /** - * 动画剪辑是否处正在播放。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._isPlaying && !this._isCompleted; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "isComplete", { - /** - * 动画剪辑是否均播放完毕。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._isCompleted; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "currentTime", { - /** - * 当前动画剪辑的播放时间。 (以秒为单位) - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._currentTime; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "totalTime", { - /** - * 当前动画剪辑的总时间。 (以秒为单位) - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._clipConfig ? this._clipConfig.duration : 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "currentPlayTimes", { - /** - * 当前动画剪辑的播放次数。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._currentPlayTimes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "playTimes", { - /** - * 当前动画剪辑需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._playTimes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "groupName", { - get: function () { - return this._groupConfig.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "clipName", { - /** - * 正在播放的动画剪辑名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._clipConfig ? this._clipConfig.name : ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "clipNames", { - /** - * 所有动画剪辑的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._clipNames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - var prevClock = this._clock; - if (prevClock) { - prevClock.remove(this); - } - this._clock = value; - if (this._clock) { - this._clock.add(this); - } - }, - enumerable: true, - configurable: true - }); - /** - * 已废弃,请参考 {@link dragonBones.Movie#clock} {@link dragonBones.Movie#clock} {@link dragonBones.EgretFactory#clock}。 - * @deprecated - * @language zh_CN - */ - Movie.prototype.advanceTimeBySelf = function (on) { - if (on) { - this.clock = dragonBones.EgretFactory.clock; - } - else { - this.clock = null; - } - }; - Object.defineProperty(Movie.prototype, "display", { - //========================================= // 兼容旧数据 - /** - * @private - */ - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "animation", { - /** - * @private - */ - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "armature", { - /** - * @private - */ - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - Movie.prototype.getAnimation = function () { - return this; - }; - /** - * @private - */ - Movie.prototype.getArmature = function () { - return this; - }; - /** - * @private - */ - Movie.prototype.getDisplay = function () { - return this; - }; - /** - * @private - */ - Movie.prototype.hasAnimation = function (name) { - return this.hasClip(name); - }; - /** - * @private - */ - Movie.prototype.invalidUpdate = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - // tslint:disable-next-line:no-unused-expression - args; - }; - Object.defineProperty(Movie.prototype, "lastAnimationName", { - /** - * @private - */ - get: function () { - return this.clipName; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "animationNames", { - /** - * @private - */ - get: function () { - return this.clipNames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "animationList", { - /** - * @private - */ - get: function () { - return this.clipNames; - }, - enumerable: true, - configurable: true - }); - return Movie; - }(egret.DisplayObjectContainer)); - dragonBones.Movie = Movie; -})(dragonBones || (dragonBones = {})); diff --git a/demo/libs/modules/dragonBones/dragonBones.min.js b/demo/libs/modules/dragonBones/dragonBones.min.js deleted file mode 100644 index bfd59c17..00000000 --- a/demo/libs/modules/dragonBones/dragonBones.min.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var a in e)if(e.hasOwnProperty(a))t[a]=e[a]};return function(e,a){t(e,a);function r(){this.constructor=e}e.prototype=a===null?Object.create(a):(r.prototype=a.prototype,new r)}}();var dragonBones;(function(t){})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function e(a){this._clock=new t.WorldClock;this._events=[];this._objects=[];this._eventManager=null;this._eventManager=a;console.info("DragonBones: "+e.VERSION+"\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/")}e.prototype.advanceTime=function(e){if(this._objects.length>0){for(var a=0,r=this._objects;a0){for(var n=0;na){i.length=a}t._maxCountMap[r]=a}else{t._defaultMaxCount=a;for(var r in t._poolsMap){var i=t._poolsMap[r];if(i.length>a){i.length=a}if(r in t._maxCountMap){t._maxCountMap[r]=a}}}};t.clearPool=function(e){if(e===void 0){e=null}if(e!==null){var a=String(e);var r=a in t._poolsMap?t._poolsMap[a]:null;if(r!==null&&r.length>0){r.length=0}}else{for(var i in t._poolsMap){var r=t._poolsMap[i];r.length=0}}};t.borrowObject=function(e){var a=String(e);var r=a in t._poolsMap?t._poolsMap[a]:null;if(r!==null&&r.length>0){var i=r.pop();i._isInPool=false;return i}var n=new e;n._onClear();return n};t.prototype.returnToPool=function(){this._onClear();t._returnObject(this)};t._hashCode=0;t._defaultMaxCount=3e3;t._maxCountMap={};t._poolsMap={};return t}();t.BaseObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n){if(t===void 0){t=1}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}this.a=t;this.b=e;this.c=a;this.d=r;this.tx=i;this.ty=n}t.prototype.toString=function(){return"[object dragonBones.Matrix] a:"+this.a+" b:"+this.b+" c:"+this.c+" d:"+this.d+" tx:"+this.tx+" ty:"+this.ty};t.prototype.copyFrom=function(t){this.a=t.a;this.b=t.b;this.c=t.c;this.d=t.d;this.tx=t.tx;this.ty=t.ty;return this};t.prototype.copyFromArray=function(t,e){if(e===void 0){e=0}this.a=t[e];this.b=t[e+1];this.c=t[e+2];this.d=t[e+3];this.tx=t[e+4];this.ty=t[e+5];return this};t.prototype.identity=function(){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this};t.prototype.concat=function(t){var e=this.a*t.a;var a=0;var r=0;var i=this.d*t.d;var n=this.tx*t.a+t.tx;var s=this.ty*t.d+t.ty;if(this.b!==0||this.c!==0){e+=this.b*t.c;a+=this.b*t.d;r+=this.c*t.a;i+=this.c*t.b}if(t.b!==0||t.c!==0){a+=this.a*t.b;r+=this.d*t.c;n+=this.ty*t.c;s+=this.tx*t.b}this.a=e;this.b=a;this.c=r;this.d=i;this.tx=n;this.ty=s;return this};t.prototype.invert=function(){var t=this.a;var e=this.b;var a=this.c;var r=this.d;var i=this.tx;var n=this.ty;if(e===0&&a===0){this.b=this.c=0;if(t===0||r===0){this.a=this.b=this.tx=this.ty=0}else{t=this.a=1/t;r=this.d=1/r;this.tx=-t*i;this.ty=-r*n}return this}var s=t*r-e*a;if(s===0){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this}s=1/s;var o=this.a=r*s;e=this.b=-e*s;a=this.c=-a*s;r=this.d=t*s;this.tx=-(o*i+a*n);this.ty=-(e*i+r*n);return this};t.prototype.transformPoint=function(t,e,a,r){if(r===void 0){r=false}a.x=this.a*t+this.c*e;a.y=this.b*t+this.d*e;if(!r){a.x+=this.tx;a.y+=this.ty}};t.prototype.transformRectangle=function(t,e){if(e===void 0){e=false}var a=this.a;var r=this.b;var i=this.c;var n=this.d;var s=e?0:this.tx;var o=e?0:this.ty;var l=t.x;var h=t.y;var f=l+t.width;var u=h+t.height;var _=a*l+i*h+s;var c=r*l+n*h+o;var p=a*f+i*h+s;var m=r*f+n*h+o;var d=a*f+i*u+s;var v=r*f+n*u+o;var y=a*l+i*u+s;var g=r*l+n*u+o;var b=0;if(_>p){b=_;_=p;p=b}if(d>y){b=d;d=y;y=b}t.x=Math.floor(_y?p:y)-t.x);if(c>m){b=c;c=m;m=b}if(v>g){b=v;v=g;g=b}t.y=Math.floor(cg?m:g)-t.y)};return t}();t.Matrix=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}if(i===void 0){i=1}if(n===void 0){n=1}this.x=t;this.y=e;this.skew=a;this.rotation=r;this.scaleX=i;this.scaleY=n}t.normalizeRadian=function(t){t=(t+Math.PI)%(Math.PI*2);t+=t>0?-Math.PI:Math.PI;return t};t.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+this.skew*180/Math.PI+" skewY:"+this.rotation*180/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY};t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.skew=t.skew;this.rotation=t.rotation;this.scaleX=t.scaleX;this.scaleY=t.scaleY;return this};t.prototype.identity=function(){this.x=this.y=0;this.skew=this.rotation=0;this.scaleX=this.scaleY=1;return this};t.prototype.add=function(t){this.x+=t.x;this.y+=t.y;this.skew+=t.skew;this.rotation+=t.rotation;this.scaleX*=t.scaleX;this.scaleY*=t.scaleY;return this};t.prototype.minus=function(t){this.x-=t.x;this.y-=t.y;this.skew-=t.skew;this.rotation-=t.rotation;this.scaleX/=t.scaleX;this.scaleY/=t.scaleY;return this};t.prototype.fromMatrix=function(e){var a=this.scaleX,r=this.scaleY;var i=t.PI_Q;this.x=e.tx;this.y=e.ty;this.rotation=Math.atan(e.b/e.a);var n=Math.atan(-e.c/e.d);this.scaleX=this.rotation>-i&&this.rotation-i&&n=0&&this.scaleX<0){this.scaleX=-this.scaleX;this.rotation=this.rotation-Math.PI}if(r>=0&&this.scaleY<0){this.scaleY=-this.scaleY;n=n-Math.PI}this.skew=n-this.rotation;return this};t.prototype.toMatrix=function(t){if(this.rotation===0){t.a=1;t.b=0}else{t.a=Math.cos(this.rotation);t.b=Math.sin(this.rotation)}if(this.skew===0){t.c=-t.b;t.d=t.a}else{t.c=-Math.sin(this.skew+this.rotation);t.d=Math.cos(this.skew+this.rotation)}if(this.scaleX!==1){t.a*=this.scaleX;t.b*=this.scaleX}if(this.scaleY!==1){t.c*=this.scaleY;t.d*=this.scaleY}t.tx=this.x;t.ty=this.y;return this};t.PI=Math.PI;t.PI_D=Math.PI*2;t.PI_H=Math.PI/2;t.PI_Q=Math.PI/4;t.RAD_DEG=180/Math.PI;t.DEG_RAD=Math.PI/180;return t}();t.Transform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n,s,o){if(t===void 0){t=1}if(e===void 0){e=1}if(a===void 0){a=1}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}if(s===void 0){s=0}if(o===void 0){o=0}this.alphaMultiplier=t;this.redMultiplier=e;this.greenMultiplier=a;this.blueMultiplier=r;this.alphaOffset=i;this.redOffset=n;this.greenOffset=s;this.blueOffset=o}t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier;this.redMultiplier=t.redMultiplier;this.greenMultiplier=t.greenMultiplier;this.blueMultiplier=t.blueMultiplier;this.alphaOffset=t.alphaOffset;this.redOffset=t.redOffset;this.greenOffset=t.greenOffset;this.blueOffset=t.blueOffset};t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1;this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0};return t}();t.ColorTransform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e){if(t===void 0){t=0}if(e===void 0){e=0}this.x=t;this.y=e}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y};t.prototype.clear=function(){this.x=this.y=0};return t}();t.Point=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}this.x=t;this.y=e;this.width=a;this.height=r}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.width=t.width;this.height=t.height};t.prototype.clear=function(){this.x=this.y=0;this.width=this.height=0};return t}();t.Rectangle=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.ints=[];e.floats=[];e.strings=[];return e}e.toString=function(){return"[class dragonBones.UserData]"};e.prototype._onClear=function(){this.ints.length=0;this.floats.length=0;this.strings.length=0};e.prototype.addInt=function(t){this.ints.push(t)};e.prototype.addFloat=function(t){this.floats.push(t)};e.prototype.addString=function(t){this.strings.push(t)};e.prototype.getInt=function(t){if(t===void 0){t=0}return t>=0&&t=0&&t=0&&t=t){a=0}if(this.sortedBones.indexOf(i)>=0){continue}var n=false;for(var s in this.constraints){var o=this.constraints[s];if(o.root===i&&this.sortedBones.indexOf(o.target)<0){n=true;break}}if(n){continue}if(i.parent!==null&&this.sortedBones.indexOf(i.parent)<0){continue}this.sortedBones.push(i);r++}};a.prototype.cacheFrames=function(t){if(this.cacheFrameRate>0){return}this.cacheFrameRate=t;for(var e in this.animations){this.animations[e].cacheFrames(this.cacheFrameRate)}};a.prototype.setCacheFrame=function(t,e){var a=this.parent.cachedFrames;var r=a.length;a.length+=10;a[r]=t.a;a[r+1]=t.b;a[r+2]=t.c;a[r+3]=t.d;a[r+4]=t.tx;a[r+5]=t.ty;a[r+6]=e.rotation;a[r+7]=e.skew;a[r+8]=e.scaleX;a[r+9]=e.scaleY;return r};a.prototype.getCacheFrame=function(t,e,a){var r=this.parent.cachedFrames;t.a=r[a];t.b=r[a+1];t.c=r[a+2];t.d=r[a+3];t.tx=r[a+4];t.ty=r[a+5];e.rotation=r[a+6];e.skew=r[a+7];e.scaleX=r[a+8];e.scaleY=r[a+9];e.x=t.tx;e.y=t.ty};a.prototype.addBone=function(t){if(t.name in this.bones){console.warn("Same bone: "+t.name);return}this.bones[t.name]=t;this.sortedBones.push(t)};a.prototype.addSlot=function(t){if(t.name in this.slots){console.warn("Same slot: "+t.name);return}this.slots[t.name]=t;this.sortedSlots.push(t)};a.prototype.addConstraint=function(t){if(t.name in this.constraints){console.warn("Same constraint: "+t.name);return}this.constraints[t.name]=t};a.prototype.addSkin=function(t){if(t.name in this.skins){console.warn("Same skin: "+t.name);return}t.parent=this;this.skins[t.name]=t;if(this.defaultSkin===null){this.defaultSkin=t}if(t.name==="default"){this.defaultSkin=t}};a.prototype.addAnimation=function(t){if(t.name in this.animations){console.warn("Same animation: "+t.name);return}t.parent=this;this.animations[t.name]=t;this.animationNames.push(t.name);if(this.defaultAnimation===null){this.defaultAnimation=t}};a.prototype.addAction=function(t,e){if(e){this.defaultActions.push(t)}else{this.actions.push(t)}};a.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null};a.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null};a.prototype.getConstraint=function(t){return t in this.constraints?this.constraints[t]:null};a.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null};a.prototype.getMesh=function(t,e,a){var r=this.getSkin(t);if(r===null){return null}return r.getDisplay(e,a)};a.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null};return a}(t.BaseObject);t.ArmatureData=e;var a=function(e){__extends(a,e);function a(){var a=e!==null&&e.apply(this,arguments)||this;a.transform=new t.Transform;a.userData=null;return a}a.toString=function(){return"[class dragonBones.BoneData]"};a.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.inheritTranslation=false;this.inheritRotation=false;this.inheritScale=false;this.inheritReflection=false;this.type=0;this.length=0;this.name="";this.transform.identity();this.userData=null;this.parent=null};return a}(t.BaseObject);t.BoneData=a;var r=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.vertices=[];return e}e.toString=function(){return"[class dragonBones.SurfaceData]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1;this.segmentX=0;this.segmentY=0;this.vertices.length=0};return e}(a);t.SurfaceData=r;var i=function(e){__extends(a,e);function a(){var t=e!==null&&e.apply(this,arguments)||this;t.color=null;t.userData=null;return t}a.createColor=function(){return new t.ColorTransform};a.toString=function(){return"[class dragonBones.SlotData]"};a.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.blendMode=0;this.displayIndex=0;this.zOrder=0;this.name="";this.color=null;this.userData=null;this.parent=null};a.DEFAULT_COLOR=new t.ColorTransform;return a}(t.BaseObject);t.SlotData=i})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.CanvasData]"};e.prototype._onClear=function(){this.hasBackground=false;this.color=0;this.x=0;this.y=0;this.width=0;this.height=0};return e}(t.BaseObject);t.CanvasData=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.displays={};return e}e.toString=function(){return"[class dragonBones.SkinData]"};e.prototype._onClear=function(){for(var t in this.displays){var e=this.displays[t];for(var a=0,r=e;ai){s|=2}if(en){s|=8}return s};e.rectangleIntersectsSegment=function(t,a,r,i,n,s,o,l,h,f,u){if(h===void 0){h=null}if(f===void 0){f=null}if(u===void 0){u=null}var _=t>n&&ts&&an&&rs&&i=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){return true}}return false};e.prototype.intersectsSegment=function(t,a,r,i,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=this.width*.5;var h=this.height*.5;var f=e.rectangleIntersectsSegment(t,a,r,i,-l,-h,l,h,n,s,o);return f};return e}(e);t.RectangleBoundingBoxData=a;var r=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.EllipseData]"};e.ellipseIntersectsSegment=function(t,e,a,r,i,n,s,o,l,h,f){if(l===void 0){l=null}if(h===void 0){h=null}if(f===void 0){f=null}var u=s/o;var _=u*u;e*=u;r*=u;var c=a-t;var p=r-e;var m=Math.sqrt(c*c+p*p);var d=c/m;var v=p/m;var y=(i-t)*d+(n-e)*v;var g=y*y;var b=t*t+e*e;var D=s*s;var T=D-b+g;var A=0;if(T>=0){var x=Math.sqrt(T);var P=y-x;var O=y+x;var S=P<0?-1:P<=m?0:1;var E=O<0?-1:O<=m?0:1;var M=S*E;if(M<0){return-1}else if(M===0){if(S===-1){A=2;a=t+O*d;r=(e+O*v)/u;if(l!==null){l.x=a;l.y=r}if(h!==null){h.x=a;h.y=r}if(f!==null){f.x=Math.atan2(r/D*_,a/D);f.y=f.x+Math.PI}}else if(E===1){A=1;t=t+P*d;e=(e+P*v)/u;if(l!==null){l.x=t;l.y=e}if(h!==null){h.x=t;h.y=e}if(f!==null){f.x=Math.atan2(e/D*_,t/D);f.y=f.x+Math.PI}}else{A=3;if(l!==null){l.x=t+P*d;l.y=(e+P*v)/u;if(f!==null){f.x=Math.atan2(l.y/D*_,l.x/D)}}if(h!==null){h.x=t+O*d;h.y=(e+O*v)/u;if(f!==null){f.y=Math.atan2(h.y/D*_,h.x/D)}}}}}return A};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1};e.prototype.containsPoint=function(t,e){var a=this.width*.5;if(t>=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){e*=a/r;return Math.sqrt(t*t+e*e)<=a}}return false};e.prototype.intersectsSegment=function(t,a,r,i,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=e.ellipseIntersectsSegment(t,a,r,i,0,0,this.width*.5,this.height*.5,n,s,o);return l};return e}(e);t.EllipseBoundingBoxData=r;var i=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.vertices=[];return e}e.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"};e.polygonIntersectsSegment=function(t,e,a,r,i,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}if(t===a){t=a+1e-6}if(e===r){e=r+1e-6}var l=i.length;var h=t-a;var f=e-r;var u=t*r-e*a;var _=0;var c=i[l-2];var p=i[l-1];var m=0;var d=0;var v=0;var y=0;var g=0;var b=0;for(var D=0;D=c&&E<=T||E>=T&&E<=c)&&(h===0||E>=t&&E<=a||E>=a&&E<=t)){var M=(u*P-f*O)/S;if((M>=p&&M<=A||M>=A&&M<=p)&&(f===0||M>=e&&M<=r||M>=r&&M<=e)){if(s!==null){var B=E-t;if(B<0){B=-B}if(_===0){m=B;d=B;v=E;y=M;g=E;b=M;if(o!==null){o.x=Math.atan2(A-p,T-c)-Math.PI*.5;o.y=o.x}}else{if(Bd){d=B;g=E;b=M;if(o!==null){o.y=Math.atan2(A-p,T-c)-Math.PI*.5}}}_++}else{v=E;y=M;g=E;b=M;_++;if(o!==null){o.x=Math.atan2(A-p,T-c)-Math.PI*.5;o.y=o.x}break}}}c=T;p=A}if(_===1){if(n!==null){n.x=v;n.y=y}if(s!==null){s.x=v;s.y=y}if(o!==null){o.y=o.x+Math.PI}}else if(_>1){_++;if(n!==null){n.x=v;n.y=y}if(s!==null){s.x=g;s.y=b}}return _};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=2;this.x=0;this.y=0;this.vertices.length=0};e.prototype.containsPoint=function(t,e){var a=false;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height){for(var r=0,i=this.vertices.length,n=i-2;r=e||s=e){var l=this.vertices[n];var h=this.vertices[r];if((e-o)*(l-h)/(s-o)+h0){return}this.cacheFrameRate=Math.max(Math.ceil(t*this.scale),1);var e=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=e;for(var a=0,r=this.cacheFrames.length;a=0};e.prototype.addBoneMask=function(t,e,a){if(a===void 0){a=true}var r=t.getBone(e);if(r===null){return}if(this.boneMask.indexOf(e)<0){this.boneMask.push(e)}if(a){for(var i=0,n=t.getBones();i=0){this.boneMask.splice(r,1)}if(a){var i=t.getBone(e);if(i!==null){if(this.boneMask.length>0){for(var n=0,s=t.getBones();n=0&&i.contains(o)){this.boneMask.splice(l,1)}}}else{for(var h=0,f=t.getBones();he._zOrder?1:-1};a.prototype._onClear=function(){if(this._clock!==null){this._clock.remove(this)}for(var t=0,e=this._bones;t=n){continue}var o=a[s];var l=this.getSlot(o.name);if(l!==null){l._setZorder(i)}}this._slotsDirty=true;this._zOrderDirty=!r}};a.prototype._addBone=function(t){if(this._bones.indexOf(t)<0){this._bones.push(t)}};a.prototype._addSlot=function(t){if(this._slots.indexOf(t)<0){this._slots.push(t)}};a.prototype._addConstraint=function(t){if(this._constraints.indexOf(t)<0){this._constraints.push(t)}};a.prototype._bufferAction=function(t,e){if(this._actions.indexOf(t)<0){if(e){this._actions.push(t)}else{this._actions.unshift(t)}}};a.prototype.dispose=function(){if(this._armatureData!==null){this._lockUpdate=true;this._dragonBones.bufferObject(this)}};a.prototype.init=function(e,a,r,i){if(this._armatureData!==null){return}this._armatureData=e;this._animation=t.BaseObject.borrowObject(t.Animation);this._proxy=a;this._display=r;this._dragonBones=i;this._proxy.dbInit(this);this._animation.init(this);this._animation.animations=this._armatureData.animations};a.prototype.advanceTime=function(t){if(this._lockUpdate){return}if(this._armatureData===null){console.warn("The armature has been disposed.");return}else if(this._armatureData.parent===null){console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear().");return}var e=this._cacheFrameIndex;this._animation.advanceTime(t);if(this._slotsDirty){this._slotsDirty=false;this._slots.sort(a._onSortSlots)}if(this._cacheFrameIndex<0||this._cacheFrameIndex!==e){var r=0,i=0;for(r=0,i=this._bones.length;r0){this._lockUpdate=true;for(var n=0,s=this._actions;n0){var a=this.getBone(t);if(a!==null){a.invalidUpdate();if(e){for(var r=0,i=this._slots;r0){if(i!==null||n!==null){if(i!==null){var T=o?i.y-e:i.x-t;if(T<0){T=-T}if(d===null||Th){h=T;_=n.x;c=n.y;v=b;if(s!==null){m=s.y}}}}else{d=b;break}}}if(d!==null&&i!==null){i.x=f;i.y=u;if(s!==null){s.x=p}}if(v!==null&&n!==null){n.x=_;n.y=c;if(s!==null){s.y=m}}return d};a.prototype.getBone=function(t){for(var e=0,a=this._bones;e=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else{if(this._hasConstraint){for(var a=0,r=this._armature._constraints;a=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var n=0,s=this._armature._constraints;n=0;if(this._localDirty){this._updateGlobalTransformMatrix(o)}if(o&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};a.prototype.updateByConstraint=function(){if(this._localDirty){this._localDirty=false;if(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty){this._updateGlobalTransformMatrix(true)}this._transformDirty=true}};a.prototype.invalidUpdate=function(){this._transformDirty=true};a.prototype.contains=function(t){if(t===this){return false}var e=t;while(e!==this&&e!==null){e=e.parent}return e===this};Object.defineProperty(a.prototype,"boneData",{get:function(){return this._boneData},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;for(var e=0,a=this._armature.getSlots();e=n){return this.globalTransformMatrix}i=a>this._kX*(t+n)+d;p=((o*(l+1)+o*2+l+c)*2+(i?1:0))*7;if(this._matrixCahce[p]>0){y.copyFromArray(v,p+1)}else{var g=c*(h+2);var b=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[2]-(l-c)*b;var A=this._hullCache[3]-(l-c)*D;var x=this._vertices;if(i){this._getAffineTransform(-n,d+u,r-n,u,x[g+h+2],x[g+h+3],T+b,A+D,x[g],x[g+1],e._helpTransform,y,true)}else{this._getAffineTransform(-r,d,r-n,u,T,A,x[g],x[g+1],T+b,A+D,e._helpTransform,y,false)}v[p]=1;v[p+1]=y.a;v[p+2]=y.b;v[p+3]=y.c;v[p+4]=y.d;v[p+5]=y.tx;v[p+6]=y.ty}}else if(t>=n){if(a<-n||a>=n){return this.globalTransformMatrix}i=a>this._kX*(t-r)+d;p=((o*(l+1)+o+c)*2+(i?1:0))*7;if(this._matrixCahce[p]>0){y.copyFromArray(v,p+1)}else{var g=(c+1)*(h+2)-2;var b=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[0]+c*b;var A=this._hullCache[1]+c*D;var x=this._vertices;if(i){this._getAffineTransform(r,d+u,r-n,u,T+b,A+D,x[g+h+2],x[g+h+3],T,A,e._helpTransform,y,true)}else{this._getAffineTransform(n,d,r-n,u,x[g],x[g+1],T,A,x[g+h+2],x[g+h+3],e._helpTransform,y,false)}v[p]=1;v[p+1]=y.a;v[p+2]=y.b;v[p+3]=y.c;v[p+4]=y.d;v[p+5]=y.tx;v[p+6]=y.ty}}else if(a<-n){if(t<-n||t>=n){return this.globalTransformMatrix}i=a>this._kY*(t-m-f)-r;p=(o*(l+1)+_*2+(i?1:0))*7;if(this._matrixCahce[p]>0){y.copyFromArray(v,p+1)}else{var g=_*2;var b=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[8]+_*b;var A=this._hullCache[9]+_*D;var x=this._vertices;if(i){this._getAffineTransform(m+f,-n,f,r-n,x[g+2],x[g+3],x[g],x[g+1],T+b,A+D,e._helpTransform,y,true)}else{this._getAffineTransform(m,-r,f,r-n,T,A,T+b,A+D,x[g],x[g+1],e._helpTransform,y,false)}v[p]=1;v[p+1]=y.a;v[p+2]=y.b;v[p+3]=y.c;v[p+4]=y.d;v[p+5]=y.tx;v[p+6]=y.ty}}else if(a>=n){if(t<-n||t>=n){return this.globalTransformMatrix}i=a>this._kY*(t-m-f)+n;p=((o*(l+1)+o+l+c)*2+(i?1:0))*7;if(this._matrixCahce[p]>0){y.copyFromArray(v,p+1)}else{var g=l*(h+2)+_*2;var b=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[6]-(o-_)*b;var A=this._hullCache[7]-(o-_)*D;var x=this._vertices;if(i){this._getAffineTransform(m+f,r,f,r-n,T+b,A+D,T,A,x[g+2],x[g+3],e._helpTransform,y,true)}else{this._getAffineTransform(m,n,f,r-n,x[g],x[g+1],x[g+2],x[g+3],T,A,e._helpTransform,y,false)}v[p]=1;v[p+1]=y.a;v[p+2]=y.b;v[p+3]=y.c;v[p+4]=y.d;v[p+5]=y.tx;v[p+6]=y.ty}}else{i=a>this._k*(t-m-f)+d;p=((o*c+_)*2+(i?1:0))*7;if(this._matrixCahce[p]>0){y.copyFromArray(v,p+1)}else{var g=_*2+c*(h+2);var x=this._vertices;if(i){this._getAffineTransform(m+f,d+u,f,u,x[g+h+4],x[g+h+5],x[g+h+2],x[g+h+3],x[g+2],x[g+3],e._helpTransform,y,true)}else{this._getAffineTransform(m,d,f,u,x[g],x[g+1],x[g+2],x[g+3],x[g+h+2],x[g+h+3],e._helpTransform,y,false)}v[p]=1;v[p+1]=y.a;v[p+2]=y.b;v[p+3]=y.c;v[p+4]=y.d;v[p+5]=y.tx;v[p+6]=y.ty}}return y};e.prototype.init=function(e,a){if(this._boneData!==null){return}t.prototype.init.call(this,e,a);var r=e.segmentX;var i=e.segmentY;var n=e.vertices.length;var s=1e3;var o=200;this._dX=o*2/r;this._dY=o*2/i;this._k=-this._dY/this._dX;this._kX=-this._dY/(s-o);this._kY=-(s-o)/this._dX;this._vertices.length=n;this._deformVertices.length=n;this._matrixCahce.length=(r*i+r*2+i*2)*2*7;this._hullCache.length=10;for(var l=0;l=0&&this._cachedFrameIndices!==null){var a=this._cachedFrameIndices[t];if(a>=0&&this._cachedFrameIndex===a){this._transformDirty=false}else if(a>=0){this._transformDirty=true;this._cachedFrameIndex=a}else{if(this._hasConstraint){for(var r=0,i=this._armature._constraints;r=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var s=0,o=this._armature._constraints;s=0;if(this._localDirty){this._updateGlobalTransformMatrix(f)}if(f&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}var u=1e3;var _=200;var c=2*this.global.x;var p=2*this.global.y;var m=e._helpPoint;this.globalTransformMatrix.transformPoint(u,-_,m);this._hullCache[0]=m.x;this._hullCache[1]=m.y;this._hullCache[2]=c-m.x;this._hullCache[3]=p-m.y;this.globalTransformMatrix.transformPoint(0,this._dY,m,true);this._hullCache[4]=m.x;this._hullCache[5]=m.y;this.globalTransformMatrix.transformPoint(_,u,m);this._hullCache[6]=m.x;this._hullCache[7]=m.y;this._hullCache[8]=c-m.x;this._hullCache[9]=p-m.y;this.globalTransformMatrix.transformPoint(this._dX,0,m,true);this._hullCache[10]=m.x;this._hullCache[11]=m.y}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};return e}(t.Bone);t.Surface=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(a,e);function a(){var a=e!==null&&e.apply(this,arguments)||this;a._localMatrix=new t.Matrix;a._colorTransform=new t.ColorTransform;a._displayDatas=[];a._displayList=[];a._deformVertices=null;a._rawDisplay=null;a._meshDisplay=null;return a}a.prototype._onClear=function(){e.prototype._onClear.call(this);var a=[];for(var r=0,i=this._displayList;r=0){if(this._rawDisplayDatas!==null){n=this._displayIndex=0&&this._displayIndex=0&&this._rawDisplayDatas!==null){var s=this._displayIndex0){for(var o=0,l=n;o0){if(this._displayList.length!==e.length){this._displayList.length=e.length}for(var a=0,r=e.length;a0){this._displayList.length=0}if(this._displayIndex>=0&&this._displayIndex=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else if(this._transformDirty||this._parent._childrenTransformDirty){this._transformDirty=true;this._cachedFrameIndex=-1}else if(this._cachedFrameIndex>=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}else if(this._transformDirty||this._parent._childrenTransformDirty){t=-1;this._transformDirty=true;this._cachedFrameIndex=-1}if(this._display===null){return}if(this._visibleDirty){this._visibleDirty=false;this._updateVisible()}if(this._blendModeDirty){this._blendModeDirty=false;this._updateBlendMode()}if(this._colorDirty){this._colorDirty=false;this._updateColor()}if(this._deformVertices!==null&&this._deformVertices.verticesData!==null&&this._display===this._meshDisplay){var a=this._deformVertices.verticesData.weight!==null;var r=this._parent._boneData.type!==0;if(this._deformVertices.verticesDirty||a&&this._deformVertices.isBonesUpdate()||r&&this._parent._childrenTransformDirty){this._deformVertices.verticesDirty=false;this._updateMesh()}if(a||r){return}}if(this._transformDirty){this._transformDirty=false;if(this._cachedFrameIndex<0){var i=t>=0;this._updateGlobalTransformMatrix(i);if(i&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}this._updateTransform()}};a.prototype.updateTransformAndMatrix=function(){if(this._transformDirty){this._transformDirty=false;this._updateGlobalTransformMatrix(false)}};a.prototype.replaceDisplayData=function(t,e){if(e===void 0){e=-1}if(e<0){if(this._displayIndex<0){e=0}else{e=this._displayIndex}}if(this._displayDatas.length<=e){this._displayDatas.length=e+1;for(var a=0,r=this._displayDatas.length;a0){if(l===1||l===2){if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n);if(s!==null){s.x=n.x;s.y=n.y}}else if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}else{if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}if(o!==null){this.globalTransformMatrix.transformPoint(Math.cos(o.x),Math.sin(o.x),a._helpPoint,true);o.x=Math.atan2(a._helpPoint.y,a._helpPoint.x);this.globalTransformMatrix.transformPoint(Math.cos(o.y),Math.sin(o.y),a._helpPoint,true);o.y=Math.atan2(a._helpPoint.y,a._helpPoint.x)}}return l};a.prototype.invalidUpdate=function(){this._displayDirty=true;this._transformDirty=true};Object.defineProperty(a.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;this._updateVisible()},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){if(this._setDisplayIndex(t)){this.update(-1)}},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"name",{get:function(){return this._slotData.name},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var a=this._displayList.concat();var r=new Array;if(this._setDisplayList(e)){this.update(-1)}for(var i=0,n=a;id){continue}var T=0;for(;;b++){var A=v[b];if(m>A){continue}if(b===0){T=m/A}else{var x=v[b-1];T=(m-x)/(A-x)}break}if(b!==p){p=b;if(f&&b===c){this._computeVertices(_-4,4,0,u);this._computeVertices(0,4,4,u)}else{this._computeVertices(b*6+2,8,0,u)}}this.addCurvePosition(T,u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],l,g,a)}return}if(f){_+=2;u.length=o;this._computeVertices(2,_-4,0,u);this._computeVertices(0,2,_-4,u);u[_-2]=u[0];u[_-1]=u[1]}else{c--;_-=4;u.length=_;this._computeVertices(2,_,0,u)}var P=new Array(c);d=0;var O=u[0],S=u[1],E=0,M=0,B=0,C=0,w=0,I=0;var F,N,R,k,j,L,V,U;for(var y=0,Y=2;yd){continue}for(;;b++){var W=P[b];if(G>W)continue;if(b===0)G/=W;else{var z=P[b-1];G=(G-z)/(W-z)}break}if(b!==p){p=b;var K=b*6;O=u[K];S=u[K+1];E=u[K+2];M=u[K+3];B=u[K+4];C=u[K+5];w=u[K+6];I=u[K+7];F=(O-E*2+B)*.03;N=(S-M*2+C)*.03;R=((E-B)*3-O+w)*.006;k=((M-C)*3-S+I)*.006;j=F*2+R;L=N*2+k;V=(E-O)*.3+F+R*.16666667;U=(M-S)*.3+N+k*.16666667;H=Math.sqrt(V*V+U*U);X[0]=H;for(K=1;K<8;K++){V+=j;U+=L;j+=R;L+=k;H+=Math.sqrt(V*V+U*U);X[K]=H}V+=j;U+=L;H+=Math.sqrt(V*V+U*U);X[8]=H;V+=j+R;U+=L+k;H+=Math.sqrt(V*V+U*U);X[9]=H;$=0}G*=H;for(;;$++){var Z=X[$];if(G>Z)continue;if($===0)G/=Z;else{var z=X[$-1];G=$+(G-z)/(Z-z)}break}this.addCurvePosition(G*.1,O,S,E,M,B,C,w,I,l,g,a)}};a.prototype.addCurvePosition=function(t,e,a,r,i,n,s,o,l,h,f,u){if(t===0){h[f]=e;h[f+1]=a;h[f+2]=0;return}if(t===1){h[f]=o;h[f+1]=l;h[f+2]=0;return}var _=1-t;var c=_*_;var p=t*t;var m=c*_;var d=c*t*3;var v=_*p*3;var y=t*p;var g=m*e+d*r+v*n+y*o;var b=m*a+d*i+v*s+y*l;h[f]=g;h[f+1]=b;if(u){h[f+2]=Math.atan2(b-(m*a+d*i+v*s),g-(m*e+d*r+v*n))}else{h[f+2]=0}};a.prototype.init=function(t,e){this._constraintData=t;this._armature=e;var a=t;this.pathOffset=a.pathDisplayData.vertices.offset;this.position=a.position;this.spacing=a.spacing;this.rotateOffset=a.rotateOffset;this.rotateMix=a.rotateMix;this.translateMix=a.translateMix;this._root=this._armature.getBone(a.root.name);this._target=this._armature.getBone(a.target.name);this._pathSlot=this._armature.getSlot(a.pathSlot.name);for(var r=0,i=a.bones.length;r0?t.Transform.DEG_RAD:-t.Transform.DEG_RAD}}var B=this.rotateMix;var C=this.translateMix;for(var v=0,w=3;v0){var k=D.a,j=D.b,L=D.c,V=D.d,U=void 0,Y=void 0,X=void 0;if(_){U=P[w-1]}else{U=Math.atan2(F,I)}U-=Math.atan2(j,k);if(M){Y=Math.cos(U);X=Math.sin(U);var H=g._boneData.length;S+=(H*(Y*k-X*j)-I)*B;E+=(H*(X*k+Y*j)-F)*B}else{U+=O}if(U>t.Transform.PI){U-=t.Transform.PI_D}else if(U<-t.Transform.PI){U+=t.Transform.PI_D}U*=B;Y=Math.cos(U);X=Math.sin(U);D.a=Y*k-X*j;D.b=X*k+Y*j;D.c=Y*L-X*V;D.d=X*L+Y*V}g.global.fromMatrix(D)}this.dirty=false};a.prototype.invalidUpdate=function(){};return a}(e);t.PathConstraint=r})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t){if(t===void 0){t=0}this.time=0;this.timeScale=1;this._systemTime=0;this._animatebles=[];this._clock=null;this.time=t;this._systemTime=(new Date).getTime()*.001}t.prototype.advanceTime=function(t){if(t!==t){t=0}var e=Date.now()*.001;if(t<0){t=e-this._systemTime}this._systemTime=e;if(this.timeScale!==1){t*=this.timeScale}if(t===0){return}if(t<0){this.time-=t}else{this.time+=t}var a=0,r=0,i=this._animatebles.length;for(;a0){this._animatebles[a-r]=n;this._animatebles[a]=null}n.advanceTime(t)}else{r++}}if(r>0){i=this._animatebles.length;for(;a=0){this._animatebles[e]=null;t.clock=null}};t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&a._subFadeState>0){this._armature._dragonBones.bufferObject(a);this._animationStates.length=0;this._lastAnimationState=null}else{var r=a._animationData;var i=r.cacheFrameRate;if(this._animationDirty&&i>0){this._animationDirty=false;for(var n=0,s=this._armature.getBones();n0){var _=u[0];if(_!==null){if(_.parent===this._armature.armatureData.defaultSkin){f._cachedFrameIndices=r.getSlotCachedFrameIndices(f.name);continue}}}f._cachedFrameIndices=null}}a.advanceTime(t,i)}}else if(e>1){for(var c=0,p=0;c0&&a._subFadeState>0){p++;this._armature._dragonBones.bufferObject(a);this._animationDirty=true;if(this._lastAnimationState===a){this._lastAnimationState=null}}else{if(p>0){this._animationStates[c-p]=a}a.advanceTime(t,0)}if(c===e-1&&p>0){this._animationStates.length-=p;if(this._lastAnimationState===null&&this._animationStates.length>0){this._lastAnimationState=this._animationStates[this._animationStates.length-1]}}}this._armature._cacheFrameIndex=-1}else{this._armature._cacheFrameIndex=-1}};a.prototype.reset=function(){for(var t=0,e=this._animationStates;t1){if(e.position<0){e.position%=r.duration;e.position=r.duration-e.position}else if(e.position===r.duration){e.position-=1e-6}else if(e.position>r.duration){e.position%=r.duration}if(e.duration>0&&e.position+e.duration>r.duration){e.duration=r.duration-e.position}if(e.playTimes<0){e.playTimes=r.playTimes}}else{e.playTimes=1;e.position=0;if(e.duration>0){e.duration=0}}if(e.duration===0){e.duration=-1}this._fadeOut(e);var o=t.BaseObject.borrowObject(t.AnimationState);o.init(this._armature,r,e);this._animationDirty=true;this._armature._cacheFrameIndex=-1;if(this._animationStates.length>0){var l=false;for(var h=0,f=this._animationStates.length;hthis._animationStates[h].layer){l=true;this._animationStates.splice(h,0,o);break}else if(h!==f-1&&o.layer>this._animationStates[h+1].layer){l=true;this._animationStates.splice(h+1,0,o);break}}if(!l){this._animationStates.push(o)}}else{this._animationStates.push(o)}for(var u=0,_=this._armature.getSlots();u<_.length;u++){var c=_[u];var p=c.childArmature;if(p!==null&&p.inheritAnimation&&p.animation.hasAnimation(a)&&p.animation.getState(a)===null){p.animation.fadeIn(a)}}var m=false;for(var d in r.animationTimelines){if(!this._lockUpdate){m=true;this._lockUpdate=true}var v=this.fadeIn(d,e.fadeInTime,1,o.layer,null,0);if(v!==null){v.resetToPose=false;v._parent=o;v.stop()}}if(m){this._lockUpdate=false}if(!this._lockUpdate){if(e.fadeInTime<=0){this._armature.advanceTime(0)}this._lastAnimationState=o}return o};a.prototype.play=function(t,e){if(t===void 0){t=null}if(e===void 0){e=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t!==null?t:"";if(t!==null&&t.length>0){this.playConfig(this._animationConfig)}else if(this._lastAnimationState===null){var a=this._armature.armatureData.defaultAnimation;if(a!==null){this._animationConfig.animation=a.name;this.playConfig(this._animationConfig)}}else if(!this._lastAnimationState.isPlaying&&!this._lastAnimationState.isCompleted){this._lastAnimationState.play()}else{this._animationConfig.animation=this._lastAnimationState.name;this.playConfig(this._animationConfig)}return this._lastAnimationState};a.prototype.fadeIn=function(t,e,a,r,i,n){if(e===void 0){e=-1}if(a===void 0){a=-1}if(r===void 0){r=0}if(i===void 0){i=null}if(n===void 0){n=3}this._animationConfig.clear();this._animationConfig.fadeOutMode=n;this._animationConfig.playTimes=a;this._animationConfig.layer=r;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=i!==null?i:"";return this.playConfig(this._animationConfig)};a.prototype.gotoAndPlayByTime=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.position=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;return this.playConfig(this._animationConfig)};a.prototype.gotoAndPlayByFrame=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.duration*e/r.frameCount}return this.playConfig(this._animationConfig)};a.prototype.gotoAndPlayByProgress=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.duration*(e>0?e:0)}return this.playConfig(this._animationConfig)};a.prototype.gotoAndStopByTime=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByTime(t,e,1);if(a!==null){a.stop()}return a};a.prototype.gotoAndStopByFrame=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByFrame(t,e,1);if(a!==null){a.stop()}return a};a.prototype.gotoAndStopByProgress=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByProgress(t,e,1);if(a!==null){a.stop()}return a};a.prototype.getState=function(t){var e=this._animationStates.length;while(e--){var a=this._animationStates[e];if(a.name===t){return a}}return null};a.prototype.hasAnimation=function(t){return t in this._animations};a.prototype.getStates=function(){return this._animationStates};Object.defineProperty(a.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState!==null?this._lastAnimationState.name:""},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animations",{get:function(){return this._animations},set:function(t){if(this._animations===t){return}this._animationNames.length=0;for(var e in this._animations){delete this._animations[e]}for(var e in t){this._animationNames.push(e);this._animations[e]=t[e]}},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animationConfig",{get:function(){this._animationConfig.clear();return this._animationConfig},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:true,configurable:true});a.prototype.gotoAndPlay=function(t,e,a,r,i,n,s,o,l){if(e===void 0){e=-1}if(a===void 0){a=-1}if(r===void 0){r=-1}if(i===void 0){i=0}if(n===void 0){n=null}if(s===void 0){s=3}if(o===void 0){o=true}if(l===void 0){l=true}console.warn("Deprecated.");o;l;this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.fadeOutMode=s;this._animationConfig.playTimes=r;this._animationConfig.layer=i;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=n!==null?n:"";var h=this._animations[t];if(h&&a>0){this._animationConfig.timeScale=h.duration/a}return this.playConfig(this._animationConfig)};a.prototype.gotoAndStop=function(t,e){if(e===void 0){e=0}console.warn("Deprecated.");return this.gotoAndStopByTime(t,e)};Object.defineProperty(a.prototype,"animationList",{get:function(){console.warn("Deprecated.");return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animationDataList",{get:function(){console.warn("Deprecated.");var t=[];for(var e=0,a=this._animationNames.length;e0;if(this._subFadeState<0){this._subFadeState=0;var r=a?t.EventObject.FADE_OUT:t.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=t.BaseObject.borrowObject(t.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}if(e<0){e=-e}this._fadeTime+=e;if(this._fadeTime>=this.fadeTotalTime){this._subFadeState=1;this._fadeProgress=a?0:1}else if(this._fadeTime>0){this._fadeProgress=a?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime}else{this._fadeProgress=a?1:0}if(this._subFadeState>0){if(!a){this._playheadState|=1;this._fadeState=0}var r=a?t.EventObject.FADE_OUT_COMPLETE:t.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=t.BaseObject.borrowObject(t.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}};i.prototype.init=function(e,a,r){if(this._armature!==null){return}this._armature=e;this._animationData=a;this.resetToPose=r.resetToPose;this.additiveBlending=r.additiveBlending;this.displayControl=r.displayControl;this.actionEnabled=r.actionEnabled;this.layer=r.layer;this.playTimes=r.playTimes;this.timeScale=r.timeScale;this.fadeTotalTime=r.fadeInTime;this.autoFadeOutTime=r.autoFadeOutTime;this.weight=r.weight;this.name=r.name.length>0?r.name:r.animation;this.group=r.group;if(r.pauseFadeIn){this._playheadState=2}else{this._playheadState=3}if(r.duration<0){this._position=0;this._duration=this._animationData.duration;if(r.position!==0){if(this.timeScale>=0){this._time=r.position}else{this._time=r.position-this._duration}}else{this._time=0}}else{this._position=r.position;this._duration=r.duration;this._time=0}if(this.timeScale<0&&this._time===0){this._time=-1e-6}if(this.fadeTotalTime<=0){this._fadeProgress=.999999}if(r.boneMask.length>0){this._boneMask.length=r.boneMask.length;for(var i=0,n=this._boneMask.length;i0;var i=true;var n=true;var s=this._time;this._weightResult=this.weight*this._fadeProgress;if(this._parent!==null){this._weightResult*=this._parent._weightResult/this._parent._fadeProgress}if(this._actionTimeline.playState<=0){this._actionTimeline.update(s)}if(r){var o=a*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*o)/o}if(this._zOrderTimeline!==null&&this._zOrderTimeline.playState<=0){this._zOrderTimeline.update(s)}if(r){var l=Math.floor(this._actionTimeline.currentTime*a);if(this._armature._cacheFrameIndex===l){i=false;n=false}else{this._armature._cacheFrameIndex=l;if(this._animationData.cachedFrames[l]){n=false}else{this._animationData.cachedFrames[l]=true}}}if(i){if(n){for(var h=0,f=this._boneTimelines.length;h0){this._subFadeState=0;if(this._poseTimelines.length>0){for(var p=0,m=this._poseTimelines;p0){if(this.autoFadeOutTime>=0){this.fadeOut(this.autoFadeOutTime)}}}};i.prototype.play=function(){this._playheadState=3};i.prototype.stop=function(){this._playheadState&=1};i.prototype.fadeOut=function(t,e){if(e===void 0){e=true}if(t<0){t=0}if(e){this._playheadState&=2}if(this._fadeState>0){if(t>this.fadeTotalTime-this._fadeTime){return}}else{this._fadeState=1;this._subFadeState=-1;if(t<=0||this._fadeProgress<=0){this._fadeProgress=1e-6}for(var a=0,r=this._boneTimelines;a1e-6?t/this._fadeProgress:0;this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)};i.prototype.containsBoneMask=function(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0};i.prototype.addBoneMask=function(t,e){if(e===void 0){e=true}var a=this._armature.getBone(t);if(a===null){return}if(this._boneMask.indexOf(t)<0){this._boneMask.push(t)}if(e){for(var r=0,i=this._armature.getBones();r=0){this._boneMask.splice(a,1)}if(e){var r=this._armature.getBone(t);if(r!==null){var i=this._armature.getBones();if(this._boneMask.length>0){for(var n=0,s=i;n=0&&r.contains(o)){this._boneMask.splice(l,1)}}}else{for(var h=0,f=i;h0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"isFadeComplete",{get:function(){return this._fadeState===0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"isPlaying",{get:function(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"totalTime",{get:function(){return this._duration},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"currentTime",{get:function(){return this._actionTimeline.currentTime},set:function(t){var e=this._actionTimeline.currentPlayTimes-(this._actionTimeline.playState>0?1:0);if(t<0||this._duration0&&e===this.playTimes-1&&t===this._duration){t=this._duration-1e-6}if(this._time===t){return}this._time=t;this._actionTimeline.setCurrentTime(this._time);if(this._zOrderTimeline!==null){this._zOrderTimeline.playState=-1}for(var a=0,r=this._boneTimelines;a0){if(this.layer!==e){if(this.layerWeight>=this.leftWeight){this.leftWeight=0;return 0}else{this.layer=e;this.leftWeight-=this.layerWeight;this.layerWeight=0}}}else{return 0}t*=this.leftWeight;this.layerWeight+=t;this.blendWeight=t;return 2}this.dirty=true;this.layer=e;this.layerWeight=t;this.leftWeight=1;this.blendWeight=t;return 1};t.prototype.clear=function(){this.dirty=false;this.layer=0;this.leftWeight=0;this.layerWeight=0;this.blendWeight=0};return t}();t.BlendState=r})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){this.playState=-1;this.currentPlayTimes=-1;this.currentTime=-1;this._tweenState=0;this._frameRate=0;this._frameValueOffset=0;this._frameCount=0;this._frameOffset=0;this._frameIndex=-1;this._frameRateR=0;this._position=0;this._duration=0;this._timeScale=1;this._timeOffset=0;this._dragonBonesData=null;this._animationData=null;this._timelineData=null;this._armature=null;this._animationState=null;this._actionTimeline=null;this._frameArray=null;this._frameIntArray=null;this._frameFloatArray=null;this._timelineArray=null;this._frameIndices=null};e.prototype._setCurrentTime=function(t){var e=this.playState;var a=this.currentPlayTimes;var r=this.currentTime;if(this._actionTimeline!==null&&this._frameCount<=1){this.playState=this._actionTimeline.playState>=0?1:-1;this.currentPlayTimes=1;this.currentTime=this._actionTimeline.currentTime}else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){var i=this._animationState.playTimes;var n=i*this._duration;t*=this._timeScale;if(this._timeOffset!==0){t+=this._timeOffset*this._animationData.duration}if(i>0&&(t>=n||t<=-n)){if(this.playState<=0&&this._animationState._playheadState===3){this.playState=1}this.currentPlayTimes=i;if(t<0){this.currentTime=0}else{this.currentTime=this._duration+1e-6}}else{if(this.playState!==0&&this._animationState._playheadState===3){this.playState=0}if(t<0){t=-t;this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=this._duration-t%this._duration}else{this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=t%this._duration}}this.currentTime+=this._position}else{this.playState=this._actionTimeline.playState;this.currentPlayTimes=this._actionTimeline.currentPlayTimes;this.currentTime=this._actionTimeline.currentTime}if(this.currentPlayTimes===a&&this.currentTime===r){return false}if(e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==a){this._frameIndex=-1}return true};e.prototype.init=function(t,e,a){this._armature=t;this._animationState=e;this._timelineData=a;this._actionTimeline=this._animationState._actionTimeline;if(this===this._actionTimeline){this._actionTimeline=null}this._animationData=this._animationState._animationData;this._frameRate=this._animationData.parent.frameRate;this._frameRateR=1/this._frameRate;this._position=this._animationState._position;this._duration=this._animationState._duration;this._dragonBonesData=this._animationData.parent.parent;if(this._timelineData!==null){this._frameIntArray=this._dragonBonesData.frameIntArray;this._frameFloatArray=this._dragonBonesData.frameFloatArray;this._frameArray=this._dragonBonesData.frameArray;this._timelineArray=this._dragonBonesData.timelineArray;this._frameIndices=this._dragonBonesData.frameIndices;this._frameCount=this._timelineArray[this._timelineData.offset+2];this._frameValueOffset=this._timelineArray[this._timelineData.offset+4];this._timeScale=100/this._timelineArray[this._timelineData.offset+0];this._timeOffset=this._timelineArray[this._timelineData.offset+1]*.01}};e.prototype.fadeOut=function(){};e.prototype.update=function(t){if(this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate);var a=this._frameIndices[this._timelineData.frameIndicesOffset+e];if(this._frameIndex!==a){this._frameIndex=a;this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+this._frameIndex];this._onArriveAtFrame()}}else if(this._frameIndex<0){this._frameIndex=0;if(this._timelineData!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5]}this._onArriveAtFrame()}if(this._tweenState!==0){this._onUpdateFrame()}}};return e}(t.BaseObject);t.TimelineState=e;var a=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e._getEasingValue=function(t,e,a){var r=e;switch(t){case 3:r=Math.pow(e,2);break;case 4:r=1-Math.pow(1-e,2);break;case 5:r=.5*(1-Math.cos(e*Math.PI));break}return(r-e)*a+e};e._getEasingCurveValue=function(t,e,a,r){if(t<=0){return 0}else if(t>=1){return 1}var i=a+1;var n=Math.floor(t*i);var s=n===0?0:e[r+n-1];var o=n===i-1?1e4:e[r+n];return(s+(o-s)*(t*i-n))*1e-4};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._tweenType=0;this._curveCount=0;this._framePosition=0;this._frameDurationR=0;this._tweenProgress=0;this._tweenEasing=0};e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0){this._frameDurationR=1/e}else{this._frameDurationR=0}}}else{this._tweenState=1}};e.prototype._onUpdateFrame=function(){if(this._tweenState===2){this._tweenProgress=(this.currentTime-this._framePosition)*this._frameDurationR;if(this._tweenType===2){this._tweenProgress=e._getEasingCurveValue(this._tweenProgress,this._frameArray,this._curveCount,this._frameOffset+3)}else if(this._tweenType!==1){this._tweenProgress=e._getEasingValue(this._tweenType,this._tweenProgress,this._tweenEasing)}}else{this._tweenProgress=0}};return e}(e);t.TweenTimelineState=a;var r=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){t.prototype._onClear.call(this);this.bone=null;this.bonePose=null};e.prototype.blend=function(t){var e=this.bone._blendState.blendWeight;var a=this.bone.animationPose;var r=this.bonePose.result;if(t===2){a.x+=r.x*e;a.y+=r.y*e;a.rotation+=r.rotation*e;a.skew+=r.skew*e;a.scaleX+=(r.scaleX-1)*e;a.scaleY+=(r.scaleY-1)*e}else if(e!==1){a.x=r.x*e;a.y=r.y*e;a.rotation=r.rotation*e;a.skew=r.skew*e;a.scaleX=(r.scaleX-1)*e+1;a.scaleY=(r.scaleY-1)*e+1}else{a.x=r.x;a.y=r.y;a.rotation=r.rotation;a.skew=r.skew;a.scaleX=r.scaleX;a.scaleY=r.scaleY}if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){this.bone._transformDirty=true}};return e}(a);t.BoneTimelineState=r;var i=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){t.prototype._onClear.call(this);this.slot=null};return e}(a);t.SlotTimelineState=i;var n=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){t.prototype._onClear.call(this);this.constraint=null};return e}(a);t.ConstraintTimelineState=n})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(a,e);function a(){return e!==null&&e.apply(this,arguments)||this}a.toString=function(){return"[class dragonBones.ActionTimelineState]"};a.prototype._onCrossFrame=function(e){var a=this._armature.eventDispatcher;if(this._animationState.actionEnabled){var r=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+e];var i=this._frameArray[r+1];var n=this._animationData.parent.actions;for(var s=0;s0){if(n.hasDBEventListener(t.EventObject.COMPLETE)){h=t.BaseObject.borrowObject(t.EventObject);h.type=t.EventObject.COMPLETE;h.armature=this._armature;h.animationState=this._animationState}}}if(this._frameCount>1){var f=this._timelineData;var u=Math.floor(this.currentTime*this._frameRate);var _=this._frameIndices[f.frameIndicesOffset+u];if(this._frameIndex!==_){var c=this._frameIndex;this._frameIndex=_;if(this._timelineArray!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[f.offset+5+this._frameIndex];if(o){if(c<0){var p=Math.floor(i*this._frameRate);c=this._frameIndices[f.frameIndicesOffset+p];if(this.currentPlayTimes===r){if(c===_){c=-1}}}while(c>=0){var m=this._animationData.frameOffset+this._timelineArray[f.offset+5+c];var d=this._frameArray[m]/this._frameRate;if(this._position<=d&&d<=this._position+this._duration){this._onCrossFrame(c)}if(l!==null&&c===0){this._armature._dragonBones.bufferEvent(l);l=null}if(c>0){c--}else{c=this._frameCount-1}if(c===_){break}}}else{if(c<0){var p=Math.floor(i*this._frameRate);c=this._frameIndices[f.frameIndicesOffset+p];var m=this._animationData.frameOffset+this._timelineArray[f.offset+5+c];var d=this._frameArray[m]/this._frameRate;if(this.currentPlayTimes===r){if(i<=d){if(c>0){c--}else{c=this._frameCount-1}}else if(c===_){c=-1}}}while(c>=0){if(c=0){var t=this._frameArray[this._frameOffset+1];if(t>0){this._armature._sortZOrder(this._frameArray,this._frameOffset+2)}else{this._armature._sortZOrder(null,0)}}};e.prototype._onUpdateFrame=function(){};return e}(t.TimelineState);t.ZOrderTimelineState=a;var r=function(e){__extends(a,e);function a(){return e!==null&&e.apply(this,arguments)||this}a.toString=function(){return"[class dragonBones.BoneAllTimelineState]"};a.prototype._onArriveAtFrame=function(){e.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*6;var a=this._armature._armatureData.scale;var r=this._frameFloatArray;var i=this.bonePose.current;var n=this.bonePose.delta;i.x=r[t++]*a;i.y=r[t++]*a;i.rotation=r[t++];i.skew=r[t++];i.scaleX=r[t++];i.scaleY=r[t++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){t=this._animationData.frameFloatOffset+this._frameValueOffset}n.x=r[t++]*a-i.x;n.y=r[t++]*a-i.y;n.rotation=r[t++]-i.rotation;n.skew=r[t++]-i.skew;n.scaleX=r[t++]-i.scaleX;n.scaleY=r[t++]-i.scaleY}else{n.x=0;n.y=0;n.rotation=0;n.skew=0;n.scaleX=0;n.scaleY=0}}else{var i=this.bonePose.current;var n=this.bonePose.delta;i.x=0;i.y=0;i.rotation=0;i.skew=0;i.scaleX=1;i.scaleY=1;n.x=0;n.y=0;n.rotation=0;n.skew=0;n.scaleX=0;n.scaleY=0}};a.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current;var a=this.bonePose.delta;var r=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}r.x=t.x+a.x*this._tweenProgress;r.y=t.y+a.y*this._tweenProgress;r.rotation=t.rotation+a.rotation*this._tweenProgress;r.skew=t.skew+a.skew*this._tweenProgress;r.scaleX=t.scaleX+a.scaleX*this._tweenProgress;r.scaleY=t.scaleY+a.scaleY*this._tweenProgress};a.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation);e.skew=t.Transform.normalizeRadian(e.skew)};return a}(t.BoneTimelineState);t.BoneAllTimelineState=r;var i=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.BoneTranslateTimelineState]"};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*2;var a=this._armature._armatureData.scale;var r=this._frameFloatArray;var i=this.bonePose.current;var n=this.bonePose.delta;i.x=r[e++]*a;i.y=r[e++]*a;if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){e=this._animationData.frameFloatOffset+this._frameValueOffset}n.x=r[e++]*a-i.x;n.y=r[e++]*a-i.y}else{n.x=0;n.y=0}}else{var i=this.bonePose.current;var n=this.bonePose.delta;i.x=0;i.y=0;n.x=0;n.y=0}};e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);var e=this.bonePose.current;var a=this.bonePose.delta;var r=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}r.x=e.x+a.x*this._tweenProgress;r.y=e.y+a.y*this._tweenProgress};return e}(t.BoneTimelineState);t.BoneTranslateTimelineState=i;var n=function(e){__extends(a,e);function a(){return e!==null&&e.apply(this,arguments)||this}a.toString=function(){return"[class dragonBones.BoneRotateTimelineState]"};a.prototype._onArriveAtFrame=function(){e.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var a=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*2;var r=this._frameFloatArray;var i=this.bonePose.current;var n=this.bonePose.delta;i.rotation=r[a++];i.skew=r[a++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){a=this._animationData.frameFloatOffset+this._frameValueOffset;n.rotation=t.Transform.normalizeRadian(r[a++]-i.rotation)}else{n.rotation=r[a++]-i.rotation}n.skew=r[a++]-i.skew}else{n.rotation=0;n.skew=0}}else{var i=this.bonePose.current;var n=this.bonePose.delta;i.rotation=0;i.skew=0;n.rotation=0;n.skew=0}};a.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current;var a=this.bonePose.delta;var r=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}r.rotation=t.rotation+a.rotation*this._tweenProgress;r.skew=t.skew+a.skew*this._tweenProgress};a.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation);e.skew=t.Transform.normalizeRadian(e.skew)};return a}(t.BoneTimelineState);t.BoneRotateTimelineState=n;var s=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.BoneScaleTimelineState]"};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*2;var a=this._frameFloatArray;var r=this.bonePose.current;var i=this.bonePose.delta;r.scaleX=a[e++];r.scaleY=a[e++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){e=this._animationData.frameFloatOffset+this._frameValueOffset}i.scaleX=a[e++]-r.scaleX;i.scaleY=a[e++]-r.scaleY}else{i.scaleX=0;i.scaleY=0}}else{var r=this.bonePose.current;var i=this.bonePose.delta;r.scaleX=1;r.scaleY=1;i.scaleX=0;i.scaleY=0}};e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);var e=this.bonePose.current;var a=this.bonePose.delta;var r=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}r.scaleX=e.scaleX+a.scaleX*this._tweenProgress;r.scaleY=e.scaleY+a.scaleY*this._tweenProgress};return e}(t.BoneTimelineState);t.BoneScaleTimelineState=s;var o=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[];e._delta=[];e._result=[];return e}e.toString=function(){return"[class dragonBones.SurfaceTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.surface=null;this._frameFloatOffset=0;this._valueCount=0;this._deformCount=0;this._valueOffset=0;this._current.length=0;this._delta.length=0;this._result.length=0};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount;var a=this._armature._armatureData.scale;var r=this._frameFloatArray;if(this._tweenState===2){var i=e+this._valueCount;if(this._frameIndex===this._frameCount-1){i=this._animationData.frameFloatOffset+this._frameValueOffset}for(var n=0;n=0){var t=this._timelineData!==null?this._frameArray[this._frameOffset+1]:this.slot._slotData.displayIndex;if(this.slot.displayIndex!==t){this.slot._setDisplayIndex(t,true)}}};return e}(t.SlotTimelineState);t.SlotDislayTimelineState=l;var h=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[0,0,0,0,0,0,0,0];e._delta=[0,0,0,0,0,0,0,0];e._result=[0,0,0,0,0,0,0,0];return e}e.toString=function(){return"[class dragonBones.SlotColorTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._dirty=false};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._dragonBonesData.intArray;var a=this._frameIntArray;var r=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex*1;var i=a[r];if(i<0){i+=65536}this._current[0]=e[i++];this._current[1]=e[i++];this._current[2]=e[i++];this._current[3]=e[i++];this._current[4]=e[i++];this._current[5]=e[i++];this._current[6]=e[i++];this._current[7]=e[i++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){i=a[this._animationData.frameIntOffset+this._frameValueOffset]}else{i=a[r+1*1]}if(i<0){i+=65536}this._delta[0]=e[i++]-this._current[0];this._delta[1]=e[i++]-this._current[1];this._delta[2]=e[i++]-this._current[2];this._delta[3]=e[i++]-this._current[3];this._delta[4]=e[i++]-this._current[4];this._delta[5]=e[i++]-this._current[5];this._delta[6]=e[i++]-this._current[6];this._delta[7]=e[i++]-this._current[7]}}else{var n=this.slot._slotData.color;this._current[0]=n.alphaMultiplier*100;this._current[1]=n.redMultiplier*100;this._current[2]=n.greenMultiplier*100;this._current[3]=n.blueMultiplier*100;this._current[4]=n.alphaOffset;this._current[5]=n.redOffset;this._current[6]=n.greenOffset;this._current[7]=n.blueOffset}};e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);this._dirty=true;if(this._tweenState!==2){this._tweenState=0}this._result[0]=(this._current[0]+this._delta[0]*this._tweenProgress)*.01;this._result[1]=(this._current[1]+this._delta[1]*this._tweenProgress)*.01;this._result[2]=(this._current[2]+this._delta[2]*this._tweenProgress)*.01;this._result[3]=(this._current[3]+this._delta[3]*this._tweenProgress)*.01;this._result[4]=this._current[4]+this._delta[4]*this._tweenProgress;this._result[5]=this._current[5]+this._delta[5]*this._tweenProgress;this._result[6]=this._current[6]+this._delta[6]*this._tweenProgress;this._result[7]=this._current[7]+this._delta[7]*this._tweenProgress};e.prototype.fadeOut=function(){this._tweenState=0;this._dirty=false};e.prototype.update=function(e){t.prototype.update.call(this,e);if(this._tweenState!==0||this._dirty){var a=this.slot._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){var r=Math.pow(this._animationState._fadeProgress,4);a.alphaMultiplier+=(this._result[0]-a.alphaMultiplier)*r;a.redMultiplier+=(this._result[1]-a.redMultiplier)*r;a.greenMultiplier+=(this._result[2]-a.greenMultiplier)*r;a.blueMultiplier+=(this._result[3]-a.blueMultiplier)*r;a.alphaOffset+=(this._result[4]-a.alphaOffset)*r;a.redOffset+=(this._result[5]-a.redOffset)*r;a.greenOffset+=(this._result[6]-a.greenOffset)*r;a.blueOffset+=(this._result[7]-a.blueOffset)*r;this.slot._colorDirty=true}}else if(this._dirty){this._dirty=false;if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){a.alphaMultiplier=this._result[0];a.redMultiplier=this._result[1];a.greenMultiplier=this._result[2];a.blueMultiplier=this._result[3];a.alphaOffset=this._result[4];a.redOffset=this._result[5];a.greenOffset=this._result[6];a.blueOffset=this._result[7];this.slot._colorDirty=true}}}};return e}(t.SlotTimelineState);t.SlotColorTimelineState=h;var f=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[];e._delta=[];e._result=[];return e}e.toString=function(){return"[class dragonBones.DeformTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.vertexOffset=0;this._dirty=false;this._frameFloatOffset=0;this._valueCount=0;this._deformCount=0;this._valueOffset=0;this._current.length=0;this._delta.length=0;this._result.length=0};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount;var a=this._armature._armatureData.scale;var r=this._frameFloatArray;if(this._tweenState===2){var i=e+this._valueCount;if(this._frameIndex===this._frameCount-1){i=this._animationData.frameFloatOffset+this._frameValueOffset}for(var n=0;n=0){this._floats[2]=this._floats[0]+this._floats[1]*this._tweenProgress}this._floats[5]=this._floats[3]+this._floats[4]*this._tweenProgress};e.prototype.blend=function(t){var e=this.animationState;var a=e._blendState.blendWeight;if(t===2){e.weight+=this._floats[5]*a;e.currentTime+=this._floats[2]*a}else{e.weight=this._floats[5]*a;e.currentTime=this._floats[2]*a}};return e}(t.TweenTimelineState);t.AnimationTimelineState=_})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.actionDataToInstance=function(t,a,r){if(t.type===0){a.type=e.FRAME_EVENT}else{a.type=t.type===10?e.FRAME_EVENT:e.SOUND_EVENT}a.name=t.name;a.armature=r;a.actionData=t;a.data=t.data;if(t.bone!==null){a.bone=r.getBone(t.bone.name)}if(t.slot!==null){a.slot=r.getSlot(t.slot.name)}};e.toString=function(){return"[class dragonBones.EventObject]"};e.prototype._onClear=function(){this.time=0;this.type="";this.name="";this.armature=null;this.bone=null;this.slot=null;this.animationState=null;this.actionData=null;this.data=null};e.START="start";e.LOOP_COMPLETE="loopComplete";e.COMPLETE="complete";e.FADE_IN="fadeIn";e.FADE_IN_COMPLETE="fadeInComplete";e.FADE_OUT="fadeOut";e.FADE_OUT_COMPLETE="fadeOutComplete";e.FRAME_EVENT="frameEvent";e.SOUND_EVENT="soundEvent";return e}(t.BaseObject);t.EventObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function e(){}e._getArmatureType=function(t){switch(t.toLowerCase()){case"stage":return 2;case"armature":return 0;case"movieclip":return 1;default:return 0}};e._getBoneType=function(t){switch(t.toLowerCase()){case"bone":return 0;case"surface":return 1;default:return 0}};e._getDisplayType=function(t){switch(t.toLowerCase()){case"image":return 0;case"mesh":return 2;case"armature":return 1;case"boundingbox":return 3;case"path":return 4;default:return 0}};e._getBoundingBoxType=function(t){switch(t.toLowerCase()){case"rectangle":return 0;case"ellipse":return 1;case"polygon":return 2;default:return 0}};e._getActionType=function(t){switch(t.toLowerCase()){case"play":return 0;case"frame":return 10;case"sound":return 11;default:return 0}};e._getBlendMode=function(t){switch(t.toLowerCase()){case"normal":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"overlay":return 11;case"screen":return 12;case"subtract":return 13;default:return 0}};e._getPositionMode=function(t){switch(t.toLocaleLowerCase()){case"percent":return 1;case"fixed":return 0;default:return 1}};e._getSpacingMode=function(t){switch(t.toLocaleLowerCase()){case"length":return 0;case"percent":return 2;case"fixed":return 1;default:return 0}};e._getRotateMode=function(t){switch(t.toLocaleLowerCase()){case"tangent":return 0;case"chain":return 1;case"chainscale":return 2;default:return 0}};e.parseDragonBonesData=function(e){console.warn("Deprecated.");if(e instanceof ArrayBuffer){return t.BinaryDataParser.getInstance().parseDragonBonesData(e)}else{return t.ObjectDataParser.getInstance().parseDragonBonesData(e)}};e.parseTextureAtlasData=function(a,r){if(r===void 0){r=1}console.warn("已废弃");var i={};var n=a[e.SUB_TEXTURE];for(var s=0,o=n.length;s255){return encodeURI(i)}}}return i}return String(i)}return r};r.prototype._getCurvePoint=function(t,e,a,r,i,n,s,o,l,h){var f=1-l;var u=f*f;var _=l*l;var c=f*u;var p=3*l*u;var m=3*f*_;var d=l*_;h.x=c*t+p*a+m*i+d*s;h.y=c*e+p*r+m*n+d*o};r.prototype._samplingEasingCurve=function(t,e){var a=t.length;var r=-2;for(var i=0,n=e.length;i=0&&r+61e-4){var y=(v+d)*.5;this._getCurvePoint(l,h,f,u,_,c,p,m,y,this._helpPoint);if(s-this._helpPoint.x>0){d=y}else{v=y}}e[i]=this._helpPoint.y}};r.prototype._parseActionDataInFrame=function(e,a,r,i){if(t.DataParser.EVENT in e){this._mergeActionFrame(e[t.DataParser.EVENT],a,10,r,i)}if(t.DataParser.SOUND in e){this._mergeActionFrame(e[t.DataParser.SOUND],a,11,r,i)}if(t.DataParser.ACTION in e){this._mergeActionFrame(e[t.DataParser.ACTION],a,0,r,i)}if(t.DataParser.EVENTS in e){this._mergeActionFrame(e[t.DataParser.EVENTS],a,10,r,i)}if(t.DataParser.ACTIONS in e){this._mergeActionFrame(e[t.DataParser.ACTIONS],a,0,r,i)}};r.prototype._mergeActionFrame=function(e,r,i,n,s){var o=t.DragonBones.webAssembly?this._armature.actions.size():this._armature.actions.length;var l=this._parseActionData(e,i,n,s);var h=0;var f=null;for(var u=0,_=l;u<_.length;u++){var c=_[u];this._armature.addAction(c,false)}if(this._actionFrames.length===0){f=new a;f.frameStart=0;this._actionFrames.push(f);f=null}for(var p=0,m=this._actionFrames;pr){break}h++}if(f===null){f=new a;f.frameStart=r;this._actionFrames.splice(h+1,0,f)}for(var v=0;v0){var p=i.getBone(_);if(p!==null){c.parent=p}else{if(!(_ in this._cacheBones)){this._cacheBones[_]=[]}this._cacheBones[_].push(c)}}if(c.name in this._cacheBones){for(var m=0,d=this._cacheBones[c.name];m0&&a.parent!==null){n.root=a.parent;n.bone=a}else{n.root=a;n.bone=null}return n};r.prototype._parsePathConstraint=function(e){var a=this._armature.getSlot(r._getString(e,t.DataParser.TARGET,""));if(a===null){return null}var i=this._armature.defaultSkin;if(i===null){return null}var n=i.getDisplay(a.name,r._getString(e,t.DataParser.TARGET_DISPLAY,a.name));if(n===null||!(n instanceof t.PathDisplayData)){return null}var s=e[t.DataParser.BONES];if(s===null||s.length===0){return null}var o=t.BaseObject.borrowObject(t.PathConstraintData);o.name=r._getString(e,t.DataParser.NAME,"");o.type=1;o.pathSlot=a;o.pathDisplayData=n;o.target=a.parent;o.positionMode=t.DataParser._getPositionMode(r._getString(e,t.DataParser.POSITION_MODE,""));o.spacingMode=t.DataParser._getSpacingMode(r._getString(e,t.DataParser.SPACING_MODE,""));o.rotateMode=t.DataParser._getRotateMode(r._getString(e,t.DataParser.ROTATE_MODE,""));o.position=r._getNumber(e,t.DataParser.POSITION,0);o.spacing=r._getNumber(e,t.DataParser.SPACING,0);o.rotateOffset=r._getNumber(e,t.DataParser.ROTATE_OFFSET,0);o.rotateMix=r._getNumber(e,t.DataParser.ROTATE_MIX,1);o.translateMix=r._getNumber(e,t.DataParser.TRANSLATE_MIX,1);for(var l=0,h=s;l0?i:a;this._parsePivot(e,o);break;case 1:var l=s=t.BaseObject.borrowObject(t.ArmatureDisplayData);l.name=a;l.path=i.length>0?i:a;l.inheritAnimation=true;if(t.DataParser.ACTIONS in e){var h=this._parseActionData(e[t.DataParser.ACTIONS],0,null,null);for(var f=0,u=h;f0?i:a;d.vertices.data=this._data;if(t.DataParser.SHARE in e){this._cacheRawMeshes.push(e);this._cacheMeshes.push(d)}else{this._parseMesh(e,d)}if(t.DataParser.GLUE_WEIGHTS in e&&t.DataParser.GLUE_MESHES in e){this._cacheRawMeshes.push(e);this._cacheMeshes.push(d)}break;case 3:var v=this._parseBoundingBox(e);if(v!==null){var y=s=t.BaseObject.borrowObject(t.BoundingBoxDisplayData);y.name=a;y.path=i.length>0?i:a;y.boundingBox=v}break;case 4:var g=e[t.DataParser.LENGTHS];var b=s=t.BaseObject.borrowObject(t.PathDisplayData);b.closed=r._getBoolean(e,t.DataParser.CLOSED,false);b.constantSpeed=r._getBoolean(e,t.DataParser.CONSTANT_SPEED,false);b.name=a;b.path=i.length>0?i:a;b.vertices.data=this._data;b.curveLengths.length=g.length;for(var D=0,T=g.length;Da.width){a.width=l}if(ha.height){a.height=h}}}a.width-=a.x;a.height-=a.y}else{console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug.")}return a};r.prototype._parseAnimation=function(e){var a=t.BaseObject.borrowObject(t.AnimationData);a.frameCount=Math.max(r._getNumber(e,t.DataParser.DURATION,1),1);a.playTimes=r._getNumber(e,t.DataParser.PLAY_TIMES,1);a.duration=a.frameCount/this._armature.frameRate;a.fadeInTime=r._getNumber(e,t.DataParser.FADE_IN_TIME,0);a.scale=r._getNumber(e,t.DataParser.SCALE,1);a.name=r._getString(e,t.DataParser.NAME,t.DataParser.DEFAULT_NAME);if(a.name.length===0){a.name=t.DataParser.DEFAULT_NAME}a.frameIntOffset=this._frameIntArray.length;a.frameFloatOffset=this._frameFloatArray.length;a.frameOffset=this._frameArray.length;this._animation=a;if(t.DataParser.FRAME in e){var i=e[t.DataParser.FRAME];var n=i.length;if(n>0){for(var s=0,o=0;s0){this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",0,false,false,0,this._parseActionFrame);this._actionFrames.length=0}this._animation=null;return a};r.prototype._parseTimeline=function(e,i,n,s,o,l,h,f){if(e!==null&&n.length>0&&n in e){i=e[n]}if(i===null){return null}var u=i.length;if(u===0){return null}var _=this._frameIntArray.length;var c=this._frameFloatArray.length;var p=t.BaseObject.borrowObject(t.TimelineData);var m=this._timelineArray.length;this._timelineArray.length+=1+1+1+1+1+u;if(e!==null){this._timelineArray[m+0]=Math.round(r._getNumber(e,t.DataParser.SCALE,1)*100);this._timelineArray[m+1]=Math.round(r._getNumber(e,t.DataParser.OFFSET,0)*100)}else{this._timelineArray[m+0]=100;this._timelineArray[m+1]=0}this._timelineArray[m+2]=u;this._timelineArray[m+3]=h;if(o){this._timelineArray[m+4]=_-this._animation.frameIntOffset}else if(l){this._timelineArray[m+4]=c-this._animation.frameFloatOffset}else{this._timelineArray[m+4]=0}this._timeline=p;p.type=s;p.offset=m;if(u===1){p.frameIndicesOffset=-1;this._timelineArray[m+5+0]=f.call(this,i[0],0,0)-this._animation.frameOffset}else{var d=this._animation.frameCount+1;var v=this._data.frameIndices;var y=0;if(t.DragonBones.webAssembly){y=v.size();v.resize(y+d,0)}else{y=v.length;v.length+=d}p.frameIndicesOffset=y;for(var g=0,b=0,D=0,T=0;g0){if(t.DataParser.CURVE in e){var s=i+1;this._helpArray.length=s;this._samplingEasingCurve(e[t.DataParser.CURVE],this._helpArray);this._frameArray.length+=1+1+this._helpArray.length;this._frameArray[n+1]=2;this._frameArray[n+2]=s;for(var o=0;o0){var s=this._armature.sortedSlots.length;var o=new Array(s-n.length/2);var l=new Array(s);for(var h=0;h0?n>=this._prevRotation:n<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}n=this._prevRotation+n-this._prevRotation+t.Transform.PI_D*this._prevClockwise}}this._prevClockwise=r._getNumber(e,t.DataParser.TWEEN_ROTATE,0);this._prevRotation=n;var s=this._parseTweenFrame(e,a,i);var o=this._frameFloatArray.length;this._frameFloatArray.length+=6;this._frameFloatArray[o++]=this._helpTransform.x;this._frameFloatArray[o++]=this._helpTransform.y;this._frameFloatArray[o++]=n;this._frameFloatArray[o++]=this._helpTransform.skew;this._frameFloatArray[o++]=this._helpTransform.scaleX;this._frameFloatArray[o++]=this._helpTransform.scaleY;this._parseActionDataInFrame(e,a,this._bone,this._slot);return s};r.prototype._parseBoneTranslateFrame=function(e,a,i){var n=this._parseTweenFrame(e,a,i);var s=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[s++]=r._getNumber(e,t.DataParser.X,0);this._frameFloatArray[s++]=r._getNumber(e,t.DataParser.Y,0);return n};r.prototype._parseBoneRotateFrame=function(e,a,i){var n=r._getNumber(e,t.DataParser.ROTATE,0)*t.Transform.DEG_RAD;if(a!==0){if(this._prevClockwise===0){n=this._prevRotation+t.Transform.normalizeRadian(n-this._prevRotation)}else{if(this._prevClockwise>0?n>=this._prevRotation:n<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}n=this._prevRotation+n-this._prevRotation+t.Transform.PI_D*this._prevClockwise}}this._prevClockwise=r._getNumber(e,t.DataParser.CLOCK_WISE,0);this._prevRotation=n;var s=this._parseTweenFrame(e,a,i);var o=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[o++]=n;this._frameFloatArray[o++]=r._getNumber(e,t.DataParser.SKEW,0)*t.Transform.DEG_RAD;return s};r.prototype._parseBoneScaleFrame=function(e,a,i){var n=this._parseTweenFrame(e,a,i);var s=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[s++]=r._getNumber(e,t.DataParser.X,1);this._frameFloatArray[s++]=r._getNumber(e,t.DataParser.Y,1);return n};r.prototype._parseSurfaceFrame=function(e,a,i){var n=this._frameFloatArray.length;var s=this._parseTweenFrame(e,a,i);var o=e[t.DataParser.VERTICES];var l=r._getNumber(e,t.DataParser.OFFSET,0);var h=this._surface.vertices.length/2;var f=0;var u=0;this._frameFloatArray.length+=h*2;for(var _=0;_=o.length){f=0}else{f=o[_-l]}if(_+1=o.length){u=0}else{u=o[_+1-l]}this._frameFloatArray[n+_]=f;this._frameFloatArray[n+_+1]=u}if(a===0){var c=this._frameIntArray.length;this._frameIntArray.length+=1+1+1+1+1;this._frameIntArray[c+0]=0;this._frameIntArray[c+1]=this._frameFloatArray.length-n;this._frameIntArray[c+2]=this._frameFloatArray.length-n;this._frameIntArray[c+3]=0;this._frameIntArray[c+4]=n-this._animation.frameFloatOffset;this._timelineArray[this._timeline.offset+3]=c-this._animation.frameIntOffset}return s};r.prototype._parseSlotDisplayFrame=function(e,a,i){var n=this._parseFrame(e,a,i);this._frameArray.length+=1;if(t.DataParser.VALUE in e){this._frameArray[n+1]=r._getNumber(e,t.DataParser.VALUE,0)}else{this._frameArray[n+1]=r._getNumber(e,t.DataParser.DISPLAY_INDEX,0)}this._parseActionDataInFrame(e,a,this._slot.parent,this._slot);return n};r.prototype._parseSlotColorFrame=function(e,a,r){var i=this._parseTweenFrame(e,a,r);var n=-1;if(t.DataParser.VALUE in e||t.DataParser.COLOR in e){var s=t.DataParser.VALUE in e?e[t.DataParser.VALUE]:e[t.DataParser.COLOR];for(var o in s){o;this._parseColorTransform(s,this._helpColorTransform);n=this._intArray.length;this._intArray.length+=8;this._intArray[n++]=Math.round(this._helpColorTransform.alphaMultiplier*100);this._intArray[n++]=Math.round(this._helpColorTransform.redMultiplier*100);this._intArray[n++]=Math.round(this._helpColorTransform.greenMultiplier*100);this._intArray[n++]=Math.round(this._helpColorTransform.blueMultiplier*100);this._intArray[n++]=Math.round(this._helpColorTransform.alphaOffset);this._intArray[n++]=Math.round(this._helpColorTransform.redOffset);this._intArray[n++]=Math.round(this._helpColorTransform.greenOffset);this._intArray[n++]=Math.round(this._helpColorTransform.blueOffset);n-=8;break}}if(n<0){if(this._defaultColorOffset<0){this._defaultColorOffset=n=this._intArray.length;this._intArray.length+=8;this._intArray[n++]=100;this._intArray[n++]=100;this._intArray[n++]=100;this._intArray[n++]=100;this._intArray[n++]=0;this._intArray[n++]=0;this._intArray[n++]=0;this._intArray[n++]=0}n=this._defaultColorOffset}var l=this._frameIntArray.length;this._frameIntArray.length+=1;this._frameIntArray[l]=n;return i};r.prototype._parseSlotFFDFrame=function(e,a,i){var n=this._frameFloatArray.length;var s=this._parseTweenFrame(e,a,i);var o=t.DataParser.VERTICES in e?e[t.DataParser.VERTICES]:null;var l=r._getNumber(e,t.DataParser.OFFSET,0);var h=this._intArray[this._mesh.vertices.offset+0];var f=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name;var u=this._mesh.vertices.weight;var _=0;var c=0;var p=0;var m=0;if(u!==null){var d=this._weightSlotPose[f];this._helpMatrixA.copyFromArray(d,0);this._frameFloatArray.length+=u.count*2;p=u.offset+2+u.bones.length}else{this._frameFloatArray.length+=h*2}for(var v=0;v=o.length){_=0}else{_=o[v-l]}if(v+1=o.length){c=0}else{c=o[v+1-l]}}if(u!==null){var y=this._weightBonePoses[f];var g=this._intArray[p++];this._helpMatrixA.transformPoint(_,c,this._helpPoint,true);_=this._helpPoint.x;c=this._helpPoint.y;for(var b=0;b=0||t.DataParser.DATA_VERSIONS.indexOf(n)>=0){var s=t.BaseObject.borrowObject(t.DragonBonesData);s.version=i;s.name=r._getString(e,t.DataParser.NAME,"");s.frameRate=r._getNumber(e,t.DataParser.FRAME_RATE,24);if(s.frameRate===0){s.frameRate=24}if(t.DataParser.ARMATURE in e){this._data=s;this._parseArray(e);var o=e[t.DataParser.ARMATURE];for(var l=0,h=o;l0){s.stage=s.getArmature(s.armatureNames[0])}this._data=null}if(t.DataParser.TEXTURE_ATLAS in e){this._rawTextureAtlases=e[t.DataParser.TEXTURE_ATLAS]}return s}else{console.assert(false,"Nonsupport data version: "+i+"\n"+"Please convert DragonBones data to support version.\n"+"Read more: https://github.com/DragonBones/Tools/")}return null};r.prototype.parseTextureAtlasData=function(e,a,i){if(i===void 0){i=1}console.assert(e!==undefined);if(e===null){if(this._rawTextureAtlases===null||this._rawTextureAtlases.length===0){return false}var n=this._rawTextureAtlases[this._rawTextureAtlasIndex++];this.parseTextureAtlasData(n,a,i);if(this._rawTextureAtlasIndex>=this._rawTextureAtlases.length){this._rawTextureAtlasIndex=0;this._rawTextureAtlases=null}return true}a.width=r._getNumber(e,t.DataParser.WIDTH,0);a.height=r._getNumber(e,t.DataParser.HEIGHT,0);a.scale=i===1?1/r._getNumber(e,t.DataParser.SCALE,1):i;a.name=r._getString(e,t.DataParser.NAME,"");a.imagePath=r._getString(e,t.DataParser.IMAGE_PATH,"");if(t.DataParser.SUB_TEXTURE in e){var s=e[t.DataParser.SUB_TEXTURE];for(var o=0,l=s.length;o0&&_>0){f.frame=t.TextureData.createRectangle();f.frame.x=r._getNumber(h,t.DataParser.FRAME_X,0);f.frame.y=r._getNumber(h,t.DataParser.FRAME_Y,0);f.frame.width=u;f.frame.height=_}a.addTexture(f)}}return true};r.getInstance=function(){if(r._objectDataParserInstance===null){r._objectDataParserInstance=new r}return r._objectDataParserInstance};r._objectDataParserInstance=null;return r}(t.DataParser);t.ObjectDataParser=e;var a=function(){function t(){this.frameStart=0;this.actions=[]}return t}();t.ActionFrame=a})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(a,e);function a(){return e!==null&&e.apply(this,arguments)||this}a.prototype._inRange=function(t,e,a){return e<=t&&t<=a};a.prototype._decodeUTF8=function(t){var e=-1;var a=-1;var r=65533;var i=0;var n="";var s;var o=0;var l=0;var h=0;var f=0;while(t.length>i){var u=t[i++];if(u===e){if(l!==0){s=r}else{s=a}}else{if(l===0){if(this._inRange(u,0,127)){s=u}else{if(this._inRange(u,194,223)){l=1;f=128;o=u-192}else if(this._inRange(u,224,239)){l=2;f=2048;o=u-224}else if(this._inRange(u,240,244)){l=3;f=65536;o=u-240}else{}o=o*Math.pow(64,l);s=null}}else if(!this._inRange(u,128,191)){o=0;l=0;h=0;f=0;i--;s=u}else{h+=1;o=o+(u-128)*Math.pow(64,l-h);if(h!==l){s=null}else{var _=o;var c=f;o=0;l=0;h=0;f=0;if(this._inRange(_,c,1114111)&&!this._inRange(_,55296,57343)){s=_}else{s=u}}}}if(s!==null&&s!==a){if(s<=65535){if(s>0)n+=String.fromCharCode(s)}else{s-=65536;n+=String.fromCharCode(55296+(s>>10&1023));n+=String.fromCharCode(56320+(s&1023))}}}return n};a.prototype._getUTF16Key=function(t){for(var e=0,a=t.length;e255){return encodeURI(t)}}return t};a.prototype._parseBinaryTimeline=function(e,a,r){if(r===void 0){r=null}var i=r!==null?r:t.BaseObject.borrowObject(t.TimelineData);i.type=e;i.offset=a;this._timeline=i;var n=this._timelineArrayBuffer[i.offset+2];if(n===1){i.frameIndicesOffset=-1}else{var s=0;var o=this._animation.frameCount+1;var l=this._data.frameIndices;if(t.DragonBones.webAssembly){s=l.size();l.resize(s+o,0)}else{s=l.length;l.length+=o}i.frameIndicesOffset=s;for(var h=0,f=0,u=0,_=0;h=0){var i=t.BaseObject.borrowObject(t.WeightData);var n=this._intArrayBuffer[a.offset+0];var s=this._intArrayBuffer[r+0];i.offset=r;for(var o=0;o0){if(e in this._dragonBonesDataMap){n=this._dragonBonesDataMap[e];s=n.getArmature(a)}}if(s===null&&(e.length===0||this.autoSearch)){for(var o in this._dragonBonesDataMap){n=this._dragonBonesDataMap[o];if(e.length===0||n.autoSearch){s=n.getArmature(a);if(s!==null){e=o;break}}}}if(s!==null){t.dataName=e;t.textureAtlasName=i;t.data=n;t.armature=s;t.skin=null;if(r.length>0){t.skin=s.getSkin(r);if(t.skin===null&&this.autoSearch){for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o];var h=l.getArmature(r);if(h!==null){t.skin=h.defaultSkin;break}}}}if(t.skin===null){t.skin=s.defaultSkin}return true}return false};e.prototype._buildBones=function(e,a){for(var r=0,i=e.armature.sortedBones;r0){o.texture=this._getTextureData(e.textureAtlasName,a.path)}if(r!==null&&r.type===2&&this._isSupportMesh()){s=i.meshDisplay}else{s=i.rawDisplay}break}case 2:{var l=a;if(l.texture===null){l.texture=this._getTextureData(n,l.path)}else if(e!==null&&e.textureAtlasName.length>0){l.texture=this._getTextureData(e.textureAtlasName,l.path)}if(this._isSupportMesh()){s=i.meshDisplay}else{s=i.rawDisplay}break}case 1:{var h=a;var f=this._buildChildArmature(e,i,a);if(f!==null){f.inheritAnimation=h.inheritAnimation;if(!f.inheritAnimation){var u=h.actions.length>0?h.actions:f.armatureData.defaultActions;if(u.length>0){for(var _=0,c=u;_=0){continue}var f=a.getDisplays(h.name);if(!f){if(s!==null&&a!==s){f=s.getDisplays(h.name)}if(!f){if(r){h.rawDisplayDatas=null;h.displayList=[]}continue}}var u=t.DragonBones.webAssembly?f.size():f.length;var _=h.displayList;_.length=u;for(var c=0,p=u;c0?this.width:e.width;var r=this.height>0?this.height:e.height;for(var i in this.textures){var n=egret.$TextureScaleFactor;var s=this.textures[i];var o=s.region.width;var l=s.region.height;if(s.renderTexture===null){s.renderTexture=new egret.Texture}s.renderTexture.bitmapData=e;if(s.rotated){s.renderTexture.$initData(s.region.x*n,s.region.y*n,l*n,o*n,0,0,l*n,o*n,a,r,s.rotated)}else{s.renderTexture.$initData(s.region.x*n,s.region.y*n,o*n,l*n,0,0,o*n,l*n,a,r)}}}else{for(var i in this.textures){var s=this.textures[i];s.renderTexture=null}}},enumerable:true,configurable:true});r.prototype.dispose=function(){console.warn("已废弃。");this.returnToPool()};Object.defineProperty(r.prototype,"texture",{get:function(){console.warn("已废弃。");return this.renderTexture},enumerable:true,configurable:true});return r}(t.TextureAtlasData);t.EgretTextureAtlasData=e;var a=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.renderTexture=null;return e}e.toString=function(){return"[class dragonBones.EgretTextureData]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);if(this.renderTexture!==null){}this.renderTexture=null};return e}(t.TextureData);t.EgretTextureData=a})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(a,e);function a(){return e!==null&&e.apply(this,arguments)||this}Object.defineProperty(a.prototype,"eventObject",{get:function(){return this.data},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animationName",{get:function(){var t=this.eventObject.animationState;return t!==null?t.name:""},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"armature",{get:function(){return this.eventObject.armature},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"bone",{get:function(){return this.eventObject.bone},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"slot",{get:function(){return this.eventObject.slot},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animationState",{get:function(){return this.eventObject.animationState},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"frameLabel",{get:function(){return this.eventObject.name},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"sound",{get:function(){return this.eventObject.name},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"movementID",{get:function(){return this.animationName},enumerable:true,configurable:true});a.START=t.EventObject.START;a.LOOP_COMPLETE=t.EventObject.LOOP_COMPLETE;a.COMPLETE=t.EventObject.COMPLETE;a.FADE_IN=t.EventObject.FADE_IN;a.FADE_IN_COMPLETE=t.EventObject.FADE_IN_COMPLETE;a.FADE_OUT=t.EventObject.FADE_OUT;a.FADE_OUT_COMPLETE=t.EventObject.FADE_OUT_COMPLETE;a.FRAME_EVENT=t.EventObject.FRAME_EVENT;a.SOUND_EVENT=t.EventObject.SOUND_EVENT;a.ANIMATION_FRAME_EVENT=t.EventObject.FRAME_EVENT;a.BONE_FRAME_EVENT=t.EventObject.FRAME_EVENT;a.MOVEMENT_FRAME_EVENT=t.EventObject.FRAME_EVENT;a.SOUND=t.EventObject.SOUND_EVENT;return a}(egret.Event);t.EgretEvent=e;var a=function(a){__extends(r,a);function r(){var t=a!==null&&a.apply(this,arguments)||this;t.debugDraw=false;t._batchEnabled=!(global["nativeRender"]||global["bricks"]);t._childDirty=true;t._debugDraw=false;t._armature=null;t._bounds=null;t._debugDrawer=null;return t}r._cleanBeforeRender=function(){};r.prototype.dbInit=function(t){this._armature=t;if(this._batchEnabled){this.$renderNode=new egret.sys.GroupNode;this.$renderNode.cleanBeforeRender=r._cleanBeforeRender}};r.prototype.dbClear=function(){this._armature=null;this._bounds=null;this._debugDrawer=null};r.prototype.dbUpdate=function(){var e=t.DragonBones.debugDraw||this.debugDraw;if(e||this._debugDraw){this._debugDraw=e;if(this._debugDraw){if(this._debugDrawer===null){this._debugDrawer=new egret.Sprite}if(this._debugDrawer.parent!==this){this.addChild(this._debugDrawer)}var a=2;var r=this._debugDrawer.graphics;r.clear();for(var i=0,n=this._armature.getBones();i0){i.setTo(999999,999999,-999999,-999999);for(var u=0,_=f.length;u<_;u+=2){var c=f[u];var p=f[u+1];if(i.x>c)i.x=c;if(i.widthp)i.y=p;if(i.heighte.width){e.width=g}if(b>e.height){e.height=b}}}e.width-=e.x;e.height-=e.y;if(t.isV5){if(this._bounds===null){this._bounds=new egret.Rectangle}this._bounds.copyFrom(e)}}else if(t.isV5){if(this._bounds===null){this._bounds=new egret.Rectangle}e.copyFrom(this._bounds)}return e}return a.prototype.$measureContentBounds.call(this,e)};r.prototype.hasEvent=function(t){return this.hasDBEventListener(t)};r.prototype.addEvent=function(t,e,a){this.addDBEventListener(t,e,a)};r.prototype.removeEvent=function(t,e,a){this.removeDBEventListener(t,e,a)};r.prototype.advanceTimeBySelf=function(e){if(e){this._armature.clock=t.EgretFactory.factory.clock}else{this._armature.clock=null}};return r}(egret.DisplayObjectContainer);t.EgretArmatureDisplay=a;var r=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(e);t.Event=r;var i=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(e);t.ArmatureEvent=i;var n=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(e);t.AnimationEvent=n;var s=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(e);t.FrameEvent=s;var o=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(e);t.SoundEvent=o;var l=function(e){__extends(a,e);function a(a,r,i){if(i===void 0){i=1}var n=e.call(this)||this;console.warn("已废弃");n._onClear();t.ObjectDataParser.getInstance().parseTextureAtlasData(r,n,i);n.renderTexture=a;return n}a.toString=function(){return"[class dragonBones.EgretTextureAtlas]"};return a}(t.EgretTextureAtlasData);t.EgretTextureAtlas=l;var h=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(l);t.EgretSheetAtlas=h;var f=function(){function e(){}e.getInstance=function(){console.warn("已废弃");return t.EgretFactory.factory.soundEventManager};return e}();t.SoundEventManager=f;var u=function(){function t(){console.warn("已废弃")}return t}();t.AnimationCacheManager=u})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(a,e);function a(){var t=e!==null&&e.apply(this,arguments)||this;t.transformUpdateEnabled=false;t._armatureDisplay=null;t._renderDisplay=null;t._colorFilter=null;return t}a.toString=function(){return"[class dragonBones.EgretSlot]"};a.prototype.init=function(a,r,i,n){e.prototype.init.call(this,a,r,i,n);if(t.isV5){this._updateTransform=this._updateTransformV5}else{this._updateTransform=this._updateTransformV4}};a.prototype._onClear=function(){e.prototype._onClear.call(this);this._armatureDisplay=null;this._renderDisplay=null;this._colorFilter=null};a.prototype._initDisplay=function(t,e){t;e};a.prototype._disposeDisplay=function(t,e){t;e};a.prototype._onUpdateDisplay=function(){this._armatureDisplay=this._armature.display;this._renderDisplay=this._display!==null?this._display:this._rawDisplay;if(t.isV5&&this._armatureDisplay._batchEnabled){if(this._renderDisplay===this._rawDisplay&&!(this._renderDisplay.$renderNode instanceof egret.sys.BitmapNode)){this._renderDisplay.$renderNode=new egret.sys.BitmapNode}}if(this._armatureDisplay._batchEnabled){if(this._renderDisplay!==this._rawDisplay&&this._renderDisplay!==this._meshDisplay){this._armatureDisplay.disableBatch()}else{var e=this._renderDisplay.$renderNode;if(!e.matrix){e.matrix=new egret.Matrix}}}};a.prototype._addDisplay=function(){if(this._armatureDisplay._batchEnabled){this._armatureDisplay.$renderNode.addNode(this._renderDisplay.$renderNode)}else{this._armatureDisplay.addChild(this._renderDisplay)}};a.prototype._replaceDisplay=function(t){var e=t;if(this._armatureDisplay._batchEnabled){var a=this._armatureDisplay.$renderNode.drawData;a[a.indexOf(e.$renderNode)]=this._renderDisplay.$renderNode}else{this._armatureDisplay.addChild(this._renderDisplay);this._armatureDisplay.swapChildren(this._renderDisplay,e);this._armatureDisplay.removeChild(e)}};a.prototype._removeDisplay=function(){if(this._armatureDisplay._batchEnabled){var t=this._armatureDisplay.$renderNode.drawData;t.splice(t.indexOf(this._renderDisplay.$renderNode),1)}else{this._renderDisplay.parent.removeChild(this._renderDisplay)}};a.prototype._updateZOrder=function(){if(this._armatureDisplay._batchEnabled){var t=this._armatureDisplay.$renderNode.drawData;t[this._zOrder]=this._renderDisplay.$renderNode}else{var e=this._armatureDisplay.getChildIndex(this._renderDisplay);if(e===this._zOrder){return}this._armatureDisplay.addChildAt(this._renderDisplay,this._zOrder)}};a.prototype._updateVisible=function(){var t=this._parent.visible&&this._visible;if(this._armatureDisplay._batchEnabled){var e=this._renderDisplay.$renderNode;e.alpha=t?1:0}else{this._renderDisplay.visible=t}};a.prototype._updateBlendMode=function(){switch(this._blendMode){case 0:this._renderDisplay.blendMode=egret.BlendMode.NORMAL;break;case 1:this._renderDisplay.blendMode=egret.BlendMode.ADD;break;case 5:this._renderDisplay.blendMode=egret.BlendMode.ERASE;break;default:break}if(this._armatureDisplay._batchEnabled){var t=this._renderDisplay.$renderNode;t.blendMode=egret.sys.blendModeToNumber(this._renderDisplay.blendMode)}};a.prototype._updateColor=function(){if(this._colorTransform.redMultiplier!==1||this._colorTransform.greenMultiplier!==1||this._colorTransform.blueMultiplier!==1||this._colorTransform.redOffset!==0||this._colorTransform.greenOffset!==0||this._colorTransform.blueOffset!==0||this._colorTransform.alphaOffset!==0){if(this._colorFilter===null){this._colorFilter=new egret.ColorMatrixFilter}var t=this._colorFilter.matrix;t[0]=this._colorTransform.redMultiplier;t[6]=this._colorTransform.greenMultiplier;t[12]=this._colorTransform.blueMultiplier;t[18]=this._colorTransform.alphaMultiplier;t[4]=this._colorTransform.redOffset;t[9]=this._colorTransform.greenOffset;t[14]=this._colorTransform.blueOffset;t[19]=this._colorTransform.alphaOffset;this._colorFilter.matrix=t;if(this._armatureDisplay._batchEnabled){var e=this._renderDisplay.$renderNode;e.filter=this._colorFilter;e.alpha=1}var a=this._renderDisplay.filters;if(!a){a=[]}if(a.indexOf(this._colorFilter)<0){a.push(this._colorFilter)}this._renderDisplay.filters=a;this._renderDisplay.alpha=1}else{if(this._armatureDisplay._batchEnabled){var e=this._renderDisplay.$renderNode;e.filter=null;e.alpha=this._colorTransform.alphaMultiplier}this._renderDisplay.filters=null;this._renderDisplay.alpha=this._colorTransform.alphaMultiplier}};a.prototype._updateFrame=function(){var e=this._deformVertices!==null&&this._display===this._meshDisplay?this._deformVertices.verticesData:null;var a=this._textureData;if(this._displayIndex>=0&&this._display!==null&&a!==null){if(this._armature.replacedTexture!==null&&this._rawDisplayDatas!==null&&this._rawDisplayDatas.indexOf(this._displayData)>=0){var r=a.parent;if(this._armature._replaceTextureAtlasData===null){r=t.BaseObject.borrowObject(t.EgretTextureAtlasData);r.copyFrom(a.parent);r.renderTexture=this._armature.replacedTexture;this._armature._replaceTextureAtlasData=r}else{r=this._armature._replaceTextureAtlasData}a=r.getTexture(a.name)}if(a.renderTexture!==null){if(e!==null){var i=e.data;var n=i.intArray;var s=i.floatArray;var o=n[e.offset+0];var l=n[e.offset+1];var h=n[e.offset+2];if(h<0){h+=65536}var f=h+o*2;var u=this._armature._armatureData.scale;var _=this._renderDisplay;var c=_.$renderNode;c.uvs.length=o*2;c.vertices.length=o*2;c.indices.length=l*3;for(var p=0,m=o*2;p0&&i.inheritDeform;var o=this._renderDisplay;var l=o.$renderNode;if(n!==null){var h=i.data;var f=h.intArray;var u=h.floatArray;var _=f[i.offset+0];var c=f[n.offset+1];if(c<0){c+=65536}for(var p=0,m=0,d=n.offset+2+r.length,v=c,y=0;p<_;++p){var g=f[d++];var b=0,D=0;for(var T=0;T=5.1;var e=function(e){__extends(a,e);function a(r){if(r===void 0){r=null}var i=e.call(this,r)||this;if(a._dragonBonesInstance===null){var n=new t.EgretArmatureDisplay;a._dragonBonesInstance=new t.DragonBones(n);a._time=egret.getTimer()*.001;egret.startTick(a._clockHandler,a)}i._dragonBones=a._dragonBonesInstance;return i}a._clockHandler=function(t){t*=.001;var e=t-this._time;a._dragonBonesInstance.advanceTime(e);this._time=t;return false};Object.defineProperty(a,"factory",{get:function(){if(a._factory===null){a._factory=new a}return a._factory},enumerable:true,configurable:true});a.prototype._isSupportMesh=function(){if(egret.Capabilities.renderMode==="webgl"||egret.Capabilities.runtimeType===egret.RuntimeType.NATIVE){return true}console.warn("Canvas can not support mesh, please change renderMode to webgl.");return false};a.prototype._buildTextureAtlasData=function(e,a){if(e!==null){if(a instanceof egret.Texture){e.renderTexture=a}else{var r=new egret.Texture;r.bitmapData=new egret.BitmapData(a);e.disposeEnabled=true;e.renderTexture=r}}else{e=t.BaseObject.borrowObject(t.EgretTextureAtlasData)}return e};a.prototype._buildArmature=function(e){var a=t.BaseObject.borrowObject(t.Armature);var r=new t.EgretArmatureDisplay;a.init(e.armature,r,r,this._dragonBones);return a};a.prototype._buildSlot=function(e,a,r){e;var i=t.BaseObject.borrowObject(t.EgretSlot);i.init(a,r,new egret.Bitmap,new egret.Mesh);return i};a.prototype.buildArmatureDisplay=function(t,e,a,r){if(e===void 0){e=""}if(a===void 0){a=""}if(r===void 0){r=""}var i=this.buildArmature(t,e||"",a||"",r||"");if(i!==null){this._dragonBones.clock.add(i);return i.display}return null};a.prototype.getTextureDisplay=function(t,e){if(e===void 0){e=null}var a=this._getTextureData(e!==null?e:"",t);if(a!==null&&a.renderTexture!==null){var r=a.renderTexture;var i=new egret.Bitmap(r);i.width=r.textureWidth*a.parent.scale;i.height=r.textureHeight*a.parent.scale;return i}return null};Object.defineProperty(a.prototype,"soundEventManager",{get:function(){return this._dragonBones.eventManager},enumerable:true,configurable:true});Object.defineProperty(a,"clock",{get:function(){return a.factory.clock},enumerable:true,configurable:true});a.prototype.addSkeletonData=function(t,e){if(e===void 0){e=null}console.warn("已废弃");this.addDragonBonesData(t,e)};a.prototype.getSkeletonData=function(t){console.warn("已废弃");return this.getDragonBonesData(t)};a.prototype.removeSkeletonData=function(t){console.warn("已废弃");this.removeDragonBonesData(t)};a.prototype.addTextureAtlas=function(t,e){if(e===void 0){e=null}console.warn("已废弃");this.addTextureAtlasData(t,e)};a.prototype.getTextureAtlas=function(t){console.warn("已废弃");return this.getTextureAtlasData(t)};a.prototype.removeTextureAtlas=function(t){console.warn("已废弃");this.removeTextureAtlasData(t)};a.prototype.buildFastArmature=function(t,e,a){if(e===void 0){e=""}if(a===void 0){a=""}console.warn("已废弃");return this.buildArmature(t,e||"",a||"")};a.prototype.dispose=function(){console.warn("已废弃");this.clear()};a._time=0;a._dragonBonesInstance=null;a._factory=null;return a}(t.BaseFactory);t.EgretFactory=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=new egret.Rectangle;var a=new egret.Matrix;var r={};function i(t,e){for(var a=0,r=t.length;a=0){e.displayConfig=this._groupConfig.display[e.displayIndex];if(e.displayConfig.type===1){var i=e.displayConfig.name in e.childMovies?e.childMovies[e.displayConfig.name]:null;if(!i){i=f(e.displayConfig.name,this._groupConfig.name);if(i){e.childMovies[e.displayConfig.name]=i}}if(i){e.display=i;e.childMovie=i}else{e.display=e.rawDisplay;e.childMovie=null}}else{e.display=e.rawDisplay;e.childMovie=null}}else{e.displayConfig=null;e.display=e.rawDisplay;e.childMovie=null}if(e.display!==a){if(a){this.addChild(e.display);this.swapChildren(e.display,a);this.removeChild(a)}this._updateSlotBlendMode(e)}if(e.display===e.rawDisplay){if(e.displayConfig&&e.displayConfig.regionIndex!==null&&e.displayConfig.regionIndex!==undefined){if(!e.displayConfig.texture){var n=this._groupConfig.textures[e.displayConfig.textureIndex||0];var s=e.displayConfig.regionIndex*4;var o=this._groupConfig.rectangleArray[s];var l=this._groupConfig.rectangleArray[s+1];var h=this._groupConfig.rectangleArray[s+2];var u=this._groupConfig.rectangleArray[s+3];e.displayConfig.texture=new egret.Texture;e.displayConfig.texture.bitmapData=n.bitmapData;e.displayConfig.texture.$initData(o,l,Math.min(h,n.textureWidth-o),Math.min(u,n.textureHeight-l),0,0,Math.min(h,n.textureWidth-o),Math.min(u,n.textureHeight-l),n.textureWidth,n.textureHeight)}if(this._batchEnabled){var _=e.displayConfig.texture;var c=e.rawDisplay.$renderNode;egret.sys.RenderNode.prototype.cleanBeforeRender.call(e.rawDisplay.$renderNode);c.image=_.bitmapData;if(t.isV5){c.drawImage(_.$bitmapX,_.$bitmapY,_.$bitmapWidth,_.$bitmapHeight,_.$offsetX,_.$offsetY,_.textureWidth,_.textureHeight);c.imageWidth=_._sourceWidth;c.imageHeight=_._sourceHeight}else{var p=_;c.drawImage(p._bitmapX,p._bitmapY,p._bitmapWidth,p._bitmapHeight,p._offsetX,p._offsetY,_.textureWidth,_.textureHeight);c.imageWidth=p._sourceWidth;c.imageHeight=p._sourceHeight}}else{e.rawDisplay.visible=true;e.rawDisplay.$setBitmapData(e.displayConfig.texture)}}else{if(this._batchEnabled){e.rawDisplay.$renderNode.image=null}else{e.rawDisplay.visible=false;e.rawDisplay.$setBitmapData(null)}}}if(e.childMovie!==r){if(r){r.stop();this._childMovies.slice(this._childMovies.indexOf(r),1)}if(e.childMovie){if(this._childMovies.indexOf(e.childMovie)<0){this._childMovies.push(e.childMovie)}if(e.config.action){e.childMovie.play(e.config.action)}else{e.childMovie.play(e.childMovie._config.action)}}}};i.prototype._getSlot=function(t){for(var e=0,a=this._slots.length;e0&&(s>=n||s<=-n)){this._isCompleted=true;o=this._playTimes;if(s<0){s=0}else{s=i}}else{this._isCompleted=false;if(s<0){o=Math.floor(-s/i);s=i- -s%i}else{o=Math.floor(s/i);s%=i}if(this._playTimes>0&&o>this._playTimes){o=this._playTimes}}if(this._currentTime===s){return}var l=Math.floor(s*this._clipConfig.cacheTimeToFrameScale);if(this._cacheFrameIndex!==l){this._cacheFrameIndex=l;var h=this._groupConfig.displayFrameArray;var f=this._groupConfig.transformArray;var u=this._groupConfig.colorArray;var c=true;var p=false;var m=false;var d=this._cacheRectangle;this._cacheRectangle=this._clipConfig.cacheRectangles[this._cacheFrameIndex];if(this._batchEnabled&&!this._cacheRectangle){m=true;this._cacheRectangle=new egret.Rectangle;this._clipConfig.cacheRectangles[this._cacheFrameIndex]=this._cacheRectangle}for(var v=0,y=this._slots.length;v=this._clipArray.length){b=this._frameSize*(this._cacheFrameIndex-1)+v*2}var D=this._clipArray[b]*2;if(D>=0){var T=h[D];var A=h[D+1]*8;var x=this._clipArray[b+1]*6;var P=false;if(g.displayIndex!==T){g.displayIndex=T;P=true;this._updateSlotDisplay(g)}if(g.colorIndex!==A||P){g.colorIndex=A;if(g.colorIndex>=0){this._updateSlotColor(g,u[A]*.01,u[A+1]*.01,u[A+2]*.01,u[A+3]*.01,u[A+4],u[A+5],u[A+6],u[A+7])}else{this._updateSlotColor(g,1,1,1,1,0,0,0,0)}}p=true;if(g.transformIndex!==x){g.transformIndex=x;if(this._batchEnabled){var O=g.display.$renderNode.matrix;if(!O){O=g.display.$renderNode.matrix=new egret.Matrix}O.a=f[x];O.b=f[x+1];O.c=f[x+2];O.d=f[x+3];O.tx=f[x+4];O.ty=f[x+5]}else{a.a=f[x];a.b=f[x+1];a.c=f[x+2];a.d=f[x+3];a.tx=f[x+4];a.ty=f[x+5];g.display.$setMatrix(a)}}if(this._batchEnabled&&m&&g.displayConfig){var O=g.display.$renderNode.matrix;e.x=0;e.y=0;e.width=g.displayConfig.texture.textureWidth;e.height=g.displayConfig.texture.textureHeight;O.$transformBounds(e);if(c){c=false;this._cacheRectangle.x=e.x;this._cacheRectangle.width=e.x+e.width;this._cacheRectangle.y=e.y;this._cacheRectangle.height=e.y+e.height}else{this._cacheRectangle.x=Math.min(this._cacheRectangle.x,e.x);this._cacheRectangle.width=Math.max(this._cacheRectangle.width,e.x+e.width);this._cacheRectangle.y=Math.min(this._cacheRectangle.y,e.y);this._cacheRectangle.height=Math.max(this._cacheRectangle.height,e.y+e.height)}}}else if(g.displayIndex!==-1){g.displayIndex=-1;this._updateSlotDisplay(g)}}if(this._cacheRectangle){if(p&&m&&c&&d){this._cacheRectangle.x=d.x;this._cacheRectangle.y=d.y;this._cacheRectangle.width=d.width;this._cacheRectangle.height=d.height}if(!t.isV5){this.$invalidateContentBounds()}}}if(this._isCompleted){this._isPlaying=false}if(!this._isStarted){this._isStarted=true;if(this.hasEventListener(_.START)){var S=egret.Event.create(_,_.START);S.movie=this;S.clipName=this._clipConfig.name;S.name="";S.slotName="";this.dispatchEvent(S)}}this._isReversing=this._currentTime>s&&this._currentPlayTimes===o;this._currentTime=s;var E=this._clipConfig.frame?this._clipConfig.frame.length:0;if(E>0){var M=Math.floor(this._currentTime*this._config.frameRate);var B=this._groupConfig.frame[this._clipConfig.frame[M]];if(this._currentFrameConfig!==B){if(E>1){var C=this._currentFrameConfig;this._currentFrameConfig=B;if(!C){var w=Math.floor(this._currentTime*this._config.frameRate);C=this._groupConfig.frame[this._clipConfig.frame[w]];if(this._isReversing){}else{if(this._currentTime<=C.position||this._currentPlayTimes!==o){C=this._groupConfig.frame[C.prev]}}}if(this._isReversing){while(C!==B){this._onCrossFrame(C);C=this._groupConfig.frame[C.prev]}}else{while(C!==B){C=this._groupConfig.frame[C.next];this._onCrossFrame(C)}}}else{this._currentFrameConfig=B;if(this._currentFrameConfig){this._onCrossFrame(this._currentFrameConfig)}}}}if(this._currentPlayTimes!==o){this._currentPlayTimes=o;if(this.hasEventListener(_.LOOP_COMPLETE)){var I=egret.Event.create(_,_.LOOP_COMPLETE);I.movie=this;I.clipName=this._clipConfig.name;I.name="";I.slotName="";this.dispatchEvent(I);egret.Event.release(I)}if(this._isCompleted&&this.hasEventListener(_.COMPLETE)){var F=egret.Event.create(_,_.COMPLETE);F.movie=this;F.clipName=this._clipConfig.name;F.name="";F.slotName="";this.dispatchEvent(F);egret.Event.release(F)}}}this._isLockDispose=false;if(this._isDelayDispose){this.dispose()}};i.prototype.play=function(t,e){if(t===void 0){t=null}if(e===void 0){e=-1}if(t){var a=null;for(var r=0,i=this._config.clip.length;r = T | null; - /** - * The HashObject class is the base class for all objects in the Egret framework.The HashObject - * class includes a hashCode property, which is a unique identification number of the instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Egret顶级对象。框架内所有对象的基类,为对象实例提供唯一的hashCode值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface IHashObject { - /** - * a unique identification number assigned to this instance. - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 返回此对象唯一的哈希值,用于唯一确定一个对象。hashCode为大于等于1的整数。 - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - hashCode: number; - } - /** - * @private - * 哈希计数 - */ - let $hashCount: number; - /** - * The HashObject class is the base class for all objects in the Egret framework.The HashObject - * class includes a hashCode property, which is a unique identification number of the instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Egret顶级对象。框架内所有对象的基类,为对象实例提供唯一的hashCode值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HashObject implements IHashObject { - /** - * Initializes a HashObject - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 HashObject 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - $hashCode: number; - /** - * a unique identification number assigned to this instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此对象唯一的哈希值,用于唯一确定一个对象。hashCode为大于等于1的整数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly hashCode: number; - } -} -declare namespace egret { - /** - * The EventDispatcher class is the base class for all classes that dispatchEvent events. The EventDispatcher class implements - * the IEventDispatcher interface and is the base class for the DisplayObject class. The EventDispatcher class allows - * any object on the display list to be an event target and as such, to use the methods of the IEventDispatcher interface. - * Event targets are an important part of the Egret event model. The event target serves as the focal point for how events - * flow through the display list hierarchy. When an event such as a touch tap, Egret dispatches an event object into the - * event flow from the root of the display list. The event object then makes its way through the display list until it - * reaches the event target, at which point it begins its return trip through the display list. This round-trip journey - * to the event target is conceptually divided into three phases:
- * the capture phase comprises the journey from the root to the last node before the event target's node, the target - * phase comprises only the event target node, and the bubbling phase comprises any subsequent nodes encountered on - * the return trip to the root of the display list. In general, the easiest way for a user-defined class to gain event - * dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already extending - * another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, and write simple - * hooks to route calls into the aggregated EventDispatcher. - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language en_US - */ - /** - * EventDispatcher 是 Egret 的事件派发器类,负责进行事件的发送和侦听。 - * 事件目标是事件如何通过显示列表层次结构这一问题的焦点。当发生鼠标单击、触摸或按键等事件时, - * 框架会将事件对象调度到从显示列表根开始的事件流中。然后该事件对象在显示列表中前进,直到到达事件目标, - * 然后从这一点开始其在显示列表中的回程。在概念上,到事件目标的此往返行程被划分为三个阶段: - * 捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括回程上遇到的任何后续节点到显示列表的根。 - * 通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。如果无法扩展(即,如果该类已经扩展了另一个类),则可以实现 - * IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的映射,将调用连接到聚合的 EventDispatcher 中。 - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language zh_CN - */ - class EventDispatcher extends HashObject implements IEventDispatcher { - /** - * create an instance of the EventDispatcher class. - * @param target The target object for events dispatched to the EventDispatcher object. This parameter is used when - * the EventDispatcher instance is aggregated by a class that implements IEventDispatcher; it is necessary so that the - * containing object can be the target for events. Do not use this parameter in simple cases in which a class extends EventDispatcher. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 EventDispatcher 类的实例 - * @param target 此 EventDispatcher 所抛出事件对象的 target 指向。此参数主要用于一个实现了 IEventDispatcher 接口的自定义类, - * 以便抛出的事件对象的 target 属性可以指向自定义类自身。请勿在直接继承 EventDispatcher 的情况下使用此参数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(target?: IEventDispatcher); - /** - * @private - */ - $EventDispatcher: Object; - /** - * @private - * - * @param useCapture - */ - $getEventMap(useCapture?: boolean): any; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - once(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * @private - */ - $addListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): void; - $insertEventBin(list: any[], type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - $removeEventBin(list: any[], listener: Function, thisObject: any): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - hasEventListener(type: string): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - willTrigger(type: string): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - dispatchEvent(event: Event): boolean; - /** - * @private - */ - $notifyListener(event: Event, capturePhase: boolean): boolean; - /** - * Distribute a specified event parameters. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个指定参数的事件。 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispatchEventWith(type: string, bubbles?: boolean, data?: any, cancelable?: boolean): boolean; - } -} -declare namespace egret.sys { - /** - * @private - * 事件信息对象 - */ - interface EventBin { - type: string; - /** - * @private - */ - listener: Function; - /** - * @private - */ - thisObject: any; - /** - * @private - */ - priority: number; - /** - * @private - */ - target: IEventDispatcher; - /** - * @private - */ - useCapture: boolean; - /** - * @private - */ - dispatchOnce: boolean; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class Filter extends HashObject { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - type: string; - /** - * @private - */ - $id: number; - /** - * @private - */ - $uniforms: any; - /** - * @private - */ - protected paddingTop: number; - /** - * @private - */ - protected paddingBottom: number; - /** - * @private - */ - protected paddingLeft: number; - /** - * @private - */ - protected paddingRight: number; - /** - * @private - * @native Render - */ - $obj: any; - constructor(); - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - onPropertyChange(): void; - } -} -declare namespace egret { - /** - * @private - */ - const enum RenderMode { - NONE = 1, - FILTER = 2, - CLIP = 3, - SCROLLRECT = 4, - } - /** - * The DisplayObject class is the base class for all objects that can be placed on the display list. The display list - * manages all objects displayed in the runtime. Use the DisplayObjectContainer class to arrange the display - * objects in the display list. DisplayObjectContainer objects can have child display objects, while other display objects, - * such as Shape and TextField objects, are "leaf" nodes that have only parents and siblings, no children. - * The DisplayObject class supports basic functionality like the x and y position of an object, as well as more advanced - * properties of the object such as its transformation matrix.
- * The DisplayObject class contains several broadcast events.Normally, the target of any particular event is a specific - * DisplayObject instance. For example, the target of an added event is the specific DisplayObject instance that was added - * to the display list. Having a single target restricts the placement of event listeners to that target and in some cases - * the target's ancestors on the display list. With broadcast events, however, the target is not a specific DisplayObject - * instance, but rather all DisplayObject instances, including those that are not on the display list. This means that you - * can add a listener to any DisplayObject instance to listen for broadcast events. - * - * @event egret.Event.ADDED Dispatched when a display object is added to the display list. - * @event egret.Event.ADDED_TO_STAGE Dispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained. - * @event egret.Event.REMOVED Dispatched when a display object is about to be removed from the display list. - * @event egret.Event.REMOVED_FROM_STAGE Dispatched when a display object is about to be removed from the display list, either directly or through the removal of a sub tree in which the display object is contained. - * @event egret.Event.ENTER_FRAME [broadcast event] Dispatched when the playhead is entering a new frame. - * @event egret.Event.RENDER [broadcast event] Dispatched when the display list is about to be updated and rendered. - * @event egret.TouchEvent.TOUCH_MOVE Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @event egret.TouchEvent.TOUCH_BEGIN Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_END Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_TAP Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language en_US - */ - /** - * DisplayObject 类是可放在显示列表中的所有对象的基类。该显示列表管理运行时中显示的所有对象。使用 DisplayObjectContainer 类排列 - * 显示列表中的显示对象。DisplayObjectContainer 对象可以有子显示对象,而其他显示对象(如 Shape 和 TextField 对象)是“叶”节点,没有子项,只有父级和 - * 同级。DisplayObject 类有一些基本的属性(如确定坐标位置的 x 和 y 属性),也有一些高级的对象属性(如 Matrix 矩阵变换)。
- * DisplayObject 类包含若干广播事件。通常,任何特定事件的目标均为一个特定的 DisplayObject 实例。例如,added 事件的目标是已添加到显示列表 - * 的目标 DisplayObject 实例。若只有一个目标,则会将事件侦听器限制为只能监听在该目标上(在某些情况下,可监听在显示列表中该目标的祖代上)。 - * 但是对于广播事件,目标不是特定的 DisplayObject 实例,而是所有 DisplayObject 实例(包括那些不在显示列表中的实例)。这意味着您可以向任何 - * DisplayObject 实例添加侦听器来侦听广播事件。 - * - * @event egret.Event.ADDED 将显示对象添加到显示列表中时调度。 - * @event egret.Event.ADDED_TO_STAGE 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @event egret.Event.REMOVED 将要从显示列表中删除显示对象时调度。 - * @event egret.Event.REMOVED_FROM_STAGE 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @event egret.Event.ENTER_FRAME [广播事件] 播放头进入新帧时调度。 - * @event egret.Event.RENDER [广播事件] 将要更新和呈现显示列表时调度。 - * @event egret.TouchEvent.TOUCH_MOVE 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @event egret.TouchEvent.TOUCH_BEGIN 当用户第一次触摸启用触摸的设备时(例如,用手指触摸手机屏幕)调度。 - * @event egret.TouchEvent.TOUCH_END 当用户移除与启用触摸的设备的接触时(例如,将手指从屏幕上抬起)调度。 - * @event egret.TouchEvent.TOUCH_TAP 当用户在启用触摸设备上的已启动接触的同一 DisplayObject 实例上抬起接触点时(例如,手机点击屏幕后抬起)调度。 - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE 当用户在启用触摸设备上的已启动接触的不同 DisplayObject 实例上抬起接触点时(例如,按住屏幕上的某个对象,然后从它上面挪开后再松开手指)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language zh_CN - */ - class DisplayObject extends EventDispatcher { - /** - * Initializes a DisplayObject object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个显示对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - $nativeDisplayObject: egret_native.NativeDisplayObject; - protected createNativeDisplayObject(): void; - /** - * @private - * 是否添加到舞台上,防止重复发送 removed_from_stage 消息 - */ - $hasAddToStage: boolean; - /** - * @private - * 能够含有子项的类将子项列表存储在这个属性里。 - */ - $children: DisplayObject[]; - private $name; - /** - * Indicates the instance name of the DisplayObject. The object can be identified in the child list of its parent - * display object container by calling the getChildByName() method of the display object container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 的实例名称。 - * 通过调用父显示对象容器的 getChildByName() 方法,可以在父显示对象容器的子列表中标识该对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * @private - */ - $parent: DisplayObjectContainer; - /** - * Indicates the DisplayObjectContainer object that contains this display object. Use the parent property to specify - * a relative path to display objects that are above the current display object in the display list hierarchy. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示包含此显示对象的 DisplayObjectContainer 对象。 - * 使用 parent 属性可以指定高于显示列表层次结构中当前显示对象的显示对象的相对路径。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly parent: DisplayObjectContainer; - /** - * @private - * 设置父级显示对象 - */ - $setParent(parent: DisplayObjectContainer): void; - /** - * @private - * 显示对象添加到舞台 - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * 显示对象从舞台移除 - */ - $onRemoveFromStage(): void; - /** - * @private - */ - $stage: Stage; - /** - * @private - * 这个对象在显示列表中的嵌套深度,舞台为1,它的子项为2,子项的子项为3,以此类推。当对象不在显示列表中时此属性值为0. - */ - $nestLevel: number; - $useTranslate: boolean; - protected $updateUseTransform(): void; - /** - * The Stage of the display object. you can create and load multiple display objects into the display list, and - * the stage property of each display object refers to the same Stage object.
- * If a display object is not added to the display list, its stage property is set to null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的舞台。 - * 例如,您可以创建多个显示对象并加载到显示列表中,每个显示对象的 stage 属性是指向相同的 Stage 对象。
- * 如果显示对象未添加到显示列表,则其 stage 属性会设置为 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stage: Stage; - /** - * A Matrix object containing values that alter the scaling, rotation, and translation of the display object.
- * Note: to change the value of a display object's matrix, you must make a copy of the entire matrix object, then copy - * the new object into the matrix property of the display object. - * @example the following code increases the tx value of a display object's matrix - *
-         *     let myMatrix:Matrix = myDisplayObject.matrix;
-         *     myMatrix.tx += 10;
-         *     myDisplayObject.matrix = myMatrix;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个 Matrix 对象,其中包含更改显示对象的缩放、旋转和平移的值。
- * 注意:要改变一个显示对象矩阵的值,您必引用整个矩阵对象,然后将它重新赋值给显示对象的 matrix 属性。 - * @example 以下代码改变了显示对象矩阵的tx属性值: - *
-         *     let myMatrix:Matrix = myDisplayObject.matrix;
-         *     myMatrix.tx += 10;
-         *     myDisplayObject.matrix = myMatrix;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - matrix: Matrix; - private $matrix; - private $matrixDirty; - /** - * @private - * 获取矩阵 - */ - $getMatrix(): Matrix; - /** - * @private - * 设置矩阵 - */ - $setMatrix(matrix: Matrix, needUpdateProperties?: boolean): void; - private $concatenatedMatrix; - /** - * @private - * 获得这个显示对象以及它所有父级对象的连接矩阵。 - */ - $getConcatenatedMatrix(): Matrix; - private $invertedConcatenatedMatrix; - /** - * @private - * 获取链接矩阵 - */ - $getInvertedConcatenatedMatrix(): Matrix; - $x: number; - /** - * Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
- * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer - * rotated 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is - * rotated 90° counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 x 坐标。
- * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * @private - * 获取x坐标 - */ - $getX(): number; - /** - * @private - * 设置x坐标 - */ - $setX(value: number): boolean; - $y: number; - /** - * Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
- * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer rotated - * 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is rotated 90° - * counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 y 坐标。
- * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * @private - * 获取y坐标 - */ - $getY(): number; - /** - * @private - * 设置y坐标 - */ - $setY(value: number): boolean; - private $scaleX; - /** - * Indicates the horizontal scale (percentage) of the object as applied from the registration point.
- * The default 1.0 equals 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从注册点开始应用的对象的水平缩放比例(百分比)。
- * 1.0 等于 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scaleX: number; - /** - * @private - * - * @returns - */ - $getScaleX(): number; - /** - * @private - * 设置水平缩放值 - */ - $setScaleX(value: number): void; - private $scaleY; - /** - * Indicates the vertical scale (percentage) of an object as applied from the registration point of the object. - * 1.0 is 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象注册点开始应用的对象的垂直缩放比例(百分比)。1.0 是 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scaleY: number; - /** - * @private - * - * @returns - */ - $getScaleY(): number; - /** - * @private - * 设置垂直缩放值 - */ - $setScaleY(value: number): void; - private $rotation; - /** - * Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation. Values from - * 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside - * this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement - * myDisplayObject.rotation = 450 is the same as myDisplayObject.rotation = 90. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例距其原始方向的旋转程度,以度为单位。 - * 从 0 到 180 的值表示顺时针方向旋转;从 0 到 -180 的值表示逆时针方向旋转。对于此范围之外的值,可以通过加上或 - * 减去 360 获得该范围内的值。例如,myDisplayObject.rotation = 450语句与 myDisplayObject.rotation = 90 是相同的。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotation: number; - /** - * @private - */ - $getRotation(): number; - $setRotation(value: number): void; - private $skewX; - private $skewXdeg; - /** - * 表示DisplayObject的x方向斜切 - * @member {number} egret.DisplayObject#skewX - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - skewX: number; - /** - * @private - * - * @param value - */ - $setSkewX(value: number): void; - private $skewY; - private $skewYdeg; - /** - * 表示DisplayObject的y方向斜切 - * @member {number} egret.DisplayObject#skewY - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - skewY: number; - /** - * @private - * - * @param value - */ - $setSkewY(value: number): void; - /** - * Indicates the width of the display object, in pixels. The width is calculated based on the bounds of the content - * of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的宽度,以像素为单位。宽度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - $explicitWidth: number; - /** - * @private - * 设置显示宽度 - */ - $setWidth(value: number): void; - /** - * Indicates the height of the display object, in pixels. The height is calculated based on the bounds of the - * content of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的高度,以像素为单位。高度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - $explicitHeight: number; - /** - * @private - * 获取显示高度 - */ - $getHeight(): number; - /** - * @private - * 设置显示高度 - */ - $setHeight(value: number): void; - /** - * 测量宽度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - readonly measuredWidth: number; - /** - * 测量高度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - readonly measuredHeight: number; - $anchorOffsetX: number; - /** - * X represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点X。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - anchorOffsetX: number; - /** - * @private - * - * @param value - * @returns - */ - $setAnchorOffsetX(value: number): void; - $anchorOffsetY: number; - /** - * Y represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点Y。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - anchorOffsetY: number; - /** - * @private - * - * @param value - * @returns - */ - $setAnchorOffsetY(value: number): void; - /** - * @private - */ - $visible: boolean; - /** - * Whether or not the display object is visible. Display objects that are not visible are disabled. For example, - * if visible=false for an DisplayObject instance, it cannot receive touch or other user input. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象是否可见。不可见的显示对象将被禁用。例如,如果实例的 visible 为 false,则无法接受触摸或用户交互操作。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - visible: boolean; - $setVisible(value: boolean): void; - /** - * @private - * cacheAsBitmap创建的缓存位图节点。 - */ - $displayList: egret.sys.DisplayList; - private $cacheAsBitmap; - /** - * If set to true, Egret runtime caches an internal bitmap representation of the display object. This caching can - * increase performance for display objects that contain complex vector content. After you set the cacheAsBitmap - * property to true, the rendering does not change, however the display object performs pixel snapping automatically. - * The execution speed can be significantly faster depending on the complexity of the content.The cacheAsBitmap - * property is best used with display objects that have mostly static content and that do not scale and rotate frequently.
- * Note: The display object will not create the bitmap caching when the memory exceeds the upper limit,even if you set it to true. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果设置为 true,则 Egret 运行时将缓存显示对象的内部位图表示形式。此缓存可以提高包含复杂矢量内容的显示对象的性能。 - * 将 cacheAsBitmap 属性设置为 true 后,呈现并不更改,但是,显示对象将自动执行像素贴紧。执行速度可能会大大加快, - * 具体取决于显示对象内容的复杂性。最好将 cacheAsBitmap 属性与主要具有静态内容且不频繁缩放或旋转的显示对象一起使用。
- * 注意:在内存超过上限的情况下,即使将 cacheAsBitmap 属性设置为 true,显示对象也不使用位图缓存。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - cacheAsBitmap: boolean; - $setHasDisplayList(value: boolean): void; - $cacheDirty: boolean; - $cacheDirtyUp(): void; - /** - * @private - */ - $alpha: number; - /** - * Indicates the alpha transparency value of the object specified. Valid values are 0 (fully transparent) to 1 (fully opaque). - * The default value is 1. Display objects with alpha set to 0 are active, even though they are invisible. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示指定对象的 Alpha 透明度值。 - * 有效值为 0(完全透明)到 1(完全不透明)。alpha 设置为 0 的显示对象是可触摸的,即使它们不可见。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - alpha: number; - /** - * @private - * - * @param value - */ - $setAlpha(value: number): void; - /** - * @private - * The default touchEnabled property of DisplayObject - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * @private - * 显示对象默认的 touchEnabled 属性 - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - static defaultTouchEnabled: boolean; - $touchEnabled: boolean; - /** - * Specifies whether this object receives touch or other user input. The default value is false, which means that - * by default any DisplayObject instance that is on the display list cannot receive touch events. If touchEnabled is - * set to false, the instance does not receive any touch events (or other user input events). Any children of - * this instance on the display list are not affected. To change the touchEnabled behavior for all children of - * an object on the display list, use DisplayObjectContainer.touchChildren. - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定此对象是否接收触摸或其他用户输入。默认值为 false,这表示默认情况下,显示列表上的任何 DisplayObject 实例都不会接收触摸事件或 - * 其他用户输入事件。如果将 touchEnabled 设置为 false,则实例将不接收任何触摸事件(或其他用户输入事件)。显示列表上的该实例的任 - * 何子级都不会受到影响。要更改显示列表上对象的所有子级的 touchEnabled 行为,请使用 DisplayObjectContainer.touchChildren。 - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchEnabled: boolean; - /** - * @private - */ - $getTouchEnabled(): boolean; - /** - * @private - */ - $setTouchEnabled(value: boolean): void; - /** - * @private - */ - $scrollRect: Rectangle; - /** - * The scroll rectangle bounds of the display object. The display object is cropped to the size defined by the rectangle, - * and it scrolls within the rectangle when you change the x and y properties of the scrollRect object. A scrolled display - * object always scrolls in whole pixel increments.You can scroll an object left and right by setting the x property of - * the scrollRect Rectangle object. You can scroll an object up and down by setting the y property of the scrollRect - * Rectangle object. If the display object is rotated 90° and you scroll it left and right, the display object actually - * scrolls up and down.
- * - * Note: to change the value of a display object's scrollRect, you must make a copy of the entire scrollRect object, then copy - * the new object into the scrollRect property of the display object. - * @example the following code increases the x value of a display object's scrollRect - *
-         *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
-         *     myRectangle.x += 10;
-         *     myDisplayObject.scrollRect = myRectangle;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的滚动矩形范围。显示对象被裁切为矩形定义的大小,当您更改 scrollRect 对象的 x 和 y 属性时,它会在矩形内滚动。 - * 滚动的显示对象始终以整像素为增量进行滚动。您可以通过设置 scrollRect Rectangle 对象的 x 属性来左右滚动对象, 还可以通过设置 - * scrollRect 对象的 y 属性来上下滚动对象。如果显示对象旋转了 90 度,并且您左右滚动它,则实际上显示对象会上下滚动。
- * - * 注意:要改变一个显示对象 scrollRect 属性的值,您必引用整个 scrollRect 对象,然后将它重新赋值给显示对象的 scrollRect 属性。 - * @example 以下代码改变了显示对象 scrollRect 的 x 属性值: - *
-         *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
-         *     myRectangle.x += 10;
-         *     myDisplayObject.scrollRect = myRectangle;//设置完scrollRect的x、y、width、height值之后,一定要对myDisplayObject重新赋值scrollRect,不然会出问题。
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollRect: Rectangle; - /** - * @private - * - * @param value - */ - private $setScrollRect(value); - /** - * @private - */ - $blendMode: number; - /** - * A value from the BlendMode class that specifies which blend mode to use. Determine how a source image (new one) - * is drawn on the target image (old one).
- * If you attempt to set this property to an invalid value, Egret runtime set the value to BlendMode.NORMAL. - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BlendMode 枚举中的一个值,用于指定要使用的混合模式,确定如何将一个源(新的)图像绘制到目标(已有)的图像上
- * 如果尝试将此属性设置为无效值,则运行时会将此值设置为 BlendMode.NORMAL。 - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - blendMode: string; - /** - * @private - * 被遮罩的对象 - */ - $maskedObject: DisplayObject; - /** - * @private - */ - $mask: DisplayObject; - /** - * @private - */ - $maskRect: Rectangle; - /** - * The calling display object is masked by the specified mask object. To ensure that masking works when the Stage - * is scaled, the mask display object must be in an active part of the display list. The mask object itself is not drawn. - * Set mask to null to remove the mask. To be able to scale a mask object, it must be on the display list. To be - * able to drag a mask object , it must be on the display list.
- * Note: A single mask object cannot be used to mask more than one calling display object. When the mask is assigned - * to a second display object, it is removed as the mask of the first object, and that object's mask property becomes null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用显示对象被指定的 mask 对象遮罩。要确保当舞台缩放时蒙版仍然有效,mask 显示对象必须处于显示列表的活动部分。 - * 但不绘制 mask 对象本身。将 mask 设置为 null 可删除蒙版。要能够缩放遮罩对象,它必须在显示列表中。要能够拖动蒙版 - * 对象,它必须在显示列表中。
- * 注意:单个 mask 对象不能用于遮罩多个执行调用的显示对象。在将 mask 分配给第二个显示对象时,会撤消其作为第一个对象的遮罩, - * 该对象的 mask 属性将变为 null。 - * - * 下面例子为 mask 为 Rectangle 类型对象,这种情况下,修改 mask 的值后,一定要对 myDisplayObject 重新赋值 mask,不然会出问题。 - * @example 以下代码改变了显示对象 mask 的 x 属性值: - *
-         *     let myMask:Rectangle = myDisplayObject.mask;
-         *     myMask.x += 10;
-         *     myDisplayObject.mask = myMask;//设置完 mask 的x、y、width、height值之后,一定要对myDisplayObject重新赋值 mask,不然会出问题。
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - mask: DisplayObject | Rectangle; - private $setMaskRect(value); - $filters: Array; - /** - * An indexed array that contains each filter object currently associated with the display object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 包含当前与显示对象关联的每个滤镜对象的索引数组。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - filters: Array; - /** - * Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object. - * @param targetCoordinateSpace The display object that defines the coordinate system to use. - * @param resultRect A reusable instance of Rectangle for saving the results. Passing this parameter can reduce the number of reallocate objects - *, which allows you to get better code execution performance.. - * @returns The rectangle that defines the area of the display object relative to the targetCoordinateSpace object's coordinate system. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个矩形,该矩形定义相对于 targetCoordinateSpace 对象坐标系的显示对象区域。 - * @param targetCoordinateSpace 定义要使用的坐标系的显示对象。 - * @param resultRect 一个用于存储结果的可复用Rectangle实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 定义与 targetCoordinateSpace 对象坐标系统相关的显示对象面积的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTransformedBounds(targetCoordinateSpace: DisplayObject, resultRect?: Rectangle): Rectangle; - /** - * Obtain measurement boundary of display object - * @param resultRect {Rectangle} Optional. It is used to import Rectangle object for saving results, preventing duplicate object creation. - * @param calculateAnchor {boolean} Optional. It is used to determine whether to calculate anchor point. - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取显示对象的测量边界 - * @param resultRect {Rectangle} 可选参数,传入用于保存结果的Rectangle对象,避免重复创建对象。 - * @param calculateAnchor {boolean} 可选参数,是否会计算锚点。 - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getBounds(resultRect?: Rectangle, calculateAnchor?: boolean): egret.Rectangle; - /** - * @private - */ - $getTransformedBounds(targetCoordinateSpace: DisplayObject, resultRect?: Rectangle): Rectangle; - /** - * Converts the point object from the Stage (global) coordinates to the display object's (local) coordinates. - * @param stageX the x value in the global coordinates - * @param stageY the y value in the global coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将从舞台(全局)坐标转换为显示对象的(本地)坐标。 - * @param stageX 舞台坐标x - * @param stageY 舞台坐标y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 具有相对于显示对象的坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - globalToLocal(stageX?: number, stageY?: number, resultPoint?: Point): Point; - /** - * Converts the point object from the display object's (local) coordinates to the Stage (global) coordinates. - * @param localX the x value in the local coordinates - * @param localY the x value in the local coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the Stage. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的(本地)坐标转换为舞台(全局)坐标。 - * @param localX 本地坐标 x - * @param localY 本地坐标 y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 一个具有相对于舞台坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - localToGlobal(localX?: number, localY?: number, resultPoint?: Point): Point; - /** - * @private - * 获取显示对象占用的矩形区域集合,通常包括自身绘制的测量区域,如果是容器,还包括所有子项占据的区域。 - */ - $getOriginalBounds(): Rectangle; - /** - * @private - * 测量子项占用的矩形区域 - * @param bounds 测量结果存储在这个矩形对象内 - */ - $measureChildBounds(bounds: Rectangle): void; - /** - * @private - */ - $getContentBounds(): Rectangle; - /** - * @private - * 测量自身占用的矩形区域,注意:此测量结果并不包括子项占据的区域。 - * @param bounds 测量结果存储在这个矩形对象内 - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $parentDisplayList: egret.sys.DisplayList; - /** - * @private - * 渲染节点,不为空表示自身有绘制到屏幕的内容 - */ - $renderNode: sys.RenderNode; - $renderDirty: boolean; - /** - * @private - * 获取渲染节点 - */ - $getRenderNode(): sys.RenderNode; - $updateRenderMode(): void; - $renderMode: RenderMode; - /** - * @private - */ - private $measureFiltersOffset(fromParent); - /** - * @private - * 获取相对于指定根节点的连接矩阵。 - * @param root 根节点显示对象 - * @param matrix 目标显示对象相对于舞台的完整连接矩阵。 - */ - $getConcatenatedMatrixAt(root: DisplayObject, matrix: Matrix): void; - /** - * @private - * 更新renderNode - */ - $updateRenderNode(): void; - /** - * @private - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * Calculate the display object to determine whether it overlaps or crosses with the points specified by the x and y parameters. The x and y parameters specify the points in the coordinates of the stage, rather than the points in the display object container that contains display objects (except the situation where the display object container is a stage). - * Note: Don't use accurate pixel collision detection on a large number of objects. Otherwise, this will cause serious performance deterioration. - * @param x {number} x coordinate of the object to be tested. - * @param y {number} y coordinate of the object to be tested. - * @param shapeFlag {boolean} Whether to check the actual pixel of object (true) or check that of border (false).Write realized. - * @returns {boolean} If display object overlaps or crosses with the specified point, it is true; otherwise, it is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计算显示对象,以确定它是否与 x 和 y 参数指定的点重叠或相交。x 和 y 参数指定舞台的坐标空间中的点,而不是包含显示对象的显示对象容器中的点(除非显示对象容器是舞台)。 - * 注意,不要在大量物体中使用精确碰撞像素检测,这回带来巨大的性能开销 - * @param x {number} 要测试的此对象的 x 坐标。 - * @param y {number} 要测试的此对象的 y 坐标。 - * @param shapeFlag {boolean} 是检查对象 (true) 的实际像素,还是检查边框 (false) 的实际像素。 - * @returns {boolean} 如果显示对象与指定的点重叠或相交,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - hitTestPoint(x: number, y: number, shapeFlag?: boolean): boolean; - /** - * @private - */ - static $enterFrameCallBackList: DisplayObject[]; - /** - * @private - */ - static $renderCallBackList: DisplayObject[]; - /** - * @private - */ - $addListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - dispatchEvent(event: Event): boolean; - /** - * @private - * 获取事件流列表。注意:Egret框架的事件流与Flash实现并不一致。 - * - * 事件流有三个阶段:捕获,目标,冒泡。 - * Flash里默认的的事件监听若不开启useCapture将监听目标和冒泡阶段。若开始capture将只能监听捕获当不包括目标的事件。 - * 可以在Flash中写一个简单的测试:实例化一个非容器显示对象,例如TextField。分别监听useCapture为true和false时的鼠标事件。 - * 点击后将只有useCapture为false的回调函数输出信息。也就带来一个问题「Flash的捕获阶段不能监听到最内层对象本身,只在父级列表有效」。 - * - * 而HTML里的事件流设置useCapture为true时是能监听到目标阶段的,也就是目标阶段会被触发两次,在捕获和冒泡过程各触发一次。这样可以避免 - * 前面提到的监听捕获无法监听目标本身的问题。 - * - * Egret最终采用了HTML里目标节点触发两次的事件流方式。 - */ - $getPropagationList(target: DisplayObject): DisplayObject[]; - /** - * @private - */ - $dispatchPropagationEvent(event: Event, list: DisplayObject[], targetIndex: number): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - willTrigger(type: string): boolean; - /** - * inspired by pixi.js - */ - private _tint; - /** - * @private - */ - $tintRGB: number; - /** - * Set a tint color for the current object - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 给当前对象设置填充色 - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - tint: number; - /** - * @private - * inspired by pixi.js - */ - $sortDirty: boolean; - sortChildren(): void; - /** - * @private - */ - private _zIndex; - /** - * the z-order (front-to-back order) of the object - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 设置对象的 Z 轴顺序(前后顺序) - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - zIndex: number; - /** - * @private - */ - $lastSortedIndex: number; - /** - * Allow objects to use zIndex sorting - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 允许对象使用 zIndex 排序 - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - sortableChildren: boolean; - } -} -declare namespace egret { - let $TextureScaleFactor: number; - /** - * The Texture class encapsulates different image resources on different platforms. - * In HTML5, resource is an HTMLElement object - * In OpenGL / WebGL, resource is a texture ID obtained after the GPU is submitted - * The Texture class encapsulates the details implemented on the underlayer. Developers just need to focus on interfaces - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @see http://edn.egret.com/cn/docs/page/123 Several ways of access to resources - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language en_US - */ - /** - * 纹理类是对不同平台不同的图片资源的封装 - * 在HTML5中,资源是一个HTMLElement对象 - * 在OpenGL / WebGL中,资源是一个提交GPU后获取的纹理id - * Texture类封装了这些底层实现的细节,开发者只需要关心接口即可 - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @see http://edn.egret.com/cn/docs/page/123 获取资源的几种方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language zh_CN - */ - class Texture extends HashObject { - /** - * Create an egret.Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * Whether to destroy the corresponding BitmapData when the texture is destroyed - * @version Egret 5.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁纹理时是否销毁对应BitmapData - * @version Egret 5.0.8 - * @platform Web,Native - * @language zh_CN - */ - disposeBitmapData: boolean; - /** - * @private - * 表示这个纹理在 bitmapData 上的 x 起始位置 - */ - $bitmapX: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的 y 起始位置 - */ - $bitmapY: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的宽度 - */ - $bitmapWidth: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的高度 - */ - $bitmapHeight: number; - /** - * @private - * 表示这个纹理显示了之后在 x 方向的渲染偏移量 - */ - $offsetX: number; - /** - * @private - * 表示这个纹理显示了之后在 y 方向的渲染偏移量 - */ - $offsetY: number; - /** - * @private - * 纹理宽度 - */ - private $textureWidth; - /** - * Texture width, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理宽度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textureWidth: number; - $getTextureWidth(): number; - /** - * @private - * 纹理高度 - */ - private $textureHeight; - /** - * Texture height, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理高度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textureHeight: number; - $getTextureHeight(): number; - $getScaleBitmapWidth(): number; - $getScaleBitmapHeight(): number; - /** - * @private - * 表示bitmapData.width - */ - $sourceWidth: number; - /** - * @private - * 表示bitmapData.height - */ - $sourceHeight: number; - /** - * @private - */ - $bitmapData: BitmapData; - /** - * @private - */ - $ktxData: ArrayBuffer; - /** - * @private - */ - $rotated: boolean; - /** - * The BitmapData object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 BitmapData 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bitmapData: BitmapData; - /** - * Set the BitmapData object. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 设置 BitmapData 对象。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - _setBitmapData(value: BitmapData): void; - /** - * The KTX object being referenced. - * @version Egret 5.2.21 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 KTXData 对象。 - * @version Egret 5.2.21 - * @platform Web,Native - * @language zh_CN - */ - ktxData: ArrayBuffer; - /** - * Set the KTXData object. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 设置 KTXData 对象。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - _setKtxData(value: ArrayBuffer): void; - /** - * @private - * 设置Texture数据 - * @param bitmapX - * @param bitmapY - * @param bitmapWidth - * @param bitmapHeight - * @param offsetX - * @param offsetY - * @param textureWidth - * @param textureHeight - * @param sourceWidth - * @param sourceHeight - */ - $initData(bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, sourceWidth: number, sourceHeight: number, rotated?: boolean): void; - /** - * @deprecated - */ - getPixel32(x: number, y: number): number[]; - /** - * Obtain the color value for the specified pixel region - * @param x The x coordinate of the pixel region - * @param y The y coordinate of the pixel region - * @param width The width of the pixel region - * @param height The height of the pixel region - * @returns Specifies the color value for the pixel region - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取指定像素区域的颜色值 - * @param x 像素区域的X轴坐标 - * @param y 像素区域的Y轴坐标 - * @param width 像素区域的宽度 - * @param height 像素区域的高度 - * @returns 指定像素区域的颜色值 - * @version Egret 3.2.1 - * @platform Web - * @language zh_CN - */ - getPixels(x: number, y: number, width?: number, height?: number): number[]; - /** - * Convert base64 string, if the picture (or pictures included) cross-border or null - * @param type Type conversions, such as "image / png" - * @param rect The need to convert the area - * @param smoothing Whether to convert data to the smoothing process - * @returns {any} base64 string - * @version Egret 2.4 - * @language en_US - */ - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如 "image/png" - * @param rect 需要转换的区域 - * @param {any} encoderOptions 编码用的参数 - * @returns {any} base64字符串 - * @version Egret 2.4 - * @language zh_CN - */ - toDataURL(type: string, rect?: egret.Rectangle, encoderOptions?: any): string; - /** - * Crop designated area and save it as image. - * native support only "image / png" and "image / jpeg"; Web browser because of the various implementations are not the same, it is recommended to use only these two kinds. - * @param type Type conversions, such as "image / png" - * @param filePath The path name of the image (the home directory for the game's private space, the path can not have "../",Web supports only pass names.) - * @param rect The need to convert the area - * @version Egret 2.4 - * @platform Native - * @language en_US - */ - /** - * 裁剪指定区域并保存成图片。 - * native只支持 "image/png" 和 "image/jpeg";Web中由于各个浏览器的实现不一样,因此建议也只用这2种。 - * @param type 转换的类型,如 "image/png" - * @param filePath 图片的名称的路径(主目录为游戏的私有空间,路径中不能有 "../",Web只支持传名称。) - * @param rect 需要转换的区域 - * @version Egret 2.4 - * @platform Native - * @language zh_CN - */ - saveToFile(type: string, filePath: string, rect?: egret.Rectangle): void; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispose(): void; - } -} -declare namespace egret { - /** - * The Event class is used as the base class for the creation of Event objects, which are passed as parameters to event - * listeners when an event occurs.The properties of the Event class carry basic information about an event, such as - * the event's type or whether the event's default behavior can be canceled. For many events, such as the events represented - * by the Event class constants, this basic information is sufficient. Other events, however, may require more detailed - * information. Events associated with a touch tap, for example, need to include additional information about the - * location of the touch event. You can pass such additional information to event listeners by extending the Event class, - * which is what the TouchEvent class does. Egret API defines several Event subclasses for common events that require - * additional information. Events associated with each of the Event subclasses are described in the documentation for - * each class.The methods of the Event class can be used in event listener functions to affect the behavior of the event - * object. Some events have an associated default behavior. Your event listener can cancel this behavior by calling the - * preventDefault() method. You can also make the current event listener the last one to process an event by calling - * the stopPropagation() or stopImmediatePropagation() method. - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language en_US - */ - /** - * Event 类作为创建事件实例的基类,当发生事件时,Event 实例将作为参数传递给事件侦听器。Event 类的属性包含有关事件的基本信息,例如事件 - * 的类型或者是否可以取消事件的默认行为。对于许多事件(如由 Event 类常量表示的事件),此基本信息就足够了。但其他事件可能需要更详细的信息。 - * 例如,与触摸关联的事件需要包括有关触摸事件的位置信息。您可以通过扩展 Event 类(TouchEvent 类执行的操作)将此类其他信息传递给事件侦听器。 - * Egret API 为需要其他信息的常见事件定义多个 Event 子类。与每个 Event 子类关联的事件将在每个类的文档中加以介绍。Event 类的方法可以在 - * 事件侦听器函数中使用以影响事件对象的行为。某些事件有关联的默认行为,通过调用 preventDefault() 方法,您的事件侦听器可以取消此行为。 - * 可以通过调用 stopPropagation() 或 stopImmediatePropagation() 方法,将当前事件侦听器作为处理事件的最后一个事件侦听器。 - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language zh_CN - */ - class Event extends HashObject { - /** - * Dispatched when a display object is added to the on stage display list, either directly or through the addition - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADDED_TO_STAGE: string; - /** - * Dispatched when a display object is about to be removed from the display list, either directly or through the removal - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static REMOVED_FROM_STAGE: string; - /** - * Dispatched when a display object is added to the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象添加到显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADDED: string; - /** - * Dispatched when a display object is about to be removed from the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将要从显示列表中删除显示对象时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static REMOVED: string; - /** - * [broadcast event] Dispatched when the playhead is entering a new frame. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * [广播事件] 进入新的一帧,监听此事件将会在下一帧开始时触发一次回调。这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ENTER_FRAME: string; - /** - * Dispatched when the display list is about to be updated and rendered. - * Note: Every time you want to receive a render event,you must call the stage.invalidate() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 渲染事件,监听此事件将会在本帧末即将开始渲染的前一刻触发回调,这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * 注意:每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 stage.invalidate() 方法,由于每帧只会触发一次屏幕刷新, - * 若在 Event.RENDER 回调函数执行期间再次调用stage.invalidate(),将会被忽略。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RENDER: string; - /** - * Dispatched when the size of stage or UIComponent is changed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台尺寸或UI组件尺寸发生改变 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RESIZE: string; - /** - * Dispatched when the value or selection of a property is chaned. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态发生改变。通常是按钮的选中状态,或者列表的选中项索引改变。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CHANGE: string; - /** - * Dispatched when the value or selection of a property is going to change.you can cancel this by calling the - * preventDefault() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态即将发生改变,通常是按钮的选中状态,或者列表的选中项索引改变。可以通过调用 preventDefault() 方法阻止索引发生更改。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CHANGING: string; - /** - * Dispatched when the net request is complete. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 网络请求加载完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static COMPLETE: string; - /** - * Dispatched when loop completed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 循环完成。循环最后一次只派发 COMPLETE 事件,不派发 LOOP_COMPLETE 事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LOOP_COMPLETE: string; - /** - * Dispatched when the TextInput instance gets focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_IN: string; - /** - * Dispatched when the TextInput instance loses focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_OUT: string; - /** - * Dispatched when the playback is ended. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 动画声音等播放完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ENDED: string; - /** - * 游戏激活 - * @version Egret 2.4 - * @platform Web,Native - */ - static ACTIVATE: string; - /** - * 取消激活 - * @version Egret 2.4 - * @platform Web,Native - */ - static DEACTIVATE: string; - /** - * Event.CLOSE 常量定义 close 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static CLOSE: string; - /** - * Event.CONNECT 常量定义 connect 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static CONNECT: string; - /** - * Event.LEAVE_STAGE 常量定义 leaveStage 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static LEAVE_STAGE: string; - /** - * Event.SOUND_COMPLETE 常量定义 在声音完成播放后调度。 - * @version Egret 2.4 - * @platform Web,Native - */ - static SOUND_COMPLETE: string; - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param data the optional data associated with this event - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param data 与此事件对象关联的可选数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, data?: any); - /** - * the optional data associated with this event - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 与此事件对象关联的可选数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: any; - /** - * @private - */ - $type: string; - /** - * The type of event. The type is case-sensitive. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件的类型。类型区分大小写。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly type: string; - /** - * @private - */ - $bubbles: boolean; - /** - * Indicates whether an event is a bubbling event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示事件是否为冒泡事件。如果事件可以冒泡,则此值为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly bubbles: boolean; - /** - * @private - */ - $cancelable: boolean; - /** - * Indicates whether the behavior associated with the event can be prevented. If the behavior can be - * canceled, this value is true; otherwise it is false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示是否可以阻止与事件相关联的行为。如果可以取消该行为,则此值为 true;否则为 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly cancelable: boolean; - /** - * @private - */ - $eventPhase: number; - /** - * The current phase in the event flow. This property can contain the following numeric values: - * The capture phase (EventPhase.CAPTURING_PHASE). - * The target phase (EventPhase.AT_TARGET) - * The bubbling phase (EventPhase.BUBBLING_PHASE). - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件流中的当前阶段。此属性可以包含以下数值: - * 捕获阶段 (EventPhase.CAPTURING_PHASE)。 - * 目标阶段 (EventPhase.AT_TARGET)。 - * 冒泡阶段 (EventPhase.BUBBLING_PHASE)。 - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly eventPhase: number; - /** - * @private - */ - $currentTarget: any; - /** - * The object that is actively processing the Event object with an event listener. For example, if a - * user clicks an OK button, the current target could be the node containing that button or one of its ancestors - * that has registered an event listener for that event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前正在使用某个事件侦听器处理 Event 对象的对象。例如,如果用户单击“确定”按钮, - * 则当前目标可以是包含该按钮的节点,也可以是它的已为该事件注册了事件侦听器的始祖之一。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly currentTarget: any; - /** - * @private - */ - $target: any; - /** - * The event target. This property contains the target node. For example, if a user clicks an OK button, - * the target node is the display list node containing that button. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件目标。此属性包含目标节点。例如,如果用户单击“确定”按钮,则目标节点就是包含该按钮的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly target: any; - $setTarget(target: any): boolean; - /** - * @private - */ - $isDefaultPrevented: boolean; - /** - * Checks whether the preventDefault() method has been called on the event. If the preventDefault() method has been - * called, returns true; otherwise, returns false. - * @returns If preventDefault() has been called, returns true; otherwise, returns false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查是否已对事件调用 preventDefault() 方法。 - * @returns 如果已调用 preventDefault() 方法,则返回 true;否则返回 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - isDefaultPrevented(): boolean; - /** - * Cancels an event's default behavior if that behavior can be canceled.Many events have associated behaviors that - * are carried out by default. For example, if a user types a character into a text input, the default behavior - * is that the character is displayed in the text input. Because the TextEvent.TEXT_INPUT event's default behavior - * can be canceled, you can use the preventDefault() method to prevent the character from appearing. - * You can use the Event.cancelable property to check whether you can prevent the default behavior associated with - * a particular event. If the value of Event.cancelable is true, then preventDefault() can be used to cancel the event; - * otherwise, preventDefault() has no effect. - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果可以取消事件的默认行为,则取消该行为。 - * 许多事件都有默认执行的关联行为。例如,如果用户在文本字段中键入一个字符,则默认行为就是在文本字段中显示该字符。 - * 由于可以取消 TextEvent.TEXT_INPUT 事件的默认行为,因此您可以使用 preventDefault() 方法来防止显示该字符。 - * 您可以使用 Event.cancelable 属性来检查是否可以防止与特定事件关联的默认行为。如果 Event.cancelable 的值为 true, - * 则可以使用 preventDefault() 来取消事件;否则,preventDefault() 无效。 - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - preventDefault(): void; - /** - * @private - */ - $isPropagationStopped: boolean; - /** - * Prevents processing of any event listeners in nodes subsequent to the current node in the event flow. This method - * does not affect any event listeners in the current node (currentTarget). In contrast, the stopImmediatePropagation() - * method prevents processing of event listeners in both the current node and subsequent nodes. Additional calls to this - * method have no effect. This method can be called in any phase of the event flow.
- * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。此方法不会影响当前节点 currentTarget 中的任何事件侦听器。 - * 相比之下,stopImmediatePropagation() 方法可以防止对当前节点中和后续节点中的事件侦听器进行处理。 - * 对此方法的其它调用没有任何效果。可以在事件流的任何阶段中调用此方法。
- * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stopPropagation(): void; - /** - * @private - */ - $isPropagationImmediateStopped: boolean; - /** - * Prevents processing of any event listeners in the current node and any subsequent nodes in the event flow. - * This method takes effect immediately, and it affects event listeners in the current node. In contrast, the - * stopPropagation() method doesn't take effect until all the event listeners in the current node finish processing.
- * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。此方法会立即生效,并且会影响当前节点中的事件侦听器。 - * 相比之下,在当前节点中的所有事件侦听器都完成处理之前,stopPropagation() 方法不会生效。
- * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stopImmediatePropagation(): void; - /** - * This method will be called automatically when you pass the event object as the parameters to the Event.release() method. - * If your custom event is designed for reusable,you should override this method to make sure all the references to external - * objects are cleaned. if not,it may cause memory leaking. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当事件实例传递给Event.release()静态方法时,实例上的clean()方法将会被自动调用。 - * 若此自定义事件的实例设计为可以循环复用的,为了避免引起内存泄露,自定义事件需要覆盖此方法来确保实例被缓存前断开对外部对象的一切引用。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - protected clean(): void; - /** - * EventDispatcher object using the specified event object thrown Event. Objects thrown objects will be cached in the pool for the next round robin. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 EventDispatcher 对象来抛出 Event 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchEvent(target: IEventDispatcher, type: string, bubbles?: boolean, data?: any): boolean; - /** - * @private - * - * @param EventClass - * @returns - */ - static _getPropertyData(EventClass: any): any; - /** - * Gets one event instance from the object pool or create a new one. We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
- * Note: If you want to use this method to initialize your custom event object,you must make sure the constructor - * of your custom event is the same as the constructor of egret.Event. - * @param EventClass Event Class。 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;    //optional,initializes custom data here
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的事件实例。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
- * 注意:若使用此方法来创建自定义事件的实例,自定义的构造函数参数列表必须跟Event类一致。 - * @param EventClass Event类名。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;  //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(EventClass: { - new (type: string, bubbles?: boolean, cancelable?: boolean): T; - eventPool?: Event[]; - }, type: string, bubbles?: boolean, cancelable?: boolean): T; - /** - * Releases an event object and cache it into the object pool.We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
- * Note: The parameters of this method only accepts an instance created by the Event.create() method. - * if not,it may throw an error. - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data; //optional,initializes custom data here
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个事件对象,并缓存到对象池。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
- * 注意:此方法只能传入由Event.create()创建的事件实例,传入非法对象实例可能会导致报错。 - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;   //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(event: Event): void; - } -} -/** - * Is debug mode. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ -/** - * 是否为 debug 模式。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ -declare let DEBUG: boolean; -/** - * Is release mode. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ -/** - * 是否为 release 模式。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ -declare let RELEASE: boolean; -declare namespace egret { - /** - * @private - */ - function $error(code: number, ...params: any[]): void; - /** - * @private - */ - function $warn(code: number, ...params: any[]): void; - /** - * @private - */ - function getString(code: number, ...params: any[]): string; - /** - * @private - */ - function $markCannotUse(instance: any, property: string, defaultVale: any): void; -} -declare namespace egret { - /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal - * axis and y represents the vertical axis. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language en_US - */ - /** - * Point 对象表示二维坐标系统中的某个位置,其中 x 表示水平轴,y 表示垂直轴。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language zh_CN - */ - class Point extends HashObject { - /** - * Releases a point instance to the object pool - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Point实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(point: Point): void; - /** - * get a point instance from the object pool or create a new one. - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Point对象。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(x: number, y: number): Point; - /** - * Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(x?: number, y?: number); - /** - * The horizontal coordinate. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该点的水平坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * The vertical coordinate. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该点的垂直坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * The length of the line segment from (0,0) to this point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 (0,0) 到此点的线段长度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly length: number; - /** - * Sets the members of Point to the specified values - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 的成员设置为指定值 - * @param x 该对象的x属性值 - * @param y 该对象的y属性值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(x: number, y: number): Point; - /** - * Creates a copy of this Point object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 克隆点对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Point; - /** - * Determines whether two points are equal. Two points are equal if they have the same x and y values. - * @param toCompare The point to be compared. - * @returns A value of true if the object is equal to this Point object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个点是否相同。如果两个点具有相同的 x 和 y 值,则它们是相同的点。 - * @param toCompare 要比较的点。 - * @returns 如果该对象与此 Point 对象相同,则为 true 值,如果不相同,则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(toCompare: Point): boolean; - /** - * Returns the distance between pt1 and pt2. - * @param p1 The first point. - * @param p2 The second point. - * @returns The distance between the first and second points. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 pt1 和 pt2 之间的距离。 - * @param p1 第一个点 - * @param p2 第二个点 - * @returns 第一个点和第二个点之间的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static distance(p1: Point, p2: Point): number; - /** - * Copies all of the point data from the source Point object into the calling Point object. - * @param sourcePoint The Point object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Point 对象中的所有点数据复制到调用方 Point 对象中。 - * @param sourcePoint 要从中复制数据的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(sourcePoint: Point): void; - /** - * Adds the coordinates of another point to the coordinates of this point to create a new point. - * @param v The point to be added. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将另一个点的坐标添加到此点的坐标以创建一个新点。 - * @param v 要添加的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - add(v: Point): Point; - /** - * Determines a point between two specified points. - * The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2. The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2). - * @param pt1 The first point. - * @param pt2 The second point. - * @param f The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned. - * @returns The new interpolated point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个指定点之间的点。 - * 参数 f 确定新的内插点相对于参数 pt1 和 pt2 指定的两个端点所处的位置。参数 f 的值越接近 1.0,则内插点就越接近第一个点(参数 pt1)。参数 f 的值越接近 0,则内插点就越接近第二个点(参数 pt2)。 - * @param pt1 第一个点。 - * @param pt2 第二个点。 - * @param f 两个点之间的内插级别。表示新点将位于 pt1 和 pt2 连成的直线上的什么位置。如果 f=1,则返回 pt1;如果 f=0,则返回 pt2。 - * @returns 新的内插点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static interpolate(pt1: Point, pt2: Point, f: number): Point; - /** - * Scales the line segment between (0,0) and the current point to a set length. - * @param thickness The scaling value. For example, if the current point is (0,5), and you normalize it to 1, the point returned is at (0,1). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 (0,0) 和当前点之间的线段缩放为设定的长度。 - * @param thickness 缩放值。例如,如果当前点为 (0,5) 并且您将它规范化为 1,则返回的点位于 (0,1) 处。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - normalize(thickness: number): void; - /** - * Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value. - * @param dx The amount by which to offset the horizontal coordinate, x. - * @param dy The amount by which to offset the vertical coordinate, y. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量偏移 Point 对象。dx 的值将添加到 x 的原始值中以创建新的 x 值。dy 的值将添加到 y 的原始值中以创建新的 y 值。 - * @param dx 水平坐标 x 的偏移量。 - * @param dy 水平坐标 y 的偏移量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offset(dx: number, dy: number): void; - /** - * Converts a pair of polar coordinates to a Cartesian point coordinate. - * @param len The length coordinate of the polar pair. - * @param angle The angle, in radians, of the polar pair. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一对极坐标转换为笛卡尔点坐标。 - * @param len 极坐标对的长度。 - * @param angle 极坐标对的角度(以弧度表示)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static polar(len: number, angle: number): Point; - /** - * Subtracts the coordinates of another point from the coordinates of this point to create a new point. - * @param v The point to be subtracted. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从此点的坐标中减去另一个点的坐标以创建一个新点。 - * @param v 要减去的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - subtract(v: Point): Point; - /** - * Returns a string that contains the values of the x and y coordinates. The string has the form "(x=x, y=y)", so calling the toString() method for a point at 23,17 would return "(x=23, y=17)". - * @returns The string representation of the coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回包含 x 和 y 坐标的值的字符串。该字符串的格式为 "(x=x, y=y)",因此为点 23,17 调用 toString() 方法将返回 "(x=23, y=17)"。 - * @returns 坐标的字符串表示形式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempPoint: Point; -} -declare namespace egret { - /** - * The DisplayObjectContainer class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language en_US - */ - /** - * DisplayObjectContainer 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language zh_CN - */ - class DisplayObjectContainer extends DisplayObject { - /** - * @private - */ - static $EVENT_ADD_TO_STAGE_LIST: DisplayObject[]; - /** - * @private - */ - static $EVENT_REMOVE_FROM_STAGE_LIST: DisplayObject[]; - /** - * Creates a new DisplayObjectContainer instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * Returns the number of children of this object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此对象的子项数目。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly numChildren: number; - /** - * Set children sort mode. - * @param value {string} The sort mode - * @see egret.ChildrenSortMode - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - /** - * 设置子项目的排序方式 - * @param value {string} 排序方式 - * @see egret.ChildrenSortMode - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - setChildrenSortMode(value: string): void; - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added to the front - * (top) of all other children in this DisplayObjectContainer instance. (To add a child to a specific index position, - * use the addChildAt() method.)If you add a child object that already has a different display object container - * as a parent, the object is removed from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @returns 在 child The DisplayObject instance that you pass in the child parameter. - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。子项将被添加到该 DisplayObjectContainer 实例中其他 - * 所有子项的前(上)面。(要将某子项添加到特定索引位置,请使用 addChildAt() 方法。) - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addChild(child: DisplayObject): DisplayObject; - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added at the index position - * specified. An index of 0 represents the back (bottom) of the display list for this DisplayObjectContainer object. - * If you add a child object that already has a different display object container as a parent, the object is removed - * from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @param index The index position to which the child is added. If you specify a currently occupied index position, - * the child object that exists at that position and all higher positions are moved up one position in the child list. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。该子项将被添加到指定的索引位置。索引为 0 表示该 - * DisplayObjectContainer 对象的显示列表的后(底)部。如果添加一个已将其它显示对象容器作为父项的子对象,则会从其它显示对象容器的子列表中删除该对象。 - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @param index 添加该子项的索引位置。 如果指定当前占用的索引位置,则该位置以及所有更高位置上的子对象会在子级列表中上移一个位置。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addChildAt(child: DisplayObject, index: number): DisplayObject; - /** - * @private - */ - $doAddChild(child: DisplayObject, index: number, notifyListeners?: boolean): DisplayObject; - /** - * Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance - * itself. The search includes the entire display list including this DisplayObjectContainer instance. Grandchildren, - * great-grandchildren, and so on each return true. - * @param child The child object to test. - * @returns true if the child object is a child of the DisplayObjectContainer or the container itself; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定指定显示对象是 DisplayObjectContainer 实例的子项或该实例本身。搜索包括整个显示列表(其中包括此 DisplayObjectContainer 实例)。 - * 孙项、曾孙项等,每项都返回 true。 - * @param child 要测试的子对象。 - * @returns 如果 child 对象是 DisplayObjectContainer 的子项或容器本身,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - contains(child: DisplayObject): boolean; - /** - * Returns the child display object instance that exists at the specified index. - * @param index The index position of the child object. - * @returns The child display object at the specified index position. - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回位于指定索引处的子显示对象实例。 - * @param index 子对象的索引位置。 - * @returns 位于指定索引位置处的子显示对象。 - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildAt(index: number): DisplayObject; - /** - * Returns the index position of a child DisplayObject instance. - * @param child The DisplayObject instance to identify. - * @returns The index position of the child display object to identify. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 DisplayObject 的 child 实例的索引位置。 - * @param child 要测试的子对象。 - * @returns 要查找的子显示对象的索引位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildIndex(child: egret.DisplayObject): number; - /** - * Returns the child display object that exists with the specified name. If more that one child display object has - * the specified name, the method returns the first object in the child list.The getChildAt() method is faster than - * the getChildByName() method. The getChildAt() method accesses a child from a cached array, whereas the getChildByName() - * method has to traverse a linked list to access a child. - * @param name The name of the child to return. - * @returns The child display object with the specified name. - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回具有指定名称的子显示对象。如果多个子显示对象具有指定名称,则该方法会返回子级列表中的第一个对象。 - * getChildAt() 方法比 getChildByName() 方法快。getChildAt() 方法从缓存数组中访问子项,而 getChildByName() 方法则必须遍历链接的列表来访问子项。 - * @param name 要返回的子项的名称。 - * @returns 具有指定名称的子显示对象。 - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildByName(name: string): DisplayObject; - /** - * Removes the specified child DisplayObject instance from the child list of the DisplayObjectContainer instance. - * The parent property of the removed child is set to null , and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are - * decreased by 1. - * @param child The DisplayObject instance to remove. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子列表中删除指定的 child DisplayObject 实例。将已删除子项的 parent 属性设置为 null; - * 如果不存在对该子项的任何其它引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param child 要删除的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChild(child: DisplayObject): DisplayObject; - /** - * Removes a child DisplayObject from the specified index position in the child list of the DisplayObjectContainer. - * The parent property of the removed child is set to null, and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are decreased by 1. - * @param index The child index of the DisplayObject to remove. - * @returns The DisplayObject instance that was removed. - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 的子列表中指定的 index 位置删除子 DisplayObject。将已删除子项的 parent 属性设置为 null; - * 如果没有对该子项的任何其他引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param index 要删除的 DisplayObject 的子索引。 - * @returns 已删除的 DisplayObject 实例。 - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChildAt(index: number): DisplayObject; - /** - * @private - */ - $doRemoveChild(index: number, notifyListeners?: boolean): DisplayObject; - /** - * Changes the position of an existing child in the display object container. This affects the layering of child objects. - * @param child The child DisplayObject instance for which you want to change the index number. - * @param index The resulting index number for the child display object. - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改现有子项在显示对象容器中的位置。这会影响子对象的分层。 - * @param child 要为其更改索引编号的 DisplayObject 子实例。 - * @param index 生成的 child 显示对象的索引编号。当新的索引编号小于0或大于已有子元件数量时,新加入的DisplayObject对象将会放置于最上层。 - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setChildIndex(child: DisplayObject, index: number): void; - /** - * @private - */ - private doSetChildIndex(child, index); - /** - * Swaps the z-order (front-to-back order) of the child objects at the two specified index positions in the child - * list. All other child objects in the display object container remain in the same index positions. - * @param index1 The index position of the first child object. - * @param index2 The index position of the second child object. - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在子级列表中两个指定的索引位置,交换子对象的 Z 轴顺序(前后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param index1 第一个子对象的索引位置。 - * @param index2 第二个子对象的索引位置。 - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - swapChildrenAt(index1: number, index2: number): void; - /** - * Swaps the z-order (front-to-back order) of the two specified child objects. All other child objects in the - * display object container remain in the same index positions. - * @param child1 The first child object. - * @param child2 The second child object. - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 交换两个指定子对象的 Z 轴顺序(从前到后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param child1 第一个子对象。 - * @param child2 第二个子对象。 - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - swapChildren(child1: DisplayObject, child2: DisplayObject): void; - /** - * @private - */ - private doSwapChildrenAt(index1, index2); - /** - * Removes all child DisplayObject instances from the child list of the DisplayObjectContainer instance. The parent - * property of the removed children is set to null , and the objects are garbage collected if no other references to the children exist. - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子级列表中删除所有 child DisplayObject 实例。 - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChildren(): void; - /** - * @private - * 一个子项被添加到容器内,此方法不仅在操作addChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - $childAdded(child: DisplayObject, index: number): void; - /** - * @private - * 一个子项从容器内移除,此方法不仅在操作removeChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - $childRemoved(child: DisplayObject, index: number): void; - /** - * @private - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * - */ - $onRemoveFromStage(): void; - /** - * @private - */ - $measureChildBounds(bounds: Rectangle): void; - $touchChildren: boolean; - /** - * Determines whether or not the children of the object are touch, or user input device, enabled. If an object is - * enabled, a user can interact with it by using a touch or user input device. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定对象的子级是否支持触摸或用户输入设备。如果对象支持触摸或用户输入设备,用户可以通过使用触摸或用户输入设备与之交互。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchChildren: boolean; - /** - * @private - * - * @returns - */ - $getTouchChildren(): boolean; - /** - * @private - */ - $setTouchChildren(value: boolean): boolean; - /** - * @private - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - private _sortChildrenFunc(a, b); - sortChildren(): void; - } -} -declare namespace egret { - /** - * SpriteSheet is a mosaic of multiple sub-bitmaps, comprising a plurality of Texture objects. - * Each Texture object shares the set bitmap of SpriteSheet, but it points to its different areas. - * On WebGL / OpenGL, this operation can significantly improve performance. - * At the same time, SpriteSheet can carry out material integration easily to reduce the number of HTTP requests - * For specification of the SpriteSheet format, see the document https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language en_US - */ - /** - * SpriteSheet 是一张由多个子位图拼接而成的集合位图,它包含多个 Texture 对象。 - * 每一个 Texture 都共享 SpriteSheet 的集合位图,但是指向它的不同的区域。 - * 在WebGL / OpenGL上,这种做法可以显著提升性能 - * 同时,SpriteSheet可以很方便的进行素材整合,降低HTTP请求数量 - * SpriteSheet 格式的具体规范可以参见此文档 https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language zh_CN - */ - class SpriteSheet extends HashObject { - /** - * Create an egret.SpriteSheet object - * @param texture {Texture} Texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.SpriteSheet 对象 - * @param texture {Texture} 纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(texture: Texture); - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置x。 - */ - private _bitmapX; - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置y。 - */ - private _bitmapY; - /** - * @private - * 共享的位图数据 - */ - $texture: Texture; - /** - * @private - * 纹理缓存字典 - */ - _textureMap: MapLike; - /** - * Obtain a cached Texture object according to the specified texture name - * @param name {string} Cache the name of this Texture object - * @returns {egret.Texture} The Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据指定纹理名称获取一个缓存的 Texture 对象 - * @param name {string} 缓存这个 Texture 对象所使用的名称 - * @returns {egret.Texture} Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTexture(name: string): Texture; - /** - * Create a new Texture object for the specified area on SpriteSheet and cache it - * @param name {string} Cache the name of this Texture object. If the name already exists, the previous Texture object will be overwrited. - * @param bitmapX {number} Starting coordinate x of texture area on bitmapData - * @param bitmapY {number} Starting coordinate y of texture area on bitmapData - * @param bitmapWidth {number} Width of texture area on bitmapData - * @param bitmapHeight {number} Height of texture area on bitmapData - * @param offsetX {number} Starting point x for a non-transparent area of the original bitmap - * @param offsetY {number} Starting point y for a non-transparent area of the original bitmap - * @param textureWidth {number} Width of the original bitmap. If it is not passed, use the bitmapWidth value. - * @param textureHeight {number} Height of the original bitmap. If it is not passed, use the bitmapHeight value. - * @returns {egret.Texture} The created Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为 SpriteSheet 上的指定区域创建一个新的 Texture 对象并缓存它 - * @param name {string} 缓存这个 Texture 对象所使用的名称,如果名称已存在,将会覆盖之前的 Texture 对象 - * @param bitmapX {number} 纹理区域在 bitmapData 上的起始坐标x - * @param bitmapY {number} 纹理区域在 bitmapData 上的起始坐标y - * @param bitmapWidth {number} 纹理区域在 bitmapData 上的宽度 - * @param bitmapHeight {number} 纹理区域在 bitmapData 上的高度 - * @param offsetX {number} 原始位图的非透明区域 x 起始点 - * @param offsetY {number} 原始位图的非透明区域 y 起始点 - * @param textureWidth {number} 原始位图的高度,若不传入,则使用 bitmapWidth 的值。 - * @param textureHeight {number} 原始位图的宽度,若不传入,则使用 bitmapHeight 的值。 - * @returns {egret.Texture} 创建的 Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createTexture(name: string, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX?: number, offsetY?: number, textureWidth?: number, textureHeight?: number): Texture; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispose(): void; - } -} -declare namespace egret { - /** - * @private - */ - let $locale_strings: any; - /** - * @private - */ - let $language: string; -} -declare namespace egret.sys { - /** - * @private - * 全局多语言翻译函数 - * @param code 要查询的字符串代码 - * @param args 替换字符串中{0}标志的参数列表 - * @returns 返回拼接后的字符串 - */ - function tr(code: number, ...args: any[]): string; -} -declare namespace egret { - /** - * The Bitmap class represents display objects that represent bitmap images. - * The Bitmap() constructor allows you to create a Bitmap object that contains a reference to a BitmapData object. - * After you create a Bitmap object, use the addChild() or addChildAt() method of the parent DisplayObjectContainer - * instance to place the bitmap on the display list.A Bitmap object can share its texture reference among several - * Bitmap objects, independent of translation or rotation properties. Because you can create multiple Bitmap objects - * that reference the same texture object, multiple display objects can use the same complex texture object - * without incurring the memory overhead of a texture object for each display object instance. - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language en_US - */ - /** - * Bitmap 类表示用于显示位图图片的显示对象。 - * 利用 Bitmap() 构造函数,可以创建包含对 BitmapData 对象引用的 Bitmap 对象。创建了 Bitmap 对象后, - * 使用父级 DisplayObjectContainer 实例的 addChild() 或 addChildAt() 方法可以将位图放在显示列表中。 - * 一个 Bitmap 对象可在若干 Bitmap 对象之中共享其 texture 引用,与缩放或旋转属性无关。 - * 由于能够创建引用相同 texture 对象的多个 Bitmap 对象,因此,多个显示对象可以使用相同的 texture 对象, - * 而不会因为每个显示对象实例使用一个 texture 对象而产生额外内存开销。 - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language zh_CN - */ - class Bitmap extends DisplayObject { - /** - * Initializes a Bitmap object to refer to the specified Texture object. - * @param value The Texture object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 Texture 实例的 Bitmap 对象 - * @param value 被引用的 Texture 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(value?: Texture); - protected $texture: Texture; - $bitmapData: BitmapData; - protected $bitmapX: number; - protected $bitmapY: number; - protected $bitmapWidth: number; - protected $bitmapHeight: number; - protected $offsetX: number; - protected $offsetY: number; - protected $textureWidth: number; - protected $textureHeight: number; - protected $sourceWidth: number; - protected $sourceHeight: number; - protected $smoothing: boolean; - protected $explicitBitmapWidth: number; - protected $explicitBitmapHeight: number; - protected createNativeDisplayObject(): void; - /** - * @private - * 显示对象添加到舞台 - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * 显示对象从舞台移除 - */ - $onRemoveFromStage(): void; - /** - * The Texture object being referenced. - * If you pass the constructor of type BitmapData or last set for bitmapData, this value returns null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 Texture 对象。 - * 如果传入构造函数的类型为 BitmapData 或者最后设置的为 bitmapData,则此值返回 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - texture: Texture; - /** - * @private - */ - $setTexture(value: Texture): boolean; - $setBitmapData(value: any): void; - /** - * @private - */ - protected setBitmapDataToWasm(data?: Texture): void; - /** - * @private - */ - $refreshImageData(): void; - /** - * @private - */ - private setImageData(bitmapData, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, sourceWidth, sourceHeight); - /** - * @private - */ - $scale9Grid: egret.Rectangle; - /** - * Represent a Rectangle Area that the 9 scale area of Image. - * Notice: This property is valid only when fillMode - * is BitmapFillMode.SCALE. - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形区域,它定义素材对象的九个缩放区域。 - * 注意:此属性仅在fillModeBitmapFillMode.SCALE时有效。 - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scale9Grid: egret.Rectangle; - protected $setScale9Grid(value: egret.Rectangle): void; - /** - * @private - */ - $fillMode: string; - /** - * Determines how the bitmap fills in the dimensions. - *

When set to BitmapFillMode.REPEAT, the bitmap - * repeats to fill the region.

- *

When set to BitmapFillMode.SCALE, the bitmap - * stretches to fill the region.

- * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 确定位图填充尺寸的方式。 - *

设置为 BitmapFillMode.REPEAT时,位图将重复以填充区域。

- *

设置为 BitmapFillMode.SCALE时,位图将拉伸以填充区域。

- * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - fillMode: string; - $setFillMode(value: string): boolean; - /** - * The default value of whether or not is smoothed when scaled. - * When object such as Bitmap is created,smoothing property will be set to this value. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理的默认值。 - * 在 Bitmap 等对象创建时,smoothing 属性会被设置为该值。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - static defaultSmoothing: boolean; - /** - * Whether or not the bitmap is smoothed when scaled. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否对位图进行平滑处理。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - smoothing: boolean; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - /** - * @private - * 获取显示宽度 - */ - $getHeight(): number; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $updateRenderNode(): void; - private _pixelHitTest; - /** - * Specifies whether this object use precise hit testing by checking the alpha value of each pixel.If pixelHitTest - * is set to true,the transparent area of the bitmap will be touched through.
- * Note:If the image is loaded from cross origin,that we can't access to the pixel data,so it might cause - * the pixelHitTest property invalid. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否开启精确像素碰撞。设置为true显示对象本身的透明区域将能够被穿透。
- * 注意:若图片资源是以跨域方式从外部服务器加载的,将无法访问图片的像素数据,而导致此属性失效。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pixelHitTest: boolean; - $hitTest(stageX: number, stageY: number): DisplayObject; - } -} -declare namespace egret.sys { - /** - * @private - * 渲染节点类型 - */ - const enum RenderNodeType { - /** - * 位图渲染节点 - */ - BitmapNode = 1, - /** - * 文本渲染节点 - */ - TextNode = 2, - /** - * 矢量渲染节点 - */ - GraphicsNode = 3, - /** - * 组渲染节点 - */ - GroupNode = 4, - /** - * Mesh 节点 - */ - MeshNode = 5, - /** - * 普通位图渲染节点 - */ - NormalBitmapNode = 6, - } - /** - * @private - * 渲染节点基类 - */ - class RenderNode { - /** - * 节点类型.. - */ - type: number; - /** - * 绘制数据 - */ - drawData: any[]; - /** - * 绘制次数 - */ - protected renderCount: number; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - $getRenderCount(): number; - } -} -declare namespace egret.sys { - /** - * @private - * 路径类型 - */ - const enum PathType { - /** - * 纯色填充路径 - */ - Fill = 1, - /** - * 渐变填充路径 - */ - GradientFill = 2, - /** - * 线条路径 - */ - Stroke = 3, - } - /** - * @private - * 2D路径命令 - */ - const enum PathCommand { - MoveTo = 1, - LineTo = 2, - CurveTo = 3, - CubicCurveTo = 4, - } - /** - * @private - * 2D路径 - */ - class Path2D { - /** - * 路径类型 - */ - type: number; - $commands: number[]; - $data: number | number[][]; - protected commandPosition: number; - protected dataPosition: number; - /** - * 当前移动到的坐标X - * 注意:目前只有drawArc之前会被赋值 - */ - $lastX: number; - /** - * 当前移动到的坐标Y - * 注意:目前只有drawArc之前会被赋值 - */ - $lastY: number; - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - moveTo(x: number, y: number): void; - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - lineTo(x: number, y: number): void; - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - */ - curveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - */ - cubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - drawRect(x: number, y: number, width: number, height: number): void; - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - */ - drawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - */ - drawCircle(x: number, y: number, radius: number): void; - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - drawEllipse(x: number, y: number, width: number, height: number): void; - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - */ - drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: boolean): void; - /** - * 绘制一段圆弧路径 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radiusX 圆弧的半径 x。 - * @param radiusY 圆弧的半径 y。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意:必须为正数。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意:与startAngle差值必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * 注意:如果为true,endAngle必须小于startAngle,反之必须大于。 - */ - private arcToBezier(x, y, radiusX, radiusY, startAngle, endAngle, anticlockwise?); - } -} -declare namespace egret { - /** - * Writes an error message to the console if the assertion is false. If the assertion is true, nothing will happen. - * @param assertion Any boolean expression. If the assertion is false, the message will get written to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 判断参数assertion是否为true,若为false则抛出异常并且在console输出相应信息,反之什么也不做。 - * @param assertion 一个 boolean 表达式,若结果为false,则抛出错误并输出信息。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外可选信息 - * @language zh_CN - */ - function assert(assertion?: boolean, message?: string, ...optionalParams: any[]): void; - /** - * Writes a warning message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个警告信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function warn(message?: any, ...optionalParams: any[]): void; - /** - * Writes an error message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个错误信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function error(message?: any, ...optionalParams: any[]): void; - /** - * Writes an message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个日志信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function log(message?: any, ...optionalParams: any[]): void; -} -/** - * @private - */ -declare namespace egret { - /** - * @private - */ - let fontMapping: {}; -} -/** - * @private - */ -declare namespace egret_native { - function readUpdateFileSync(filePath: any): any; - function readResourceFileSync(filePath: any): any; - function sendInfoToPlugin(info: string): void; - function receivedPluginInfo(info: string): void; - function nrInit(): void; - function nrDownloadBuffers(callback: (displayCmdBuffer: Float32Array) => void): void; - function nrSetRenderMode(mode: number): void; - function nrRenderDisplayObject(id: number, scale: number, useClip: boolean, clipX: number, clipY: number, clipW: number, clipH: number): void; - function nrRenderDisplayObject2(id: number, offsetX: number, offsetY: number, forHitTest: boolean): void; - function nrLocalToGlobal(id: number, localX: number, localY: number): string; - function nrGlobalToLocal(id: number, globalX: number, globalY: number): string; - function nrGetTextFieldWidth(id: number): number; - function nrGetTextFieldHeight(id: number): number; - function nrGetTextWidth(id: number): number; - function nrGetTextHeight(id: number): number; - function nrResize(width: number, height: number): void; - function nrSetCanvasScaleFactor(factor: number, scalex: number, scaley: number): void; - function nrUpdate(): void; - function nrRender(): void; - function nrSendTextFieldData(textFieldId: number, strData: string): void; - function nrUpdateCallbackList(dt: number): void; - function nrActiveBuffer(id: number, width: number, height: number): void; - function nrGetPixels(x: number, y: number, width: number, height: number, pixels: Uint8Array): void; - function nrGetCustomImageId(type: number): number; - function nrSetCustomImageData(customImageId: number, pvrtcData: any, width: any, height: any, mipmapsCount: any, format: any): void; - class NrNode { - constructor(id: number, type: number); - } -} -/** - * @private - */ -declare namespace egret_native { - let rootWebGLBuffer: egret.sys.RenderBuffer; - let forHitTest: boolean; - let addModuleCallback: (callback: Function, thisObj: any) => void; - let initNativeRender: () => void; - let updateNativeRender: () => void; - let activateBuffer: (buffer: egret.sys.RenderBuffer) => void; - let getJsCustomFilterVertexSrc: (key: any) => any; - let getJsCustomFilterFragSrc: (key: any) => any; - let getJsCustomFilterUniforms: (key: any) => any; - let nrABIVersion: number; - let nrMinEgretVersion: string; -} -declare namespace egret_native { - /** - * @private - */ - class NativeRenderSurface { - width: number; - height: number; - constructor(currRenderBuffer: any, w?: number, h?: number, root?: boolean); - resize(w: number, h: number): void; - } - /** - * @private - */ - class NativeBitmapData { - $init(): any; - $id: any; - } - /** - * @private - */ - class NativeDisplayObject { - id: number; - constructor(type: number); - setChildrenSortMode(mode: string): void; - addChildAt(childId: number, index: number): void; - removeChild(childId: number): void; - swapChild(index1: number, index2: number): void; - setX(value: number): void; - setY(value: number): void; - setRotation(value: number): void; - setScaleX(value: number): void; - setScaleY(value: number): void; - setSkewX(value: number): void; - setSkewY(value: number): void; - setAlpha(value: number): void; - setAnchorOffsetX(value: number): void; - setAnchorOffsetY(value: number): void; - setVisible(value: boolean): void; - setBlendMode(value: number): void; - setMaskRect(x: number, y: number, w: number, h: number): void; - setScrollRect(x: number, y: number, w: number, h: number): void; - setFilters(filters: Array): void; - static createFilter(filter: egret.Filter): void; - static setFilterPadding(filterId: number, paddingTop: number, paddingBottom: number, paddingLeft: number, paddingRight: number): void; - setMask(value: number): void; - static setSourceToNativeBitmapData(nativeBitmapData: egret_native.NativeBitmapData, source: any): any; - setTexture(texture: egret.Texture): void; - setBitmapDataToMesh(texture: egret.Texture): void; - setBitmapDataToParticle(texture: egret.Texture): void; - setWidth(value: number): void; - setHeight(value: number): void; - setCacheAsBitmap(value: boolean): void; - setBitmapFillMode(fillMode: string): void; - setScale9Grid(x: number, y: number, w: number, h: number): void; - setMatrix(a: number, b: number, c: number, d: number, tx: number, ty: number): void; - setIsTyping(value: boolean): void; - setDataToBitmapNode(id: number, texture: egret.Texture, arr: number[]): void; - setDataToMesh(vertexArr: number[], indiceArr: number[], uvArr: number[]): void; - static setDataToFilter(currFilter: egret.Filter): void; - static disposeNativeBitmapData(nativeBitmapData: egret_native.NativeBitmapData): void; - static disposeTextData(node: egret.TextField): void; - static disposeGraphicData(graphic: egret.Graphics): void; - setFontSize(value: number): void; - setLineSpacing(value: number): void; - setTextColor(value: number): void; - setTextFieldWidth(value: number): void; - setTextFieldHeight(value: number): void; - setFontFamily(value: string): void; - setTextFlow(textArr: Array): void; - setTextAlign(value: string): void; - setVerticalAlign(value: string): void; - setText(value: string): void; - setBold(value: boolean): void; - setItalic(value: boolean): void; - setWordWrap(value: boolean): void; - setMaxChars(value: number): void; - setType(value: string): void; - setStrokeColor(value: number): void; - setStroke(value: number): void; - setScrollV(value: number): void; - setMultiline(value: boolean): void; - setBorder(value: boolean): void; - setBorderColor(value: number): void; - setBackground(value: boolean): void; - setBackgroundColor(value: number): void; - setInputType(value: string): void; - setBeginFill(color: number, alpha?: number): void; - setBeginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix: egret.Matrix): void; - setEndFill(): void; - setLineStyle(thickness?: number, color?: number, alpha?: number, pixelHinting?: boolean, scaleMode?: string, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): void; - setDrawRect(x: number, y: number, width: number, height: number): void; - setDrawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - setDrawCircle(x: number, y: number, radius: number): void; - setDrawEllipse(x: number, y: number, width: number, height: number): void; - setMoveTo(x: number, y: number): void; - setLineTo(x: number, y: number): void; - setCurveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - setCubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - setDrawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - setGraphicsClear(): void; - } -} -/** - * @private - */ -declare namespace egret_native { - /** - * @private - */ - const enum NativeObjectType { - /** - * 容器 - */ - CONTAINER = 0, - /** - * 位图 - */ - BITMAP = 1, - /** - * 位图数据 - */ - BITMAP_DATA = 2, - /** - * 滤镜 - */ - FILTER = 6, - /** - * 文本 - */ - TEXT = 7, - /** - * 矢量绘图 - */ - GRAPHICS = 8, - /** - * 含一个适量绘图的容器 - */ - SPRITE = 9, - /** - * 粒子系统 - */ - PARTICLE_SYSTEM = 10, - /** - * 位图文本 - */ - BITMAP_TEXT = 11, - /** - * 网格 - */ - MESH = 12, - /** - * 舞台(根容器) - */ - STAGE = 13, - } -} -declare namespace egret { - /** - * @private - */ - interface MapLike { - [key: string]: T; - [key: number]: T; - } - /** - * @private - */ - function createMap(): MapLike; -} -declare namespace egret { - /** - * @class egret.GlowFilter - * @classdesc - * 使用 GlowFilter 类可以对显示对象应用发光效果。在投影滤镜的 distance 和 angle 属性设置为 0 时,发光滤镜与投影滤镜极为相似。 - * @extends egret.Filter - * @version Egret 3.1.4 - * @platform Web,Native - */ - class GlowFilter extends Filter { - /** - * @private - */ - $red: number; - /** - * @private - */ - $green: number; - /** - * @private - */ - $blue: number; - /** - * Initializes a new GlowFilter instance. - * @method egret.GlowFilter#constructor - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 GlowFilter 对象 - * @method egret.GlowFilter#constructor - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - constructor(color?: number, alpha?: number, blurX?: number, blurY?: number, strength?: number, quality?: number, inner?: boolean, knockout?: boolean); - /** - * @private - */ - $color: number; - /** - * The color of the glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 光晕颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - color: number; - /** - * @private - */ - $alpha: number; - /** - * The alpha transparency value for the color. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 颜色的 Alpha 透明度值。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - alpha: number; - /** - * @private - */ - $blurX: number; - /** - * The amount of horizontal blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - blurX: number; - /** - * @private - */ - $blurY: number; - /** - * The amount of vertical blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - blurY: number; - /** - * @private - */ - $strength: number; - /** - * The strength of the imprint or spread. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 印记或跨页的强度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - strength: number; - /** - * @private - */ - $quality: number; - /** - * The number of times to apply the filter. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 应用滤镜的次数。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - quality: number; - /** - * @private - */ - $inner: boolean; - /** - * Specifies whether the glow is an inner glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定发光是否为内侧发光。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - inner: boolean; - /** - * @private - */ - $knockout: boolean; - /** - * Specifies whether the object has a knockout effect. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定对象是否具有挖空效果。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - knockout: boolean; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - } -} -declare namespace egret { - /** - * The Stage class represents the main drawing area.The Stage object is not globally accessible. You need to access - * it through the stage property of a DisplayObject instance.
- * The Stage class has several ancestor classes — Sprite, DisplayObject, and EventDispatcher — from which it inherits - * properties and methods. Many of these properties and methods are inapplicable to Stage objects. - * @event egret.Event.RESIZE Dispatched when the stageWidth or stageHeight property of the Stage object is changed. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language en_US - */ - /** - * Stage 类代表主绘图区。 - * 可以利用 DisplayObject 实例的 stage 属性进行访问。
- * Stage 类具有多个祖代类: Sprite、DisplayObject 和 EventDispatcher,属性和方法便是从这些类继承而来的。 - * 从这些继承的许多属性和方法不适用于 Stage 对象。 - * @event egret.Event.RESIZE 当stageWidth或stageHeight属性发生改变时调度 - * @event egret.Event.DEACTIVATE 当stage失去焦点后调度 - * @event egret.Event.ACTIVATE 当stage获得焦点后调度 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language zh_CN - */ - class Stage extends DisplayObjectContainer { - /** - * @private - * Stage不许允许自行实例化 - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * Gets and sets the frame rate of the stage. The frame rate is defined as frames per second. Valid range for the - * frame rate is from 0.01 to 1000 frames per second.
- * Note: setting the frameRate property of one Stage object changes the frame rate for all Stage objects - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取并设置舞台的帧速率。帧速率是指每秒显示的帧数。帧速率的有效范围为每秒 0.01 到 60 个帧。
- * 注意: 修改任何一个Stage的frameRate属性都会同步修改其他Stage的帧率。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - frameRate: number; - /** - * @private - */ - $stageWidth: number; - /** - * Indicates the width of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前宽度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageWidth: number; - /** - * @private - */ - $stageHeight: number; - /** - * Indicates the height of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageHeight: number; - /** - * After you call the invalidate() method, when the display list is next rendered, the Egret runtime sends a render - * event to each display object that has registered to listen for the render event. You must call the invalidate() - * method each time you want the Egret runtime to send render events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用 invalidate() 方法后,在显示列表下次呈现时,Egret 会向每个已注册侦听 Event.RENDER 事件的显示对象发送一个 Event.RENDER 事件。 - * 每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 invalidate() 方法。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - invalidate(): void; - /** - * @deprecated - */ - registerImplementation(interfaceName: string, instance: any): void; - /** - * @deprecated - */ - getImplementation(interfaceName: string): any; - /** - * @private - * 设备屏幕引用 - */ - $screen: egret.sys.Screen; - $scaleMode: string; - /** - * A StageScaleMode class that specifies which scale mode to use. The following are valid values:
- *
    - *
  • StageScaleMode.EXACT_FIT -- The entire application be visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur, the application may be stretched or compressed.
  • - *
  • StageScaleMode.SHOW_ALL -- The entire application is visible in the specified area without distortion while maintaining the application of the original aspect ratio. Applications may display border.
  • - *
  • StageScaleMode.NO_SCALE -- The size of the entire application is fixed, so that even if the size of the player window changes, it remains unchanged. If the player window is smaller than the content, it may do some trimming.
  • - *
  • StageScaleMode.NO_BORDER -- Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
  • - *
  • StageScaleMode.FIXED_WIDTH -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
  • - *
  • StageScaleMode.FIXED_HEIGHT -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
  • - *
- * @default egret.StageScaleMode.SHOW_ALL - * @language en_US - */ - /** - * 一个 StageScaleMode 类中指定要使用哪种缩放模式的值。以下是有效值:
- *
    - *
  • StageScaleMode.EXACT_FIT -- 整个应用程序在指定区域中可见,但不尝试保持原始高宽比。可能会发生扭曲,应用程序可能会拉伸或压缩显示。
  • - *
  • StageScaleMode.SHOW_ALL -- 整个应用程序在指定区域中可见,且不发生扭曲,同时保持应用程序的原始高宽比。应用程序的可能会显示边框。
  • - *
  • StageScaleMode.NO_SCALE -- 整个应用程序的大小固定,因此,即使播放器窗口的大小更改,它也会保持不变。如果播放器窗口比内容小,则可能进行一些裁切。
  • - *
  • StageScaleMode.NO_BORDER -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
  • - *
  • StageScaleMode.FIXED_WIDTH -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
  • - *
  • StageScaleMode.FIXED_HEIGHT -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
  • - *
- * @default egret.StageScaleMode.SHOW_ALL - * @language zh_CN - */ - scaleMode: string; - $orientation: string; - /** - * Horizontal and vertical screen display screen, can only be set under the current Native in the configuration file. A egret.OrientationMode class that specifies which display mode to use. The following are valid values:
- *
    - *
  • egret.OrientationMode.AUTO -- Always follow the direction of application display screen, always guaranteed by the look down.
  • - *
  • egret.OrientationMode.PORTRAIT -- Applications remain portrait mode, namely horizontal screen look, the screen from left to right.
  • - *
  • egret.OrientationMode.LANDSCAPE -- Applications remain horizontal screen mode, namely vertical screen, the screen from right to left.
  • - *
  • egret.OrientationMode.LANDSCAPE_FLIPPED -- Applications remain horizontal screen mode, namely vertical screen, the screen from left to right.
  • - *
- * @platform Web - * @version 2.4 - * @language en_US - */ - /** - * 屏幕横竖屏显示方式,目前 Native 下只能在配置文件里设置。一个 egret.OrientationMode 类中指定要使用哪种显示方式。以下是有效值:
- *
    - *
  • egret.OrientationMode.AUTO -- 应用始终跟随屏幕的方向显示,始终保证由上往下看。
  • - *
  • egret.OrientationMode.PORTRAIT -- 应用始终保持竖屏模式,即横屏看时,屏幕由左往右看。
  • - *
  • egret.OrientationMode.LANDSCAPE -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由右往左。
  • - *
  • egret.OrientationMode.LANDSCAPE_FLIPPED -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由左往右。
  • - *
- * @platform Web - * @version 2.4 - * @language zh_CN - */ - orientation: string; - /** - * Draw texture zoom ratio - * @default 1 - * @language en_US - */ - /** - * 绘制纹理的缩放比率,默认值为1 - * @default 1 - * @language zh_CN - */ - textureScaleFactor: number; - $maxTouches: number; - /** - * Set the number of screens can simultaneously touch. Above this amount will not be triggered in response. - * @default 99 - * @language en_US - */ - /** - * 设置屏幕同时可以触摸的数量。高于这个数量将不会被触发响应。 - * @default 99 - * @language zh_CN - */ - maxTouches: number; - /** - * Set resolution size - * @param width width - * @param height height - * @version Egret 2.5.5 - * @platform Web,Native - * @language en_US - */ - /** - * 设置分辨率尺寸 - * @param width 宽度 - * @param height 高度 - * @version Egret 2.5.5 - * @platform Web,Native - * @language zh_CN - */ - setContentSize(width: number, height: number): void; - } -} -declare namespace egret { - /** - * A class that provides constant values for visual blend mode effects. These constants are used in the blendMode - * property of the DisplayObject class. - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language en_US - */ - /** - * 提供混合模式可视效果的常量值的类,通常用于 DisplayObject 的 blendMode 属性上。 - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language zh_CN - */ - class BlendMode { - /** - * The display object appears in front of the background. Pixel values of the display object override the pixel - * values of the background. Where the display object is transparent, the background is visible. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该显示对象出现在背景前面。显示对象的像素值会覆盖背景的像素值。在显示对象为透明的区域,背景是可见的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static NORMAL: string; - /** - * Adds the values of the constituent colors of the display object to the colors of its background, applying a - * ceiling of 0xFF. This setting is commonly used for animating a lightening dissolve between two objects.
- * For example, if the display object has a pixel with an RGB value of 0xAAA633, and the background pixel has an - * RGB value of 0xDD2200, the resulting RGB value for the displayed pixel is 0xFFC833 (because 0xAA + 0xDD > 0xFF, - * 0xA6 + 0x22 = 0xC8, and 0x33 + 0x00 = 0x33). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的原色值添加到它的背景颜色中,上限值为 0xFF。此设置通常用于使两个对象间的加亮溶解产生动画效果。
- * 例如,如果显示对象的某个像素的 RGB 值为 0xAAA633,背景像素的 RGB 值为 0xDD2200,则显示像素的结果 RGB 值为 0xFFC833 - * (因为 0xAA + 0xDD > 0xFF,0xA6 + 0x22 = 0xC8,且 0x33 + 0x00 = 0x33)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADD: string; - /** - * Erases the background based on the alpha value of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据显示对象的 Alpha 值擦除背景。Alpha 值不为0的区域将被擦除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ERASE: string; - } -} -declare namespace egret.sys { - /** - * @private - * 转换 blendMode 字符串为数字。 - */ - function blendModeToNumber(blendMode: string): number; - /** - * @private - * 转换数字为 blendMode 字符串。 - */ - function numberToBlendMode(blendMode: number): string; -} -declare namespace egret { - /** - * The ChildrenSortMode class defines a pattern enumeration for children sort mode of egret.DisplayObjectContainer. - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - /** - * BitmapFillMode 类定义egret.DisplayObjectContainer的子项目排序方式。 - * @version Egret 5.2.19 - * @platform Native - * @language zh_CN - */ - const ChildrenSortMode: { - DEFAULT: string; - INCREASE_Y: string; - DECREASE_Y: string; - }; -} -declare namespace egret { - /** - * The CapsStyle class is an enumeration of constant values that specify the caps style to use in drawing lines. - * The constants are provided for use as values in the caps parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * CapsStyle 类是可指定在绘制线条中使用的端点样式的常量值枚举。常量可用作 egret.Graphics.lineStyle() 方法的 caps 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - const CapsStyle: { - NONE: string; - ROUND: string; - SQUARE: string; - }; -} -declare namespace egret { - /** - * @private - */ - class WebGLUtils { - static compileProgram(gl: WebGLRenderingContext, vertexSrc: string, fragmentSrc: string): WebGLProgram; - static compileFragmentShader(gl: WebGLRenderingContext, shaderSrc: string): WebGLShader; - static compileVertexShader(gl: WebGLRenderingContext, shaderSrc: string): WebGLShader; - private static _compileShader(gl, shaderSrc, shaderType); - private static canUseWebGL; - static checkCanUseWebGL(): boolean; - static deleteWebGLTexture(webglTexture: WebGLTexture): void; - /** - * inspired by pixi.js - */ - static premultiplyTint(tint: number, alpha: number): number; - } -} -declare namespace egret { - /** - * The EventPhase class provides values for the eventPhase property of the Event class. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventPhase.ts - * @language en_US - */ - /** - * EventPhase 可为 Event 类的 eventPhase 属性提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventPhase.ts - * @language zh_CN - */ - const enum EventPhase { - /** - * The capturing phase, which is the first phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 捕获阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - CAPTURING_PHASE = 1, - /** - * The target phase, which is the second phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 目标阶段,是事件流的第二个阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - AT_TARGET = 2, - /** - * The bubbling phase, which is the third phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 冒泡阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BUBBLING_PHASE = 3, - } -} -declare namespace egret { - /** - * When the user changes the focus from one object in the display list to another object, the object dispatches a FocusEvent object. Currently only supports input text. - * Focus events: FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用户将焦点从显示列表中的一个对象更改到另一个对象时,对象将调度 FocusEvent 对象。目前只支持输入文本。 - * 焦点事件:FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class FocusEvent extends egret.Event { - /** - * Gets focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_IN: "focusIn"; - /** - * Loses focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_OUT: "focusOut"; - /** - * Create a egret.FocusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.FocusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - } -} -declare namespace egret { - interface Geolocation { - addEventListener(type: "ioError", listener: (this: Z, e: GeolocationEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * The GeolocationEvent represents the position and altitude of the device on Earth, - * and show errors occurred while getting the location of the device. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language en_US - */ - /** - * GeolocationEvent 提供设备的地理位置信息和获取位置时发生的错误信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language zh_CN - */ - class GeolocationEvent extends Event { - /** - * The acquisition of the location information failed because of app don't have permission. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由于用户拒绝访问位置信息,获取位置信息失败 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static PERMISSION_DENIED: string; - /** - * The acquisition of the location failed because at least one internal source of position returned an internal error. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设备位置服务不可用或者超时等原因没有得到位置信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static UNAVAILABLE: string; - /** - * The position's longitude in decimal degrees. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前位置的经度信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - longitude: number; - /** - * The position's latitude in decimal degrees. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前位置的纬度信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - latitude: number; - /** - * The velocity of the device in meters per second. This value can be null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前设备的速度 单位是 米/秒,这个值可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - speed: number; - /** - * The direction in which the device is traveling. This value, specified in degrees, - * indicates how far off from heading due north the device is. 0 degrees represents - * true true north, and the direction is determined clockwise (which means that east - * is 90 degrees and west is 270 degrees). If speed is 0, heading is NaN. If the - * device is unable to provide heading information, this value is null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备正在前进的方向,单位是度。heading 表示从正北开始顺时针旋转到当前方向的角度, - * 比如正东是 90 度,正西是 270 度,如果 speed 是 0,heading 为 NaN。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - heading: number; - /** - * The position's altitude in metres, relative to sea level. - * This value can be null if the implementation cannot provide the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该位置的海拔信息,如果设备没有实现这个属性时,这个值有可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - altitude: number; - /** - * The accuracy of the latitude and longitude properties, expressed in meters. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 经纬度的准确性,单位是米 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - accuracy: number; - /** - * The accuracy of the altitude expressed in meters. This value can be null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该位置海拔信息的准确性,单位是米,这个值有可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - altitudeAccuracy: number; - /** - * The type of error occurred while get the location of the device. The value could be: - * @see egret.GeolocationEvent.PERMISSION_DENIED - * @see egret.GeolocationEvent.UNAVAILABLE - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位置信息错误时的错误类型。值可能为: - * @see egret.GeolocationEvent.PERMISSION_DENIED - * @see egret.GeolocationEvent.UNAVAILABLE - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - errorType: string; - /** - * The error message occurred while get the location of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位置信息错误的错误信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - errorMessage: string; - } -} -declare namespace egret { - /** - * When a network request returns an HTTP status code, the application dispatches HTTPStatusEvent objects. - * Before error or completion events will always send HTTPStatusEvent object. HTTPStatusEvent object does not necessarily indicate an error condition; it simply reflects the HTTP status code provided by the network stack (if any). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在网络请求返回 HTTP 状态代码时,应用程序将调度 HTTPStatusEvent 对象。 - * 在错误或完成事件之前,将始终发送 HTTPStatusEvent 对象。HTTPStatusEvent 对象不一定表示错误条件;它仅反映网络堆栈提供的 HTTP 状态代码(如果有的话)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HTTPStatusEvent extends Event { - /** - * HTTPStatusEvent.HTTP_STATUS constant defines the value of the type property httpStatus event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HTTPStatusEvent.HTTP_STATUS 常量定义 httpStatus 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static HTTP_STATUS: "httpStatus"; - /** - * Create a egret.HTTPStatusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.HTTPStatusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * @private - */ - private _status; - /** - * he server returns the HTTP status code. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由服务器返回的 HTTP 状态代码。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly status: number; - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param status {number} The server returns the HTTP status code - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param status {number} 由服务器返回的 HTTP 状态代码 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchHTTPStatusEvent(target: IEventDispatcher, status: number): boolean; - } -} -declare namespace egret { - /** - * The IEventDispatcher interface defines methods for adding or removing event listeners, checks whether specific types - * of event listeners are registered, and dispatches events. Event targets are an important part of the Egret event model. - * The event target serves as the focal point for how events flow through the display list hierarchy. When an event - * such as a touch tap occurs, an event object is dispatched into the event flow from the root of the display list. - * The event object makes a round-trip journey to the event target, which is conceptually divided into three phases:
- * the capture phase includes the journey from the root to the last node before the event target's node; the target - * phase includes only the event target node; and the bubbling phase includes any subsequent nodes encountered on the - * return trip to the root of the display list.In general, the easiest way for a user-defined class to gain event - * dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already - * extending another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, - * and write simple hooks to route calls into the aggregated EventDispatcher. - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IEventDispatcher.ts - * @language en_US - */ - /** - * IEventDispatcher 接口定义用于添加或删除事件侦听器的方法,检查是否已注册特定类型的事件侦听器,并调度事件。 - * 事件目标是 Egret 事件模型的重要组成部分。事件目标是事件如何通过显示列表层次结构这一问题的焦点。当发生触摸轻拍事件时, - * 会将事件对象调度到从显示列表根开始的事件流中。事件对象进行到事件目标的往返行程,在概念上,此往返行程被划分为三个阶段:
- * 捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括到显示列表的根的回程上遇到的任何后续节点。 - * 通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。如果无法扩展(即,如果该类已经扩展了另一个类), - * 则可以实现 IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的挂钩,将调用连接到聚合的 EventDispatcher 中。 - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IEventDispatcher.ts - * @language zh_CN - */ - interface IEventDispatcher extends HashObject { - /** - * Registers an event listener object with an EventDispatcher object so that the listener receives notification of an - * event. You can register event listeners on all nodes in the display list for a specific type of event, phase, - * and priority.After you successfully register an event listener, you cannot change its priority through additional - * calls to on(). To change a listener's priority, you must first call removeEventListener(). Then you can register the - * listener again with the new priority level.After the listener is registered, subsequent calls to on() with a - * different value for either type or useCapture result in the creation of a separate listener registration.
- * When you no longer need an event listener, remove it by calling EventDispatcher.removeEventListener(); otherwise, memory - * problems might result. Objects with registered event listeners are not automatically removed from memory because - * the garbage collector does not remove objects that still have references.Copying an EventDispatcher instance does - * not copy the event listeners attached to it. (If your newly created node needs an event listener, you must attach - * the listener after creating the node.) However, if you move an EventDispatcher instance, the event listeners attached - * to it move along with it.If the event listener is being registered on a node while an event is also being processed - * on this node, the event listener is not triggered during the current phase but may be triggered during a later phase - * in the event flow, such as the bubbling phase.If an event listener is removed from a node while an event is being - * processed on the node, it is still triggered by the current actions. After it is removed, the event listener is - * never invoked again (unless it is registered again for future processing). - * @param type The type of event. - * @param listener The listener function that processes the event. This function must accept an event object as - * its only parameter and must return nothing, as this example shows: function(evt:Event):void The function can - * have any name. - * @param thisObject the listener function's "this" - * @param useCapture Determines whether the listener works in the capture phase or the bubbling phases. If useCapture - * is set to true, the listener processes the event only during the capture phase and not in the bubbling phase. - * If useCapture is false, the listener processes the event only during the bubbling phase. To listen for the event - * in all three phases, call on() twice, once with useCapture set to true, then again with useCapture set to false. - * @param priority The priority level of the event listener. Priorities are designated by a integer. The higher - * the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. - * If two or more listeners share the same priority, they are processed in the order in which they were added. - * The default priority is - * @see #once() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。可以为特定类型的事件、阶段和优先级在显示列表的所有节 - * 点上注册事件侦听器。成功注册一个事件侦听器后,无法通过额外调用 on() 来更改其优先级。要更改侦听器的优先级,必须 - * 先调用 removeEventListener()。然后,可以使用新的优先级再次注册该侦听器。注册该侦听器后,如果继续调用具有不同 type 或 useCapture - * 值的 on(),则会创建单独的侦听器注册。
- * 如果不再需要某个事件侦听器,可调用 EventDispatcher.removeEventListener() - * 删除它;否则会产生内存问题。由于垃圾回收器不会删除仍包含引用的对象,因此不会从内存中自动删除使用已注册事件侦听器的对象。复制 - * EventDispatcher 实例时并不复制其中附加的事件侦听器。(如果新近创建的节点需要一个事件侦听器,必须在创建该节点后附加该侦听器。) - * 但是,如果移动 EventDispatcher 实例,则其中附加的事件侦听器也会随之移动。如果在正在处理事件的节点上注册事件侦听器,则不会在当 - * 前阶段触发事件侦听器,但会在事件流的稍后阶段触发,如冒泡阶段。如果从正在处理事件的节点中删除事件侦听器,则该事件侦听器仍由当前操 - * 作触发。删除事件侦听器后,决不会再次调用该事件侦听器(除非再次注册以备将来处理)。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在冒泡阶段处理事件。 - * 要在两个阶段都侦听事件,请调用 on() 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号的整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see #once() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Registers an event listener object with an EventDispatcher object so that the listener receives notification of an - * event. Different from the on() method,the listener receives notification only once,and then it will be removed - * automatically. - * @param type The type of event. - * @param listener The listener function that processes the event. This function must accept an event object as - * its only parameter and must return nothing, as this example shows: function(evt:Event):void The function can - * have any name. - * @param thisObject the listener function's "this" - * @param useCapture Determines whether the listener works in the capture phase or the bubbling phases. If useCapture - * is set to true, the listener processes the event only during the capture phase and not in the bubbling phase. - * If useCapture is false, the listener processes the event only during the bubbling phase. To listen for the event - * in all three phases, call on() twice, once with useCapture set to true, then again with useCapture set to false. - * @param priority The priority level of the event listener. Priorities are designated by a integer. The higher - * the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. - * If two or more listeners share the same priority, they are processed in the order in which they were added. - * The default priority is - * @see #on() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 添加仅回调一次的事件侦听器,此方法与on()方法不同,on()方法会持续产生回调,而此方法在第一次回调时就会自动移除监听。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在冒泡阶段处理事件。 - * 要在两个阶段都侦听事件,请调用 once() 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see #on() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - once(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Removes a listener from the EventDispatcher object. If there is no matching listener registered with the - * EventDispatcher object, a call to this method has no effect. - * @param type The type of event. - * @param listener The listener object to remove. - * @param thisObject the listener function's "this" - * @param useCapture Specifies whether the listener was registered for the capture phase or the bubbling phases. - * If the listener was registered for both the capture phase and the bubbling phases, two calls to removeEventListener() - * are required to remove both: one call with useCapture set to true, and another call with useCapture set to false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 EventDispatcher 对象中删除侦听器。如果没有向 EventDispatcher 对象注册任何匹配的侦听器,则对此方法的调用没有任何效果。 - * @param type 事件的类型。 - * @param listener 要删除的侦听器对象 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 指出是为捕获阶段还是为冒泡阶段注册了侦听器。如果为捕获阶段以及冒泡阶段注册了侦听器,则需要对 - * removeEventListener() 进行两次调用才能将这两个侦听器删除:一次调用将 useCapture 设置为 true,另一次调用将 useCapture 设置为 false。。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - /** - * Checks whether the EventDispatcher object has any listeners registered for a specific type of event. This allows - * you to determine where an EventDispatcher object has altered handling of an event type in the event flow hierarchy. - * To determine whether a specific event type will actually trigger an event listener, use IEventDispatcher.willTrigger(). - * The difference between hasEventListener() and willTrigger() is that hasEventListener() examines only the object to - * which it belongs, whereas willTrigger() examines the entire event flow for the event specified by the type parameter. - * @param type The type of event. - * @returns A value of true if a listener of the specified type is registered; false otherwise. - * @see #willTrigger() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。这样,您就可以确定 EventDispatcher 对象在事件流层次结构中的哪个 - * 位置改变了对事件类型的处理。要确定特定事件类型是否确实会触发事件侦听器,请使用 IEventDispatcher.willTrigger()。hasEventListener() - * 与 willTrigger() 的区别是:hasEventListener() 只检查它所属的对象,而 willTrigger() 检查整个事件流以查找由 type 参数指定的事件。 - * @param type 事件的类型。 - * @returns 如果指定类型的侦听器已注册,则值为 true;否则,值为 false。 - * @see #willTrigger() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - hasEventListener(type: string): boolean; - /** - * Dispatches an event into the event flow. The event target is the EventDispatcher object upon which dispatchEvent() is called. - * @param event The event object dispatched into the event flow. - * @returns A value of true unless preventDefault() is called on the event, in which case it returns false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将事件分派到事件流中。事件目标是对其调用 dispatchEvent() 方法的 EventDispatcher 对象。 - * @param event 调度到事件流中的 Event 对象。 - * @returns 如果成功调度了事件,则值为 true。值 false 表示失败或对事件调用了 preventDefault()。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispatchEvent(event: Event): boolean; - /** - * Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the - * specified event type. This method returns true if an event listener is triggered during any phase of the event - * flow when an event of the specified type is dispatched to this EventDispatcher object or any of its descendants. - * @param type The type of event. - * @returns A value of true if a listener of the specified type will be triggered; false otherwise. - * @see #hasEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查是否用此 EventDispatcher 对象或其任何始祖为指定事件类型注册了事件侦听器。将指定类型的事件调度给此 - * EventDispatcher 对象或其任一后代时,如果在事件流的任何阶段触发了事件侦听器,则此方法返回 true。 - * hasEventListener() 与 willTrigger() 方法的区别是:hasEventListener() 只检查它所属的对象, - * 而 willTrigger() 方法检查整个事件流以查找由 type 参数指定的事件。 - * @param type 事件类型 - * @returns 是否注册过监听器,如果注册过返回true,反之返回false - * @see #hasEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - willTrigger(type: string): boolean; - } -} -declare namespace egret { - interface HttpRequest { - addEventListener(type: "ioError", listener: (this: Z, e: IOErrorEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language en_US - */ - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language zh_CN - */ - class IOErrorEvent extends Event { - /** - * io error - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * io发生错误 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static IO_ERROR: "ioError"; - /** - * Create a egret.IOErrorEvent objects - * @param type {string} Type of event, accessible as Event.type. - * @param bubbles {boolean} Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable {boolean} Determine whether the Event object can be canceled. The default value is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.IOErrorEvent 对象 - * @param type {string} 事件的类型,可以作为 Event.type 访问。 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchIOErrorEvent(target: IEventDispatcher): boolean; - } -} -declare namespace egret { - /** - * MotionEvent represents the device's movement - * Acceleration and accelerationIncludingGravity to represents the device's acceleration - * RotationRate to represents the device's rotation - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language en_US - */ - /** - * MotionEvent 类呈现设备运动的具体信息 - * Acceleration 和 accelerationIncludingGravity 呈现设备三个维度的加速度信息 - * RotationRate 呈现设备的旋转状态信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language zh_CN - */ - class MotionEvent extends Event { - /** - * An object giving the acceleration of the device on the three axis X, Y and Z. Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * acceleration 表示设备在 X Y Z 轴方将的加速度信息,单位是 m/s2,不包含重力 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - acceleration: DeviceAcceleration; - /** - * An object giving the acceleration of the device on the three axis X, Y and Z with the effect of gravity. Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * acceleration 表示设备在 X Y Z 轴方将的加速度信息,单位是 m/s2,包含重力 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - accelerationIncludingGravity: DeviceAcceleration; - /** - * An object giving the rate of change of the device's orientation on the three orientation axis alpha, beta and gamma. Rotation rate is express in degrees per seconds. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * rotationRate 表示设备在 alpha、 beta 和 gamma 三个轴向的角速度信息,单位是 角度每秒 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotationRate: DeviceRotationRate; - } -} -declare namespace egret { - /** - * The OrientationEvent provides information from the physical orientation of the device. - * Note: Currently, Browsers on the iOS and Android does not handle the coordinates the same way. - * Take care about this while using them. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language en_US - */ - /** - * OrientationEvent 提供设备的方向信息 - * 注意: 目前各个浏览器和操作系统处理方向的方式不完全相同,请根据使用场景做相应的校正, - * 比如使用两次方向数据的变化而不是直接使用方向的值 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language zh_CN - */ - class OrientationEvent extends Event { - /** - * A number representing the motion of the device around the z axis, - * express in degrees with values ranging from 0 to 360 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 Z 轴的角度,单位是 角度 范围是 0 到 360 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - alpha: number; - /** - * A number representing the motion of the device around the x axis, - * express in degrees with values ranging from -180 to 180. - * This represents a front to back motion of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 X 轴的角度,单位是 角度 范围是 -180 到 180. - * 这个值表示设备从前向后的旋转状态 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - beta: number; - /** - * A number representing the motion of the device around the y axis, - * express in degrees with values ranging from -90 to 90. - * This represents a left to right motion of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 Y 轴的角度,单位是 角度 范围是 -90 到 90. - * 这个值表示设备从前向后的旋转状态 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - gamma: number; - } -} -declare namespace egret { - interface HttpRequest { - addEventListener(type: "progress", listener: (this: Z, e: ProgressEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * When a load operation has begun or a socket has received data, ProgressEvent object is dispatched. - * There are two types of progress events: ProgressEvent.PROGRESS and ProgressEvent.SOCKET_DATA. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当加载操作已开始或套接字已接收到数据时,将调度 ProgressEvent 对象。 - * 有两种类型的进程事件:ProgressEvent.PROGRESS 和 ProgressEvent.SOCKET_DATA。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class ProgressEvent extends egret.Event { - /** - * Changes in the loading progress - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 加载进度发生变化 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static PROGRESS: "progress"; - /** - * Get the data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取到数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static SOCKET_DATA: "socketData"; - /** - * Number of items or bytes when the listener processes the event。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在侦听器处理事件时加载的项数或字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bytesLoaded: number; - /** - * If the loading process succeeds, the total number or the total number of bytes that will be loaded term. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果加载过程成功,将加载的总项数或总字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bytesTotal: number; - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, bytesLoaded?: number, bytesTotal?: number); - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param type The type of the event, accessible as Event.type. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchProgressEvent(target: IEventDispatcher, type: string, bytesLoaded?: number, bytesTotal?: number): boolean; - } -} -declare namespace egret { - interface Stage { - addEventListener(type: "orientationChange", listener: (this: Z, e: StageOrientationEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * When the direction of the stage of change, Stage object dispatches StageOrientationEvent object. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language en_US - */ - /** - * 当舞台的方向更改时,Stage 对象将调度 StageOrientationEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language zh_CN - */ - class StageOrientationEvent extends Event { - /** - * After screen rotation distribute events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 屏幕旋转后派发的事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ORIENTATION_CHANGE: "orientationChange"; - /** - * Creating contains specific information related to the event and the stage direction of StageOrientationEvent object. - * @param type Event types:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles It indicates whether the Event object participates in the bubbling stage of the event flow. - * @param cancelable It indicates whether the Event object can be canceled. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建包含与舞台方向事件相关的特定信息的 StageOrientationEvent 对象。 - * @param type 事件的类型:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles 表示 Event 对象是否参与事件流的冒泡阶段。 - * @param cancelable 表示是否可以取消 Event 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {egret.IEventDispatcher} 派发事件类型 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} Distribute event target - * @param type {egret.IEventDispatcher} Distribute event type - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchStageOrientationEvent(target: IEventDispatcher, type: string): boolean; - } -} -declare namespace egret { - /** - * When a user clicks a hyperlink rich text object dispatches TextEvent object. Text Event Type: TextEvent.LINK. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language en_US - */ - /** - * 用户在富文本中单击超链接时,对象将调度 TextEvent 对象。文本事件类型:TextEvent.LINK。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language zh_CN - */ - class TextEvent extends Event { - /** - * TextEvent create an object that contains information about text events. - * @param type Type of event, you can access the TextEvent.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determine whether the Event object can be canceled. The default value is false. - * @param text One or more characters of text entered by the user. Event listeners can access this information through the text property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TextEvent 对象,其中包含有关文本事件的信息。 - * @param type 事件的类型,可以作为 TextEvent.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param text 用户输入的一个或多个文本字符。事件侦听器可以通过 text 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, text?: string); - /** - * It defines the value of the type property of a link event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 定义 link 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LINK: "link"; - /** - * In TextEvent.LINK event, event corresponding string. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在 TextEvent.LINK 事件中,event对应的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * EventDispatcher object using the specified event object thrown TextEvent. The objects will be thrown in the object cache pool for the next round robin. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param text Text TextEvent object assignment - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出TextEvent事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件类型 - * @param text TextEvent对象的text赋值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTextEvent(target: IEventDispatcher, type: string, text: string): boolean; - } -} -declare namespace egret { - interface Timer { - addEventListener(type: "timer" | "timerComplete", listener: (this: Z, e: TimerEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * A Timer object dispatches a TimerEvent objects whenever the Timer object reaches the interval specified by the Timer.delay property. - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language en_US - */ - /** - * 每当 Timer 对象达到由 Timer.delay 属性指定的间隔时,Timer 对象即会调度 TimerEvent 对象。 - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language zh_CN - */ - class TimerEvent extends Event { - /** - * Dispatched whenever a Timer object reaches an interval specified according to the Timer.delay property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当 Timer 对象达到根据 Timer.delay 属性指定的间隔时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TIMER: "timer"; - /** - * Dispatched whenever it has completed the number of requests set by Timer.repeatCount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当它完成 Timer.repeatCount 设置的请求数后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TIMER_COMPLETE: "timerComplete"; - /** - * Creates an Event object with specific information relevant to timer events. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Event 对象,其中包含有关 timer 事件的特定信息。 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @example - *
-         *    function onTimer(event:TimerEvent):void {
-         *        if (40 < mySp.x && mySp.x < 375) {
-         *            mySp.x-= 50;
-         *        } else {
-         *            mySp.x=374;
-         *        }
-         *        event.updateAfterEvent();
-         *    }
-         *
-         *    let moveTimer:Timer=new Timer(50,250);
-         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
-         *    moveTimer.start();
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @example - *
-         *    function onTimer(event:TimerEvent):void {
-         *        if (40 < mySp.x && mySp.x < 375) {
-         *            mySp.x-= 50;
-         *        } else {
-         *            mySp.x=374;
-         *        }
-         *        event.updateAfterEvent();
-         *    }
-         *
-         *    let moveTimer:Timer=new Timer(50,250);
-         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
-         *    moveTimer.start();
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - updateAfterEvent(): void; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 事件派发目标 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTimerEvent(target: IEventDispatcher, type: string, bubbles?: boolean, cancelable?: boolean): boolean; - } -} -declare namespace egret { - class CompressedTextureData { - glInternalFormat: number; - width: number; - height: number; - byteArray: Uint8Array; - face: number; - level: number; - } - const etc_alpha_mask = "etc_alpha_mask"; - const engine_default_empty_texture = "engine_default_empty_texture"; - const is_compressed_texture = "is_compressed_texture"; - const glContext = "glContext"; - const UNPACK_PREMULTIPLY_ALPHA_WEBGL = "UNPACK_PREMULTIPLY_ALPHA_WEBGL"; - /** - * A BitmapData object contains an array of pixel data. This data can represent either a fully opaque bitmap or a - * transparent bitmap that contains alpha channel data. Either type of BitmapData object is stored as a buffer of 32-bit - * integers. Each 32-bit integer determines the properties of a single pixel in the bitmap.
- * Each 32-bit integer is a combination of four 8-bit channel values (from 0 to 255) that describe the alpha transparency - * and the red, green, and blue (ARGB) values of the pixel. (For ARGB values, the most significant byte represents the - * alpha channel value, followed by red, green, and blue.) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapData 对象是一个包含像素数据的数组。此数据可以表示完全不透明的位图,或表示包含 Alpha 通道数据的透明位图。 - * 以上任一类型的 BitmapData 对象都作为 32 位整数的缓冲区进行存储。每个 32 位整数确定位图中单个像素的属性。
- * 每个 32 位整数都是四个 8 位通道值(从 0 到 255)的组合,这些值描述像素的 Alpha 透明度以及红色、绿色、蓝色 (ARGB) 值。 - * (对于 ARGB 值,最高有效字节代表 Alpha 通道值,其后的有效字节分别代表红色、绿色和蓝色通道值。) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class BitmapData extends HashObject { - /** - * The width of the bitmap image in pixels. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 位图图像的宽度,以像素为单位。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * The height of the bitmap image in pixels. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 位图图像的高度,以像素为单位。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - /** - * Original bitmap image. - * HTMLImageElement|HTMLCanvasElement|HTMLVideoElement - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * 原始位图图像。 - * HTMLImageElement|HTMLCanvasElement|HTMLVideoElement - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language zh_CN - */ - $source: any; - /** - * WebGL texture. - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * WebGL纹理。 - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language zh_CN - */ - webGLTexture: any; - /** - * Texture format. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理格式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - format: string; - /** - * @private - * webgl纹理生成后,是否删掉原始图像数据 - */ - $deleteSource: boolean; - /** - * @private - * id - */ - $nativeBitmapData: egret_native.NativeBitmapData; - /** - * @private - * - */ - readonly compressedTextureData: Array>; - debugCompressedTextureURL: string; - etcAlphaMask: Nullable; - /** - * Initializes a BitmapData object to refer to the specified source object. - * @param source The source object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 source 实例的 BitmapData 对象 - * @param source 被引用的 source 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(source: any); - source: any; - static create(type: "arraybuffer", data: ArrayBuffer, callback?: (bitmapData: BitmapData) => void): BitmapData; - static create(type: "base64", data: string, callback?: (bitmapData: BitmapData) => void): BitmapData; - $dispose(): void; - private static _displayList; - static $addDisplayObject(displayObject: DisplayObject, bitmapData: BitmapData): void; - static $removeDisplayObject(displayObject: DisplayObject, bitmapData: BitmapData): void; - static $invalidate(bitmapData: BitmapData): void; - static $dispose(bitmapData: BitmapData): void; - private _getCompressedTextureData(level, face); - getCompressed2dTextureData(): CompressedTextureData; - hasCompressed2d(): boolean; - clearCompressedTextureData(): void; - } -} -declare namespace egret { - interface DisplayObject { - addEventListener(type: "touchMove" | "touchBegin" | "touchEnd" | "touchCancel" | "touchTap" | "touchReleaseOutside" | "touchRollOut" | "touchRollOver", listener: (this: Z, e: TouchEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * The TouchEvent class lets you handle events on devices that detect user contact with the device (such as a finger - * on a touch screen).When a user interacts with a device such as a mobile phone or tablet with a touch screen, the - * user typically touches the screen with his or her fingers or a pointing device. You can develop applications that - * respond to basic touch events (such as a single finger tap) with the TouchEvent class. Create event listeners using - * the event types defined in this class. - * Note: When objects are nested on the display list, touch events target the deepest possible nested object that is - * visible in the display list. This object is called the target node. To have a target node's ancestor (an object - * containing the target node in the display list) receive notification of a touch event, use EventDispatcher.addEventListener() - * on the ancestor node with the type parameter set to the specific touch event you want to detect. - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language en_US - */ - /** - * 使用 TouchEvent 类,您可以处理设备上那些检测用户与设备之间的接触的事件。 - * 当用户与带有触摸屏的移动电话或平板电脑等设备交互时,用户通常使用手指或指针设备接触屏幕。可使用 TouchEvent - * 类开发响应基本触摸事件(如单个手指点击)的应用程序。使用此类中定义的事件类型创建事件侦听器。 - * 注意:当对象嵌套在显示列表中时,触摸事件的目标将是显示列表中可见的最深的可能嵌套对象。 - * 此对象称为目标节点。要使目标节点的祖代(祖代是一个包含显示列表中所有目标节点的对象,从舞台到目标节点的父节点均包括在内) - * 接收触摸事件的通知,请对祖代节点使用 EventDispatcher.on() 并将 type 参数设置为要检测的特定触摸事件。 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language zh_CN - */ - class TouchEvent extends Event { - /** - * Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_MOVE: "touchMove"; - /** - * Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户第一次触摸启用触摸的设备时(例如,用手指触摸配有触摸屏的移动电话或平板电脑)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_BEGIN: "touchBegin"; - /** - * Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone - * or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户移除与启用触摸的设备的接触时(例如,将手指从配有触摸屏的移动电话或平板电脑上抬起)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_END: "touchEnd"; - /** - * Dispatched when an event of some kind occurred that canceled the touch. - * Such as the eui.Scroller will dispatch 'TOUCH_CANCEL' when it start move, the 'TOUCH_END' and 'TOUCH_TAP' will not be triggered. - * @version Egret 3.0.1 - * @platform Web,Native - * @language en_US - */ - /** - * 由于某个事件取消了触摸时触发。比如 eui.Scroller 在开始滚动后会触发 'TOUCH_CANCEL' 事件,不再触发后续的 'TOUCH_END' 和 'TOUCH_TAP' 事件 - * @version Egret 3.0.1 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_CANCEL: "touchCancel"; - /** - * Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact - * was initiated on a touch-enabled device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的同一 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_TAP: "touchTap"; - /** - * Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact - * was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display - * object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的不同 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_RELEASE_OUTSIDE: "touchReleaseOutside"; - /** - * Creates an Event object that contains information about touch events. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number assigned to the touch point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TouchEvent 对象,其中包含有关Touch事件的信息 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, stageX?: number, stageY?: number, touchPointID?: number); - /** - * @private - */ - $initTo(stageX: number, stageY: number, touchPointID: number): void; - /** - * @private - */ - $stageX: number; - /** - * The horizontal coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageX: number; - /** - * @private - */ - $stageY: number; - /** - * The vertical coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageY: number; - private _localX; - /** - * The horizontal coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly localX: number; - private _localY; - /** - * The vertical coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly localY: number; - private targetChanged; - /** - * @private - */ - private getLocalXY(); - $setTarget(target: any): boolean; - /** - * A unique identification number assigned to the touch point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 分配给触摸点的唯一标识号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchPointID: number; - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - updateAfterEvent(): void; - /** - * Whether the touch is pressed (true) or not pressed (false). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示触摸已按下 (true) 还是未按下 (false)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchDown: boolean; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number (as an int) assigned to the touch point. - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTouchEvent(target: IEventDispatcher, type: string, bubbles?: boolean, cancelable?: boolean, stageX?: number, stageY?: number, touchPointID?: number, touchDown?: boolean): boolean; - } -} -declare namespace egret { - /** - * h5 and native interaction. - * @see http://edn.egret.com/cn/article/index/id/714 Egret basic skills to communicate with Native - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/external/ExternalInterface.ts - * @language en_US - */ - /** - * h5与native交互。 - * @see http://edn.egret.com/cn/article/index/id/714 Egret 与 Native 通信基本技巧 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/external/ExternalInterface.ts - * @language zh_CN - */ - interface ExternalInterface { - } - let ExternalInterface: { - /** - * Call functionName, and the value passed to the native. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用 functionName,并将value传入到native中。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - call(functionName: string, value: string): void; - /** - * FunctionName callback listener, you need to have to call functionName this field in native rather than such a call. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 监听 functionName 回调,需要在native中有调用 functionName 这个字段,而不是 此类的call。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addCallback(functionName: string, listener: (value: string) => void): void; - }; -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - const enum BitmapFilterQuality { - /** - * 定义低品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - LOW = 1, - /** - * 定义中等品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - MEDIUM = 2, - /** - * 定义高品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - HIGH = 3, - } -} -declare namespace egret { - /** - * The BlurFilter class lets you apply a blur visual effect to display objects. A blur effect softens the details of an image. - * You can produce blurs that range from a softly unfocused look to a Gaussian blur, a hazy appearance like viewing an image through semi-opaque glass. - * @version Egret 3.0.1 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language en_US - */ - /** - * 可使用 BlurFilter 类将模糊视觉效果应用于显示对象。模糊效果可以柔化图像的细节。 - * 您可以生成一些模糊效果,范围从创建一个柔化的、未聚焦的外观到高斯模糊(就像通过半透明玻璃查看图像一样的朦胧的外观)。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language zh_CN - */ - class BlurFilter extends Filter { - /** - * Initializes a BlurFilter object. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param quality {number} The number of times to apply the filter. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 BlurFilter 对象。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - constructor(blurX?: number, blurY?: number, quality?: number); - /** - * @private - */ - blurXFilter: IBlurXFilter; - /** - * @private - */ - blurYFilter: IBlurYFilter; - /** - * @private - */ - $quality: number; - /** - * The amount of horizontal blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - blurX: number; - /** - * @private - */ - $blurX: number; - /** - * The amount of vertical blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - blurY: number; - /** - * @private - */ - $blurY: number; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - onPropertyChange(): void; - } - /** - * @private - */ - interface IBlurXFilter extends Filter { - type: string; - $uniforms: any; - blurX: number; - } - /** - * @private - */ - interface IBlurYFilter extends Filter { - type: string; - $uniforms: any; - blurY: number; - } -} -declare namespace egret { - /** - * The ColorMatrixFilter class lets you apply a 4 x 5 matrix transformation on the RGBA color and alpha values of every pixel in the input image to produce a result with a new set of RGBA color and alpha values. - * It allows saturation changes, hue rotation, luminance to alpha, and various other effects. - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language en_US - */ - /** - * 使用 ColorMatrixFilter 类可以将 4 x 5 矩阵转换应用于输入图像上的每个像素的 RGBA 颜色和 Alpha 值,以生成具有一组新的 RGBA 颜色和 Alpha 值的结果。 - * 该类允许饱和度更改、色相旋转、亮度为 Alpha 以及各种其他效果。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language zh_CN - */ - class ColorMatrixFilter extends Filter { - /** - * @private - */ - $matrix: number[]; - /** - * @private - */ - private matrix2; - /** - * Initializes a ColorMatrixFilter object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 ColorMatrixFilter 对象。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - constructor(matrix?: number[]); - /** - * A comma delimited list of 20 doubles that comprise a 4x5 matrix applied to the rendered element. - * The matrix is in row major order -- that is, the first five elements are multipled by the vector [srcR,srcG,srcB,srcA,1] to determine the output red value, the second five determine the output green value, etc. - * The value must either be an array or comma delimited string of 20 numbers. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 构成应用于所呈示的元素的一个 4x5 矩阵的、以逗号分隔的 20 个双精度数的列表。 - * 矩阵以行作为主要顺序,即用第一行五个元素乘以矢量 [srcR,srcG,srcB,srcA,1] 以确定输出的红色值,用第二行的五个元素确定输出的绿色值,等等。 - * 该值必须为 20 个数字组成的数组或以逗号分隔的字符串。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - matrix: number[]; - /** - * @private - */ - private setMatrix(value); - /** - * @private - */ - $toJson(): string; - } -} -declare namespace egret { - /** - * custom filter, now support WebGL mode only. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 自定义滤镜,目前仅支持WebGL模式 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - class CustomFilter extends Filter { - /** - * @private - */ - $vertexSrc: string; - /** - * @private - */ - $fragmentSrc: string; - /** - * @private - */ - $shaderKey: string; - /** - * @private - */ - type: string; - private $padding; - /** - * The inner margin of the filter. - * If the desired area of the custom filter is larger than the original area (stroke, etc.), you need to set it manually. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 滤镜的内边距 - * 如果自定义滤镜所需区域比原区域大(描边等),需要手动设置 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - padding: number; - /** - * The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - readonly uniforms: any; - /** - * Initialize the CustomFilter object. - * @param vertexSrc Custom vertex shader program. - * @param fragmentSrc Custom fragment shader program. - * @param uniforms The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 初始化 CustomFilter 对象 - * @param vertexSrc 自定义的顶点着色器程序。 - * @param fragmentSrc 自定义的片段着色器程序。 - * @param uniforms 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - constructor(vertexSrc: string, fragmentSrc: string, uniforms?: any); - onPropertyChange(): void; - } -} -declare namespace egret { - /** - * @class egret.DropShadowFilter - * @classdesc - * 可使用 DropShadowFilter 类向显示对象添加投影。 - * @extends egret.GlowFilter - * @version Egret 3.1.4 - * @platform Web,Native - */ - class DropShadowFilter extends GlowFilter { - /** - * Initializes a new DropShadowFilter instance. - * @method egret.DropShadowFilter#constructor - * @param distance {number} The offset distance of the bevel. Valid values are in pixels (floating point). - * @param angle {number} The angle of the bevel. Valid values are from 0 to 360°. - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @param hideObject {number} Indicates whether or not the object is hidden. The value true indicates that the object itself is not drawn; only the shadow is visible. The default is false, meaning that the object is shown. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 DropShadowFilter 对象 - * @method egret.DropShadowFilter#constructor - * @param distance {number} 阴影的偏移距离,以像素为单位。 - * @param angle {number} 阴影的角度,0 到 360 度(浮点)。 - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @param hideObject {number} 表示是否隐藏对象。如果值为 true,则表示没有绘制对象本身,只有阴影是可见的。默认值为 false(显示对象)。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - constructor(distance?: number, angle?: number, color?: number, alpha?: number, blurX?: number, blurY?: number, strength?: number, quality?: number, inner?: boolean, knockout?: boolean, hideObject?: boolean); - /** - * @private - */ - $distance: number; - /** - * The offset distance of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的偏移距离,以像素为单位。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - distance: number; - /** - * @private - */ - $angle: number; - /** - * The angle of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的角度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - angle: number; - /** - * @private - */ - $hideObject: boolean; - /** - * Indicates whether or not the object is hidden. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 表示是否隐藏对象。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - hideObject: boolean; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - } -} -declare namespace egret { - /** - * The GradientType class provides values for the type parameter in the beginGradientFill() methods of the egret.Graphics class. - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * GradientType 类为 egret.Graphics 类的 beginGradientFill() 方法中的 type 参数提供值。 - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class GradientType { - /** - * Value used to specify a linear gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定线性渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LINEAR: string; - /** - * Value used to specify a radial gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定放射状渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RADIAL: string; - } -} -declare namespace egret { - /** - * The Graphics class contains a set of methods for creating vector shape. Display objects that support drawing include Sprite and Shape objects. Each class in these classes includes the graphics attribute that is a Graphics object. - * The following auxiliary functions are provided for ease of use: drawRect(), drawRoundRect(), drawCircle(), and drawEllipse(). - * @see http://edn.egret.com/cn/docs/page/136 Draw Rectangle - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language en_US - */ - /** - * Graphics 类包含一组可用来创建矢量形状的方法。支持绘制的显示对象包括 Sprite 和 Shape 对象。这些类中的每一个类都包括 graphics 属性,该属性是一个 Graphics 对象。 - * 以下是为便于使用而提供的一些辅助函数:drawRect()、drawRoundRect()、drawCircle() 和 drawEllipse()。 - * @see http://edn.egret.com/cn/docs/page/136 绘制矩形 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language zh_CN - */ - class Graphics extends HashObject { - /** - * Initializes a Graphics object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Graphics 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - $renderNode: sys.GraphicsNode; - /** - * 绑定到的目标显示对象 - */ - $targetDisplay: DisplayObject; - $targetIsSprite: boolean; - /** - * @private - * 设置绑定到的目标显示对象 - */ - $setTarget(target: DisplayObject): void; - /** - * 当前移动到的坐标X - */ - private lastX; - /** - * 当前移动到的坐标Y - */ - private lastY; - /** - * 当前正在绘制的填充 - */ - private fillPath; - /** - * 当前正在绘制的线条 - */ - private strokePath; - /** - * 线条的左上方宽度 - */ - private topLeftStrokeWidth; - /** - * 线条的右下方宽度 - */ - private bottomRightStrokeWidth; - /** - * 对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - private setStrokeWidth(width); - /** - * Specify a simple single color fill that will be used for subsequent calls to other Graphics methods (for example, lineTo() and drawCircle()) when drawing. - * Calling the clear() method will clear the fill. - * @param color Filled color - * @param alpha Filled Alpha value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - beginFill(color: number, alpha?: number): void; - /** - * Specifies a gradient fill used by subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) for the object. - * Calling the clear() method clears the fill. - * @param type A value from the GradientType class that specifies which gradient type to use: GradientType.LINEAR or GradientType.RADIAL. - * @param colors An array of RGB hexadecimal color values used in the gradient; for example, red is 0xFF0000, blue is 0x0000FF, and so on. You can specify up to 15 colors. For each color, specify a corresponding value in the alphas and ratios parameters. - * @param alphas An array of alpha values for the corresponding colors in the colors array; - * @param ratios An array of color distribution ratios; valid values are 0-255. - * @param matrix A transformation matrix as defined by the egret.Matrix class. The egret.Matrix class includes a createGradientBox() method, which lets you conveniently set up the matrix for use with the beginGradientFill() method. - * @platform Web,Native - * @version Egret 2.4 - * @language en_US - */ - /** - * 指定一种渐变填充,用于随后调用对象的其他 Graphics 方法(如 lineTo() 或 drawCircle())。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @platform Web,Native - * @version Egret 2.4 - * @language zh_CN - */ - beginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix?: egret.Matrix): void; - /** - * Apply fill to the lines and curves added after the previous calling to the beginFill() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对从上一次调用 beginFill()方法之后添加的直线和曲线应用填充。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - endFill(): void; - /** - * Specify a line style that will be used for subsequent calls to Graphics methods such as lineTo() and drawCircle(). - * @param thickness An integer, indicating the thickness of the line in points. Valid values are 0 to 255. If a number is not specified, or if the parameter is undefined, a line is not drawn. If a value less than 0 is passed, the default value is 0. Value 0 indicates hairline thickness; the maximum thickness is 255. If a value greater than 255 is passed, the default value is 255. - * @param color A hexadecimal color value of the line (for example, red is 0xFF0000, and blue is 0x0000FF, etc.). If no value is specified, the default value is 0x000000 (black). Optional. - * @param alpha Indicates Alpha value of the line's color. Valid values are 0 to 1. If no value is specified, the default value is 1 (solid). If the value is less than 0, the default value is 0. If the value is greater than 1, the default value is 1. - * @param pixelHinting A boolean value that specifies whether to hint strokes to full pixels. This affects both the position of anchors of a curve and the line stroke size itself. With pixelHinting set to true, the line width is adjusted to full pixel width. With pixelHinting set to false, disjoints can appear for curves and straight lines. - * @param scaleMode Specifies the scale mode to be used - * @param caps Specifies the value of the CapsStyle class of the endpoint type at the end of the line. (default = CapsStyle.ROUND) - * @param joints Specifies the type of joint appearance of corner. (default = JointStyle.ROUND) - * @param miterLimit Indicates the limit number of cut miter. - * @param lineDash set the line dash. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param pixelHinting 布尔型值,指定是否提示笔触采用完整像素。它同时影响曲线锚点的位置以及线条笔触大小本身。在 pixelHinting 设置为 true 的情况下,线条宽度会调整到完整像素宽度。在 pixelHinting 设置为 false 的情况下,对于曲线和直线可能会出现脱节。 - * @param scaleMode 用于指定要使用的比例模式 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - * @param lineDash 设置虚线样式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineStyle(thickness?: number, color?: number, alpha?: number, pixelHinting?: boolean, scaleMode?: string, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): void; - /** - * Draw a rectangle - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawRect(x: number, y: number, width: number, height: number): void; - /** - * Draw a rectangle with rounded corners. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @param ellipseWidth Width used to draw an ellipse with rounded corners (in pixels). - * @param ellipseHeight Height used to draw an ellipse with rounded corners (in pixels). (Optional) If no value is specified, the default value matches the value of the ellipseWidth parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - /** - * Draw a circle. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param r Radius of the circle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawCircle(x: number, y: number, radius: number): void; - /** - * Draw an ellipse. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawEllipse(x: number, y: number, width: number, height: number): void; - /** - * Move the current drawing position to (x, y). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - moveTo(x: number, y: number): void; - /** - * Draw a straight line from the current drawing position to (x, y) using the current line style; the current drawing position is then set to (x, y). - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineTo(x: number, y: number): void; - /** - * Draw a quadratic Bezier curve from the current drawing position to (anchorX, anchorY) using the current line style according to the control points specified by (controlX, controlY). The current drawing position is then set to (anchorX, anchorY). - * If the curveTo() method is called before the moveTo() method, the default value of the current drawing position is (0, 0). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * The drawn curve is a quadratic Bezier curve. A quadratic Bezier curve contains two anchor points and one control point. The curve interpolates the two anchor points and bends to the control point. - * @param controlX A number indicating the horizontal position of the control point, relative to the registration point of the parent display object. - * @param controlY A number indicating the vertical position of the control point, relative to the registration point of the parent display object. - * @param anchorX A number indicating the horizontal position of the next anchor point, relative to the registration point of the parent display object. - * @param anchorY A number indicating the vertical position of the next anchor point, relative to the registration point of the parent display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - curveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - /** - * Draws a cubic Bezier curve from the current drawing position to the specified anchor. Cubic Bezier curves consist of two anchor points and two control points. The curve interpolates the two anchor points and two control points to the curve. - * @param controlX1 Specifies the first control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY1 Specifies the first control point relative to the registration point of the parent display the vertical position of the object. - * @param controlX2 Specify the second control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY2 Specify the second control point relative to the registration point of the parent display the vertical position of the object. - * @param anchorX Specifies the anchor point relative to the registration point of the parent display the horizontal position of the object. - * @param anchorY Specifies the anchor point relative to the registration point of the parent display the vertical position of the object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - cubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - /** - * adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending - * at endAngle going in the given direction by anticlockwise (defaulting to clockwise). - * @param x The x coordinate of the arc's center. - * @param y The y coordinate of the arc's center. - * @param radius The arc's radius. - * @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. - * @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. - * @param anticlockwise if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - private dirty(); - /** - * @private - * 测量圆弧的矩形大小 - */ - private arcBounds(x, y, radius, startAngle, endAngle); - /** - * Clear graphics that are drawn to this Graphics object, and reset fill and line style settings. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除绘制到此 Graphics 对象的图形,并重置填充和线条样式设置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clear(): void; - /** - * @private - */ - private minX; - /** - * @private - */ - private minY; - /** - * @private - */ - private maxX; - /** - * @private - */ - private maxY; - /** - * @private - */ - private extendBoundsByPoint(x, y); - /** - * @private - */ - private extendBoundsByX(x); - /** - * @private - */ - private extendBoundsByY(y); - /** - * @private - */ - private updateNodeBounds(); - /** - * 是否已经包含上一次moveTo的坐标点 - */ - private includeLastPosition; - /** - * 更新当前的lineX和lineY值,并标记尺寸失效。 - * @private - */ - private updatePosition(x, y); - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - * - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * The Matrix class represents a transformation matrix that determines how to map points from one coordinate space to - * another. You can perform various graphical transformations on a display object by setting the properties of a Matrix - * object, applying that Matrix object to the matrix property of a display object, These transformation functions include - * translation (x and y repositioning), rotation, scaling, and skewing. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language en_US - */ - /** - * Matrix 类表示一个转换矩阵,它确定如何将点从一个坐标空间映射到另一个坐标空间。 - * 您可以对一个显示对象执行不同的图形转换,方法是设置 Matrix 对象的属性,将该 Matrix - * 对象应用于显示对象的 matrix 属性。这些转换函数包括平移(x 和 y 重新定位)、旋转、缩放和倾斜。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language zh_CN - */ - class Matrix extends HashObject { - /** - * Releases a matrix instance to the object pool - * @param matrix matrix that Needs to be recycled - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Matrix实例到对象池 - * @param matrix 需要回收的 matrix - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(matrix: Matrix): void; - /** - * get a matrix instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Matrix对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(): Matrix; - /** - * Creates a new Matrix object with the specified parameters. - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定参数创建一个 Matrix 对象 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - /** - * The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - a: number; - /** - * The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 旋转或倾斜图像时影响像素沿 y 轴定位的值 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - b: number; - /** - * The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 旋转或倾斜图像时影响像素沿 x 轴定位的值 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - c: number; - /** - * The value that affects the positioning of pixels along the y axis when scaling or rotating an image. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - d: number; - /** - * The distance by which to translate each point along the x axis. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 x 轴平移每个点的距离 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - tx: number; - /** - * The distance by which to translate each point along the y axis. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 y 轴平移每个点的距离 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ty: number; - /** - * Returns a new Matrix object that is a clone of this matrix, with an exact copy of the contained object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Matrix 对象,它是此矩阵的克隆,带有与所含对象完全相同的副本。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Matrix; - /** - * Concatenates a matrix with the current matrix, effectively combining the geometric effects of the two. In mathematical - * terms, concatenating two matrixes is the same as combining them using matrix multiplication. - * @param other The matrix to be concatenated to the source matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将某个矩阵与当前矩阵连接,从而将这两个矩阵的几何效果有效地结合在一起。在数学术语中,将两个矩阵连接起来与使用矩阵乘法将它们结合起来是相同的。 - * @param other 要连接到源矩阵的矩阵。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - concat(other: Matrix): void; - /** - * Copies all of the matrix data from the source Point object into the calling Matrix object. - * @param other The Matrix object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Matrix 对象中的所有矩阵数据复制到调用方 Matrix 对象中。 - * @param other 要拷贝的目标矩阵 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(other: Matrix): Matrix; - /** - * Sets each matrix property to a value that causes a null transformation. An object transformed by applying an - * identity matrix will be identical to the original. After calling the identity() method, the resulting matrix - * has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为每个矩阵属性设置一个值,该值将导致矩阵无转换。通过应用恒等矩阵转换的对象将与原始对象完全相同。 - * 调用 identity() 方法后,生成的矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0 和 ty=0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - identity(): void; - /** - * Performs the opposite transformation of the original matrix. You can apply an inverted matrix to an object to - * undo the transformation performed when applying the original matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行原始矩阵的逆转换。 - * 您可以将一个逆矩阵应用于对象来撤消在应用原始矩阵时执行的转换。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - invert(): void; - /** - * @private - */ - $invertInto(target: Matrix): void; - /** - * Applies a rotation transformation to the Matrix object. - * The rotate() method alters the a, b, c, and d properties of the Matrix object. - * @param angle The rotation angle in radians. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对 Matrix 对象应用旋转转换。 - * rotate() 方法将更改 Matrix 对象的 a、b、c 和 d 属性。 - * @param angle 以弧度为单位的旋转角度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotate(angle: number): void; - /** - * Applies a scaling transformation to the matrix. The x axis is multiplied by sx, and the y axis it is multiplied by sy. - * The scale() method alters the a and d properties of the Matrix object. - * @param sx A multiplier used to scale the object along the x axis. - * @param sy A multiplier used to scale the object along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对矩阵应用缩放转换。x 轴乘以 sx,y 轴乘以 sy。 - * scale() 方法将更改 Matrix 对象的 a 和 d 属性。 - * @param sx 用于沿 x 轴缩放对象的乘数。 - * @param sy 用于沿 y 轴缩放对象的乘数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scale(sx: number, sy: number): void; - /** - * Sets the members of Matrix to the specified values - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Matrix 的成员设置为指定值 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * Returns the result of applying the geometric transformation represented by the Matrix object to the specified point. - * @param pointX The x coordinate for which you want to get the result of the Matrix transformation. - * @param pointY The y coordinate for which you want to get the result of the Matrix transformation. - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns The point resulting from applying the Matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @param pointX 想要获得其矩阵转换结果的点的x坐标。 - * @param pointY 想要获得其矩阵转换结果的点的y坐标。 - * @param resultPoint 框架建议尽可能减少创建对象次数来优化性能,可以从外部传入一个复用的Point对象来存储结果,若不传入将创建一个新的Point对象返回。 - * @returns 由应用矩阵转换所产生的点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - transformPoint(pointX: number, pointY: number, resultPoint?: Point): Point; - /** - * Translates the matrix along the x and y axes, as specified by the dx and dy parameters. - * @param dx The amount of movement along the x axis to the right, in pixels. - * @param dy The amount of movement down along the y axis, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 x 和 y 轴平移矩阵,由 dx 和 dy 参数指定。 - * @param dx 沿 x 轴向右移动的量(以像素为单位)。 - * @param dy 沿 y 轴向下移动的量(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - translate(dx: number, dy: number): void; - /** - * Determines whether two matrixes are equal. - * @param other The matrix to be compared. - * @returns A value of true if the object is equal to this Matrix object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否与另一个矩阵数据相等 - * @param other 要比较的另一个矩阵对象。 - * @returns 是否相等,ture表示相等。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(other: Matrix): boolean; - /** - * prepend matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 前置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - prepend(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * append matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 后置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - append(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * Given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs. - * Unlike the standard transformation applied using the transformPoint() method, the deltaTransformPoint() method's transformation does not consider the translation parameters tx and ty. - * @param point The point for which you want to get the result of the matrix transformation. - * @returns The point resulting from applying the matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果给定预转换坐标空间中的点,则此方法返回发生转换后该点的坐标。 - * 与使用 transformPoint() 方法应用的标准转换不同,deltaTransformPoint() 方法的转换不考虑转换参数 tx 和 ty。 - * @param point 想要获得其矩阵转换结果的点 - * @returns 由应用矩阵转换所产生的点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - deltaTransformPoint(point: Point): Point; - /** - * Returns a text value listing the properties of the Matrix object. - * @returns A string containing the values of the properties of the Matrix object: a, b, c, d, tx, and ty. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @returns 一个字符串,它包含 Matrix 对象的属性值:a、b、c、d、tx 和 ty。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - /** - * Includes parameters for scaling, rotation, and translation. When applied to a matrix it sets the matrix's values based on those parameters. - * @param scaleX The factor by which to scale horizontally. - * @param scaleY The factor by which scale vertically. - * @param rotation The amount to rotate, in radians. - * @param tx The number of pixels to translate (move) to the right along the x axis. - * @param ty The number of pixels to translate (move) down along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 包括用于缩放、旋转和转换的参数。当应用于矩阵时,该方法会基于这些参数设置矩阵的值。 - * @param scaleX 水平缩放所用的系数 - * @param scaleY 垂直缩放所用的系数 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移(移动)的像素数 - * @param ty 沿 y 轴向下平移(移动)的像素数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createBox(scaleX: number, scaleY: number, rotation?: number, tx?: number, ty?: number): void; - /** - * Creates the specific style of matrix expected by the beginGradientFill() and lineGradientStyle() methods of the Graphics class. - * Width and height are scaled to a scaleX/scaleY pair and the tx/ty values are offset by half the width and height. - * @param width The width of the gradient box. - * @param height The height of the gradient box. - * @param rotation The amount to rotate, in radians. - * @param tx The distance, in pixels, to translate to the right along the x axis. This value is offset by half of the width parameter. - * @param ty The distance, in pixels, to translate down along the y axis. This value is offset by half of the height parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 Graphics 类的 beginGradientFill() 和 lineGradientStyle() 方法所需的矩阵的特定样式。 - * 宽度和高度被缩放为 scaleX/scaleY 对,而 tx/ty 值偏移了宽度和高度的一半。 - * @param width 渐变框的宽度 - * @param height 渐变框的高度 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移的距离(以像素为单位)。此值将偏移 width 参数的一半 - * @param ty 沿 y 轴向下平移的距离(以像素为单位)。此值将偏移 height 参数的一半 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createGradientBox(width: number, height: number, rotation?: number, tx?: number, ty?: number): void; - /** - * @private - */ - $transformBounds(bounds: Rectangle): void; - /** - * @private - */ - private getDeterminant(); - /** - * @private - */ - $getScaleX(): number; - /** - * @private - */ - $getScaleY(): number; - /** - * @private - */ - $getSkewX(): number; - /** - * @private - */ - $getSkewY(): number; - /** - * @private - */ - $updateScaleAndRotation(scaleX: number, scaleY: number, skewX: number, skewY: number): void; - /** - * @private - * target = other * this - */ - $preMultiplyInto(other: Matrix, target: Matrix): void; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempMatrix: Matrix; -} -declare namespace egret { - /** - * A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its - * width and its height.
- * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of - * one property has no effect on the others. However, the right and bottom properties are integrally related to those - * four properties. For example, if you change the value of the right property, the value of the width property changes; - * if you change the bottom property, the value of the height property changes. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language en_US - */ - /** - * Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
- * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language zh_CN - */ - class Rectangle extends HashObject { - /** - * Releases a rectangle instance to the object pool. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Rectangle实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(rect: Rectangle): void; - /** - * get a rectangle instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Rectangle对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(): Rectangle; - /** - * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified - * width and height parameters. - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个新 Rectangle 对象,其左上角由 x 和 y 参数指定,并具有指定的 width 和 height 参数。 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(x?: number, y?: number, width?: number, height?: number); - /** - * The x coordinate of the top-left corner of the rectangle. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 x 坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * The y coordinate of the top-left corner of the rectangle. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 y 坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * The width of the rectangle, in pixels. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形的宽度(以像素为单位)。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * 矩形的高度(以像素为单位)。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * The height of the rectangle, in pixels. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - /** - * The sum of the x and width properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * x 和 width 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - right: number; - /** - * The sum of the y and height properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * y 和 height 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bottom: number; - /** - * The x coordinate of the top-left corner of the rectangle. Changing the left property of a Rectangle object has - * no effect on the y and height properties. However it does affect the width property, whereas changing the x value - * does not affect the width property. - * The value of the left property is equal to the value of the x property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 x 坐标。更改 Rectangle 对象的 left 属性对 y 和 height 属性没有影响。但是,它会影响 width 属性,而更改 x 值不会影响 width 属性。 - * left 属性的值等于 x 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - left: number; - /** - * The y coordinate of the top-left corner of the rectangle. Changing the top property of a Rectangle object has - * no effect on the x and width properties. However it does affect the height property, whereas changing the y - * value does not affect the height property.
- * The value of the top property is equal to the value of the y property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 y 坐标。更改 Rectangle 对象的 top 属性对 x 和 width 属性没有影响。但是,它会影响 height 属性,而更改 y 值不会影响 height 属性。
- * top 属性的值等于 y 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - top: number; - /** - * The location of the Rectangle object's top-left corner, determined by the x and y coordinates of the point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由该点的 x 和 y 坐标确定的 Rectangle 对象左上角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - topLeft: Point; - /** - * The location of the Rectangle object's bottom-right corner, determined by the values of the right and bottom properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由 right 和 bottom 属性的值确定的 Rectangle 对象的右下角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bottomRight: Point; - /** - * Copies all of rectangle data from the source Rectangle object into the calling Rectangle object. - * @param sourceRect The Rectangle object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Rectangle 对象中的所有矩形数据复制到调用方 Rectangle 对象中。 - * @param sourceRect 要从中复制数据的 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(sourceRect: Rectangle): Rectangle; - /** - * Sets the members of Rectangle to the specified values - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 的成员设置为指定值 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(x: number, y: number, width: number, height: number): Rectangle; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * @param x The x coordinate (horizontal position) of the point. - * @param y The y coordinate (vertical position) of the point. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * @param x 检测点的x轴 - * @param y 检测点的y轴 - * @returns 如果检测点位于矩形内,返回true,否则,返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - contains(x: number, y: number): boolean; - /** - * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns - * the area of intersection as a Rectangle object. If the rectangles do not intersect, this method returns an empty - * Rectangle object with its properties set to 0. - * @param toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object. - * @returns A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method - * returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果在 toIntersect 参数中指定的 Rectangle 对象与此 Rectangle 对象相交,则返回交集区域作为 Rectangle 对象。如果矩形不相交, - * 则此方法返回一个空的 Rectangle 对象,其属性设置为 0。 - * @param toIntersect 要对照比较以查看其是否与此 Rectangle 对象相交的 Rectangle 对象。 - * @returns 等于交集区域的 Rectangle 对象。如果该矩形不相交,则此方法返回一个空的 Rectangle 对象;即,其 x、y、width 和 - * height 属性均设置为 0 的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - intersection(toIntersect: Rectangle): Rectangle; - /** - * Increases the size of the Rectangle object by the specified amounts, in pixels. - * The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. - * @param dx The value to be added to the left and the right of the Rectangle object. - * @param dy The value to be added to the top and the bottom of the Rectangle. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量增加 Rectangle 对象的大小(以像素为单位) - * 保持 Rectangle 对象的中心点不变,使用 dx 值横向增加它的大小,使用 dy 值纵向增加它的大小。 - * @param dx Rectangle 对象横向增加的值。 - * @param dy Rectangle 对象纵向增加的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - inflate(dx: number, dy: number): void; - /** - * @private - */ - $intersectInPlace(clipRect: Rectangle): Rectangle; - /** - * Determines whether the object specified in the toIntersect parameter intersects with this Rectangle object. - * This method checks the x, y, width, and height properties of the specified Rectangle object to see if it - * intersects with this Rectangle object. - * @param toIntersect The Rectangle object to compare against this Rectangle object. - * @returns A value of true if the specified object intersects with this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toIntersect 参数中指定的对象是否与此 Rectangle 对象相交。此方法检查指定的 Rectangle - * 对象的 x、y、width 和 height 属性,以查看它是否与此 Rectangle 对象相交。 - * @param toIntersect 要与此 Rectangle 对象比较的 Rectangle 对象。 - * @returns 如果两个矩形相交,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - intersects(toIntersect: Rectangle): boolean; - /** - * Determines whether or not this Rectangle object is empty. - * @returns A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象是否为空。 - * @returns 如果 Rectangle 对象的宽度或高度小于等于 0,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - isEmpty(): boolean; - /** - * Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 对象的所有属性设置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setEmpty(): void; - /** - * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @returns A new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @returns 新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Rectangle; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter. - * @param point The point, as represented by its x and y coordinates. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * 此方法与 Rectangle.contains() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 包含点对象 - * @returns 如果包含,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - containsPoint(point: Point): boolean; - /** - * Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object. - * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. - * @param rect The Rectangle object being checked. - * @returns A value of true if the Rectangle object that you specify is contained by this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象内是否包含由 rect 参数指定的 Rectangle 对象。 - * 如果一个 Rectangle 对象完全在另一个 Rectangle 的边界内,我们说第二个 Rectangle 包含第一个 Rectangle。 - * @param rect 所检查的 Rectangle 对象 - * @returns 如果此 Rectangle 对象包含您指定的 Rectangle 对象,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - containsRect(rect: egret.Rectangle): boolean; - /** - * Determines whether the object specified in the toCompare parameter is equal to this Rectangle object. - * This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object. - * @param The rectangle to compare to this Rectangle object. - * @returns A value of true if the object has exactly the same values for the x, y, width, and height properties as this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toCompare 参数中指定的对象是否等于此 Rectangle 对象。 - * 此方法将某个对象的 x、y、width 和 height 属性与此 Rectangle 对象所对应的相同属性进行比较。 - * @param toCompare 要与此 Rectangle 对象进行比较的矩形。 - * @returns 如果对象具有与此 Rectangle 对象完全相同的 x、y、width 和 height 属性值,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(toCompare: Rectangle): boolean; - /** - * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter. - * @param point 此 Point 对象的 x 属性用于增加 Rectangle 对象的水平尺寸。y 属性用于增加 Rectangle 对象的垂直尺寸。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 增加 Rectangle 对象的大小。此方法与 Rectangle.inflate() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - inflatePoint(point: Point): void; - /** - * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. - * @param dx Moves the x value of the Rectangle object by this amount. - * @param dy Moves the y value of the Rectangle object by this amount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量调整 Rectangle 对象的位置(由其左上角确定)。 - * @param dx 将 Rectangle 对象的 x 值移动此数量。 - * @param dy 将 Rectangle 对象的 t 值移动此数量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offset(dx: number, dy: number): void; - /** - * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter. - * @param point A Point object to use to offset this Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 对象用作参数来调整 Rectangle 对象的位置。此方法与 Rectangle.offset() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 要用于偏移此 Rectangle 对象的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offsetPoint(point: Point): void; - /** - * Builds and returns a string that lists the horizontal and vertical positions and the width and height of the Rectangle object. - * @returns A string listing the value of each of the following properties of the Rectangle object: x, y, width, and height. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 生成并返回一个字符串,该字符串列出 Rectangle 对象的水平位置和垂直位置以及高度和宽度。 - * @returns 一个字符串,它列出了 Rectangle 对象的下列各个属性的值:x、y、width 和 height。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - /** - * Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles. - * @param toUnion A Rectangle object to add to this Rectangle object. - * @returns A new Rectangle object that is the union of the two rectangles. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过填充两个矩形之间的水平和垂直空间,将这两个矩形组合在一起以创建一个新的 Rectangle 对象。 - * @param toUnion 要添加到此 Rectangle 对象的 Rectangle 对象。 - * @returns 充当两个矩形的联合的新 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - union(toUnion: Rectangle): Rectangle; - /** - * @private - */ - $getBaseWidth(angle: number): number; - /** - * @private - */ - $getBaseHeight(angle: number): number; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempRectangle: Rectangle; -} -declare namespace egret { -} -declare namespace egret { - /** - * The JointStyle class is an enumeration of constant values that specify the joint style to use in drawing lines. - * These constants are provided for use as values in the joints parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * JointStyle 类是指定要在绘制线条中使用的联接点样式的常量值枚举。提供的这些常量用作 egret.Graphics.lineStyle() 方法的 joints 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - const JointStyle: { - BEVEL: string; - MITER: string; - ROUND: string; - }; -} -declare namespace egret { -} -/** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/localStorage/localStorage.ts - */ -declare namespace egret.localStorage { - /** - * Read data - * @param key {string} Name of the key to be read - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 读取数据 - * @param key {string} 要读取的键名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let getItem: (key: string) => string; - /** - * Save data - * @param key {string} Name of the key to be saved - * @param value {string} Value to be saved - * @returns {boolean} Whether data is saved successfully - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 保存数据 - * @param key {string} 要保存的键名称 - * @param value {string} 要保存的值 - * @returns {boolean} 数据保存是否成功 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let setItem: (key: string, value: string) => boolean; - /** - * Delete data - * @param key {string} Name of the key to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除数据 - * @param key {string} 要删除的键名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let removeItem: (key: string) => void; - /** - * Clear all data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将所有数据清空 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let clear: () => void; -} -declare namespace egret.sys { - /** - * @private - * @param channel - */ - function $pushSoundChannel(channel: SoundChannel): void; - /** - * @private - * @param channel - */ - function $popSoundChannel(channel: SoundChannel): boolean; -} -declare namespace egret { - /** - * The Sound class lets you work with sound in an application. - * The Sound class lets you create a Sound object, load and play an external audio file into that object. - * More detailed control of the sound is performed through the SoundChannel - * - * @event egret.Event.COMPLETE Dispatch when the audio resource is loaded and ready to play - * @event egret.IOErrorEvent.IO_ERROR Dispatch when the audio resource is failed to load - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language en_US - */ - /** - * Sound 允许您在应用程序中使用声音。使用 Sound 类可以创建 Sound 对象、将外部音频文件加载到该对象并播放该文件。 - * 可通过 SoundChannel 对声音执行更精细的控制,如控制音量和监控播放进度。 - * @see http://edn.egret.com/cn/docs/page/156 音频系统 - * - * @event egret.Event.COMPLETE 音频加载完成时抛出 - * @event egret.IOErrorEvent.IO_ERROR 音频加载失败时抛出 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language zh_CN - */ - interface Sound extends EventDispatcher { - /** - * Initiates loading of an external audio file from the specified URL. - * @param url Audio file URL - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动从指定 URL 加载外部音频文件的过程。 - * @param url 需要加载的音频文件URL - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string): void; - /** - * Generates a new SoundChannel object to play back the sound. - * @param startTime The initial position in seconds at which playback should start, (default = 0) - * @param loops Plays, the default value is 0. Greater than 0 to the number of plays, such as 1 to play 1, less than or equal to 0, to loop. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 生成一个新的 SoundChannel 对象来播放该声音。此方法返回 SoundChannel 对象,访问该对象可停止声音调整音量。 - * @param startTime 应开始播放的初始位置(以秒为单位),默认值是 0 - * @param loops 播放次数,默认值是 0,循环播放。 大于 0 为播放次数,如 1 为播放 1 次;小于等于 0,为循环播放。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - play(startTime?: number, loops?: number): SoundChannel; - /** - * Closes the stream, causing any download of data to cease - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭该流,从而停止所有数据的下载。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - close(): void; - /** - * Type, default is egret.Sound.EFFECT. - * In the native and runtime environment, while only play a background music, sound length so as not to be too long. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 类型,默认为 egret.Sound.EFFECT。 - * 在 native 和 runtime 环境下,背景音乐同时只能播放一个,音效长度尽量不要太长。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - type: string; - /** - * Length of the current sound (in seconds). - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前声音的长度(以秒为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - length: number; - } - /** - * @copy egret.Sound - */ - let Sound: { - /** - * Create Sound object, load an external audio file and play - * @param url Audio file URL, Sound will start to load the media if url is not empty - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 Sound 对象、将外部音频文件加载到该对象并播放该文件 - * @param url 需要加载的音频文件URL,如果指定了 url, Sound会立即开始加载指定的媒体文件 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - new (): Sound; - /** - * Background music - * @default "music" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 背景音乐 - * @default "music" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - MUSIC: string; - /** - * EFFECT - * @default "effect" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音效 - * @default "effect" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - EFFECT: string; - }; -} -declare namespace egret { - /** - * The SoundChannel class controls a sound in an application. - * Every sound is assigned to a sound channel, and the application - * can have multiple sound channels that are mixed together. - * The SoundChannel class contains a stop() method, properties for - * set the volume of the channel - * - * @event egret.Event.SOUND_COMPLETE Dispatch when a sound has finished playing at last time - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language en_US - */ - /** - * SoundChannel 类控制应用程序中的声音。每个声音均分配给一个声道,而且应用程序可以具有混合在一起的多个声道。 - * SoundChannel 类包含 stop() 方法、用于设置音量和监视播放进度的属性。 - * - * @event egret.Event.SOUND_COMPLETE 音频最后一次播放完成时抛出 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language zh_CN - */ - interface SoundChannel extends IEventDispatcher { - /** - * The volume, ranging from 0 (silent) to 1 (full volume). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音量范围从 0(静音)至 1(最大音量)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - volume: number; - /** - * When the sound is playing, the position property indicates - * in seconds the current point that is being played in the sound file. - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当播放声音时,position 属性表示声音文件中当前播放的位置(以秒为单位) - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - position: number; - /** - * Stops the sound playing in the channel. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止在该声道中播放声音。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - } -} -declare namespace egret { - /** - * The Video class lets you work with video in an application. - * The Video class lets you create a Video object, load and play an external video file into that object. - * Note: On most mobile device, the video is playback in the full screen mode.
- * - * @param url URL of the media to play, Video will start to load if the url is not empty - * - * @event egret.Event.COMPLETE Dispatch when the video resource is loaded and ready to play - * @event egret.Event.ENDED Dispatch when the video playback ended - * @event egret.IOErrorEvent.IO_ERROR when the video is failed to load - * @version Egret 2.4 - * @platform Web - * @includeExample egret/media/Video.ts - * @language en_US - */ - /** - * Video 允许您在应用程序中使用视频。使用 Video 类可以创建 Video 对象、将外部视频文件加载到该对象并播放该文件。
- * 注意: 在大多数移动设备中,视频是强制全屏播放的,所以你可以直接调用 play() 方法全屏播放视频,不用将它绘制在Stage中。 - * @see http://edn.egret.com/cn/docs/page/657 视频系统 - * - * @param url 要播放的视频的URL,如果url不为空,Video会立即加载这个视频 - * - * @event egret.Event.COMPLETE 视频加载完成时抛出 - * @event egret.Event.ENDED 视频播放完成时抛出 - * @event egret.IOErrorEvent.IO_ERROR 视频加载失败时触发 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/media/Video.ts - * @language zh_CN - */ - interface Video extends DisplayObject { - /** - * Initiates loading of an external video file from the specified URL. - * @param url Audio file URL - * * @param cache Should cache the video,only used in Native - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动从指定 URL 加载外部视频文件的过程。 - * @param url 需要加载的视频文件URL - * @param cache 是否需要缓存到本地,只在 Native 上使用 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string, cache?: boolean): void; - /** - * Play back the video. - * @param startTime The initial position in seconds at which playback should start, (default = 0) - * @param loop Defines should play the video again when the video is ended. (default = false) - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 播放该视频 - * @param startTime 应开始播放的初始位置(以秒为单位),默认值是视频上次结束的位置 - * @param loop 是否需要循环播放,默认值是 false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - play(startTime?: number, loop?: boolean): any; - /** - * Closes the stream, causing any download of data to cease - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭该流,从而停止所有数据的下载。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - close(): void; - /** - * The URL of the video you want to play. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 想要播放的视频的URL - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - src: string; - /** - * The URL of an image you want to display before the video is loaded or video cannot been draw on the canvas on some mobile device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 视频加载前,或者在不支持将 video 画在 canvas 的设备上,想要显示的视频截图地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - poster: string; - /** - * Should play the video in fullscreen mode (default = true). - * Currently only supports full-screen mobile terminal web. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否全屏播放这个视频(默认值是 true)。 - * 目前移动端 web 只支持全屏。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fullscreen: boolean; - /** - * The volume, ranging from 0 (silent) to 1 (full volume). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音量范围从 0(静音)至 1(最大音量)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - volume: number; - /** - * When the video is playing, the position property indicates - * in seconds the current point that is being played in the video file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当播放视频时,position 属性表示视频文件中当前播放的位置(以秒为单位) - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - position: number; - /** - * Pause the video playing. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停播放。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - /** - * Get bitmapData of the video file, you can use the video as bitmapData on the stage. - * Note: On most mobile device, the video is playback in the full screen mode. - * So you can just use the play() method instead of draw it on the Stage - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 获取视频的 bitmapData, 你可以将视频绘制到舞台上。 - * 注意: 在大多数移动设备中,视频是全屏播放的,所以你可以直接调用 play() 方法全屏播放视频,不用将它绘制在Stage中。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - bitmapData?: BitmapData; - /** - * Whether current video is paused. - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前视频是否在暂停状态。 - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - paused: boolean; - /** - * Length of the current video (in seconds). - * @version Egret 3.0.8 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前视频的长度(以秒为单位)。 - * @version Egret 3.0.8 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - length: number; - } - /** - * @copy egret.Video - */ - let Video: { - new (url?: string, cache?: boolean): Video; - }; -} -declare namespace egret { - /** - * The HttpMethod class provides values that specify whether the HttpRequest object should use the POST method - * or the GET method when sending data to a server. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HttpRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时, - * HttpRequest 对象应使用 POST 方法还是 GET 方法。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace HttpMethod { - /** - * Specifies that the HttpRequest object is a GET. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 GET。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const GET = "GET"; - /** - * Specifies that the HttpRequest object is a POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const POST = "POST"; - } -} -declare namespace egret { - /** - * The HttpRequest class downloads data from a URL as text or binary data. It is useful for downloading text files, - * XML, or other information to be used in a dynamic, data-driven application. A HttpRequest object downloads all - * of the data from a URL before making it available to code in the applications. It sends out notifications about - * the progress of the download, which you can monitor through the bytesLoaded and bytesTotal properties, - * as well as through dispatched events. - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.Event.IO_ERROR Dispatched when the net request is failed. - * @event egret.ProgressEvent.PROGRESS Dispatched when data is received as the download operation progresses. - * @see egret.HttpMethod - * @see egret.HttpResponseType - * @includeExample egret/net/HttpRequestExample.ts - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HttpRequest 类以文本或二进制数据的形式从 URL 下载数据。 - * HttpRequest 对象会先从 URL 中下载所有数据,然后才将数据用于应用程序中的代码。它会发出有关下载进度的通知, - * 通过 bytesLoaded 和 bytesTotal 属性以及已调度的事件,可以监视下载进度。 - * @event egret.Event.COMPLETE 加载完成 - * @event egret.Event.IO_ERROR 加载失败 - * @event egret.ProgressEvent.PROGRESS 加载进度,可通过event.bytesLoaded和event.bytesTotal统计进度信息。 - * @see egret.HttpMethod - * @see egret.HttpResponseType - * @includeExample egret/net/HttpRequestExample.ts - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface HttpRequest extends EventDispatcher { - /** - * The data received from the load operation. The format of the data depends on the setting of the responseType property. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 本次请求返回的数据,数据类型根据 responseType 设置的值确定。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - response: any; - /** - * Controls whether the downloaded data is received as text (HttpResponseType.TEXT) or raw binary data (HttpResponseType.ArrayBuffer)
- * Note:If you attempt to set this property to an invalid value, Egret runtime set the value to HttpResponseType.TEXT. - * @default egret.HttpResponseType.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置返回的数据格式为文本(HttpResponseType.TEXT)还是二进制数据(HttpResponseType.ArrayBuffer)
- * 注意:若尝试设置此属性为一个非法的值,运行时将使用HttpResponseType.TEXT。 - * @default egret.HttpResponseType.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - responseType: string; - /** - * Can be set to a time in milliseconds.When set to a non-zero value will cause fetching to terminate after the given time has passed. - * @default egret.HttpResponseType.TEXT - * @version Egret 5.2.15 - * @platform Web,Native - * @language en_US - */ - /** - * 代表着一个请求在被自动终止前所消耗的毫秒数。默认值为 0,意味着没有超时。 - * @default egret.HttpResponseType.TEXT - * @version Egret 5.2.15 - * @platform Web,Native - * @language zh_CN - */ - timeout: number; - /** - * indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies - * or authorization headers. (This never affects same-site requests.) - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表明在进行跨站(cross-site)的访问控制(Access-Control)请求时,是否使用认证信息(例如cookie或授权的header)。(这个标志不会影响同站的请求) - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - withCredentials: boolean; - /** - * Initializes a request.
- * Note: Calling this method for an already active request (one for which open() or openRequest() has already been - * called) is the equivalent of calling abort(). - * @param url The URL to send the request to. - * @param method The HTTP method to use, please use the const value in the HttpMethod class. - * @see egret.HttpMethod - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 初始化一个请求.
- * 注意: 若在已经发出请求的对象上调用此方法,相当于立即调用abort(). - * @param url 该请求所要访问的URL该请求所要访问的URL - * @param method 请求所使用的HTTP方法, 请使用 HttpMethod 定义的枚举值. - * @see egret.HttpMethod - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - open(url: string, method?: string): void; - /** - * Sends the request. - * @param data the data to send. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 发送请求. - * @param data 需要发送的数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - send(data?: any): void; - /** - * Aborts the request if it has already been sent. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果请求已经被发送,则立刻中止请求. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - abort(): void; - /** - * Returns all the response headers as a string, or null if no response has been received. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回所有响应头信息(响应头名和值), 如果响应头还没接受,则返回"". - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getAllResponseHeaders(): string; - /** - * Sets the value of an HTTP request header. You must call setRequestHeader() after open(). - * @param header The name of the header whose value is to be set. - * @param value The value to set as the body of the header. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 给指定的HTTP请求头赋值.在这之前,您必须确认已经调用 open() 方法打开了一个url. - * @param header 将要被赋值的请求头名称. - * @param value 给指定的请求头赋的值. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setRequestHeader(header: string, value: string): void; - /** - * Returns the string containing the text of the specified header, or null if either the response has not yet been - * received or the header doesn't exist in the response. - * @param header The name of the header whose value is to be get. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回指定的响应头的值, 如果响应头还没被接受,或该响应头不存在,则返回"". - * @param header 要返回的响应头名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getResponseHeader(header: string): string; - } - /** - * Creates a HttpRequest object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 HttpRequest 实例。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let HttpRequest: { - new (): HttpRequest; - }; -} -declare namespace egret { - /** - * The HttpResponseType class provides values that specify how downloaded data is received. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HttpResponseType { - /** - * Specifies that downloaded data is received as text. This is the default value of HttpRequest.responseType - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回字符串。HttpRequest.responseType属性的默认值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TEXT: string; - /** - * Specifies that downloaded data is received as raw binary data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回二进制的ArrayBuffer对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ARRAY_BUFFER: string; - } -} -declare namespace egret { - /** - * The Loader class is used to load image (JPG, PNG, or GIF) files. Use the load() method to initiate loading. - * The loaded image data is in the data property of ImageLoader. - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.IOErrorEvent.IO_ERROR Dispatched when the net request is failed. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/net/ImageLoaderExample.ts - * @see http://edn.egret.com/cn/docs/page/590 加载位图文件 - * @language en_US - */ - /** - * ImageLoader 类可用于加载图像(JPG、PNG 或 GIF)文件。使用 load() 方法来启动加载。被加载的图像对象数据将存储在 ImageLoader.data 属性上 。 - * @event egret.Event.COMPLETE 加载完成 - * @event egret.IOErrorEvent.IO_ERROR 加载失败 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/net/ImageLoaderExample.ts - * @see http://edn.egret.com/cn/docs/page/590 加载位图文件 - * @language zh_CN - */ - interface ImageLoader extends EventDispatcher { - /** - * The data received from the load operation. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用 load() 方法加载成功的 BitmapData 图像数据。 - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: BitmapData; - /** - * Specifies whether or not cross-site Access-Control requests should be made when loading a image from foreign origins.
- * possible values are:"anonymous","use-credentials" or null. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当从其他站点加载一个图片时,指定是否启用跨域资源共享(CORS),默认值为null。
- * 可以设置为"anonymous","use-credentials"或null,设置为其他值将等同于"anonymous"。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - crossOrigin: string; - /** - * start a load operation。
- * Note: Calling this method for an already active request (one for which load() has already been - * called) will abort the last load operation immediately. - * @param url 要加载的图像文件的地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动一次图像加载。
- * 注意:若之前已经调用过加载请求,重新调用 load() 将终止先前的请求,并开始新的加载。 - * @param url 要加载的图像文件的地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string): void; - } - /** - * Creates a ImageLoader object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 ImageLoader 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let ImageLoader: { - /** - * constructor - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - new (): ImageLoader; - /** - * Specifies whether to enable cross-origin resource sharing, If ImageLoader instance has been set crossOrigin property will be used to set the property. - * @version Egret 2.5.7 - * @platform Web,Native - * @language en_US - */ - /** - * 指定是否启用跨域资源共享,如果ImageLoader实例有设置过crossOrigin属性将使用设置的属性 - * @version Egret 2.5.7 - * @platform Web,Native - * @language zh_CN - */ - crossOrigin: string; - }; -} -declare namespace egret.sys { - /** - * @private - * 显示列表 - */ - class DisplayList extends HashObject { - /** - * 创建一个DisplayList对象,若内存不足或无法创建RenderBuffer,将会返回null。 - */ - static create(target: DisplayObject): DisplayList; - /** - * @private - * 创建一个DisplayList对象 - */ - constructor(root: DisplayObject); - private isStage; - /** - * 位图渲染节点 - */ - $renderNode: RenderNode; - /** - * @private - * 获取渲染节点 - */ - $getRenderNode(): sys.RenderNode; - /** - * @private - */ - renderBuffer: RenderBuffer; - /** - * @private - */ - offsetX: number; - /** - * @private - */ - offsetY: number; - /** - * @private - */ - private offsetMatrix; - /** - * @private - * 显示列表根节点 - */ - root: DisplayObject; - /** - * @private - * 设置剪裁边界,不再绘制完整目标对象,画布尺寸由外部决定,超过边界的节点将跳过绘制。 - */ - setClipRect(width: number, height: number): void; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * @private - * 绘制根节点显示对象到目标画布,返回draw的次数。 - */ - drawToSurface(): number; - private bitmapData; - /** - * @private - * 改变画布的尺寸,由于画布尺寸修改会清空原始画布。所以这里将原始画布绘制到一个新画布上,再与原始画布交换。 - */ - changeSurfaceSize(): void; - static $canvasScaleFactor: number; - /** - * @private - */ - static $canvasScaleX: number; - static $canvasScaleY: number; - /** - * @private - */ - static $setCanvasScale(x: number, y: number): void; - } -} -declare namespace egret { - type runEgretOptions = { - renderMode?: string; - audioType?: number; - screenAdapter?: sys.IScreenAdapter; - antialias?: boolean; - canvasScaleFactor?: number; - calculateCanvasScaleFactor?: (context: CanvasRenderingContext2D) => number; - /** - * 以下目前仅供小游戏使用 - * The following are for mini-games only - */ - entryClassName?: string; - scaleMode?: string; - frameRate?: number; - contentWidth?: number; - contentHeight?: number; - orientation?: string; - maxTouches?: number; - showFPS?: boolean; - showLog?: boolean; - fpsStyles?: string; - }; - /** - * egret project entry function - * @param options An object containing the initialization properties for egret engine. - * @language en_US - */ - /** - * egret工程入口函数 - * @param options 一个可选对象,包含初始化Egret引擎需要的参数。 - * @language zh_CN - */ - function runEgret(options?: runEgretOptions): void; - /** - * Refresh the screen display - * @language en_US - */ - /** - * 刷新屏幕显示 - * @language zh_CN - */ - function updateAllScreens(): void; -} -declare namespace egret { - /** - * @private - */ - interface FPSDisplay { - /** - * 更新FPS信息 - */ - update(datas: FPSData): void; - /** - * 插入一条log信息 - */ - updateInfo(info: string): void; - /** - * 插入一条warn信息 - */ - updateWarn(info: string): void; - /** - * 插入一条error信息 - */ - updateError(info: string): void; - } - /** - * @private - */ - let FPSDisplay: { - new (stage: Stage, showFPS: boolean, showLog: boolean, logFilter: string, styles: Object): FPSDisplay; - }; -} -/** - * @private - */ -interface FPSData extends Object { - fps: number; - draw: number; - costTicker: number; - costRender: number; -} -declare namespace egret.sys { - let $TempStage: egret.Stage; - /** - * @private - * Egret播放器 - */ - class Player extends HashObject { - /** - * @private - * 实例化一个播放器对象。 - */ - constructor(buffer: RenderBuffer, stage: Stage, entryClassName: string); - /** - * @private - */ - private createDisplayList(stage, buffer); - /** - * @private - */ - private screenDisplayList; - /** - * @private - * 入口类的完整类名 - */ - private entryClassName; - /** - * @private - * 舞台引用 - */ - stage: Stage; - /** - * @private - * 入口类实例 - */ - private root; - /** - * @private - */ - private isPlaying; - /** - * @private - * 启动播放器 - */ - start(): void; - /** - * @private - */ - private initialize(); - /** - * @private - * 停止播放器,停止后将不能重新启动。 - */ - stop(): void; - /** - * @private - * 暂停播放器,后续可以通过调用start()重新启动播放器。 - */ - pause(): void; - /** - * @private - * 渲染屏幕 - */ - $render(triggerByFrame: boolean, costTicker: number): void; - /** - * @private - * 更新舞台尺寸 - * @param stageWidth 舞台宽度(以像素为单位) - * @param stageHeight 舞台高度(以像素为单位) - */ - updateStageSize(stageWidth: number, stageHeight: number): void; - /** - * @private - * 显示FPS。 - */ - displayFPS(showFPS: boolean, showLog: boolean, logFilter: string, styles: Object): void; - /** - * @private - */ - private showFPS; - /** - * @private - */ - private showLog; - /** - * @private - */ - private stageDisplayList; - } - /** - * @private - */ - let $logToFPS: (info: string) => void; - /** - * @private - */ - let $warnToFPS: (info: string) => void; - /** - * @private - */ - let $errorToFPS: (info: string) => void; -} -/** - * @private - */ -declare module egret { - /** - * @private - */ - var nativeRender: boolean; -} -declare namespace egret { - /** !!!!!!!!inspired by Babylon.js!!!!!!!!!!!!! - * for description see https://www.khronos.org/opengles/sdk/tools/KTX/ - * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ - * Current families are astc, dxt, pvrtc, etc2, & etc1. - * @returns The extension selected. - */ - class KTXContainer { - /** contents of the KTX container file */ arrayBuffer: any; - private static readonly HEADER_LEN; - private static readonly COMPRESSED_2D; - private static readonly COMPRESSED_3D; - private static readonly TEX_2D; - private static readonly TEX_3D; - /** - * Gets the openGL type - */ - glType: number; - /** - * Gets the openGL type size - */ - glTypeSize: number; - /** - * Gets the openGL format - */ - glFormat: number; - /** - * Gets the openGL internal format - */ - glInternalFormat: number; - /** - * Gets the base internal format - */ - glBaseInternalFormat: number; - /** - * Gets image width in pixel - */ - pixelWidth: number; - /** - * Gets image height in pixel - */ - pixelHeight: number; - /** - * Gets image depth in pixels - */ - pixelDepth: number; - /** - * Gets the number of array elements - */ - numberOfArrayElements: number; - /** - * Gets the number of faces - */ - numberOfFaces: number; - /** - * Gets the number of mipmap levels - */ - numberOfMipmapLevels: number; - /** - * Gets the bytes of key value data - */ - bytesOfKeyValueData: number; - /** - * Gets the load type - */ - loadType: number; - /** - * If the container has been made invalid (eg. constructor failed to correctly load array buffer) - */ - isInvalid: boolean; - /** - * Creates a new KhronosTextureContainer - * @param arrayBuffer contents of the KTX container file - * @param facesExpected should be either 1 or 6, based whether a cube texture or or - * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented - * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented - */ - constructor(/** contents of the KTX container file */ arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean); - /** - * Uploads KTX content to a Babylon Texture. - * It is assumed that the texture has already been created & is currently bound - * @hidden - */ - uploadLevels(bitmapData: egret.BitmapData, loadMipmaps: boolean): void; - private _upload2DCompressedLevels(bitmapData, loadMipmaps); - } -} -declare namespace egret.sys { - /** - * @private - * 共享的用于碰撞检测的渲染缓冲 - */ - let customHitTestBuffer: sys.RenderBuffer; - /** - * @private - * 共享的用于canvas碰撞检测的渲染缓冲 - */ - let canvasHitTestBuffer: sys.RenderBuffer; - /** - * @private - * 渲染缓冲 - */ - interface RenderBuffer { - /** - * 呈现最终绘图结果的画布。 - * @readOnly - */ - surface: any; - /** - * 渲染上下文。 - * @readOnly - */ - context: any; - /** - * 渲染缓冲的宽度,以像素为单位。 - * @readOnly - */ - width: number; - /** - * 渲染缓冲的高度,以像素为单位。 - * @readOnly - */ - height: number; - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param width 改变后的宽 - * @param height 改变后的高 - * @param useMaxSize 若传入true,则将改变后的尺寸与已有尺寸对比,保留较大的尺寸。 - */ - resize(width: number, height: number, useMaxSize?: boolean): void; - /** - * 获取指定区域的像素 - */ - getPixels(x: number, y: number, width?: number, height?: number): number[]; - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如: "image/png","image/jpeg" - */ - toDataURL(type?: string, ...args: any[]): string; - /** - * 清空缓冲区数据 - */ - clear(): void; - /** - * 销毁渲染缓冲 - */ - destroy(): void; - } - /** - * @private - */ - let RenderBuffer: { - /** - * 创建一个RenderTarget。 - * 注意:若内存不足或创建缓冲区失败,将会抛出错误异常。 - * @param width 渲染缓冲的初始宽 - * @param height 渲染缓冲的初始高 - * @param root 是否为舞台buffer - */ - new (width?: number, height?: number, root?: boolean): RenderBuffer; - }; - /** - * @private - */ - let CanvasRenderBuffer: { - /** - * 创建一个CanvasRenderBuffer。 - * 注意:若内存不足或创建缓冲区失败,将会抛出错误异常。 - * @param width 渲染缓冲的初始宽 - * @param height 渲染缓冲的初始高 - */ - new (width?: number, height?: number): RenderBuffer; - }; -} -declare namespace egret.sys { - /** - * @private - * 设备屏幕 - */ - interface Screen { - /** - * @private - * 更新屏幕视口尺寸 - */ - updateScreenSize(): any; - /** - * @private - * 更新触摸数量 - */ - updateMaxTouches(): any; - /** - * @private - * 设置分辨率尺寸 - */ - setContentSize(width: number, height: number): any; - } -} -declare namespace egret.sys { - /** - * @private - * 屏幕适配器接口,当播放器视口尺寸改变时,屏幕适配器将被用于计算当前对应的舞台显示尺寸。 - */ - interface IScreenAdapter { - /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; - } - /** - * @private - * 舞台显示尺寸数据 - */ - interface StageDisplaySize { - /** - * @private - * 舞台宽度 - */ - stageWidth: number; - /** - * @private - * 舞台高度 - */ - stageHeight: number; - /** - * @private - * 显示宽度,若跟舞台宽度不同,将会产生缩放。 - */ - displayWidth: number; - /** - * @private - * 显示高度,若跟舞台高度不同,将会产生缩放。 - */ - displayHeight: number; - } - /** - * @private - * 屏幕适配器实例,开发者可以通过给这个变量赋值实现了IScreenAdapter接口的实例,从而注入自定义的屏幕适配器。 - */ - let screenAdapter: IScreenAdapter; - /** - * @private - * 屏幕适配器默认实现,开发者可以实现自定义规则的屏幕适配器。并在初始化加载时将适配器的实例赋值给egret.sys.screenAdapter上,从而替换掉默认适配器。 - */ - class DefaultScreenAdapter extends HashObject implements IScreenAdapter { - /** - * @private - */ - constructor(); - /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; - } -} -declare namespace egret { - /** - * StageScaleMode class provides values for the stage zoom mode. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language en_US - */ - /** - * StageScaleMode 类为舞台缩放模式提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language zh_CN - */ - class StageScaleMode { - /** - * Do not scale application content. Even when you change the player viewport size, it remains unchanged. If the player is smaller than the viewport content, possibly with some cropping.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) always with the player viewport size consistent. - * @language en_US - */ - /** - * 不缩放应用程序内容。即使在更改播放器视口大小时,它仍然保持不变。如果播放器视口比内容小,则可能进行一些裁切。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终跟播放器视口大小保持一致。 - * @language zh_CN - */ - static NO_SCALE: string; - /** - * Keep the original aspect ratio scaling application content, after scaling a wide directions application content to fill the viewport players on both sides in the other direction may not be wide enough and left black bars.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较宽方向填满播放器视口,另一个方向的两侧可能会不够宽而留有黑边。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static SHOW_ALL: string; - /** - * Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static NO_BORDER: string; - /** - * Do not keep the original aspect ratio scaling application content, after scaling application content just fill the player viewport.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 不保持原始宽高比缩放应用程序内容,缩放后应用程序内容正好填满播放器视口。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static EXACT_FIT: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
- * In this mode, the stage width (Stage.stageWidth) is always equal to initialize external incoming application content width. Stage height (Stage.stageHeight) by the current scale with the player viewport height decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
- * 在此模式下,舞台宽度(Stage.stageWidth)始终等于初始化时外部传入的应用程序内容宽度。舞台高度(Stage.stageHeight)由当前的缩放比例与播放器视口高度决定。 - * @language zh_CN - */ - static FIXED_WIDTH: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
- * In this mode, the stage height (Stage.stageHeight) is always equal to initialize external incoming application content height. Stage width (Stage.stageWidth) by the current scale with the player viewport width decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
- * 在此模式下,舞台高度(Stage.stageHeight)始终等于初始化时外部传入的应用程序内容高度。舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽度决定。 - * @language zh_CN - */ - static FIXED_HEIGHT: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player,a narrow direction may not be wide enough and fill.
- * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较窄方向可能会不够宽而填充。
- * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - static FIXED_NARROW: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, a wide direction may exceed the viewport and the player is cut.
- * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较宽方向的两侧可能会超出播放器视口而被裁切。
- * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - static FIXED_WIDE: string; - } -} -declare namespace egret.sys { - /** - * @private - */ - let systemRenderer: SystemRenderer; - /** - * @private - * 用于碰撞检测绘制 - */ - let canvasRenderer: SystemRenderer; - /** - * @private - * 显示渲染器接口 - */ - interface SystemRenderer { - /** - * 渲染一个显示对象 - * @param displayObject 要渲染的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forRenderTexture 绘制目标是RenderTexture的标志 - * @returns drawCall触发绘制的次数 - */ - render(displayObject: DisplayObject, buffer: RenderBuffer, matrix: Matrix, forRenderTexture?: boolean): number; - /** - * 将一个RenderNode对象绘制到渲染缓冲 - * @param node 要绘制的节点 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。 - */ - drawNodeToBuffer(node: sys.RenderNode, buffer: RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; - } - /** - * - */ - interface RenderContext { - } - /** - * 创建一个canvas。 - */ - function mainCanvas(width?: number, height?: number): HTMLCanvasElement; - function createCanvas(width?: number, height?: number): HTMLCanvasElement; - /** - * 重新设置主canvas的大小 - */ - function resizeContext(renderContext: RenderContext, width: number, height: number, useMaxSize?: boolean): void; - /** - * 获得系统的渲染运行时 - */ - function getContextWebGL(surface: HTMLCanvasElement): WebGLRenderingContext; - function getContext2d(surface: HTMLCanvasElement): CanvasRenderingContext2D; - /** - * 仅通过bitmapData创建纹理 - */ - function createTexture(renderContext: RenderContext, bitmapData: BitmapData | HTMLCanvasElement): WebGLTexture; - /** - * 通过 width, height, data创建纹理 - */ - function _createTexture(renderContext: RenderContext, width: number, height: number, data: any): WebGLTexture; - /** - * 画texture - **/ - function drawTextureElements(renderContext: RenderContext, data: any, offset: number): number; - /** - * 测量文本的宽度 - * @param context - * @param text - */ - function measureTextWith(context: CanvasRenderingContext2D, text: string): number; - /** - * 为CanvasRenderBuffer创建一个canvas - * @param defaultFunc - * @param width - * @param height - * @param root - */ - function createCanvasRenderBufferSurface(defaultFunc: (width?: number, height?: number) => HTMLCanvasElement, width?: number, height?: number, root?: boolean): HTMLCanvasElement; - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param renderContext - * @param width - * @param height - * @param useMaxSize - */ - function resizeCanvasRenderBuffer(renderContext: RenderContext, width: number, height: number, useMaxSize?: boolean): void; -} -declare namespace egret.sys { - /** - * @private - */ - let $START_TIME: number; - /** - * @private - * 是否要广播Event.RENDER事件的标志。 - */ - let $invalidateRenderFlag: boolean; - /** - * @private - * 需要立即刷新屏幕的标志 - */ - let $requestRenderingFlag: boolean; - /** - * Egret心跳计时器 - */ - class SystemTicker { - /** - * @private - */ - constructor(); - /** - * @private - */ - private playerList; - /** - * @private - * 注册一个播放器实例并运行 - */ - $addPlayer(player: Player): void; - /** - * @private - * 停止一个播放器实例的运行。 - */ - $removePlayer(player: Player): void; - /** - * @private - */ - private callBackList; - /** - * @private - */ - private thisObjectList; - /** - * @private - */ - $startTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; - /** - * @private - */ - $stopTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; - /** - * @private - */ - private getTickIndex(callBack, thisObject); - /** - * @private - * - */ - private concatTick(); - /** - * @private - * 全局帧率 - */ - $frameRate: number; - /** - * @private - */ - private frameInterval; - /** - * @private - */ - private frameDeltaTime; - /** - * @private - */ - private lastTimeStamp; - /** - * @private - * 设置全局帧率 - */ - $setFrameRate(value: number): boolean; - /** - * @private - */ - private lastCount; - /** - * @private - * ticker 花销的时间 - */ - private costEnterFrame; - /** - * @private - * 是否被暂停 - */ - private isPaused; - /** - * Pause the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - /** - * Resume the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 恢复心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - resume(): void; - /** - * @private - * 执行一次刷新 - */ - update(forceUpdate?: boolean): void; - /** - * @private - * 执行一次屏幕渲染 - */ - private render(triggerByFrame, costTicker); - /** - * @private - * 广播EnterFrame事件。 - */ - private broadcastEnterFrame(); - /** - * @private - * 广播Render事件。 - */ - private broadcastRender(); - /** - * @private - */ - private callLaters(); - /** - * @private - */ - private callLaterAsyncs(); - } -} -declare module egret { - namespace lifecycle { - type LifecyclePlugin = (context: LifecycleContext) => void; - /** - * @private - */ - let stage: egret.Stage; - /** - * @private - */ - let contexts: LifecycleContext[]; - class LifecycleContext { - pause(): void; - resume(): void; - onUpdate?: () => void; - } - let onResume: () => void; - let onPause: () => void; - function addLifecycleListener(plugin: LifecyclePlugin): void; - } - /** - * 心跳计时器单例 - */ - let ticker: sys.SystemTicker; -} -/** - * @private - */ -declare let egret_stages: egret.Stage[]; -declare namespace egret.sys { - /** - * @private - * 用户交互操作管理器 - */ - class TouchHandler extends HashObject { - private maxTouches; - private useTouchesCount; - /** - * @private - */ - constructor(stage: Stage); - /** - * @private - * 设置同时触摸数量 - */ - $initMaxTouches(): void; - /** - * @private - */ - private stage; - /** - * @private - */ - private touchDownTarget; - /** - * @private - * 触摸开始(按下) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchBegin(x: number, y: number, touchPointID: number): void; - /** - * @private - */ - private lastTouchX; - /** - * @private - */ - private lastTouchY; - /** - * @private - * 触摸移动 - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchMove(x: number, y: number, touchPointID: number): void; - /** - * @private - * 触摸结束(弹起) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchEnd(x: number, y: number, touchPointID: number): void; - /** - * @private - * 获取舞台坐标下的触摸对象 - */ - private findTarget(stageX, stageY); - } -} -declare namespace egret.sys { - /** - * @private - * 位图渲染节点 - */ - class BitmapNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 使用的混合模式 - */ - blendMode: number; - /** - * 相对透明度 - */ - alpha: number; - /** - * 颜色变换滤镜 - */ - filter: ColorMatrixFilter; - /** - * 翻转 - */ - rotated: boolean; - /** - * 绘制一次位图 - */ - drawImage(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - static $updateTextureData(node: sys.NormalBitmapNode, image: BitmapData, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, destW: number, destH: number, sourceWidth: number, sourceHeight: number, fillMode: string, smoothing: boolean): void; - /** - * @private - * 绘制九宫格位图 - */ - static $updateTextureDataWithScale9Grid(node: sys.NormalBitmapNode, image: BitmapData, scale9Grid: egret.Rectangle, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, destW: number, destH: number, sourceWidth: number, sourceHeight: number, smoothing: boolean): void; - /** - * @private - */ - private static drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, destW, destH, startX?, startY?); - } -} -declare namespace egret.sys { - /** - * @private - * 矢量渲染节点 - */ - class GraphicsNode extends RenderNode { - constructor(); - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - beginFill(color: number, alpha?: number, beforePath?: Path2D): Path2D; - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - beginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix?: egret.Matrix, beforePath?: Path2D): Path2D; - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - */ - lineStyle(thickness?: number, color?: number, alpha?: number, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): StrokePath; - /** - * 清空所有缓存的绘制数据 - */ - clear(): void; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - */ - cleanBeforeRender(): void; - /** - * 绘制x偏移 - */ - x: number; - /** - * 绘制y偏移 - */ - y: number; - /** - * 绘制宽度 - */ - width: number; - /** - * 绘制高度 - */ - height: number; - /** - * 脏渲染标记 - * 暂时调用lineStyle,beginFill,beginGradientFill标记,实际应该draw时候标记在Path2D - */ - dirtyRender: boolean; - $texture: WebGLTexture; - $textureWidth: number; - $textureHeight: number; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * 清除非绘制的缓存数据 - */ - clean(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 组渲染节点,用于组合多个渲染节点 - */ - class GroupNode extends RenderNode { - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - constructor(); - addNode(node: RenderNode): void; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - * 这里只是想清空绘制命令,因此不调用super - */ - cleanBeforeRender(): void; - $getRenderCount(): number; - } -} -declare namespace egret.sys { - /** - * @private - * Mesh 渲染节点 - */ - class MeshNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - /** - * UV 坐标。 - */ - uvs: number[]; - /** - * 顶点坐标。 - */ - vertices: number[]; - /** - * 顶点索引。 - */ - indices: number[]; - /** - * 顶点索引。 - */ - bounds: Rectangle; - /** - * 使用的混合模式 - */ - blendMode: number; - /** - * 相对透明度 - */ - alpha: number; - /** - * 颜色变换滤镜 - */ - filter: ColorMatrixFilter; - /** - * 翻转 - */ - rotated: boolean; - /** - * 绘制一次位图 - */ - drawMesh(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 位图渲染节点 - */ - class NormalBitmapNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 翻转 - */ - rotated: boolean; - sourceX: number; - sourceY: number; - sourceW: number; - sourceH: number; - drawX: number; - drawY: number; - drawW: number; - drawH: number; - /** - * 绘制一次位图 - */ - drawImage(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret { - /** - * @private - */ - class Mesh extends Bitmap { - constructor(value?: Texture); - protected createNativeDisplayObject(): void; - /** - * @private - */ - protected setBitmapDataToWasm(data?: Texture): void; - /** - * @private - */ - $updateRenderNode(): void; - /** - * @private - */ - private _verticesDirty; - private _bounds; - /** - * @private - */ - $updateVertices(): void; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - } -} -declare namespace egret.sys { - /** - * @private - * 文本格式 - */ - interface TextFormat { - /** - * 颜色值 - */ - textColor?: number; - /** - * 描边颜色值 - */ - strokeColor?: number; - /** - * 字号 - */ - size?: number; - /** - * 描边大小 - */ - stroke?: number; - /** - * 是否加粗 - */ - bold?: boolean; - /** - * 是否倾斜 - */ - italic?: boolean; - /** - * 字体名称 - */ - fontFamily?: string; - } -} -declare namespace egret.sys { - /** - * @private - * 文本渲染节点 - */ - class TextNode extends RenderNode { - constructor(); - /** - * 颜色值 - */ - textColor: number; - /** - * 描边颜色值 - */ - strokeColor: number; - /** - * 字号 - */ - size: number; - /** - * 描边大小 - */ - stroke: number; - /** - * 是否加粗 - */ - bold: boolean; - /** - * 是否倾斜 - */ - italic: boolean; - /** - * 字体名称 - */ - fontFamily: string; - /** - * 绘制一行文本 - */ - drawText(x: number, y: number, text: string, format: TextFormat): void; - /** - * 绘制x偏移 - */ - x: number; - /** - * 绘制y偏移 - */ - y: number; - /** - * 绘制宽度 - */ - width: number; - /** - * 绘制高度 - */ - height: number; - /** - * 脏渲染标记 - */ - dirtyRender: boolean; - $texture: WebGLTexture; - $textureWidth: number; - $textureHeight: number; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * 清除非绘制的缓存数据 - */ - clean(): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 填充路径 - */ - class FillPath extends Path2D { - constructor(); - /** - * 填充颜色 - */ - fillColor: number; - /** - * 填充透明度 - */ - fillAlpha: number; - } -} -declare namespace egret.sys { - /** - * @private - * 渐变填充路径 - */ - class GradientFillPath extends Path2D { - constructor(); - gradientType: string; - colors: number[]; - alphas: number[]; - ratios: number[]; - matrix: Matrix; - } -} -declare namespace egret { - /** - * OrientationMode 类为舞台初始旋转模式提供值。 - */ - const OrientationMode: { - AUTO: string; - PORTRAIT: string; - LANDSCAPE: string; - LANDSCAPE_FLIPPED: string; - }; -} -declare namespace egret.sys { - /** - * @private - * 线条路径。 - * 注意:当线条宽度(lineWidth)为1或3像素时,需要特殊处理,往右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - class StrokePath extends Path2D { - constructor(); - /** - * 线条宽度。 - * 注意:绘制时对1像素和3像素要特殊处理,整体向右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - lineWidth: number; - /** - * 线条颜色 - */ - lineColor: number; - /** - * 线条透明度 - */ - lineAlpha: number; - /** - * 端点样式,"none":无端点,"round":圆头端点,"square":方头端点 - */ - caps: string; - /** - * 联接点样式,"bevel":斜角连接,"miter":尖角连接,"round":圆角连接 - */ - joints: string; - /** - * 用于表示剪切斜接的极限值的数字。 - */ - miterLimit: number; - /** - * 描述交替绘制线段和间距(坐标空间单位)长度的数字。 - */ - lineDash: number[]; - } -} -/** - * @private - */ -interface CanvasRenderingContext2D { - imageSmoothingEnabled: boolean; - $imageSmoothingEnabled: boolean; - $offsetX: number; - $offsetY: number; -} -declare namespace egret { - class CanvasRenderer { - private nestLevel; - render(displayObject: DisplayObject, buffer: sys.RenderBuffer, matrix: Matrix, forRenderTexture?: boolean): number; - /** - * @private - * 绘制一个显示对象 - */ - private drawDisplayObject(displayObject, context, offsetX, offsetY, isStage?); - private drawWithFilter(displayObject, context, offsetX, offsetY); - private drawWithClip(displayObject, context, offsetX, offsetY); - private drawWithScrollRect(displayObject, context, offsetX, offsetY); - drawNodeToBuffer(node: sys.RenderNode, buffer: sys.RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; - /** - * 将一个DisplayObject绘制到渲染缓冲,用于RenderTexture绘制 - * @param displayObject 要绘制的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - */ - drawDisplayToBuffer(displayObject: DisplayObject, buffer: sys.RenderBuffer, matrix: Matrix): number; - private renderNode(node, context, forHitTest?); - private renderNormalBitmap(node, context); - private renderBitmap(node, context); - private renderMesh(node, context); - renderText(node: sys.TextNode, context: CanvasRenderingContext2D): void; - private renderingMask; - /** - * @private - */ - renderGraphics(node: sys.GraphicsNode, context: CanvasRenderingContext2D, forHitTest?: boolean): number; - private renderPath(path, context); - private renderGroup(groupNode, context); - private createRenderBuffer(width, height, useForFilters?); - } - /** - * @private - * 获取字体字符串 - */ - function getFontString(node: sys.TextNode, format: sys.TextFormat): string; - /** - * @private - * 获取RGBA字符串 - */ - function getRGBAString(color: number, alpha: number): string; -} -declare namespace egret { - /** - * Orientation monitor the orientation of the device, send CHANGE event when the orientation is changed - * - * @event egret.Event.CHANGE device's orientation is changed - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/DeviceOrientation.ts - * @see http://edn.egret.com/cn/docs/page/661 获取设备旋转角度 - * @language en_US - */ - /** - * Orientation 监听设备方向的变化,当方向变化时派发 CHANGE 事件 - * @event egret.Event.CHANGE 设备方向改变时派发 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/DeviceOrientation.ts - * @see http://edn.egret.com/cn/docs/page/661 获取设备旋转角度 - * @language zh_CN - */ - interface DeviceOrientation extends EventDispatcher { - /** - * Start to monitor the device's orientation - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备方向变化 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor the device's orientation - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备方向变化 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * @copy egret.Orientation - */ - let DeviceOrientation: { - new (): DeviceOrientation; - }; -} -declare namespace egret { - /** - * The Geolocation able to obtain the position of the device. - * Geolocation will emit CHANGE event when the device's location is changed. - * It will emit IO_ERROR event if the location request is denied - * or there is no location service on the device. - * - * @event egret.Event.CHANGE The device's location is changed - * @event egret.Event.IO_ERROR Error occurred while getting the location - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Geolocation.ts - * @language en_US - */ - /** - * Geolocation 能够从设备的定位服务获取设备的当前位置。 - * 当设备的位置发生改变时 Geolocation 会派发 CHANGE 事件。 - * 当定位请求被拒绝或该设备没有定位服务时 Geolocation 会派发 IO_ERROR 事件。 - * - * @event egret.Event.CHANGE 设备位置发生改变 - * @event egret.Event.IO_ERROR 获取设备位置时发生错误 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Geolocation.ts - * @language zh_CN - */ - interface Geolocation extends EventDispatcher { - /** - * Start to monitor the device's location - * @returns - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备位置信息 - * @returns - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor the device's location - * @returns - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备位置信息 - * @returns - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * @copy egret.Geolocation - */ - let Geolocation: { - /** - * constructor - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 构造函数 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - new (): Geolocation; - }; -} -declare namespace egret { - /** - * @copy egret.Motion - */ - let Motion: { - new (): Motion; - }; - /** - * The Motion class emits events based on activity detected by the device's motion sensor. - * This data represents the device's movement along a 3-dimensional axis. When the device moves, - * the sensor detects this movement and emit the CHANGE event. @see egret.MotionEvent - * - * @event egret.Event.CHANGE device is moved - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Motion.ts - * @language en_US - */ - /** - * Motion 类从用户设备读取运动状态信息并派发 CHANGE 事件。 - * 当设备移动时,传感器会检测到此移动并返回设备加速度,重力和旋转数据。@see egret.MotionEvent - * Motion 类提供了 start 和 stop 方法,来启动和停止运动信息检查 - * - * @event egret.Event.CHANGE 运动状态发生改变 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Motion.ts - * @language zh_CN - */ - interface Motion extends EventDispatcher { - /** - * Start to monitor device movement - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备运动状态 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor device movement - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备运动状态 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * A DeviceRotationRate object provides information about the rate at which - * the device is rotating around all three axes. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * DeviceRotationRate 提供设备围绕三个轴旋转的角速度信息,单位是 角度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - interface DeviceRotationRate { - /** - * The amount of rotation around the Z axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 Z 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - alpha: number; - /** - * The amount of rotation around the X axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 X 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - beta: number; - /** - * The amount of rotation around the Y axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 Y 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - gamma: number; - } - /** - * A DeviceAcceleration object provides information about the amount - * of acceleration the device is experiencing along all three axes. - * Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * DeviceAcceleration 提供设备在三个维度的加速度信息,加速度值的单位是 m/s2 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - interface DeviceAcceleration { - /** - * The amount of acceleration along the X axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * X 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - x: number; - /** - * The amount of acceleration along the Y axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * Y 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - y: number; - /** - * The amount of acceleration along the Z axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * Z 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - z: number; - } -} -declare namespace egret { - /** - * Type of operation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行类型的类型。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace RuntimeType { - /** - * Running on Web - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Web上 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const WEB = "web"; - /** - * Running on NATIVE - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language en_US - */ - /** - * 运行在NATIVE上 - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language zh_CN - */ - const NATIVE = "native"; - /** - * Running on Runtime2.0 - * @version Egret 5.1.5 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Runtime2.0上 - * @version Egret 5.1.5 - * @platform Web,Native - * @language zh_CN - */ - const RUNTIME2 = "runtime2"; - /** - * Running on Alipay - * @version Egret 5.2.33 - * @platform All - * @language en_US - */ - /** - * 运行在支付宝小游戏上 - * @version Egret 5.2.33 - * @platform All - * @language zh_CN - */ - const MYGAME = "mygame"; - /** - * Running on WeChat mini game - * @version Egret 5.1.5 - * @platform All - * @language en_US - */ - /** - * 运行在微信小游戏上 - * @version Egret 5.1.5 - * @platform All - * @language zh_CN - */ - const WXGAME = "wxgame"; - /** - * Running on Baidu mini game - * @version Egret 5.2.13 - * @platform All - * @language en_US - */ - /** - * 运行在百度小游戏上 - * @version Egret 5.2.13 - * @platform All - * @language zh_CN - */ - const BAIDUGAME = "baidugame"; - /** - * Running on Xiaomi quick game - * @version Egret 5.2.14 - * @platform All - * @language en_US - */ - /** - * 运行在小米快游戏上 - * @version Egret 5.2.14 - * @platform All - * @language zh_CN - */ - const QGAME = "qgame"; - /** - * Running on OPPO mini game - * @version Egret 5.2.14 - * @platform All - * @language en_US - */ - /** - * 运行在 Oppo 小游戏上 - * @version Egret 5.2.14 - * @platform All - * @language zh_CN - */ - const OPPOGAME = "oppogame"; - /** - * Running on QQ mini game - * @version Egret 5.2.25 - * @platform All - * @language en_US - */ - /** - * 运行在 QQ 小游戏上 - * @version Egret 5.2.25 - * @platform All - * @language zh_CN - */ - const QQGAME = "qqgame"; - /** - * Running on vivo mini game - * @version Egret 5.2.23 - * @platform All - * @language en_US - */ - /** - * 运行在 vivo 小游戏上 - * @version Egret 5.2.23 - * @platform All - * @language zh_CN - */ - const VIVOGAME = "vivogame"; - } - interface SupportedCompressedTexture { - pvrtc: boolean; - etc1: boolean; - } - /** - * The Capabilities class provides properties that describe the system and runtime that are hosting the application. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language en_US - */ - /** - * Capabilities 类提供一些属性,这些属性描述了承载应用程序的系统和运行时。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language zh_CN - */ - class Capabilities { - /** - * Specifies the language code of the system on which the content is running. The language is specified as a lowercase - * two-letter language code from ISO 639-1. For Chinese, an additional uppercase two-letter country code from ISO 3166 - * distinguishes between Simplified and Traditional Chinese.
- * The following table lists the possible values,but not limited to them: - *
    - *
  • Simplified Chinese zh-CN
  • - *
  • Traditional Chinese zh-TW
  • - *
  • English en
  • - *
  • Japanese ja
  • - *
  • Korean ko
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示运行内容的系统的语言代码。语言指定为 ISO 639-1 中的小写双字母语言代码。 - * 对于中文,另外使用 ISO 3166 中的大写双字母国家/地区代码,以区分简体中文和繁体中文。
- * 以下是可能但不限于的语言和值: - *
    - *
  • 简体中文 zh-CN
  • - *
  • 繁体中文 zh-TW
  • - *
  • 英语 en
  • - *
  • 日语 ja
  • - *
  • 韩语 ko
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly language: string; - /** - * Specifies whether the system is running in a mobile device.(such as a mobile phone or tablet) - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示程序内容是否运行在移动设备中(例如移动电话或平板电脑)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly isMobile: boolean; - /** - * Specifies the current operating system. The os property can return the following strings: - *
    - *
  • iPhone "iOS"
  • - *
  • Android Phone "Android"
  • - *
  • Windows Phone "Windows Phone"
  • - *
  • Windows Desktop "Windows PC"
  • - *
  • Mac Desktop "Mac OS"
  • - *
  • Unknown OS "Unknown"
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的操作系统。os 属性返回下列字符串: - *
    - *
  • 苹果手机操作系统 "iOS"
  • - *
  • 安卓手机操作系统 "Android"
  • - *
  • 微软手机操作系统 "Windows Phone"
  • - *
  • 微软桌面操作系统 "Windows PC"
  • - *
  • 苹果桌面操作系统 "Mac OS"
  • - *
  • 未知操作系统 "Unknown"
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly os: string; - /** - * It indicates the current type of operation. runtimeType property returns the following string: - *
    - *
  • Run on Web egret.RuntimeType.WEB
  • - *
  • Run on Runtime2.0 egret.RuntimeType.RUNTIME2
  • - *
  • Run on WeChat mini game egret.RuntimeType.WXGAME
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的运行类型。runtimeType 属性返回下列字符串: - *
    - *
  • 运行在Web上 egret.RuntimeType.WEB
  • - *
  • 运行在Runtime2.0上 egret.RuntimeType.RUNTIME2
  • - *
  • 运行在微信小游戏上 egret.RuntimeType.WXGAME
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly runtimeType: string; - /*** - * version of Egret. - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language en_US - */ - /*** - * Egret 的版本号。 - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language zh_CN - */ - static readonly engineVersion: string; - /*** - * current render mode. - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language en_US - */ - /*** - * 当前渲染模式。 - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language zh_CN - */ - static readonly renderMode: string; - /*** - * Clients border width. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界宽度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - static readonly boundingClientWidth: number; - /*** - * Clients border height. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界高度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - static readonly boundingClientHeight: number; - /*** - * supported compressed texture - * @version Egret 5.2.19 - * @platform Web,Native - * @language en_US - */ - /*** - * supported compressed texture - * @version Egret 5.2.19 - * @platform Web,Native - * @language zh_CN - */ - static supportedCompressedTexture: SupportedCompressedTexture; - } -} -declare namespace egret { - /** - * RenderTexture is a dynamic texture - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language en_US - */ - /** - * RenderTexture 是动态纹理类,他实现了将显示对象及其子对象绘制成为一个纹理的功能 - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language zh_CN - */ - class RenderTexture extends egret.Texture { - constructor(); - $renderBuffer: sys.RenderBuffer; - /** - * The specified display object is drawn as a texture - * @param displayObject {egret.DisplayObject} the display to draw - * @param clipBounds {egret.Rectangle} clip rect - * @param scale {number} scale factor - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定显示对象绘制为一个纹理 - * @param displayObject {egret.DisplayObject} 需要绘制的显示对象 - * @param clipBounds {egret.Rectangle} 绘制矩形区域 - * @param scale {number} 缩放比例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawToTexture(displayObject: egret.DisplayObject, clipBounds?: Rectangle, scale?: number): boolean; - /** - * @inheritDoc - */ - getPixel32(x: number, y: number): number[]; - /** - * @inheritDoc - */ - dispose(): void; - } -} -declare namespace egret { - /** - * Adds an interface-name-to-implementation-class mapping to the registry. - * @param interfaceName the interface name to register. For example:"eui.IAssetAdapter","eui.Theme" - * @param instance the instance to register. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 注册一个接口实现。 - * @param interfaceName 注入的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @param instance 实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function registerImplementation(interfaceName: string, instance: any): void; - /** - * Returns the singleton instance of the implementation class that was registered for the specified interface. - * This method is usually called by egret framework. - * @param interfaceName The interface name to identify. For example:"eui.IAssetAdapter","eui.Theme" - * @returns the singleton instance of the implementation class - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个接口实现。此方法通常由框架内部调用。获取项目注入的自定义实现实例。 - * @param interfaceName 要获取的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @returns 返回实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function getImplementation(interfaceName: string): any; -} -declare namespace egret { - /** - * This class is used to create lightweight shapes using the drawing application program interface (API). The Shape - * class includes a graphics property, which lets you access methods from the Graphics class. - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language en_US - */ - /** - * 此类用于使用绘图应用程序编程接口 (API) 创建简单形状。Shape 类含有 graphics 属性,通过该属性您可以访问各种矢量绘图方法。 - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language zh_CN - */ - class Shape extends DisplayObject { - /** - * Creates a new Shape object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Shape 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $graphics: Graphics; - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly graphics: Graphics; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * Bitmap font, texture set of a font. It is generally used as the value of the BitmapText.font attribute. - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 Text(Containing the specific usage of the bitmap font ) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language en_US - */ - /** - * 位图字体,是一个字体的纹理集,通常作为BitmapText.font属性的值。 - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 文本(含位图字体具体用法) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language zh_CN - */ - class BitmapFont extends SpriteSheet { - /** - * Create an egret.BitmapFont object - * @param texture {egret.Texture} Texture set that use TextureMerger create - * @param config {any} Configure data that use TextureMerger create - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapFont 对象 - * @param texture {egret.Texture} 使用TextureMerger生成的纹理集 - * @param config {any} 使用TextureMerger生成的配置数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(texture: Texture, config: any); - /** - * @private - */ - private charList; - /** - * Obtain corresponding texture through the name attribute - * @param name {string} name Attribute - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过 name 属性获取对应纹理 - * @param name {string} name属性 - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTexture(name: string): Texture; - /** - * @private - */ - getConfig(name: string, key: string): number; - /** - * @private - */ - private firstCharHeight; - /** - * @private - * - * @returns - */ - _getFirstCharHeight(): number; - /** - * @private - * - * @param fntText - * @returns - */ - private parseConfig(fntText); - /** - * @private - * - * @param configText - * @param key - * @returns - */ - private getConfigByKey(configText, key); - } -} -declare namespace egret { - /** - * Bitmap font adopts the Bitmap+SpriteSheet mode to render text. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language en_US - */ - /** - * 位图字体采用了Bitmap+SpriteSheet的方式来渲染文字。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language zh_CN - */ - class BitmapText extends DisplayObject { - /** - * Create an egret.BitmapText object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapText 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - private $smoothing; - /** - * Whether or not is smoothed when scaled. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - smoothing: boolean; - private $text; - /** - * A string to display in the text field. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要显示的文本内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * @private - */ - $setText(value: string): boolean; - protected $textFieldWidth: number; - /** - * @private - */ - $getWidth(): number; - /** - * @private - */ - $setWidth(value: number): boolean; - private $textLinesChanged; - /** - * @private - */ - $invalidateContentBounds(): void; - protected $textFieldHeight: number; - /** - * @private - */ - $getHeight(): number; - /** - * @private - */ - $setHeight(value: number): boolean; - protected $font: BitmapFont; - protected $fontStringChanged: boolean; - /** - * The name of the font to use, or a comma-separated list of font names, the type of value must be BitmapFont. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表,类型必须是 BitmapFont。 - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - font: Object; - $setFont(value: any): boolean; - private $lineSpacing; - /** - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineSpacing: number; - $setLineSpacing(value: number): boolean; - private $letterSpacing; - /** - * An integer representing the amount of distance between characters. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示字符之间的距离。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - letterSpacing: number; - $setLetterSpacing(value: number): boolean; - private $textAlign; - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - textAlign: string; - $setTextAlign(value: string): boolean; - private $verticalAlign; - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - verticalAlign: string; - $setVerticalAlign(value: string): boolean; - /** - * A ratio of the width of the space character. This value is multiplied by the height of the first character is the space character width. - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个空格字符的宽度比例。这个数值乘以第一个字符的高度即为空格字符的宽。 - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static EMPTY_FACTOR: number; - /** - * @private - */ - $updateRenderNode(): void; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - private $textWidth; - /** - * Get the BitmapText measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textWidth: number; - private $textHeight; - /** - * Get Text BitmapText height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textHeight: number; - /** - * @private - */ - private $textOffsetX; - /** - * @private - */ - private $textOffsetY; - /** - * @private - */ - private $textStartX; - /** - * @private - */ - private $textStartY; - /** - * @private - */ - private textLines; - /** - * @private 每一行文字的宽度 - */ - private $textLinesWidth; - /** - * @private - */ - $lineHeights: number[]; - /** - * @private - * - * @returns - */ - $getTextLines(): string[]; - } -} -declare namespace egret { - /** - * The HorizontalAlign class defines the possible values for the horizontal alignment. - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HorizontalAlign 类为水平对齐方式定义可能的值。 - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HorizontalAlign { - /** - * Horizontally align content to the left of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的左侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LEFT: string; - /** - * Horizontally align content to the right of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的右侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RIGHT: string; - /** - * Horizontally align content in the center of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的水平中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CENTER: string; - /** - * Horizontal alignment with both edges. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 水平两端对齐。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY: string; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Width \" of the container \". - * The Content Width \" of the container \" is the size of the max. child item. If the size of all child items are less than the width of the container, they will be adjusted to the width of the container. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容宽度"。 - * 容器的"内容宽度"是最大子项的大小,如果所有子项都小于容器的宽度,则会将所有子项的大小调整为容器的宽度。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CONTENT_JUSTIFY: string; - } -} -declare namespace egret { - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language zh_CN - */ - class HtmlTextParser { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - private replaceArr; - private initReplaceArr(); - /** - * @private - * - * @param value - * @returns - */ - private replaceSpecial(value); - /** - * @private - */ - private resutlArr; - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @param htmltext {string} Text in html - * @returns {Array} 可赋值给 egret.TextField#textFlow Object that can be assigned to the egret.TextField#textFlow property - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @param htmltext {string} html文本 - * @returns {Array} 可赋值给 egret.TextField#textFlow 属性的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - parse(htmltext: string): egret.ITextElement[]; - parser(htmltext: string): Array; - /** - * @private - * - * @param value - */ - private addToResultArr(value); - private changeStringToObject(str); - /** - * @private - * - * @returns - */ - private getHeadReg(); - /** - * @private - * - * @param info - * @param head - * @param value - */ - private addProperty(info, head, value); - /** - * @private - */ - private stackArray; - /** - * @private - * - * @param infoStr - */ - private addToArray(infoStr); - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface IHitTextElement { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - lineIndex: number; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - textElementIndex: number; - } - /** - * Text Style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本样式 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface ITextStyle { - /** - * text color - * @version Egret 2.4 - * @platform Web,Native - * @see http://edn.egret.com/cn/docs/page/146 多种样式混合文本的基本结构 - * @language en_US - */ - /** - * 颜色值 - * @version Egret 2.4 - * @platform Web,Native - * @see http://edn.egret.com/cn/docs/page/146 多种样式混合文本的基本结构 - * @language zh_CN - */ - textColor?: number; - /** - * stroke color - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 描边颜色值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - strokeColor?: number; - /** - * size - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - size?: number; - /** - * stroke width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 描边大小 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stroke?: number; - /** - * whether bold - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否加粗 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bold?: boolean; - /** - * whether italic - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否倾斜 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - italic?: boolean; - /** - * fontFamily - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字体名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fontFamily?: string; - /** - * Link events or address - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 链接事件或者地址 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - href?: string; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - target?: string; - /** - * Is underlined - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否加下划线 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - underline?: boolean; - } - /** - * Used to build the basic structure of text with a variety of mixed styles, mainly for setting textFlow property - * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于建立多种样式混合文本的基本结构,主要用于设置 textFlow 属性 - * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface ITextElement { - /** - * String Content - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字符串内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * Text Style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本样式 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - style?: ITextStyle; - } - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface IWTextElement extends ITextElement { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - width: number; - } - /** - * 文本最终解析的一行数据格式 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface ILineElement { - /** - * 文本占用宽度 - * @version Egret 2.4 - * @platform Web,Native - */ - width: number; - /** - * 文本占用高度 - * @version Egret 2.4 - * @platform Web,Native - */ - height: number; - /** - * 当前文本字符总数量(包括换行符) - * @version Egret 2.4 - * @platform Web,Native - */ - charNum: number; - /** - * 是否含有换行符 - * @version Egret 2.4 - * @platform Web,Native - */ - hasNextLine: boolean; - /** - * 本行文本内容 - * @version Egret 2.4 - * @platform Web,Native - */ - elements: Array; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class InputController extends HashObject { - /** - * @private - */ - stageText: egret.StageText; - /** - * @private - */ - private stageTextAdded; - /** - * @private - */ - private _text; - /** - * @private - */ - private _isFocus; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - init(text: TextField): void; - /** - * @private - * - */ - _addStageText(): void; - /** - * @private - * - */ - _removeStageText(): void; - /** - * @private - * - * @returns - */ - _getText(): string; - /** - * @private - * - * @param value - */ - _setText(value: string): void; - /** - * @private - */ - _setColor(value: number): void; - /** - * @private - * - * @param event - */ - private focusHandler(event); - /** - * @private - * - * @param event - */ - private blurHandler(event); - private tempStage; - private onMouseDownHandler(event); - $onFocus(): void; - private onStageDownHandler(event); - /** - * @private - * - * @param event - */ - private updateTextHandler(event); - /** - * @private - * - */ - private resetText(); - /** - * @private - * - */ - _hideInput(): void; - /** - * @private - * - */ - private updateInput(); - /** - * @private - * - */ - _updateProperties(): void; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface StageText extends EventDispatcher { - /** - * @private - */ - $textfield: egret.TextField; - /** - * @private - * - * @param textfield - */ - $setTextField(textfield: egret.TextField): boolean; - /** - * @private - * - */ - $resetStageText(): void; - /** - * @private - * - * @returns - */ - $getText(): string; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - /** - * @private - * - * @param value - */ - $setColor(value: number): boolean; - /** - * @private - * - */ - $show(): void; - /** - * @private - * - */ - $hide(): void; - /** - * @private - * - */ - $addToStage(): void; - /** - * @private - * - */ - $removeFromStage(): void; - /** - * @private - * - */ - $onBlur(): void; - } - /** - * @version Egret 2.4 - * @platform Web,Native - */ - let StageText: { - new (): StageText; - }; -} -declare namespace egret.sys { - /** - * @private - */ - const enum TextKeys { - /** - * @private - */ - fontSize = 0, - /** - * @private - */ - lineSpacing = 1, - /** - * @private - */ - textColor = 2, - /** - * @private - */ - textFieldWidth = 3, - /** - * @private - */ - textFieldHeight = 4, - /** - * @private - */ - textWidth = 5, - /** - * @private - */ - textHeight = 6, - /** - * @private - */ - textDrawWidth = 7, - /** - * @private - */ - fontFamily = 8, - /** - * @private - */ - textAlign = 9, - /** - * @private - */ - verticalAlign = 10, - /** - * @private - */ - textColorString = 11, - /** - * @private - */ - fontString = 12, - /** - * @private - */ - text = 13, - /** - * @private - */ - measuredWidths = 14, - /** - * @private - */ - bold = 15, - /** - * @private - */ - italic = 16, - /** - * @private - */ - fontStringChanged = 17, - /** - * @private - */ - textLinesChanged = 18, - /** - * @private - */ - wordWrap = 19, - /** - * @private - */ - displayAsPassword = 20, - /** - * @private - */ - maxChars = 21, - /** - * @private - */ - selectionActivePosition = 22, - /** - * @private - */ - selectionAnchorPosition = 23, - /** - * @private - */ - type = 24, - /** - * @private - */ - strokeColor = 25, - /** - * @private - */ - strokeColorString = 26, - /** - * @private - */ - stroke = 27, - /** - * @private - */ - scrollV = 28, - /** - * @private - */ - numLines = 29, - /** - * @private - */ - multiline = 30, - /** - * @private - */ - border = 31, - /** - * @private - */ - borderColor = 32, - /** - * @private - */ - background = 33, - /** - * @private - */ - backgroundColor = 34, - /** - * @private - */ - restrictAnd = 35, - /** - * @private - */ - restrictNot = 36, - /** - * @private - */ - inputType = 37, - /** - * @private - */ - textLinesChangedForNativeRender = 38, - } -} -declare namespace egret { - /** - * TextField is the text rendering class of egret. It conducts rendering by using the browser / device API. Due to different ways of font rendering in different browsers / devices, there may be differences in the rendering - * If developers expect no differences among all platforms, please use BitmapText - * @see http://edn.egret.com/cn/docs/page/141 Create Text - * - * @event egret.Event.CHANGE Dispatched when entering text user input。 - * @event egret.FocusEvent.FOCUS_IN Dispatched after the focus to enter text. - * @event egret.FocusEvent.FOCUS_OUT Enter the text loses focus after dispatch. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language en_US - */ - /** - * TextField是egret的文本渲染类,采用浏览器/设备的API进行渲染,在不同的浏览器/设备中由于字体渲染方式不一,可能会有渲染差异 - * 如果开发者希望所有平台完全无差异,请使用BitmapText - * @see http://edn.egret.com/cn/docs/page/141 创建文本 - * - * @event egret.Event.CHANGE 输入文本有用户输入时调度。 - * @event egret.FocusEvent.FOCUS_IN 聚焦输入文本后调度。 - * @event egret.FocusEvent.FOCUS_OUT 输入文本失去焦点后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language zh_CN - */ - class TextField extends DisplayObject { - /** - * default fontFamily - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字体 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static default_fontFamily: string; - /** - * default size in pixels of text - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字号大小 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - static default_size: number; - /** - * default color of the text. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本颜色 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - static default_textColor: number; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $TextField: Object; - /** - * @private - */ - private isInput(); - $inputEnabled: boolean; - $setTouchEnabled(value: boolean): void; - /** - * The name of the font to use, or a comma-separated list of font names. - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表。 - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fontFamily: string; - $setFontFamily(value: string): boolean; - /** - * The size in pixels of text - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的字号大小。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - size: number; - $setSize(value: number): boolean; - /** - * Specifies whether the text is boldface. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为粗体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bold: boolean; - $setBold(value: boolean): boolean; - /** - * Determines whether the text is italic font. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为斜体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - italic: boolean; - $setItalic(value: boolean): boolean; - /** - * @private - * - */ - private invalidateFontString(); - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - textAlign: string; - $setTextAlign(value: string): boolean; - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - verticalAlign: string; - $setVerticalAlign(value: string): boolean; - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineSpacing: number; - $setLineSpacing(value: number): boolean; - /** - * Color of the text. - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本颜色 - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - textColor: number; - $setTextColor(value: number): boolean; - /** - * A Boolean value that indicates whether the text field word wrap. If the value is true, then the text field by word wrap; - * if the value is false, the text field by newline characters. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个布尔值,表示文本字段是否按单词换行。如果值为 true,则该文本字段按单词换行; - * 如果值为 false,则该文本字段按字符换行。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - wordWrap: boolean; - $setWordWrap(value: boolean): void; - protected inputUtils: InputController; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Type of the text field. - * Any one of the following TextFieldType constants: TextFieldType.DYNAMIC (specifies the dynamic text field that users can not edit), or TextFieldType.INPUT (specifies the dynamic text field that users can edit). - * @default egret.TextFieldType.DYNAMIC - * @language en_US - */ - /** - * 文本字段的类型。 - * 以下 TextFieldType 常量中的任一个:TextFieldType.DYNAMIC(指定用户无法编辑的动态文本字段),或 TextFieldType.INPUT(指定用户可以编辑的输入文本字段)。 - * @default egret.TextFieldType.DYNAMIC - * @language zh_CN - */ - type: string; - /** - * @private - * - * @param value - */ - $setType(value: string): boolean; - /** - * @version Egret 3.1.2 - * @platform Web,Native - */ - /** - * Pop-up keyboard type. - * Any of a TextFieldInputType constants. - * @language en_US - */ - /** - * 弹出键盘的类型。 - * TextFieldInputType 常量中的任一个。 - * @language zh_CN - */ - inputType: string; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Serve as a string of the current text field in the text - * @language en_US - */ - /** - * 作为文本字段中当前文本的字符串 - * @language zh_CN - */ - text: string; - /** - * @private - * - * @returns - */ - $getText(): string; - /** - * @private - * - * @param value - */ - $setBaseText(value: string): boolean; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - /** - * Specify whether the text field is a password text field. - * If the value of this property is true, the text field is treated as a password text field and hides the input characters using asterisks instead of the actual characters. If false, the text field is not treated as a password text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否是密码文本字段。 - * 如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。 - * @default false - * @language zh_CN - */ - displayAsPassword: boolean; - /** - * @private - * - * @param value - */ - $setDisplayAsPassword(value: boolean): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Represent the stroke color of the text. - * Contain three 8-bit numbers with RGB color components; for example, 0xFF0000 is red, 0x00FF00 is green. - * @default 0x000000 - * @language en_US - */ - /** - * 表示文本的描边颜色。 - * 包含三个 8 位 RGB 颜色成分的数字;例如,0xFF0000 为红色,0x00FF00 为绿色。 - * @default 0x000000 - * @language zh_CN - */ - strokeColor: number; - /** - * @private - * - * @param value - */ - $setStrokeColor(value: number): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Indicate the stroke width. - * 0 means no stroke. - * @default 0 - * @language en_US - */ - /** - * 表示描边宽度。 - * 0为没有描边。 - * @default 0 - * @language zh_CN - */ - stroke: number; - /** - * @private - * - * @param value - */ - $setStroke(value: number): boolean; - /** - * The maximum number of characters that the text field can contain, as entered by a user. \n A script can insert more text than maxChars allows; the maxChars property indicates only how much text a user can enter. If the value of this property is 0, a user can enter an unlimited amount of text. - * The default value is 0. - * @default 0 - * @language en_US - */ - /** - * 文本字段中最多可包含的字符数(即用户输入的字符数)。 - * 脚本可以插入比 maxChars 允许的字符数更多的文本;maxChars 属性仅表示用户可以输入多少文本。如果此属性的值为 0,则用户可以输入无限数量的文本。 - * @default 0 - * @language zh_CN - */ - maxChars: number; - /** - * @private - * - * @param value - */ - $setMaxChars(value: number): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Vertical position of text in a text field. scrollV property helps users locate specific passages in a long article, and create scrolling text fields. - * Vertically scrolling units are lines, and horizontal scrolling unit is pixels. - * If the first displayed line is the first line in the text field, scrollV is set to 1 (instead of 0). - * @language en_US - */ - /** - * 文本在文本字段中的垂直位置。scrollV 属性可帮助用户定位到长篇文章的特定段落,还可用于创建滚动文本字段。 - * 垂直滚动的单位是行,而水平滚动的单位是像素。 - * 如果显示的第一行是文本字段中的第一行,则 scrollV 设置为 1(而非 0)。 - * @language zh_CN - */ - scrollV: number; - /** - * The maximum value of scrollV - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * scrollV 的最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly maxScrollV: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly selectionBeginIndex: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly selectionEndIndex: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly caretIndex: number; - /** - * @private - * - * @param beginIndex - * @param endIndex - */ - $setSelection(beginIndex: number, endIndex: number): boolean; - /** - * @private - * - * @returns - */ - $getLineHeight(): number; - /** - * Number of lines of text. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本行数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly numLines: number; - /** - * Indicate whether field is a multiline text field. Note that this property is valid only when the type is TextFieldType.INPUT. - * If the value is true, the text field is multiline; if the value is false, the text field is a single-line text field. In a field of type TextFieldType.INPUT, the multiline value determines whether the Enter key creates a new line (a value of false, and the Enter key is ignored). - * @default false - * @language en_US - */ - /** - * 表示字段是否为多行文本字段。注意,此属性仅在type为TextFieldType.INPUT时才有效。 - * 如果值为 true,则文本字段为多行文本字段;如果值为 false,则文本字段为单行文本字段。在类型为 TextFieldType.INPUT 的字段中,multiline 值将确定 Enter 键是否创建新行(如果值为 false,则将忽略 Enter 键)。 - * @default false - * @language zh_CN - */ - multiline: boolean; - /** - * @private - * - * @param value - */ - $setMultiline(value: boolean): boolean; - /** - * Indicates a user can enter into the text field character set. If you restrict property is null, you can enter any character. If you restrict property is an empty string, you can not enter any character. If you restrict property is a string of characters, you can enter only characters in the string in the text field. The string is scanned from left to right. You can use a hyphen (-) to specify a range. Only restricts user interaction; a script may put any text into the text field.
- * If the string of characters caret (^) at the beginning, all characters are initially accepted, then the string are excluded from receiving ^ character. If the string does not begin with a caret (^) to, any characters are initially accepted and then a string of characters included in the set of accepted characters.
- * The following example allows only uppercase characters, spaces, and numbers in the text field:
- * My_txt.restrict = "A-Z 0-9";
- * The following example includes all characters except lowercase letters:
- * My_txt.restrict = "^ a-z";
- * If you need to enter characters \ ^, use two backslash "\\ -" "\\ ^":
- * Can be used anywhere in the string ^ to rule out including characters and switch between characters, but can only be used to exclude a ^. The following code includes only uppercase letters except uppercase Q:
- * My_txt.restrict = "A-Z ^ Q";
- * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language en_US - */ - /** - * 表示用户可输入到文本字段中的字符集。如果 restrict 属性的值为 null,则可以输入任何字符。如果 restrict 属性的值为空字符串,则不能输入任何字符。如果 restrict 属性的值为一串字符,则只能在文本字段中输入该字符串中的字符。从左向右扫描该字符串。可以使用连字符 (-) 指定一个范围。只限制用户交互;脚本可将任何文本放入文本字段中。
- * 如果字符串以尖号 (^) 开头,则先接受所有字符,然后从接受字符集中排除字符串中 ^ 之后的字符。如果字符串不以尖号 (^) 开头,则最初不接受任何字符,然后将字符串中的字符包括在接受字符集中。
- * 下例仅允许在文本字段中输入大写字符、空格和数字:
- * my_txt.restrict = "A-Z 0-9";
- * 下例包含除小写字母之外的所有字符:
- * my_txt.restrict = "^a-z";
- * 如果需要输入字符 \ ^,请使用2个反斜杠 "\\-" "\\^" :
- * 可在字符串中的任何位置使用 ^,以在包含字符与排除字符之间进行切换,但是最多只能有一个 ^ 用来排除。下面的代码只包含除大写字母 Q 之外的大写字母:
- * my_txt.restrict = "A-Z^Q";
- * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language zh_CN - */ - restrict: string; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - /** - * @private - * 获取显示宽度 - */ - $getHeight(): number; - /** - * @private - */ - private textNode; - /** - * @private - */ - $graphicsNode: sys.GraphicsNode; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Specifies whether the text field has a border. - * If true, the text field has a border. If false, the text field has no border. - * Use borderColor property to set the border color. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有边框。 - * 如果为 true,则文本字段具有边框。如果为 false,则文本字段没有边框。 - * 使用 borderColor 属性来设置边框颜色。 - * @default false - * @language zh_CN - */ - border: boolean; - /** - * @private - */ - $setBorder(value: boolean): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * The color of the text field border. - * Even currently is no border can be retrieved or set this property, but only if the text field has the border property is set to true, the color is visible. - * @default 0x000000 - * @language en_US - */ - /** - * 文本字段边框的颜色。 - * 即使当前没有边框,也可检索或设置此属性,但只有当文本字段已将 border 属性设置为 true 时,才可以看到颜色。 - * @default 0x000000 - * @language zh_CN - */ - borderColor: number; - /** - * @private - */ - $setBorderColor(value: number): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Specifies whether the text field has a background fill. - * If true, the text field has a background fill. If false, the text field has no background fill. - * Use the backgroundColor property to set the background color of the text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有背景填充。 - * 如果为 true,则文本字段具有背景填充。如果为 false,则文本字段没有背景填充。 - * 使用 backgroundColor 属性来设置文本字段的背景颜色。 - * @default false - * @language zh_CN - */ - background: boolean; - /** - * @private - */ - $setBackground(value: boolean): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Color of the text field background. - * Even currently is no background, can be retrieved or set this property, but only if the text field has the background property set to true, the color is visible. - * @default 0xFFFFFF - * @language en_US - */ - /** - * 文本字段背景的颜色。 - * 即使当前没有背景,也可检索或设置此属性,但只有当文本字段已将 background 属性设置为 true 时,才可以看到颜色。 - * @default 0xFFFFFF - * @language zh_CN - */ - backgroundColor: number; - /** - * @private - */ - $setBackgroundColor(value: number): void; - /** - * @private - * - */ - private fillBackground(lines?); - /** - * Enter the text automatically entered into the input state, the input type is text only and may only be invoked in the user interaction. - * @version Egret 3.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 输入文本自动进入到输入状态,仅在类型是输入文本并且是在用户交互下才可以调用。 - * @version Egret 3.0.8 - * @platform Web,Native - * @language zh_CN - */ - setFocus(): void; - /** - * @private - * - */ - $onRemoveFromStage(): void; - /** - * @private - * - * @param stage - * @param nestLevel - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - $invalidateTextField(): void; - $getRenderBounds(): Rectangle; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - $updateRenderNode(): void; - /** - * @private - */ - private isFlow; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Set rich text - * @language en_US - */ - /** - * 设置富文本 - * @see http://edn.egret.com/cn/index.php/article/index/id/146 - * @language zh_CN - */ - textFlow: Array; - /** - * @private - * - * @param text - * @returns - */ - private changeToPassText(text); - /** - * @private - */ - private textArr; - /** - * @private - * - * @param textArr - */ - private setMiddleStyle(textArr); - /** - * Get the text measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textWidth: number; - /** - * Get Text measuring height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textHeight: number; - /** - * @private - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - appendText(text: string): void; - /** - * @private - * @param element - * @version Egret 2.4 - * @platform Web,Native - */ - appendElement(element: egret.ITextElement): void; - /** - * @private - */ - private linesArr; - $getLinesArr(): Array; - /** - * @private - * - * @returns - */ - $getLinesArr2(): Array; - /** - * @private - */ - $isTyping: boolean; - /** - * @private - */ - $setIsTyping(value: boolean): void; - /** - * @private - * 返回要绘制的下划线列表 - */ - private drawText(); - private addEvent(); - private removeEvent(); - private onTapHandler(e); - } - interface TextField { - addEventListener(type: "link", listener: (this: Z, e: TextEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: "focusIn" | "focusOut", listener: (this: Z, e: FocusEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } -} -declare namespace egret { - /** - * TextFieldInputType class is an enumeration of constant value used in setting the inputType property of the TextField class. - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldInputType 类是在设置 TextField 类的 inputType 属性时使用的常数值的枚举。 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - class TextFieldInputType { - /** - * The default - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 默认 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static TEXT: string; - /** - * Telephone Number Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 电话号码 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static TEL: string; - /** - * Password Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * password 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static PASSWORD: string; - } -} -declare namespace egret { - /** - * TextFieldType class is an enumeration of constant value used in setting the type property of the TextField class. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldType 类是在设置 TextField 类的 type 属性时使用的常数值的枚举。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class TextFieldType { - /** - * Used to specify dynamic text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定动态文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static DYNAMIC: string; - /** - * Used to specify the input text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定输入文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static INPUT: string; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class TextFieldUtils { - /** - * 获取第一个绘制的行数 - * @param textfield 文本 - * @returns {number} 行数,从0开始 - * @private - */ - static $getStartLine(textfield: egret.TextField): number; - /** - * 获取水平比例 - * @param textfield 文本 - * @returns {number} 水平比例 - * @private - */ - static $getHalign(textfield: egret.TextField): number; - /** - * @private - * - * @param textfield - * @returns - */ - static $getTextHeight(textfield: egret.TextField): number; - /** - * 获取垂直比例 - * @param textfield 文本 - * @returns {number} 垂直比例 - * @private - */ - static $getValign(textfield: egret.TextField): number; - /** - * 根据x、y获取文本项 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本单项 - * @private - */ - static $getTextElement(textfield: egret.TextField, x: number, y: number): ITextElement; - /** - * 获取文本点击块 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本点击块 - * @private - */ - static $getHit(textfield: egret.TextField, x: number, y: number): IHitTextElement; - /** - * 获取当前显示多少行 - * @param textfield 文本 - * @returns {number} 显示的行数 - * @private - */ - static $getScrollNum(textfield: egret.TextField): number; - } -} -/** - * @private - */ -declare namespace egret.sys { - /** - * 测量文本在指定样式下的宽度。 - * @param text 要测量的文本内容。 - * @param fontFamily 字体名称 - * @param fontSize 字体大小 - * @param bold 是否粗体 - * @param italic 是否斜体 - */ - let measureText: (text: string, fontFamily: string, fontSize: number, bold: boolean, italic: boolean) => number; -} -declare namespace egret { - /** - * The VerticalAlign class defines the possible values for the vertical alignment. - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * VerticalAlign 类为垂直对齐方式定义可能的值。 - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class VerticalAlign { - /** - * Vertically align content to the top of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的顶部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOP: string; - /** - * Vertically align content to the bottom of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的底部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static BOTTOM: string; - /** - * Vertically align content in the middle of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的垂直中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static MIDDLE: string; - /** - * Vertical alignment with both edges - * Note: TextFiled does not support this alignment method." - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直两端对齐 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY: string; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Height \" of the container \". - * The Content Height \" of the container \" is the size of the max. child item. If the size of all child items are less than the height of the container, they will be adjusted to the height of the container. - * Note: TextFiled does not support this alignment method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容高度"。 - * 容器的"内容高度"是最大子项的大小,如果所有子项都小于容器的高度,则会将所有子项的大小调整为容器的高度。 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CONTENT_JUSTIFY: string; - } -} -declare namespace egret { - /** - * @language en_US - * The Base64Util class provides methods for encoding and decoding base64. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - /** - * @language zh_CN - * Base64Util 类提供用于编解码base64的方法。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - class Base64Util { - /** - * @language en_US - * encode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 编码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - static encode(arraybuffer: ArrayBuffer): string; - /** - * @language en_US - * decode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 解码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - static decode(base64: string): ArrayBuffer; - } -} -/** - * @private - */ -declare let chars: string; -/** - * @private - */ -declare let lookup: Uint8Array; -declare namespace egret { - /** - * The Endian class contains values that denote the byte order used to represent multibyte numbers. - * The byte order is either bigEndian (most significant byte first) or littleEndian (least significant byte first). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Endian 类中包含一些值,它们表示用于表示多字节数字的字节顺序。 - * 字节顺序为 bigEndian(最高有效字节位于最前)或 littleEndian(最低有效字节位于最前)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class Endian { - /** - * Indicates the least significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最低有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LITTLE_ENDIAN: string; - /** - * Indicates the most significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最高有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static BIG_ENDIAN: string; - } - const enum EndianConst { - LITTLE_ENDIAN = 0, - BIG_ENDIAN = 1, - } - /** - * The ByteArray class provides methods and attributes for optimized reading and writing as well as dealing with binary data. - * Note: The ByteArray class is applied to the advanced developers who need to access data at the byte layer. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language en_US - */ - /** - * ByteArray 类提供用于优化读取、写入以及处理二进制数据的方法和属性。 - * 注意:ByteArray 类适用于需要在字节层访问数据的高级开发人员。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language zh_CN - */ - class ByteArray { - /** - * @private - */ - protected bufferExtSize: number; - protected data: DataView; - protected _bytes: Uint8Array; - /** - * @private - */ - protected _position: number; - /** - * - * 已经使用的字节偏移量 - * @protected - * @type {number} - * @memberOf ByteArray - */ - protected write_position: number; - /** - * Changes or reads the byte order; egret.EndianConst.BIG_ENDIAN or egret.EndianConst.LITTLE_EndianConst. - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改或读取数据的字节顺序;egret.EndianConst.BIG_ENDIAN 或 egret.EndianConst.LITTLE_ENDIAN。 - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - endian: string; - protected $endian: EndianConst; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(buffer?: ArrayBuffer | Uint8Array, bufferExtSize?: number); - /** - * @deprecated - * @version Egret 2.4 - * @platform Web,Native - */ - setArrayBuffer(buffer: ArrayBuffer): void; - /** - * 可读的剩余字节数 - * - * @returns - * - * @memberOf ByteArray - */ - readonly readAvailable: number; - /** - * @private - */ - buffer: ArrayBuffer; - readonly rawBuffer: ArrayBuffer; - readonly bytes: Uint8Array; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @private - */ - dataView: DataView; - /** - * @private - */ - readonly bufferOffset: number; - /** - * The current position of the file pointer (in bytes) to move or return to the ByteArray object. The next time you start reading reading method call in this position, or will start writing in this position next time call a write method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将文件指针的当前位置(以字节为单位)移动或返回到 ByteArray 对象中。下一次调用读取方法时将在此位置开始读取,或者下一次调用写入方法时将在此位置开始写入。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - position: number; - /** - * The length of the ByteArray object (in bytes). - * If the length is set to be larger than the current length, the right-side zero padding byte array. - * If the length is set smaller than the current length, the byte array is truncated. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * ByteArray 对象的长度(以字节为单位)。 - * 如果将长度设置为大于当前长度的值,则用零填充字节数组的右侧。 - * 如果将长度设置为小于当前长度的值,将会截断该字节数组。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - length: number; - protected _validateBuffer(value: number): void; - /** - * The number of bytes that can be read from the current position of the byte array to the end of the array data. - * When you access a ByteArray object, the bytesAvailable property in conjunction with the read methods each use to make sure you are reading valid data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 可从字节数组的当前位置到数组末尾读取的数据的字节数。 - * 每次访问 ByteArray 对象时,将 bytesAvailable 属性与读取方法结合使用,以确保读取有效的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly bytesAvailable: number; - /** - * Clears the contents of the byte array and resets the length and position properties to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除字节数组的内容,并将 length 和 position 属性重置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clear(): void; - /** - * Read a Boolean value from the byte stream. Read a simple byte. If the byte is non-zero, it returns true; otherwise, it returns false. - * @return If the byte is non-zero, it returns true; otherwise, it returns false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取布尔值。读取单个字节,如果字节非零,则返回 true,否则返回 false - * @return 如果字节不为零,则返回 true,否则返回 false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readBoolean(): boolean; - /** - * Read signed bytes from the byte stream. - * @return An integer ranging from -128 to 127 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取带符号的字节 - * @return 介于 -128 和 127 之间的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readByte(): number; - /** - * Read data byte number specified by the length parameter from the byte stream. Starting from the position specified by offset, read bytes into the ByteArray object specified by the bytes parameter, and write bytes into the target ByteArray - * @param bytes ByteArray object that data is read into - * @param offset Offset (position) in bytes. Read data should be written from this position - * @param length Byte number to be read Default value 0 indicates reading all available data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取 length 参数指定的数据字节数。从 offset 指定的位置开始,将字节读入 bytes 参数指定的 ByteArray 对象中,并将字节写入目标 ByteArray 中 - * @param bytes 要将数据读入的 ByteArray 对象 - * @param offset bytes 中的偏移(位置),应从该位置写入读取的数据 - * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readBytes(bytes: ByteArray, offset?: number, length?: number): void; - /** - * Read an IEEE 754 double-precision (64 bit) floating point number from the byte stream - * @return Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 双精度(64 位)浮点数 - * @return 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readDouble(): number; - /** - * Read an IEEE 754 single-precision (32 bit) floating point number from the byte stream - * @return Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 单精度(32 位)浮点数 - * @return 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readFloat(): number; - /** - * Read a 32-bit signed integer from the byte stream. - * @return A 32-bit signed integer ranging from -2147483648 to 2147483647 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 32 位整数 - * @return 介于 -2147483648 和 2147483647 之间的 32 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readInt(): number; - /** - * Read a 16-bit signed integer from the byte stream. - * @return A 16-bit signed integer ranging from -32768 to 32767 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 16 位整数 - * @return 介于 -32768 和 32767 之间的 16 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readShort(): number; - /** - * Read unsigned bytes from the byte stream. - * @return A unsigned integer ranging from 0 to 255 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取无符号的字节 - * @return 介于 0 和 255 之间的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedByte(): number; - /** - * Read a 32-bit unsigned integer from the byte stream. - * @return A 32-bit unsigned integer ranging from 0 to 4294967295 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 32 位整数 - * @return 介于 0 和 4294967295 之间的 32 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedInt(): number; - /** - * Read a 16-bit unsigned integer from the byte stream. - * @return A 16-bit unsigned integer ranging from 0 to 65535 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 16 位整数 - * @return 介于 0 和 65535 之间的 16 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedShort(): number; - /** - * Read a UTF-8 character string from the byte stream Assume that the prefix of the character string is a short unsigned integer (use byte to express length) - * @return UTF-8 character string - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 UTF-8 字符串。假定字符串的前缀是无符号的短整型(以字节表示长度) - * @return UTF-8 编码的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUTF(): string; - /** - * Read a UTF-8 byte sequence specified by the length parameter from the byte stream, and then return a character string - * @param Specify a short unsigned integer of the UTF-8 byte length - * @return A character string consists of UTF-8 bytes of the specified length - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个由 length 参数指定的 UTF-8 字节序列,并返回一个字符串 - * @param length 指明 UTF-8 字节长度的无符号短整型数 - * @return 由指定长度的 UTF-8 字节组成的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUTFBytes(length: number): string; - /** - * Write a Boolean value. A single byte is written according to the value parameter. If the value is true, write 1; if the value is false, write 0. - * @param value A Boolean value determining which byte is written. If the value is true, write 1; if the value is false, write 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 写入布尔值。根据 value 参数写入单个字节。如果为 true,则写入 1,如果为 false,则写入 0 - * @param value 确定写入哪个字节的布尔值。如果该参数为 true,则该方法写入 1;如果该参数为 false,则该方法写入 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeBoolean(value: boolean): void; - /** - * Write a byte into the byte stream - * The low 8 bits of the parameter are used. The high 24 bits are ignored. - * @param value A 32-bit integer. The low 8 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个字节 - * 使用参数的低 8 位。忽略高 24 位 - * @param value 一个 32 位整数。低 8 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeByte(value: number): void; - /** - * Write the byte sequence that includes length bytes in the specified byte array, bytes, (starting at the byte specified by offset, using a zero-based index), into the byte stream - * If the length parameter is omitted, the default length value 0 is used and the entire buffer starting at offset is written. If the offset parameter is also omitted, the entire buffer is written - * If the offset or length parameter is out of range, they are clamped to the beginning and end of the bytes array. - * @param bytes ByteArray Object - * @param offset A zero-based index specifying the position into the array to begin writing - * @param length An unsigned integer specifying how far into the buffer to write - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定字节数组 bytes(起始偏移量为 offset,从零开始的索引)中包含 length 个字节的字节序列写入字节流 - * 如果省略 length 参数,则使用默认长度 0;该方法将从 offset 开始写入整个缓冲区。如果还省略了 offset 参数,则写入整个缓冲区 - * 如果 offset 或 length 超出范围,它们将被锁定到 bytes 数组的开头和结尾 - * @param bytes ByteArray 对象 - * @param offset 从 0 开始的索引,表示在数组中开始写入的位置 - * @param length 一个无符号整数,表示在缓冲区中的写入范围 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeBytes(bytes: ByteArray, offset?: number, length?: number): void; - /** - * Write an IEEE 754 double-precision (64 bit) floating point number into the byte stream - * @param value Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 双精度(64 位)浮点数 - * @param value 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeDouble(value: number): void; - /** - * Write an IEEE 754 single-precision (32 bit) floating point number into the byte stream - * @param value Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 单精度(32 位)浮点数 - * @param value 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeFloat(value: number): void; - /** - * Write a 32-bit signed integer into the byte stream - * @param value An integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个带符号的 32 位整数 - * @param value 要写入字节流的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeInt(value: number): void; - /** - * Write a 16-bit integer into the byte stream. The low 16 bits of the parameter are used. The high 16 bits are ignored. - * @param value A 32-bit integer. Its low 16 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 16 位整数。使用参数的低 16 位。忽略高 16 位 - * @param value 32 位整数,该整数的低 16 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeShort(value: number): void; - /** - * Write a 32-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 32 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUnsignedInt(value: number): void; - /** - * Write a 16-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 16 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - writeUnsignedShort(value: number): void; - /** - * Write a UTF-8 string into the byte stream. The length of the UTF-8 string in bytes is written first, as a 16-bit integer, followed by the bytes representing the characters of the string - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。先写入以字节表示的 UTF-8 字符串长度(作为 16 位整数),然后写入表示字符串字符的字节 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUTF(value: string): void; - /** - * Write a UTF-8 string into the byte stream. Similar to the writeUTF() method, but the writeUTFBytes() method does not prefix the string with a 16-bit length word - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。类似于 writeUTF() 方法,但 writeUTFBytes() 不使用 16 位长度的词为字符串添加前缀 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUTFBytes(value: string): void; - /** - * - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - toString(): string; - /** - * @private - * 将 Uint8Array 写入字节流 - * @param bytes 要写入的Uint8Array - * @param validateBuffer - */ - _writeUint8Array(bytes: Uint8Array | ArrayLike, validateBuffer?: boolean): void; - /** - * @param len - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - validate(len: number): boolean; - /**********************/ - /**********************/ - /** - * @private - * @param len - * @param needReplace - */ - protected validateBuffer(len: number): void; - /** - * @private - * UTF-8 Encoding/Decoding - */ - private encodeUTF8(str); - /** - * @private - * - * @param data - * @returns - */ - private decodeUTF8(data); - /** - * @private - * - * @param code_point - */ - private encoderError(code_point); - /** - * @private - * - * @param fatal - * @param opt_code_point - * @returns - */ - private decoderError(fatal, opt_code_point?); - /** - * @private - */ - private EOF_byte; - /** - * @private - */ - private EOF_code_point; - /** - * @private - * - * @param a - * @param min - * @param max - */ - private inRange(a, min, max); - /** - * @private - * - * @param n - * @param d - */ - private div(n, d); - /** - * @private - * - * @param string - */ - private stringToCodePoints(string); - } -} -declare namespace egret { - /** - * The Sprite class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language en_US - */ - /** - * Sprite 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language zh_CN - */ - class Sprite extends DisplayObjectContainer { - /** - * Creates a new Sprite instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $graphics: Graphics; - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly graphics: Graphics; - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * Registers the runtime class information for a class.This method adds some strings which represent the class name or - * some interface names to the class definition. After the registration,you can use egret.is() method to do the type checking - * for the instance of this class.
- * Note:If you use the TypeScript programming language, the egret command line tool will automatically generate the registration code line. - * You don't need to manually call this method. - * - * @example the following code shows how to register the runtime class information for the EventDispatcher class and do the type checking: - *
-     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
-     *      let dispatcher = new egret.EventDispatcher();
-     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
-     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
-     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
-     * 
- * @param classDefinition the class definition to be registered. - * @param className a unique identification string of the specific class - * @param interfaceNames a list of unique identification string of the specific interfaces. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为一个类定义注册运行时类信息,用此方法往类定义上注册它自身以及所有接口对应的字符串。 - * 在运行时,这个类的实例将可以使用 egret.is() 方法传入一个字符串来判断实例类型。 - * @example 以下代码演示了如何为EventDispatcher类注册运行时类信息并判断类型: - *
-     *      //为egret.EventDispatcher类注册运行时类信息,由于它实现了IEventDispatcher接口,这里应同时传入接口名对应的字符串。
-     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
-     *      let dispatcher = new egret.EventDispatcher();
-     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
-     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
-     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
-     * 
- * 注意:若您使用 TypeScript 来编写程序,egret 命令行会自动帮您生成类信息注册代码行到最终的 Javascript 文件中。因此您不需要手动调用此方法。 - * - * @param classDefinition 要注册的类定义。 - * @param className 要注册的类名。 - * @param interfaceNames 要注册的类所实现的接口名列表。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function registerClass(classDefinition: any, className: string, interfaceNames?: string[]): void; -} -declare namespace egret { - /** - * The BitmapFillMode class defines the image fill mode of Bitmap. - * The BitmapFillMode class defines a pattern enumeration for adjusting size. These patterns determine how Bitmap fill the size designated by the layout system. - * @see http://edn.egret.com/cn/docs/page/134 Texture filling way - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language en_US - */ - /** - * BitmapFillMode 类定义Bitmap的图像填充方式。 - * BitmapFillMode 类定义了调整大小模式的一个枚举,这些模式确定 Bitmap 如何填充由布局系统指定的尺寸。 - * @see http://edn.egret.com/cn/docs/page/134 纹理的填充方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language zh_CN - */ - const BitmapFillMode: { - REPEAT: string; - SCALE: string; - CLIP: string; - }; -} -declare namespace egret { - /** - * Logger is an entrance for the log processing namespace of the engine - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Logger是引擎的日志处理模块入口 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class Logger { - /** - * open all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全开 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ALL: string; - /** - * level: DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static DEBUG: string; - /** - * level: INFO - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 INFO - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static INFO: string; - /** - * level: WARN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 WARN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static WARN: string; - /** - * level: ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ERROR: string; - /** - * close all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全关 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static OFF: string; - /** - * Set the current need to open the log level. Grade level are: ALL - * This feature is only in DEBUG mode to take effect.
- *
    - *
  • Logger.ALL - all levels of log can be printed out. - *
  • Logger.DEBUG - print debug, info, log, warn, error. - *
  • Logger.INFO - print info, log, warn, error. - *
  • Logger.WARN - can print warn, error. - *
  • Logger.ERROR - You can print error. - *
  • Logger.OFF - all closed. - * - *param LogType from this level to start printing. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置当前需要开启的log级别。级别等级分别为:ALL < DEBUG < INFO < WARN < ERROR < OFF
    - * 此功能只在 DEBUG 模式下才生效。
    - *
      - *
    • Logger.ALL -- 所有等级的log都可以打印出来。
    • - *
    • Logger.DEBUG -- 可以打印debug、info、log、warn、error。
    • - *
    • Logger.INFO -- 可以打印info、log、warn、error。
    • - *
    • Logger.WARN -- 可以打印warn、error。
    • - *
    • Logger.ERROR -- 可以打印error。
    • - *
    • Logger.OFF -- 全部关闭。
    • - *
    - * @param logType 从这个等级开始打印。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static logLevel: string; - } -} -declare namespace egret { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - class NumberUtils { - /** - * Judge whether it is a numerical value - * @param value Parameter that needs to be judged - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 判断是否是数值 - * @param value 需要判断的参数 - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static isNumber(value: any): boolean; - /** - * Obtain the approximate sin value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} sin value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 得到对应角度值的sin近似值 - * @param value {number} 角度值 - * @returns {number} sin值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sin(value: number): number; - /** - * @private - * - * @param value - * @returns - */ - private static sinInt(value); - /** - * Obtain the approximate cos value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} cos value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 得到对应角度值的cos近似值 - * @param value {number} 角度值 - * @returns {number} cos值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cos(value: number): number; - /** - * @private - * - * @param value - * @returns - */ - private static cosInt(value); - static convertStringToHashCode(str: string): number; - } -} -/** - * @private - */ -declare let egret_sin_map: {}; -/** - * @private - */ -declare let egret_cos_map: {}; -/** - * @private - */ -declare let DEG_TO_RAD: number; -declare namespace egret { - /** - * The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the start() - * method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.
    - * You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. Depending - * on the framerate or the runtime environment (available memory and other factors), the runtime may dispatchEvent events at - * slightly offset intervals. - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - * @language en_US - */ - /** - * Timer 类是计时器的接口,它使您能按指定的时间序列运行代码。 - * 使用 start() 方法来启动计时器。为 timer 事件添加事件侦听器,以便将代码设置为按计时器间隔运行。 - * 可以创建 Timer 对象以运行一次或按指定间隔重复运行,从而按计划执行代码。 - * 根据 Egret 的帧速率或运行时环境(可用内存和其他因素),运行时调度事件的间隔可能稍有不同。 - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - * @language zh_CN - */ - class Timer extends EventDispatcher { - /** - * Constructs a new Timer object with the specified delay and repeatCount states. - * @param delay The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended. - * Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @param repeatCount Specifies the number of repetitions. If zero, the timer repeats indefinitely.If nonzero, - * the timer runs the specified number of times and then stops. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 delay 和 repeatCount 状态构造新的 Timer 对象。 - * @param delay 计时器事件间的延迟(以毫秒为单位)。建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @param repeatCount 指定重复次数。如果为零,则计时器将持续不断重复运行。如果不为 0,则将运行计时器,运行次数为指定的次数,然后停止。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(delay: number, repeatCount?: number); - /** - * @private - */ - private _delay; - /** - * The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended.
    - * Note: Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器事件间的延迟(以毫秒为单位)。如果在计时器正在运行时设置延迟间隔,则计时器将按相同的 repeatCount 迭代重新启动。
    - * 注意:建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - delay: number; - /** - * The total number of times the timer is set to run. If the repeat count is set to 0, the timer continues indefinitely, - * until the stop() method is invoked or the program stops. If the repeat count is nonzero, the timer runs the specified - * number of times. If repeatCount is set to a total that is the same or less then currentCount the timer stops and will not fire again. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置的计时器运行总次数。如果重复计数设置为 0,则计时器将持续不断运行,或直至调用了 stop() 方法或节目停止。 - * 如果重复计数不为 0,则将运行计时器,运行次数为指定的次数。如果设置的 repeatCount 总数等于或小于 currentCount,则计时器将停止并且不会再次触发。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - repeatCount: number; - /** - * @private - */ - private _currentCount; - /** - * The total number of times the timer has fired since it started at zero. If the timer has been reset, only the fires since the reset are counted. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器从 0 开始后触发的总次数。如果已重置了计时器,则只会计入重置后的触发次数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly currentCount: number; - /** - * @private - */ - private _running; - /** - * The timer's current state; true if the timer is running, otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器的当前状态;如果计时器正在运行,则为 true,否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly running: boolean; - /** - * Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch. - * Then, when start() is called, the timer instance runs for the specified number of repetitions, as set by the repeatCount value. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果计时器正在运行,则停止计时器,并将 currentCount 属性设回为 0,这类似于秒表的重置按钮。然后,在调用 start() 后,将运行计时器实例,运行次数为指定的重复次数(由 repeatCount 值设置)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - reset(): void; - /** - * Starts the timer, if it is not already running. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果计时器尚未运行,则启动计时器。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - start(): void; - /** - * Stops the timer. When start() is called after stop(), the timer instance runs for the remaining number of - * repetitions, as set by the repeatCount property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止计时器。如果在调用 stop() 后调用 start(),则将继续运行计时器实例,运行次数为剩余的 重复次数(由 repeatCount 属性设置)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - /** - * @private - */ - private updateInterval; - /** - * @private - */ - private lastCount; - /** - * @private - */ - private lastTimeStamp; - /** - * @private - * Ticker以60FPS频率刷新此方法 - */ - $update(timeStamp: number): boolean; - } -} -declare namespace egret { - /** - * The XMLNode class is the base class for all xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * XML节点基类 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface XMLNode { - /** - * a integer representing the type of the node, 1:XML,2:XMLAttribute,3:XMLText - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点类型,1:XML,2:XMLAttribute,3:XMLText - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - nodeType: number; - /** - * the parent node of this xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点所属的父级节点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - parent: XML; - } - /** - * The XML class contains properties for working with XML objects. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/XML.ts - * @language en_US - */ - /** - * XML 类包含用于处理 XML 对象的属性。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/XML.ts - * @language zh_CN - */ - interface XML extends XMLNode { - /** - * the attributes of this xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前节点上的属性列表 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - attributes: any; - /** - * the children of the xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前节点的子节点列表 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - children: XMLNode[]; - /** - * the full name of this xml node. For example,the name of is "s:Button". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点完整名称。例如节点 的 name 为:"s:Button" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * thie namesapce prefix of this xml node.For example,the prefix of is "s". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点的命名空间前缀。例如节点 的 prefix 为:s - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - prefix: string; - /** - * the local name of this xml node. For example,the local name of is "Button". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点的本地名称。例如节点 的 localName 为:Button - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - localName: string; - /** - * the namesapce uri of this xml node.For example,the namespace uri of is "http://ns.egret.com/eui". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点的命名空间地址。例如节点 的 namespace 为: http://ns.egret.com/eui - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace: string; - } - /** - * The XMLText class represents a string node in the XML. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * XMLText 类表示在XML中的文本节点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface XMLText extends XMLNode { - /** - * the text content - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - } - /** - * The XML class contains properties for working with XML objects. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * XML 类包含用于处理 XML 对象的属性。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let XML: { - /** - * parses a text to XML instance. - * @param text the text to be parsed. - * @language en_US - */ - /** - * 解析字符串为XML对象 - * @param text 要解析的XML对象。 - * @language zh_CN - */ - parse(text: string): XML; - }; -} -declare namespace egret { - /** - * @private - */ - let $callLaterFunctionList: any[]; - /** - * @private - */ - let $callLaterThisList: any[]; - /** - * @private - */ - let $callLaterArgsList: any[]; - /** - * Delay the function to run unless screen is redrawn. - * @param method {Function} The function to be delayed to run - * @param thisObject {any} this reference of callback function - * @param ...args {any} Function parameter list - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - * @language en_US - */ - /** - * 延迟函数到屏幕重绘前执行。 - * @param method {Function} 要延迟执行的函数 - * @param thisObject {any} 回调函数的this引用 - * @param ...args {any} 函数参数列表 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - * @language zh_CN - */ - function callLater(method: Function, thisObject: any, ...args: any[]): void; - /** - * @private - */ - let $callAsyncFunctionList: any[]; - /** - * @private - */ - let $callAsyncThisList: any[]; - /** - * @private - */ - let $callAsyncArgsList: any[]; - /** - * 异步调用函数 - * @param method {Function} 要异步调用的函数 - * @param thisObject {any} 函数的this引用 - * @param ...args {any} 函数参数列表 - * @private - */ - function $callAsync(method: Function, thisObject: any, ...args: any[]): void; -} -declare namespace egret { - /** - * Call setter properties of the parent class, instead of the other writing languages, such as super.alpha = 1; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @param values Value passed to the parent class - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - * @language en_US - */ - /** - * 调用父类的setter属性,代替其他语言的写法,如 super.alpha = 1; - * @param currentClass 当前 class 类名,非字符串 - * @param thisObj 当前对象。永远都this - * @param type 需要调用的setter属性名称 - * @param values 传给父类的值 - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - * @language zh_CN - */ - function superSetter(currentClass: any, thisObj: any, type: string, ...values: any[]): any; - /** - * Get getter property value of the parent class. Instead of writing in other languages, such as super.alpha; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @returns {any} The value returned by the parent - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - * @language en_US - */ - /** - * 获取父类的getter属性值。代替其他语言的写法,如 super.alpha; - * @param currentClass 当前 class 类名,非字符串 - * @param thisObj 当前对象。永远都this - * @param type 需要调用的getter属性名称 - * @returns {any} 父类返回的值 - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - * @language zh_CN - */ - function superGetter(currentClass: any, thisObj: any, type: string): any; -} -declare namespace egret { - /** - * Returns a reference to the class object of the class specified by the name parameter. - * @param name The name of a class. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - * @language en_US - */ - /** - * 返回 name 参数指定的类的类对象引用。 - * @param name 类的名称。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - * @language zh_CN - */ - function getDefinitionByName(name: string): any; -} -declare namespace egret { - /** - * Get browser or Runtime parameters, returns an empty string if not set - * Get the url parameter corresponds to the browser, access to the corresponding parameter in the Runtime setOption - * @method egret.getOption - * @param key {string} Parameters key - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取浏览器或者Runtime参数,如果没有设置返回空字符串 - * 在浏览器中相当于获取url中参数,在Runtime获取对应setOption参数 - * @method egret.getOption - * @param key {string} 参数key - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let getOption: (key: string) => string; -} -declare namespace egret { - /** - * Return the fully qualified class name of an object - * @param value The object for which a fully qualified class name is desired. Any JavaScript value may be passed to - * this method including all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A string containing the fully qualified class name. - * @example - *
    -     *  egret.getQualifiedClassName(egret.DisplayObject) //return "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - * @language en_US - */ - /** - * 返回对象的完全限定类名。 - * @param value 需要完全限定类名称的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型 - * (如number)和类对象 - * @returns 包含完全限定类名称的字符串。 - * @example - *
    -     *  egret.getQualifiedClassName(egret.DisplayObject) //返回 "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - * @language zh_CN - */ - function getQualifiedClassName(value: any): string; -} -declare namespace egret { - /** - * Returns the fully qualified class name of the base class of the object specified by the value parameter. - * @param value The object for which a parent class is desired. Any JavaScript value may be passed to this method including - * all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A fully qualified base class name, or null if none exists. - * @example - *
    -     *  egret.getQualifiedSuperclassName(egret.Bitmap) //return "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts - * @language en_US - */ - /** - * 返回 value 参数指定的对象的基类的完全限定类名。 - * @param value 需要取得父类的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型(如number)和类对象 - * @returns 完全限定的基类名称,或 null(如果不存在基类名称)。 - * @example - *
    -     *  egret.getQualifiedSuperclassName(egret.Sprite) //返回 "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts - * @language zh_CN - */ - function getQualifiedSuperclassName(value: any): string; -} -declare namespace egret { - /** - * Used to compute relative time.this method returns the number of milliseconds since the Egret framework was initialized - * @returns The number of milliseconds since the Egret framework was initialized - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getTimer.ts - * @language en_US - */ - /** - * 用于计算相对时间。此方法返回自启动 Egret 框架以来经过的毫秒数。 - * @returns 启动 Egret 框架以来经过的毫秒数。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getTimer.ts - * @language zh_CN - */ - function getTimer(): number; -} -declare namespace egret { - /** - * Check whether a public definition exists in the specified application domain. The definition can be that of a class, a naming space or a function. - * @param name {string} Name of the definition. - * @returns {boolean} Whether the public definition exists - * @example - * egret.hasDefinition("egret.DisplayObject") //return true - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts - * @language en_US - */ - /** - * 检查指定的应用程序域之内是否存在一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。 - * @param name {string} 定义的名称。 - * @returns {boolean} 公共定义是否存在 - * @example - * egret.hasDefinition("egret.DisplayObject") //返回 true - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts - * @language zh_CN - */ - function hasDefinition(name: string): boolean; -} -declare namespace egret { - /** - * Indicates whether an object is a instance of the class or interface specified as the parameter.This method has better performance - * compared width the instanceOf operator,and it can indicate whether an object is a instance of the specific interface. - * @param instance the instance to be checked. - * @param typeName the string value representing a specific class or interface. - * @returns A value of true if the object is a instance of the class or interface specified as the parameter. - * @example - *
    -     *     let instance = new egret.Sprite();
    -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
    -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
    -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
    -     * 
    - * @see egret.registerClass() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查指定对象是否为 Egret 框架内指定接口或类或其子类的实例。此方法与使用 instanceOf 关键字相比具有更高的性能,并且能判断接口的实现。 - * @param instance 要判断的实例。 - * @param typeName 类或接口的完全名称. - * @returns 返回true表示当前对象是指定类或接口的实例。 - * @example - *
    -     *     let instance = new egret.Sprite();
    -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
    -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
    -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
    -     * 
    - * @see egret.registerClass() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function is(instance: any, typeName: string): boolean; -} -declare namespace egret { - /** - * Register and start a timer,which will notify the callback method at a rate of 60 FPS ,and pass the current time stamp as parameters.
    - * Note: After the registration,it will notify the callback method continuously,you can call the stopTick () method to stop it. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 注册并启动一个计时器,通常会以60FPS的速率触发回调方法,并传入当前时间戳。注意:注册后将会持续触发回调方法,若要停止回调,需要手动调用stopTick()方法。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function startTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; -} -declare namespace egret { - /** - * Stops the timer started by the egret.startTick() method. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止之前用 startTick() 方法启动的计时器。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function stopTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; -} -declare namespace egret { - /** - * Transfer number to color character string - * @param value {number} color value ,such as 0xffffff - * @returns {string} Color character string, for example, #ffffff. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/toColorString.ts - * @language en_US - */ - /** - * 转换数字为颜色字符串 - * @param value {number} 颜色值,例如 0xffffff - * @returns {string} 颜色字符串,例如"#ffffff"。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/toColorString.ts - * @language zh_CN - */ - function toColorString(value: number): string; -} -/** - * @private - */ -interface PlayerOption { - /** - * 入口类完整类名 - */ - entryClassName?: string; - /** - * 默认帧率 - */ - frameRate?: number; - /** - * 屏幕适配模式 - */ - scaleMode?: string; - /** - * 初始内容宽度 - */ - contentWidth?: number; - /** - * 初始内容高度 - */ - contentHeight?: number; - /** - * 屏幕方向 - */ - orientation?: string; - /** - * 显示FPS - */ - showFPS?: boolean; - /** - * - */ - fpsStyles?: Object; - /** - * 显示日志 - */ - showLog?: boolean; - /** - * 过滤日志的正则表达式 - */ - logFilter?: string; - /** - * - */ - maxTouches?: number; - /** - * - */ - textureScaleFactor?: number; -} diff --git a/demo/libs/modules/egret/egret.js b/demo/libs/modules/egret/egret.js deleted file mode 100644 index e9be5d65..00000000 --- a/demo/libs/modules/egret/egret.js +++ /dev/null @@ -1,25845 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -if (typeof global == 'undefined') { - var global = window; -} -if (typeof __global == 'undefined') { - var __global = global; -} -var __define = this && this.__define || function (o, p, g, s) { Object.defineProperty(o, p, { configurable: true, enumerable: true, get: g, set: s }); }; -var egret; -(function (egret) { - /** - * @private - * 哈希计数 - */ - egret.$hashCount = 1; - /** - * The HashObject class is the base class for all objects in the Egret framework.The HashObject - * class includes a hashCode property, which is a unique identification number of the instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Egret顶级对象。框架内所有对象的基类,为对象实例提供唯一的hashCode值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var HashObject = (function () { - /** - * Initializes a HashObject - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 HashObject 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function HashObject() { - this.$hashCode = egret.$hashCount++; - } - Object.defineProperty(HashObject.prototype, "hashCode", { - /** - * a unique identification number assigned to this instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此对象唯一的哈希值,用于唯一确定一个对象。hashCode为大于等于1的整数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$hashCode; - }, - enumerable: true, - configurable: true - }); - return HashObject; - }()); - egret.HashObject = HashObject; - __reflect(HashObject.prototype, "egret.HashObject", ["egret.IHashObject"]); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var ONCE_EVENT_LIST = []; - /** - * The EventDispatcher class is the base class for all classes that dispatchEvent events. The EventDispatcher class implements - * the IEventDispatcher interface and is the base class for the DisplayObject class. The EventDispatcher class allows - * any object on the display list to be an event target and as such, to use the methods of the IEventDispatcher interface. - * Event targets are an important part of the Egret event model. The event target serves as the focal point for how events - * flow through the display list hierarchy. When an event such as a touch tap, Egret dispatches an event object into the - * event flow from the root of the display list. The event object then makes its way through the display list until it - * reaches the event target, at which point it begins its return trip through the display list. This round-trip journey - * to the event target is conceptually divided into three phases:
    - * the capture phase comprises the journey from the root to the last node before the event target's node, the target - * phase comprises only the event target node, and the bubbling phase comprises any subsequent nodes encountered on - * the return trip to the root of the display list. In general, the easiest way for a user-defined class to gain event - * dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already extending - * another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, and write simple - * hooks to route calls into the aggregated EventDispatcher. - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language en_US - */ - /** - * EventDispatcher 是 Egret 的事件派发器类,负责进行事件的发送和侦听。 - * 事件目标是事件如何通过显示列表层次结构这一问题的焦点。当发生鼠标单击、触摸或按键等事件时, - * 框架会将事件对象调度到从显示列表根开始的事件流中。然后该事件对象在显示列表中前进,直到到达事件目标, - * 然后从这一点开始其在显示列表中的回程。在概念上,到事件目标的此往返行程被划分为三个阶段: - * 捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括回程上遇到的任何后续节点到显示列表的根。 - * 通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。如果无法扩展(即,如果该类已经扩展了另一个类),则可以实现 - * IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的映射,将调用连接到聚合的 EventDispatcher 中。 - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language zh_CN - */ - var EventDispatcher = (function (_super) { - __extends(EventDispatcher, _super); - /** - * create an instance of the EventDispatcher class. - * @param target The target object for events dispatched to the EventDispatcher object. This parameter is used when - * the EventDispatcher instance is aggregated by a class that implements IEventDispatcher; it is necessary so that the - * containing object can be the target for events. Do not use this parameter in simple cases in which a class extends EventDispatcher. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 EventDispatcher 类的实例 - * @param target 此 EventDispatcher 所抛出事件对象的 target 指向。此参数主要用于一个实现了 IEventDispatcher 接口的自定义类, - * 以便抛出的事件对象的 target 属性可以指向自定义类自身。请勿在直接继承 EventDispatcher 的情况下使用此参数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function EventDispatcher(target) { - if (target === void 0) { target = null; } - var _this = _super.call(this) || this; - _this.$EventDispatcher = { - 0: target ? target : _this, - 1: {}, - 2: {}, - 3: 0 - }; - return _this; - } - /** - * @private - * - * @param useCapture - */ - EventDispatcher.prototype.$getEventMap = function (useCapture) { - var values = this.$EventDispatcher; - var eventMap = useCapture ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */]; - return eventMap; - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.addEventListener = function (type, listener, thisObject, useCapture, priority) { - this.$addListener(type, listener, thisObject, useCapture, priority); - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.once = function (type, listener, thisObject, useCapture, priority) { - this.$addListener(type, listener, thisObject, useCapture, priority, true); - }; - /** - * @private - */ - EventDispatcher.prototype.$addListener = function (type, listener, thisObject, useCapture, priority, dispatchOnce) { - if (true && !listener) { - egret.$error(1003, "listener"); - } - var values = this.$EventDispatcher; - var eventMap = useCapture ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */]; - var list = eventMap[type]; - if (!list) { - list = eventMap[type] = []; - } - else if (values[3 /* notifyLevel */] !== 0) { - eventMap[type] = list = list.concat(); - } - this.$insertEventBin(list, type, listener, thisObject, useCapture, priority, dispatchOnce); - }; - EventDispatcher.prototype.$insertEventBin = function (list, type, listener, thisObject, useCapture, priority, dispatchOnce) { - priority = +priority | 0; - var insertIndex = -1; - var length = list.length; - for (var i = 0; i < length; i++) { - var bin = list[i]; - if (bin.listener == listener && bin.thisObject == thisObject && bin.target == this) { - return false; - } - if (insertIndex == -1 && bin.priority < priority) { - insertIndex = i; - } - } - var eventBin = { - type: type, listener: listener, thisObject: thisObject, priority: priority, - target: this, useCapture: useCapture, dispatchOnce: !!dispatchOnce - }; - if (insertIndex !== -1) { - list.splice(insertIndex, 0, eventBin); - } - else { - list.push(eventBin); - } - return true; - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.removeEventListener = function (type, listener, thisObject, useCapture) { - var values = this.$EventDispatcher; - var eventMap = useCapture ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */]; - var list = eventMap[type]; - if (!list) { - return; - } - if (values[3 /* notifyLevel */] !== 0) { - eventMap[type] = list = list.concat(); - } - this.$removeEventBin(list, listener, thisObject); - if (list.length == 0) { - eventMap[type] = null; - } - }; - EventDispatcher.prototype.$removeEventBin = function (list, listener, thisObject) { - var length = list.length; - for (var i = 0; i < length; i++) { - var bin = list[i]; - if (bin.listener == listener && bin.thisObject == thisObject && bin.target == this) { - list.splice(i, 1); - return true; - } - } - return false; - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.hasEventListener = function (type) { - var values = this.$EventDispatcher; - return !!(values[1 /* eventsMap */][type] || values[2 /* captureEventsMap */][type]); - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.willTrigger = function (type) { - return this.hasEventListener(type); - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - EventDispatcher.prototype.dispatchEvent = function (event) { - event.$currentTarget = this.$EventDispatcher[0 /* eventTarget */]; - event.$setTarget(event.$currentTarget); - return this.$notifyListener(event, false); - }; - /** - * @private - */ - EventDispatcher.prototype.$notifyListener = function (event, capturePhase) { - var values = this.$EventDispatcher; - var eventMap = capturePhase ? values[2 /* captureEventsMap */] : values[1 /* eventsMap */]; - var list = eventMap[event.$type]; - if (!list) { - return true; - } - var length = list.length; - if (length == 0) { - return true; - } - var onceList = ONCE_EVENT_LIST; - //做个标记,防止外部修改原始数组导致遍历错误。这里不直接调用list.concat()因为dispatch()方法调用通常比on()等方法频繁。 - values[3 /* notifyLevel */]++; - for (var i = 0; i < length; i++) { - var eventBin = list[i]; - eventBin.listener.call(eventBin.thisObject, event); - if (eventBin.dispatchOnce) { - onceList.push(eventBin); - } - if (event.$isPropagationImmediateStopped) { - break; - } - } - values[3 /* notifyLevel */]--; - while (onceList.length) { - var eventBin = onceList.pop(); - eventBin.target.removeEventListener(eventBin.type, eventBin.listener, eventBin.thisObject, eventBin.useCapture); - } - return !event.$isDefaultPrevented; - }; - /** - * Distribute a specified event parameters. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个指定参数的事件。 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - EventDispatcher.prototype.dispatchEventWith = function (type, bubbles, data, cancelable) { - if (bubbles || this.hasEventListener(type)) { - var event_1 = egret.Event.create(egret.Event, type, bubbles, cancelable); - event_1.data = data; - var result = this.dispatchEvent(event_1); - egret.Event.release(event_1); - return result; - } - return true; - }; - return EventDispatcher; - }(egret.HashObject)); - egret.EventDispatcher = EventDispatcher; - __reflect(EventDispatcher.prototype, "egret.EventDispatcher", ["egret.IEventDispatcher"]); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - var Filter = (function (_super) { - __extends(Filter, _super); - function Filter() { - var _this = _super.call(this) || this; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - _this.type = null; - /** - * @private - */ - _this.$id = null; - /** - * @private - */ - _this.paddingTop = 0; - /** - * @private - */ - _this.paddingBottom = 0; - /** - * @private - */ - _this.paddingLeft = 0; - /** - * @private - */ - _this.paddingRight = 0; - _this.$uniforms = {}; - if (egret.nativeRender) { - egret_native.NativeDisplayObject.createFilter(_this); - } - return _this; - } - /** - * @private - */ - Filter.prototype.$toJson = function () { - return ''; - }; - Filter.prototype.updatePadding = function () { - }; - Filter.prototype.onPropertyChange = function () { - var self = this; - self.updatePadding(); - if (egret.nativeRender) { - egret_native.NativeDisplayObject.setFilterPadding(self.$id, self.paddingTop, self.paddingBottom, self.paddingLeft, self.paddingRight); - egret_native.NativeDisplayObject.setDataToFilter(self); - } - }; - return Filter; - }(egret.HashObject)); - egret.Filter = Filter; - __reflect(Filter.prototype, "egret.Filter"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - ; - /** - * @private - * 格式化旋转角度的值 - */ - function clampRotation(value) { - value %= 360; - if (value > 180) { - value -= 360; - } - else if (value < -180) { - value += 360; - } - return value; - } - /** - * The DisplayObject class is the base class for all objects that can be placed on the display list. The display list - * manages all objects displayed in the runtime. Use the DisplayObjectContainer class to arrange the display - * objects in the display list. DisplayObjectContainer objects can have child display objects, while other display objects, - * such as Shape and TextField objects, are "leaf" nodes that have only parents and siblings, no children. - * The DisplayObject class supports basic functionality like the x and y position of an object, as well as more advanced - * properties of the object such as its transformation matrix.
    - * The DisplayObject class contains several broadcast events.Normally, the target of any particular event is a specific - * DisplayObject instance. For example, the target of an added event is the specific DisplayObject instance that was added - * to the display list. Having a single target restricts the placement of event listeners to that target and in some cases - * the target's ancestors on the display list. With broadcast events, however, the target is not a specific DisplayObject - * instance, but rather all DisplayObject instances, including those that are not on the display list. This means that you - * can add a listener to any DisplayObject instance to listen for broadcast events. - * - * @event egret.Event.ADDED Dispatched when a display object is added to the display list. - * @event egret.Event.ADDED_TO_STAGE Dispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained. - * @event egret.Event.REMOVED Dispatched when a display object is about to be removed from the display list. - * @event egret.Event.REMOVED_FROM_STAGE Dispatched when a display object is about to be removed from the display list, either directly or through the removal of a sub tree in which the display object is contained. - * @event egret.Event.ENTER_FRAME [broadcast event] Dispatched when the playhead is entering a new frame. - * @event egret.Event.RENDER [broadcast event] Dispatched when the display list is about to be updated and rendered. - * @event egret.TouchEvent.TOUCH_MOVE Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @event egret.TouchEvent.TOUCH_BEGIN Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_END Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_TAP Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language en_US - */ - /** - * DisplayObject 类是可放在显示列表中的所有对象的基类。该显示列表管理运行时中显示的所有对象。使用 DisplayObjectContainer 类排列 - * 显示列表中的显示对象。DisplayObjectContainer 对象可以有子显示对象,而其他显示对象(如 Shape 和 TextField 对象)是“叶”节点,没有子项,只有父级和 - * 同级。DisplayObject 类有一些基本的属性(如确定坐标位置的 x 和 y 属性),也有一些高级的对象属性(如 Matrix 矩阵变换)。
    - * DisplayObject 类包含若干广播事件。通常,任何特定事件的目标均为一个特定的 DisplayObject 实例。例如,added 事件的目标是已添加到显示列表 - * 的目标 DisplayObject 实例。若只有一个目标,则会将事件侦听器限制为只能监听在该目标上(在某些情况下,可监听在显示列表中该目标的祖代上)。 - * 但是对于广播事件,目标不是特定的 DisplayObject 实例,而是所有 DisplayObject 实例(包括那些不在显示列表中的实例)。这意味着您可以向任何 - * DisplayObject 实例添加侦听器来侦听广播事件。 - * - * @event egret.Event.ADDED 将显示对象添加到显示列表中时调度。 - * @event egret.Event.ADDED_TO_STAGE 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @event egret.Event.REMOVED 将要从显示列表中删除显示对象时调度。 - * @event egret.Event.REMOVED_FROM_STAGE 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @event egret.Event.ENTER_FRAME [广播事件] 播放头进入新帧时调度。 - * @event egret.Event.RENDER [广播事件] 将要更新和呈现显示列表时调度。 - * @event egret.TouchEvent.TOUCH_MOVE 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @event egret.TouchEvent.TOUCH_BEGIN 当用户第一次触摸启用触摸的设备时(例如,用手指触摸手机屏幕)调度。 - * @event egret.TouchEvent.TOUCH_END 当用户移除与启用触摸的设备的接触时(例如,将手指从屏幕上抬起)调度。 - * @event egret.TouchEvent.TOUCH_TAP 当用户在启用触摸设备上的已启动接触的同一 DisplayObject 实例上抬起接触点时(例如,手机点击屏幕后抬起)调度。 - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE 当用户在启用触摸设备上的已启动接触的不同 DisplayObject 实例上抬起接触点时(例如,按住屏幕上的某个对象,然后从它上面挪开后再松开手指)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language zh_CN - */ - var DisplayObject = (function (_super) { - __extends(DisplayObject, _super); - /** - * Initializes a DisplayObject object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个显示对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function DisplayObject() { - var _this = _super.call(this) || this; - /** - * @private - * 能够含有子项的类将子项列表存储在这个属性里。 - */ - _this.$children = null; - _this.$name = ""; - /** - * @private - */ - _this.$parent = null; - /** - * @private - */ - _this.$stage = null; - /** - * @private - * 这个对象在显示列表中的嵌套深度,舞台为1,它的子项为2,子项的子项为3,以此类推。当对象不在显示列表中时此属性值为0. - */ - _this.$nestLevel = 0; - _this.$useTranslate = false; - _this.$matrix = new egret.Matrix(); - _this.$matrixDirty = false; - _this.$x = 0; - _this.$y = 0; - _this.$scaleX = 1; - _this.$scaleY = 1; - _this.$rotation = 0; - _this.$skewX = 0; - _this.$skewXdeg = 0; - _this.$skewY = 0; - _this.$skewYdeg = 0; - _this.$explicitWidth = NaN; - _this.$explicitHeight = NaN; - _this.$anchorOffsetX = 0; - _this.$anchorOffsetY = 0; - /** - * @private - */ - _this.$visible = true; - /** - * @private - * cacheAsBitmap创建的缓存位图节点。 - */ - _this.$displayList = null; - _this.$cacheAsBitmap = false; - _this.$cacheDirty = false; - /** - * @private - */ - _this.$alpha = 1; - _this.$touchEnabled = DisplayObject.defaultTouchEnabled; - /** - * @private - */ - _this.$scrollRect = null; - /** - * @private - */ - _this.$blendMode = 0; - /** - * @private - * 被遮罩的对象 - */ - _this.$maskedObject = null; - /** - * @private - */ - _this.$mask = null; - /** - * @private - */ - _this.$maskRect = null; - /** - * @private - */ - _this.$parentDisplayList = null; - /** - * @private - * 渲染节点,不为空表示自身有绘制到屏幕的内容 - */ - _this.$renderNode = null; - _this.$renderDirty = false; - _this.$renderMode = null; - /** - * inspired by pixi.js - */ - _this._tint = 0; - /** - * @private - */ - _this.$tintRGB = 0; - /** - * @private - * inspired by pixi.js - */ - _this.$sortDirty = false; - /** - * @private - */ - _this._zIndex = 0; - /** - * @private - */ - _this.$lastSortedIndex = 0; - /** - * Allow objects to use zIndex sorting - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 允许对象使用 zIndex 排序 - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - _this.sortableChildren = false; - if (egret.nativeRender) { - _this.createNativeDisplayObject(); - } - //默认都是纯白 - _this.tint = 0xFFFFFF; - return _this; - } - DisplayObject.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(0 /* CONTAINER */); - }; - Object.defineProperty(DisplayObject.prototype, "name", { - /** - * Indicates the instance name of the DisplayObject. The object can be identified in the child list of its parent - * display object container by calling the getChildByName() method of the display object container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 的实例名称。 - * 通过调用父显示对象容器的 getChildByName() 方法,可以在父显示对象容器的子列表中标识该对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$name; - }, - set: function (value) { - this.$name = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "parent", { - /** - * Indicates the DisplayObjectContainer object that contains this display object. Use the parent property to specify - * a relative path to display objects that are above the current display object in the display list hierarchy. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示包含此显示对象的 DisplayObjectContainer 对象。 - * 使用 parent 属性可以指定高于显示列表层次结构中当前显示对象的显示对象的相对路径。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$parent; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 设置父级显示对象 - */ - DisplayObject.prototype.$setParent = function (parent) { - this.$parent = parent; - }; - /** - * @private - * 显示对象添加到舞台 - */ - DisplayObject.prototype.$onAddToStage = function (stage, nestLevel) { - var self = this; - self.$stage = stage; - self.$nestLevel = nestLevel; - self.$hasAddToStage = true; - egret.Sprite.$EVENT_ADD_TO_STAGE_LIST.push(self); - }; - /** - * @private - * 显示对象从舞台移除 - */ - DisplayObject.prototype.$onRemoveFromStage = function () { - var self = this; - self.$nestLevel = 0; - egret.Sprite.$EVENT_REMOVE_FROM_STAGE_LIST.push(self); - }; - DisplayObject.prototype.$updateUseTransform = function () { - var self = this; - if (self.$scaleX == 1 && self.$scaleY == 1 && self.$skewX == 0 && self.$skewY == 0) { - self.$useTranslate = false; - } - else { - self.$useTranslate = true; - } - }; - Object.defineProperty(DisplayObject.prototype, "stage", { - /** - * The Stage of the display object. you can create and load multiple display objects into the display list, and - * the stage property of each display object refers to the same Stage object.
    - * If a display object is not added to the display list, its stage property is set to null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的舞台。 - * 例如,您可以创建多个显示对象并加载到显示列表中,每个显示对象的 stage 属性是指向相同的 Stage 对象。
    - * 如果显示对象未添加到显示列表,则其 stage 属性会设置为 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$stage; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "matrix", { - /** - * A Matrix object containing values that alter the scaling, rotation, and translation of the display object.
    - * Note: to change the value of a display object's matrix, you must make a copy of the entire matrix object, then copy - * the new object into the matrix property of the display object. - * @example the following code increases the tx value of a display object's matrix - *
    -             *     let myMatrix:Matrix = myDisplayObject.matrix;
    -             *     myMatrix.tx += 10;
    -             *     myDisplayObject.matrix = myMatrix;
    -             * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个 Matrix 对象,其中包含更改显示对象的缩放、旋转和平移的值。
    - * 注意:要改变一个显示对象矩阵的值,您必引用整个矩阵对象,然后将它重新赋值给显示对象的 matrix 属性。 - * @example 以下代码改变了显示对象矩阵的tx属性值: - *
    -             *     let myMatrix:Matrix = myDisplayObject.matrix;
    -             *     myMatrix.tx += 10;
    -             *     myDisplayObject.matrix = myMatrix;
    -             * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getMatrix().clone(); - }, - set: function (value) { - this.$setMatrix(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 获取矩阵 - */ - DisplayObject.prototype.$getMatrix = function () { - var self = this; - if (self.$matrixDirty) { - self.$matrixDirty = false; - self.$matrix.$updateScaleAndRotation(self.$scaleX, self.$scaleY, self.$skewX, self.$skewY); - } - self.$matrix.tx = self.$x; - self.$matrix.ty = self.$y; - return self.$matrix; - }; - /** - * @private - * 设置矩阵 - */ - DisplayObject.prototype.$setMatrix = function (matrix, needUpdateProperties) { - if (needUpdateProperties === void 0) { needUpdateProperties = true; } - var self = this; - var m = self.$matrix; - m.a = matrix.a; - m.b = matrix.b; - m.c = matrix.c; - m.d = matrix.d; - self.$x = matrix.tx; - self.$y = matrix.ty; - self.$matrixDirty = false; - if (m.a == 1 && m.b == 0 && m.c == 0 && m.d == 1) { - self.$useTranslate = false; - } - else { - self.$useTranslate = true; - } - if (needUpdateProperties) { - self.$scaleX = m.$getScaleX(); - self.$scaleY = m.$getScaleY(); - self.$skewX = matrix.$getSkewX(); - self.$skewY = matrix.$getSkewY(); - self.$skewXdeg = clampRotation(self.$skewX * 180 / Math.PI); - self.$skewYdeg = clampRotation(self.$skewY * 180 / Math.PI); - self.$rotation = clampRotation(self.$skewY * 180 / Math.PI); - } - if (egret.nativeRender) { - self.$nativeDisplayObject.setMatrix(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty); - } - }; - /** - * @private - * 获得这个显示对象以及它所有父级对象的连接矩阵。 - */ - DisplayObject.prototype.$getConcatenatedMatrix = function () { - var self = this; - var matrix = self.$concatenatedMatrix; - if (!matrix) { - matrix = self.$concatenatedMatrix = new egret.Matrix(); - } - if (self.$parent) { - self.$parent.$getConcatenatedMatrix().$preMultiplyInto(self.$getMatrix(), matrix); - } - else { - matrix.copyFrom(self.$getMatrix()); - } - var offsetX = self.$anchorOffsetX; - var offsetY = self.$anchorOffsetY; - var rect = self.$scrollRect; - if (rect) { - matrix.$preMultiplyInto(egret.$TempMatrix.setTo(1, 0, 0, 1, -rect.x - offsetX, -rect.y - offsetY), matrix); - } - else if (offsetX != 0 || offsetY != 0) { - matrix.$preMultiplyInto(egret.$TempMatrix.setTo(1, 0, 0, 1, -offsetX, -offsetY), matrix); - } - return self.$concatenatedMatrix; - }; - /** - * @private - * 获取链接矩阵 - */ - DisplayObject.prototype.$getInvertedConcatenatedMatrix = function () { - var self = this; - if (!self.$invertedConcatenatedMatrix) { - self.$invertedConcatenatedMatrix = new egret.Matrix(); - } - self.$getConcatenatedMatrix().$invertInto(self.$invertedConcatenatedMatrix); - return self.$invertedConcatenatedMatrix; - }; - Object.defineProperty(DisplayObject.prototype, "x", { - /** - * Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
    - * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer - * rotated 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is - * rotated 90° counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 x 坐标。
    - * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getX(); - }, - set: function (value) { - this.$setX(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 获取x坐标 - */ - DisplayObject.prototype.$getX = function () { - return this.$x; - }; - /** - * @private - * 设置x坐标 - */ - DisplayObject.prototype.$setX = function (value) { - var self = this; - if (self.$x == value) { - return false; - } - self.$x = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setX(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - return true; - }; - Object.defineProperty(DisplayObject.prototype, "y", { - /** - * Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
    - * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer rotated - * 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is rotated 90° - * counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 y 坐标。
    - * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getY(); - }, - set: function (value) { - this.$setY(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 获取y坐标 - */ - DisplayObject.prototype.$getY = function () { - return this.$y; - }; - /** - * @private - * 设置y坐标 - */ - DisplayObject.prototype.$setY = function (value) { - var self = this; - if (self.$y == value) { - return false; - } - self.$y = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setY(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - return true; - }; - Object.defineProperty(DisplayObject.prototype, "scaleX", { - /** - * Indicates the horizontal scale (percentage) of the object as applied from the registration point.
    - * The default 1.0 equals 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从注册点开始应用的对象的水平缩放比例(百分比)。
    - * 1.0 等于 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getScaleX(); - }, - set: function (value) { - this.$setScaleX(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - DisplayObject.prototype.$getScaleX = function () { - return this.$scaleX; - }; - /** - * @private - * 设置水平缩放值 - */ - DisplayObject.prototype.$setScaleX = function (value) { - var self = this; - if (self.$scaleX == value) { - return; - } - self.$scaleX = value; - self.$matrixDirty = true; - self.$updateUseTransform(); - if (egret.nativeRender) { - self.$nativeDisplayObject.setScaleX(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "scaleY", { - /** - * Indicates the vertical scale (percentage) of an object as applied from the registration point of the object. - * 1.0 is 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象注册点开始应用的对象的垂直缩放比例(百分比)。1.0 是 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getScaleY(); - }, - set: function (value) { - this.$setScaleY(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - DisplayObject.prototype.$getScaleY = function () { - return this.$scaleY; - }; - /** - * @private - * 设置垂直缩放值 - */ - DisplayObject.prototype.$setScaleY = function (value) { - var self = this; - if (self.$scaleY == value) { - return; - } - self.$scaleY = value; - self.$matrixDirty = true; - self.$updateUseTransform(); - if (egret.nativeRender) { - self.$nativeDisplayObject.setScaleY(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "rotation", { - /** - * Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation. Values from - * 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside - * this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement - * myDisplayObject.rotation = 450 is the same as myDisplayObject.rotation = 90. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例距其原始方向的旋转程度,以度为单位。 - * 从 0 到 180 的值表示顺时针方向旋转;从 0 到 -180 的值表示逆时针方向旋转。对于此范围之外的值,可以通过加上或 - * 减去 360 获得该范围内的值。例如,myDisplayObject.rotation = 450语句与 myDisplayObject.rotation = 90 是相同的。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getRotation(); - }, - set: function (value) { - this.$setRotation(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - DisplayObject.prototype.$getRotation = function () { - return this.$rotation; - }; - DisplayObject.prototype.$setRotation = function (value) { - value = clampRotation(value); - var self = this; - if (value == self.$rotation) { - return; - } - var delta = value - self.$rotation; - var angle = delta / 180 * Math.PI; - self.$skewX += angle; - self.$skewY += angle; - self.$rotation = value; - self.$matrixDirty = true; - self.$updateUseTransform(); - if (egret.nativeRender) { - self.$nativeDisplayObject.setRotation(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "skewX", { - /** - * 表示DisplayObject的x方向斜切 - * @member {number} egret.DisplayObject#skewX - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$skewXdeg; - }, - set: function (value) { - this.$setSkewX(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - DisplayObject.prototype.$setSkewX = function (value) { - var self = this; - if (value == self.$skewXdeg) { - return; - } - self.$skewXdeg = value; - value = clampRotation(value); - value = value / 180 * Math.PI; - self.$skewX = value; - self.$matrixDirty = true; - self.$updateUseTransform(); - if (egret.nativeRender) { - self.$nativeDisplayObject.setSkewX(self.$skewXdeg); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "skewY", { - /** - * 表示DisplayObject的y方向斜切 - * @member {number} egret.DisplayObject#skewY - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$skewYdeg; - }, - set: function (value) { - this.$setSkewY(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - DisplayObject.prototype.$setSkewY = function (value) { - var self = this; - if (value == self.$skewYdeg) { - return; - } - self.$skewYdeg = value; - value = clampRotation(value); - value = (value + self.$rotation) / 180 * Math.PI; - self.$skewY = value; - self.$matrixDirty = true; - self.$updateUseTransform(); - if (egret.nativeRender) { - self.$nativeDisplayObject.setSkewY(self.$skewYdeg); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "width", { - /** - * Indicates the width of the display object, in pixels. The width is calculated based on the bounds of the content - * of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的宽度,以像素为单位。宽度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getWidth(); - }, - set: function (value) { - this.$setWidth(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 获取显示宽度 - */ - DisplayObject.prototype.$getWidth = function () { - var self = this; - return isNaN(self.$explicitWidth) ? self.$getOriginalBounds().width : self.$explicitWidth; - }; - /** - * @private - * 设置显示宽度 - */ - DisplayObject.prototype.$setWidth = function (value) { - value = isNaN(value) ? NaN : value; - if (this.$explicitWidth == value) { - return; - } - this.$explicitWidth = value; - }; - Object.defineProperty(DisplayObject.prototype, "height", { - /** - * Indicates the height of the display object, in pixels. The height is calculated based on the bounds of the - * content of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的高度,以像素为单位。高度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getHeight(); - }, - set: function (value) { - this.$setHeight(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 获取显示高度 - */ - DisplayObject.prototype.$getHeight = function () { - var self = this; - return isNaN(self.$explicitHeight) ? self.$getOriginalBounds().height : self.$explicitHeight; - }; - /** - * @private - * 设置显示高度 - */ - DisplayObject.prototype.$setHeight = function (value) { - value = isNaN(value) ? NaN : value; - if (this.$explicitHeight == value) { - return; - } - this.$explicitHeight = value; - }; - Object.defineProperty(DisplayObject.prototype, "measuredWidth", { - /** - * 测量宽度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$getOriginalBounds().width; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "measuredHeight", { - /** - * 测量高度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$getOriginalBounds().height; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "anchorOffsetX", { - /** - * X represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点X。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$anchorOffsetX; - }, - set: function (value) { - this.$setAnchorOffsetX(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - * @returns - */ - DisplayObject.prototype.$setAnchorOffsetX = function (value) { - var self = this; - if (self.$anchorOffsetX == value) { - return; - } - self.$anchorOffsetX = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setAnchorOffsetX(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "anchorOffsetY", { - /** - * Y represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点Y。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$anchorOffsetY; - }, - set: function (value) { - this.$setAnchorOffsetY(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - * @returns - */ - DisplayObject.prototype.$setAnchorOffsetY = function (value) { - var self = this; - if (self.$anchorOffsetY == value) { - return; - } - self.$anchorOffsetY = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setAnchorOffsetY(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "visible", { - /** - * Whether or not the display object is visible. Display objects that are not visible are disabled. For example, - * if visible=false for an DisplayObject instance, it cannot receive touch or other user input. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象是否可见。不可见的显示对象将被禁用。例如,如果实例的 visible 为 false,则无法接受触摸或用户交互操作。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$visible; - }, - set: function (value) { - this.$setVisible(value); - }, - enumerable: true, - configurable: true - }); - DisplayObject.prototype.$setVisible = function (value) { - var self = this; - if (self.$visible == value) { - return; - } - self.$visible = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setVisible(value); - } - else { - self.$updateRenderMode(); - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "cacheAsBitmap", { - /** - * If set to true, Egret runtime caches an internal bitmap representation of the display object. This caching can - * increase performance for display objects that contain complex vector content. After you set the cacheAsBitmap - * property to true, the rendering does not change, however the display object performs pixel snapping automatically. - * The execution speed can be significantly faster depending on the complexity of the content.The cacheAsBitmap - * property is best used with display objects that have mostly static content and that do not scale and rotate frequently.
    - * Note: The display object will not create the bitmap caching when the memory exceeds the upper limit,even if you set it to true. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果设置为 true,则 Egret 运行时将缓存显示对象的内部位图表示形式。此缓存可以提高包含复杂矢量内容的显示对象的性能。 - * 将 cacheAsBitmap 属性设置为 true 后,呈现并不更改,但是,显示对象将自动执行像素贴紧。执行速度可能会大大加快, - * 具体取决于显示对象内容的复杂性。最好将 cacheAsBitmap 属性与主要具有静态内容且不频繁缩放或旋转的显示对象一起使用。
    - * 注意:在内存超过上限的情况下,即使将 cacheAsBitmap 属性设置为 true,显示对象也不使用位图缓存。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$cacheAsBitmap; - }, - set: function (value) { - var self = this; - self.$cacheAsBitmap = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setCacheAsBitmap(value); - } - else { - self.$setHasDisplayList(value); - } - }, - enumerable: true, - configurable: true - }); - DisplayObject.prototype.$setHasDisplayList = function (value) { - var self = this; - var hasDisplayList = !!self.$displayList; - if (hasDisplayList == value) { - return; - } - if (value) { - var displayList = egret.sys.DisplayList.create(self); - if (displayList) { - self.$displayList = displayList; - self.$cacheDirty = true; - } - } - else { - self.$displayList = null; - } - }; - DisplayObject.prototype.$cacheDirtyUp = function () { - var p = this.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - }; - Object.defineProperty(DisplayObject.prototype, "alpha", { - /** - * Indicates the alpha transparency value of the object specified. Valid values are 0 (fully transparent) to 1 (fully opaque). - * The default value is 1. Display objects with alpha set to 0 are active, even though they are invisible. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示指定对象的 Alpha 透明度值。 - * 有效值为 0(完全透明)到 1(完全不透明)。alpha 设置为 0 的显示对象是可触摸的,即使它们不可见。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$alpha; - }, - set: function (value) { - this.$setAlpha(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - DisplayObject.prototype.$setAlpha = function (value) { - var self = this; - if (self.$alpha == value) { - return; - } - self.$alpha = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setAlpha(value); - } - else { - self.$updateRenderMode(); - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "touchEnabled", { - /** - * Specifies whether this object receives touch or other user input. The default value is false, which means that - * by default any DisplayObject instance that is on the display list cannot receive touch events. If touchEnabled is - * set to false, the instance does not receive any touch events (or other user input events). Any children of - * this instance on the display list are not affected. To change the touchEnabled behavior for all children of - * an object on the display list, use DisplayObjectContainer.touchChildren. - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定此对象是否接收触摸或其他用户输入。默认值为 false,这表示默认情况下,显示列表上的任何 DisplayObject 实例都不会接收触摸事件或 - * 其他用户输入事件。如果将 touchEnabled 设置为 false,则实例将不接收任何触摸事件(或其他用户输入事件)。显示列表上的该实例的任 - * 何子级都不会受到影响。要更改显示列表上对象的所有子级的 touchEnabled 行为,请使用 DisplayObjectContainer.touchChildren。 - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getTouchEnabled(); - }, - set: function (value) { - this.$setTouchEnabled(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - DisplayObject.prototype.$getTouchEnabled = function () { - return this.$touchEnabled; - }; - /** - * @private - */ - DisplayObject.prototype.$setTouchEnabled = function (value) { - this.$touchEnabled = !!value; - }; - Object.defineProperty(DisplayObject.prototype, "scrollRect", { - /** - * The scroll rectangle bounds of the display object. The display object is cropped to the size defined by the rectangle, - * and it scrolls within the rectangle when you change the x and y properties of the scrollRect object. A scrolled display - * object always scrolls in whole pixel increments.You can scroll an object left and right by setting the x property of - * the scrollRect Rectangle object. You can scroll an object up and down by setting the y property of the scrollRect - * Rectangle object. If the display object is rotated 90° and you scroll it left and right, the display object actually - * scrolls up and down.
    - * - * Note: to change the value of a display object's scrollRect, you must make a copy of the entire scrollRect object, then copy - * the new object into the scrollRect property of the display object. - * @example the following code increases the x value of a display object's scrollRect - *
    -             *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
    -             *     myRectangle.x += 10;
    -             *     myDisplayObject.scrollRect = myRectangle;
    -             * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的滚动矩形范围。显示对象被裁切为矩形定义的大小,当您更改 scrollRect 对象的 x 和 y 属性时,它会在矩形内滚动。 - * 滚动的显示对象始终以整像素为增量进行滚动。您可以通过设置 scrollRect Rectangle 对象的 x 属性来左右滚动对象, 还可以通过设置 - * scrollRect 对象的 y 属性来上下滚动对象。如果显示对象旋转了 90 度,并且您左右滚动它,则实际上显示对象会上下滚动。
    - * - * 注意:要改变一个显示对象 scrollRect 属性的值,您必引用整个 scrollRect 对象,然后将它重新赋值给显示对象的 scrollRect 属性。 - * @example 以下代码改变了显示对象 scrollRect 的 x 属性值: - *
    -             *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
    -             *     myRectangle.x += 10;
    -             *     myDisplayObject.scrollRect = myRectangle;//设置完scrollRect的x、y、width、height值之后,一定要对myDisplayObject重新赋值scrollRect,不然会出问题。
    -             * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$scrollRect; - }, - set: function (value) { - this.$setScrollRect(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - DisplayObject.prototype.$setScrollRect = function (value) { - var self = this; - if (!value && !self.$scrollRect) { - self.$updateRenderMode(); - return; - } - if (value) { - if (!self.$scrollRect) { - self.$scrollRect = new egret.Rectangle(); - } - self.$scrollRect.copyFrom(value); - if (egret.nativeRender) { - self.$nativeDisplayObject.setScrollRect(value.x, value.y, value.width, value.height); - } - } - else { - self.$scrollRect = null; - if (egret.nativeRender) { - self.$nativeDisplayObject.setScrollRect(0, 0, 0, 0); - } - } - if (!egret.nativeRender) { - self.$updateRenderMode(); - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(DisplayObject.prototype, "blendMode", { - /** - * A value from the BlendMode class that specifies which blend mode to use. Determine how a source image (new one) - * is drawn on the target image (old one).
    - * If you attempt to set this property to an invalid value, Egret runtime set the value to BlendMode.NORMAL. - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BlendMode 枚举中的一个值,用于指定要使用的混合模式,确定如何将一个源(新的)图像绘制到目标(已有)的图像上
    - * 如果尝试将此属性设置为无效值,则运行时会将此值设置为 BlendMode.NORMAL。 - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return egret.sys.numberToBlendMode(this.$blendMode); - }, - set: function (value) { - var self = this; - var mode = egret.sys.blendModeToNumber(value); - if (self.$blendMode == mode) { - return; - } - self.$blendMode = mode; - if (egret.nativeRender) { - self.$nativeDisplayObject.setBlendMode(mode); - } - else { - self.$updateRenderMode(); - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "mask", { - /** - * The calling display object is masked by the specified mask object. To ensure that masking works when the Stage - * is scaled, the mask display object must be in an active part of the display list. The mask object itself is not drawn. - * Set mask to null to remove the mask. To be able to scale a mask object, it must be on the display list. To be - * able to drag a mask object , it must be on the display list.
    - * Note: A single mask object cannot be used to mask more than one calling display object. When the mask is assigned - * to a second display object, it is removed as the mask of the first object, and that object's mask property becomes null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用显示对象被指定的 mask 对象遮罩。要确保当舞台缩放时蒙版仍然有效,mask 显示对象必须处于显示列表的活动部分。 - * 但不绘制 mask 对象本身。将 mask 设置为 null 可删除蒙版。要能够缩放遮罩对象,它必须在显示列表中。要能够拖动蒙版 - * 对象,它必须在显示列表中。
    - * 注意:单个 mask 对象不能用于遮罩多个执行调用的显示对象。在将 mask 分配给第二个显示对象时,会撤消其作为第一个对象的遮罩, - * 该对象的 mask 属性将变为 null。 - * - * 下面例子为 mask 为 Rectangle 类型对象,这种情况下,修改 mask 的值后,一定要对 myDisplayObject 重新赋值 mask,不然会出问题。 - * @example 以下代码改变了显示对象 mask 的 x 属性值: - *
    -             *     let myMask:Rectangle = myDisplayObject.mask;
    -             *     myMask.x += 10;
    -             *     myDisplayObject.mask = myMask;//设置完 mask 的x、y、width、height值之后,一定要对myDisplayObject重新赋值 mask,不然会出问题。
    -             * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - var self = this; - return self.$mask ? self.$mask : self.$maskRect; - }, - set: function (value) { - var self = this; - if (value === self) { - return; - } - if (value) { - if (value instanceof DisplayObject) { - if (value == self.$mask) { - return; - } - if (value.$maskedObject) { - value.$maskedObject.mask = null; - } - value.$maskedObject = self; - self.$mask = value; - if (!egret.nativeRender) { - value.$updateRenderMode(); - } - if (self.$maskRect) { - if (egret.nativeRender) { - self.$nativeDisplayObject.setMaskRect(0, 0, 0, 0); - } - self.$maskRect = null; - } - if (egret.nativeRender) { - self.$nativeDisplayObject.setMask(value.$nativeDisplayObject.id); - } - } - else { - if (!self.$maskRect) { - self.$maskRect = new egret.Rectangle(); - } - self.$maskRect.copyFrom(value); - if (egret.nativeRender) { - self.$nativeDisplayObject.setMaskRect(value.x, value.y, value.width, value.height); - } - if (self.$mask) { - self.$mask.$maskedObject = null; - if (!egret.nativeRender) { - self.$mask.$updateRenderMode(); - } - } - if (self.mask) { - if (egret.nativeRender) { - self.$nativeDisplayObject.setMask(-1); - } - self.$mask = null; - } - } - } - else { - if (self.$mask) { - self.$mask.$maskedObject = null; - if (!egret.nativeRender) { - self.$mask.$updateRenderMode(); - } - } - if (self.mask) { - if (egret.nativeRender) { - self.$nativeDisplayObject.setMask(-1); - } - self.$mask = null; - } - if (self.$maskRect) { - if (egret.nativeRender) { - self.$nativeDisplayObject.setMaskRect(0, 0, 0, 0); - } - self.$maskRect = null; - } - } - if (!egret.nativeRender) { - self.$updateRenderMode(); - } - }, - enumerable: true, - configurable: true - }); - DisplayObject.prototype.$setMaskRect = function (value) { - var self = this; - if (!value && !self.$maskRect) { - return; - } - if (value) { - if (!self.$maskRect) { - self.$maskRect = new egret.Rectangle(); - } - self.$maskRect.copyFrom(value); - } - else { - self.$maskRect = null; - } - }; - Object.defineProperty(DisplayObject.prototype, "filters", { - /** - * An indexed array that contains each filter object currently associated with the display object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 包含当前与显示对象关联的每个滤镜对象的索引数组。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$filters; - }, - set: function (value) { - var self = this; - var filters = self.$filters; - if (!filters && !value) { - self.$filters = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setFilters(null); - } - else { - self.$updateRenderMode(); - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - return; - } - if (value && value.length) { - value = value.concat(); - self.$filters = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setFilters(value); - } - } - else { - self.$filters = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setFilters(null); - } - } - if (!egret.nativeRender) { - self.$updateRenderMode(); - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }, - enumerable: true, - configurable: true - }); - /** - * Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object. - * @param targetCoordinateSpace The display object that defines the coordinate system to use. - * @param resultRect A reusable instance of Rectangle for saving the results. Passing this parameter can reduce the number of reallocate objects - *, which allows you to get better code execution performance.. - * @returns The rectangle that defines the area of the display object relative to the targetCoordinateSpace object's coordinate system. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个矩形,该矩形定义相对于 targetCoordinateSpace 对象坐标系的显示对象区域。 - * @param targetCoordinateSpace 定义要使用的坐标系的显示对象。 - * @param resultRect 一个用于存储结果的可复用Rectangle实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 定义与 targetCoordinateSpace 对象坐标系统相关的显示对象面积的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.prototype.getTransformedBounds = function (targetCoordinateSpace, resultRect) { - targetCoordinateSpace = targetCoordinateSpace || this; - return this.$getTransformedBounds(targetCoordinateSpace, resultRect); - }; - /** - * Obtain measurement boundary of display object - * @param resultRect {Rectangle} Optional. It is used to import Rectangle object for saving results, preventing duplicate object creation. - * @param calculateAnchor {boolean} Optional. It is used to determine whether to calculate anchor point. - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取显示对象的测量边界 - * @param resultRect {Rectangle} 可选参数,传入用于保存结果的Rectangle对象,避免重复创建对象。 - * @param calculateAnchor {boolean} 可选参数,是否会计算锚点。 - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.prototype.getBounds = function (resultRect, calculateAnchor) { - if (calculateAnchor === void 0) { calculateAnchor = true; } - var self = this; - resultRect = self.$getTransformedBounds(self, resultRect); - if (calculateAnchor) { - if (self.$anchorOffsetX != 0) { - resultRect.x -= self.$anchorOffsetX; - } - if (self.$anchorOffsetY != 0) { - resultRect.y -= self.$anchorOffsetY; - } - } - return resultRect; - }; - /** - * @private - */ - DisplayObject.prototype.$getTransformedBounds = function (targetCoordinateSpace, resultRect) { - var self = this; - var bounds = self.$getOriginalBounds(); - if (!resultRect) { - resultRect = new egret.Rectangle(); - } - resultRect.copyFrom(bounds); - if (targetCoordinateSpace == self) { - return resultRect; - } - var m; - if (targetCoordinateSpace) { - m = egret.$TempMatrix; - var invertedTargetMatrix = targetCoordinateSpace.$getInvertedConcatenatedMatrix(); - invertedTargetMatrix.$preMultiplyInto(self.$getConcatenatedMatrix(), m); - } - else { - m = self.$getConcatenatedMatrix(); - } - m.$transformBounds(resultRect); - return resultRect; - }; - /** - * Converts the point object from the Stage (global) coordinates to the display object's (local) coordinates. - * @param stageX the x value in the global coordinates - * @param stageY the y value in the global coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将从舞台(全局)坐标转换为显示对象的(本地)坐标。 - * @param stageX 舞台坐标x - * @param stageY 舞台坐标y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 具有相对于显示对象的坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.prototype.globalToLocal = function (stageX, stageY, resultPoint) { - if (stageX === void 0) { stageX = 0; } - if (stageY === void 0) { stageY = 0; } - if (egret.nativeRender) { - egret_native.updateNativeRender(); - var result = egret_native.nrGlobalToLocal(this.$nativeDisplayObject.id, stageX, stageY); - var arr = result.split(","); - var x = parseFloat(arr[0]); - var y = parseFloat(arr[1]); - if (resultPoint) { - resultPoint.setTo(x, y); - } - else { - resultPoint = new egret.Point(x, y); - } - return resultPoint; - } - else { - var m = this.$getInvertedConcatenatedMatrix(); - return m.transformPoint(stageX, stageY, resultPoint); - } - }; - /** - * Converts the point object from the display object's (local) coordinates to the Stage (global) coordinates. - * @param localX the x value in the local coordinates - * @param localY the x value in the local coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the Stage. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的(本地)坐标转换为舞台(全局)坐标。 - * @param localX 本地坐标 x - * @param localY 本地坐标 y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 一个具有相对于舞台坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.prototype.localToGlobal = function (localX, localY, resultPoint) { - if (localX === void 0) { localX = 0; } - if (localY === void 0) { localY = 0; } - if (egret.nativeRender) { - egret_native.updateNativeRender(); - var result = egret_native.nrLocalToGlobal(this.$nativeDisplayObject.id, localX, localY); - var arr = result.split(","); - var x = parseFloat(arr[0]); - var y = parseFloat(arr[1]); - if (resultPoint) { - resultPoint.setTo(x, y); - } - else { - resultPoint = new egret.Point(x, y); - } - return resultPoint; - } - else { - var m = this.$getConcatenatedMatrix(); - return m.transformPoint(localX, localY, resultPoint); - } - }; - /** - * @private - * 获取显示对象占用的矩形区域集合,通常包括自身绘制的测量区域,如果是容器,还包括所有子项占据的区域。 - */ - DisplayObject.prototype.$getOriginalBounds = function () { - var self = this; - var bounds = self.$getContentBounds(); - self.$measureChildBounds(bounds); - var offset = self.$measureFiltersOffset(false); - if (offset) { - bounds.x += offset.minX; - bounds.y += offset.minY; - bounds.width += -offset.minX + offset.maxX; - bounds.height += -offset.minY + offset.maxY; - } - return bounds; - }; - /** - * @private - * 测量子项占用的矩形区域 - * @param bounds 测量结果存储在这个矩形对象内 - */ - DisplayObject.prototype.$measureChildBounds = function (bounds) { - }; - /** - * @private - */ - DisplayObject.prototype.$getContentBounds = function () { - var bounds = egret.$TempRectangle; - bounds.setEmpty(); - this.$measureContentBounds(bounds); - return bounds; - }; - /** - * @private - * 测量自身占用的矩形区域,注意:此测量结果并不包括子项占据的区域。 - * @param bounds 测量结果存储在这个矩形对象内 - */ - DisplayObject.prototype.$measureContentBounds = function (bounds) { - }; - /** - * @private - * 获取渲染节点 - */ - DisplayObject.prototype.$getRenderNode = function () { - var self = this; - var node = self.$renderNode; - if (!node) { - return null; - } - if (self.$renderDirty) { - node.cleanBeforeRender(); - self.$updateRenderNode(); - self.$renderDirty = false; - node = self.$renderNode; - } - return node; - }; - DisplayObject.prototype.$updateRenderMode = function () { - var self = this; - if (!self.$visible || self.$alpha <= 0 || self.$maskedObject) { - self.$renderMode = 1 /* NONE */; - } - else if (self.filters && self.filters.length > 0) { - self.$renderMode = 2 /* FILTER */; - } - else if (self.$blendMode !== 0 || (self.$mask && self.$mask.$stage)) { - self.$renderMode = 3 /* CLIP */; - } - else if (self.$scrollRect || self.$maskRect) { - self.$renderMode = 4 /* SCROLLRECT */; - } - else { - self.$renderMode = null; - } - }; - /** - * @private - */ - DisplayObject.prototype.$measureFiltersOffset = function (fromParent) { - var display = this; - var minX = 0; - var minY = 0; - var maxX = 0; - var maxY = 0; - while (display) { - var filters = display.$filters; - if (filters && filters.length) { - var length_1 = filters.length; - for (var i = 0; i < length_1; i++) { - var filter = filters[i]; - //todo 缓存这个数据 - if (filter.type == "blur") { - var offsetX = filter.blurX; - var offsetY = filter.blurY; - minX -= offsetX; - minY -= offsetY; - maxX += offsetX; - maxY += offsetY; - } - else if (filter.type == "glow") { - var offsetX = filter.blurX; - var offsetY = filter.blurY; - minX -= offsetX; - minY -= offsetY; - maxX += offsetX; - maxY += offsetY; - var distance = filter.distance || 0; - var angle = filter.angle || 0; - var distanceX = 0; - var distanceY = 0; - if (distance != 0) { - distanceX = distance * egret.NumberUtils.cos(angle); - if (distanceX > 0) { - distanceX = Math.ceil(distanceX); - } - else { - distanceX = Math.floor(distanceX); - } - distanceY = distance * egret.NumberUtils.sin(angle); - if (distanceY > 0) { - distanceY = Math.ceil(distanceY); - } - else { - distanceY = Math.floor(distanceY); - } - minX += distanceX; - maxX += distanceX; - minY += distanceY; - maxY += distanceY; - } - } - else if (filter.type == "custom") { - var padding = filter.padding; - minX -= padding; - minY -= padding; - maxX += padding; - maxY += padding; - } - } - } - if (fromParent) { - display = display.$parent; - } - else { - display = null; - } - } - minX = Math.min(minX, 0); - minY = Math.min(minY, 0); - maxX = Math.max(maxX, 0); - maxY = Math.max(maxY, 0); - return { minX: minX, minY: minY, maxX: maxX, maxY: maxY }; - }; - /** - * @private - * 获取相对于指定根节点的连接矩阵。 - * @param root 根节点显示对象 - * @param matrix 目标显示对象相对于舞台的完整连接矩阵。 - */ - DisplayObject.prototype.$getConcatenatedMatrixAt = function (root, matrix) { - var invertMatrix = root.$getInvertedConcatenatedMatrix(); - if (invertMatrix.a === 0 || invertMatrix.d === 0) { - var target = this; - var rootLevel = root.$nestLevel; - matrix.identity(); - while (target.$nestLevel > rootLevel) { - var rect = target.$scrollRect; - if (rect) { - matrix.concat(egret.$TempMatrix.setTo(1, 0, 0, 1, -rect.x, -rect.y)); - } - matrix.concat(target.$getMatrix()); - target = target.$parent; - } - } - else { - invertMatrix.$preMultiplyInto(matrix, matrix); - } - }; - /** - * @private - * 更新renderNode - */ - DisplayObject.prototype.$updateRenderNode = function () { - }; - /** - * @private - */ - DisplayObject.prototype.$hitTest = function (stageX, stageY) { - var self = this; - if ((!egret.nativeRender && !self.$renderNode) || !self.$visible || self.$scaleX == 0 || self.$scaleY == 0) { - return null; - } - var m = self.$getInvertedConcatenatedMatrix(); - if (m.a == 0 && m.b == 0 && m.c == 0 && m.d == 0) { - return null; - } - var bounds = self.$getContentBounds(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - if (bounds.contains(localX, localY)) { - if (!self.$children) { - var rect = self.$scrollRect ? self.$scrollRect : self.$maskRect; - if (rect && !rect.contains(localX, localY)) { - return null; - } - if (self.$mask && !self.$mask.$hitTest(stageX, stageY)) { - return null; - } - } - return self; - } - return null; - }; - /** - * Calculate the display object to determine whether it overlaps or crosses with the points specified by the x and y parameters. The x and y parameters specify the points in the coordinates of the stage, rather than the points in the display object container that contains display objects (except the situation where the display object container is a stage). - * Note: Don't use accurate pixel collision detection on a large number of objects. Otherwise, this will cause serious performance deterioration. - * @param x {number} x coordinate of the object to be tested. - * @param y {number} y coordinate of the object to be tested. - * @param shapeFlag {boolean} Whether to check the actual pixel of object (true) or check that of border (false).Write realized. - * @returns {boolean} If display object overlaps or crosses with the specified point, it is true; otherwise, it is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计算显示对象,以确定它是否与 x 和 y 参数指定的点重叠或相交。x 和 y 参数指定舞台的坐标空间中的点,而不是包含显示对象的显示对象容器中的点(除非显示对象容器是舞台)。 - * 注意,不要在大量物体中使用精确碰撞像素检测,这回带来巨大的性能开销 - * @param x {number} 要测试的此对象的 x 坐标。 - * @param y {number} 要测试的此对象的 y 坐标。 - * @param shapeFlag {boolean} 是检查对象 (true) 的实际像素,还是检查边框 (false) 的实际像素。 - * @returns {boolean} 如果显示对象与指定的点重叠或相交,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.prototype.hitTestPoint = function (x, y, shapeFlag) { - var self = this; - if (!shapeFlag) { - if (self.$scaleX == 0 || self.$scaleY == 0) { - return false; - } - var m = self.$getInvertedConcatenatedMatrix(); - var bounds = self.getBounds(null, false); - var localX = m.a * x + m.c * y + m.tx; - var localY = m.b * x + m.d * y + m.ty; - if (bounds.contains(localX, localY)) { - //这里不考虑设置mask的情况 - var rect = self.$scrollRect ? self.$scrollRect : self.$maskRect; - if (rect && !rect.contains(localX, localY)) { - return false; - } - return true; - } - return false; - } - else { - var m = self.$getInvertedConcatenatedMatrix(); - var localX = m.a * x + m.c * y + m.tx; - var localY = m.b * x + m.d * y + m.ty; - var data = void 0; - if (egret.nativeRender) { - var buffer = egret.sys.customHitTestBuffer; - buffer.resize(3, 3); - egret_native.forHitTest = true; - egret_native.activateBuffer(buffer); - egret_native.updateNativeRender(); - egret_native.nrRenderDisplayObject2(self.$nativeDisplayObject.id, 1 - localX, 1 - localY, true); - try { - data = new Uint8Array(4); - egret_native.nrGetPixels(1, 1, 1, 1, data); - } - catch (e) { - throw new Error(egret.sys.tr(1039)); - } - egret_native.activateBuffer(null); - egret_native.forHitTest = false; - if (data[3] === 0) { - return false; - } - return true; - } - else { - var displayList = self.$displayList; - if (displayList) { - var buffer = displayList.renderBuffer; - try { - data = buffer.getPixels(localX - displayList.offsetX, localY - displayList.offsetY); - } - catch (e) { - throw new Error(egret.sys.tr(1039)); - } - } - else { - var buffer = egret.sys.customHitTestBuffer; - buffer.resize(3, 3); - var matrix = egret.Matrix.create(); - matrix.identity(); - matrix.translate(1 - localX, 1 - localY); - egret.sys.systemRenderer.render(this, buffer, matrix, true); - egret.Matrix.release(matrix); - try { - data = buffer.getPixels(1, 1); - } - catch (e) { - throw new Error(egret.sys.tr(1039)); - } - } - if (data[3] === 0) { - return false; - } - return true; - } - } - }; - /** - * @private - */ - DisplayObject.prototype.$addListener = function (type, listener, thisObject, useCapture, priority, dispatchOnce) { - _super.prototype.$addListener.call(this, type, listener, thisObject, useCapture, priority, dispatchOnce); - var isEnterFrame = (type == egret.Event.ENTER_FRAME); - if (isEnterFrame || type == egret.Event.RENDER) { - var list = isEnterFrame ? DisplayObject.$enterFrameCallBackList : DisplayObject.$renderCallBackList; - if (list.indexOf(this) == -1) { - list.push(this); - } - } - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - DisplayObject.prototype.removeEventListener = function (type, listener, thisObject, useCapture) { - _super.prototype.removeEventListener.call(this, type, listener, thisObject, useCapture); - var isEnterFrame = (type == egret.Event.ENTER_FRAME); - if ((isEnterFrame || type == egret.Event.RENDER) && !this.hasEventListener(type)) { - var list = isEnterFrame ? DisplayObject.$enterFrameCallBackList : DisplayObject.$renderCallBackList; - var index = list.indexOf(this); - if (index !== -1) { - list.splice(index, 1); - } - } - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - DisplayObject.prototype.dispatchEvent = function (event) { - if (!event.$bubbles) { - return _super.prototype.dispatchEvent.call(this, event); - } - var list = this.$getPropagationList(this); - var targetIndex = list.length * 0.5; - event.$setTarget(this); - this.$dispatchPropagationEvent(event, list, targetIndex); - return !event.$isDefaultPrevented; - }; - /** - * @private - * 获取事件流列表。注意:Egret框架的事件流与Flash实现并不一致。 - * - * 事件流有三个阶段:捕获,目标,冒泡。 - * Flash里默认的的事件监听若不开启useCapture将监听目标和冒泡阶段。若开始capture将只能监听捕获当不包括目标的事件。 - * 可以在Flash中写一个简单的测试:实例化一个非容器显示对象,例如TextField。分别监听useCapture为true和false时的鼠标事件。 - * 点击后将只有useCapture为false的回调函数输出信息。也就带来一个问题「Flash的捕获阶段不能监听到最内层对象本身,只在父级列表有效」。 - * - * 而HTML里的事件流设置useCapture为true时是能监听到目标阶段的,也就是目标阶段会被触发两次,在捕获和冒泡过程各触发一次。这样可以避免 - * 前面提到的监听捕获无法监听目标本身的问题。 - * - * Egret最终采用了HTML里目标节点触发两次的事件流方式。 - */ - DisplayObject.prototype.$getPropagationList = function (target) { - var list = []; - while (target) { - list.push(target); - target = target.$parent; - } - var captureList = list.concat(); - captureList.reverse(); //使用一次reverse()方法比多次调用unshift()性能高。 - list = captureList.concat(list); - return list; - }; - /** - * @private - */ - DisplayObject.prototype.$dispatchPropagationEvent = function (event, list, targetIndex) { - var length = list.length; - var captureIndex = targetIndex - 1; - for (var i = 0; i < length; i++) { - var currentTarget = list[i]; - event.$currentTarget = currentTarget; - if (i < captureIndex) - event.$eventPhase = 1 /* CAPTURING_PHASE */; - else if (i == targetIndex || i == captureIndex) - event.$eventPhase = 2 /* AT_TARGET */; - else - event.$eventPhase = 3 /* BUBBLING_PHASE */; - currentTarget.$notifyListener(event, i < targetIndex); - if (event.$isPropagationStopped || event.$isPropagationImmediateStopped) { - return; - } - } - }; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - DisplayObject.prototype.willTrigger = function (type) { - var parent = this; - while (parent) { - if (parent.hasEventListener(type)) - return true; - parent = parent.$parent; - } - return false; - }; - Object.defineProperty(DisplayObject.prototype, "tint", { - /** - * Set a tint color for the current object - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 给当前对象设置填充色 - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._tint; - }, - set: function (value) { - this._tint = value; - this.$tintRGB = (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); - }, - enumerable: true, - configurable: true - }); - DisplayObject.prototype.sortChildren = function () { - this.$sortDirty = false; - }; - Object.defineProperty(DisplayObject.prototype, "zIndex", { - /** - * the z-order (front-to-back order) of the object - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 设置对象的 Z 轴顺序(前后顺序) - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._zIndex; - }, - set: function (value) { - this._zIndex = value; - if (this.parent) { - this.parent.$sortDirty = true; - } - }, - enumerable: true, - configurable: true - }); - /** - * @private - * The default touchEnabled property of DisplayObject - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * @private - * 显示对象默认的 touchEnabled 属性 - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - DisplayObject.defaultTouchEnabled = false; - /** - * @private - */ - DisplayObject.$enterFrameCallBackList = []; - /** - * @private - */ - DisplayObject.$renderCallBackList = []; - return DisplayObject; - }(egret.EventDispatcher)); - egret.DisplayObject = DisplayObject; - __reflect(DisplayObject.prototype, "egret.DisplayObject"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - egret.$TextureScaleFactor = 1; - /** - * The Texture class encapsulates different image resources on different platforms. - * In HTML5, resource is an HTMLElement object - * In OpenGL / WebGL, resource is a texture ID obtained after the GPU is submitted - * The Texture class encapsulates the details implemented on the underlayer. Developers just need to focus on interfaces - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @see http://edn.egret.com/cn/docs/page/123 Several ways of access to resources - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language en_US - */ - /** - * 纹理类是对不同平台不同的图片资源的封装 - * 在HTML5中,资源是一个HTMLElement对象 - * 在OpenGL / WebGL中,资源是一个提交GPU后获取的纹理id - * Texture类封装了这些底层实现的细节,开发者只需要关心接口即可 - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @see http://edn.egret.com/cn/docs/page/123 获取资源的几种方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language zh_CN - */ - var Texture = (function (_super) { - __extends(Texture, _super); - /** - * Create an egret.Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Texture() { - var _this = _super.call(this) || this; - /** - * Whether to destroy the corresponding BitmapData when the texture is destroyed - * @version Egret 5.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁纹理时是否销毁对应BitmapData - * @version Egret 5.0.8 - * @platform Web,Native - * @language zh_CN - */ - _this.disposeBitmapData = true; - /** - * @private - * 表示这个纹理在 bitmapData 上的 x 起始位置 - */ - _this.$bitmapX = 0; - /** - * @private - * 表示这个纹理在 bitmapData 上的 y 起始位置 - */ - _this.$bitmapY = 0; - /** - * @private - * 表示这个纹理在 bitmapData 上的宽度 - */ - _this.$bitmapWidth = 0; - /** - * @private - * 表示这个纹理在 bitmapData 上的高度 - */ - _this.$bitmapHeight = 0; - /** - * @private - * 表示这个纹理显示了之后在 x 方向的渲染偏移量 - */ - _this.$offsetX = 0; - /** - * @private - * 表示这个纹理显示了之后在 y 方向的渲染偏移量 - */ - _this.$offsetY = 0; - /** - * @private - * 纹理宽度 - */ - _this.$textureWidth = 0; - /** - * @private - * 纹理高度 - */ - _this.$textureHeight = 0; - /** - * @private - * 表示bitmapData.width - */ - _this.$sourceWidth = 0; - /** - * @private - * 表示bitmapData.height - */ - _this.$sourceHeight = 0; - /** - * @private - */ - _this.$bitmapData = null; - /** - * @private - */ - _this.$ktxData = null; - /** - * @private - */ - _this.$rotated = false; - return _this; - } - Object.defineProperty(Texture.prototype, "textureWidth", { - /** - * Texture width, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理宽度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getTextureWidth(); - }, - enumerable: true, - configurable: true - }); - Texture.prototype.$getTextureWidth = function () { - return this.$textureWidth; - }; - Object.defineProperty(Texture.prototype, "textureHeight", { - /** - * Texture height, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理高度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getTextureHeight(); - }, - enumerable: true, - configurable: true - }); - Texture.prototype.$getTextureHeight = function () { - return this.$textureHeight; - }; - Texture.prototype.$getScaleBitmapWidth = function () { - return this.$bitmapWidth * egret.$TextureScaleFactor; - }; - Texture.prototype.$getScaleBitmapHeight = function () { - return this.$bitmapHeight * egret.$TextureScaleFactor; - }; - Object.defineProperty(Texture.prototype, "bitmapData", { - /** - * The BitmapData object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 BitmapData 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$bitmapData; - }, - set: function (value) { - this.$ktxData = null; - this._setBitmapData(value); - }, - enumerable: true, - configurable: true - }); - /** - * Set the BitmapData object. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 设置 BitmapData 对象。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - Texture.prototype._setBitmapData = function (value) { - this.$bitmapData = value; - var scale = egret.$TextureScaleFactor; - var w = value.width * scale; - var h = value.height * scale; - this.$initData(0, 0, w, h, 0, 0, w, h, value.width, value.height); - }; - Object.defineProperty(Texture.prototype, "ktxData", { - /** - * The KTX object being referenced. - * @version Egret 5.2.21 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 KTXData 对象。 - * @version Egret 5.2.21 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$ktxData; - }, - set: function (data) { - this._setKtxData(data); - }, - enumerable: true, - configurable: true - }); - /** - * Set the KTXData object. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 设置 KTXData 对象。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - Texture.prototype._setKtxData = function (value) { - if (!value) { - egret.error('ktx data is null'); - return; - } - if (value == this.$ktxData) { - return; - } - var ktx = new egret.KTXContainer(value, 1); - if (ktx.isInvalid) { - egret.error('ktx data is invalid'); - return; - } - this.$ktxData = value; - var bitmapData = new egret.BitmapData(value); - bitmapData.format = 'ktx'; - ktx.uploadLevels(bitmapData, false); - this._setBitmapData(bitmapData); - }; - /** - * @private - * 设置Texture数据 - * @param bitmapX - * @param bitmapY - * @param bitmapWidth - * @param bitmapHeight - * @param offsetX - * @param offsetY - * @param textureWidth - * @param textureHeight - * @param sourceWidth - * @param sourceHeight - */ - Texture.prototype.$initData = function (bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, sourceWidth, sourceHeight, rotated) { - if (rotated === void 0) { rotated = false; } - var scale = egret.$TextureScaleFactor; - this.$bitmapX = bitmapX / scale; - this.$bitmapY = bitmapY / scale; - this.$bitmapWidth = bitmapWidth / scale; - this.$bitmapHeight = bitmapHeight / scale; - this.$offsetX = offsetX; - this.$offsetY = offsetY; - this.$textureWidth = textureWidth; - this.$textureHeight = textureHeight; - this.$sourceWidth = sourceWidth; - this.$sourceHeight = sourceHeight; - this.$rotated = rotated; - //todo - egret.BitmapData.$invalidate(this.$bitmapData); - }; - /** - * @deprecated - */ - Texture.prototype.getPixel32 = function (x, y) { - throw new Error(); - }; - /** - * Obtain the color value for the specified pixel region - * @param x The x coordinate of the pixel region - * @param y The y coordinate of the pixel region - * @param width The width of the pixel region - * @param height The height of the pixel region - * @returns Specifies the color value for the pixel region - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取指定像素区域的颜色值 - * @param x 像素区域的X轴坐标 - * @param y 像素区域的Y轴坐标 - * @param width 像素区域的宽度 - * @param height 像素区域的高度 - * @returns 指定像素区域的颜色值 - * @version Egret 3.2.1 - * @platform Web - * @language zh_CN - */ - Texture.prototype.getPixels = function (x, y, width, height) { - if (width === void 0) { width = 1; } - if (height === void 0) { height = 1; } - throw new Error(); - }; - /** - * Convert base64 string, if the picture (or pictures included) cross-border or null - * @param type Type conversions, such as "image / png" - * @param rect The need to convert the area - * @param smoothing Whether to convert data to the smoothing process - * @returns {any} base64 string - * @version Egret 2.4 - * @language en_US - */ - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如 "image/png" - * @param rect 需要转换的区域 - * @param {any} encoderOptions 编码用的参数 - * @returns {any} base64字符串 - * @version Egret 2.4 - * @language zh_CN - */ - Texture.prototype.toDataURL = function (type, rect, encoderOptions) { - throw new Error(); - }; - /** - * Crop designated area and save it as image. - * native support only "image / png" and "image / jpeg"; Web browser because of the various implementations are not the same, it is recommended to use only these two kinds. - * @param type Type conversions, such as "image / png" - * @param filePath The path name of the image (the home directory for the game's private space, the path can not have "../",Web supports only pass names.) - * @param rect The need to convert the area - * @version Egret 2.4 - * @platform Native - * @language en_US - */ - /** - * 裁剪指定区域并保存成图片。 - * native只支持 "image/png" 和 "image/jpeg";Web中由于各个浏览器的实现不一样,因此建议也只用这2种。 - * @param type 转换的类型,如 "image/png" - * @param filePath 图片的名称的路径(主目录为游戏的私有空间,路径中不能有 "../",Web只支持传名称。) - * @param rect 需要转换的区域 - * @version Egret 2.4 - * @platform Native - * @language zh_CN - */ - Texture.prototype.saveToFile = function (type, filePath, rect) { - throw new Error(); - }; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Texture.prototype.dispose = function () { - if (this.$bitmapData) { - if (this.disposeBitmapData) { - this.$bitmapData.$dispose(); - } - this.$bitmapData = null; - } - }; - return Texture; - }(egret.HashObject)); - egret.Texture = Texture; - __reflect(Texture.prototype, "egret.Texture"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Event class is used as the base class for the creation of Event objects, which are passed as parameters to event - * listeners when an event occurs.The properties of the Event class carry basic information about an event, such as - * the event's type or whether the event's default behavior can be canceled. For many events, such as the events represented - * by the Event class constants, this basic information is sufficient. Other events, however, may require more detailed - * information. Events associated with a touch tap, for example, need to include additional information about the - * location of the touch event. You can pass such additional information to event listeners by extending the Event class, - * which is what the TouchEvent class does. Egret API defines several Event subclasses for common events that require - * additional information. Events associated with each of the Event subclasses are described in the documentation for - * each class.The methods of the Event class can be used in event listener functions to affect the behavior of the event - * object. Some events have an associated default behavior. Your event listener can cancel this behavior by calling the - * preventDefault() method. You can also make the current event listener the last one to process an event by calling - * the stopPropagation() or stopImmediatePropagation() method. - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language en_US - */ - /** - * Event 类作为创建事件实例的基类,当发生事件时,Event 实例将作为参数传递给事件侦听器。Event 类的属性包含有关事件的基本信息,例如事件 - * 的类型或者是否可以取消事件的默认行为。对于许多事件(如由 Event 类常量表示的事件),此基本信息就足够了。但其他事件可能需要更详细的信息。 - * 例如,与触摸关联的事件需要包括有关触摸事件的位置信息。您可以通过扩展 Event 类(TouchEvent 类执行的操作)将此类其他信息传递给事件侦听器。 - * Egret API 为需要其他信息的常见事件定义多个 Event 子类。与每个 Event 子类关联的事件将在每个类的文档中加以介绍。Event 类的方法可以在 - * 事件侦听器函数中使用以影响事件对象的行为。某些事件有关联的默认行为,通过调用 preventDefault() 方法,您的事件侦听器可以取消此行为。 - * 可以通过调用 stopPropagation() 或 stopImmediatePropagation() 方法,将当前事件侦听器作为处理事件的最后一个事件侦听器。 - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language zh_CN - */ - var Event = (function (_super) { - __extends(Event, _super); - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param data the optional data associated with this event - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param data 与此事件对象关联的可选数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Event(type, bubbles, cancelable, data) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$eventPhase = 2; - /** - * @private - */ - _this.$currentTarget = null; - /** - * @private - */ - _this.$target = null; - /** - * @private - */ - _this.$isDefaultPrevented = false; - /** - * @private - */ - _this.$isPropagationStopped = false; - /** - * @private - */ - _this.$isPropagationImmediateStopped = false; - _this.$type = type; - _this.$bubbles = !!bubbles; - _this.$cancelable = !!cancelable; - _this.data = data; - return _this; - } - Object.defineProperty(Event.prototype, "type", { - /** - * The type of event. The type is case-sensitive. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件的类型。类型区分大小写。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$type; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Event.prototype, "bubbles", { - /** - * Indicates whether an event is a bubbling event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示事件是否为冒泡事件。如果事件可以冒泡,则此值为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$bubbles; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Event.prototype, "cancelable", { - /** - * Indicates whether the behavior associated with the event can be prevented. If the behavior can be - * canceled, this value is true; otherwise it is false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示是否可以阻止与事件相关联的行为。如果可以取消该行为,则此值为 true;否则为 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$cancelable; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Event.prototype, "eventPhase", { - /** - * The current phase in the event flow. This property can contain the following numeric values: - * The capture phase (EventPhase.CAPTURING_PHASE). - * The target phase (EventPhase.AT_TARGET) - * The bubbling phase (EventPhase.BUBBLING_PHASE). - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件流中的当前阶段。此属性可以包含以下数值: - * 捕获阶段 (EventPhase.CAPTURING_PHASE)。 - * 目标阶段 (EventPhase.AT_TARGET)。 - * 冒泡阶段 (EventPhase.BUBBLING_PHASE)。 - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$eventPhase; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Event.prototype, "currentTarget", { - /** - * The object that is actively processing the Event object with an event listener. For example, if a - * user clicks an OK button, the current target could be the node containing that button or one of its ancestors - * that has registered an event listener for that event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前正在使用某个事件侦听器处理 Event 对象的对象。例如,如果用户单击“确定”按钮, - * 则当前目标可以是包含该按钮的节点,也可以是它的已为该事件注册了事件侦听器的始祖之一。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$currentTarget; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Event.prototype, "target", { - /** - * The event target. This property contains the target node. For example, if a user clicks an OK button, - * the target node is the display list node containing that button. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件目标。此属性包含目标节点。例如,如果用户单击“确定”按钮,则目标节点就是包含该按钮的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$target; - }, - enumerable: true, - configurable: true - }); - Event.prototype.$setTarget = function (target) { - this.$target = target; - return true; - }; - /** - * Checks whether the preventDefault() method has been called on the event. If the preventDefault() method has been - * called, returns true; otherwise, returns false. - * @returns If preventDefault() has been called, returns true; otherwise, returns false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查是否已对事件调用 preventDefault() 方法。 - * @returns 如果已调用 preventDefault() 方法,则返回 true;否则返回 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.prototype.isDefaultPrevented = function () { - return this.$isDefaultPrevented; - }; - /** - * Cancels an event's default behavior if that behavior can be canceled.Many events have associated behaviors that - * are carried out by default. For example, if a user types a character into a text input, the default behavior - * is that the character is displayed in the text input. Because the TextEvent.TEXT_INPUT event's default behavior - * can be canceled, you can use the preventDefault() method to prevent the character from appearing. - * You can use the Event.cancelable property to check whether you can prevent the default behavior associated with - * a particular event. If the value of Event.cancelable is true, then preventDefault() can be used to cancel the event; - * otherwise, preventDefault() has no effect. - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果可以取消事件的默认行为,则取消该行为。 - * 许多事件都有默认执行的关联行为。例如,如果用户在文本字段中键入一个字符,则默认行为就是在文本字段中显示该字符。 - * 由于可以取消 TextEvent.TEXT_INPUT 事件的默认行为,因此您可以使用 preventDefault() 方法来防止显示该字符。 - * 您可以使用 Event.cancelable 属性来检查是否可以防止与特定事件关联的默认行为。如果 Event.cancelable 的值为 true, - * 则可以使用 preventDefault() 来取消事件;否则,preventDefault() 无效。 - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.prototype.preventDefault = function () { - if (this.$cancelable) - this.$isDefaultPrevented = true; - }; - /** - * Prevents processing of any event listeners in nodes subsequent to the current node in the event flow. This method - * does not affect any event listeners in the current node (currentTarget). In contrast, the stopImmediatePropagation() - * method prevents processing of event listeners in both the current node and subsequent nodes. Additional calls to this - * method have no effect. This method can be called in any phase of the event flow.
    - * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。此方法不会影响当前节点 currentTarget 中的任何事件侦听器。 - * 相比之下,stopImmediatePropagation() 方法可以防止对当前节点中和后续节点中的事件侦听器进行处理。 - * 对此方法的其它调用没有任何效果。可以在事件流的任何阶段中调用此方法。
    - * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.prototype.stopPropagation = function () { - if (this.$bubbles) - this.$isPropagationStopped = true; - }; - /** - * Prevents processing of any event listeners in the current node and any subsequent nodes in the event flow. - * This method takes effect immediately, and it affects event listeners in the current node. In contrast, the - * stopPropagation() method doesn't take effect until all the event listeners in the current node finish processing.
    - * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。此方法会立即生效,并且会影响当前节点中的事件侦听器。 - * 相比之下,在当前节点中的所有事件侦听器都完成处理之前,stopPropagation() 方法不会生效。
    - * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.prototype.stopImmediatePropagation = function () { - if (this.$bubbles) - this.$isPropagationImmediateStopped = true; - }; - /** - * This method will be called automatically when you pass the event object as the parameters to the Event.release() method. - * If your custom event is designed for reusable,you should override this method to make sure all the references to external - * objects are cleaned. if not,it may cause memory leaking. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当事件实例传递给Event.release()静态方法时,实例上的clean()方法将会被自动调用。 - * 若此自定义事件的实例设计为可以循环复用的,为了避免引起内存泄露,自定义事件需要覆盖此方法来确保实例被缓存前断开对外部对象的一切引用。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.prototype.clean = function () { - this.data = this.$currentTarget = null; - this.$setTarget(null); - }; - /** - * EventDispatcher object using the specified event object thrown Event. Objects thrown objects will be cached in the pool for the next round robin. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 EventDispatcher 对象来抛出 Event 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.dispatchEvent = function (target, type, bubbles, data) { - if (bubbles === void 0) { bubbles = false; } - var event = Event.create(Event, type, bubbles); - var props = Event._getPropertyData(Event); - if (data != undefined) { - props.data = data; - } - var result = target.dispatchEvent(event); - Event.release(event); - return result; - }; - /** - * @private - * - * @param EventClass - * @returns - */ - Event._getPropertyData = function (EventClass) { - var props = EventClass._props; - if (!props) - props = EventClass._props = {}; - return props; - }; - /** - * Gets one event instance from the object pool or create a new one. We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
    - * Note: If you want to use this method to initialize your custom event object,you must make sure the constructor - * of your custom event is the same as the constructor of egret.Event. - * @param EventClass Event Class。 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @example - *
    -         *    let event = Event.create(Event,type, bubbles);
    -         *    event.data = data;    //optional,initializes custom data here
    -         *    this.dispatchEvent(event);
    -         *    Event.release(event);
    -         * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的事件实例。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
    - * 注意:若使用此方法来创建自定义事件的实例,自定义的构造函数参数列表必须跟Event类一致。 - * @param EventClass Event类名。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @example - *
    -         *    let event = Event.create(Event,type, bubbles);
    -         *    event.data = data;  //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
    -         *    this.dispatchEvent(event);
    -         *    Event.release(event);
    -         * 
    - * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.create = function (EventClass, type, bubbles, cancelable) { - var eventPool; - var hasEventPool = EventClass.hasOwnProperty("eventPool"); - if (hasEventPool) { - eventPool = EventClass.eventPool; - } - if (!eventPool) { - eventPool = EventClass.eventPool = []; - } - if (eventPool.length) { - var event_2 = eventPool.pop(); - event_2.$type = type; - event_2.$bubbles = !!bubbles; - event_2.$cancelable = !!cancelable; - event_2.$isDefaultPrevented = false; - event_2.$isPropagationStopped = false; - event_2.$isPropagationImmediateStopped = false; - event_2.$eventPhase = 2 /* AT_TARGET */; - return event_2; - } - return new EventClass(type, bubbles, cancelable); - }; - /** - * Releases an event object and cache it into the object pool.We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
    - * Note: The parameters of this method only accepts an instance created by the Event.create() method. - * if not,it may throw an error. - * @example - *
    -         *    let event = Event.create(Event,type, bubbles);
    -         *    event.data = data; //optional,initializes custom data here
    -         *    this.dispatchEvent(event);
    -         *    Event.release(event);
    -         * 
    - * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个事件对象,并缓存到对象池。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
    - * 注意:此方法只能传入由Event.create()创建的事件实例,传入非法对象实例可能会导致报错。 - * @example - *
    -         *    let event = Event.create(Event,type, bubbles);
    -         *    event.data = data;   //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
    -         *    this.dispatchEvent(event);
    -         *    Event.release(event);
    -         * 
    - * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.release = function (event) { - event.clean(); - var EventClass = Object.getPrototypeOf(event).constructor; - EventClass.eventPool.push(event); - }; - /** - * Dispatched when a display object is added to the on stage display list, either directly or through the addition - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.ADDED_TO_STAGE = "addedToStage"; - /** - * Dispatched when a display object is about to be removed from the display list, either directly or through the removal - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.REMOVED_FROM_STAGE = "removedFromStage"; - /** - * Dispatched when a display object is added to the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象添加到显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.ADDED = "added"; - /** - * Dispatched when a display object is about to be removed from the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将要从显示列表中删除显示对象时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.REMOVED = "removed"; - /** - * [broadcast event] Dispatched when the playhead is entering a new frame. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * [广播事件] 进入新的一帧,监听此事件将会在下一帧开始时触发一次回调。这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.ENTER_FRAME = "enterFrame"; - /** - * Dispatched when the display list is about to be updated and rendered. - * Note: Every time you want to receive a render event,you must call the stage.invalidate() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 渲染事件,监听此事件将会在本帧末即将开始渲染的前一刻触发回调,这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * 注意:每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 stage.invalidate() 方法,由于每帧只会触发一次屏幕刷新, - * 若在 Event.RENDER 回调函数执行期间再次调用stage.invalidate(),将会被忽略。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.RENDER = "render"; - /** - * Dispatched when the size of stage or UIComponent is changed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台尺寸或UI组件尺寸发生改变 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.RESIZE = "resize"; - /** - * Dispatched when the value or selection of a property is chaned. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态发生改变。通常是按钮的选中状态,或者列表的选中项索引改变。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.CHANGE = "change"; - /** - * Dispatched when the value or selection of a property is going to change.you can cancel this by calling the - * preventDefault() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态即将发生改变,通常是按钮的选中状态,或者列表的选中项索引改变。可以通过调用 preventDefault() 方法阻止索引发生更改。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.CHANGING = "changing"; - /** - * Dispatched when the net request is complete. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 网络请求加载完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.COMPLETE = "complete"; - /** - * Dispatched when loop completed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 循环完成。循环最后一次只派发 COMPLETE 事件,不派发 LOOP_COMPLETE 事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.LOOP_COMPLETE = "loopComplete"; - /** - * Dispatched when the TextInput instance gets focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.FOCUS_IN = "focusIn"; - /** - * Dispatched when the TextInput instance loses focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.FOCUS_OUT = "focusOut"; - /** - * Dispatched when the playback is ended. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 动画声音等播放完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Event.ENDED = "ended"; - /** - * 游戏激活 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.ACTIVATE = "activate"; - /** - * 取消激活 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.DEACTIVATE = "deactivate"; - /** - * Event.CLOSE 常量定义 close 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.CLOSE = "close"; - /** - * Event.CONNECT 常量定义 connect 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.CONNECT = "connect"; - /** - * Event.LEAVE_STAGE 常量定义 leaveStage 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.LEAVE_STAGE = "leaveStage"; - /** - * Event.SOUND_COMPLETE 常量定义 在声音完成播放后调度。 - * @version Egret 2.4 - * @platform Web,Native - */ - Event.SOUND_COMPLETE = "soundComplete"; - return Event; - }(egret.HashObject)); - egret.Event = Event; - __reflect(Event.prototype, "egret.Event"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -global.DEBUG = true; -global.RELEASE = false; -var egret; -(function (egret) { - /** - * @private - */ - function _getString(code) { - var params = []; - for (var _i = 1; _i < arguments.length; _i++) { - params[_i - 1] = arguments[_i]; - } - return egret.sys.tr.apply(egret.sys, arguments); - } - egret.getString = _getString; - function _error(code) { - var params = []; - for (var _i = 1; _i < arguments.length; _i++) { - params[_i - 1] = arguments[_i]; - } - var text = egret.sys.tr.apply(null, arguments); - if (true) { - egret.sys.$errorToFPS("Error #" + code + ": " + text); - } - throw new Error("#" + code + ": " + text); //使用这种方式报错能够终止后续代码继续运行 - } - egret.$error = _error; - function _warn(code) { - var params = []; - for (var _i = 1; _i < arguments.length; _i++) { - params[_i - 1] = arguments[_i]; - } - var text = egret.sys.tr.apply(null, arguments); - if (true) { - egret.sys.$warnToFPS("Warning #" + code + ": " + text); - } - egret.warn("Warning #" + code + ": " + text); - } - egret.$warn = _warn; - function _markReadOnly(instance, property, isProperty) { - if (isProperty === void 0) { isProperty = true; } - var data = Object.getOwnPropertyDescriptor(isProperty ? instance.prototype : instance, property); - if (data == null) { - console.log(instance); - return; - } - data.set = function (value) { - if (isProperty) { - egret.$warn(1010, egret.getQualifiedClassName(instance), property); - } - else { - egret.$warn(1014, egret.getQualifiedClassName(instance), property); - } - }; - Object.defineProperty(instance.prototype, property, data); - } - function markCannotUse(instance, property, defaultValue) { - Object.defineProperty(instance.prototype, property, { - get: function () { - egret.$warn(1009, egret.getQualifiedClassName(instance), property); - return defaultValue; - }, - set: function (value) { - egret.$error(1009, egret.getQualifiedClassName(instance), property); - }, - enumerable: true, - configurable: true - }); - } - egret.$markCannotUse = markCannotUse; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var pointPool = []; - var DEG_TO_RAD = Math.PI / 180; - /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal - * axis and y represents the vertical axis. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language en_US - */ - /** - * Point 对象表示二维坐标系统中的某个位置,其中 x 表示水平轴,y 表示垂直轴。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language zh_CN - */ - var Point = (function (_super) { - __extends(Point, _super); - /** - * Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Point(x, y) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - var _this = _super.call(this) || this; - _this.x = x; - _this.y = y; - return _this; - } - /** - * Releases a point instance to the object pool - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Point实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.release = function (point) { - if (!point) { - return; - } - pointPool.push(point); - }; - /** - * get a point instance from the object pool or create a new one. - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Point对象。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.create = function (x, y) { - var point = pointPool.pop(); - if (!point) { - point = new Point(); - } - return point.setTo(x, y); - }; - Object.defineProperty(Point.prototype, "length", { - /** - * The length of the line segment from (0,0) to this point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 (0,0) 到此点的线段长度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return Math.sqrt(this.x * this.x + this.y * this.y); - }, - enumerable: true, - configurable: true - }); - /** - * Sets the members of Point to the specified values - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 的成员设置为指定值 - * @param x 该对象的x属性值 - * @param y 该对象的y属性值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.setTo = function (x, y) { - this.x = x; - this.y = y; - return this; - }; - /** - * Creates a copy of this Point object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 克隆点对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.clone = function () { - return new Point(this.x, this.y); - }; - /** - * Determines whether two points are equal. Two points are equal if they have the same x and y values. - * @param toCompare The point to be compared. - * @returns A value of true if the object is equal to this Point object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个点是否相同。如果两个点具有相同的 x 和 y 值,则它们是相同的点。 - * @param toCompare 要比较的点。 - * @returns 如果该对象与此 Point 对象相同,则为 true 值,如果不相同,则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.equals = function (toCompare) { - return this.x == toCompare.x && this.y == toCompare.y; - }; - /** - * Returns the distance between pt1 and pt2. - * @param p1 The first point. - * @param p2 The second point. - * @returns The distance between the first and second points. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 pt1 和 pt2 之间的距离。 - * @param p1 第一个点 - * @param p2 第二个点 - * @returns 第一个点和第二个点之间的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.distance = function (p1, p2) { - return Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)); - }; - /** - * Copies all of the point data from the source Point object into the calling Point object. - * @param sourcePoint The Point object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Point 对象中的所有点数据复制到调用方 Point 对象中。 - * @param sourcePoint 要从中复制数据的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.copyFrom = function (sourcePoint) { - this.x = sourcePoint.x; - this.y = sourcePoint.y; - }; - /** - * Adds the coordinates of another point to the coordinates of this point to create a new point. - * @param v The point to be added. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将另一个点的坐标添加到此点的坐标以创建一个新点。 - * @param v 要添加的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.add = function (v) { - return new Point(this.x + v.x, this.y + v.y); - }; - /** - * Determines a point between two specified points. - * The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2. The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2). - * @param pt1 The first point. - * @param pt2 The second point. - * @param f The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned. - * @returns The new interpolated point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个指定点之间的点。 - * 参数 f 确定新的内插点相对于参数 pt1 和 pt2 指定的两个端点所处的位置。参数 f 的值越接近 1.0,则内插点就越接近第一个点(参数 pt1)。参数 f 的值越接近 0,则内插点就越接近第二个点(参数 pt2)。 - * @param pt1 第一个点。 - * @param pt2 第二个点。 - * @param f 两个点之间的内插级别。表示新点将位于 pt1 和 pt2 连成的直线上的什么位置。如果 f=1,则返回 pt1;如果 f=0,则返回 pt2。 - * @returns 新的内插点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.interpolate = function (pt1, pt2, f) { - var f1 = 1 - f; - return new Point(pt1.x * f + pt2.x * f1, pt1.y * f + pt2.y * f1); - }; - /** - * Scales the line segment between (0,0) and the current point to a set length. - * @param thickness The scaling value. For example, if the current point is (0,5), and you normalize it to 1, the point returned is at (0,1). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 (0,0) 和当前点之间的线段缩放为设定的长度。 - * @param thickness 缩放值。例如,如果当前点为 (0,5) 并且您将它规范化为 1,则返回的点位于 (0,1) 处。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.normalize = function (thickness) { - if (this.x != 0 || this.y != 0) { - var relativeThickness = thickness / this.length; - this.x *= relativeThickness; - this.y *= relativeThickness; - } - }; - /** - * Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value. - * @param dx The amount by which to offset the horizontal coordinate, x. - * @param dy The amount by which to offset the vertical coordinate, y. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量偏移 Point 对象。dx 的值将添加到 x 的原始值中以创建新的 x 值。dy 的值将添加到 y 的原始值中以创建新的 y 值。 - * @param dx 水平坐标 x 的偏移量。 - * @param dy 水平坐标 y 的偏移量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.offset = function (dx, dy) { - this.x += dx; - this.y += dy; - }; - /** - * Converts a pair of polar coordinates to a Cartesian point coordinate. - * @param len The length coordinate of the polar pair. - * @param angle The angle, in radians, of the polar pair. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一对极坐标转换为笛卡尔点坐标。 - * @param len 极坐标对的长度。 - * @param angle 极坐标对的角度(以弧度表示)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.polar = function (len, angle) { - return new Point(len * egret.NumberUtils.cos(angle / DEG_TO_RAD), len * egret.NumberUtils.sin(angle / DEG_TO_RAD)); - }; - /** - * Subtracts the coordinates of another point from the coordinates of this point to create a new point. - * @param v The point to be subtracted. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从此点的坐标中减去另一个点的坐标以创建一个新点。 - * @param v 要减去的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.subtract = function (v) { - return new Point(this.x - v.x, this.y - v.y); - }; - /** - * Returns a string that contains the values of the x and y coordinates. The string has the form "(x=x, y=y)", so calling the toString() method for a point at 23,17 would return "(x=23, y=17)". - * @returns The string representation of the coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回包含 x 和 y 坐标的值的字符串。该字符串的格式为 "(x=x, y=y)",因此为点 23,17 调用 toString() 方法将返回 "(x=23, y=17)"。 - * @returns 坐标的字符串表示形式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Point.prototype.toString = function () { - return "(x=" + this.x + ", y=" + this.y + ")"; - }; - return Point; - }(egret.HashObject)); - egret.Point = Point; - __reflect(Point.prototype, "egret.Point"); - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - egret.$TempPoint = new Point(); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The DisplayObjectContainer class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language en_US - */ - /** - * DisplayObjectContainer 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language zh_CN - */ - var DisplayObjectContainer = (function (_super) { - __extends(DisplayObjectContainer, _super); - /** - * Creates a new DisplayObjectContainer instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function DisplayObjectContainer() { - var _this = _super.call(this) || this; - _this.$touchChildren = true; - _this.$children = []; - return _this; - } - Object.defineProperty(DisplayObjectContainer.prototype, "numChildren", { - /** - * Returns the number of children of this object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此对象的子项数目。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$children.length; - }, - enumerable: true, - configurable: true - }); - /** - * Set children sort mode. - * @param value {string} The sort mode - * @see egret.ChildrenSortMode - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - /** - * 设置子项目的排序方式 - * @param value {string} 排序方式 - * @see egret.ChildrenSortMode - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - DisplayObjectContainer.prototype.setChildrenSortMode = function (value) { - if (egret.nativeRender && this.$nativeDisplayObject.setChildrenSortMode) { - this.$nativeDisplayObject.setChildrenSortMode(value); - } - }; - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added to the front - * (top) of all other children in this DisplayObjectContainer instance. (To add a child to a specific index position, - * use the addChildAt() method.)If you add a child object that already has a different display object container - * as a parent, the object is removed from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @returns 在 child The DisplayObject instance that you pass in the child parameter. - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。子项将被添加到该 DisplayObjectContainer 实例中其他 - * 所有子项的前(上)面。(要将某子项添加到特定索引位置,请使用 addChildAt() 方法。) - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.addChild = function (child) { - var index = this.$children.length; - if (child.$parent == this) - index--; - return this.$doAddChild(child, index); - }; - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added at the index position - * specified. An index of 0 represents the back (bottom) of the display list for this DisplayObjectContainer object. - * If you add a child object that already has a different display object container as a parent, the object is removed - * from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @param index The index position to which the child is added. If you specify a currently occupied index position, - * the child object that exists at that position and all higher positions are moved up one position in the child list. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。该子项将被添加到指定的索引位置。索引为 0 表示该 - * DisplayObjectContainer 对象的显示列表的后(底)部。如果添加一个已将其它显示对象容器作为父项的子对象,则会从其它显示对象容器的子列表中删除该对象。 - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @param index 添加该子项的索引位置。 如果指定当前占用的索引位置,则该位置以及所有更高位置上的子对象会在子级列表中上移一个位置。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.addChildAt = function (child, index) { - index = +index | 0; - if (index < 0 || index >= this.$children.length) { - index = this.$children.length; - if (child.$parent == this) { - index--; - } - } - return this.$doAddChild(child, index); - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$doAddChild = function (child, index, notifyListeners) { - if (notifyListeners === void 0) { notifyListeners = true; } - var self = this; - if (true) { - if (child == self) { - egret.$error(1005); - } - else if ((child instanceof egret.DisplayObjectContainer) && child.contains(self)) { - egret.$error(1004); - } - } - var host = child.$parent; - if (host == self) { - self.doSetChildIndex(child, index); - return child; - } - if (host) { - host.removeChild(child); - } - self.$children.splice(index, 0, child); - child.$setParent(self); - if (egret.nativeRender) { - self.$nativeDisplayObject.addChildAt(child.$nativeDisplayObject.id, index); - } - var stage = self.$stage; - if (stage) { - child.$onAddToStage(stage, self.$nestLevel + 1); - } - if (notifyListeners) { - child.dispatchEventWith(egret.Event.ADDED, true); - } - if (stage) { - var list = DisplayObjectContainer.$EVENT_ADD_TO_STAGE_LIST; - while (list.length) { - var childAddToStage = list.shift(); - if (childAddToStage.$stage && notifyListeners) { - childAddToStage.dispatchEventWith(egret.Event.ADDED_TO_STAGE); - } - } - } - if (!egret.nativeRender) { - if (child.$maskedObject) { - child.$maskedObject.$updateRenderMode(); - } - if (!self.$cacheDirty) { - self.$cacheDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - } - this.$childAdded(child, index); - return child; - }; - /** - * Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance - * itself. The search includes the entire display list including this DisplayObjectContainer instance. Grandchildren, - * great-grandchildren, and so on each return true. - * @param child The child object to test. - * @returns true if the child object is a child of the DisplayObjectContainer or the container itself; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定指定显示对象是 DisplayObjectContainer 实例的子项或该实例本身。搜索包括整个显示列表(其中包括此 DisplayObjectContainer 实例)。 - * 孙项、曾孙项等,每项都返回 true。 - * @param child 要测试的子对象。 - * @returns 如果 child 对象是 DisplayObjectContainer 的子项或容器本身,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.contains = function (child) { - while (child) { - if (child == this) { - return true; - } - child = child.$parent; - } - return false; - }; - /** - * Returns the child display object instance that exists at the specified index. - * @param index The index position of the child object. - * @returns The child display object at the specified index position. - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回位于指定索引处的子显示对象实例。 - * @param index 子对象的索引位置。 - * @returns 位于指定索引位置处的子显示对象。 - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.getChildAt = function (index) { - index = +index | 0; - if (index >= 0 && index < this.$children.length) { - return this.$children[index]; - } - else { - true && egret.$error(1007); - return null; - } - }; - /** - * Returns the index position of a child DisplayObject instance. - * @param child The DisplayObject instance to identify. - * @returns The index position of the child display object to identify. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 DisplayObject 的 child 实例的索引位置。 - * @param child 要测试的子对象。 - * @returns 要查找的子显示对象的索引位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.getChildIndex = function (child) { - return this.$children.indexOf(child); - }; - /** - * Returns the child display object that exists with the specified name. If more that one child display object has - * the specified name, the method returns the first object in the child list.The getChildAt() method is faster than - * the getChildByName() method. The getChildAt() method accesses a child from a cached array, whereas the getChildByName() - * method has to traverse a linked list to access a child. - * @param name The name of the child to return. - * @returns The child display object with the specified name. - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回具有指定名称的子显示对象。如果多个子显示对象具有指定名称,则该方法会返回子级列表中的第一个对象。 - * getChildAt() 方法比 getChildByName() 方法快。getChildAt() 方法从缓存数组中访问子项,而 getChildByName() 方法则必须遍历链接的列表来访问子项。 - * @param name 要返回的子项的名称。 - * @returns 具有指定名称的子显示对象。 - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.getChildByName = function (name) { - var children = this.$children; - var length = children.length; - var displayObject; - for (var i = 0; i < length; i++) { - displayObject = children[i]; - if (displayObject.name == name) { - return displayObject; - } - } - return null; - }; - /** - * Removes the specified child DisplayObject instance from the child list of the DisplayObjectContainer instance. - * The parent property of the removed child is set to null , and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are - * decreased by 1. - * @param child The DisplayObject instance to remove. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子列表中删除指定的 child DisplayObject 实例。将已删除子项的 parent 属性设置为 null; - * 如果不存在对该子项的任何其它引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param child 要删除的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.removeChild = function (child) { - var index = this.$children.indexOf(child); - if (index >= 0) { - return this.$doRemoveChild(index); - } - else { - true && egret.$error(1006); - return null; - } - }; - /** - * Removes a child DisplayObject from the specified index position in the child list of the DisplayObjectContainer. - * The parent property of the removed child is set to null, and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are decreased by 1. - * @param index The child index of the DisplayObject to remove. - * @returns The DisplayObject instance that was removed. - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 的子列表中指定的 index 位置删除子 DisplayObject。将已删除子项的 parent 属性设置为 null; - * 如果没有对该子项的任何其他引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param index 要删除的 DisplayObject 的子索引。 - * @returns 已删除的 DisplayObject 实例。 - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.removeChildAt = function (index) { - index = +index | 0; - if (index >= 0 && index < this.$children.length) { - return this.$doRemoveChild(index); - } - else { - true && egret.$error(1007); - return null; - } - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$doRemoveChild = function (index, notifyListeners) { - if (notifyListeners === void 0) { notifyListeners = true; } - index = +index | 0; - var self = this; - var children = this.$children; - var child = children[index]; - this.$childRemoved(child, index); - if (notifyListeners) { - child.dispatchEventWith(egret.Event.REMOVED, true); - } - if (this.$stage) { - child.$onRemoveFromStage(); - var list = DisplayObjectContainer.$EVENT_REMOVE_FROM_STAGE_LIST; - while (list.length > 0) { - var childAddToStage = list.shift(); - if (notifyListeners && childAddToStage.$hasAddToStage) { - childAddToStage.$hasAddToStage = false; - childAddToStage.dispatchEventWith(egret.Event.REMOVED_FROM_STAGE); - } - childAddToStage.$hasAddToStage = false; - childAddToStage.$stage = null; - } - } - var displayList = this.$displayList || this.$parentDisplayList; - child.$setParent(null); - var indexNow = children.indexOf(child); - if (indexNow != -1) { - children.splice(indexNow, 1); - } - if (egret.nativeRender) { - self.$nativeDisplayObject.removeChild(child.$nativeDisplayObject.id); - } - else { - if (child.$maskedObject) { - child.$maskedObject.$updateRenderMode(); - } - if (!self.$cacheDirty) { - self.$cacheDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - } - return child; - }; - /** - * Changes the position of an existing child in the display object container. This affects the layering of child objects. - * @param child The child DisplayObject instance for which you want to change the index number. - * @param index The resulting index number for the child display object. - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改现有子项在显示对象容器中的位置。这会影响子对象的分层。 - * @param child 要为其更改索引编号的 DisplayObject 子实例。 - * @param index 生成的 child 显示对象的索引编号。当新的索引编号小于0或大于已有子元件数量时,新加入的DisplayObject对象将会放置于最上层。 - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.setChildIndex = function (child, index) { - index = +index | 0; - if (index < 0 || index >= this.$children.length) { - index = this.$children.length - 1; - } - this.doSetChildIndex(child, index); - }; - /** - * @private - */ - DisplayObjectContainer.prototype.doSetChildIndex = function (child, index) { - var self = this; - var lastIndex = this.$children.indexOf(child); - if (lastIndex < 0) { - true && egret.$error(1006); - } - if (lastIndex == index) { - return; - } - this.$childRemoved(child, lastIndex); - //从原来的位置删除 - this.$children.splice(lastIndex, 1); - //放到新的位置 - this.$children.splice(index, 0, child); - this.$childAdded(child, index); - if (egret.nativeRender) { - this.$nativeDisplayObject.removeChild(child.$nativeDisplayObject.id); - this.$nativeDisplayObject.addChildAt(child.$nativeDisplayObject.id, index); - } - else { - if (!self.$cacheDirty) { - self.$cacheDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - } - }; - /** - * Swaps the z-order (front-to-back order) of the child objects at the two specified index positions in the child - * list. All other child objects in the display object container remain in the same index positions. - * @param index1 The index position of the first child object. - * @param index2 The index position of the second child object. - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在子级列表中两个指定的索引位置,交换子对象的 Z 轴顺序(前后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param index1 第一个子对象的索引位置。 - * @param index2 第二个子对象的索引位置。 - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.swapChildrenAt = function (index1, index2) { - index1 = +index1 | 0; - index2 = +index2 | 0; - if (index1 >= 0 && index1 < this.$children.length && index2 >= 0 && index2 < this.$children.length) { - this.doSwapChildrenAt(index1, index2); - } - else { - true && egret.$error(1007); - } - }; - /** - * Swaps the z-order (front-to-back order) of the two specified child objects. All other child objects in the - * display object container remain in the same index positions. - * @param child1 The first child object. - * @param child2 The second child object. - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 交换两个指定子对象的 Z 轴顺序(从前到后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param child1 第一个子对象。 - * @param child2 第二个子对象。 - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.swapChildren = function (child1, child2) { - var index1 = this.$children.indexOf(child1); - var index2 = this.$children.indexOf(child2); - if (index1 == -1 || index2 == -1) { - true && egret.$error(1006); - } - else { - this.doSwapChildrenAt(index1, index2); - } - }; - /** - * @private - */ - DisplayObjectContainer.prototype.doSwapChildrenAt = function (index1, index2) { - var self = this; - if (index1 > index2) { - var temp = index2; - index2 = index1; - index1 = temp; - } - else if (index1 == index2) { - return; - } - var list = this.$children; - var child1 = list[index1]; - var child2 = list[index2]; - this.$childRemoved(child1, index1); - this.$childRemoved(child2, index2); - list[index1] = child2; - list[index2] = child1; - this.$childAdded(child2, index1); - this.$childAdded(child1, index2); - if (egret.nativeRender) { - this.$nativeDisplayObject.swapChild(index1, index2); - } - else { - if (!self.$cacheDirty) { - self.$cacheDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - } - }; - /** - * Removes all child DisplayObject instances from the child list of the DisplayObjectContainer instance. The parent - * property of the removed children is set to null , and the objects are garbage collected if no other references to the children exist. - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子级列表中删除所有 child DisplayObject 实例。 - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - DisplayObjectContainer.prototype.removeChildren = function () { - var children = this.$children; - for (var i = children.length - 1; i >= 0; i--) { - this.$doRemoveChild(i); - } - }; - /** - * @private - * 一个子项被添加到容器内,此方法不仅在操作addChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - DisplayObjectContainer.prototype.$childAdded = function (child, index) { - }; - /** - * @private - * 一个子项从容器内移除,此方法不仅在操作removeChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - DisplayObjectContainer.prototype.$childRemoved = function (child, index) { - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$onAddToStage = function (stage, nestLevel) { - _super.prototype.$onAddToStage.call(this, stage, nestLevel); - var children = this.$children; - var length = children.length; - nestLevel++; - for (var i = 0; i < length; i++) { - var child = this.$children[i]; - child.$onAddToStage(stage, nestLevel); - if (child.$maskedObject) { - child.$maskedObject.$updateRenderMode(); - } - } - }; - /** - * @private - * - */ - DisplayObjectContainer.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - var children = this.$children; - var length = children.length; - for (var i = 0; i < length; i++) { - var child = children[i]; - child.$onRemoveFromStage(); - } - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$measureChildBounds = function (bounds) { - var children = this.$children; - var length = children.length; - if (length == 0) { - return; - } - var xMin = 0, xMax = 0, yMin = 0, yMax = 0; - var found = false; - for (var i = -1; i < length; i++) { - var childBounds = void 0; - if (i == -1) { - childBounds = bounds; - } - else { - children[i].getBounds(egret.$TempRectangle); - children[i].$getMatrix().$transformBounds(egret.$TempRectangle); - childBounds = egret.$TempRectangle; - } - if (childBounds.isEmpty()) { - continue; - } - if (found) { - xMin = Math.min(xMin, childBounds.x); - xMax = Math.max(xMax, childBounds.x + childBounds.width); - yMin = Math.min(yMin, childBounds.y); - yMax = Math.max(yMax, childBounds.y + childBounds.height); - } - else { - found = true; - xMin = childBounds.x; - xMax = xMin + childBounds.width; - yMin = childBounds.y; - yMax = yMin + childBounds.height; - } - } - bounds.setTo(xMin, yMin, xMax - xMin, yMax - yMin); - }; - Object.defineProperty(DisplayObjectContainer.prototype, "touchChildren", { - /** - * Determines whether or not the children of the object are touch, or user input device, enabled. If an object is - * enabled, a user can interact with it by using a touch or user input device. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定对象的子级是否支持触摸或用户输入设备。如果对象支持触摸或用户输入设备,用户可以通过使用触摸或用户输入设备与之交互。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getTouchChildren(); - }, - set: function (value) { - this.$setTouchChildren(!!value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - DisplayObjectContainer.prototype.$getTouchChildren = function () { - return this.$touchChildren; - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$setTouchChildren = function (value) { - if (this.$touchChildren == value) { - return false; - } - this.$touchChildren = value; - return true; - }; - /** - * @private - */ - DisplayObjectContainer.prototype.$hitTest = function (stageX, stageY) { - if (!this.$visible) { - return null; - } - var m = this.$getInvertedConcatenatedMatrix(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - var rect = this.$scrollRect ? this.$scrollRect : this.$maskRect; - if (rect && !rect.contains(localX, localY)) { - return null; - } - if (this.$mask && !this.$mask.$hitTest(stageX, stageY)) { - return null; - } - var children = this.$children; - var found = false; - var target = null; - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.$maskedObject) { - continue; - } - target = child.$hitTest(stageX, stageY); - if (target) { - found = true; - if (target.$touchEnabled) { - break; - } - else { - target = null; - } - } - } - if (target) { - if (this.$touchChildren) { - return target; - } - return this; - } - if (found) { - return this; - } - return _super.prototype.$hitTest.call(this, stageX, stageY); - }; - DisplayObjectContainer.prototype._sortChildrenFunc = function (a, b) { - if (a.zIndex === b.zIndex) { - return a.$lastSortedIndex - b.$lastSortedIndex; - } - return a.zIndex - b.zIndex; - }; - DisplayObjectContainer.prototype.sortChildren = function () { - //关掉脏的标记 - _super.prototype.sortChildren.call(this); - this.$sortDirty = false; - //准备重新排序 - var sortRequired = false; - var children = this.$children; - var child = null; - for (var i = 0, j = children.length; i < j; ++i) { - child = children[i]; - child.$lastSortedIndex = i; - if (!sortRequired && child.zIndex !== 0) { - sortRequired = true; - } - } - if (sortRequired && children.length > 1) { - //开始排 - children.sort(this._sortChildrenFunc); - } - }; - /** - * @private - */ - DisplayObjectContainer.$EVENT_ADD_TO_STAGE_LIST = []; - /** - * @private - */ - DisplayObjectContainer.$EVENT_REMOVE_FROM_STAGE_LIST = []; - return DisplayObjectContainer; - }(egret.DisplayObject)); - egret.DisplayObjectContainer = DisplayObjectContainer; - __reflect(DisplayObjectContainer.prototype, "egret.DisplayObjectContainer"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * SpriteSheet is a mosaic of multiple sub-bitmaps, comprising a plurality of Texture objects. - * Each Texture object shares the set bitmap of SpriteSheet, but it points to its different areas. - * On WebGL / OpenGL, this operation can significantly improve performance. - * At the same time, SpriteSheet can carry out material integration easily to reduce the number of HTTP requests - * For specification of the SpriteSheet format, see the document https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language en_US - */ - /** - * SpriteSheet 是一张由多个子位图拼接而成的集合位图,它包含多个 Texture 对象。 - * 每一个 Texture 都共享 SpriteSheet 的集合位图,但是指向它的不同的区域。 - * 在WebGL / OpenGL上,这种做法可以显著提升性能 - * 同时,SpriteSheet可以很方便的进行素材整合,降低HTTP请求数量 - * SpriteSheet 格式的具体规范可以参见此文档 https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language zh_CN - */ - var SpriteSheet = (function (_super) { - __extends(SpriteSheet, _super); - /** - * Create an egret.SpriteSheet object - * @param texture {Texture} Texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.SpriteSheet 对象 - * @param texture {Texture} 纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function SpriteSheet(texture) { - var _this = _super.call(this) || this; - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置x。 - */ - _this._bitmapX = 0; - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置y。 - */ - _this._bitmapY = 0; - /** - * @private - * 纹理缓存字典 - */ - _this._textureMap = egret.createMap(); - _this.$texture = texture; - _this._bitmapX = texture.$bitmapX - texture.$offsetX; - _this._bitmapY = texture.$bitmapY - texture.$offsetY; - return _this; - } - /** - * Obtain a cached Texture object according to the specified texture name - * @param name {string} Cache the name of this Texture object - * @returns {egret.Texture} The Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据指定纹理名称获取一个缓存的 Texture 对象 - * @param name {string} 缓存这个 Texture 对象所使用的名称 - * @returns {egret.Texture} Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - SpriteSheet.prototype.getTexture = function (name) { - return this._textureMap[name]; - }; - /** - * Create a new Texture object for the specified area on SpriteSheet and cache it - * @param name {string} Cache the name of this Texture object. If the name already exists, the previous Texture object will be overwrited. - * @param bitmapX {number} Starting coordinate x of texture area on bitmapData - * @param bitmapY {number} Starting coordinate y of texture area on bitmapData - * @param bitmapWidth {number} Width of texture area on bitmapData - * @param bitmapHeight {number} Height of texture area on bitmapData - * @param offsetX {number} Starting point x for a non-transparent area of the original bitmap - * @param offsetY {number} Starting point y for a non-transparent area of the original bitmap - * @param textureWidth {number} Width of the original bitmap. If it is not passed, use the bitmapWidth value. - * @param textureHeight {number} Height of the original bitmap. If it is not passed, use the bitmapHeight value. - * @returns {egret.Texture} The created Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为 SpriteSheet 上的指定区域创建一个新的 Texture 对象并缓存它 - * @param name {string} 缓存这个 Texture 对象所使用的名称,如果名称已存在,将会覆盖之前的 Texture 对象 - * @param bitmapX {number} 纹理区域在 bitmapData 上的起始坐标x - * @param bitmapY {number} 纹理区域在 bitmapData 上的起始坐标y - * @param bitmapWidth {number} 纹理区域在 bitmapData 上的宽度 - * @param bitmapHeight {number} 纹理区域在 bitmapData 上的高度 - * @param offsetX {number} 原始位图的非透明区域 x 起始点 - * @param offsetY {number} 原始位图的非透明区域 y 起始点 - * @param textureWidth {number} 原始位图的高度,若不传入,则使用 bitmapWidth 的值。 - * @param textureHeight {number} 原始位图的宽度,若不传入,则使用 bitmapHeight 的值。 - * @returns {egret.Texture} 创建的 Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - SpriteSheet.prototype.createTexture = function (name, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight) { - if (offsetX === void 0) { offsetX = 0; } - if (offsetY === void 0) { offsetY = 0; } - if (textureWidth === void 0) { - textureWidth = offsetX + bitmapWidth; - } - if (textureHeight === void 0) { - textureHeight = offsetY + bitmapHeight; - } - var texture = new egret.Texture(); - texture.disposeBitmapData = false; - texture.$bitmapData = this.$texture.$bitmapData; - texture.$initData(this._bitmapX + bitmapX, this._bitmapY + bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, this.$texture.$sourceWidth, this.$texture.$sourceHeight); - this._textureMap[name] = texture; - return texture; - }; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - SpriteSheet.prototype.dispose = function () { - if (this.$texture) { - this.$texture.dispose(); - } - }; - return SpriteSheet; - }(egret.HashObject)); - egret.SpriteSheet = SpriteSheet; - __reflect(SpriteSheet.prototype, "egret.SpriteSheet"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - egret.$locale_strings = egret.$locale_strings || {}; - /** - * @private - */ - egret.$language = "en_US"; -})(egret || (egret = {})); -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 全局多语言翻译函数 - * @param code 要查询的字符串代码 - * @param args 替换字符串中{0}标志的参数列表 - * @returns 返回拼接后的字符串 - */ - function tr(code) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - var text = egret.$locale_strings[egret.$language][code]; - if (!text) { - return "{" + code + "}"; - } - var length = args.length; - for (var i = 0; i < length; i++) { - text = text.replace("{" + i + "}", args[i]); - } - return text; - } - sys.tr = tr; - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Bitmap class represents display objects that represent bitmap images. - * The Bitmap() constructor allows you to create a Bitmap object that contains a reference to a BitmapData object. - * After you create a Bitmap object, use the addChild() or addChildAt() method of the parent DisplayObjectContainer - * instance to place the bitmap on the display list.A Bitmap object can share its texture reference among several - * Bitmap objects, independent of translation or rotation properties. Because you can create multiple Bitmap objects - * that reference the same texture object, multiple display objects can use the same complex texture object - * without incurring the memory overhead of a texture object for each display object instance. - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language en_US - */ - /** - * Bitmap 类表示用于显示位图图片的显示对象。 - * 利用 Bitmap() 构造函数,可以创建包含对 BitmapData 对象引用的 Bitmap 对象。创建了 Bitmap 对象后, - * 使用父级 DisplayObjectContainer 实例的 addChild() 或 addChildAt() 方法可以将位图放在显示列表中。 - * 一个 Bitmap 对象可在若干 Bitmap 对象之中共享其 texture 引用,与缩放或旋转属性无关。 - * 由于能够创建引用相同 texture 对象的多个 Bitmap 对象,因此,多个显示对象可以使用相同的 texture 对象, - * 而不会因为每个显示对象实例使用一个 texture 对象而产生额外内存开销。 - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language zh_CN - */ - var Bitmap = (function (_super) { - __extends(Bitmap, _super); - /** - * Initializes a Bitmap object to refer to the specified Texture object. - * @param value The Texture object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 Texture 实例的 Bitmap 对象 - * @param value 被引用的 Texture 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Bitmap(value) { - var _this = _super.call(this) || this; - _this.$texture = null; - _this.$bitmapData = null; - _this.$bitmapX = 0; - _this.$bitmapY = 0; - _this.$bitmapWidth = 0; - _this.$bitmapHeight = 0; - _this.$offsetX = 0; - _this.$offsetY = 0; - _this.$textureWidth = 0; - _this.$textureHeight = 0; - _this.$sourceWidth = 0; - _this.$sourceHeight = 0; - _this.$smoothing = Bitmap.defaultSmoothing; - _this.$explicitBitmapWidth = NaN; - _this.$explicitBitmapHeight = NaN; - /** - * @private - */ - _this.$scale9Grid = null; - /** - * @private - */ - _this.$fillMode = "scale"; - _this._pixelHitTest = false; - _this.$renderNode = new egret.sys.NormalBitmapNode(); - _this.$setTexture(value); - if (value) { - _this.$renderNode.rotated = value.$rotated; - } - return _this; - } - Bitmap.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(1 /* BITMAP */); - }; - /** - * @private - * 显示对象添加到舞台 - */ - Bitmap.prototype.$onAddToStage = function (stage, nestLevel) { - _super.prototype.$onAddToStage.call(this, stage, nestLevel); - var texture = this.$texture; - if (texture && texture.$bitmapData) { - egret.BitmapData.$addDisplayObject(this, texture.$bitmapData); - } - }; - /** - * @private - * 显示对象从舞台移除 - */ - Bitmap.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - var texture = this.$texture; - if (texture) { - egret.BitmapData.$removeDisplayObject(this, texture.$bitmapData); - } - }; - Object.defineProperty(Bitmap.prototype, "texture", { - /** - * The Texture object being referenced. - * If you pass the constructor of type BitmapData or last set for bitmapData, this value returns null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 Texture 对象。 - * 如果传入构造函数的类型为 BitmapData 或者最后设置的为 bitmapData,则此值返回 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$texture; - }, - set: function (value) { - var self = this; - self.$setTexture(value); - if (value && self.$renderNode) { - self.$renderNode.rotated = value.$rotated; - } - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - Bitmap.prototype.$setTexture = function (value) { - var self = this; - var oldTexture = self.$texture; - if (value == oldTexture) { - return false; - } - self.$texture = value; - if (value) { - self.$refreshImageData(); - } - else { - if (oldTexture) { - egret.BitmapData.$removeDisplayObject(self, oldTexture.$bitmapData); - } - self.setImageData(null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - self.$renderDirty = true; - var p_1 = self.$parent; - if (p_1 && !p_1.$cacheDirty) { - p_1.$cacheDirty = true; - p_1.$cacheDirtyUp(); - } - var maskedObject_1 = self.$maskedObject; - if (maskedObject_1 && !maskedObject_1.$cacheDirty) { - maskedObject_1.$cacheDirty = true; - maskedObject_1.$cacheDirtyUp(); - } - if (egret.nativeRender) { - this.setBitmapDataToWasm(null); - } - return true; - } - if (self.$stage) { - if (oldTexture && oldTexture.$bitmapData) { - var oldHashCode = oldTexture.$bitmapData.hashCode; - var newHashCode = value.$bitmapData ? value.$bitmapData.hashCode : -1; - if (oldHashCode == newHashCode) { - self.$renderDirty = true; - var p_2 = self.$parent; - if (p_2 && !p_2.$cacheDirty) { - p_2.$cacheDirty = true; - p_2.$cacheDirtyUp(); - } - var maskedObject_2 = self.$maskedObject; - if (maskedObject_2 && !maskedObject_2.$cacheDirty) { - maskedObject_2.$cacheDirty = true; - maskedObject_2.$cacheDirtyUp(); - } - return true; - } - egret.BitmapData.$removeDisplayObject(self, oldTexture.$bitmapData); - } - egret.BitmapData.$addDisplayObject(self, value.$bitmapData); - } - self.$renderDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - return true; - }; - Bitmap.prototype.$setBitmapData = function (value) { - this.$setTexture(value); - }; - /** - * @private - */ - Bitmap.prototype.setBitmapDataToWasm = function (data) { - this.$nativeDisplayObject.setTexture(data); - }; - /** - * @private - */ - Bitmap.prototype.$refreshImageData = function () { - var texture = this.$texture; - if (texture) { - if (egret.nativeRender) { - this.setBitmapDataToWasm(texture); - } - this.setImageData(texture.$bitmapData, texture.$bitmapX, texture.$bitmapY, texture.$bitmapWidth, texture.$bitmapHeight, texture.$offsetX, texture.$offsetY, texture.$getTextureWidth(), texture.$getTextureHeight(), texture.$sourceWidth, texture.$sourceHeight); - } - else { - if (egret.nativeRender) { - this.setBitmapDataToWasm(null); - } - } - }; - /** - * @private - */ - Bitmap.prototype.setImageData = function (bitmapData, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, sourceWidth, sourceHeight) { - this.$bitmapData = bitmapData; - this.$bitmapX = bitmapX; - this.$bitmapY = bitmapY; - this.$bitmapWidth = bitmapWidth; - this.$bitmapHeight = bitmapHeight; - this.$offsetX = offsetX; - this.$offsetY = offsetY; - this.$textureWidth = textureWidth; - this.$textureHeight = textureHeight; - this.$sourceWidth = sourceWidth; - this.$sourceHeight = sourceHeight; - }; - Object.defineProperty(Bitmap.prototype, "scale9Grid", { - /** - * Represent a Rectangle Area that the 9 scale area of Image. - * Notice: This property is valid only when fillMode - * is BitmapFillMode.SCALE. - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形区域,它定义素材对象的九个缩放区域。 - * 注意:此属性仅在fillModeBitmapFillMode.SCALE时有效。 - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$scale9Grid; - }, - set: function (value) { - this.$setScale9Grid(value); - }, - enumerable: true, - configurable: true - }); - Bitmap.prototype.$setScale9Grid = function (value) { - var self = this; - self.$scale9Grid = value; - self.$renderDirty = true; - if (egret.nativeRender) { - if (value) { - self.$nativeDisplayObject.setScale9Grid(value.x, value.y, value.width, value.height); - } - else { - self.$nativeDisplayObject.setScale9Grid(0, 0, -1, -1); - } - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - Object.defineProperty(Bitmap.prototype, "fillMode", { - /** - * Determines how the bitmap fills in the dimensions. - *

    When set to BitmapFillMode.REPEAT, the bitmap - * repeats to fill the region.

    - *

    When set to BitmapFillMode.SCALE, the bitmap - * stretches to fill the region.

    - * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 确定位图填充尺寸的方式。 - *

    设置为 BitmapFillMode.REPEAT时,位图将重复以填充区域。

    - *

    设置为 BitmapFillMode.SCALE时,位图将拉伸以填充区域。

    - * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$fillMode; - }, - set: function (value) { - this.$setFillMode(value); - }, - enumerable: true, - configurable: true - }); - Bitmap.prototype.$setFillMode = function (value) { - var self = this; - if (value == self.$fillMode) { - return false; - } - self.$fillMode = value; - if (egret.nativeRender) { - self.$nativeDisplayObject.setBitmapFillMode(self.$fillMode); - } - else { - self.$renderDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - return true; - }; - Object.defineProperty(Bitmap.prototype, "smoothing", { - /** - * Whether or not the bitmap is smoothed when scaled. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否对位图进行平滑处理。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$smoothing; - }, - set: function (value) { - var self = this; - if (value == this.$smoothing) { - return; - } - this.$smoothing = value; - this.$renderNode.smoothing = value; - if (!egret.nativeRender) { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - Bitmap.prototype.$setWidth = function (value) { - var self = this; - if (value < 0 || value == self.$explicitBitmapWidth) { - return false; - } - self.$explicitBitmapWidth = value; - self.$renderDirty = true; - if (egret.nativeRender) { - self.$nativeDisplayObject.setWidth(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - return true; - }; - /** - * @private - * - * @param value - */ - Bitmap.prototype.$setHeight = function (value) { - var self = this; - if (value < 0 || value == self.$explicitBitmapHeight) { - return false; - } - self.$explicitBitmapHeight = value; - self.$renderDirty = true; - if (egret.nativeRender) { - self.$nativeDisplayObject.setHeight(value); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - return true; - }; - /** - * @private - * 获取显示宽度 - */ - Bitmap.prototype.$getWidth = function () { - return isNaN(this.$explicitBitmapWidth) ? this.$getContentBounds().width : this.$explicitBitmapWidth; - }; - /** - * @private - * 获取显示宽度 - */ - Bitmap.prototype.$getHeight = function () { - return isNaN(this.$explicitBitmapHeight) ? this.$getContentBounds().height : this.$explicitBitmapHeight; - }; - /** - * @private - */ - Bitmap.prototype.$measureContentBounds = function (bounds) { - if (this.$bitmapData) { - var w = !isNaN(this.$explicitBitmapWidth) ? this.$explicitBitmapWidth : this.$textureWidth; - var h = !isNaN(this.$explicitBitmapHeight) ? this.$explicitBitmapHeight : this.$textureHeight; - bounds.setTo(0, 0, w, h); - } - else { - var w = !isNaN(this.$explicitBitmapWidth) ? this.$explicitBitmapWidth : 0; - var h = !isNaN(this.$explicitBitmapHeight) ? this.$explicitBitmapHeight : 0; - bounds.setTo(0, 0, w, h); - } - }; - /** - * @private - */ - Bitmap.prototype.$updateRenderNode = function () { - if (this.$texture) { - var destW = !isNaN(this.$explicitBitmapWidth) ? this.$explicitBitmapWidth : this.$textureWidth; - var destH = !isNaN(this.$explicitBitmapHeight) ? this.$explicitBitmapHeight : this.$textureHeight; - var scale9Grid = this.scale9Grid || this.$texture["scale9Grid"]; - if (scale9Grid) { - if (this.$renderNode instanceof egret.sys.NormalBitmapNode) { - this.$renderNode = new egret.sys.BitmapNode(); - } - egret.sys.BitmapNode.$updateTextureDataWithScale9Grid(this.$renderNode, this.$bitmapData, scale9Grid, this.$bitmapX, this.$bitmapY, this.$bitmapWidth, this.$bitmapHeight, this.$offsetX, this.$offsetY, this.$textureWidth, this.$textureHeight, destW, destH, this.$sourceWidth, this.$sourceHeight, this.$smoothing); - } - else { - if (this.fillMode == egret.BitmapFillMode.REPEAT && this.$renderNode instanceof egret.sys.NormalBitmapNode) { - this.$renderNode = new egret.sys.BitmapNode(); - } - egret.sys.BitmapNode.$updateTextureData(this.$renderNode, this.$bitmapData, this.$bitmapX, this.$bitmapY, this.$bitmapWidth, this.$bitmapHeight, this.$offsetX, this.$offsetY, this.$textureWidth, this.$textureHeight, destW, destH, this.$sourceWidth, this.$sourceHeight, this.$fillMode, this.$smoothing); - } - } - }; - Object.defineProperty(Bitmap.prototype, "pixelHitTest", { - /** - * Specifies whether this object use precise hit testing by checking the alpha value of each pixel.If pixelHitTest - * is set to true,the transparent area of the bitmap will be touched through.
    - * Note:If the image is loaded from cross origin,that we can't access to the pixel data,so it might cause - * the pixelHitTest property invalid. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否开启精确像素碰撞。设置为true显示对象本身的透明区域将能够被穿透。
    - * 注意:若图片资源是以跨域方式从外部服务器加载的,将无法访问图片的像素数据,而导致此属性失效。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._pixelHitTest; - }, - set: function (value) { - this._pixelHitTest = !!value; - }, - enumerable: true, - configurable: true - }); - Bitmap.prototype.$hitTest = function (stageX, stageY) { - var target = _super.prototype.$hitTest.call(this, stageX, stageY); - if (target && this._pixelHitTest) { - var boo = this.hitTestPoint(stageX, stageY, true); - if (!boo) { - target = null; - } - } - return target; - }; - /** - * The default value of whether or not is smoothed when scaled. - * When object such as Bitmap is created,smoothing property will be set to this value. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理的默认值。 - * 在 Bitmap 等对象创建时,smoothing 属性会被设置为该值。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - Bitmap.defaultSmoothing = true; - return Bitmap; - }(egret.DisplayObject)); - egret.Bitmap = Bitmap; - __reflect(Bitmap.prototype, "egret.Bitmap"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 渲染节点基类 - */ - var RenderNode = (function () { - function RenderNode() { - /** - * 节点类型.. - */ - this.type = 0; - /** - * 绘制数据 - */ - this.drawData = []; - /** - * 绘制次数 - */ - this.renderCount = 0; - } - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - RenderNode.prototype.cleanBeforeRender = function () { - this.drawData.length = 0; - this.renderCount = 0; - }; - RenderNode.prototype.$getRenderCount = function () { - return this.renderCount; - }; - return RenderNode; - }()); - sys.RenderNode = RenderNode; - __reflect(RenderNode.prototype, "egret.sys.RenderNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 2D路径 - */ - var Path2D = (function () { - function Path2D() { - /** - * 路径类型 - */ - this.type = 0; - this.$commands = []; - this.$data = []; - this.commandPosition = 0; - this.dataPosition = 0; - /** - * 当前移动到的坐标X - * 注意:目前只有drawArc之前会被赋值 - */ - this.$lastX = 0; - /** - * 当前移动到的坐标Y - * 注意:目前只有drawArc之前会被赋值 - */ - this.$lastY = 0; - } - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - Path2D.prototype.moveTo = function (x, y) { - this.$commands[this.commandPosition++] = 1 /* MoveTo */; - var pos = this.dataPosition; - this.$data[pos++] = x; - this.$data[pos++] = y; - this.dataPosition = pos; - }; - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - Path2D.prototype.lineTo = function (x, y) { - this.$commands[this.commandPosition++] = 2 /* LineTo */; - var pos = this.dataPosition; - this.$data[pos++] = x; - this.$data[pos++] = y; - this.dataPosition = pos; - }; - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - */ - Path2D.prototype.curveTo = function (controlX, controlY, anchorX, anchorY) { - this.$commands[this.commandPosition++] = 3 /* CurveTo */; - var pos = this.dataPosition; - this.$data[pos++] = controlX; - this.$data[pos++] = controlY; - this.$data[pos++] = anchorX; - this.$data[pos++] = anchorY; - this.dataPosition = pos; - }; - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - */ - Path2D.prototype.cubicCurveTo = function (controlX1, controlY1, controlX2, controlY2, anchorX, anchorY) { - this.$commands[this.commandPosition++] = 4 /* CubicCurveTo */; - var pos = this.dataPosition; - this.$data[pos++] = controlX1; - this.$data[pos++] = controlY1; - this.$data[pos++] = controlX2; - this.$data[pos++] = controlY2; - this.$data[pos++] = anchorX; - this.$data[pos++] = anchorY; - this.dataPosition = pos; - }; - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - Path2D.prototype.drawRect = function (x, y, width, height) { - var x2 = x + width; - var y2 = y + height; - this.moveTo(x, y); - this.lineTo(x2, y); - this.lineTo(x2, y2); - this.lineTo(x, y2); - this.lineTo(x, y); - }; - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - */ - Path2D.prototype.drawRoundRect = function (x, y, width, height, ellipseWidth, ellipseHeight) { - var radiusX = (ellipseWidth * 0.5) | 0; - var radiusY = ellipseHeight ? (ellipseHeight * 0.5) | 0 : radiusX; - if (!radiusX || !radiusY) { - this.drawRect(x, y, width, height); - return; - } - var hw = width * 0.5; - var hh = height * 0.5; - if (radiusX > hw) { - radiusX = hw; - } - if (radiusY > hh) { - radiusY = hh; - } - if (hw === radiusX && hh === radiusY) { - if (radiusX === radiusY) { - this.drawCircle(x + radiusX, y + radiusY, radiusX); - } - else { - this.drawEllipse(x, y, radiusX * 2, radiusY * 2); - } - return; - } - // A-----B - // H C - // G D - // F-----E - // 从D点开始,结束在D点 - var right = x + width; - var bottom = y + height; - var xlw = x + radiusX; - var xrw = right - radiusX; - var ytw = y + radiusY; - var ybw = bottom - radiusY; - this.moveTo(right, ybw); - this.curveTo(right, bottom, xrw, bottom); - this.lineTo(xlw, bottom); - this.curveTo(x, bottom, x, ybw); - this.lineTo(x, ytw); - this.curveTo(x, y, xlw, y); - this.lineTo(xrw, y); - this.curveTo(right, y, right, ytw); - this.lineTo(right, ybw); - }; - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - */ - Path2D.prototype.drawCircle = function (x, y, radius) { - this.arcToBezier(x, y, radius, radius, 0, Math.PI * 2); - }; - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - Path2D.prototype.drawEllipse = function (x, y, width, height) { - var radiusX = width * 0.5; - var radiusY = height * 0.5; - // 移动x和y到椭圆的中心. - x += radiusX; - y += radiusY; - this.arcToBezier(x, y, radiusX, radiusY, 0, Math.PI * 2); - }; - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - */ - Path2D.prototype.drawArc = function (x, y, radius, startAngle, endAngle, anticlockwise) { - if (anticlockwise) { - if (endAngle >= startAngle) { - endAngle -= Math.PI * 2; - } - } - else { - if (endAngle <= startAngle) { - endAngle += Math.PI * 2; - } - } - this.arcToBezier(x, y, radius, radius, startAngle, endAngle, anticlockwise); - }; - /** - * 绘制一段圆弧路径 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radiusX 圆弧的半径 x。 - * @param radiusY 圆弧的半径 y。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意:必须为正数。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意:与startAngle差值必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * 注意:如果为true,endAngle必须小于startAngle,反之必须大于。 - */ - Path2D.prototype.arcToBezier = function (x, y, radiusX, radiusY, startAngle, endAngle, anticlockwise) { - var halfPI = Math.PI * 0.5; - var start = startAngle; - var end = start; - if (anticlockwise) { - end += -halfPI - (start % halfPI); - if (end < endAngle) { - end = endAngle; - } - } - else { - end += halfPI - (start % halfPI); - if (end > endAngle) { - end = endAngle; - } - } - var currentX = x + Math.cos(start) * radiusX; - var currentY = y + Math.sin(start) * radiusY; - if (this.$lastX != currentX || this.$lastY != currentY) { - this.moveTo(currentX, currentY); - } - var u = Math.cos(start); - var v = Math.sin(start); - for (var i = 0; i < 4; i++) { - var addAngle = end - start; - var a = 4 * Math.tan(addAngle / 4) / 3; - var x1 = currentX - v * a * radiusX; - var y1 = currentY + u * a * radiusY; - u = Math.cos(end); - v = Math.sin(end); - currentX = x + u * radiusX; - currentY = y + v * radiusY; - var x2 = currentX + v * a * radiusX; - var y2 = currentY - u * a * radiusY; - this.cubicCurveTo(x1, y1, x2, y2, currentX, currentY); - if (end === endAngle) { - break; - } - start = end; - if (anticlockwise) { - end = start - halfPI; - if (end < endAngle) { - end = endAngle; - } - } - else { - end = start + halfPI; - if (end > endAngle) { - end = endAngle; - } - } - } - }; - return Path2D; - }()); - sys.Path2D = Path2D; - __reflect(Path2D.prototype, "egret.sys.Path2D"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/** - * @private - */ -var egret; -(function (egret) { - //todo remove - /** - * @private - */ - egret.fontMapping = {}; -})(egret || (egret = {})); -var egret; -(function (egret) { - /** - * @private - */ - function createMap() { - var obj = Object.create(null); - obj.__v8__ = undefined; - delete obj.__v8__; - return obj; - } - egret.createMap = createMap; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @class egret.GlowFilter - * @classdesc - * 使用 GlowFilter 类可以对显示对象应用发光效果。在投影滤镜的 distance 和 angle 属性设置为 0 时,发光滤镜与投影滤镜极为相似。 - * @extends egret.Filter - * @version Egret 3.1.4 - * @platform Web,Native - */ - var GlowFilter = (function (_super) { - __extends(GlowFilter, _super); - /** - * Initializes a new GlowFilter instance. - * @method egret.GlowFilter#constructor - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 GlowFilter 对象 - * @method egret.GlowFilter#constructor - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - function GlowFilter(color, alpha, blurX, blurY, strength, quality, inner, knockout) { - if (color === void 0) { color = 0xFF0000; } - if (alpha === void 0) { alpha = 1.0; } - if (blurX === void 0) { blurX = 6.0; } - if (blurY === void 0) { blurY = 6.0; } - if (strength === void 0) { strength = 2; } - if (quality === void 0) { quality = 1; } - if (inner === void 0) { inner = false; } - if (knockout === void 0) { knockout = false; } - var _this = _super.call(this) || this; - var self = _this; - self.type = "glow"; - self.$color = color; - self.$blue = color & 0x0000FF; - self.$green = (color & 0x00ff00) >> 8; - self.$red = color >> 16; - self.$alpha = alpha; - self.$blurX = blurX; - self.$blurY = blurY; - self.$strength = strength; - self.$quality = quality; - self.$inner = inner; - self.$knockout = knockout; - self.$uniforms.color = { x: _this.$red / 255, y: _this.$green / 255, z: _this.$blue / 255, w: 1 }; - self.$uniforms.alpha = alpha; - self.$uniforms.blurX = blurX; - self.$uniforms.blurY = blurY; - self.$uniforms.strength = strength; - // this.$uniforms.quality = quality; - self.$uniforms.inner = inner ? 1 : 0; - self.$uniforms.knockout = knockout ? 0 : 1; - self.$uniforms.dist = 0; - self.$uniforms.angle = 0; - self.$uniforms.hideObject = 0; - self.onPropertyChange(); - return _this; - } - Object.defineProperty(GlowFilter.prototype, "color", { - /** - * The color of the glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 光晕颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$color; - }, - set: function (value) { - if (this.$color == value) { - return; - } - this.$color = value; - this.$blue = value & 0x0000FF; - this.$green = (value & 0x00ff00) >> 8; - this.$red = value >> 16; - this.$uniforms.color.x = this.$red / 255; - this.$uniforms.color.y = this.$green / 255; - this.$uniforms.color.z = this.$blue / 255; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "alpha", { - /** - * The alpha transparency value for the color. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 颜色的 Alpha 透明度值。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$alpha; - }, - set: function (value) { - if (this.$alpha == value) { - return; - } - this.$alpha = value; - this.$uniforms.alpha = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "blurX", { - /** - * The amount of horizontal blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$blurX; - }, - set: function (value) { - var self = this; - if (self.$blurX == value) { - return; - } - self.$blurX = value; - self.$uniforms.blurX = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "blurY", { - /** - * The amount of vertical blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$blurY; - }, - set: function (value) { - var self = this; - if (self.$blurY == value) { - return; - } - self.$blurY = value; - self.$uniforms.blurY = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "strength", { - /** - * The strength of the imprint or spread. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 印记或跨页的强度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$strength; - }, - set: function (value) { - if (this.$strength == value) { - return; - } - this.$strength = value; - this.$uniforms.strength = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "quality", { - /** - * The number of times to apply the filter. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 应用滤镜的次数。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$quality; - }, - set: function (value) { - if (this.$quality == value) { - return; - } - this.$quality = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "inner", { - /** - * Specifies whether the glow is an inner glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定发光是否为内侧发光。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$inner; - }, - set: function (value) { - if (this.$inner == value) { - return; - } - this.$inner = value; - this.$uniforms.inner = value ? 1 : 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GlowFilter.prototype, "knockout", { - /** - * Specifies whether the object has a knockout effect. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定对象是否具有挖空效果。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$knockout; - }, - set: function (value) { - if (this.$knockout == value) { - return; - } - this.$knockout = value; - this.$uniforms.knockout = value ? 0 : 1; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - GlowFilter.prototype.$toJson = function () { - return '{"color": ' + this.$color + ', "red": ' + this.$red + ', "green": ' + this.$green + ', "blue": ' + this.$blue + ', "alpha": ' + this.$alpha + ', "blurX": ' + this.$blurX + ', "blurY": ' + this.blurY + ', "strength": ' + this.$strength + ', "quality": ' + this.$quality + ', "inner": ' + this.$inner + ', "knockout": ' + this.$knockout + '}'; - }; - GlowFilter.prototype.updatePadding = function () { - var self = this; - self.paddingLeft = self.blurX; - self.paddingRight = self.blurX; - self.paddingTop = self.blurY; - self.paddingBottom = self.blurY; - }; - return GlowFilter; - }(egret.Filter)); - egret.GlowFilter = GlowFilter; - __reflect(GlowFilter.prototype, "egret.GlowFilter"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Stage class represents the main drawing area.The Stage object is not globally accessible. You need to access - * it through the stage property of a DisplayObject instance.
    - * The Stage class has several ancestor classes — Sprite, DisplayObject, and EventDispatcher — from which it inherits - * properties and methods. Many of these properties and methods are inapplicable to Stage objects. - * @event egret.Event.RESIZE Dispatched when the stageWidth or stageHeight property of the Stage object is changed. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language en_US - */ - /** - * Stage 类代表主绘图区。 - * 可以利用 DisplayObject 实例的 stage 属性进行访问。
    - * Stage 类具有多个祖代类: Sprite、DisplayObject 和 EventDispatcher,属性和方法便是从这些类继承而来的。 - * 从这些继承的许多属性和方法不适用于 Stage 对象。 - * @event egret.Event.RESIZE 当stageWidth或stageHeight属性发生改变时调度 - * @event egret.Event.DEACTIVATE 当stage失去焦点后调度 - * @event egret.Event.ACTIVATE 当stage获得焦点后调度 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language zh_CN - */ - var Stage = (function (_super) { - __extends(Stage, _super); - /** - * @private - * Stage不许允许自行实例化 - * @version Egret 2.4 - * @platform Web,Native - */ - function Stage() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$stageWidth = 0; - /** - * @private - */ - _this.$stageHeight = 0; - _this.$scaleMode = egret.StageScaleMode.SHOW_ALL; - _this.$orientation = egret.OrientationMode.AUTO; - _this.$maxTouches = 99; - _this.$stage = _this; - _this.$nestLevel = 1; - return _this; - } - Stage.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(13 /* STAGE */); - }; - Object.defineProperty(Stage.prototype, "frameRate", { - /** - * Gets and sets the frame rate of the stage. The frame rate is defined as frames per second. Valid range for the - * frame rate is from 0.01 to 1000 frames per second.
    - * Note: setting the frameRate property of one Stage object changes the frame rate for all Stage objects - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取并设置舞台的帧速率。帧速率是指每秒显示的帧数。帧速率的有效范围为每秒 0.01 到 60 个帧。
    - * 注意: 修改任何一个Stage的frameRate属性都会同步修改其他Stage的帧率。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return egret.ticker.$frameRate; - }, - set: function (value) { - egret.ticker.$setFrameRate(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Stage.prototype, "stageWidth", { - /** - * Indicates the width of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前宽度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$stageWidth; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Stage.prototype, "stageHeight", { - /** - * Indicates the height of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$stageHeight; - }, - enumerable: true, - configurable: true - }); - /** - * After you call the invalidate() method, when the display list is next rendered, the Egret runtime sends a render - * event to each display object that has registered to listen for the render event. You must call the invalidate() - * method each time you want the Egret runtime to send render events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用 invalidate() 方法后,在显示列表下次呈现时,Egret 会向每个已注册侦听 Event.RENDER 事件的显示对象发送一个 Event.RENDER 事件。 - * 每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 invalidate() 方法。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Stage.prototype.invalidate = function () { - egret.sys.$invalidateRenderFlag = true; - }; - /** - * @deprecated - */ - Stage.prototype.registerImplementation = function (interfaceName, instance) { - egret.registerImplementation(interfaceName, instance); - }; - /** - * @deprecated - */ - Stage.prototype.getImplementation = function (interfaceName) { - return egret.getImplementation(interfaceName); - }; - Object.defineProperty(Stage.prototype, "scaleMode", { - /** - * A StageScaleMode class that specifies which scale mode to use. The following are valid values:
    - *
      - *
    • StageScaleMode.EXACT_FIT -- The entire application be visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur, the application may be stretched or compressed.
    • - *
    • StageScaleMode.SHOW_ALL -- The entire application is visible in the specified area without distortion while maintaining the application of the original aspect ratio. Applications may display border.
    • - *
    • StageScaleMode.NO_SCALE -- The size of the entire application is fixed, so that even if the size of the player window changes, it remains unchanged. If the player window is smaller than the content, it may do some trimming.
    • - *
    • StageScaleMode.NO_BORDER -- Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
    • - *
    • StageScaleMode.FIXED_WIDTH -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
    • - *
    • StageScaleMode.FIXED_HEIGHT -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
    • - *
    - * @default egret.StageScaleMode.SHOW_ALL - * @language en_US - */ - /** - * 一个 StageScaleMode 类中指定要使用哪种缩放模式的值。以下是有效值:
    - *
      - *
    • StageScaleMode.EXACT_FIT -- 整个应用程序在指定区域中可见,但不尝试保持原始高宽比。可能会发生扭曲,应用程序可能会拉伸或压缩显示。
    • - *
    • StageScaleMode.SHOW_ALL -- 整个应用程序在指定区域中可见,且不发生扭曲,同时保持应用程序的原始高宽比。应用程序的可能会显示边框。
    • - *
    • StageScaleMode.NO_SCALE -- 整个应用程序的大小固定,因此,即使播放器窗口的大小更改,它也会保持不变。如果播放器窗口比内容小,则可能进行一些裁切。
    • - *
    • StageScaleMode.NO_BORDER -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
    • - *
    • StageScaleMode.FIXED_WIDTH -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
    • - *
    • StageScaleMode.FIXED_HEIGHT -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
    • - *
    - * @default egret.StageScaleMode.SHOW_ALL - * @language zh_CN - */ - get: function () { - return this.$scaleMode; - }, - set: function (value) { - if (this.$scaleMode == value) { - return; - } - this.$scaleMode = value; - this.$screen.updateScreenSize(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Stage.prototype, "orientation", { - /** - * Horizontal and vertical screen display screen, can only be set under the current Native in the configuration file. A egret.OrientationMode class that specifies which display mode to use. The following are valid values:
    - *
      - *
    • egret.OrientationMode.AUTO -- Always follow the direction of application display screen, always guaranteed by the look down.
    • - *
    • egret.OrientationMode.PORTRAIT -- Applications remain portrait mode, namely horizontal screen look, the screen from left to right.
    • - *
    • egret.OrientationMode.LANDSCAPE -- Applications remain horizontal screen mode, namely vertical screen, the screen from right to left.
    • - *
    • egret.OrientationMode.LANDSCAPE_FLIPPED -- Applications remain horizontal screen mode, namely vertical screen, the screen from left to right.
    • - *
    - * @platform Web - * @version 2.4 - * @language en_US - */ - /** - * 屏幕横竖屏显示方式,目前 Native 下只能在配置文件里设置。一个 egret.OrientationMode 类中指定要使用哪种显示方式。以下是有效值:
    - *
      - *
    • egret.OrientationMode.AUTO -- 应用始终跟随屏幕的方向显示,始终保证由上往下看。
    • - *
    • egret.OrientationMode.PORTRAIT -- 应用始终保持竖屏模式,即横屏看时,屏幕由左往右看。
    • - *
    • egret.OrientationMode.LANDSCAPE -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由右往左。
    • - *
    • egret.OrientationMode.LANDSCAPE_FLIPPED -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由左往右。
    • - *
    - * @platform Web - * @version 2.4 - * @language zh_CN - */ - get: function () { - return this.$orientation; - }, - set: function (value) { - if (this.$orientation == value) { - return; - } - this.$orientation = value; - this.$screen.updateScreenSize(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Stage.prototype, "textureScaleFactor", { - /** - * Draw texture zoom ratio - * @default 1 - * @language en_US - */ - /** - * 绘制纹理的缩放比率,默认值为1 - * @default 1 - * @language zh_CN - */ - get: function () { - return egret.$TextureScaleFactor; - }, - set: function (value) { - egret.$TextureScaleFactor = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Stage.prototype, "maxTouches", { - /** - * Set the number of screens can simultaneously touch. Above this amount will not be triggered in response. - * @default 99 - * @language en_US - */ - /** - * 设置屏幕同时可以触摸的数量。高于这个数量将不会被触发响应。 - * @default 99 - * @language zh_CN - */ - get: function () { - return this.$maxTouches; - }, - set: function (value) { - if (this.$maxTouches == value) { - return; - } - this.$maxTouches = value; - this.$screen.updateMaxTouches(); - }, - enumerable: true, - configurable: true - }); - /** - * Set resolution size - * @param width width - * @param height height - * @version Egret 2.5.5 - * @platform Web,Native - * @language en_US - */ - /** - * 设置分辨率尺寸 - * @param width 宽度 - * @param height 高度 - * @version Egret 2.5.5 - * @platform Web,Native - * @language zh_CN - */ - Stage.prototype.setContentSize = function (width, height) { - this.$screen.setContentSize(width, height); - }; - return Stage; - }(egret.DisplayObjectContainer)); - egret.Stage = Stage; - __reflect(Stage.prototype, "egret.Stage"); - if (true) { - egret.$markCannotUse(Stage, "alpha", 1); - egret.$markCannotUse(Stage, "visible", true); - egret.$markCannotUse(Stage, "x", 0); - egret.$markCannotUse(Stage, "y", 0); - egret.$markCannotUse(Stage, "scaleX", 1); - egret.$markCannotUse(Stage, "scaleY", 1); - egret.$markCannotUse(Stage, "rotation", 0); - egret.$markCannotUse(Stage, "cacheAsBitmap", false); - egret.$markCannotUse(Stage, "scrollRect", null); - egret.$markCannotUse(Stage, "filters", null); - egret.$markCannotUse(Stage, "blendMode", null); - egret.$markCannotUse(Stage, "touchEnabled", true); - egret.$markCannotUse(Stage, "matrix", null); - } -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - //混合模式在Web端只有部分被支持,在 Native 中全部都支持。 - //目前所有平台的浏览器都支持的有:Layer,Alpha,Normal,Add,ERASE。 - //IOS中的所有浏览器以及Android内的部分浏览器还支持:Multiply,Screen,Lighten,Darken,Difference,Overlay,HardLight。 - //仅在 Native 端支持的有:Subtract,Invert。 - /** - * A class that provides constant values for visual blend mode effects. These constants are used in the blendMode - * property of the DisplayObject class. - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language en_US - */ - /** - * 提供混合模式可视效果的常量值的类,通常用于 DisplayObject 的 blendMode 属性上。 - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language zh_CN - */ - var BlendMode = (function () { - function BlendMode() { - } - /** - * The display object appears in front of the background. Pixel values of the display object override the pixel - * values of the background. Where the display object is transparent, the background is visible. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该显示对象出现在背景前面。显示对象的像素值会覆盖背景的像素值。在显示对象为透明的区域,背景是可见的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BlendMode.NORMAL = "normal"; - /** - * Adds the values of the constituent colors of the display object to the colors of its background, applying a - * ceiling of 0xFF. This setting is commonly used for animating a lightening dissolve between two objects.
    - * For example, if the display object has a pixel with an RGB value of 0xAAA633, and the background pixel has an - * RGB value of 0xDD2200, the resulting RGB value for the displayed pixel is 0xFFC833 (because 0xAA + 0xDD > 0xFF, - * 0xA6 + 0x22 = 0xC8, and 0x33 + 0x00 = 0x33). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的原色值添加到它的背景颜色中,上限值为 0xFF。此设置通常用于使两个对象间的加亮溶解产生动画效果。
    - * 例如,如果显示对象的某个像素的 RGB 值为 0xAAA633,背景像素的 RGB 值为 0xDD2200,则显示像素的结果 RGB 值为 0xFFC833 - * (因为 0xAA + 0xDD > 0xFF,0xA6 + 0x22 = 0xC8,且 0x33 + 0x00 = 0x33)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BlendMode.ADD = "add"; - /** - * Erases the background based on the alpha value of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据显示对象的 Alpha 值擦除背景。Alpha 值不为0的区域将被擦除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BlendMode.ERASE = "erase"; - return BlendMode; - }()); - egret.BlendMode = BlendMode; - __reflect(BlendMode.prototype, "egret.BlendMode"); -})(egret || (egret = {})); -(function (egret) { - var sys; - (function (sys) { - var blendModeString = ["normal", "add", "erase"]; - var blendModeNumber = {}; - var length = blendModeString.length; - for (var i = 0; i < length; i++) { - var str = blendModeString[i]; - blendModeNumber[str] = i; - } - /** - * @private - * 转换 blendMode 字符串为数字。 - */ - function blendModeToNumber(blendMode) { - var num = blendModeNumber[blendMode]; - return num === undefined ? 0 : num; - } - sys.blendModeToNumber = blendModeToNumber; - /** - * @private - * 转换数字为 blendMode 字符串。 - */ - function numberToBlendMode(blendMode) { - var str = blendModeString[blendMode]; - return str === undefined ? "normal" : str; - } - sys.numberToBlendMode = numberToBlendMode; - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The ChildrenSortMode class defines a pattern enumeration for children sort mode of egret.DisplayObjectContainer. - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - /** - * BitmapFillMode 类定义egret.DisplayObjectContainer的子项目排序方式。 - * @version Egret 5.2.19 - * @platform Native - * @language zh_CN - */ - egret.ChildrenSortMode = { - /** - * Default mode. - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - /** - * 默认方式。 - * @version Egret 5.2.19 - * @platform Native - * @language zh_CN - */ - DEFAULT: "default", - /** - * Y increase mode. Automatic sorted ascending by y coordinates. - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - /** - * Y递增模式。自动按y坐标升序排序。 - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - INCREASE_Y: "increaseY", - /** - * Y decrease mode. Automatic sorted descending by y coordinates. - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - /** - * Y递减模式。自动按y坐标降序排序。 - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - DECREASE_Y: "decreaseY" - }; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The CapsStyle class is an enumeration of constant values that specify the caps style to use in drawing lines. - * The constants are provided for use as values in the caps parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * CapsStyle 类是可指定在绘制线条中使用的端点样式的常量值枚举。常量可用作 egret.Graphics.lineStyle() 方法的 caps 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - egret.CapsStyle = { - /** - * Used to specify no caps in the caps parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 用于在 egret.Graphics.lineStyle() 方法的 caps 参数中指定没有端点。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - NONE: "none", - /** - * Used to specify round caps in the caps parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 用于在 egret.Graphics.lineStyle() 方法的 caps 参数中指定圆头端点。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - ROUND: "round", - /** - * Used to specify square caps in the caps parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 用于在 egret.Graphics.lineStyle() 方法的 caps 参数中指定方头端点。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - SQUARE: "square" - }; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - var WebGLUtils = (function () { - function WebGLUtils() { - } - WebGLUtils.compileProgram = function (gl, vertexSrc, fragmentSrc) { - var fragmentShader = WebGLUtils.compileFragmentShader(gl, fragmentSrc); - var vertexShader = WebGLUtils.compileVertexShader(gl, vertexSrc); - var shaderProgram = gl.createProgram(); - gl.attachShader(shaderProgram, vertexShader); - gl.attachShader(shaderProgram, fragmentShader); - gl.linkProgram(shaderProgram); - if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { - egret.$warn(1020); - } - return shaderProgram; - }; - WebGLUtils.compileFragmentShader = function (gl, shaderSrc) { - return WebGLUtils._compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER); - }; - WebGLUtils.compileVertexShader = function (gl, shaderSrc) { - return WebGLUtils._compileShader(gl, shaderSrc, gl.VERTEX_SHADER); - }; - WebGLUtils._compileShader = function (gl, shaderSrc, shaderType) { - var shader = gl.createShader(shaderType); - gl.shaderSource(shader, shaderSrc); - gl.compileShader(shader); - if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { - //egret.info(gl.getShaderInfoLog(shader)); - return null; - } - return shader; - }; - WebGLUtils.checkCanUseWebGL = function () { - if (WebGLUtils.canUseWebGL == undefined) { - try { - var canvas = document.createElement("canvas"); - WebGLUtils.canUseWebGL = !!window["WebGLRenderingContext"] - && !!(canvas.getContext("webgl") || canvas.getContext("experimental-webgl")); - } - catch (e) { - WebGLUtils.canUseWebGL = false; - } - } - return WebGLUtils.canUseWebGL; - }; - WebGLUtils.deleteWebGLTexture = function (webglTexture) { - if (!webglTexture) { - return; - } - if (webglTexture[egret.engine_default_empty_texture]) { - if (true) { - //引擎默认的空白纹理,不允许删除 - console.warn('deleteWebGLTexture:' + egret.engine_default_empty_texture); - } - return; - } - var gl = webglTexture[egret.glContext]; - if (gl) { - gl.deleteTexture(webglTexture); - } - else { - if (true) { - console.error('deleteWebGLTexture gl = ' + gl); - } - } - /*old - if (webglTexture && !webglTexture['engine_default_empty_texture']) { - const gl = webglTexture['glContext'] as WebGLRenderingContext;//bitmapData.glContext; - if (gl) { - gl.deleteTexture(webglTexture); - } - else { - console.error('deleteWebGLTexture gl = ' + gl); - } - } - */ - }; - /** - * inspired by pixi.js - */ - WebGLUtils.premultiplyTint = function (tint, alpha) { - if (alpha === 1.0) { - return (alpha * 255 << 24) + tint; - } - if (alpha === 0.0) { - return 0; - } - var R = ((tint >> 16) & 0xFF); - var G = ((tint >> 8) & 0xFF); - var B = (tint & 0xFF); - R = ((R * alpha) + 0.5) | 0; - G = ((G * alpha) + 0.5) | 0; - B = ((B * alpha) + 0.5) | 0; - return (alpha * 255 << 24) + (R << 16) + (G << 8) + B; - }; - return WebGLUtils; - }()); - egret.WebGLUtils = WebGLUtils; - __reflect(WebGLUtils.prototype, "egret.WebGLUtils"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - // export interface TextField{ - // addEventListener(type: "focusIn" | - // "focusOut" - // , listener: (this: Z, e: FocusEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number); - // addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number); - // } - /** - * When the user changes the focus from one object in the display list to another object, the object dispatches a FocusEvent object. Currently only supports input text. - * Focus events: FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用户将焦点从显示列表中的一个对象更改到另一个对象时,对象将调度 FocusEvent 对象。目前只支持输入文本。 - * 焦点事件:FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var FocusEvent = (function (_super) { - __extends(FocusEvent, _super); - /** - * Create a egret.FocusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.FocusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function FocusEvent(type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - return _super.call(this, type, bubbles, cancelable) || this; - } - /** - * Gets focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - FocusEvent.FOCUS_IN = "focusIn"; - /** - * Loses focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - FocusEvent.FOCUS_OUT = "focusOut"; - return FocusEvent; - }(egret.Event)); - egret.FocusEvent = FocusEvent; - __reflect(FocusEvent.prototype, "egret.FocusEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The GeolocationEvent represents the position and altitude of the device on Earth, - * and show errors occurred while getting the location of the device. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language en_US - */ - /** - * GeolocationEvent 提供设备的地理位置信息和获取位置时发生的错误信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language zh_CN - */ - var GeolocationEvent = (function (_super) { - __extends(GeolocationEvent, _super); - function GeolocationEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * The acquisition of the location information failed because of app don't have permission. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由于用户拒绝访问位置信息,获取位置信息失败 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - GeolocationEvent.PERMISSION_DENIED = "permissionDenied"; - /** - * The acquisition of the location failed because at least one internal source of position returned an internal error. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设备位置服务不可用或者超时等原因没有得到位置信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - GeolocationEvent.UNAVAILABLE = "unavailable"; - return GeolocationEvent; - }(egret.Event)); - egret.GeolocationEvent = GeolocationEvent; - __reflect(GeolocationEvent.prototype, "egret.GeolocationEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * When a network request returns an HTTP status code, the application dispatches HTTPStatusEvent objects. - * Before error or completion events will always send HTTPStatusEvent object. HTTPStatusEvent object does not necessarily indicate an error condition; it simply reflects the HTTP status code provided by the network stack (if any). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在网络请求返回 HTTP 状态代码时,应用程序将调度 HTTPStatusEvent 对象。 - * 在错误或完成事件之前,将始终发送 HTTPStatusEvent 对象。HTTPStatusEvent 对象不一定表示错误条件;它仅反映网络堆栈提供的 HTTP 状态代码(如果有的话)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var HTTPStatusEvent = (function (_super) { - __extends(HTTPStatusEvent, _super); - /** - * Create a egret.HTTPStatusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.HTTPStatusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function HTTPStatusEvent(type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - var _this = _super.call(this, type, bubbles, cancelable) || this; - /** - * @private - */ - _this._status = 0; - return _this; - } - Object.defineProperty(HTTPStatusEvent.prototype, "status", { - /** - * he server returns the HTTP status code. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由服务器返回的 HTTP 状态代码。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._status; - }, - enumerable: true, - configurable: true - }); - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param status {number} The server returns the HTTP status code - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param status {number} 由服务器返回的 HTTP 状态代码 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HTTPStatusEvent.dispatchHTTPStatusEvent = function (target, status) { - var event = egret.Event.create(HTTPStatusEvent, HTTPStatusEvent.HTTP_STATUS); - event._status = status; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * HTTPStatusEvent.HTTP_STATUS constant defines the value of the type property httpStatus event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HTTPStatusEvent.HTTP_STATUS 常量定义 httpStatus 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HTTPStatusEvent.HTTP_STATUS = "httpStatus"; - return HTTPStatusEvent; - }(egret.Event)); - egret.HTTPStatusEvent = HTTPStatusEvent; - __reflect(HTTPStatusEvent.prototype, "egret.HTTPStatusEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language en_US - */ - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language zh_CN - */ - var IOErrorEvent = (function (_super) { - __extends(IOErrorEvent, _super); - /** - * Create a egret.IOErrorEvent objects - * @param type {string} Type of event, accessible as Event.type. - * @param bubbles {boolean} Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable {boolean} Determine whether the Event object can be canceled. The default value is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.IOErrorEvent 对象 - * @param type {string} 事件的类型,可以作为 Event.type 访问。 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function IOErrorEvent(type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - return _super.call(this, type, bubbles, cancelable) || this; - } - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - IOErrorEvent.dispatchIOErrorEvent = function (target) { - var event = egret.Event.create(IOErrorEvent, IOErrorEvent.IO_ERROR); - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * io error - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * io发生错误 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - IOErrorEvent.IO_ERROR = "ioError"; - return IOErrorEvent; - }(egret.Event)); - egret.IOErrorEvent = IOErrorEvent; - __reflect(IOErrorEvent.prototype, "egret.IOErrorEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * MotionEvent represents the device's movement - * Acceleration and accelerationIncludingGravity to represents the device's acceleration - * RotationRate to represents the device's rotation - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language en_US - */ - /** - * MotionEvent 类呈现设备运动的具体信息 - * Acceleration 和 accelerationIncludingGravity 呈现设备三个维度的加速度信息 - * RotationRate 呈现设备的旋转状态信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language zh_CN - */ - var MotionEvent = (function (_super) { - __extends(MotionEvent, _super); - function MotionEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return MotionEvent; - }(egret.Event)); - egret.MotionEvent = MotionEvent; - __reflect(MotionEvent.prototype, "egret.MotionEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The OrientationEvent provides information from the physical orientation of the device. - * Note: Currently, Browsers on the iOS and Android does not handle the coordinates the same way. - * Take care about this while using them. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language en_US - */ - /** - * OrientationEvent 提供设备的方向信息 - * 注意: 目前各个浏览器和操作系统处理方向的方式不完全相同,请根据使用场景做相应的校正, - * 比如使用两次方向数据的变化而不是直接使用方向的值 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language zh_CN - */ - var OrientationEvent = (function (_super) { - __extends(OrientationEvent, _super); - function OrientationEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return OrientationEvent; - }(egret.Event)); - egret.OrientationEvent = OrientationEvent; - __reflect(OrientationEvent.prototype, "egret.OrientationEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * When a load operation has begun or a socket has received data, ProgressEvent object is dispatched. - * There are two types of progress events: ProgressEvent.PROGRESS and ProgressEvent.SOCKET_DATA. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当加载操作已开始或套接字已接收到数据时,将调度 ProgressEvent 对象。 - * 有两种类型的进程事件:ProgressEvent.PROGRESS 和 ProgressEvent.SOCKET_DATA。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var ProgressEvent = (function (_super) { - __extends(ProgressEvent, _super); - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function ProgressEvent(type, bubbles, cancelable, bytesLoaded, bytesTotal) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - if (bytesLoaded === void 0) { bytesLoaded = 0; } - if (bytesTotal === void 0) { bytesTotal = 0; } - var _this = _super.call(this, type, bubbles, cancelable) || this; - /** - * Number of items or bytes when the listener processes the event。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在侦听器处理事件时加载的项数或字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.bytesLoaded = 0; - /** - * If the loading process succeeds, the total number or the total number of bytes that will be loaded term. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果加载过程成功,将加载的总项数或总字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.bytesTotal = 0; - _this.bytesLoaded = bytesLoaded; - _this.bytesTotal = bytesTotal; - return _this; - } - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param type The type of the event, accessible as Event.type. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ProgressEvent.dispatchProgressEvent = function (target, type, bytesLoaded, bytesTotal) { - if (bytesLoaded === void 0) { bytesLoaded = 0; } - if (bytesTotal === void 0) { bytesTotal = 0; } - var event = egret.Event.create(ProgressEvent, type); - event.bytesLoaded = bytesLoaded; - event.bytesTotal = bytesTotal; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Changes in the loading progress - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 加载进度发生变化 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ProgressEvent.PROGRESS = "progress"; - /** - * Get the data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取到数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ProgressEvent.SOCKET_DATA = "socketData"; - return ProgressEvent; - }(egret.Event)); - egret.ProgressEvent = ProgressEvent; - __reflect(ProgressEvent.prototype, "egret.ProgressEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * When the direction of the stage of change, Stage object dispatches StageOrientationEvent object. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language en_US - */ - /** - * 当舞台的方向更改时,Stage 对象将调度 StageOrientationEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language zh_CN - */ - var StageOrientationEvent = (function (_super) { - __extends(StageOrientationEvent, _super); - /** - * Creating contains specific information related to the event and the stage direction of StageOrientationEvent object. - * @param type Event types:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles It indicates whether the Event object participates in the bubbling stage of the event flow. - * @param cancelable It indicates whether the Event object can be canceled. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建包含与舞台方向事件相关的特定信息的 StageOrientationEvent 对象。 - * @param type 事件的类型:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles 表示 Event 对象是否参与事件流的冒泡阶段。 - * @param cancelable 表示是否可以取消 Event 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function StageOrientationEvent(type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - return _super.call(this, type, bubbles, cancelable) || this; - } - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {egret.IEventDispatcher} 派发事件类型 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} Distribute event target - * @param type {egret.IEventDispatcher} Distribute event type - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - StageOrientationEvent.dispatchStageOrientationEvent = function (target, type) { - var event = egret.Event.create(StageOrientationEvent, type); - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * After screen rotation distribute events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 屏幕旋转后派发的事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - StageOrientationEvent.ORIENTATION_CHANGE = "orientationChange"; - return StageOrientationEvent; - }(egret.Event)); - egret.StageOrientationEvent = StageOrientationEvent; - __reflect(StageOrientationEvent.prototype, "egret.StageOrientationEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - // export interface TextField{ - // addEventListener(type: "link" - // , listener: (this: Z, e: TextEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number); - // addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number); - // } - /** - * When a user clicks a hyperlink rich text object dispatches TextEvent object. Text Event Type: TextEvent.LINK. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language en_US - */ - /** - * 用户在富文本中单击超链接时,对象将调度 TextEvent 对象。文本事件类型:TextEvent.LINK。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language zh_CN - */ - var TextEvent = (function (_super) { - __extends(TextEvent, _super); - /** - * TextEvent create an object that contains information about text events. - * @param type Type of event, you can access the TextEvent.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determine whether the Event object can be canceled. The default value is false. - * @param text One or more characters of text entered by the user. Event listeners can access this information through the text property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TextEvent 对象,其中包含有关文本事件的信息。 - * @param type 事件的类型,可以作为 TextEvent.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param text 用户输入的一个或多个文本字符。事件侦听器可以通过 text 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function TextEvent(type, bubbles, cancelable, text) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - if (text === void 0) { text = ""; } - var _this = _super.call(this, type, bubbles, cancelable) || this; - _this.text = text; - return _this; - } - /** - * EventDispatcher object using the specified event object thrown TextEvent. The objects will be thrown in the object cache pool for the next round robin. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param text Text TextEvent object assignment - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出TextEvent事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件类型 - * @param text TextEvent对象的text赋值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TextEvent.dispatchTextEvent = function (target, type, text) { - var event = egret.Event.create(TextEvent, type); - event.text = text; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * It defines the value of the type property of a link event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 定义 link 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TextEvent.LINK = "link"; - return TextEvent; - }(egret.Event)); - egret.TextEvent = TextEvent; - __reflect(TextEvent.prototype, "egret.TextEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * A Timer object dispatches a TimerEvent objects whenever the Timer object reaches the interval specified by the Timer.delay property. - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language en_US - */ - /** - * 每当 Timer 对象达到由 Timer.delay 属性指定的间隔时,Timer 对象即会调度 TimerEvent 对象。 - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language zh_CN - */ - var TimerEvent = (function (_super) { - __extends(TimerEvent, _super); - /** - * Creates an Event object with specific information relevant to timer events. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Event 对象,其中包含有关 timer 事件的特定信息。 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function TimerEvent(type, bubbles, cancelable) { - return _super.call(this, type, bubbles, cancelable) || this; - } - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @example - *
    -         *    function onTimer(event:TimerEvent):void {
    -         *        if (40 < mySp.x && mySp.x < 375) {
    -         *            mySp.x-= 50;
    -         *        } else {
    -         *            mySp.x=374;
    -         *        }
    -         *        event.updateAfterEvent();
    -         *    }
    -         *
    -         *    let moveTimer:Timer=new Timer(50,250);
    -         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
    -         *    moveTimer.start();
    -         * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @example - *
    -         *    function onTimer(event:TimerEvent):void {
    -         *        if (40 < mySp.x && mySp.x < 375) {
    -         *            mySp.x-= 50;
    -         *        } else {
    -         *            mySp.x=374;
    -         *        }
    -         *        event.updateAfterEvent();
    -         *    }
    -         *
    -         *    let moveTimer:Timer=new Timer(50,250);
    -         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
    -         *    moveTimer.start();
    -         * 
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TimerEvent.prototype.updateAfterEvent = function () { - egret.sys.$requestRenderingFlag = true; - }; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 事件派发目标 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TimerEvent.dispatchTimerEvent = function (target, type, bubbles, cancelable) { - var event = egret.Event.create(TimerEvent, type, bubbles, cancelable); - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Dispatched whenever a Timer object reaches an interval specified according to the Timer.delay property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当 Timer 对象达到根据 Timer.delay 属性指定的间隔时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TimerEvent.TIMER = "timer"; - /** - * Dispatched whenever it has completed the number of requests set by Timer.repeatCount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当它完成 Timer.repeatCount 设置的请求数后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TimerEvent.TIMER_COMPLETE = "timerComplete"; - return TimerEvent; - }(egret.Event)); - egret.TimerEvent = TimerEvent; - __reflect(TimerEvent.prototype, "egret.TimerEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - //refactor - var CompressedTextureData = (function () { - function CompressedTextureData() { - } - return CompressedTextureData; - }()); - egret.CompressedTextureData = CompressedTextureData; - __reflect(CompressedTextureData.prototype, "egret.CompressedTextureData"); - egret.etc_alpha_mask = 'etc_alpha_mask'; - egret.engine_default_empty_texture = 'engine_default_empty_texture'; - egret.is_compressed_texture = 'is_compressed_texture'; - egret.glContext = 'glContext'; - egret.UNPACK_PREMULTIPLY_ALPHA_WEBGL = 'UNPACK_PREMULTIPLY_ALPHA_WEBGL'; - /** - * A BitmapData object contains an array of pixel data. This data can represent either a fully opaque bitmap or a - * transparent bitmap that contains alpha channel data. Either type of BitmapData object is stored as a buffer of 32-bit - * integers. Each 32-bit integer determines the properties of a single pixel in the bitmap.
    - * Each 32-bit integer is a combination of four 8-bit channel values (from 0 to 255) that describe the alpha transparency - * and the red, green, and blue (ARGB) values of the pixel. (For ARGB values, the most significant byte represents the - * alpha channel value, followed by red, green, and blue.) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapData 对象是一个包含像素数据的数组。此数据可以表示完全不透明的位图,或表示包含 Alpha 通道数据的透明位图。 - * 以上任一类型的 BitmapData 对象都作为 32 位整数的缓冲区进行存储。每个 32 位整数确定位图中单个像素的属性。
    - * 每个 32 位整数都是四个 8 位通道值(从 0 到 255)的组合,这些值描述像素的 Alpha 透明度以及红色、绿色、蓝色 (ARGB) 值。 - * (对于 ARGB 值,最高有效字节代表 Alpha 通道值,其后的有效字节分别代表红色、绿色和蓝色通道值。) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var BitmapData = (function (_super) { - __extends(BitmapData, _super); - /** - * Initializes a BitmapData object to refer to the specified source object. - * @param source The source object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 source 实例的 BitmapData 对象 - * @param source 被引用的 source 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function BitmapData(source) { - var _this = _super.call(this) || this; - /** - * Texture format. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理格式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.format = "image"; - /** - * @private - * webgl纹理生成后,是否删掉原始图像数据 - */ - _this.$deleteSource = true; - /** - * @private - * - */ - _this.compressedTextureData = []; - _this.debugCompressedTextureURL = ''; - _this.etcAlphaMask = null; - if (egret.nativeRender) { - var nativeBitmapData = new egret_native.NativeBitmapData(); - nativeBitmapData.$init(); - _this.$nativeBitmapData = nativeBitmapData; - } - _this.source = source; - // this.width = source.width; - // this.height = source.height; - _this.source = source; - if (_this.source) { - _this.width = +source.width; - _this.height = +source.height; - } - else { - ///compressed texture? - } - return _this; - } - Object.defineProperty(BitmapData.prototype, "source", { - get: function () { - return this.$source; - }, - set: function (value) { - this.$source = value; - if (egret.nativeRender) { - egret_native.NativeDisplayObject.setSourceToNativeBitmapData(this.$nativeBitmapData, value); - } - }, - enumerable: true, - configurable: true - }); - BitmapData.create = function (type, data, callback) { - var base64 = ""; - if (type === "arraybuffer") { - base64 = egret.Base64Util.encode(data); - } - else { - base64 = data; - } - var imageType = "image/png"; //default value - if (base64.charAt(0) === '/') { - imageType = "image/jpeg"; - } - else if (base64.charAt(0) === 'R') { - imageType = "image/gif"; - } - else if (base64.charAt(0) === 'i') { - imageType = "image/png"; - } - var img = new Image(); - img.src = "data:" + imageType + ";base64," + base64; - img.crossOrigin = '*'; - var bitmapData = new BitmapData(img); - img.onload = function () { - img.onload = undefined; - bitmapData.source = img; - bitmapData.height = img.height; - bitmapData.width = img.width; - if (callback) { - callback(bitmapData); - } - }; - return bitmapData; - }; - BitmapData.prototype.$dispose = function () { - if (egret.Capabilities.renderMode == "webgl" && this.webGLTexture) { - egret.WebGLUtils.deleteWebGLTexture(this.webGLTexture); - this.webGLTexture = null; - } - //native or WebGLRenderTarget - if (this.source && this.source.dispose) { - this.source.dispose(); - } - // WeChat Memory leakage bug - if (this.source && this.source.src) { - this.source.src = ""; - } - this.source = null; - ///dispose compressed texture info - //this.bitmapCompressedData.length = 0; - this.clearCompressedTextureData(); - this.debugCompressedTextureURL = ''; - this.etcAlphaMask = null; - /// - if (egret.nativeRender) { - egret_native.NativeDisplayObject.disposeNativeBitmapData(this.$nativeBitmapData); - } - BitmapData.$dispose(this); - }; - BitmapData.$addDisplayObject = function (displayObject, bitmapData) { - if (!bitmapData) { - return; - } - var hashCode = bitmapData.hashCode; - if (!hashCode) { - return; - } - if (!BitmapData._displayList[hashCode]) { - BitmapData._displayList[hashCode] = [displayObject]; - return; - } - var tempList = BitmapData._displayList[hashCode]; - if (tempList.indexOf(displayObject) < 0) { - tempList.push(displayObject); - } - }; - BitmapData.$removeDisplayObject = function (displayObject, bitmapData) { - if (!bitmapData) { - return; - } - var hashCode = bitmapData.hashCode; - if (!hashCode) { - return; - } - if (!BitmapData._displayList[hashCode]) { - return; - } - var tempList = BitmapData._displayList[hashCode]; - var index = tempList.indexOf(displayObject); - if (index >= 0) { - tempList.splice(index, 1); - } - }; - BitmapData.$invalidate = function (bitmapData) { - if (!bitmapData) { - return; - } - var hashCode = bitmapData.hashCode; - if (!hashCode) { - return; - } - if (!BitmapData._displayList[hashCode]) { - return; - } - var tempList = BitmapData._displayList[hashCode]; - for (var i = 0; i < tempList.length; i++) { - if (tempList[i] instanceof egret.Bitmap) { - tempList[i].$refreshImageData(); - } - var bitmap = tempList[i]; - bitmap.$renderDirty = true; - var p = bitmap.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = bitmap.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - BitmapData.$dispose = function (bitmapData) { - if (!bitmapData) { - return; - } - var hashCode = bitmapData.hashCode; - if (!hashCode) { - return; - } - if (!BitmapData._displayList[hashCode]) { - return; - } - var tempList = BitmapData._displayList[hashCode]; - for (var _i = 0, tempList_1 = tempList; _i < tempList_1.length; _i++) { - var node = tempList_1[_i]; - if (node instanceof egret.Bitmap) { - node.$bitmapData = null; - } - node.$renderDirty = true; - var p = node.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = node.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - delete BitmapData._displayList[hashCode]; - }; - BitmapData.prototype._getCompressedTextureData = function (level, face) { - var levelData = this.compressedTextureData[level]; - return levelData ? levelData[face] : null; - }; - BitmapData.prototype.getCompressed2dTextureData = function () { - return this._getCompressedTextureData(0, 0); - }; - BitmapData.prototype.hasCompressed2d = function () { - return !!this.getCompressed2dTextureData(); - }; - BitmapData.prototype.clearCompressedTextureData = function () { - this.compressedTextureData.length = 0; - }; - BitmapData._displayList = egret.createMap(); - return BitmapData; - }(egret.HashObject)); - egret.BitmapData = BitmapData; - __reflect(BitmapData.prototype, "egret.BitmapData"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -var egret; -(function (egret) { - var localPoint = new egret.Point(); - /** - * The TouchEvent class lets you handle events on devices that detect user contact with the device (such as a finger - * on a touch screen).When a user interacts with a device such as a mobile phone or tablet with a touch screen, the - * user typically touches the screen with his or her fingers or a pointing device. You can develop applications that - * respond to basic touch events (such as a single finger tap) with the TouchEvent class. Create event listeners using - * the event types defined in this class. - * Note: When objects are nested on the display list, touch events target the deepest possible nested object that is - * visible in the display list. This object is called the target node. To have a target node's ancestor (an object - * containing the target node in the display list) receive notification of a touch event, use EventDispatcher.addEventListener() - * on the ancestor node with the type parameter set to the specific touch event you want to detect. - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language en_US - */ - /** - * 使用 TouchEvent 类,您可以处理设备上那些检测用户与设备之间的接触的事件。 - * 当用户与带有触摸屏的移动电话或平板电脑等设备交互时,用户通常使用手指或指针设备接触屏幕。可使用 TouchEvent - * 类开发响应基本触摸事件(如单个手指点击)的应用程序。使用此类中定义的事件类型创建事件侦听器。 - * 注意:当对象嵌套在显示列表中时,触摸事件的目标将是显示列表中可见的最深的可能嵌套对象。 - * 此对象称为目标节点。要使目标节点的祖代(祖代是一个包含显示列表中所有目标节点的对象,从舞台到目标节点的父节点均包括在内) - * 接收触摸事件的通知,请对祖代节点使用 EventDispatcher.on() 并将 type 参数设置为要检测的特定触摸事件。 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language zh_CN - */ - var TouchEvent = (function (_super) { - __extends(TouchEvent, _super); - /** - * Creates an Event object that contains information about touch events. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number assigned to the touch point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TouchEvent 对象,其中包含有关Touch事件的信息 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function TouchEvent(type, bubbles, cancelable, stageX, stageY, touchPointID) { - var _this = _super.call(this, type, bubbles, cancelable) || this; - _this.targetChanged = true; - /** - * Whether the touch is pressed (true) or not pressed (false). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示触摸已按下 (true) 还是未按下 (false)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.touchDown = false; - _this.$initTo(stageX, stageY, touchPointID); - return _this; - } - /** - * @private - */ - TouchEvent.prototype.$initTo = function (stageX, stageY, touchPointID) { - this.touchPointID = +touchPointID || 0; - this.$stageX = +stageX || 0; - this.$stageY = +stageY || 0; - }; - Object.defineProperty(TouchEvent.prototype, "stageX", { - /** - * The horizontal coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$stageX; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TouchEvent.prototype, "stageY", { - /** - * The vertical coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$stageY; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TouchEvent.prototype, "localX", { - /** - * The horizontal coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - if (this.targetChanged) { - this.getLocalXY(); - } - return this._localX; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TouchEvent.prototype, "localY", { - /** - * The vertical coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - if (this.targetChanged) { - this.getLocalXY(); - } - return this._localY; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - TouchEvent.prototype.getLocalXY = function () { - this.targetChanged = false; - var m = this.$target.$getInvertedConcatenatedMatrix(); - m.transformPoint(this.$stageX, this.$stageY, localPoint); - this._localX = localPoint.x; - this._localY = localPoint.y; - }; - TouchEvent.prototype.$setTarget = function (target) { - this.$target = target; - this.targetChanged = !!target; - return true; - }; - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.prototype.updateAfterEvent = function () { - egret.sys.$requestRenderingFlag = true; - }; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number (as an int) assigned to the touch point. - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.dispatchTouchEvent = function (target, type, bubbles, cancelable, stageX, stageY, touchPointID, touchDown) { - if (touchDown === void 0) { touchDown = false; } - if (!bubbles && !target.hasEventListener(type)) { - return true; - } - var event = egret.Event.create(TouchEvent, type, bubbles, cancelable); - event.$initTo(stageX, stageY, touchPointID); - event.touchDown = touchDown; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_MOVE = "touchMove"; - /** - * Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户第一次触摸启用触摸的设备时(例如,用手指触摸配有触摸屏的移动电话或平板电脑)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_BEGIN = "touchBegin"; - /** - * Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone - * or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户移除与启用触摸的设备的接触时(例如,将手指从配有触摸屏的移动电话或平板电脑上抬起)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_END = "touchEnd"; - /** - * Dispatched when an event of some kind occurred that canceled the touch. - * Such as the eui.Scroller will dispatch 'TOUCH_CANCEL' when it start move, the 'TOUCH_END' and 'TOUCH_TAP' will not be triggered. - * @version Egret 3.0.1 - * @platform Web,Native - * @language en_US - */ - /** - * 由于某个事件取消了触摸时触发。比如 eui.Scroller 在开始滚动后会触发 'TOUCH_CANCEL' 事件,不再触发后续的 'TOUCH_END' 和 'TOUCH_TAP' 事件 - * @version Egret 3.0.1 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_CANCEL = "touchCancel"; - /** - * Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact - * was initiated on a touch-enabled device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的同一 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_TAP = "touchTap"; - /** - * Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact - * was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display - * object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的不同 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TouchEvent.TOUCH_RELEASE_OUTSIDE = "touchReleaseOutside"; - return TouchEvent; - }(egret.Event)); - egret.TouchEvent = TouchEvent; - __reflect(TouchEvent.prototype, "egret.TouchEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The BlurFilter class lets you apply a blur visual effect to display objects. A blur effect softens the details of an image. - * You can produce blurs that range from a softly unfocused look to a Gaussian blur, a hazy appearance like viewing an image through semi-opaque glass. - * @version Egret 3.0.1 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language en_US - */ - /** - * 可使用 BlurFilter 类将模糊视觉效果应用于显示对象。模糊效果可以柔化图像的细节。 - * 您可以生成一些模糊效果,范围从创建一个柔化的、未聚焦的外观到高斯模糊(就像通过半透明玻璃查看图像一样的朦胧的外观)。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language zh_CN - */ - var BlurFilter = (function (_super) { - __extends(BlurFilter, _super); - /** - * Initializes a BlurFilter object. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param quality {number} The number of times to apply the filter. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 BlurFilter 对象。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - function BlurFilter(blurX, blurY, quality) { - if (blurX === void 0) { blurX = 4; } - if (blurY === void 0) { blurY = 4; } - if (quality === void 0) { quality = 1; } - var _this = _super.call(this) || this; - var self = _this; - self.type = "blur"; - self.$blurX = blurX; - self.$blurY = blurY; - self.$quality = quality; - self.blurXFilter = new BlurXFilter(blurX); - self.blurYFilter = new BlurYFilter(blurY); - self.onPropertyChange(); - return _this; - } - Object.defineProperty(BlurFilter.prototype, "blurX", { - /** - * The amount of horizontal blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$blurX; - }, - set: function (value) { - var self = this; - if (self.$blurX == value) { - return; - } - self.$blurX = value; - self.blurXFilter.blurX = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BlurFilter.prototype, "blurY", { - /** - * The amount of vertical blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$blurY; - }, - set: function (value) { - var self = this; - if (self.$blurY == value) { - return; - } - self.$blurY = value; - self.blurYFilter.blurY = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - BlurFilter.prototype.$toJson = function () { - return '{"blurX": ' + this.$blurX + ', "blurY": ' + this.$blurY + ', "quality": 1}'; - }; - BlurFilter.prototype.updatePadding = function () { - var self = this; - self.paddingLeft = self.blurX; - self.paddingRight = self.blurX; - self.paddingTop = self.blurY; - self.paddingBottom = self.blurY; - }; - BlurFilter.prototype.onPropertyChange = function () { - var self = this; - self.updatePadding(); - if (egret.nativeRender) { - egret_native.NativeDisplayObject.setFilterPadding(self.blurXFilter.$id, 0, 0, self.paddingLeft, self.paddingRight); - egret_native.NativeDisplayObject.setFilterPadding(self.blurYFilter.$id, self.paddingTop, self.paddingBottom, 0, 0); - egret_native.NativeDisplayObject.setDataToFilter(self); - } - }; - return BlurFilter; - }(egret.Filter)); - egret.BlurFilter = BlurFilter; - __reflect(BlurFilter.prototype, "egret.BlurFilter"); - var BlurXFilter = (function (_super) { - __extends(BlurXFilter, _super); - function BlurXFilter(blurX) { - if (blurX === void 0) { blurX = 4; } - var _this = _super.call(this) || this; - if (egret.nativeRender) { - _this.type = "blur"; - } - else { - _this.type = "blurX"; - } - _this.$uniforms.blur = { x: blurX, y: 0 }; - _this.onPropertyChange(); - return _this; - } - Object.defineProperty(BlurXFilter.prototype, "blurX", { - get: function () { - return this.$uniforms.blur.x; - }, - set: function (value) { - this.$uniforms.blur.x = value; - }, - enumerable: true, - configurable: true - }); - return BlurXFilter; - }(egret.Filter)); - __reflect(BlurXFilter.prototype, "BlurXFilter", ["egret.IBlurXFilter"]); - var BlurYFilter = (function (_super) { - __extends(BlurYFilter, _super); - function BlurYFilter(blurY) { - if (blurY === void 0) { blurY = 4; } - var _this = _super.call(this) || this; - if (egret.nativeRender) { - _this.type = "blur"; - } - else { - _this.type = "blurY"; - } - _this.$uniforms.blur = { x: 0, y: blurY }; - _this.onPropertyChange(); - return _this; - } - Object.defineProperty(BlurYFilter.prototype, "blurY", { - get: function () { - return this.$uniforms.blur.y; - }, - set: function (value) { - this.$uniforms.blur.y = value; - }, - enumerable: true, - configurable: true - }); - return BlurYFilter; - }(egret.Filter)); - __reflect(BlurYFilter.prototype, "BlurYFilter", ["egret.IBlurYFilter"]); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The ColorMatrixFilter class lets you apply a 4 x 5 matrix transformation on the RGBA color and alpha values of every pixel in the input image to produce a result with a new set of RGBA color and alpha values. - * It allows saturation changes, hue rotation, luminance to alpha, and various other effects. - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language en_US - */ - /** - * 使用 ColorMatrixFilter 类可以将 4 x 5 矩阵转换应用于输入图像上的每个像素的 RGBA 颜色和 Alpha 值,以生成具有一组新的 RGBA 颜色和 Alpha 值的结果。 - * 该类允许饱和度更改、色相旋转、亮度为 Alpha 以及各种其他效果。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language zh_CN - */ - var ColorMatrixFilter = (function (_super) { - __extends(ColorMatrixFilter, _super); - /** - * Initializes a ColorMatrixFilter object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 ColorMatrixFilter 对象。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - function ColorMatrixFilter(matrix) { - if (matrix === void 0) { matrix = null; } - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$matrix = []; - /** - * @private - */ - _this.matrix2 = []; - _this.type = "colorTransform"; - _this.$uniforms.matrix = [ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]; - _this.$uniforms.colorAdd = { x: 0, y: 0, z: 0, w: 0 }; - _this.setMatrix(matrix); - _this.onPropertyChange(); - return _this; - } - Object.defineProperty(ColorMatrixFilter.prototype, "matrix", { - /** - * A comma delimited list of 20 doubles that comprise a 4x5 matrix applied to the rendered element. - * The matrix is in row major order -- that is, the first five elements are multipled by the vector [srcR,srcG,srcB,srcA,1] to determine the output red value, the second five determine the output green value, etc. - * The value must either be an array or comma delimited string of 20 numbers. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 构成应用于所呈示的元素的一个 4x5 矩阵的、以逗号分隔的 20 个双精度数的列表。 - * 矩阵以行作为主要顺序,即用第一行五个元素乘以矢量 [srcR,srcG,srcB,srcA,1] 以确定输出的红色值,用第二行的五个元素确定输出的绿色值,等等。 - * 该值必须为 20 个数字组成的数组或以逗号分隔的字符串。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - for (var i = 0; i < 20; i++) { - this.matrix2[i] = this.$matrix[i]; - } - return this.matrix2; - }, - set: function (value) { - this.setMatrix(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - ColorMatrixFilter.prototype.setMatrix = function (value) { - if (value) { - for (var i = 0; i < 20; i++) { - this.$matrix[i] = value[i]; - } - } - else { - for (var i = 0; i < 20; i++) { - this.$matrix[i] = (i == 0 || i == 6 || i == 12 || i == 18) ? 1 : 0; - } - } - var $matrix = this.$matrix; - var matrix = this.$uniforms.matrix; - var colorAdd = this.$uniforms.colorAdd; - for (var i = 0, j = 0; i < $matrix.length; i++) { - if (i === 4) { - colorAdd.x = $matrix[i] / 255; - } - else if (i === 9) { - colorAdd.y = $matrix[i] / 255; - } - else if (i === 14) { - colorAdd.z = $matrix[i] / 255; - } - else if (i === 19) { - colorAdd.w = $matrix[i] / 255; - } - else { - matrix[j] = $matrix[i]; - j++; - } - } - this.onPropertyChange(); - }; - /** - * @private - */ - ColorMatrixFilter.prototype.$toJson = function () { - return '{"matrix": [' + this.$matrix.toString() + ']}'; - }; - return ColorMatrixFilter; - }(egret.Filter)); - egret.ColorMatrixFilter = ColorMatrixFilter; - __reflect(ColorMatrixFilter.prototype, "egret.ColorMatrixFilter"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var SOURCE_KEY_MAP = {}; - var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); - var uuid = new Array(36); - var rnd = 0, r; - /** - * generate uuid - * http://www.broofa.com/Tools/Math.uuid.htm - */ - var generateUUID = function () { - for (var i = 0; i < 36; i++) { - if (i === 8 || i === 13 || i === 18 || i === 23) { - uuid[i] = '-'; - } - else if (i === 14) { - uuid[i] = '4'; - } - else { - if (rnd <= 0x02) - rnd = 0x2000000 + (Math.random() * 0x1000000) | 0; - r = rnd & 0xf; - rnd = rnd >> 4; - uuid[i] = chars[(i === 19) ? (r & 0x3) | 0x8 : r]; - } - } - return uuid.join(''); - }; - /** - * custom filter, now support WebGL mode only. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 自定义滤镜,目前仅支持WebGL模式 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - var CustomFilter = (function (_super) { - __extends(CustomFilter, _super); - /** - * Initialize the CustomFilter object. - * @param vertexSrc Custom vertex shader program. - * @param fragmentSrc Custom fragment shader program. - * @param uniforms The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 初始化 CustomFilter 对象 - * @param vertexSrc 自定义的顶点着色器程序。 - * @param fragmentSrc 自定义的片段着色器程序。 - * @param uniforms 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - function CustomFilter(vertexSrc, fragmentSrc, uniforms) { - if (uniforms === void 0) { uniforms = {}; } - var _this = _super.call(this) || this; - _this.$padding = 0; - _this.$vertexSrc = vertexSrc; - _this.$fragmentSrc = fragmentSrc; - var tempKey = vertexSrc + fragmentSrc; - if (!SOURCE_KEY_MAP[tempKey]) { - SOURCE_KEY_MAP[tempKey] = generateUUID(); - } - _this.$shaderKey = SOURCE_KEY_MAP[tempKey]; - _this.$uniforms = uniforms; - _this.type = "custom"; - return _this; - } - Object.defineProperty(CustomFilter.prototype, "padding", { - /** - * The inner margin of the filter. - * If the desired area of the custom filter is larger than the original area (stroke, etc.), you need to set it manually. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 滤镜的内边距 - * 如果自定义滤镜所需区域比原区域大(描边等),需要手动设置 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$padding; - }, - set: function (value) { - var self = this; - if (self.$padding == value) { - return; - } - self.$padding = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CustomFilter.prototype, "uniforms", { - /** - * The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$uniforms; - }, - enumerable: true, - configurable: true - }); - CustomFilter.prototype.onPropertyChange = function () { - if (egret.nativeRender) { - var self_1 = this; - egret_native.NativeDisplayObject.setFilterPadding(self_1.$id, self_1.$padding, self_1.$padding, self_1.$padding, self_1.$padding); - egret_native.NativeDisplayObject.setDataToFilter(self_1); - } - }; - return CustomFilter; - }(egret.Filter)); - egret.CustomFilter = CustomFilter; - __reflect(CustomFilter.prototype, "egret.CustomFilter"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @class egret.DropShadowFilter - * @classdesc - * 可使用 DropShadowFilter 类向显示对象添加投影。 - * @extends egret.GlowFilter - * @version Egret 3.1.4 - * @platform Web,Native - */ - var DropShadowFilter = (function (_super) { - __extends(DropShadowFilter, _super); - /** - * Initializes a new DropShadowFilter instance. - * @method egret.DropShadowFilter#constructor - * @param distance {number} The offset distance of the bevel. Valid values are in pixels (floating point). - * @param angle {number} The angle of the bevel. Valid values are from 0 to 360°. - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @param hideObject {number} Indicates whether or not the object is hidden. The value true indicates that the object itself is not drawn; only the shadow is visible. The default is false, meaning that the object is shown. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 DropShadowFilter 对象 - * @method egret.DropShadowFilter#constructor - * @param distance {number} 阴影的偏移距离,以像素为单位。 - * @param angle {number} 阴影的角度,0 到 360 度(浮点)。 - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @param hideObject {number} 表示是否隐藏对象。如果值为 true,则表示没有绘制对象本身,只有阴影是可见的。默认值为 false(显示对象)。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - function DropShadowFilter(distance, angle, color, alpha, blurX, blurY, strength, quality, inner, knockout, hideObject) { - if (distance === void 0) { distance = 4.0; } - if (angle === void 0) { angle = 45; } - if (color === void 0) { color = 0; } - if (alpha === void 0) { alpha = 1.0; } - if (blurX === void 0) { blurX = 4.0; } - if (blurY === void 0) { blurY = 4.0; } - if (strength === void 0) { strength = 1.0; } - if (quality === void 0) { quality = 1; } - if (inner === void 0) { inner = false; } - if (knockout === void 0) { knockout = false; } - if (hideObject === void 0) { hideObject = false; } - var _this = _super.call(this, color, alpha, blurX, blurY, strength, quality, inner, knockout) || this; - var self = _this; - self.$distance = distance; - self.$angle = angle; - self.$hideObject = hideObject; - self.$uniforms.dist = distance; - self.$uniforms.angle = angle / 180 * Math.PI; - self.$uniforms.hideObject = hideObject ? 1 : 0; - self.onPropertyChange(); - return _this; - } - Object.defineProperty(DropShadowFilter.prototype, "distance", { - /** - * The offset distance of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的偏移距离,以像素为单位。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$distance; - }, - set: function (value) { - var self = this; - if (self.$distance == value) { - return; - } - self.$distance = value; - self.$uniforms.dist = value; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DropShadowFilter.prototype, "angle", { - /** - * The angle of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的角度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$angle; - }, - set: function (value) { - var self = this; - if (self.$angle == value) { - return; - } - self.$angle = value; - self.$uniforms.angle = value / 180 * Math.PI; - self.onPropertyChange(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DropShadowFilter.prototype, "hideObject", { - /** - * Indicates whether or not the object is hidden. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 表示是否隐藏对象。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$hideObject; - }, - set: function (value) { - if (this.$hideObject == value) { - return; - } - this.$hideObject = value; - this.$uniforms.hideObject = value ? 1 : 0; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - DropShadowFilter.prototype.$toJson = function () { - return '{"distance": ' + this.$distance + ', "angle": ' + this.$angle + ', "color": ' + this.$color + ', "red": ' + this.$red + ', "green": ' + this.$green + ', "blue": ' + this.$blue + ', "alpha": ' + this.$alpha + ', "blurX": ' + this.$blurX + ', "blurY": ' + this.blurY + ', "strength": ' + this.$strength + ', "quality": ' + this.$quality + ', "inner": ' + this.$inner + ', "knockout": ' + this.$knockout + ', "hideObject": ' + this.$hideObject + '}'; - }; - DropShadowFilter.prototype.updatePadding = function () { - var self = this; - self.paddingLeft = self.blurX; - self.paddingRight = self.blurX; - self.paddingTop = self.blurY; - self.paddingBottom = self.blurY; - var distance = self.distance || 0; - var angle = self.angle || 0; - var distanceX = 0; - var distanceY = 0; - if (distance != 0) { - distanceX = distance * egret.NumberUtils.cos(angle); - if (distanceX > 0) { - distanceX = Math.ceil(distanceX); - } - else { - distanceX = Math.floor(distanceX); - } - distanceY = distance * egret.NumberUtils.sin(angle); - if (distanceY > 0) { - distanceY = Math.ceil(distanceY); - } - else { - distanceY = Math.floor(distanceY); - } - self.paddingLeft += distanceX; - self.paddingRight += distanceX; - self.paddingTop += distanceY; - self.paddingBottom += distanceY; - } - }; - return DropShadowFilter; - }(egret.GlowFilter)); - egret.DropShadowFilter = DropShadowFilter; - __reflect(DropShadowFilter.prototype, "egret.DropShadowFilter"); -})(egret || (egret = {})); -var egret; -(function (egret) { - /** - * The GradientType class provides values for the type parameter in the beginGradientFill() methods of the egret.Graphics class. - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * GradientType 类为 egret.Graphics 类的 beginGradientFill() 方法中的 type 参数提供值。 - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var GradientType = (function () { - function GradientType() { - } - /** - * Value used to specify a linear gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定线性渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - GradientType.LINEAR = "linear"; - /** - * Value used to specify a radial gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定放射状渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - GradientType.RADIAL = "radial"; - return GradientType; - }()); - egret.GradientType = GradientType; - __reflect(GradientType.prototype, "egret.GradientType"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - * 格式化弧线角度的值 - */ - function clampAngle(value) { - value %= Math.PI * 2; - if (value < 0) { - value += Math.PI * 2; - } - return value; - } - /** - * @private - * 根据传入的锚点组返回贝塞尔曲线上的一组点,返回类型为egret.Point[]; - * @param pointsData 锚点组,保存着所有控制点的x和y坐标,格式为[x0,y0,x1,y1,x2,y2...] - * @param pointsAmount 要获取的点的总个数,实际返回点数不一定等于该属性,与范围有关 - * @param range 要获取的点与中心锚点的范围值,0~1之间 - * @returns egret.Point[]; - */ - function createBezierPoints(pointsData, pointsAmount) { - var points = []; - for (var i = 0; i < pointsAmount; i++) { - var point = getBezierPointByFactor(pointsData, i / pointsAmount); - if (point) - points.push(point); - } - return points; - } - /** - * @private - * 根据锚点组与取值系数获取贝塞尔曲线上的一点 - * @param pointsData 锚点组,保存着所有控制点的x和y坐标,格式为[x0,y0,x1,y1,x2,y2...] - * @param t 取值系数 - * @returns egret.Point - */ - function getBezierPointByFactor(pointsData, t) { - var i = 0; - var x = 0, y = 0; - var len = pointsData.length; - //根据传入的数据数量判断是二次贝塞尔还是三次贝塞尔 - if (len / 2 == 3) { - //二次 - var x0 = pointsData[i++]; - var y0 = pointsData[i++]; - var x1 = pointsData[i++]; - var y1 = pointsData[i++]; - var x2 = pointsData[i++]; - var y2 = pointsData[i++]; - x = getCurvePoint(x0, x1, x2, t); - y = getCurvePoint(y0, y1, y2, t); - } - else if (len / 2 == 4) { - //三次 - var x0 = pointsData[i++]; - var y0 = pointsData[i++]; - var x1 = pointsData[i++]; - var y1 = pointsData[i++]; - var x2 = pointsData[i++]; - var y2 = pointsData[i++]; - var x3 = pointsData[i++]; - var y3 = pointsData[i++]; - x = getCubicCurvePoint(x0, x1, x2, x3, t); - y = getCubicCurvePoint(y0, y1, y2, y3, t); - } - return egret.Point.create(x, y); - } - /** - * 通过factor参数获取二次贝塞尔曲线上的位置 - * 公式为B(t) = (1-t)^2 * P0 + 2t(1-t) * P1 + t^2 * P2 - * @param value0 P0 - * @param value1 P1 - * @param value2 P2 - * @param factor t,从0到1的闭区间 - */ - function getCurvePoint(value0, value1, value2, factor) { - var result = Math.pow((1 - factor), 2) * value0 + 2 * factor * (1 - factor) * value1 + Math.pow(factor, 2) * value2; - return result; - } - /** - * 通过factor参数获取三次贝塞尔曲线上的位置 - * 公式为B(t) = (1-t)^3 * P0 + 3t(1-t)^2 * P1 + 3t^2 * (1-t) t^2 * P2 + t^3 *P3 - * @param value0 P0 - * @param value1 P1 - * @param value2 P2 - * @param value3 P3 - * @param factor t,从0到1的闭区间 - */ - function getCubicCurvePoint(value0, value1, value2, value3, factor) { - var result = Math.pow((1 - factor), 3) * value0 + 3 * factor * Math.pow((1 - factor), 2) * value1 + 3 * (1 - factor) * Math.pow(factor, 2) * value2 + Math.pow(factor, 3) * value3; - return result; - } - /** - * The Graphics class contains a set of methods for creating vector shape. Display objects that support drawing include Sprite and Shape objects. Each class in these classes includes the graphics attribute that is a Graphics object. - * The following auxiliary functions are provided for ease of use: drawRect(), drawRoundRect(), drawCircle(), and drawEllipse(). - * @see http://edn.egret.com/cn/docs/page/136 Draw Rectangle - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language en_US - */ - /** - * Graphics 类包含一组可用来创建矢量形状的方法。支持绘制的显示对象包括 Sprite 和 Shape 对象。这些类中的每一个类都包括 graphics 属性,该属性是一个 Graphics 对象。 - * 以下是为便于使用而提供的一些辅助函数:drawRect()、drawRoundRect()、drawCircle() 和 drawEllipse()。 - * @see http://edn.egret.com/cn/docs/page/136 绘制矩形 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language zh_CN - */ - var Graphics = (function (_super) { - __extends(Graphics, _super); - /** - * Initializes a Graphics object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Graphics 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Graphics() { - var _this = _super.call(this) || this; - /** - * 当前移动到的坐标X - */ - _this.lastX = 0; - /** - * 当前移动到的坐标Y - */ - _this.lastY = 0; - /** - * 当前正在绘制的填充 - */ - _this.fillPath = null; - /** - * 当前正在绘制的线条 - */ - _this.strokePath = null; - /** - * 线条的左上方宽度 - */ - _this.topLeftStrokeWidth = 0; - /** - * 线条的右下方宽度 - */ - _this.bottomRightStrokeWidth = 0; - /** - * @private - */ - _this.minX = Infinity; - /** - * @private - */ - _this.minY = Infinity; - /** - * @private - */ - _this.maxX = -Infinity; - /** - * @private - */ - _this.maxY = -Infinity; - /** - * 是否已经包含上一次moveTo的坐标点 - */ - _this.includeLastPosition = true; - _this.$renderNode = new egret.sys.GraphicsNode(); - return _this; - } - /** - * @private - * 设置绑定到的目标显示对象 - */ - Graphics.prototype.$setTarget = function (target) { - if (this.$targetDisplay) { - this.$targetDisplay.$renderNode = null; - } - target.$renderNode = this.$renderNode; - this.$targetDisplay = target; - this.$targetIsSprite = target instanceof egret.Sprite; - }; - /** - * 对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - Graphics.prototype.setStrokeWidth = function (width) { - switch (width) { - case 1: - this.topLeftStrokeWidth = 0; - this.bottomRightStrokeWidth = 1; - break; - case 3: - this.topLeftStrokeWidth = 1; - this.bottomRightStrokeWidth = 2; - break; - default: - var half = Math.ceil(width * 0.5) | 0; - this.topLeftStrokeWidth = half; - this.bottomRightStrokeWidth = half; - break; - } - }; - /** - * Specify a simple single color fill that will be used for subsequent calls to other Graphics methods (for example, lineTo() and drawCircle()) when drawing. - * Calling the clear() method will clear the fill. - * @param color Filled color - * @param alpha Filled Alpha value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.beginFill = function (color, alpha) { - if (alpha === void 0) { alpha = 1; } - color = +color || 0; - alpha = +alpha || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setBeginFill(color, alpha); - } - this.fillPath = this.$renderNode.beginFill(color, alpha, this.strokePath); - if (this.$renderNode.drawData.length > 1) { - this.fillPath.moveTo(this.lastX, this.lastY); - } - }; - /** - * Specifies a gradient fill used by subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) for the object. - * Calling the clear() method clears the fill. - * @param type A value from the GradientType class that specifies which gradient type to use: GradientType.LINEAR or GradientType.RADIAL. - * @param colors An array of RGB hexadecimal color values used in the gradient; for example, red is 0xFF0000, blue is 0x0000FF, and so on. You can specify up to 15 colors. For each color, specify a corresponding value in the alphas and ratios parameters. - * @param alphas An array of alpha values for the corresponding colors in the colors array; - * @param ratios An array of color distribution ratios; valid values are 0-255. - * @param matrix A transformation matrix as defined by the egret.Matrix class. The egret.Matrix class includes a createGradientBox() method, which lets you conveniently set up the matrix for use with the beginGradientFill() method. - * @platform Web,Native - * @version Egret 2.4 - * @language en_US - */ - /** - * 指定一种渐变填充,用于随后调用对象的其他 Graphics 方法(如 lineTo() 或 drawCircle())。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @platform Web,Native - * @version Egret 2.4 - * @language zh_CN - */ - Graphics.prototype.beginGradientFill = function (type, colors, alphas, ratios, matrix) { - if (matrix === void 0) { matrix = null; } - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setBeginGradientFill(type, colors, alphas, ratios, matrix); - } - this.fillPath = this.$renderNode.beginGradientFill(type, colors, alphas, ratios, matrix, this.strokePath); - if (this.$renderNode.drawData.length > 1) { - this.fillPath.moveTo(this.lastX, this.lastY); - } - }; - /** - * Apply fill to the lines and curves added after the previous calling to the beginFill() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对从上一次调用 beginFill()方法之后添加的直线和曲线应用填充。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.endFill = function () { - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setEndFill(); - } - this.fillPath = null; - }; - /** - * Specify a line style that will be used for subsequent calls to Graphics methods such as lineTo() and drawCircle(). - * @param thickness An integer, indicating the thickness of the line in points. Valid values are 0 to 255. If a number is not specified, or if the parameter is undefined, a line is not drawn. If a value less than 0 is passed, the default value is 0. Value 0 indicates hairline thickness; the maximum thickness is 255. If a value greater than 255 is passed, the default value is 255. - * @param color A hexadecimal color value of the line (for example, red is 0xFF0000, and blue is 0x0000FF, etc.). If no value is specified, the default value is 0x000000 (black). Optional. - * @param alpha Indicates Alpha value of the line's color. Valid values are 0 to 1. If no value is specified, the default value is 1 (solid). If the value is less than 0, the default value is 0. If the value is greater than 1, the default value is 1. - * @param pixelHinting A boolean value that specifies whether to hint strokes to full pixels. This affects both the position of anchors of a curve and the line stroke size itself. With pixelHinting set to true, the line width is adjusted to full pixel width. With pixelHinting set to false, disjoints can appear for curves and straight lines. - * @param scaleMode Specifies the scale mode to be used - * @param caps Specifies the value of the CapsStyle class of the endpoint type at the end of the line. (default = CapsStyle.ROUND) - * @param joints Specifies the type of joint appearance of corner. (default = JointStyle.ROUND) - * @param miterLimit Indicates the limit number of cut miter. - * @param lineDash set the line dash. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param pixelHinting 布尔型值,指定是否提示笔触采用完整像素。它同时影响曲线锚点的位置以及线条笔触大小本身。在 pixelHinting 设置为 true 的情况下,线条宽度会调整到完整像素宽度。在 pixelHinting 设置为 false 的情况下,对于曲线和直线可能会出现脱节。 - * @param scaleMode 用于指定要使用的比例模式 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - * @param lineDash 设置虚线样式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.lineStyle = function (thickness, color, alpha, pixelHinting, scaleMode, caps, joints, miterLimit, lineDash) { - if (thickness === void 0) { thickness = NaN; } - if (color === void 0) { color = 0; } - if (alpha === void 0) { alpha = 1.0; } - if (pixelHinting === void 0) { pixelHinting = false; } - if (scaleMode === void 0) { scaleMode = "normal"; } - if (caps === void 0) { caps = null; } - if (joints === void 0) { joints = null; } - if (miterLimit === void 0) { miterLimit = 3; } - thickness = +thickness || 0; - color = +color || 0; - alpha = +alpha || 0; - miterLimit = +miterLimit || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setLineStyle(thickness, color, alpha, pixelHinting, scaleMode, caps, joints, miterLimit); - } - if (thickness <= 0) { - this.strokePath = null; - this.setStrokeWidth(0); - } - else { - this.setStrokeWidth(thickness); - this.strokePath = this.$renderNode.lineStyle(thickness, color, alpha, caps, joints, miterLimit, lineDash); - if (this.$renderNode.drawData.length > 1) { - this.strokePath.moveTo(this.lastX, this.lastY); - } - } - }; - /** - * Draw a rectangle - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.drawRect = function (x, y, width, height) { - x = +x || 0; - y = +y || 0; - width = +width || 0; - height = +height || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setDrawRect(x, y, width, height); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.drawRect(x, y, width, height); - strokePath && strokePath.drawRect(x, y, width, height); - this.extendBoundsByPoint(x + width, y + height); - this.updatePosition(x, y); - this.dirty(); - }; - /** - * Draw a rectangle with rounded corners. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @param ellipseWidth Width used to draw an ellipse with rounded corners (in pixels). - * @param ellipseHeight Height used to draw an ellipse with rounded corners (in pixels). (Optional) If no value is specified, the default value matches the value of the ellipseWidth parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.drawRoundRect = function (x, y, width, height, ellipseWidth, ellipseHeight) { - x = +x || 0; - y = +y || 0; - width = +width || 0; - height = +height || 0; - ellipseWidth = +ellipseWidth || 0; - ellipseHeight = +ellipseHeight || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setDrawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.drawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight); - strokePath && strokePath.drawRoundRect(x, y, width, height, ellipseWidth, ellipseHeight); - var radiusX = (ellipseWidth * 0.5) | 0; - var radiusY = ellipseHeight ? (ellipseHeight * 0.5) | 0 : radiusX; - var right = x + width; - var bottom = y + height; - var ybw = bottom - radiusY; - this.extendBoundsByPoint(x, y); - this.extendBoundsByPoint(right, bottom); - this.updatePosition(right, ybw); - this.dirty(); - }; - /** - * Draw a circle. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param r Radius of the circle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.drawCircle = function (x, y, radius) { - x = +x || 0; - y = +y || 0; - radius = +radius || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setDrawCircle(x, y, radius); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.drawCircle(x, y, radius); - strokePath && strokePath.drawCircle(x, y, radius); - //-1 +2 解决WebGL裁切问题 - this.extendBoundsByPoint(x - radius - 1, y - radius - 1); - this.extendBoundsByPoint(x + radius + 2, y + radius + 2); - this.updatePosition(x + radius, y); - this.dirty(); - }; - /** - * Draw an ellipse. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.drawEllipse = function (x, y, width, height) { - x = +x || 0; - y = +y || 0; - width = +width || 0; - height = +height || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setDrawEllipse(x, y, width, height); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.drawEllipse(x, y, width, height); - strokePath && strokePath.drawEllipse(x, y, width, height); - //-1 +2 解决WebGL裁切问题 - this.extendBoundsByPoint(x - 1, y - 1); - this.extendBoundsByPoint(x + width + 2, y + height + 2); - this.updatePosition(x + width, y + height * 0.5); - this.dirty(); - }; - /** - * Move the current drawing position to (x, y). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.moveTo = function (x, y) { - x = +x || 0; - y = +y || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setMoveTo(x, y); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.moveTo(x, y); - strokePath && strokePath.moveTo(x, y); - this.includeLastPosition = false; - this.lastX = x; - this.lastY = y; - this.dirty(); - }; - /** - * Draw a straight line from the current drawing position to (x, y) using the current line style; the current drawing position is then set to (x, y). - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.lineTo = function (x, y) { - x = +x || 0; - y = +y || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setLineTo(x, y); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.lineTo(x, y); - strokePath && strokePath.lineTo(x, y); - this.updatePosition(x, y); - this.dirty(); - }; - /** - * Draw a quadratic Bezier curve from the current drawing position to (anchorX, anchorY) using the current line style according to the control points specified by (controlX, controlY). The current drawing position is then set to (anchorX, anchorY). - * If the curveTo() method is called before the moveTo() method, the default value of the current drawing position is (0, 0). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * The drawn curve is a quadratic Bezier curve. A quadratic Bezier curve contains two anchor points and one control point. The curve interpolates the two anchor points and bends to the control point. - * @param controlX A number indicating the horizontal position of the control point, relative to the registration point of the parent display object. - * @param controlY A number indicating the vertical position of the control point, relative to the registration point of the parent display object. - * @param anchorX A number indicating the horizontal position of the next anchor point, relative to the registration point of the parent display object. - * @param anchorY A number indicating the vertical position of the next anchor point, relative to the registration point of the parent display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.curveTo = function (controlX, controlY, anchorX, anchorY) { - controlX = +controlX || 0; - controlY = +controlY || 0; - anchorX = +anchorX || 0; - anchorY = +anchorY || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setCurveTo(controlX, controlY, anchorX, anchorY); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.curveTo(controlX, controlY, anchorX, anchorY); - strokePath && strokePath.curveTo(controlX, controlY, anchorX, anchorY); - var lastX = this.lastX || 0; - var lastY = this.lastY || 0; - var bezierPoints = createBezierPoints([lastX, lastY, controlX, controlY, anchorX, anchorY], 50); - for (var i = 0; i < bezierPoints.length; i++) { - var point = bezierPoints[i]; - this.extendBoundsByPoint(point.x, point.y); - egret.Point.release(point); - } - this.extendBoundsByPoint(anchorX, anchorY); - this.updatePosition(anchorX, anchorY); - this.dirty(); - }; - /** - * Draws a cubic Bezier curve from the current drawing position to the specified anchor. Cubic Bezier curves consist of two anchor points and two control points. The curve interpolates the two anchor points and two control points to the curve. - * @param controlX1 Specifies the first control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY1 Specifies the first control point relative to the registration point of the parent display the vertical position of the object. - * @param controlX2 Specify the second control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY2 Specify the second control point relative to the registration point of the parent display the vertical position of the object. - * @param anchorX Specifies the anchor point relative to the registration point of the parent display the horizontal position of the object. - * @param anchorY Specifies the anchor point relative to the registration point of the parent display the vertical position of the object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.cubicCurveTo = function (controlX1, controlY1, controlX2, controlY2, anchorX, anchorY) { - controlX1 = +controlX1 || 0; - controlY1 = +controlY1 || 0; - controlX2 = +controlX2 || 0; - controlY2 = +controlY2 || 0; - anchorX = +anchorX || 0; - anchorY = +anchorY || 0; - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setCubicCurveTo(controlX1, controlY1, controlX2, controlY2, anchorX, anchorY); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - fillPath && fillPath.cubicCurveTo(controlX1, controlY1, controlX2, controlY2, anchorX, anchorY); - strokePath && strokePath.cubicCurveTo(controlX1, controlY1, controlX2, controlY2, anchorX, anchorY); - var lastX = this.lastX || 0; - var lastY = this.lastY || 0; - var bezierPoints = createBezierPoints([lastX, lastY, controlX1, controlY1, controlX2, controlY2, anchorX, anchorY], 50); - for (var i = 0; i < bezierPoints.length; i++) { - var point = bezierPoints[i]; - this.extendBoundsByPoint(point.x, point.y); - egret.Point.release(point); - } - this.extendBoundsByPoint(anchorX, anchorY); - this.updatePosition(anchorX, anchorY); - this.dirty(); - }; - /** - * adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending - * at endAngle going in the given direction by anticlockwise (defaulting to clockwise). - * @param x The x coordinate of the arc's center. - * @param y The y coordinate of the arc's center. - * @param radius The arc's radius. - * @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. - * @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. - * @param anticlockwise if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.drawArc = function (x, y, radius, startAngle, endAngle, anticlockwise) { - if (radius < 0 || startAngle === endAngle) { - return; - } - x = +x || 0; - y = +y || 0; - radius = +radius || 0; - startAngle = +startAngle || 0; - endAngle = +endAngle || 0; - anticlockwise = !!anticlockwise; - startAngle = clampAngle(startAngle); - endAngle = clampAngle(endAngle); - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setDrawArc(x, y, radius, startAngle, endAngle, anticlockwise); - } - var fillPath = this.fillPath; - var strokePath = this.strokePath; - if (fillPath) { - fillPath.$lastX = this.lastX; - fillPath.$lastY = this.lastY; - fillPath.drawArc(x, y, radius, startAngle, endAngle, anticlockwise); - } - if (strokePath) { - strokePath.$lastX = this.lastX; - strokePath.$lastY = this.lastY; - strokePath.drawArc(x, y, radius, startAngle, endAngle, anticlockwise); - } - if (anticlockwise) { - this.arcBounds(x, y, radius, endAngle, startAngle); - } - else { - this.arcBounds(x, y, radius, startAngle, endAngle); - } - var endX = x + Math.cos(endAngle) * radius; - var endY = y + Math.sin(endAngle) * radius; - this.updatePosition(endX, endY); - this.dirty(); - }; - Graphics.prototype.dirty = function () { - var self = this; - self.$renderNode.dirtyRender = true; - if (!egret.nativeRender) { - var target = self.$targetDisplay; - target.$cacheDirty = true; - var p = target.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = target.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - /** - * @private - * 测量圆弧的矩形大小 - */ - Graphics.prototype.arcBounds = function (x, y, radius, startAngle, endAngle) { - var PI = Math.PI; - if (Math.abs(startAngle - endAngle) < 0.01) { - this.extendBoundsByPoint(x - radius, y - radius); - this.extendBoundsByPoint(x + radius, y + radius); - return; - } - if (startAngle > endAngle) { - endAngle += PI * 2; - } - var startX = Math.cos(startAngle) * radius; - var endX = Math.cos(endAngle) * radius; - var xMin = Math.min(startX, endX); - var xMax = Math.max(startX, endX); - var startY = Math.sin(startAngle) * radius; - var endY = Math.sin(endAngle) * radius; - var yMin = Math.min(startY, endY); - var yMax = Math.max(startY, endY); - var startRange = startAngle / (PI * 0.5); - var endRange = endAngle / (PI * 0.5); - for (var i = Math.ceil(startRange); i <= endRange; i++) { - switch (i % 4) { - case 0: - xMax = radius; - break; - case 1: - yMax = radius; - break; - case 2: - xMin = -radius; - break; - case 3: - yMin = -radius; - break; - } - } - xMin = Math.floor(xMin); - yMin = Math.floor(yMin); - xMax = Math.ceil(xMax); - yMax = Math.ceil(yMax); - this.extendBoundsByPoint(xMin + x, yMin + y); - this.extendBoundsByPoint(xMax + x, yMax + y); - }; - /** - * Clear graphics that are drawn to this Graphics object, and reset fill and line style settings. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除绘制到此 Graphics 对象的图形,并重置填充和线条样式设置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Graphics.prototype.clear = function () { - if (egret.nativeRender) { - this.$targetDisplay.$nativeDisplayObject.setGraphicsClear(); - } - this.$renderNode.clear(); - this.updatePosition(0, 0); - this.minX = Infinity; - this.minY = Infinity; - this.maxX = -Infinity; - this.maxY = -Infinity; - this.dirty(); - }; - /** - * @private - */ - Graphics.prototype.extendBoundsByPoint = function (x, y) { - this.extendBoundsByX(x); - this.extendBoundsByY(y); - }; - /** - * @private - */ - Graphics.prototype.extendBoundsByX = function (x) { - this.minX = Math.min(this.minX, x - this.topLeftStrokeWidth); - this.maxX = Math.max(this.maxX, x + this.bottomRightStrokeWidth); - this.updateNodeBounds(); - }; - /** - * @private - */ - Graphics.prototype.extendBoundsByY = function (y) { - this.minY = Math.min(this.minY, y - this.topLeftStrokeWidth); - this.maxY = Math.max(this.maxY, y + this.bottomRightStrokeWidth); - this.updateNodeBounds(); - }; - /** - * @private - */ - Graphics.prototype.updateNodeBounds = function () { - var node = this.$renderNode; - node.x = this.minX; - node.y = this.minY; - node.width = Math.ceil(this.maxX - this.minX); - node.height = Math.ceil(this.maxY - this.minY); - }; - /** - * 更新当前的lineX和lineY值,并标记尺寸失效。 - * @private - */ - Graphics.prototype.updatePosition = function (x, y) { - if (!this.includeLastPosition) { - this.extendBoundsByPoint(this.lastX, this.lastY); - this.includeLastPosition = true; - } - this.lastX = x; - this.lastY = y; - this.extendBoundsByPoint(x, y); - }; - /** - * @private - */ - Graphics.prototype.$measureContentBounds = function (bounds) { - if (this.minX === Infinity) { - bounds.setEmpty(); - } - else { - bounds.setTo(this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY); - } - }; - /** - * @private - * - */ - Graphics.prototype.$hitTest = function (stageX, stageY) { - var target = this.$targetDisplay; - var m = target.$getInvertedConcatenatedMatrix(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - var buffer = egret.sys.canvasHitTestBuffer; - buffer.resize(3, 3); - var node = this.$renderNode; - var matrix = egret.Matrix.create(); - matrix.identity(); - matrix.translate(1 - localX, 1 - localY); - egret.sys.canvasRenderer.drawNodeToBuffer(node, buffer, matrix, true); - egret.Matrix.release(matrix); - try { - var data = buffer.getPixels(1, 1); - if (data[3] === 0) { - return null; - } - } - catch (e) { - throw new Error(egret.sys.tr(1039)); - } - return target; - }; - /** - * @private - */ - Graphics.prototype.$onRemoveFromStage = function () { - if (this.$renderNode) { - this.$renderNode.clean(); - } - if (egret.nativeRender) { - egret_native.NativeDisplayObject.disposeGraphicData(this); - } - }; - return Graphics; - }(egret.HashObject)); - egret.Graphics = Graphics; - __reflect(Graphics.prototype, "egret.Graphics"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var PI = Math.PI; - var TwoPI = PI * 2; - var DEG_TO_RAD = PI / 180; - var matrixPool = []; - /** - * The Matrix class represents a transformation matrix that determines how to map points from one coordinate space to - * another. You can perform various graphical transformations on a display object by setting the properties of a Matrix - * object, applying that Matrix object to the matrix property of a display object, These transformation functions include - * translation (x and y repositioning), rotation, scaling, and skewing. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language en_US - */ - /** - * Matrix 类表示一个转换矩阵,它确定如何将点从一个坐标空间映射到另一个坐标空间。 - * 您可以对一个显示对象执行不同的图形转换,方法是设置 Matrix 对象的属性,将该 Matrix - * 对象应用于显示对象的 matrix 属性。这些转换函数包括平移(x 和 y 重新定位)、旋转、缩放和倾斜。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language zh_CN - */ - var Matrix = (function (_super) { - __extends(Matrix, _super); - /** - * Creates a new Matrix object with the specified parameters. - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定参数创建一个 Matrix 对象 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Matrix(a, b, c, d, tx, ty) { - if (a === void 0) { a = 1; } - if (b === void 0) { b = 0; } - if (c === void 0) { c = 0; } - if (d === void 0) { d = 1; } - if (tx === void 0) { tx = 0; } - if (ty === void 0) { ty = 0; } - var _this = _super.call(this) || this; - _this.a = a; - _this.b = b; - _this.c = c; - _this.d = d; - _this.tx = tx; - _this.ty = ty; - return _this; - } - /** - * Releases a matrix instance to the object pool - * @param matrix matrix that Needs to be recycled - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Matrix实例到对象池 - * @param matrix 需要回收的 matrix - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.release = function (matrix) { - if (!matrix) { - return; - } - matrixPool.push(matrix); - }; - /** - * get a matrix instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Matrix对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.create = function () { - var matrix = matrixPool.pop(); - if (!matrix) { - matrix = new Matrix(); - } - return matrix; - }; - /** - * Returns a new Matrix object that is a clone of this matrix, with an exact copy of the contained object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Matrix 对象,它是此矩阵的克隆,带有与所含对象完全相同的副本。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.clone = function () { - return new Matrix(this.a, this.b, this.c, this.d, this.tx, this.ty); - }; - /** - * Concatenates a matrix with the current matrix, effectively combining the geometric effects of the two. In mathematical - * terms, concatenating two matrixes is the same as combining them using matrix multiplication. - * @param other The matrix to be concatenated to the source matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将某个矩阵与当前矩阵连接,从而将这两个矩阵的几何效果有效地结合在一起。在数学术语中,将两个矩阵连接起来与使用矩阵乘法将它们结合起来是相同的。 - * @param other 要连接到源矩阵的矩阵。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.concat = function (other) { - var a = this.a * other.a; - var b = 0.0; - var c = 0.0; - var d = this.d * other.d; - var tx = this.tx * other.a + other.tx; - var ty = this.ty * other.d + other.ty; - if (this.b !== 0.0 || this.c !== 0.0 || other.b !== 0.0 || other.c !== 0.0) { - a += this.b * other.c; - d += this.c * other.b; - b += this.a * other.b + this.b * other.d; - c += this.c * other.a + this.d * other.c; - tx += this.ty * other.c; - ty += this.tx * other.b; - } - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.tx = tx; - this.ty = ty; - }; - /** - * Copies all of the matrix data from the source Point object into the calling Matrix object. - * @param other The Matrix object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Matrix 对象中的所有矩阵数据复制到调用方 Matrix 对象中。 - * @param other 要拷贝的目标矩阵 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.copyFrom = function (other) { - this.a = other.a; - this.b = other.b; - this.c = other.c; - this.d = other.d; - this.tx = other.tx; - this.ty = other.ty; - return this; - }; - /** - * Sets each matrix property to a value that causes a null transformation. An object transformed by applying an - * identity matrix will be identical to the original. After calling the identity() method, the resulting matrix - * has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为每个矩阵属性设置一个值,该值将导致矩阵无转换。通过应用恒等矩阵转换的对象将与原始对象完全相同。 - * 调用 identity() 方法后,生成的矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0 和 ty=0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.identity = function () { - this.a = this.d = 1; - this.b = this.c = this.tx = this.ty = 0; - }; - /** - * Performs the opposite transformation of the original matrix. You can apply an inverted matrix to an object to - * undo the transformation performed when applying the original matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行原始矩阵的逆转换。 - * 您可以将一个逆矩阵应用于对象来撤消在应用原始矩阵时执行的转换。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.invert = function () { - this.$invertInto(this); - }; - /** - * @private - */ - Matrix.prototype.$invertInto = function (target) { - var a = this.a; - var b = this.b; - var c = this.c; - var d = this.d; - var tx = this.tx; - var ty = this.ty; - if (b == 0 && c == 0) { - target.b = target.c = 0; - if (a == 0 || d == 0) { - target.a = target.d = target.tx = target.ty = 0; - } - else { - a = target.a = 1 / a; - d = target.d = 1 / d; - target.tx = -a * tx; - target.ty = -d * ty; - } - return; - } - var determinant = a * d - b * c; - if (determinant == 0) { - target.identity(); - return; - } - determinant = 1 / determinant; - var k = target.a = d * determinant; - b = target.b = -b * determinant; - c = target.c = -c * determinant; - d = target.d = a * determinant; - target.tx = -(k * tx + c * ty); - target.ty = -(b * tx + d * ty); - }; - /** - * Applies a rotation transformation to the Matrix object. - * The rotate() method alters the a, b, c, and d properties of the Matrix object. - * @param angle The rotation angle in radians. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对 Matrix 对象应用旋转转换。 - * rotate() 方法将更改 Matrix 对象的 a、b、c 和 d 属性。 - * @param angle 以弧度为单位的旋转角度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.rotate = function (angle) { - angle = +angle; - if (angle !== 0) { - angle = angle / DEG_TO_RAD; - var u = egret.NumberUtils.cos(angle); - var v = egret.NumberUtils.sin(angle); - var ta = this.a; - var tb = this.b; - var tc = this.c; - var td = this.d; - var ttx = this.tx; - var tty = this.ty; - this.a = ta * u - tb * v; - this.b = ta * v + tb * u; - this.c = tc * u - td * v; - this.d = tc * v + td * u; - this.tx = ttx * u - tty * v; - this.ty = ttx * v + tty * u; - } - }; - /** - * Applies a scaling transformation to the matrix. The x axis is multiplied by sx, and the y axis it is multiplied by sy. - * The scale() method alters the a and d properties of the Matrix object. - * @param sx A multiplier used to scale the object along the x axis. - * @param sy A multiplier used to scale the object along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对矩阵应用缩放转换。x 轴乘以 sx,y 轴乘以 sy。 - * scale() 方法将更改 Matrix 对象的 a 和 d 属性。 - * @param sx 用于沿 x 轴缩放对象的乘数。 - * @param sy 用于沿 y 轴缩放对象的乘数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.scale = function (sx, sy) { - if (sx !== 1) { - this.a *= sx; - this.c *= sx; - this.tx *= sx; - } - if (sy !== 1) { - this.b *= sy; - this.d *= sy; - this.ty *= sy; - } - }; - /** - * Sets the members of Matrix to the specified values - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Matrix 的成员设置为指定值 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.setTo = function (a, b, c, d, tx, ty) { - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.tx = tx; - this.ty = ty; - return this; - }; - /** - * Returns the result of applying the geometric transformation represented by the Matrix object to the specified point. - * @param pointX The x coordinate for which you want to get the result of the Matrix transformation. - * @param pointY The y coordinate for which you want to get the result of the Matrix transformation. - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns The point resulting from applying the Matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @param pointX 想要获得其矩阵转换结果的点的x坐标。 - * @param pointY 想要获得其矩阵转换结果的点的y坐标。 - * @param resultPoint 框架建议尽可能减少创建对象次数来优化性能,可以从外部传入一个复用的Point对象来存储结果,若不传入将创建一个新的Point对象返回。 - * @returns 由应用矩阵转换所产生的点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.transformPoint = function (pointX, pointY, resultPoint) { - var x = this.a * pointX + this.c * pointY + this.tx; - var y = this.b * pointX + this.d * pointY + this.ty; - if (resultPoint) { - resultPoint.setTo(x, y); - return resultPoint; - } - return new egret.Point(x, y); - }; - /** - * Translates the matrix along the x and y axes, as specified by the dx and dy parameters. - * @param dx The amount of movement along the x axis to the right, in pixels. - * @param dy The amount of movement down along the y axis, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 x 和 y 轴平移矩阵,由 dx 和 dy 参数指定。 - * @param dx 沿 x 轴向右移动的量(以像素为单位)。 - * @param dy 沿 y 轴向下移动的量(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.translate = function (dx, dy) { - this.tx += dx; - this.ty += dy; - }; - /** - * Determines whether two matrixes are equal. - * @param other The matrix to be compared. - * @returns A value of true if the object is equal to this Matrix object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否与另一个矩阵数据相等 - * @param other 要比较的另一个矩阵对象。 - * @returns 是否相等,ture表示相等。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.equals = function (other) { - return this.a == other.a && this.b == other.b && - this.c == other.c && this.d == other.d && - this.tx == other.tx && this.ty == other.ty; - }; - /** - * prepend matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 前置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.prepend = function (a, b, c, d, tx, ty) { - var tx1 = this.tx; - if (a != 1 || b != 0 || c != 0 || d != 1) { - var a1 = this.a; - var c1 = this.c; - this.a = a1 * a + this.b * c; - this.b = a1 * b + this.b * d; - this.c = c1 * a + this.d * c; - this.d = c1 * b + this.d * d; - } - this.tx = tx1 * a + this.ty * c + tx; - this.ty = tx1 * b + this.ty * d + ty; - return this; - }; - /** - * append matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 后置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.append = function (a, b, c, d, tx, ty) { - var a1 = this.a; - var b1 = this.b; - var c1 = this.c; - var d1 = this.d; - if (a != 1 || b != 0 || c != 0 || d != 1) { - this.a = a * a1 + b * c1; - this.b = a * b1 + b * d1; - this.c = c * a1 + d * c1; - this.d = c * b1 + d * d1; - } - this.tx = tx * a1 + ty * c1 + this.tx; - this.ty = tx * b1 + ty * d1 + this.ty; - return this; - }; - /** - * Given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs. - * Unlike the standard transformation applied using the transformPoint() method, the deltaTransformPoint() method's transformation does not consider the translation parameters tx and ty. - * @param point The point for which you want to get the result of the matrix transformation. - * @returns The point resulting from applying the matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果给定预转换坐标空间中的点,则此方法返回发生转换后该点的坐标。 - * 与使用 transformPoint() 方法应用的标准转换不同,deltaTransformPoint() 方法的转换不考虑转换参数 tx 和 ty。 - * @param point 想要获得其矩阵转换结果的点 - * @returns 由应用矩阵转换所产生的点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.deltaTransformPoint = function (point) { - var self = this; - var x = self.a * point.x + self.c * point.y; - var y = self.b * point.x + self.d * point.y; - return new egret.Point(x, y); - }; - /** - * Returns a text value listing the properties of the Matrix object. - * @returns A string containing the values of the properties of the Matrix object: a, b, c, d, tx, and ty. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @returns 一个字符串,它包含 Matrix 对象的属性值:a、b、c、d、tx 和 ty。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.toString = function () { - return "(a=" + this.a + ", b=" + this.b + ", c=" + this.c + ", d=" + this.d + ", tx=" + this.tx + ", ty=" + this.ty + ")"; - }; - /** - * Includes parameters for scaling, rotation, and translation. When applied to a matrix it sets the matrix's values based on those parameters. - * @param scaleX The factor by which to scale horizontally. - * @param scaleY The factor by which scale vertically. - * @param rotation The amount to rotate, in radians. - * @param tx The number of pixels to translate (move) to the right along the x axis. - * @param ty The number of pixels to translate (move) down along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 包括用于缩放、旋转和转换的参数。当应用于矩阵时,该方法会基于这些参数设置矩阵的值。 - * @param scaleX 水平缩放所用的系数 - * @param scaleY 垂直缩放所用的系数 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移(移动)的像素数 - * @param ty 沿 y 轴向下平移(移动)的像素数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.createBox = function (scaleX, scaleY, rotation, tx, ty) { - if (rotation === void 0) { rotation = 0; } - if (tx === void 0) { tx = 0; } - if (ty === void 0) { ty = 0; } - var self = this; - if (rotation !== 0) { - rotation = rotation / DEG_TO_RAD; - var u = egret.NumberUtils.cos(rotation); - var v = egret.NumberUtils.sin(rotation); - self.a = u * scaleX; - self.b = v * scaleY; - self.c = -v * scaleX; - self.d = u * scaleY; - } - else { - self.a = scaleX; - self.b = 0; - self.c = 0; - self.d = scaleY; - } - self.tx = tx; - self.ty = ty; - }; - /** - * Creates the specific style of matrix expected by the beginGradientFill() and lineGradientStyle() methods of the Graphics class. - * Width and height are scaled to a scaleX/scaleY pair and the tx/ty values are offset by half the width and height. - * @param width The width of the gradient box. - * @param height The height of the gradient box. - * @param rotation The amount to rotate, in radians. - * @param tx The distance, in pixels, to translate to the right along the x axis. This value is offset by half of the width parameter. - * @param ty The distance, in pixels, to translate down along the y axis. This value is offset by half of the height parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 Graphics 类的 beginGradientFill() 和 lineGradientStyle() 方法所需的矩阵的特定样式。 - * 宽度和高度被缩放为 scaleX/scaleY 对,而 tx/ty 值偏移了宽度和高度的一半。 - * @param width 渐变框的宽度 - * @param height 渐变框的高度 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移的距离(以像素为单位)。此值将偏移 width 参数的一半 - * @param ty 沿 y 轴向下平移的距离(以像素为单位)。此值将偏移 height 参数的一半 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Matrix.prototype.createGradientBox = function (width, height, rotation, tx, ty) { - if (rotation === void 0) { rotation = 0; } - if (tx === void 0) { tx = 0; } - if (ty === void 0) { ty = 0; } - this.createBox(width / 1638.4, height / 1638.4, rotation, tx + width / 2, ty + height / 2); - }; - /** - * @private - */ - Matrix.prototype.$transformBounds = function (bounds) { - var a = this.a; - var b = this.b; - var c = this.c; - var d = this.d; - var tx = this.tx; - var ty = this.ty; - var x = bounds.x; - var y = bounds.y; - var xMax = x + bounds.width; - var yMax = y + bounds.height; - var x0 = a * x + c * y + tx; - var y0 = b * x + d * y + ty; - var x1 = a * xMax + c * y + tx; - var y1 = b * xMax + d * y + ty; - var x2 = a * xMax + c * yMax + tx; - var y2 = b * xMax + d * yMax + ty; - var x3 = a * x + c * yMax + tx; - var y3 = b * x + d * yMax + ty; - var tmp = 0; - if (x0 > x1) { - tmp = x0; - x0 = x1; - x1 = tmp; - } - if (x2 > x3) { - tmp = x2; - x2 = x3; - x3 = tmp; - } - bounds.x = Math.floor(x0 < x2 ? x0 : x2); - bounds.width = Math.ceil((x1 > x3 ? x1 : x3) - bounds.x); - if (y0 > y1) { - tmp = y0; - y0 = y1; - y1 = tmp; - } - if (y2 > y3) { - tmp = y2; - y2 = y3; - y3 = tmp; - } - bounds.y = Math.floor(y0 < y2 ? y0 : y2); - bounds.height = Math.ceil((y1 > y3 ? y1 : y3) - bounds.y); - }; - /** - * @private - */ - Matrix.prototype.getDeterminant = function () { - return this.a * this.d - this.b * this.c; - }; - /** - * @private - */ - Matrix.prototype.$getScaleX = function () { - var m = this; - if (m.b == 0) { - return m.a; - } - var result = Math.sqrt(m.a * m.a + m.b * m.b); - return this.getDeterminant() < 0 ? -result : result; - }; - /** - * @private - */ - Matrix.prototype.$getScaleY = function () { - var m = this; - if (m.c == 0) { - return m.d; - } - var result = Math.sqrt(m.c * m.c + m.d * m.d); - return this.getDeterminant() < 0 ? -result : result; - }; - /** - * @private - */ - Matrix.prototype.$getSkewX = function () { - if (this.d < 0) { - return Math.atan2(this.d, this.c) + (PI / 2); - } - else { - return Math.atan2(this.d, this.c) - (PI / 2); - } - }; - /** - * @private - */ - Matrix.prototype.$getSkewY = function () { - if (this.a < 0) { - return Math.atan2(this.b, this.a) - PI; - } - else { - return Math.atan2(this.b, this.a); - } - }; - /** - * @private - */ - Matrix.prototype.$updateScaleAndRotation = function (scaleX, scaleY, skewX, skewY) { - if ((skewX == 0 || skewX == TwoPI) && (skewY == 0 || skewY == TwoPI)) { - this.a = scaleX; - this.b = this.c = 0; - this.d = scaleY; - return; - } - skewX = skewX / DEG_TO_RAD; - skewY = skewY / DEG_TO_RAD; - var u = egret.NumberUtils.cos(skewX); - var v = egret.NumberUtils.sin(skewX); - if (skewX == skewY) { - this.a = u * scaleX; - this.b = v * scaleX; - } - else { - this.a = egret.NumberUtils.cos(skewY) * scaleX; - this.b = egret.NumberUtils.sin(skewY) * scaleX; - } - this.c = -v * scaleY; - this.d = u * scaleY; - }; - /** - * @private - * target = other * this - */ - Matrix.prototype.$preMultiplyInto = function (other, target) { - var a = other.a * this.a; - var b = 0.0; - var c = 0.0; - var d = other.d * this.d; - var tx = other.tx * this.a + this.tx; - var ty = other.ty * this.d + this.ty; - if (other.b !== 0.0 || other.c !== 0.0 || this.b !== 0.0 || this.c !== 0.0) { - a += other.b * this.c; - d += other.c * this.b; - b += other.a * this.b + other.b * this.d; - c += other.c * this.a + other.d * this.c; - tx += other.ty * this.c; - ty += other.tx * this.b; - } - target.a = a; - target.b = b; - target.c = c; - target.d = d; - target.tx = tx; - target.ty = ty; - }; - return Matrix; - }(egret.HashObject)); - egret.Matrix = Matrix; - __reflect(Matrix.prototype, "egret.Matrix"); - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - egret.$TempMatrix = new Matrix(); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var rectanglePool = []; - /** - * A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its - * width and its height.
    - * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of - * one property has no effect on the others. However, the right and bottom properties are integrally related to those - * four properties. For example, if you change the value of the right property, the value of the width property changes; - * if you change the bottom property, the value of the height property changes. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language en_US - */ - /** - * Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
    - * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language zh_CN - */ - var Rectangle = (function (_super) { - __extends(Rectangle, _super); - /** - * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified - * width and height parameters. - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个新 Rectangle 对象,其左上角由 x 和 y 参数指定,并具有指定的 width 和 height 参数。 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Rectangle(x, y, width, height) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (width === void 0) { width = 0; } - if (height === void 0) { height = 0; } - var _this = _super.call(this) || this; - _this.x = x; - _this.y = y; - _this.width = width; - _this.height = height; - return _this; - } - /** - * Releases a rectangle instance to the object pool. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Rectangle实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.release = function (rect) { - if (!rect) { - return; - } - rectanglePool.push(rect); - }; - /** - * get a rectangle instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Rectangle对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.create = function () { - var rect = rectanglePool.pop(); - if (!rect) { - rect = new Rectangle(); - } - return rect; - }; - Object.defineProperty(Rectangle.prototype, "right", { - /** - * The sum of the x and width properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * x 和 width 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.x + this.width; - }, - set: function (value) { - this.width = value - this.x; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "bottom", { - /** - * The sum of the y and height properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * y 和 height 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.y + this.height; - }, - set: function (value) { - this.height = value - this.y; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "left", { - /** - * The x coordinate of the top-left corner of the rectangle. Changing the left property of a Rectangle object has - * no effect on the y and height properties. However it does affect the width property, whereas changing the x value - * does not affect the width property. - * The value of the left property is equal to the value of the x property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 x 坐标。更改 Rectangle 对象的 left 属性对 y 和 height 属性没有影响。但是,它会影响 width 属性,而更改 x 值不会影响 width 属性。 - * left 属性的值等于 x 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.x; - }, - set: function (value) { - this.width += this.x - value; - this.x = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "top", { - /** - * The y coordinate of the top-left corner of the rectangle. Changing the top property of a Rectangle object has - * no effect on the x and width properties. However it does affect the height property, whereas changing the y - * value does not affect the height property.
    - * The value of the top property is equal to the value of the y property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 y 坐标。更改 Rectangle 对象的 top 属性对 x 和 width 属性没有影响。但是,它会影响 height 属性,而更改 y 值不会影响 height 属性。
    - * top 属性的值等于 y 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.y; - }, - set: function (value) { - this.height += this.y - value; - this.y = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "topLeft", { - /** - * The location of the Rectangle object's top-left corner, determined by the x and y coordinates of the point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由该点的 x 和 y 坐标确定的 Rectangle 对象左上角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return new egret.Point(this.left, this.top); - }, - set: function (value) { - this.top = value.y; - this.left = value.x; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "bottomRight", { - /** - * The location of the Rectangle object's bottom-right corner, determined by the values of the right and bottom properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由 right 和 bottom 属性的值确定的 Rectangle 对象的右下角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return new egret.Point(this.right, this.bottom); - }, - set: function (value) { - this.bottom = value.y; - this.right = value.x; - }, - enumerable: true, - configurable: true - }); - /** - * Copies all of rectangle data from the source Rectangle object into the calling Rectangle object. - * @param sourceRect The Rectangle object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Rectangle 对象中的所有矩形数据复制到调用方 Rectangle 对象中。 - * @param sourceRect 要从中复制数据的 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.copyFrom = function (sourceRect) { - this.x = sourceRect.x; - this.y = sourceRect.y; - this.width = sourceRect.width; - this.height = sourceRect.height; - return this; - }; - /** - * Sets the members of Rectangle to the specified values - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 的成员设置为指定值 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.setTo = function (x, y, width, height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - return this; - }; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * @param x The x coordinate (horizontal position) of the point. - * @param y The y coordinate (vertical position) of the point. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * @param x 检测点的x轴 - * @param y 检测点的y轴 - * @returns 如果检测点位于矩形内,返回true,否则,返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.contains = function (x, y) { - return this.x <= x && - this.x + this.width >= x && - this.y <= y && - this.y + this.height >= y; - }; - /** - * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns - * the area of intersection as a Rectangle object. If the rectangles do not intersect, this method returns an empty - * Rectangle object with its properties set to 0. - * @param toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object. - * @returns A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method - * returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果在 toIntersect 参数中指定的 Rectangle 对象与此 Rectangle 对象相交,则返回交集区域作为 Rectangle 对象。如果矩形不相交, - * 则此方法返回一个空的 Rectangle 对象,其属性设置为 0。 - * @param toIntersect 要对照比较以查看其是否与此 Rectangle 对象相交的 Rectangle 对象。 - * @returns 等于交集区域的 Rectangle 对象。如果该矩形不相交,则此方法返回一个空的 Rectangle 对象;即,其 x、y、width 和 - * height 属性均设置为 0 的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.intersection = function (toIntersect) { - return this.clone().$intersectInPlace(toIntersect); - }; - /** - * Increases the size of the Rectangle object by the specified amounts, in pixels. - * The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. - * @param dx The value to be added to the left and the right of the Rectangle object. - * @param dy The value to be added to the top and the bottom of the Rectangle. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量增加 Rectangle 对象的大小(以像素为单位) - * 保持 Rectangle 对象的中心点不变,使用 dx 值横向增加它的大小,使用 dy 值纵向增加它的大小。 - * @param dx Rectangle 对象横向增加的值。 - * @param dy Rectangle 对象纵向增加的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.inflate = function (dx, dy) { - this.x -= dx; - this.width += 2 * dx; - this.y -= dy; - this.height += 2 * dy; - }; - /** - * @private - */ - Rectangle.prototype.$intersectInPlace = function (clipRect) { - var x0 = this.x; - var y0 = this.y; - var x1 = clipRect.x; - var y1 = clipRect.y; - var l = Math.max(x0, x1); - var r = Math.min(x0 + this.width, x1 + clipRect.width); - if (l <= r) { - var t = Math.max(y0, y1); - var b = Math.min(y0 + this.height, y1 + clipRect.height); - if (t <= b) { - this.setTo(l, t, r - l, b - t); - return this; - } - } - this.setEmpty(); - return this; - }; - /** - * Determines whether the object specified in the toIntersect parameter intersects with this Rectangle object. - * This method checks the x, y, width, and height properties of the specified Rectangle object to see if it - * intersects with this Rectangle object. - * @param toIntersect The Rectangle object to compare against this Rectangle object. - * @returns A value of true if the specified object intersects with this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toIntersect 参数中指定的对象是否与此 Rectangle 对象相交。此方法检查指定的 Rectangle - * 对象的 x、y、width 和 height 属性,以查看它是否与此 Rectangle 对象相交。 - * @param toIntersect 要与此 Rectangle 对象比较的 Rectangle 对象。 - * @returns 如果两个矩形相交,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.intersects = function (toIntersect) { - return Math.max(this.x, toIntersect.x) <= Math.min(this.right, toIntersect.right) - && Math.max(this.y, toIntersect.y) <= Math.min(this.bottom, toIntersect.bottom); - }; - /** - * Determines whether or not this Rectangle object is empty. - * @returns A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象是否为空。 - * @returns 如果 Rectangle 对象的宽度或高度小于等于 0,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.isEmpty = function () { - return this.width <= 0 || this.height <= 0; - }; - /** - * Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 对象的所有属性设置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.setEmpty = function () { - this.x = 0; - this.y = 0; - this.width = 0; - this.height = 0; - }; - /** - * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @returns A new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @returns 新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.clone = function () { - return new Rectangle(this.x, this.y, this.width, this.height); - }; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter. - * @param point The point, as represented by its x and y coordinates. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * 此方法与 Rectangle.contains() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 包含点对象 - * @returns 如果包含,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.containsPoint = function (point) { - if (this.x <= point.x - && this.x + this.width > point.x - && this.y <= point.y - && this.y + this.height > point.y) { - return true; - } - return false; - }; - /** - * Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object. - * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. - * @param rect The Rectangle object being checked. - * @returns A value of true if the Rectangle object that you specify is contained by this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象内是否包含由 rect 参数指定的 Rectangle 对象。 - * 如果一个 Rectangle 对象完全在另一个 Rectangle 的边界内,我们说第二个 Rectangle 包含第一个 Rectangle。 - * @param rect 所检查的 Rectangle 对象 - * @returns 如果此 Rectangle 对象包含您指定的 Rectangle 对象,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.containsRect = function (rect) { - var r1 = rect.x + rect.width; - var b1 = rect.y + rect.height; - var r2 = this.x + this.width; - var b2 = this.y + this.height; - return (rect.x >= this.x) && (rect.x < r2) && (rect.y >= this.y) && (rect.y < b2) && (r1 > this.x) && (r1 <= r2) && (b1 > this.y) && (b1 <= b2); - }; - /** - * Determines whether the object specified in the toCompare parameter is equal to this Rectangle object. - * This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object. - * @param The rectangle to compare to this Rectangle object. - * @returns A value of true if the object has exactly the same values for the x, y, width, and height properties as this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toCompare 参数中指定的对象是否等于此 Rectangle 对象。 - * 此方法将某个对象的 x、y、width 和 height 属性与此 Rectangle 对象所对应的相同属性进行比较。 - * @param toCompare 要与此 Rectangle 对象进行比较的矩形。 - * @returns 如果对象具有与此 Rectangle 对象完全相同的 x、y、width 和 height 属性值,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.equals = function (toCompare) { - if (this === toCompare) { - return true; - } - return this.x === toCompare.x && this.y === toCompare.y - && this.width === toCompare.width && this.height === toCompare.height; - }; - /** - * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter. - * @param point 此 Point 对象的 x 属性用于增加 Rectangle 对象的水平尺寸。y 属性用于增加 Rectangle 对象的垂直尺寸。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 增加 Rectangle 对象的大小。此方法与 Rectangle.inflate() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.inflatePoint = function (point) { - this.inflate(point.x, point.y); - }; - /** - * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. - * @param dx Moves the x value of the Rectangle object by this amount. - * @param dy Moves the y value of the Rectangle object by this amount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量调整 Rectangle 对象的位置(由其左上角确定)。 - * @param dx 将 Rectangle 对象的 x 值移动此数量。 - * @param dy 将 Rectangle 对象的 t 值移动此数量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.offset = function (dx, dy) { - this.x += dx; - this.y += dy; - }; - /** - * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter. - * @param point A Point object to use to offset this Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 对象用作参数来调整 Rectangle 对象的位置。此方法与 Rectangle.offset() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 要用于偏移此 Rectangle 对象的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.offsetPoint = function (point) { - this.offset(point.x, point.y); - }; - /** - * Builds and returns a string that lists the horizontal and vertical positions and the width and height of the Rectangle object. - * @returns A string listing the value of each of the following properties of the Rectangle object: x, y, width, and height. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 生成并返回一个字符串,该字符串列出 Rectangle 对象的水平位置和垂直位置以及高度和宽度。 - * @returns 一个字符串,它列出了 Rectangle 对象的下列各个属性的值:x、y、width 和 height。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.toString = function () { - return "(x=" + this.x + ", y=" + this.y + ", width=" + this.width + ", height=" + this.height + ")"; - }; - /** - * Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles. - * @param toUnion A Rectangle object to add to this Rectangle object. - * @returns A new Rectangle object that is the union of the two rectangles. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过填充两个矩形之间的水平和垂直空间,将这两个矩形组合在一起以创建一个新的 Rectangle 对象。 - * @param toUnion 要添加到此 Rectangle 对象的 Rectangle 对象。 - * @returns 充当两个矩形的联合的新 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Rectangle.prototype.union = function (toUnion) { - var result = this.clone(); - if (toUnion.isEmpty()) { - return result; - } - if (result.isEmpty()) { - result.copyFrom(toUnion); - return result; - } - var l = Math.min(result.x, toUnion.x); - var t = Math.min(result.y, toUnion.y); - result.setTo(l, t, Math.max(result.right, toUnion.right) - l, Math.max(result.bottom, toUnion.bottom) - t); - return result; - }; - /** - * @private - */ - Rectangle.prototype.$getBaseWidth = function (angle) { - var u = Math.abs(Math.cos(angle)); - var v = Math.abs(Math.sin(angle)); - return u * this.width + v * this.height; - }; - /** - * @private - */ - Rectangle.prototype.$getBaseHeight = function (angle) { - var u = Math.abs(Math.cos(angle)); - var v = Math.abs(Math.sin(angle)); - return v * this.width + u * this.height; - }; - return Rectangle; - }(egret.HashObject)); - egret.Rectangle = Rectangle; - __reflect(Rectangle.prototype, "egret.Rectangle"); - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - egret.$TempRectangle = new Rectangle(); -})(egret || (egret = {})); -var egret; -(function (egret) { - egret.$locale_strings = egret.$locale_strings || {}; - egret.$locale_strings["en_US"] = egret.$locale_strings["en_US"] || {}; - var locale_strings = egret.$locale_strings["en_US"]; - //core 1000-1999 - locale_strings[1001] = "Could not find Egret entry class: {0}。"; - locale_strings[1002] = "Egret entry class '{0}' must inherit from egret.DisplayObject."; - locale_strings[1003] = "Parameter {0} must be non-null."; - locale_strings[1004] = "An object cannot be added as a child to one of it's children (or children's children, etc.)."; - locale_strings[1005] = "An object cannot be added as a child of itself."; - locale_strings[1006] = "The supplied DisplayObject must be a child of the caller."; - locale_strings[1007] = "An index specified for a parameter was out of range."; - locale_strings[1008] = "Instantiate singleton error,singleton class {0} can not create multiple instances."; - locale_strings[1009] = "the Class {0} cannot use the property \"{1}\""; - locale_strings[1010] = "the property \"{1}\" of the Class \"{0}\" is readonly"; - locale_strings[1011] = "Stream Error. URL: {0}"; - locale_strings[1012] = "The type of parameter {0} must be Class."; - locale_strings[1013] = "Variable assignment is NaN, please see the code!"; - locale_strings[1014] = "the constant \"{1}\" of the Class \"{0}\" is read-only"; - locale_strings[1015] = "xml not found!"; - locale_strings[1016] = "{0}has been obsoleted"; - locale_strings[1017] = "The format of JSON file is incorrect: {0}\ndata: {1}"; - locale_strings[1018] = "the scale9Grid is not correct"; - locale_strings[1019] = "Network ab:{0}"; - locale_strings[1020] = "Cannot initialize Shader"; - locale_strings[1021] = "Current browser does not support webgl"; - locale_strings[1022] = "{0} ArgumentError"; - locale_strings[1023] = "This method is not available in the ScrollView!"; - locale_strings[1025] = "end of the file"; - locale_strings[1026] = "! EncodingError The code point {0} could not be encoded."; - locale_strings[1027] = "DecodingError"; - locale_strings[1028] = ". called injection is not configured rule: {0}, please specify configuration during its initial years of injection rule, and then call the corresponding single case."; - locale_strings[1029] = "Function.prototype.bind - what is trying to be bound is not callable"; - locale_strings[1033] = "Photos can not be used across domains toDataURL to convert base64"; - locale_strings[1034] = "Music file decoding failed: \"{0}\", please use the standard conversion tool reconversion under mp3."; - locale_strings[1035] = "Native does not support this feature!"; - locale_strings[1036] = "Sound has stopped, please recall Sound.play () to play the sound!"; - locale_strings[1037] = "Non-load the correct blob!"; - locale_strings[1038] = "XML format error!"; - locale_strings[1039] = "Cross domains pictures can not get pixel information!"; - locale_strings[1040] = "hitTestPoint can not detect crossOrigin images! Please check if the display object has crossOrigin elements."; - locale_strings[1041] = "{0} is deprecated, please use {1} replace"; - locale_strings[1042] = "The parameters passed in the region needs is an integer in drawToTexture method. Otherwise, some browsers will draw abnormal."; - locale_strings[1043] = "Compile errors in {0}, the attribute name: {1}, the attribute value: {2}."; - locale_strings[1044] = "The current version of the Runtime does not support video playback, please use the latest version"; - locale_strings[1045] = "The resource url is not found"; - locale_strings[1046] = "BitmapText no corresponding characters: {0}, please check the configuration file"; - locale_strings[1047] = "egret.localStorage.setItem save failed,key={0}&value={1}"; - locale_strings[1048] = "Video loading failed"; - locale_strings[1049] = "In the absence of sound is not allowed to play after loading"; - locale_strings[1050] = "ExternalInterface calls the method without js registration: {0}"; - locale_strings[1051] = "runtime only support webgl render mode"; - locale_strings[1052] = "network request timeout{0}"; - //gui 3000-3099 - locale_strings[3000] = "Theme configuration file failed to load: {0}"; - locale_strings[3001] = "Cannot find the skin name which is configured in Theme: {0}"; - locale_strings[3002] = "Index:\"{0}\" is out of the collection element index range"; - locale_strings[3003] = "Cannot be available in this component. If this component is container, please continue to use"; - locale_strings[3004] = "addChild(){0}addElement() replace"; - locale_strings[3005] = "addChildAt(){0}addElementAt() replace"; - locale_strings[3006] = "removeChild(){0}removeElement() replace"; - locale_strings[3007] = "removeChildAt(){0}removeElementAt() replace"; - locale_strings[3008] = "setChildIndex(){0}setElementIndex() replace"; - locale_strings[3009] = "swapChildren(){0}swapElements() replace"; - locale_strings[3010] = "swapChildrenAt(){0}swapElementsAt() replace"; - locale_strings[3011] = "Index:\"{0}\" is out of the visual element index range"; - locale_strings[3012] = "This method is not available in Scroller component!"; - locale_strings[3013] = "UIStage is GUI root container, and only one such instant is in the display list!"; - locale_strings[3014] = "set fullscreen error"; - //socket 3100-3199 - locale_strings[3100] = "Current browser does not support WebSocket"; - locale_strings[3101] = "Please connect Socket firstly"; - locale_strings[3102] = "Please set the type of binary type"; - //RES 3200-3299 - locale_strings[3200] = "getResByUrl must be called after loadConfig"; - //db 4000-4299 - locale_strings[4000] = "An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)"; - locale_strings[4001] = "Abstract class can not be instantiated!"; - locale_strings[4002] = "Unnamed data!"; - locale_strings[4003] = "Nonsupport version!"; - //4500-5000 platform - locale_strings[4500] = "The platform does not support {0} adapter mode and has been automatically replaced with {1} mode, please modify your code adapter logic"; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The JointStyle class is an enumeration of constant values that specify the joint style to use in drawing lines. - * These constants are provided for use as values in the joints parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * JointStyle 类是指定要在绘制线条中使用的联接点样式的常量值枚举。提供的这些常量用作 egret.Graphics.lineStyle() 方法的 joints 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - egret.JointStyle = { - /** - * Specifies beveled joints in the joints parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在 egret.Graphics.lineStyle() 方法的 joints 参数中指定斜角连接。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - BEVEL: "bevel", - /** - * Specifies mitered joints in the joints parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在 egret.Graphics.lineStyle() 方法的 joints 参数中指定尖角连接。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - MITER: "miter", - /** - * Specifies round joints in the joints parameter of the egret.Graphics.lineStyle() method. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在 egret.Graphics.lineStyle() 方法的 joints 参数中指定圆角连接。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - ROUND: "round" - }; -})(egret || (egret = {})); -var egret; -(function (egret) { - egret.$locale_strings = egret.$locale_strings || {}; - egret.$locale_strings["zh_CN"] = egret.$locale_strings["zh_CN"] || {}; - var locale_strings = egret.$locale_strings["zh_CN"]; - //eui 2000-2999 - //core 1000-1999 - locale_strings[1001] = "找不到Egret入口类: {0}。"; - locale_strings[1002] = "Egret入口类 {0} 必须继承自egret.DisplayObject。"; - locale_strings[1003] = "参数 {0} 不能为 null。"; - locale_strings[1004] = "无法将对象添加为它的一个子对象(或子对象的子对象等)的子对象。"; - locale_strings[1005] = "不能将对象添加为其自身的子对象。"; - locale_strings[1006] = "提供的 DisplayObject 必须是调用者的子级。"; - locale_strings[1007] = "为参数指定的索引不在范围内。"; - locale_strings[1008] = "实例化单例出错,不允许实例化多个 {0} 对象。"; - locale_strings[1009] = "类 {0} 不可以使用属性 {1}"; - locale_strings[1010] = "类 {0} 属性 {1} 是只读的"; - locale_strings[1011] = "流错误。URL: {0}"; - locale_strings[1012] = "参数 {0} 的类型必须为 Class。"; - locale_strings[1013] = "变量赋值为NaN,请查看代码!"; - locale_strings[1014] = "类 {0} 常量 {1} 是只读的"; - locale_strings[1015] = "xml not found!"; - locale_strings[1016] = "{0}已经废弃"; - locale_strings[1017] = "JSON文件格式不正确: {0}\ndata: {1}"; - locale_strings[1018] = "9宫格设置错误"; - locale_strings[1019] = "网络异常:{0}"; - locale_strings[1020] = "无法初始化着色器"; - locale_strings[1021] = "当前浏览器不支持webgl"; - locale_strings[1022] = "{0} ArgumentError"; - locale_strings[1023] = "此方法在ScrollView内不可用!"; - locale_strings[1025] = "遇到文件尾"; - locale_strings[1026] = "EncodingError! The code point {0} could not be encoded."; - locale_strings[1027] = "DecodingError"; - locale_strings[1028] = "调用了未配置的注入规则:{0}。 请先在项目初始化里配置指定的注入规则,再调用对应单例。"; - locale_strings[1029] = "Function.prototype.bind - what is trying to be bound is not callable"; - locale_strings[1033] = "跨域图片不可以使用toDataURL来转换成base64"; - locale_strings[1034] = "音乐文件解码失败:\"{0}\",请使用标准的转换工具重新转换下mp3。"; - locale_strings[1035] = "Native 下暂未实现此功能!"; - locale_strings[1036] = "声音已停止,请重新调用 Sound.play() 来播放声音!"; - locale_strings[1037] = "非正确的blob加载!"; - locale_strings[1038] = "XML 格式错误!"; - locale_strings[1039] = "跨域图片不能获取像素信息!"; - locale_strings[1040] = "hitTestPoint 不能对跨域图片进行检测! 请检查该显示对象内是否含有跨域元素"; - locale_strings[1041] = "{0} 已废弃,请使用 {1} 代替"; - locale_strings[1042] = "drawToTexture方法传入的区域各个参数需要为整数,否则某些浏览器绘制会出现异常"; - locale_strings[1043] = "{0} 中存在编译错误,属性名 : {1},属性值 : {2}"; - locale_strings[1044] = "当前的 runtime 版本不支持视频播放,请使用最新的版本"; - locale_strings[1045] = "没有设置要加载的资源地址"; - locale_strings[1046] = "BitmapText 找不到对应字符:{0},请检查配置文件"; - locale_strings[1047] = "egret.localStorage.setItem保存失败,key={0}&value={1}"; - locale_strings[1048] = "视频加载失败"; - locale_strings[1049] = "声音在没有加载完之前不允许播放"; - locale_strings[1050] = "ExternalInterface调用了js没有注册的方法: {0}"; - locale_strings[1051] = "runtime 只支持 webgl 渲染模式"; - locale_strings[1052] = "网络请求超时:{0}"; - //gui 3000-3099 - locale_strings[3000] = "主题配置文件加载失败: {0}"; - locale_strings[3001] = "找不到主题中所配置的皮肤类名: {0}"; - locale_strings[3002] = "索引:\"{0}\"超出集合元素索引范围"; - locale_strings[3003] = "在此组件中不可用,若此组件为容器类,请使用"; - locale_strings[3004] = "addChild(){0}addElement()代替"; - locale_strings[3005] = "addChildAt(){0}addElementAt()代替"; - locale_strings[3006] = "removeChild(){0}removeElement()代替"; - locale_strings[3007] = "removeChildAt(){0}removeElementAt()代替"; - locale_strings[3008] = "setChildIndex(){0}setElementIndex()代替"; - locale_strings[3009] = "swapChildren(){0}swapElements()代替"; - locale_strings[3010] = "swapChildrenAt(){0}swapElementsAt()代替"; - locale_strings[3011] = "索引:\"{0}\"超出可视元素索引范围"; - locale_strings[3012] = "此方法在Scroller组件内不可用!"; - locale_strings[3013] = "UIStage是GUI根容器,只能有一个此实例在显示列表中!"; - locale_strings[3014] = "设置全屏模式失败"; - //socket 3100-3199 - locale_strings[3100] = "当前浏览器不支持WebSocket"; - locale_strings[3101] = "请先连接WebSocket"; - locale_strings[3102] = "请先设置type为二进制类型"; - //RES 3200-3299 - locale_strings[3200] = "getResByUrl 必须在 loadConfig 之后调用"; - //db 4000-4299 - locale_strings[4000] = "An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)"; - locale_strings[4001] = "Abstract class can not be instantiated!"; - locale_strings[4002] = "Unnamed data!"; - locale_strings[4003] = "Nonsupport version!"; - //4500-5000 platform - locale_strings[4500] = "该平台不支持 {0} 适配模式,已经自动替换为 {1} 模式,请修改您的代码适配逻辑"; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/localStorage/localStorage.ts - */ -var egret; -(function (egret) { - var localStorage; - (function (localStorage) { - })(localStorage = egret.localStorage || (egret.localStorage = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - var usingChannel = []; - /** - * @private - * @param channel - */ - function $pushSoundChannel(channel) { - if (usingChannel.indexOf(channel) < 0) { - usingChannel.push(channel); - } - } - sys.$pushSoundChannel = $pushSoundChannel; - /** - * @private - * @param channel - */ - function $popSoundChannel(channel) { - var index = usingChannel.indexOf(channel); - if (index >= 0) { - usingChannel.splice(index, 1); - return true; - } - return false; - } - sys.$popSoundChannel = $popSoundChannel; - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The HttpMethod class provides values that specify whether the HttpRequest object should use the POST method - * or the GET method when sending data to a server. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HttpRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时, - * HttpRequest 对象应使用 POST 方法还是 GET 方法。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var HttpMethod; - (function (HttpMethod) { - /** - * Specifies that the HttpRequest object is a GET. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 GET。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HttpMethod.GET = "GET"; - /** - * Specifies that the HttpRequest object is a POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HttpMethod.POST = "POST"; - })(HttpMethod = egret.HttpMethod || (egret.HttpMethod = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The HttpResponseType class provides values that specify how downloaded data is received. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var HttpResponseType = (function () { - function HttpResponseType() { - } - /** - * Specifies that downloaded data is received as text. This is the default value of HttpRequest.responseType - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回字符串。HttpRequest.responseType属性的默认值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HttpResponseType.TEXT = "text"; - /** - * Specifies that downloaded data is received as raw binary data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回二进制的ArrayBuffer对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HttpResponseType.ARRAY_BUFFER = "arraybuffer"; - return HttpResponseType; - }()); - egret.HttpResponseType = HttpResponseType; - __reflect(HttpResponseType.prototype, "egret.HttpResponseType"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - var displayListPool = []; - var blendModes = ["source-over", "lighter", "destination-out"]; - var defaultCompositeOp = "source-over"; - /** - * @private - * 显示列表 - */ - var DisplayList = (function (_super) { - __extends(DisplayList, _super); - /** - * @private - * 创建一个DisplayList对象 - */ - function DisplayList(root) { - var _this = _super.call(this) || this; - _this.isStage = false; - /** - * 位图渲染节点 - */ - _this.$renderNode = new sys.BitmapNode(); - /** - * @private - */ - _this.renderBuffer = null; - /** - * @private - */ - _this.offsetX = 0; - /** - * @private - */ - _this.offsetY = 0; - /** - * @private - */ - _this.offsetMatrix = new egret.Matrix(); - _this.$canvasScaleX = 1; - _this.$canvasScaleY = 1; - _this.root = root; - _this.isStage = (root instanceof egret.Stage); - return _this; - } - /** - * 创建一个DisplayList对象,若内存不足或无法创建RenderBuffer,将会返回null。 - */ - DisplayList.create = function (target) { - var displayList = new egret.sys.DisplayList(target); - try { - var buffer = new sys.RenderBuffer(); - displayList.renderBuffer = buffer; - } - catch (e) { - return null; - } - displayList.root = target; - return displayList; - }; - /** - * @private - * 获取渲染节点 - */ - DisplayList.prototype.$getRenderNode = function () { - return this.$renderNode; - }; - /** - * @private - * 设置剪裁边界,不再绘制完整目标对象,画布尺寸由外部决定,超过边界的节点将跳过绘制。 - */ - DisplayList.prototype.setClipRect = function (width, height) { - width *= DisplayList.$canvasScaleX; - height *= DisplayList.$canvasScaleY; - this.renderBuffer.resize(width, height); - }; - /** - * @private - * 绘制根节点显示对象到目标画布,返回draw的次数。 - */ - DisplayList.prototype.drawToSurface = function () { - var drawCalls = 0; - this.$canvasScaleX = this.offsetMatrix.a = DisplayList.$canvasScaleX; - this.$canvasScaleY = this.offsetMatrix.d = DisplayList.$canvasScaleY; - if (!this.isStage) { - this.changeSurfaceSize(); - } - var buffer = this.renderBuffer; - buffer.clear(); - drawCalls = sys.systemRenderer.render(this.root, buffer, this.offsetMatrix); - if (!this.isStage) { - var surface = buffer.surface; - var renderNode = this.$renderNode; - renderNode.drawData.length = 0; - var width = surface.width; - var height = surface.height; - if (!this.bitmapData) { - this.bitmapData = new egret.BitmapData(surface); - } - else { - this.bitmapData.source = surface; - this.bitmapData.width = width; - this.bitmapData.height = height; - } - renderNode.image = this.bitmapData; - renderNode.imageWidth = width; - renderNode.imageHeight = height; - renderNode.drawImage(0, 0, width, height, -this.offsetX, -this.offsetY, width / this.$canvasScaleX, height / this.$canvasScaleY); - } - return drawCalls; - }; - /** - * @private - * 改变画布的尺寸,由于画布尺寸修改会清空原始画布。所以这里将原始画布绘制到一个新画布上,再与原始画布交换。 - */ - DisplayList.prototype.changeSurfaceSize = function () { - var root = this.root; - var oldOffsetX = this.offsetX; - var oldOffsetY = this.offsetY; - var bounds = this.root.$getOriginalBounds(); - var scaleX = this.$canvasScaleX; - var scaleY = this.$canvasScaleY; - this.offsetX = -bounds.x; - this.offsetY = -bounds.y; - this.offsetMatrix.setTo(this.offsetMatrix.a, 0, 0, this.offsetMatrix.d, this.offsetX, this.offsetY); - var buffer = this.renderBuffer; - //在chrome里,小等于256*256的canvas会不启用GPU加速。 - var width = Math.max(257, bounds.width * scaleX); - var height = Math.max(257, bounds.height * scaleY); - if (this.offsetX == oldOffsetX && - this.offsetY == oldOffsetY && - buffer.surface.width == width && - buffer.surface.height == height) { - return; - } - buffer.resize(width, height); - }; - /** - * @private - */ - DisplayList.$setCanvasScale = function (x, y) { - DisplayList.$canvasScaleX = x; - DisplayList.$canvasScaleY = y; - if (egret.nativeRender) { - egret_native.nrSetCanvasScaleFactor(DisplayList.$canvasScaleFactor, x, y); - } - }; - DisplayList.$canvasScaleFactor = 1; - /** - * @private - */ - DisplayList.$canvasScaleX = 1; - DisplayList.$canvasScaleY = 1; - return DisplayList; - }(egret.HashObject)); - sys.DisplayList = DisplayList; - __reflect(DisplayList.prototype, "egret.sys.DisplayList"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * Egret播放器 - */ - var Player = (function (_super) { - __extends(Player, _super); - /** - * @private - * 实例化一个播放器对象。 - */ - function Player(buffer, stage, entryClassName) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.isPlaying = false; - if (true && !buffer) { - egret.$error(1003, "buffer"); - } - _this.entryClassName = entryClassName; - _this.stage = stage; - _this.screenDisplayList = _this.createDisplayList(stage, buffer); - _this.showFPS = false; - _this.showLog = false; - _this.stageDisplayList = null; - if (egret.nativeRender) { - egret_native.rootWebGLBuffer = buffer; - } - return _this; - } - /** - * @private - */ - Player.prototype.createDisplayList = function (stage, buffer) { - var displayList = new sys.DisplayList(stage); - displayList.renderBuffer = buffer; - stage.$displayList = displayList; - return displayList; - }; - /** - * @private - * 启动播放器 - */ - Player.prototype.start = function () { - if (this.isPlaying || !this.stage) { - return; - } - sys.$TempStage = sys.$TempStage || this.stage; - this.isPlaying = true; - if (!this.root) { - this.initialize(); - } - egret.ticker.$addPlayer(this); - }; - /** - * @private - */ - Player.prototype.initialize = function () { - var rootClass; - if (this.entryClassName) { - rootClass = egret.getDefinitionByName(this.entryClassName); - } - if (rootClass) { - var rootContainer = new rootClass(); - this.root = rootContainer; - if (rootContainer instanceof egret.DisplayObject) { - this.stage.addChild(rootContainer); - } - else { - true && egret.$error(1002, this.entryClassName); - } - } - else { - true && egret.$error(1001, this.entryClassName); - } - }; - /** - * @private - * 停止播放器,停止后将不能重新启动。 - */ - Player.prototype.stop = function () { - this.pause(); - this.stage = null; - }; - /** - * @private - * 暂停播放器,后续可以通过调用start()重新启动播放器。 - */ - Player.prototype.pause = function () { - if (!this.isPlaying) { - return; - } - this.isPlaying = false; - egret.ticker.$removePlayer(this); - }; - /** - * @private - * 渲染屏幕 - */ - Player.prototype.$render = function (triggerByFrame, costTicker) { - if (egret.nativeRender) { - egret_native.updateNativeRender(); - egret_native.nrRender(); - return; - } - var stage = this.stage; - var t1 = egret.getTimer(); - var drawCalls = stage.$displayList.drawToSurface(); - var t2 = egret.getTimer(); - if (triggerByFrame && this.showFPS) { - fpsDisplay.update(drawCalls, t2 - t1, costTicker); - } - }; - /** - * @private - * 更新舞台尺寸 - * @param stageWidth 舞台宽度(以像素为单位) - * @param stageHeight 舞台高度(以像素为单位) - */ - Player.prototype.updateStageSize = function (stageWidth, stageHeight) { - var stage = this.stage; - stage.$stageWidth = stageWidth; - stage.$stageHeight = stageHeight; - if (egret.nativeRender) { - egret_native.nrResize(stageWidth, stageHeight); - } - else { - this.screenDisplayList.setClipRect(stageWidth, stageHeight); - if (this.stageDisplayList) { - this.stageDisplayList.setClipRect(stageWidth, stageHeight); - } - } - stage.dispatchEventWith(egret.Event.RESIZE); - }; - /** - * @private - * 显示FPS。 - */ - Player.prototype.displayFPS = function (showFPS, showLog, logFilter, styles) { - showLog = !!showLog; - if (showLog) { - egret.log = function () { - var length = arguments.length; - var info = ""; - for (var i = 0; i < length; i++) { - info += arguments[i] + " "; - } - sys.$logToFPS(info); - console.log.apply(console, toArray(arguments)); - }; - egret.warn = function () { - var length = arguments.length; - var info = ""; - for (var i = 0; i < length; i++) { - info += arguments[i] + " "; - } - sys.$warnToFPS(info); - console.warn.apply(console, toArray(arguments)); - }; - egret.error = function () { - var length = arguments.length; - var info = ""; - for (var i = 0; i < length; i++) { - info += arguments[i] + " "; - } - sys.$errorToFPS(info); - console.error.apply(console, toArray(arguments)); - }; - } - this.showFPS = !!showFPS; - this.showLog = showLog; - if (!fpsDisplay) { - fpsDisplay = new FPS(this.stage, showFPS, showLog, logFilter, styles); - var logLength = logLines.length; - for (var i = 0; i < logLength; i++) { - fpsDisplay.updateInfo(logLines[i]); - } - logLines = null; - var warnLength = warnLines.length; - for (var i = 0; i < warnLength; i++) { - fpsDisplay.updateWarn(warnLines[i]); - } - warnLines = null; - var errorLength = errorLines.length; - for (var i = 0; i < errorLength; i++) { - fpsDisplay.updateError(errorLines[i]); - } - errorLines = null; - } - }; - return Player; - }(egret.HashObject)); - sys.Player = Player; - __reflect(Player.prototype, "egret.sys.Player"); - var logLines = []; - var warnLines = []; - var errorLines = []; - var fpsDisplay; - sys.$logToFPS = function (info) { - if (!fpsDisplay) { - logLines.push(info); - return; - } - fpsDisplay.updateInfo(info); - }; - sys.$warnToFPS = function (info) { - if (!fpsDisplay) { - warnLines.push(info); - return; - } - fpsDisplay.updateWarn(info); - }; - sys.$errorToFPS = function (info) { - if (!fpsDisplay) { - errorLines.push(info); - return; - } - fpsDisplay.updateError(info); - }; - var FPSImpl = (function () { - function FPSImpl(stage, showFPS, showLog, logFilter, styles) { - this.showFPS = showFPS; - this.showLog = showLog; - this.logFilter = logFilter; - this.styles = styles; - this.infoLines = []; - this.totalTime = 0; - this.totalTick = 0; - this.lastTime = 0; - this.drawCalls = 0; - this.costRender = 0; - this.costTicker = 0; - this.infoLines = []; - this.totalTime = 0; - this.totalTick = 0; - this.lastTime = 0; - this.drawCalls = 0; - this.costRender = 0; - this.costTicker = 0; - this._stage = stage; - this.showFPS = showFPS; - this.showLog = showLog; - this.logFilter = logFilter; - this.styles = styles; - this.fpsDisplay = new egret.FPSDisplay(stage, showFPS, showLog, logFilter, styles); - var logFilterRegExp; - try { - logFilterRegExp = logFilter ? new RegExp(logFilter) : null; - } - catch (e) { - egret.log(e); - } - this.filter = function (message) { - if (logFilterRegExp) - return logFilterRegExp.test(message); - return !logFilter || message.indexOf(logFilter) == 0; - }; - } - FPSImpl.prototype.update = function (drawCalls, costRender, costTicker) { - var current = egret.getTimer(); - this.totalTime += current - this.lastTime; - this.lastTime = current; - //todo 多Player - this.totalTick++; - this.drawCalls += drawCalls; - this.costRender += costRender; - this.costTicker += costTicker; - if (this.totalTime >= 1000) { - var lastFPS = Math.min(Math.ceil(this.totalTick * 1000 / this.totalTime), egret.ticker.$frameRate); - var lastDrawCalls = Math.round(this.drawCalls / this.totalTick); - var lastCostRender = Math.round(this.costRender / this.totalTick); - var lastCostTicker = Math.round(this.costTicker / this.totalTick); - this.fpsDisplay.update({ - fps: lastFPS, - draw: lastDrawCalls, - costTicker: lastCostTicker, - costRender: lastCostRender - }); - this.totalTick = 0; - this.totalTime = this.totalTime % 1000; - this.drawCalls = 0; - this.costRender = 0; - this.costTicker = 0; - } - }; - FPSImpl.prototype.updateInfo = function (info) { - if (!info) { - return; - } - if (!this.showLog) { - return; - } - if (!this.filter(info)) { - return; - } - this.fpsDisplay.updateInfo(info); - }; - FPSImpl.prototype.updateWarn = function (info) { - if (!info) { - return; - } - if (!this.showLog) { - return; - } - if (!this.filter(info)) { - return; - } - if (this.fpsDisplay.updateWarn) { - this.fpsDisplay.updateWarn(info); - } - else { - this.fpsDisplay.updateInfo("[Warning]" + info); - } - }; - FPSImpl.prototype.updateError = function (info) { - if (!info) { - return; - } - if (!this.showLog) { - return; - } - if (!this.filter(info)) { - return; - } - if (this.fpsDisplay.updateError) { - this.fpsDisplay.updateError(info); - } - else { - this.fpsDisplay.updateInfo("[Error]" + info); - } - }; - return FPSImpl; - }()); - __reflect(FPSImpl.prototype, "FPSImpl"); - __global.FPS = FPSImpl; - function toArray(argument) { - var args = []; - for (var i = 0; i < argument.length; i++) { - args.push(argument[i]); - } - return args; - } - egret.warn = function () { - console.warn.apply(console, toArray(arguments)); - }; - egret.error = function () { - console.error.apply(console, toArray(arguments)); - }; - egret.assert = function () { - console.assert.apply(console, toArray(arguments)); - }; - egret.log = function () { - console.log.apply(console, toArray(arguments)); - }; - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -/** - * @private - */ -(function (egret) { - /** - * @private - */ - egret.nativeRender = __global.nativeRender; - //检测版本是否匹配,不匹配改用非原生加速渲染方式 - if (egret.nativeRender) { - var nrABIVersion = egret_native.nrABIVersion; - var nrMinEgretVersion = egret_native.nrMinEgretVersion; - var requiredNrABIVersion = 5; - if (nrABIVersion < requiredNrABIVersion) { - egret.nativeRender = false; - var msg = "需要升级微端版本到 0.1.14 才可以开启原生渲染加速"; - egret.sys.$warnToFPS(msg); - egret.warn(msg); - } - else if (nrABIVersion > requiredNrABIVersion) { - egret.nativeRender = false; - var msg = "\u9700\u8981\u5347\u7EA7\u5F15\u64CE\u7248\u672C\u5230 " + nrMinEgretVersion + " \u624D\u53EF\u4EE5\u5F00\u542F\u539F\u751F\u6E32\u67D3\u52A0\u901F"; - egret.sys.$warnToFPS(msg); - egret.warn(msg); - } - } -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** !!!!!!!!inspired by Babylon.js!!!!!!!!!!!!! - * for description see https://www.khronos.org/opengles/sdk/tools/KTX/ - * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ - * Current families are astc, dxt, pvrtc, etc2, & etc1. - * @returns The extension selected. - */ - var KTXContainer = (function () { - /** - * Creates a new KhronosTextureContainer - * @param arrayBuffer contents of the KTX container file - * @param facesExpected should be either 1 or 6, based whether a cube texture or or - * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented - * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented - */ - function KTXContainer(/** contents of the KTX container file */ arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) { - this.arrayBuffer = arrayBuffer; - /** - * If the container has been made invalid (eg. constructor failed to correctly load array buffer) - */ - this.isInvalid = false; - // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is: - // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n' - // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A - var identifier = new Uint8Array(this.arrayBuffer, 0, 12); - if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 || - identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) { - this.isInvalid = true; - //Logger.Error("texture missing KTX identifier"); - console.error("texture missing KTX identifier"); - return; - } - // load the reset of the header in native 32 bit uint - var dataSize = Uint32Array.BYTES_PER_ELEMENT; - var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize); - var endianness = headerDataView.getUint32(0, true); - var littleEndian = endianness === 0x04030201; - this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures - this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures - this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures - this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,) - this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only) - this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,) - this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,) - this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,) - this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays - this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6 - this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures - this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data - // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing. - if (this.glType !== 0) { - console.error("only compressed formats currently supported"); - return; - } - else { - // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard. - this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels); - } - if (this.pixelHeight === 0 || this.pixelDepth !== 0) { - console.error("only 2D textures currently supported"); - return; - } - if (this.numberOfArrayElements !== 0) { - console.error("texture arrays not currently supported"); - return; - } - if (this.numberOfFaces !== facesExpected) { - console.error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces); - return; - } - // we now have a completely validated file, so could use existence of loadType as success - // would need to make this more elaborate & adjust checks above to support more than one load type - this.loadType = KTXContainer.COMPRESSED_2D; - } - /** - * Uploads KTX content to a Babylon Texture. - * It is assumed that the texture has already been created & is currently bound - * @hidden - */ - KTXContainer.prototype.uploadLevels = function (bitmapData, loadMipmaps) { - if (this.loadType === KTXContainer.COMPRESSED_2D) { - this._upload2DCompressedLevels(bitmapData, loadMipmaps); - } - }; - KTXContainer.prototype._upload2DCompressedLevels = function (bitmapData, loadMipmaps) { - bitmapData.clearCompressedTextureData(); - var compressedTextureData = bitmapData.compressedTextureData; - // initialize width & height for level 1 - var dataOffset = KTXContainer.HEADER_LEN + this.bytesOfKeyValueData; - var width = this.pixelWidth; - var height = this.pixelHeight; - var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1; - for (var level = 0; level < mipmapCount; level++) { - var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps - dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above. - var levelData = []; - for (var face = 0; face < this.numberOfFaces; face++) { - var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize); - var compressedData = new egret.CompressedTextureData; - compressedData.glInternalFormat = this.glInternalFormat; - compressedData.width = width; - compressedData.height = height; - compressedData.byteArray = byteArray; - compressedData.face = face; - compressedData.level = level; - levelData.push(compressedData); - dataOffset += imageSize; // add size of the image for the next face/mipmap - dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image - } - compressedTextureData.push(levelData); - width = Math.max(1.0, width * 0.5); - height = Math.max(1.0, height * 0.5); - } - var compressed2d = bitmapData.getCompressed2dTextureData(); - if (compressed2d) { - bitmapData.width = compressed2d.width; - bitmapData.height = compressed2d.height; - } - }; - KTXContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs) - // load types - KTXContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D() - KTXContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D() - KTXContainer.TEX_2D = 2; // uses a gl.texImage2D() - KTXContainer.TEX_3D = 3; // uses a gl.texImage3D() - return KTXContainer; - }()); - egret.KTXContainer = KTXContainer; - __reflect(KTXContainer.prototype, "egret.KTXContainer"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 屏幕适配器默认实现,开发者可以实现自定义规则的屏幕适配器。并在初始化加载时将适配器的实例赋值给egret.sys.screenAdapter上,从而替换掉默认适配器。 - */ - var DefaultScreenAdapter = (function (_super) { - __extends(DefaultScreenAdapter, _super); - /** - * @private - */ - function DefaultScreenAdapter() { - return _super.call(this) || this; - } - /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - DefaultScreenAdapter.prototype.calculateStageSize = function (scaleMode, screenWidth, screenHeight, contentWidth, contentHeight) { - var displayWidth = screenWidth; - var displayHeight = screenHeight; - var stageWidth = contentWidth; - var stageHeight = contentHeight; - var scaleX = (screenWidth / stageWidth) || 0; - var scaleY = (screenHeight / stageHeight) || 0; - switch (scaleMode) { - case egret.StageScaleMode.EXACT_FIT: - break; - case egret.StageScaleMode.FIXED_HEIGHT: - stageWidth = Math.round(screenWidth / scaleY); - break; - case egret.StageScaleMode.FIXED_WIDTH: - stageHeight = Math.round(screenHeight / scaleX); - break; - case egret.StageScaleMode.NO_BORDER: - if (scaleX > scaleY) { - displayHeight = Math.round(stageHeight * scaleX); - } - else { - displayWidth = Math.round(stageWidth * scaleY); - } - break; - case egret.StageScaleMode.SHOW_ALL: - if (scaleX > scaleY) { - displayWidth = Math.round(stageWidth * scaleY); - } - else { - displayHeight = Math.round(stageHeight * scaleX); - } - break; - case egret.StageScaleMode.FIXED_NARROW: - if (scaleX > scaleY) { - stageWidth = Math.round(screenWidth / scaleY); - } - else { - stageHeight = Math.round(screenHeight / scaleX); - } - break; - case egret.StageScaleMode.FIXED_WIDE: - if (scaleX > scaleY) { - stageHeight = Math.round(screenHeight / scaleX); - } - else { - stageWidth = Math.round(screenWidth / scaleY); - } - break; - default: - stageWidth = screenWidth; - stageHeight = screenHeight; - break; - } - if (egret.Capabilities.runtimeType != egret.RuntimeType.WXGAME) { - //宽高不是2的整数倍会导致图片绘制出现问题 - if (stageWidth % 2 != 0) { - stageWidth += 1; - } - if (stageHeight % 2 != 0) { - stageHeight += 1; - } - if (displayWidth % 2 != 0) { - displayWidth += 1; - } - if (displayHeight % 2 != 0) { - displayHeight += 1; - } - } - return { - stageWidth: stageWidth, - stageHeight: stageHeight, - displayWidth: displayWidth, - displayHeight: displayHeight - }; - }; - return DefaultScreenAdapter; - }(egret.HashObject)); - sys.DefaultScreenAdapter = DefaultScreenAdapter; - __reflect(DefaultScreenAdapter.prototype, "egret.sys.DefaultScreenAdapter", ["egret.sys.IScreenAdapter"]); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * StageScaleMode class provides values for the stage zoom mode. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language en_US - */ - /** - * StageScaleMode 类为舞台缩放模式提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language zh_CN - */ - var StageScaleMode = (function () { - function StageScaleMode() { - } - /** - * Do not scale application content. Even when you change the player viewport size, it remains unchanged. If the player is smaller than the viewport content, possibly with some cropping.
    - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) always with the player viewport size consistent. - * @language en_US - */ - /** - * 不缩放应用程序内容。即使在更改播放器视口大小时,它仍然保持不变。如果播放器视口比内容小,则可能进行一些裁切。
    - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终跟播放器视口大小保持一致。 - * @language zh_CN - */ - StageScaleMode.NO_SCALE = "noScale"; - /** - * Keep the original aspect ratio scaling application content, after scaling a wide directions application content to fill the viewport players on both sides in the other direction may not be wide enough and left black bars.
    - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较宽方向填满播放器视口,另一个方向的两侧可能会不够宽而留有黑边。
    - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - StageScaleMode.SHOW_ALL = "showAll"; - /** - * Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
    - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
    - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - StageScaleMode.NO_BORDER = "noBorder"; - /** - * Do not keep the original aspect ratio scaling application content, after scaling application content just fill the player viewport.
    - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 不保持原始宽高比缩放应用程序内容,缩放后应用程序内容正好填满播放器视口。
    - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - StageScaleMode.EXACT_FIT = "exactFit"; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
    - * In this mode, the stage width (Stage.stageWidth) is always equal to initialize external incoming application content width. Stage height (Stage.stageHeight) by the current scale with the player viewport height decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
    - * 在此模式下,舞台宽度(Stage.stageWidth)始终等于初始化时外部传入的应用程序内容宽度。舞台高度(Stage.stageHeight)由当前的缩放比例与播放器视口高度决定。 - * @language zh_CN - */ - StageScaleMode.FIXED_WIDTH = "fixedWidth"; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
    - * In this mode, the stage height (Stage.stageHeight) is always equal to initialize external incoming application content height. Stage width (Stage.stageWidth) by the current scale with the player viewport width decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
    - * 在此模式下,舞台高度(Stage.stageHeight)始终等于初始化时外部传入的应用程序内容高度。舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽度决定。 - * @language zh_CN - */ - StageScaleMode.FIXED_HEIGHT = "fixedHeight"; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player,a narrow direction may not be wide enough and fill.
    - * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较窄方向可能会不够宽而填充。
    - * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - StageScaleMode.FIXED_NARROW = "fixedNarrow"; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, a wide direction may exceed the viewport and the player is cut.
    - * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较宽方向的两侧可能会超出播放器视口而被裁切。
    - * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - StageScaleMode.FIXED_WIDE = "fixedWide"; - return StageScaleMode; - }()); - egret.StageScaleMode = StageScaleMode; - __reflect(StageScaleMode.prototype, "egret.StageScaleMode"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * 创建一个canvas。 - */ - function mainCanvas(width, height) { - console.error("empty sys.mainCanvas = " + width + ", " + height); - return null; - } - sys.mainCanvas = mainCanvas; - function createCanvas(width, height) { - console.error("empty sys.createCanvas = " + width + ", " + height); - return null; - } - sys.createCanvas = createCanvas; - /** - * 重新设置主canvas的大小 - */ - function resizeContext(renderContext, width, height, useMaxSize) { - console.error("empty sys.resizeContext = " + renderContext + ", " + width + ", " + height + ", " + useMaxSize); - } - sys.resizeContext = resizeContext; - /** - * 获得系统的渲染运行时 - */ - function getContextWebGL(surface) { - console.error("empty sys.getContextWebGL = " + surface); - return null; - } - sys.getContextWebGL = getContextWebGL; - function getContext2d(surface) { - console.error("empty sys.getContext2d = " + surface); - return null; - } - sys.getContext2d = getContext2d; - /** - * 仅通过bitmapData创建纹理 - */ - function createTexture(renderContext, bitmapData) { - console.error("empty sys.createTexture = " + bitmapData); - return null; - } - sys.createTexture = createTexture; - /** - * 通过 width, height, data创建纹理 - */ - function _createTexture(renderContext, width, height, data) { - console.error("empty sys._createTexture = " + width + ", " + height + ", " + data); - return null; - } - sys._createTexture = _createTexture; - /** - * 画texture - **/ - function drawTextureElements(renderContext, data, offset) { - console.error("empty sys.drawTextureElements = " + renderContext + ", " + data + ", " + offset); - return 0; - } - sys.drawTextureElements = drawTextureElements; - /** - * 测量文本的宽度 - * @param context - * @param text - */ - function measureTextWith(context, text) { - console.error("empty sys.measureTextWith = " + context + ", " + text); - return 0; - } - sys.measureTextWith = measureTextWith; - /** - * 为CanvasRenderBuffer创建一个canvas - * @param defaultFunc - * @param width - * @param height - * @param root - */ - function createCanvasRenderBufferSurface(defaultFunc, width, height, root) { - console.error("empty sys.createCanvasRenderBufferSurface = " + width + ", " + height); - return null; - } - sys.createCanvasRenderBufferSurface = createCanvasRenderBufferSurface; - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param renderContext - * @param width - * @param height - * @param useMaxSize - */ - function resizeCanvasRenderBuffer(renderContext, width, height, useMaxSize) { - console.error("empty sys.resizeContext = " + renderContext + ", " + width + ", " + height + ", " + useMaxSize); - } - sys.resizeCanvasRenderBuffer = resizeCanvasRenderBuffer; - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - */ - sys.$START_TIME = 0; - /** - * @private - * 是否要广播Event.RENDER事件的标志。 - */ - sys.$invalidateRenderFlag = false; - /** - * @private - * 需要立即刷新屏幕的标志 - */ - sys.$requestRenderingFlag = false; - /** - * Egret心跳计时器 - */ - var SystemTicker = (function () { - /** - * @private - */ - function SystemTicker() { - /** - * @private - */ - this.playerList = []; - /** - * @private - */ - this.callBackList = []; - /** - * @private - */ - this.thisObjectList = []; - /** - * @private - * 全局帧率 - */ - this.$frameRate = 30; - /** - * @private - */ - this.lastTimeStamp = 0; - /** - * @private - * ticker 花销的时间 - */ - this.costEnterFrame = 0; - /** - * @private - * 是否被暂停 - */ - this.isPaused = false; - if (true && egret.ticker) { - egret.$error(1008, "egret.sys.SystemTicker"); - } - sys.$START_TIME = Date.now(); - this.frameDeltaTime = 1000 / this.$frameRate; - this.lastCount = this.frameInterval = Math.round(60000 / this.$frameRate); - } - /** - * @private - * 注册一个播放器实例并运行 - */ - SystemTicker.prototype.$addPlayer = function (player) { - if (this.playerList.indexOf(player) != -1) { - return; - } - if (true) { - egret_stages.push(player.stage); - } - this.playerList = this.playerList.concat(); - this.playerList.push(player); - }; - /** - * @private - * 停止一个播放器实例的运行。 - */ - SystemTicker.prototype.$removePlayer = function (player) { - var index = this.playerList.indexOf(player); - if (index !== -1) { - if (true) { - var i = egret_stages.indexOf(player.stage); - egret_stages.splice(i, 1); - } - this.playerList = this.playerList.concat(); - this.playerList.splice(index, 1); - } - }; - /** - * @private - */ - SystemTicker.prototype.$startTick = function (callBack, thisObject) { - var index = this.getTickIndex(callBack, thisObject); - if (index != -1) { - return; - } - this.concatTick(); - this.callBackList.push(callBack); - this.thisObjectList.push(thisObject); - }; - /** - * @private - */ - SystemTicker.prototype.$stopTick = function (callBack, thisObject) { - var index = this.getTickIndex(callBack, thisObject); - if (index == -1) { - return; - } - this.concatTick(); - this.callBackList.splice(index, 1); - this.thisObjectList.splice(index, 1); - }; - /** - * @private - */ - SystemTicker.prototype.getTickIndex = function (callBack, thisObject) { - var callBackList = this.callBackList; - var thisObjectList = this.thisObjectList; - for (var i = callBackList.length - 1; i >= 0; i--) { - if (callBackList[i] == callBack && - thisObjectList[i] == thisObject) { - return i; - } - } - return -1; - }; - /** - * @private - * - */ - SystemTicker.prototype.concatTick = function () { - this.callBackList = this.callBackList.concat(); - this.thisObjectList = this.thisObjectList.concat(); - }; - /** - * @private - * 设置全局帧率 - */ - SystemTicker.prototype.$setFrameRate = function (value) { - if (value <= 0) { - return false; - } - if (this.$frameRate == value) { - return false; - } - this.$frameRate = value; - if (value > 60) { - value = 60; - } - this.frameDeltaTime = 1000 / value; - //这里用60*1000来避免浮点数计算不准确的问题。 - this.lastCount = this.frameInterval = Math.round(60000 / value); - return true; - }; - /** - * Pause the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - SystemTicker.prototype.pause = function () { - this.isPaused = true; - }; - /** - * Resume the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 恢复心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - SystemTicker.prototype.resume = function () { - this.isPaused = false; - }; - /** - * @private - * 执行一次刷新 - */ - SystemTicker.prototype.update = function (forceUpdate) { - var t1 = egret.getTimer(); - var callBackList = this.callBackList; - var thisObjectList = this.thisObjectList; - var length = callBackList.length; - var requestRenderingFlag = sys.$requestRenderingFlag; - var timeStamp = egret.getTimer(); - var contexts = egret.lifecycle.contexts; - for (var _i = 0, contexts_1 = contexts; _i < contexts_1.length; _i++) { - var c = contexts_1[_i]; - if (c.onUpdate) { - c.onUpdate(); - } - } - if (this.isPaused) { - this.lastTimeStamp = timeStamp; - return; - } - this.callLaterAsyncs(); - for (var i = 0; i < length; i++) { - if (callBackList[i].call(thisObjectList[i], timeStamp)) { - requestRenderingFlag = true; - } - } - var t2 = egret.getTimer(); - var deltaTime = timeStamp - this.lastTimeStamp; - this.lastTimeStamp = timeStamp; - if (deltaTime >= this.frameDeltaTime || forceUpdate) { - this.lastCount = this.frameInterval; - } - else { - this.lastCount -= 1000; - if (this.lastCount > 0) { - if (requestRenderingFlag) { - this.render(false, this.costEnterFrame + t2 - t1); - } - return; - } - this.lastCount += this.frameInterval; - } - this.render(true, this.costEnterFrame + t2 - t1); - var t3 = egret.getTimer(); - this.broadcastEnterFrame(); - var t4 = egret.getTimer(); - this.costEnterFrame = t4 - t3; - }; - /** - * @private - * 执行一次屏幕渲染 - */ - SystemTicker.prototype.render = function (triggerByFrame, costTicker) { - var playerList = this.playerList; - var length = playerList.length; - if (length == 0) { - return; - } - this.callLaters(); - if (sys.$invalidateRenderFlag) { - this.broadcastRender(); - sys.$invalidateRenderFlag = false; - } - for (var i = 0; i < length; i++) { - playerList[i].$render(triggerByFrame, costTicker); - } - sys.$requestRenderingFlag = false; - }; - /** - * @private - * 广播EnterFrame事件。 - */ - SystemTicker.prototype.broadcastEnterFrame = function () { - var list = egret.DisplayObject.$enterFrameCallBackList; - var length = list.length; - if (length == 0) { - return; - } - list = list.concat(); - for (var i = 0; i < length; i++) { - list[i].dispatchEventWith(egret.Event.ENTER_FRAME); - } - }; - /** - * @private - * 广播Render事件。 - */ - SystemTicker.prototype.broadcastRender = function () { - var list = egret.DisplayObject.$renderCallBackList; - var length = list.length; - if (length == 0) { - return; - } - list = list.concat(); - for (var i = 0; i < length; i++) { - list[i].dispatchEventWith(egret.Event.RENDER); - } - }; - /** - * @private - */ - SystemTicker.prototype.callLaters = function () { - var functionList; - var thisList; - var argsList; - if (egret.$callLaterFunctionList.length > 0) { - functionList = egret.$callLaterFunctionList; - egret.$callLaterFunctionList = []; - thisList = egret.$callLaterThisList; - egret.$callLaterThisList = []; - argsList = egret.$callLaterArgsList; - egret.$callLaterArgsList = []; - } - if (functionList) { - var length_2 = functionList.length; - for (var i = 0; i < length_2; i++) { - var func = functionList[i]; - if (func != null) { - func.apply(thisList[i], argsList[i]); - } - } - } - }; - /** - * @private - */ - SystemTicker.prototype.callLaterAsyncs = function () { - if (egret.$callAsyncFunctionList.length > 0) { - var locCallAsyncFunctionList = egret.$callAsyncFunctionList; - var locCallAsyncThisList = egret.$callAsyncThisList; - var locCallAsyncArgsList = egret.$callAsyncArgsList; - egret.$callAsyncFunctionList = []; - egret.$callAsyncThisList = []; - egret.$callAsyncArgsList = []; - for (var i = 0; i < locCallAsyncFunctionList.length; i++) { - var func = locCallAsyncFunctionList[i]; - if (func != null) { - func.apply(locCallAsyncThisList[i], locCallAsyncArgsList[i]); - } - } - } - }; - return SystemTicker; - }()); - sys.SystemTicker = SystemTicker; - __reflect(SystemTicker.prototype, "egret.sys.SystemTicker"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -(function (egret) { - var lifecycle; - (function (lifecycle) { - /** - * @private - */ - lifecycle.contexts = []; - var isActivate = true; - var LifecycleContext = (function () { - function LifecycleContext() { - } - LifecycleContext.prototype.pause = function () { - if (isActivate) { - isActivate = false; - lifecycle.stage.dispatchEvent(new egret.Event(egret.Event.DEACTIVATE)); - if (lifecycle.onPause) { - lifecycle.onPause(); - } - } - }; - LifecycleContext.prototype.resume = function () { - if (!isActivate) { - isActivate = true; - lifecycle.stage.dispatchEvent(new egret.Event(egret.Event.ACTIVATE)); - if (lifecycle.onResume) { - lifecycle.onResume(); - } - } - }; - return LifecycleContext; - }()); - lifecycle.LifecycleContext = LifecycleContext; - __reflect(LifecycleContext.prototype, "egret.lifecycle.LifecycleContext"); - function addLifecycleListener(plugin) { - var context = new LifecycleContext(); - lifecycle.contexts.push(context); - plugin(context); - } - lifecycle.addLifecycleListener = addLifecycleListener; - })(lifecycle = egret.lifecycle || (egret.lifecycle = {})); - /** - * 心跳计时器单例 - */ - egret.ticker = new egret.sys.SystemTicker(); -})(egret || (egret = {})); -if (true) { - global.egret_stages = []; -} -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 用户交互操作管理器 - */ - var TouchHandler = (function (_super) { - __extends(TouchHandler, _super); - /** - * @private - */ - function TouchHandler(stage) { - var _this = _super.call(this) || this; - _this.maxTouches = 0; - _this.useTouchesCount = 0; - /** - * @private - */ - _this.touchDownTarget = {}; - /** - * @private - */ - _this.lastTouchX = -1; - /** - * @private - */ - _this.lastTouchY = -1; - _this.stage = stage; - return _this; - } - /** - * @private - * 设置同时触摸数量 - */ - TouchHandler.prototype.$initMaxTouches = function () { - this.maxTouches = this.stage.$maxTouches; - }; - /** - * @private - * 触摸开始(按下) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - TouchHandler.prototype.onTouchBegin = function (x, y, touchPointID) { - if (this.useTouchesCount >= this.maxTouches) { - return; - } - this.lastTouchX = x; - this.lastTouchY = y; - var target = this.findTarget(x, y); - if (this.touchDownTarget[touchPointID] == null) { - this.touchDownTarget[touchPointID] = target; - this.useTouchesCount++; - } - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_BEGIN, true, true, x, y, touchPointID, true); - }; - /** - * @private - * 触摸移动 - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - TouchHandler.prototype.onTouchMove = function (x, y, touchPointID) { - if (this.touchDownTarget[touchPointID] == null) { - return; - } - if (this.lastTouchX == x && this.lastTouchY == y) { - return; - } - this.lastTouchX = x; - this.lastTouchY = y; - var target = this.findTarget(x, y); - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_MOVE, true, true, x, y, touchPointID, true); - }; - /** - * @private - * 触摸结束(弹起) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - TouchHandler.prototype.onTouchEnd = function (x, y, touchPointID) { - if (this.touchDownTarget[touchPointID] == null) { - return; - } - var target = this.findTarget(x, y); - var oldTarget = this.touchDownTarget[touchPointID]; - delete this.touchDownTarget[touchPointID]; - this.useTouchesCount--; - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_END, true, true, x, y, touchPointID, false); - if (oldTarget == target) { - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_TAP, true, true, x, y, touchPointID, false); - } - else { - egret.TouchEvent.dispatchTouchEvent(oldTarget, egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, true, true, x, y, touchPointID, false); - } - }; - /** - * @private - * 获取舞台坐标下的触摸对象 - */ - TouchHandler.prototype.findTarget = function (stageX, stageY) { - var target = this.stage.$hitTest(stageX, stageY); - if (!target) { - target = this.stage; - } - return target; - }; - return TouchHandler; - }(egret.HashObject)); - sys.TouchHandler = TouchHandler; - __reflect(TouchHandler.prototype, "egret.sys.TouchHandler"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 位图渲染节点 - */ - var BitmapNode = (function (_super) { - __extends(BitmapNode, _super); - function BitmapNode() { - var _this = _super.call(this) || this; - /** - * 要绘制的位图 - */ - _this.image = null; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - _this.smoothing = true; - /** - * 使用的混合模式 - */ - _this.blendMode = null; - /** - * 相对透明度 - */ - _this.alpha = NaN; - /** - * 颜色变换滤镜 - */ - _this.filter = null; - /** - * 翻转 - */ - _this.rotated = false; - _this.type = 1 /* BitmapNode */; - return _this; - } - /** - * 绘制一次位图 - */ - BitmapNode.prototype.drawImage = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) { - this.drawData.push(sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH); - this.renderCount++; - }; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - BitmapNode.prototype.cleanBeforeRender = function () { - _super.prototype.cleanBeforeRender.call(this); - this.image = null; - this.matrix = null; - this.blendMode = null; - this.alpha = NaN; - this.filter = null; - }; - BitmapNode.$updateTextureData = function (node, image, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH, sourceWidth, sourceHeight, fillMode, smoothing) { - if (!image) { - return; - } - var scale = egret.$TextureScaleFactor; - node.smoothing = smoothing; - node.image = image; - node.imageWidth = sourceWidth; - node.imageHeight = sourceHeight; - if (fillMode == egret.BitmapFillMode.SCALE) { - var tsX = destW / textureWidth * scale; - var tsY = destH / textureHeight * scale; - node.drawImage(bitmapX, bitmapY, bitmapWidth, bitmapHeight, tsX * offsetX, tsY * offsetY, tsX * bitmapWidth, tsY * bitmapHeight); - } - else if (fillMode == egret.BitmapFillMode.CLIP) { - var displayW = Math.min(textureWidth, destW); - var displayH = Math.min(textureHeight, destH); - var scaledBitmapW = bitmapWidth * scale; - var scaledBitmapH = bitmapHeight * scale; - BitmapNode.drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, displayW, displayH); - } - else { - var scaledBitmapW = bitmapWidth * scale; - var scaledBitmapH = bitmapHeight * scale; - for (var startX = 0; startX < destW; startX += textureWidth) { - for (var startY = 0; startY < destH; startY += textureHeight) { - var displayW = Math.min(destW - startX, textureWidth); - var displayH = Math.min(destH - startY, textureHeight); - BitmapNode.drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, displayW, displayH, startX, startY); - } - } - } - }; - /** - * @private - * 绘制九宫格位图 - */ - BitmapNode.$updateTextureDataWithScale9Grid = function (node, image, scale9Grid, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH, sourceWidth, sourceHeight, smoothing) { - node.smoothing = smoothing; - node.image = image; - node.imageWidth = sourceWidth; - node.imageHeight = sourceHeight; - var imageWidth = bitmapWidth; - var imageHeight = bitmapHeight; - destW = destW - (textureWidth - bitmapWidth * egret.$TextureScaleFactor); - destH = destH - (textureHeight - bitmapHeight * egret.$TextureScaleFactor); - var targetW0 = scale9Grid.x - offsetX; - var targetH0 = scale9Grid.y - offsetY; - var sourceW0 = targetW0 / egret.$TextureScaleFactor; - var sourceH0 = targetH0 / egret.$TextureScaleFactor; - var sourceW1 = scale9Grid.width / egret.$TextureScaleFactor; - var sourceH1 = scale9Grid.height / egret.$TextureScaleFactor; - //防止空心的情况出现。 - if (sourceH1 == 0) { - sourceH1 = 1; - if (sourceH0 >= imageHeight) { - sourceH0--; - } - } - if (sourceW1 == 0) { - sourceW1 = 1; - if (sourceW0 >= imageWidth) { - sourceW0--; - } - } - var sourceX0 = bitmapX; - var sourceX1 = sourceX0 + sourceW0; - var sourceX2 = sourceX1 + sourceW1; - var sourceW2 = imageWidth - sourceW0 - sourceW1; - var sourceY0 = bitmapY; - var sourceY1 = sourceY0 + sourceH0; - var sourceY2 = sourceY1 + sourceH1; - var sourceH2 = imageHeight - sourceH0 - sourceH1; - var targetW2 = sourceW2 * egret.$TextureScaleFactor; - var targetH2 = sourceH2 * egret.$TextureScaleFactor; - if ((sourceW0 + sourceW2) * egret.$TextureScaleFactor > destW || (sourceH0 + sourceH2) * egret.$TextureScaleFactor > destH) { - node.drawImage(bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, destW, destH); - return; - } - var targetX0 = offsetX; - var targetX1 = targetX0 + targetW0; - var targetX2 = targetX0 + (destW - targetW2); - var targetW1 = destW - targetW0 - targetW2; - var targetY0 = offsetY; - var targetY1 = targetY0 + targetH0; - var targetY2 = targetY0 + destH - targetH2; - var targetH1 = destH - targetH0 - targetH2; - // - // x0 x1 x2 - // y0 +------+------+------+ - // | | | | h0 - // | | | | - // y1 +------+------+------+ - // | | | | h1 - // | | | | - // y2 +------+------+------+ - // | | | | h2 - // | | | | - // +------+------+------+ - // w0 w1 w2 - // - if (sourceH0 > 0) { - if (sourceW0 > 0) - node.drawImage(sourceX0, sourceY0, sourceW0, sourceH0, targetX0, targetY0, targetW0, targetH0); - if (sourceW1 > 0) - node.drawImage(sourceX1, sourceY0, sourceW1, sourceH0, targetX1, targetY0, targetW1, targetH0); - if (sourceW2 > 0) - node.drawImage(sourceX2, sourceY0, sourceW2, sourceH0, targetX2, targetY0, targetW2, targetH0); - } - if (sourceH1 > 0) { - if (sourceW0 > 0) - node.drawImage(sourceX0, sourceY1, sourceW0, sourceH1, targetX0, targetY1, targetW0, targetH1); - if (sourceW1 > 0) - node.drawImage(sourceX1, sourceY1, sourceW1, sourceH1, targetX1, targetY1, targetW1, targetH1); - if (sourceW2 > 0) - node.drawImage(sourceX2, sourceY1, sourceW2, sourceH1, targetX2, targetY1, targetW2, targetH1); - } - if (sourceH2 > 0) { - if (sourceW0 > 0) - node.drawImage(sourceX0, sourceY2, sourceW0, sourceH2, targetX0, targetY2, targetW0, targetH2); - if (sourceW1 > 0) - node.drawImage(sourceX1, sourceY2, sourceW1, sourceH2, targetX1, targetY2, targetW1, targetH2); - if (sourceW2 > 0) - node.drawImage(sourceX2, sourceY2, sourceW2, sourceH2, targetX2, targetY2, targetW2, targetH2); - } - }; - /** - * @private - */ - BitmapNode.drawClipImage = function (node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, destW, destH, startX, startY) { - if (startX === void 0) { startX = 0; } - if (startY === void 0) { startY = 0; } - var offset = offsetX + scaledBitmapW - destW; - if (offset > 0) { - scaledBitmapW -= offset; - } - offset = offsetY + scaledBitmapH - destH; - if (offset > 0) { - scaledBitmapH -= offset; - } - node.drawImage(bitmapX, bitmapY, scaledBitmapW / scale, scaledBitmapH / scale, startX + offsetX, startY + offsetY, scaledBitmapW, scaledBitmapH); - }; - return BitmapNode; - }(sys.RenderNode)); - sys.BitmapNode = BitmapNode; - __reflect(BitmapNode.prototype, "egret.sys.BitmapNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - var CAPS_STYLES = ["none", "round", "square"]; - var JOINT_STYLES = ["bevel", "miter", "round"]; - /** - * @private - * 矢量渲染节点 - */ - var GraphicsNode = (function (_super) { - __extends(GraphicsNode, _super); - function GraphicsNode() { - var _this = _super.call(this) || this; - /** - * 脏渲染标记 - * 暂时调用lineStyle,beginFill,beginGradientFill标记,实际应该draw时候标记在Path2D - */ - _this.dirtyRender = true; - _this.type = 3 /* GraphicsNode */; - return _this; - } - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - GraphicsNode.prototype.beginFill = function (color, alpha, beforePath) { - if (alpha === void 0) { alpha = 1; } - var path = new sys.FillPath(); - path.fillColor = color; - path.fillAlpha = alpha; - if (beforePath) { - var index = this.drawData.lastIndexOf(beforePath); - this.drawData.splice(index, 0, path); - } - else { - this.drawData.push(path); - } - this.renderCount++; - return path; - }; - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - GraphicsNode.prototype.beginGradientFill = function (type, colors, alphas, ratios, matrix, beforePath) { - var m = new egret.Matrix(); - if (matrix) { - m.a = matrix.a * 819.2; - m.b = matrix.b * 819.2; - m.c = matrix.c * 819.2; - m.d = matrix.d * 819.2; - m.tx = matrix.tx; - m.ty = matrix.ty; - } - else { - //默认值 - m.a = 100; - m.d = 100; - } - var path = new sys.GradientFillPath(); - path.gradientType = type; - path.colors = colors; - path.alphas = alphas; - path.ratios = ratios; - path.matrix = m; - if (beforePath) { - var index = this.drawData.lastIndexOf(beforePath); - this.drawData.splice(index, 0, path); - } - else { - this.drawData.push(path); - } - this.renderCount++; - return path; - }; - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - */ - GraphicsNode.prototype.lineStyle = function (thickness, color, alpha, caps, joints, miterLimit, lineDash) { - if (alpha === void 0) { alpha = 1; } - if (miterLimit === void 0) { miterLimit = 3; } - if (lineDash === void 0) { lineDash = []; } - if (CAPS_STYLES.indexOf(caps) == -1) { - caps = "round"; - } - if (JOINT_STYLES.indexOf(joints) == -1) { - joints = "round"; - } - var path = new sys.StrokePath(); - path.lineWidth = thickness; - path.lineColor = color; - path.lineAlpha = alpha; - path.caps = caps || egret.CapsStyle.ROUND; - path.joints = joints; - path.miterLimit = miterLimit; - path.lineDash = lineDash; - this.drawData.push(path); - this.renderCount++; - return path; - }; - /** - * 清空所有缓存的绘制数据 - */ - GraphicsNode.prototype.clear = function () { - this.drawData.length = 0; - this.dirtyRender = true; - this.renderCount = 0; - }; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - */ - GraphicsNode.prototype.cleanBeforeRender = function () { - }; - /** - * 清除非绘制的缓存数据 - */ - GraphicsNode.prototype.clean = function () { - if (this.$texture) { - egret.WebGLUtils.deleteWebGLTexture(this.$texture); - this.$texture = null; - this.dirtyRender = true; - } - }; - return GraphicsNode; - }(sys.RenderNode)); - sys.GraphicsNode = GraphicsNode; - __reflect(GraphicsNode.prototype, "egret.sys.GraphicsNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 组渲染节点,用于组合多个渲染节点 - */ - var GroupNode = (function (_super) { - __extends(GroupNode, _super); - function GroupNode() { - var _this = _super.call(this) || this; - _this.type = 4 /* GroupNode */; - return _this; - } - GroupNode.prototype.addNode = function (node) { - this.drawData.push(node); - }; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - * 这里只是想清空绘制命令,因此不调用super - */ - GroupNode.prototype.cleanBeforeRender = function () { - var data = this.drawData; - for (var i = data.length - 1; i >= 0; i--) { - data[i].cleanBeforeRender(); - } - }; - GroupNode.prototype.$getRenderCount = function () { - var result = 0; - var data = this.drawData; - for (var i = data.length - 1; i >= 0; i--) { - result += data[i].$getRenderCount(); - } - return result; - }; - return GroupNode; - }(sys.RenderNode)); - sys.GroupNode = GroupNode; - __reflect(GroupNode.prototype, "egret.sys.GroupNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * Mesh 渲染节点 - */ - var MeshNode = (function (_super) { - __extends(MeshNode, _super); - function MeshNode() { - var _this = _super.call(this) || this; - /** - * 要绘制的位图 - */ - _this.image = null; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - _this.smoothing = true; - /** - * 顶点索引。 - */ - _this.bounds = new egret.Rectangle(); - /** - * 使用的混合模式 - */ - _this.blendMode = null; - /** - * 相对透明度 - */ - _this.alpha = NaN; - /** - * 颜色变换滤镜 - */ - _this.filter = null; - /** - * 翻转 - */ - _this.rotated = false; - _this.type = 5 /* MeshNode */; - _this.vertices = []; - _this.uvs = []; - _this.indices = []; - return _this; - } - /** - * 绘制一次位图 - */ - MeshNode.prototype.drawMesh = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) { - this.drawData.push(sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH); - this.renderCount++; - }; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - MeshNode.prototype.cleanBeforeRender = function () { - _super.prototype.cleanBeforeRender.call(this); - this.image = null; - this.matrix = null; - }; - return MeshNode; - }(sys.RenderNode)); - sys.MeshNode = MeshNode; - __reflect(MeshNode.prototype, "egret.sys.MeshNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 位图渲染节点 - */ - var NormalBitmapNode = (function (_super) { - __extends(NormalBitmapNode, _super); - function NormalBitmapNode() { - var _this = _super.call(this) || this; - /** - * 要绘制的位图 - */ - _this.image = null; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - _this.smoothing = true; - /** - * 翻转 - */ - _this.rotated = false; - _this.type = 6 /* NormalBitmapNode */; - return _this; - } - /** - * 绘制一次位图 - */ - NormalBitmapNode.prototype.drawImage = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) { - var self = this; - self.sourceX = sourceX; - self.sourceY = sourceY; - self.sourceW = sourceW; - self.sourceH = sourceH; - self.drawX = drawX; - self.drawY = drawY; - self.drawW = drawW; - self.drawH = drawH; - self.renderCount = 1; - }; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - NormalBitmapNode.prototype.cleanBeforeRender = function () { - _super.prototype.cleanBeforeRender.call(this); - this.image = null; - }; - return NormalBitmapNode; - }(sys.RenderNode)); - sys.NormalBitmapNode = NormalBitmapNode; - __reflect(NormalBitmapNode.prototype, "egret.sys.NormalBitmapNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - var Mesh = (function (_super) { - __extends(Mesh, _super); - function Mesh(value) { - var _this = _super.call(this, value) || this; - /** - * @private - */ - _this._verticesDirty = true; - _this._bounds = new egret.Rectangle(); - _this.$renderNode = new egret.sys.MeshNode(); - return _this; - } - Mesh.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(12 /* MESH */); - }; - /** - * @private - */ - Mesh.prototype.setBitmapDataToWasm = function (data) { - this.$nativeDisplayObject.setBitmapDataToMesh(data); - }; - /** - * @private - */ - Mesh.prototype.$updateRenderNode = function () { - var image = this.$bitmapData; - if (!image) { - return; - } - var scale = egret.$TextureScaleFactor; - var node = this.$renderNode; - node.smoothing = this.$smoothing; - node.image = image; - node.imageWidth = this.$sourceWidth; - node.imageHeight = this.$sourceHeight; - var destW = !isNaN(this.$explicitBitmapWidth) ? this.$explicitBitmapWidth : this.$textureWidth; - var destH = !isNaN(this.$explicitBitmapHeight) ? this.$explicitBitmapHeight : this.$textureHeight; - var tsX = destW / this.$textureWidth; - var tsY = destH / this.$textureHeight; - var bitmapWidth = this.$bitmapWidth; - var bitmapHeight = this.$bitmapHeight; - node.drawMesh(this.$bitmapX, this.$bitmapY, bitmapWidth, bitmapHeight, this.$offsetX * tsX, this.$offsetY * tsY, tsX * bitmapWidth, tsY * bitmapHeight); - }; - /** - * @private - */ - Mesh.prototype.$updateVertices = function () { - var self = this; - self._verticesDirty = true; - self.$renderDirty = true; - if (egret.nativeRender) { - var renderNode = (this.$renderNode); - this.$nativeDisplayObject.setDataToMesh(renderNode.vertices, renderNode.indices, renderNode.uvs); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - /** - * @private - */ - Mesh.prototype.$measureContentBounds = function (bounds) { - if (this._verticesDirty) { - this._verticesDirty = false; - var node = this.$renderNode; - var vertices = node.vertices; - if (vertices.length) { - this._bounds.setTo(Number.MAX_VALUE, Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE); - for (var i = 0, l = vertices.length; i < l; i += 2) { - var x = vertices[i]; - var y = vertices[i + 1]; - if (this._bounds.x > x) - this._bounds.x = x; - if (this._bounds.width < x) - this._bounds.width = x; - if (this._bounds.y > y) - this._bounds.y = y; - if (this._bounds.height < y) - this._bounds.height = y; - } - this._bounds.width -= this._bounds.x; - this._bounds.height -= this._bounds.y; - } - else { - this._bounds.setTo(0, 0, 0, 0); - } - node.bounds.copyFrom(this._bounds); - } - bounds.copyFrom(this._bounds); - }; - return Mesh; - }(egret.Bitmap)); - egret.Mesh = Mesh; - __reflect(Mesh.prototype, "egret.Mesh"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 文本渲染节点 - */ - var TextNode = (function (_super) { - __extends(TextNode, _super); - function TextNode() { - var _this = _super.call(this) || this; - /** - * 颜色值 - */ - _this.textColor = 0xFFFFFF; - /** - * 描边颜色值 - */ - _this.strokeColor = 0x000000; - /** - * 字号 - */ - _this.size = 30; - /** - * 描边大小 - */ - _this.stroke = 0; - /** - * 是否加粗 - */ - _this.bold = false; - /** - * 是否倾斜 - */ - _this.italic = false; - /** - * 字体名称 - */ - _this.fontFamily = "Arial"; - /** - * 脏渲染标记 - */ - _this.dirtyRender = true; - _this.type = 2 /* TextNode */; - return _this; - } - /** - * 绘制一行文本 - */ - TextNode.prototype.drawText = function (x, y, text, format) { - this.drawData.push(x, y, text, format); - this.renderCount++; - this.dirtyRender = true; - }; - /** - * 清除非绘制的缓存数据 - */ - TextNode.prototype.clean = function () { - if (this.$texture) { - egret.WebGLUtils.deleteWebGLTexture(this.$texture); - this.$texture = null; - this.dirtyRender = true; - } - }; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - TextNode.prototype.cleanBeforeRender = function () { - _super.prototype.cleanBeforeRender.call(this); - this.dirtyRender = true; - }; - return TextNode; - }(sys.RenderNode)); - sys.TextNode = TextNode; - __reflect(TextNode.prototype, "egret.sys.TextNode"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 填充路径 - */ - var FillPath = (function (_super) { - __extends(FillPath, _super); - function FillPath() { - var _this = _super.call(this) || this; - _this.type = 1 /* Fill */; - return _this; - } - return FillPath; - }(sys.Path2D)); - sys.FillPath = FillPath; - __reflect(FillPath.prototype, "egret.sys.FillPath"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 渐变填充路径 - */ - var GradientFillPath = (function (_super) { - __extends(GradientFillPath, _super); - function GradientFillPath() { - var _this = _super.call(this) || this; - _this.type = 2 /* GradientFill */; - return _this; - } - return GradientFillPath; - }(sys.Path2D)); - sys.GradientFillPath = GradientFillPath; - __reflect(GradientFillPath.prototype, "egret.sys.GradientFillPath"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * OrientationMode 类为舞台初始旋转模式提供值。 - */ - egret.OrientationMode = { - /** - * 适配屏幕 - */ - AUTO: "auto", - /** - * 默认竖屏 - */ - PORTRAIT: "portrait", - /** - * 默认横屏,舞台顺时针旋转90度 - */ - LANDSCAPE: "landscape", - /** - * 默认横屏,舞台逆时针旋转90度 - */ - LANDSCAPE_FLIPPED: "landscapeFlipped" - }; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 线条路径。 - * 注意:当线条宽度(lineWidth)为1或3像素时,需要特殊处理,往右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - var StrokePath = (function (_super) { - __extends(StrokePath, _super); - function StrokePath() { - var _this = _super.call(this) || this; - _this.type = 3 /* Stroke */; - return _this; - } - return StrokePath; - }(sys.Path2D)); - sys.StrokePath = StrokePath; - __reflect(StrokePath.prototype, "egret.sys.StrokePath"); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var blendModes = ["source-over", "lighter", "destination-out"]; - var defaultCompositeOp = "source-over"; - var BLACK_COLOR = "#000000"; - var CAPS_STYLES = { none: 'butt', square: 'square', round: 'round' }; - var renderBufferPool = []; //渲染缓冲区对象池 - var renderBufferPool_Filters = []; //滤镜缓冲区对象池 - var CanvasRenderer = (function () { - function CanvasRenderer() { - this.nestLevel = 0; //渲染的嵌套层次,0表示在调用堆栈的最外层。 - this.renderingMask = false; - } - CanvasRenderer.prototype.render = function (displayObject, buffer, matrix, forRenderTexture) { - this.nestLevel++; - var context = buffer.context; - var root = forRenderTexture ? displayObject : null; - //绘制显示对象 - context.transform(matrix.a, matrix.b, matrix.c, matrix.d, 0, 0); - var drawCall = this.drawDisplayObject(displayObject, context, matrix.tx, matrix.ty, true); - var invert = egret.Matrix.create(); - matrix.$invertInto(invert); - context.transform(invert.a, invert.b, invert.c, invert.d, 0, 0); - egret.Matrix.release(invert); - this.nestLevel--; - if (this.nestLevel === 0) { - //最大缓存6个渲染缓冲 - if (renderBufferPool.length > 6) { - renderBufferPool.length = 6; - } - var length_3 = renderBufferPool.length; - for (var i = 0; i < length_3; i++) { - renderBufferPool[i].resize(0, 0); - } - } - return drawCall; - }; - /** - * @private - * 绘制一个显示对象 - */ - CanvasRenderer.prototype.drawDisplayObject = function (displayObject, context, offsetX, offsetY, isStage) { - var drawCalls = 0; - var node; - var displayList = displayObject.$displayList; - if (displayList && !isStage) { - if (displayObject.$cacheDirty || displayObject.$renderDirty || - displayList.$canvasScaleX != egret.sys.DisplayList.$canvasScaleX || - displayList.$canvasScaleY != egret.sys.DisplayList.$canvasScaleY) { - drawCalls += displayList.drawToSurface(); - } - node = displayList.$renderNode; - } - else { - if (displayObject.$renderDirty) { - node = displayObject.$getRenderNode(); - } - else { - node = displayObject.$renderNode; - } - } - displayObject.$cacheDirty = false; - if (node) { - drawCalls++; - context.$offsetX = offsetX; - context.$offsetY = offsetY; - switch (node.type) { - case 1 /* BitmapNode */: - this.renderBitmap(node, context); - break; - case 2 /* TextNode */: - this.renderText(node, context); - break; - case 3 /* GraphicsNode */: - this.renderGraphics(node, context); - break; - case 4 /* GroupNode */: - this.renderGroup(node, context); - break; - case 5 /* MeshNode */: - this.renderMesh(node, context); - break; - case 6 /* NormalBitmapNode */: - this.renderNormalBitmap(node, context); - break; - } - context.$offsetX = 0; - context.$offsetY = 0; - } - if (displayList && !isStage) { - return drawCalls; - } - var children = displayObject.$children; - if (children) { - var length_4 = children.length; - for (var i = 0; i < length_4; i++) { - var child = children[i]; - var offsetX2 = void 0; - var offsetY2 = void 0; - if (child.$useTranslate) { - var m = child.$getMatrix(); - offsetX2 = offsetX + child.$x; - offsetY2 = offsetY + child.$y; - context.save(); - context.transform(m.a, m.b, m.c, m.d, offsetX2, offsetY2); - offsetX2 = -child.$anchorOffsetX; - offsetY2 = -child.$anchorOffsetY; - } - else { - offsetX2 = offsetX + child.$x - child.$anchorOffsetX; - offsetY2 = offsetY + child.$y - child.$anchorOffsetY; - } - var tempAlpha = void 0; - if (child.$alpha != 1) { - tempAlpha = context.globalAlpha; - context.globalAlpha *= child.$alpha; - } - switch (child.$renderMode) { - case 1 /* NONE */: - break; - case 2 /* FILTER */: - drawCalls += this.drawWithFilter(child, context, offsetX2, offsetY2); - break; - case 3 /* CLIP */: - drawCalls += this.drawWithClip(child, context, offsetX2, offsetY2); - break; - case 4 /* SCROLLRECT */: - drawCalls += this.drawWithScrollRect(child, context, offsetX2, offsetY2); - break; - default: - drawCalls += this.drawDisplayObject(child, context, offsetX2, offsetY2); - break; - } - if (child.$useTranslate) { - context.restore(); - } - else if (tempAlpha) { - context.globalAlpha = tempAlpha; - } - } - } - return drawCalls; - }; - CanvasRenderer.prototype.drawWithFilter = function (displayObject, context, offsetX, offsetY) { - if (displayObject.$children && displayObject.$children.length == 0 && (!displayObject.$renderNode || displayObject.$renderNode.$getRenderCount() == 0)) { - return 0; - } - var drawCalls = 0; - var filters = displayObject.$filters; - var filtersLen = filters.length; - var hasBlendMode = (displayObject.$blendMode !== 0); - var compositeOp; - if (hasBlendMode) { - compositeOp = blendModes[displayObject.$blendMode]; - if (!compositeOp) { - compositeOp = defaultCompositeOp; - } - } - var displayBounds = displayObject.$getOriginalBounds(); - var displayBoundsX = displayBounds.x; - var displayBoundsY = displayBounds.y; - var displayBoundsWidth = displayBounds.width; - var displayBoundsHeight = displayBounds.height; - if (displayBoundsWidth <= 0 || displayBoundsHeight <= 0) { - return drawCalls; - } - // 为显示对象创建一个新的buffer - var displayBuffer = this.createRenderBuffer(displayBoundsWidth - displayBoundsX, displayBoundsHeight - displayBoundsY, true); - var displayContext = displayBuffer.context; - if (displayObject.$mask) { - drawCalls += this.drawWithClip(displayObject, displayContext, -displayBoundsX, -displayBoundsY); - } - else if (displayObject.$scrollRect || displayObject.$maskRect) { - drawCalls += this.drawWithScrollRect(displayObject, displayContext, -displayBoundsX, -displayBoundsY); - } - else { - drawCalls += this.drawDisplayObject(displayObject, displayContext, -displayBoundsX, -displayBoundsY); - } - //绘制结果到屏幕 - if (drawCalls > 0) { - if (hasBlendMode) { - context.globalCompositeOperation = compositeOp; - } - drawCalls++; - // 应用滤镜 - var imageData = displayContext.getImageData(0, 0, displayBuffer.surface.width, displayBuffer.surface.height); - for (var i = 0; i < filtersLen; i++) { - var filter = filters[i]; - if (filter.type == "colorTransform") { - colorFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, filter.$matrix); - } - else if (filter.type == "blur") { - blurFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, filter.$blurX, filter.$blurY); - } - else if (filter.type == "glow") { - var r = filter.$red; - var g = filter.$green; - var b = filter.$blue; - var a = filter.$alpha; - if (filter.$inner || filter.$knockout || filter.$hideObject) { - dropShadowFilter2(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, [r / 255, g / 255, b / 255, a], filter.$blurX, filter.$blurY, filter.$angle ? (filter.$angle / 180 * Math.PI) : 0, filter.$distance || 0, filter.$strength, filter.$inner ? 1 : 0, filter.$knockout ? 0 : 1, filter.$hideObject ? 1 : 0); - } - else { - // 如果没有高级效果,使用性能比较高的方式 - dropShadowFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, [r / 255, g / 255, b / 255, a], filter.$blurX, filter.$blurY, filter.$angle ? (filter.$angle / 180 * Math.PI) : 0, filter.$distance || 0, filter.$strength); - } - } - else if (filter.type == "custom") { - // 目前canvas渲染不支持自定义滤镜 - } - } - displayContext.putImageData(imageData, 0, 0); - // 绘制结果的时候,应用滤镜 - context.drawImage(displayBuffer.surface, offsetX + displayBoundsX, offsetY + displayBoundsY); - if (hasBlendMode) { - context.globalCompositeOperation = defaultCompositeOp; - } - } - renderBufferPool_Filters.push(displayBuffer); - return drawCalls; - }; - CanvasRenderer.prototype.drawWithClip = function (displayObject, context, offsetX, offsetY) { - var drawCalls = 0; - var hasBlendMode = (displayObject.$blendMode !== 0); - var compositeOp; - if (hasBlendMode) { - compositeOp = blendModes[displayObject.$blendMode]; - if (!compositeOp) { - compositeOp = defaultCompositeOp; - } - } - var scrollRect = displayObject.$scrollRect ? displayObject.$scrollRect : displayObject.$maskRect; - var mask = displayObject.$mask; - if (mask) { - var maskRenderMatrix = mask.$getMatrix(); - //遮罩scaleX或scaleY为0,放弃绘制 - if ((maskRenderMatrix.a == 0 && maskRenderMatrix.b == 0) || (maskRenderMatrix.c == 0 && maskRenderMatrix.d == 0)) { - return drawCalls; - } - } - //没有遮罩,同时显示对象没有子项 - if (!mask && (!displayObject.$children || displayObject.$children.length == 0)) { - if (scrollRect) { - context.save(); - context.beginPath(); - context.rect(scrollRect.x + offsetX, scrollRect.y + offsetY, scrollRect.width, scrollRect.height); - context.clip(); - } - if (hasBlendMode) { - context.globalCompositeOperation = compositeOp; - } - drawCalls += this.drawDisplayObject(displayObject, context, offsetX, offsetY); - if (hasBlendMode) { - context.globalCompositeOperation = defaultCompositeOp; - } - if (scrollRect) { - context.restore(); - } - return drawCalls; - } - //遮罩是单纯的填充图形,且alpha为1,性能优化 - if (mask) { - var maskRenderNode = mask.$getRenderNode(); - if ((!mask.$children || mask.$children.length == 0) && - maskRenderNode && maskRenderNode.type == 3 /* GraphicsNode */ && - maskRenderNode.drawData.length == 1 && - maskRenderNode.drawData[0].type == 1 /* Fill */ && - maskRenderNode.drawData[0].fillAlpha == 1) { - this.renderingMask = true; - context.save(); - var maskMatrix = egret.Matrix.create(); - maskMatrix.copyFrom(mask.$getConcatenatedMatrix()); - mask.$getConcatenatedMatrixAt(displayObject, maskMatrix); - maskMatrix.prepend(1, 0, 0, 1, offsetX, offsetY); - context.transform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.tx, maskMatrix.ty); - var calls = this.drawDisplayObject(mask, context, 0, 0); - this.renderingMask = false; - maskMatrix.$invertInto(maskMatrix); - context.transform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.tx, maskMatrix.ty); - egret.Matrix.release(maskMatrix); - if (scrollRect) { - context.beginPath(); - context.rect(scrollRect.x + offsetX, scrollRect.y + offsetY, scrollRect.width, scrollRect.height); - context.clip(); - } - calls += this.drawDisplayObject(displayObject, context, offsetX, offsetY); - context.restore(); - return calls; - } - } - //todo 若显示对象是容器,同时子项有混合模式,则需要先绘制背景到displayBuffer并清除背景区域 - //绘制显示对象自身,若有scrollRect,应用clip - var displayBounds = displayObject.$getOriginalBounds(); - var displayBoundsX = displayBounds.x; - var displayBoundsY = displayBounds.y; - var displayBoundsWidth = displayBounds.width; - var displayBoundsHeight = displayBounds.height; - if (displayBoundsWidth <= 0 || displayBoundsHeight <= 0) { - return drawCalls; - } - var displayBuffer = this.createRenderBuffer(displayBoundsWidth, displayBoundsHeight); - var displayContext = displayBuffer.context; - if (!displayContext) { - drawCalls += this.drawDisplayObject(displayObject, context, offsetX, offsetY); - return drawCalls; - } - drawCalls += this.drawDisplayObject(displayObject, displayContext, -displayBoundsX, -displayBoundsY); - //绘制遮罩 - if (mask) { - var maskRenderNode = mask.$getRenderNode(); - var maskMatrix = egret.Matrix.create(); - maskMatrix.copyFrom(mask.$getConcatenatedMatrix()); - mask.$getConcatenatedMatrixAt(displayObject, maskMatrix); - maskMatrix.translate(-displayBoundsX, -displayBoundsY); - //如果只有一次绘制或是已经被cache直接绘制到displayContext - if (maskRenderNode && maskRenderNode.$getRenderCount() == 1 || mask.$displayList) { - displayContext.globalCompositeOperation = "destination-in"; - displayContext.save(); - displayContext.setTransform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.tx, maskMatrix.ty); - drawCalls += this.drawDisplayObject(mask, displayContext, 0, 0); - displayContext.restore(); - } - else { - var maskBuffer = this.createRenderBuffer(displayBoundsWidth, displayBoundsHeight); - var maskContext = maskBuffer.context; - maskContext.setTransform(maskMatrix.a, maskMatrix.b, maskMatrix.c, maskMatrix.d, maskMatrix.tx, maskMatrix.ty); - drawCalls += this.drawDisplayObject(mask, maskContext, 0, 0); - displayContext.globalCompositeOperation = "destination-in"; - displayContext.drawImage(maskBuffer.surface, 0, 0); - renderBufferPool.push(maskBuffer); - } - egret.Matrix.release(maskMatrix); - } - //绘制结果到屏幕 - if (drawCalls > 0) { - drawCalls++; - if (hasBlendMode) { - context.globalCompositeOperation = compositeOp; - } - if (scrollRect) { - context.save(); - context.beginPath(); - context.rect(scrollRect.x + offsetX, scrollRect.y + offsetY, scrollRect.width, scrollRect.height); - context.clip(); - } - context.drawImage(displayBuffer.surface, offsetX + displayBoundsX, offsetY + displayBoundsY); - if (scrollRect) { - context.restore(); - } - if (hasBlendMode) { - context.globalCompositeOperation = defaultCompositeOp; - } - } - renderBufferPool.push(displayBuffer); - return drawCalls; - }; - CanvasRenderer.prototype.drawWithScrollRect = function (displayObject, context, offsetX, offsetY) { - var drawCalls = 0; - var scrollRect = displayObject.$scrollRect ? displayObject.$scrollRect : displayObject.$maskRect; - if (scrollRect.isEmpty()) { - return drawCalls; - } - if (displayObject.$scrollRect) { - offsetX -= scrollRect.x; - offsetY -= scrollRect.y; - } - //绘制显示对象自身 - context.save(); - context.beginPath(); - context.rect(scrollRect.x + offsetX, scrollRect.y + offsetY, scrollRect.width, scrollRect.height); - context.clip(); - drawCalls += this.drawDisplayObject(displayObject, context, offsetX, offsetY); - context.restore(); - return drawCalls; - }; - CanvasRenderer.prototype.drawNodeToBuffer = function (node, buffer, matrix, forHitTest) { - var context = buffer.context; - context.setTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty); - this.renderNode(node, context, forHitTest); - }; - /** - * 将一个DisplayObject绘制到渲染缓冲,用于RenderTexture绘制 - * @param displayObject 要绘制的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - */ - CanvasRenderer.prototype.drawDisplayToBuffer = function (displayObject, buffer, matrix) { - var context = buffer.context; - if (matrix) { - context.setTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty); - } - var node; - if (displayObject.$renderDirty) { - node = displayObject.$getRenderNode(); - } - else { - node = displayObject.$renderNode; - } - var drawCalls = 0; - if (node) { - drawCalls++; - switch (node.type) { - case 1 /* BitmapNode */: - this.renderBitmap(node, context); - break; - case 2 /* TextNode */: - this.renderText(node, context); - break; - case 3 /* GraphicsNode */: - this.renderGraphics(node, context); - break; - case 4 /* GroupNode */: - this.renderGroup(node, context); - break; - case 5 /* MeshNode */: - this.renderMesh(node, context); - break; - case 6 /* NormalBitmapNode */: - this.renderNormalBitmap(node, context); - break; - } - } - var children = displayObject.$children; - if (children) { - var length_5 = children.length; - for (var i = 0; i < length_5; i++) { - var child = children[i]; - switch (child.$renderMode) { - case 1 /* NONE */: - break; - case 2 /* FILTER */: - drawCalls += this.drawWithFilter(child, context, 0, 0); - break; - case 3 /* CLIP */: - drawCalls += this.drawWithClip(child, context, 0, 0); - break; - case 4 /* SCROLLRECT */: - drawCalls += this.drawWithScrollRect(child, context, 0, 0); - break; - default: - drawCalls += this.drawDisplayObject(child, context, 0, 0); - break; - } - } - } - return drawCalls; - }; - CanvasRenderer.prototype.renderNode = function (node, context, forHitTest) { - var drawCalls = 0; - switch (node.type) { - case 1 /* BitmapNode */: - drawCalls = this.renderBitmap(node, context); - break; - case 2 /* TextNode */: - drawCalls = 1; - this.renderText(node, context); - break; - case 3 /* GraphicsNode */: - drawCalls = this.renderGraphics(node, context, forHitTest); - break; - case 4 /* GroupNode */: - drawCalls = this.renderGroup(node, context); - break; - case 5 /* MeshNode */: - drawCalls = this.renderMesh(node, context); - break; - case 6 /* NormalBitmapNode */: - drawCalls += this.renderNormalBitmap(node, context); - break; - } - return drawCalls; - }; - CanvasRenderer.prototype.renderNormalBitmap = function (node, context) { - var image = node.image; - if (!image || !image.source) { - return 0; - } - if (context.$imageSmoothingEnabled != node.smoothing) { - context.imageSmoothingEnabled = node.smoothing; - context.$imageSmoothingEnabled = node.smoothing; - } - if (node.rotated) { - var sourceX = node.sourceX; - var sourceY = node.sourceY; - var sourceHeight = node.sourceW; - var sourceWidth = node.sourceH; - var offsetX = node.drawX; - var offsetY = node.drawY; - var destHeight = node.drawW; - var destWidth = node.drawH; - context.save(); - context.transform(0, -1, 1, 0, 0, destWidth); - context.drawImage(image.source, sourceX, sourceY, sourceWidth, sourceHeight, offsetX + context.$offsetX, offsetY + context.$offsetY, destWidth, destHeight); - context.restore(); - } - else { - context.drawImage(image.source, node.sourceX, node.sourceY, node.sourceW, node.sourceH, node.drawX + context.$offsetX, node.drawY + context.$offsetY, node.drawW, node.drawH); - } - return 1; - }; - CanvasRenderer.prototype.renderBitmap = function (node, context) { - var image = node.image; - if (!image || !image.source) { - return 0; - } - if (context.$imageSmoothingEnabled != node.smoothing) { - context.imageSmoothingEnabled = node.smoothing; - context.$imageSmoothingEnabled = node.smoothing; - } - var data = node.drawData; - var length = data.length; - var pos = 0; - var m = node.matrix; - var blendMode = node.blendMode; - var alpha = node.alpha; - var saved = false; - var offsetX; - var offsetY; - if (m) { - context.save(); - saved = true; - if (context.$offsetX != 0 || context.$offsetY != 0) { - context.translate(context.$offsetX, context.$offsetY); - offsetX = context.$offsetX; - offsetY = context.$offsetY; - context.$offsetX = context.$offsetY = 0; - } - context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); - } - //这里不考虑嵌套 - if (blendMode) { - context.globalCompositeOperation = blendModes[blendMode]; - } - var originAlpha; - if (alpha == alpha) { - originAlpha = context.globalAlpha; - context.globalAlpha *= alpha; - } - var drawCalls = 0; - var filter = node.filter; - //todo 暂时只考虑绘制一次的情况 - if (filter && length == 8) { - var sourceX = data[0]; - var sourceY = data[1]; - var sourceWidth = data[2]; - var sourceHeight = data[3]; - var offsetX_1 = data[4]; - var offsetY_1 = data[5]; - var destWidth = data[6]; - var destHeight = data[7]; - if (node.rotated) { - sourceWidth = data[3]; - sourceHeight = data[2]; - destWidth = data[7]; - destHeight = data[6]; - } - var displayBuffer = this.createRenderBuffer(destWidth, destHeight); - var displayContext = displayBuffer.context; - drawCalls++; - if (node.rotated) { - context.transform(0, -1, 1, 0, 0, destWidth); - } - displayContext.drawImage(image.source, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, destWidth, destHeight); - //绘制结果到屏幕 - drawCalls++; - // 应用滤镜 - var imageData = displayContext.getImageData(0, 0, destWidth, destHeight); - colorFilter(imageData.data, destWidth, destHeight, filter.$matrix); - displayContext.putImageData(imageData, 0, 0); - // 绘制结果的时候,应用滤镜 - context.drawImage(displayBuffer.surface, 0, 0, destWidth, destHeight, offsetX_1 + context.$offsetX, offsetY_1 + context.$offsetY, destWidth, destHeight); - renderBufferPool.push(displayBuffer); - } - else { - while (pos < length) { - drawCalls++; - if (node.rotated) { - var sourceX = data[pos++]; - var sourceY = data[pos++]; - var sourceHeight = data[pos++]; - var sourceWidth = data[pos++]; - var offsetX_2 = data[pos++]; - var offsetY_2 = data[pos++]; - var destHeight = data[pos++]; - var destWidth = data[pos++]; - context.save(); - context.transform(0, -1, 1, 0, 0, destWidth); - context.drawImage(image.source, sourceX, sourceY, sourceWidth, sourceHeight, offsetX_2 + context.$offsetX, offsetY_2 + context.$offsetY, destWidth, destHeight); - context.restore(); - } - else { - context.drawImage(image.source, data[pos++], data[pos++], data[pos++], data[pos++], data[pos++] + context.$offsetX, data[pos++] + context.$offsetY, data[pos++], data[pos++]); - } - } - } - if (saved) { - context.restore(); - } - else { - if (blendMode) { - context.globalCompositeOperation = defaultCompositeOp; - } - if (alpha == alpha) { - context.globalAlpha = originAlpha; - } - } - if (offsetX) { - context.$offsetX = offsetX; - } - if (offsetY) { - context.$offsetY = offsetY; - } - return drawCalls; - }; - CanvasRenderer.prototype.renderMesh = function (node, context) { - return 0; - }; - CanvasRenderer.prototype.renderText = function (node, context) { - context.textAlign = "left"; - context.textBaseline = "middle"; - context.lineJoin = "round"; //确保描边样式是圆角 - var drawData = node.drawData; - var length = drawData.length; - var pos = 0; - while (pos < length) { - var x = drawData[pos++]; - var y = drawData[pos++]; - var text = drawData[pos++]; - var format = drawData[pos++]; - context.font = getFontString(node, format); - var textColor = format.textColor == null ? node.textColor : format.textColor; - var strokeColor = format.strokeColor == null ? node.strokeColor : format.strokeColor; - var stroke = format.stroke == null ? node.stroke : format.stroke; - context.fillStyle = egret.toColorString(textColor); - context.strokeStyle = egret.toColorString(strokeColor); - if (stroke) { - context.lineWidth = stroke * 2; - context.strokeText(text, x + context.$offsetX, y + context.$offsetY); - } - context.fillText(text, x + context.$offsetX, y + context.$offsetY); - } - }; - /** - * @private - */ - CanvasRenderer.prototype.renderGraphics = function (node, context, forHitTest) { - var drawData = node.drawData; - var length = drawData.length; - forHitTest = !!forHitTest; - for (var i = 0; i < length; i++) { - var path = drawData[i]; - switch (path.type) { - case 1 /* Fill */: - var fillPath = path; - context.fillStyle = forHitTest ? BLACK_COLOR : getRGBAString(fillPath.fillColor, fillPath.fillAlpha); - this.renderPath(path, context); - if (this.renderingMask) { - context.clip(); - } - else { - context.fill(); - } - break; - case 2 /* GradientFill */: - var g = path; - context.fillStyle = forHitTest ? BLACK_COLOR : getGradient(context, g.gradientType, g.colors, g.alphas, g.ratios, g.matrix); - context.save(); - var m = g.matrix; - this.renderPath(path, context); - context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); - context.fill(); - context.restore(); - break; - case 3 /* Stroke */: - var strokeFill = path; - var lineWidth = strokeFill.lineWidth; - context.lineWidth = lineWidth; - context.strokeStyle = forHitTest ? BLACK_COLOR : getRGBAString(strokeFill.lineColor, strokeFill.lineAlpha); - context.lineCap = CAPS_STYLES[strokeFill.caps]; - context.lineJoin = strokeFill.joints; - context.miterLimit = strokeFill.miterLimit; - if (context.setLineDash) { - context.setLineDash(strokeFill.lineDash); - } - //对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。 - var isSpecialCaseWidth = lineWidth === 1 || lineWidth === 3; - if (isSpecialCaseWidth) { - context.translate(0.5, 0.5); - } - this.renderPath(path, context); - context.stroke(); - if (isSpecialCaseWidth) { - context.translate(-0.5, -0.5); - } - break; - } - } - return length == 0 ? 0 : 1; - }; - CanvasRenderer.prototype.renderPath = function (path, context) { - context.beginPath(); - var data = path.$data; - var commands = path.$commands; - var commandCount = commands.length; - var pos = 0; - for (var commandIndex = 0; commandIndex < commandCount; commandIndex++) { - var command = commands[commandIndex]; - switch (command) { - case 4 /* CubicCurveTo */: - context.bezierCurveTo(data[pos++] + context.$offsetX, data[pos++] + context.$offsetY, data[pos++] + context.$offsetX, data[pos++] + context.$offsetY, data[pos++] + context.$offsetX, data[pos++] + context.$offsetY); - break; - case 3 /* CurveTo */: - context.quadraticCurveTo(data[pos++] + context.$offsetX, data[pos++] + context.$offsetY, data[pos++] + context.$offsetX, data[pos++] + context.$offsetY); - break; - case 2 /* LineTo */: - context.lineTo(data[pos++] + context.$offsetX, data[pos++] + context.$offsetY); - break; - case 1 /* MoveTo */: - context.moveTo(data[pos++] + context.$offsetX, data[pos++] + context.$offsetY); - break; - } - } - }; - CanvasRenderer.prototype.renderGroup = function (groupNode, context) { - var m = groupNode.matrix; - var saved = false; - var offsetX; - var offsetY; - if (m) { - context.save(); - saved = true; - if (context.$offsetX != 0 || context.$offsetY != 0) { - context.translate(context.$offsetX, context.$offsetY); - offsetX = context.$offsetX; - offsetY = context.$offsetY; - context.$offsetX = context.$offsetY = 0; - } - context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); - } - var drawCalls = 0; - var children = groupNode.drawData; - var length = children.length; - for (var i = 0; i < length; i++) { - var node = children[i]; - drawCalls += this.renderNode(node, context); - } - if (saved) { - context.restore(); - } - if (offsetX) { - context.$offsetX = offsetX; - } - if (offsetY) { - context.$offsetY = offsetY; - } - return drawCalls; - }; - CanvasRenderer.prototype.createRenderBuffer = function (width, height, useForFilters) { - var buffer = useForFilters ? renderBufferPool_Filters.pop() : renderBufferPool.pop(); - if (buffer) { - buffer.resize(width, height, true); - } - else { - buffer = new egret.sys.CanvasRenderBuffer(width, height); - } - return buffer; - }; - return CanvasRenderer; - }()); - egret.CanvasRenderer = CanvasRenderer; - __reflect(CanvasRenderer.prototype, "egret.CanvasRenderer"); - /** - * @private - * 获取字体字符串 - */ - function getFontString(node, format) { - var italic = format.italic == null ? node.italic : format.italic; - var bold = format.bold == null ? node.bold : format.bold; - var size = format.size == null ? node.size : format.size; - var fontFamily = format.fontFamily || node.fontFamily; - var font = italic ? "italic " : "normal "; - font += bold ? "bold " : "normal "; - font += size + "px " + fontFamily; - return font; - } - egret.getFontString = getFontString; - /** - * @private - * 获取RGBA字符串 - */ - function getRGBAString(color, alpha) { - var red = color >> 16; - var green = (color >> 8) & 0xFF; - var blue = color & 0xFF; - return "rgba(" + red + "," + green + "," + blue + "," + alpha + ")"; - } - egret.getRGBAString = getRGBAString; - /** - * @private - * 获取渐变填充样式对象 - */ - function getGradient(context, type, colors, alphas, ratios, matrix) { - var gradient; - if (type == egret.GradientType.LINEAR) { - gradient = context.createLinearGradient(-1, 0, 1, 0); - } - else { - gradient = context.createRadialGradient(0, 0, 0, 0, 0, 1); - } - //todo colors alphas ratios数量不一致情况处理 - var l = colors.length; - for (var i = 0; i < l; i++) { - gradient.addColorStop(ratios[i] / 255, getRGBAString(colors[i], alphas[i])); - } - return gradient; - } - // 判断浏览器是否支持 Uint8ClampedArray - var use8Clamp = false; - try { - use8Clamp = (typeof Uint8ClampedArray !== undefined); - } - catch (e) { } - function setArray(a, b, index) { - if (index === void 0) { index = 0; } - for (var i = 0, l = b.length; i < l; i++) { - a[i + index] = b[i]; - } - } - /** - * @private - */ - function colorFilter(buffer, w, h, matrix) { - var r0 = matrix[0], r1 = matrix[1], r2 = matrix[2], r3 = matrix[3], r4 = matrix[4]; - var g0 = matrix[5], g1 = matrix[6], g2 = matrix[7], g3 = matrix[8], g4 = matrix[9]; - var b0 = matrix[10], b1 = matrix[11], b2 = matrix[12], b3 = matrix[13], b4 = matrix[14]; - var a0 = matrix[15], a1 = matrix[16], a2 = matrix[17], a3 = matrix[18], a4 = matrix[19]; - for (var p = 0, e = w * h * 4; p < e; p += 4) { - var r = buffer[p + 0]; - var g = buffer[p + 1]; - var b = buffer[p + 2]; - var a = buffer[p + 3]; - buffer[p + 0] = r0 * r + r1 * g + r2 * b + r3 * a + r4; - buffer[p + 1] = g0 * r + g1 * g + g2 * b + g3 * a + g4; - buffer[p + 2] = b0 * r + b1 * g + b2 * b + b3 * a + b4; - buffer[p + 3] = a0 * r + a1 * g + a2 * b + a3 * a + a4; - } - } - /** - * @private - */ - function blurFilter(buffer, w, h, blurX, blurY) { - blurFilterH(buffer, w, h, blurX); - blurFilterV(buffer, w, h, blurY); - } - /** - * @private - */ - function blurFilterH(buffer, w, h, blurX) { - var lineBuffer; - if (use8Clamp) { - lineBuffer = new Uint8ClampedArray(w * 4); - } - else { - lineBuffer = new Array(w * 4); - } - var lineSize = w * 4; - var windowLength = (blurX * 2) + 1; - var windowSize = windowLength * 4; - for (var y = 0; y < h; y++) { - var pLineStart = y * lineSize; - var rs = 0, gs = 0, bs = 0, _as = 0, alpha = 0, alpha2 = 0; - // Fill window - for (var ptr = -blurX * 4, end = blurX * 4 + 4; ptr < end; ptr += 4) { - var key = pLineStart + ptr; - if (key < pLineStart || key >= pLineStart + lineSize) { - continue; - } - alpha = buffer[key + 3]; - rs += buffer[key + 0] * alpha; - gs += buffer[key + 1] * alpha; - bs += buffer[key + 2] * alpha; - _as += alpha; - } - // Slide window - for (var ptr = pLineStart, end = pLineStart + lineSize, linePtr = 0, lastPtr = ptr - blurX * 4, nextPtr = ptr + (blurX + 1) * 4; ptr < end; ptr += 4, linePtr += 4, nextPtr += 4, lastPtr += 4) { - if (_as === 0) { - lineBuffer[linePtr + 0] = 0; - lineBuffer[linePtr + 1] = 0; - lineBuffer[linePtr + 2] = 0; - lineBuffer[linePtr + 3] = 0; - } - else { - lineBuffer[linePtr + 0] = rs / _as; - lineBuffer[linePtr + 1] = gs / _as; - lineBuffer[linePtr + 2] = bs / _as; - lineBuffer[linePtr + 3] = _as / windowLength; - } - alpha = buffer[nextPtr + 3]; - alpha2 = buffer[lastPtr + 3]; - if (alpha || alpha == 0) { - if (alpha2 || alpha2 == 0) { - rs += buffer[nextPtr + 0] * alpha - buffer[lastPtr + 0] * alpha2; - gs += buffer[nextPtr + 1] * alpha - buffer[lastPtr + 1] * alpha2; - bs += buffer[nextPtr + 2] * alpha - buffer[lastPtr + 2] * alpha2; - _as += alpha - alpha2; - } - else { - rs += buffer[nextPtr + 0] * alpha; - gs += buffer[nextPtr + 1] * alpha; - bs += buffer[nextPtr + 2] * alpha; - _as += alpha; - } - } - else { - if (alpha2 || alpha2 == 0) { - rs += -buffer[lastPtr + 0] * alpha2; - gs += -buffer[lastPtr + 1] * alpha2; - bs += -buffer[lastPtr + 2] * alpha2; - _as += -alpha2; - } - else { - // do nothing - } - } - } - // Copy line - if (use8Clamp) { - buffer.set(lineBuffer, pLineStart); - } - else { - setArray(buffer, lineBuffer, pLineStart); - } - } - } - /** - * @private - */ - function blurFilterV(buffer, w, h, blurY) { - var columnBuffer; - if (use8Clamp) { - columnBuffer = new Uint8ClampedArray(h * 4); - } - else { - columnBuffer = new Array(h * 4); - } - var stride = w * 4; - var windowLength = (blurY * 2) + 1; - for (var x = 0; x < w; x++) { - var pColumnStart = x * 4; - var rs = 0, gs = 0, bs = 0, _as = 0, alpha = 0, alpha2 = 0; - // Fill window - for (var ptr = -blurY * stride, end = blurY * stride + stride; ptr < end; ptr += stride) { - var key = pColumnStart + ptr; - if (key < pColumnStart || key >= pColumnStart + h * stride) { - continue; - } - alpha = buffer[key + 3]; - rs += buffer[key + 0] * alpha; - gs += buffer[key + 1] * alpha; - bs += buffer[key + 2] * alpha; - _as += alpha; - } - // Slide window - for (var ptr = pColumnStart, end = pColumnStart + h * stride, columnPtr = 0, lastPtr = pColumnStart - blurY * stride, nextPtr = pColumnStart + ((blurY + 1) * stride); ptr < end; ptr += stride, columnPtr += 4, nextPtr += stride, lastPtr += stride) { - if (_as === 0) { - columnBuffer[columnPtr + 0] = 0; - columnBuffer[columnPtr + 1] = 0; - columnBuffer[columnPtr + 2] = 0; - columnBuffer[columnPtr + 3] = 0; - } - else { - columnBuffer[columnPtr + 0] = rs / _as; - columnBuffer[columnPtr + 1] = gs / _as; - columnBuffer[columnPtr + 2] = bs / _as; - columnBuffer[columnPtr + 3] = _as / windowLength; - } - alpha = buffer[nextPtr + 3]; - alpha2 = buffer[lastPtr + 3]; - if (alpha || alpha == 0) { - if (alpha2 || alpha2 == 0) { - rs += buffer[nextPtr + 0] * alpha - buffer[lastPtr + 0] * alpha2; - gs += buffer[nextPtr + 1] * alpha - buffer[lastPtr + 1] * alpha2; - bs += buffer[nextPtr + 2] * alpha - buffer[lastPtr + 2] * alpha2; - _as += alpha - alpha2; - } - else { - rs += buffer[nextPtr + 0] * alpha; - gs += buffer[nextPtr + 1] * alpha; - bs += buffer[nextPtr + 2] * alpha; - _as += alpha; - } - } - else { - if (alpha2 || alpha2 == 0) { - rs += -buffer[lastPtr + 0] * alpha2; - gs += -buffer[lastPtr + 1] * alpha2; - bs += -buffer[lastPtr + 2] * alpha2; - _as += -alpha2; - } - else { - // do nothing - } - } - } - // Copy column - for (var i = x * 4, end = i + h * stride, j = 0; i < end; i += stride, j += 4) { - buffer[i + 0] = columnBuffer[j + 0]; - buffer[i + 1] = columnBuffer[j + 1]; - buffer[i + 2] = columnBuffer[j + 2]; - buffer[i + 3] = columnBuffer[j + 3]; - } - } - } - // function glowFilter(buffer, w, h, color, blurX, blurY, strength) { - // dropShadowFilter(buffer, w, h, color, blurX, blurY, 0, 0, strength) - // } - function dropShadowFilter(buffer, w, h, color, blurX, blurY, angle, distance, strength) { - var tmp = alphaFilter(buffer, color); - panFilter(tmp, w, h, angle, distance); - blurFilter(tmp, w, h, blurX, blurY); - scaleAlphaChannel(tmp, strength); - compositeSourceOver(tmp, buffer); - buffer.set(tmp); - if (use8Clamp) { - buffer.set(tmp); - } - else { - setArray(buffer, tmp); - } - } - function alphaFilter(buffer, color) { - if (!color) { - color = [0, 0, 0, 0]; - } - var plane; - if (use8Clamp) { - plane = new Uint8ClampedArray(buffer); - } - else { - plane = new Array(buffer.length); - setArray(plane, buffer); - } - var colorR = color[0]; - var colorG = color[1]; - var colorB = color[2]; - var colorA = color[3]; - for (var ptr = 0, end = plane.length; ptr < end; ptr += 4) { - var alpha = plane[ptr + 3]; - plane[ptr + 0] = colorR * alpha; - plane[ptr + 1] = colorG * alpha; - plane[ptr + 2] = colorB * alpha; - plane[ptr + 3] = colorA * alpha; - } - return plane; - } - function panFilter(buffer, w, h, angle, distance) { - var dy = (Math.sin(angle) * distance) | 0; - var dx = (Math.cos(angle) * distance) | 0; - var oldBuffer, newBuffer; - if (use8Clamp) { - oldBuffer = new Int32Array(buffer.buffer); - newBuffer = new Int32Array(oldBuffer.length); - for (var oy = 0; oy < h; oy++) { - var ny = oy + dy; - if (ny < 0 || ny > h) { - continue; - } - for (var ox = 0; ox < w; ox++) { - var nx = ox + dx; - if (nx < 0 || nx > w) { - continue; - } - newBuffer[ny * w + nx] = oldBuffer[oy * w + ox]; - } - } - oldBuffer.set(newBuffer); - } - else { - oldBuffer = buffer; - newBuffer = new Array(oldBuffer.length); - for (var oy = 0; oy < h; oy++) { - var ny = oy + dy; - if (ny < 0 || ny > h) { - continue; - } - for (var ox = 0; ox < w; ox++) { - var nx = ox + dx; - if (nx < 0 || nx > w) { - continue; - } - newBuffer[(ny * w + nx) * 4 + 0] = oldBuffer[(oy * w + ox) * 4 + 0]; - newBuffer[(ny * w + nx) * 4 + 1] = oldBuffer[(oy * w + ox) * 4 + 1]; - newBuffer[(ny * w + nx) * 4 + 2] = oldBuffer[(oy * w + ox) * 4 + 2]; - newBuffer[(ny * w + nx) * 4 + 3] = oldBuffer[(oy * w + ox) * 4 + 3]; - } - } - setArray(oldBuffer, newBuffer); - } - } - function scaleAlphaChannel(buffer, value) { - for (var ptr = 0, end = buffer.length; ptr < end; ptr += 4) { - buffer[ptr + 3] *= value; - } - } - function compositeSourceOver(dst, src) { - for (var ptr = 0, end = dst.length; ptr < end; ptr += 4) { - var Dr = dst[ptr + 0]; - var Dg = dst[ptr + 1]; - var Db = dst[ptr + 2]; - var Da = dst[ptr + 3] / 255; - var Sr = src[ptr + 0]; - var Sg = src[ptr + 1]; - var Sb = src[ptr + 2]; - var Sa = src[ptr + 3] / 255; - dst[ptr + 0] = Sr + Dr * (1 - Sa); - dst[ptr + 1] = Sg + Dg * (1 - Sa); - dst[ptr + 2] = Sb + Db * (1 - Sa); - dst[ptr + 3] = (Sa + Da * (1 - Sa)) * 255; - } - } - function getPixelKey(w, x, y) { - return y * w * 4 + x * 4; - } - function mix(v1, v2, rate) { - return v1 * (1 - rate) + v2 * rate; - } - // dropShadowFilter2 - // 模拟shader中的算法,可以实现内发光,挖空等高级效果 - function dropShadowFilter2(buffer, w, h, color, blurX, blurY, angle, distance, strength, inner, knockout, hideObject) { - var plane; - if (use8Clamp) { - plane = new Uint8ClampedArray(buffer.length); - } - else { - plane = new Array(buffer.length); - } - var alpha = color[3]; - var curDistanceX = 0; - var curDistanceY = 0; - var offsetX = distance * Math.cos(angle); - var offsetY = distance * Math.sin(angle); - var linearSamplingTimes = 7.0; - var circleSamplingTimes = 12.0; - var PI = 3.14159265358979323846264; - var cosAngle; - var sinAngle; - var stepX = blurX / linearSamplingTimes; - var stepY = blurY / linearSamplingTimes; - // 遍历像素 - for (var u = 0; u < w; u++) { - for (var v = 0; v < h; v++) { - // 此处为了避免毛刺可以添加一个随机值 - var offset = 0; - // 处理单个像素 - var key = v * w * 4 + u * 4; - var totalAlpha = 0; - var maxTotalAlpha = 0; - // 采样出来的色值 - var _r = buffer[key + 0] / 255; - var _g = buffer[key + 1] / 255; - var _b = buffer[key + 2] / 255; - var _a = buffer[key + 3] / 255; - for (var a = 0; a <= PI * 2; a += PI * 2 / circleSamplingTimes) { - cosAngle = Math.cos(a + offset); - sinAngle = Math.sin(a + offset); - for (var i = 0; i < linearSamplingTimes; i++) { - curDistanceX = i * stepX * cosAngle; - curDistanceY = i * stepY * sinAngle; - var _u = Math.round(u + curDistanceX - offsetX); - var _v = Math.round(v + curDistanceY - offsetY); - var __a = 0; - if (_u >= w || _u < 0 || _v < 0 || _v >= h) { - __a = 0; - } - else { - var _key = _v * w * 4 + _u * 4; - __a = buffer[_key + 3] / 255; - } - totalAlpha += (linearSamplingTimes - i) * __a; - maxTotalAlpha += (linearSamplingTimes - i); - } - } - _a = Math.max(_a, 0.0001); - // 'ownColor.rgb = ownColor.rgb / ownColor.a;', - var outerGlowAlpha = (totalAlpha / maxTotalAlpha) * strength * alpha * (1. - inner) * Math.max(Math.min(hideObject, knockout), 1. - _a); - var innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * strength * alpha * inner * _a; - _a = Math.max(_a * knockout * (1 - hideObject), 0.0001); - var rate1 = innerGlowAlpha / (innerGlowAlpha + _a); - var r1 = mix(_r, color[0], rate1); - var g1 = mix(_g, color[1], rate1); - var b1 = mix(_b, color[2], rate1); - var rate2 = outerGlowAlpha / (innerGlowAlpha + _a + outerGlowAlpha); - var r2 = mix(r1, color[0], rate2); - var g2 = mix(g1, color[1], rate2); - var b2 = mix(b1, color[2], rate2); - var resultAlpha = Math.min(_a + outerGlowAlpha + innerGlowAlpha, 1); - // 赋值颜色 - plane[key + 0] = r2 * 255; - plane[key + 1] = g2 * 255; - plane[key + 2] = b2 * 255; - plane[key + 3] = resultAlpha * 255; - } - } - if (use8Clamp) { - buffer.set(plane); - } - else { - setArray(buffer, plane); - } - } -})(egret || (egret = {})); -var egret; -(function (egret) { - /** - * @copy egret.Orientation - */ - egret.DeviceOrientation = null; -})(egret || (egret = {})); -var egret; -(function (egret) { -})(egret || (egret = {})); -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Type of operation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行类型的类型。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var RuntimeType; - (function (RuntimeType) { - /** - * Running on Web - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Web上 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - RuntimeType.WEB = "web"; - /** - * Running on NATIVE - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language en_US - */ - /** - * 运行在NATIVE上 - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language zh_CN - */ - RuntimeType.NATIVE = "native"; - /** - * Running on Runtime2.0 - * @version Egret 5.1.5 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Runtime2.0上 - * @version Egret 5.1.5 - * @platform Web,Native - * @language zh_CN - */ - RuntimeType.RUNTIME2 = "runtime2"; - /** - * Running on Alipay - * @version Egret 5.2.33 - * @platform All - * @language en_US - */ - /** - * 运行在支付宝小游戏上 - * @version Egret 5.2.33 - * @platform All - * @language zh_CN - */ - RuntimeType.MYGAME = "mygame"; - /** - * Running on WeChat mini game - * @version Egret 5.1.5 - * @platform All - * @language en_US - */ - /** - * 运行在微信小游戏上 - * @version Egret 5.1.5 - * @platform All - * @language zh_CN - */ - RuntimeType.WXGAME = "wxgame"; - /** - * Running on Baidu mini game - * @version Egret 5.2.13 - * @platform All - * @language en_US - */ - /** - * 运行在百度小游戏上 - * @version Egret 5.2.13 - * @platform All - * @language zh_CN - */ - RuntimeType.BAIDUGAME = "baidugame"; - /** - * Running on Xiaomi quick game - * @version Egret 5.2.14 - * @platform All - * @language en_US - */ - /** - * 运行在小米快游戏上 - * @version Egret 5.2.14 - * @platform All - * @language zh_CN - */ - RuntimeType.QGAME = "qgame"; - /** - * Running on OPPO mini game - * @version Egret 5.2.14 - * @platform All - * @language en_US - */ - /** - * 运行在 Oppo 小游戏上 - * @version Egret 5.2.14 - * @platform All - * @language zh_CN - */ - RuntimeType.OPPOGAME = "oppogame"; - /** - * Running on QQ mini game - * @version Egret 5.2.25 - * @platform All - * @language en_US - */ - /** - * 运行在 QQ 小游戏上 - * @version Egret 5.2.25 - * @platform All - * @language zh_CN - */ - RuntimeType.QQGAME = "qqgame"; - /** - * Running on vivo mini game - * @version Egret 5.2.23 - * @platform All - * @language en_US - */ - /** - * 运行在 vivo 小游戏上 - * @version Egret 5.2.23 - * @platform All - * @language zh_CN - */ - RuntimeType.VIVOGAME = "vivogame"; - })(RuntimeType = egret.RuntimeType || (egret.RuntimeType = {})); - /** - * The Capabilities class provides properties that describe the system and runtime that are hosting the application. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language en_US - */ - /** - * Capabilities 类提供一些属性,这些属性描述了承载应用程序的系统和运行时。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language zh_CN - */ - var Capabilities = (function () { - function Capabilities() { - } - /** - * Specifies the language code of the system on which the content is running. The language is specified as a lowercase - * two-letter language code from ISO 639-1. For Chinese, an additional uppercase two-letter country code from ISO 3166 - * distinguishes between Simplified and Traditional Chinese.
    - * The following table lists the possible values,but not limited to them: - *
      - *
    • Simplified Chinese zh-CN
    • - *
    • Traditional Chinese zh-TW
    • - *
    • English en
    • - *
    • Japanese ja
    • - *
    • Korean ko
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示运行内容的系统的语言代码。语言指定为 ISO 639-1 中的小写双字母语言代码。 - * 对于中文,另外使用 ISO 3166 中的大写双字母国家/地区代码,以区分简体中文和繁体中文。
    - * 以下是可能但不限于的语言和值: - *
      - *
    • 简体中文 zh-CN
    • - *
    • 繁体中文 zh-TW
    • - *
    • 英语 en
    • - *
    • 日语 ja
    • - *
    • 韩语 ko
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.language = "zh-CN"; - /** - * Specifies the current operating system. The os property can return the following strings: - *
      - *
    • iPhone "iOS"
    • - *
    • Android Phone "Android"
    • - *
    • Windows Phone "Windows Phone"
    • - *
    • Windows Desktop "Windows PC"
    • - *
    • Mac Desktop "Mac OS"
    • - *
    • Unknown OS "Unknown"
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的操作系统。os 属性返回下列字符串: - *
      - *
    • 苹果手机操作系统 "iOS"
    • - *
    • 安卓手机操作系统 "Android"
    • - *
    • 微软手机操作系统 "Windows Phone"
    • - *
    • 微软桌面操作系统 "Windows PC"
    • - *
    • 苹果桌面操作系统 "Mac OS"
    • - *
    • 未知操作系统 "Unknown"
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.os = "Unknown"; - /** - * It indicates the current type of operation. runtimeType property returns the following string: - *
      - *
    • Run on Web egret.RuntimeType.WEB
    • - *
    • Run on Runtime2.0 egret.RuntimeType.RUNTIME2
    • - *
    • Run on WeChat mini game egret.RuntimeType.WXGAME
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的运行类型。runtimeType 属性返回下列字符串: - *
      - *
    • 运行在Web上 egret.RuntimeType.WEB
    • - *
    • 运行在Runtime2.0上 egret.RuntimeType.RUNTIME2
    • - *
    • 运行在微信小游戏上 egret.RuntimeType.WXGAME
    • - *
    - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.runtimeType = egret.RuntimeType.WEB; - /*** - * version of Egret. - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language en_US - */ - /*** - * Egret 的版本号。 - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.engineVersion = "5.2.33"; - /*** - * current render mode. - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language en_US - */ - /*** - * 当前渲染模式。 - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.renderMode = "Unknown"; - /*** - * Clients border width. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界宽度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.boundingClientWidth = 0; - /*** - * Clients border height. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界高度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - Capabilities.boundingClientHeight = 0; - return Capabilities; - }()); - egret.Capabilities = Capabilities; - __reflect(Capabilities.prototype, "egret.Capabilities"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * RenderTexture is a dynamic texture - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language en_US - */ - /** - * RenderTexture 是动态纹理类,他实现了将显示对象及其子对象绘制成为一个纹理的功能 - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language zh_CN - */ - var RenderTexture = (function (_super) { - __extends(RenderTexture, _super); - function RenderTexture() { - var _this = _super.call(this) || this; - _this.$renderBuffer = new egret.sys.RenderBuffer(); - var bitmapData = new egret.BitmapData(_this.$renderBuffer.surface); - bitmapData.$deleteSource = false; - _this._setBitmapData(bitmapData); - return _this; - } - /** - * The specified display object is drawn as a texture - * @param displayObject {egret.DisplayObject} the display to draw - * @param clipBounds {egret.Rectangle} clip rect - * @param scale {number} scale factor - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定显示对象绘制为一个纹理 - * @param displayObject {egret.DisplayObject} 需要绘制的显示对象 - * @param clipBounds {egret.Rectangle} 绘制矩形区域 - * @param scale {number} 缩放比例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - RenderTexture.prototype.drawToTexture = function (displayObject, clipBounds, scale) { - if (scale === void 0) { scale = 1; } - if (clipBounds && (clipBounds.width == 0 || clipBounds.height == 0)) { - return false; - } - var bounds = clipBounds || displayObject.$getOriginalBounds(); - if (bounds.width == 0 || bounds.height == 0) { - return false; - } - scale /= egret.$TextureScaleFactor; - var width = (bounds.x + bounds.width) * scale; - var height = (bounds.y + bounds.height) * scale; - if (clipBounds) { - width = bounds.width * scale; - height = bounds.height * scale; - } - var renderBuffer = this.$renderBuffer; - if (!renderBuffer) { - return false; - } - renderBuffer.resize(width, height); - this.$bitmapData.width = width; - this.$bitmapData.height = height; - if (egret.nativeRender) { - egret_native.activateBuffer(this.$renderBuffer); - var useClip = false; - var clipX = 0; - var clipY = 0; - var clipW = 0; - var clipH = 0; - if (clipBounds) { - useClip = true; - clipX = clipBounds.x; - clipY = clipBounds.y; - clipW = clipBounds.width; - clipH = clipBounds.height; - } - egret_native.updateNativeRender(); - egret_native.nrRenderDisplayObject(displayObject.$nativeDisplayObject.id, scale, useClip, clipX, clipY, clipW, clipH); - egret_native.activateBuffer(null); - } - else { - var matrix = egret.Matrix.create(); - matrix.identity(); - matrix.scale(scale, scale); - //应用裁切 - if (clipBounds) { - matrix.translate(-clipBounds.x, -clipBounds.y); - } - egret.sys.systemRenderer.render(displayObject, renderBuffer, matrix, true); - egret.Matrix.release(matrix); - } - //设置纹理参数 - this.$initData(0, 0, width, height, 0, 0, width, height, width, height); - return true; - }; - /** - * @inheritDoc - */ - RenderTexture.prototype.getPixel32 = function (x, y) { - var data; - if (this.$renderBuffer) { - var scale = egret.$TextureScaleFactor; - x = Math.round(x / scale); - y = Math.round(y / scale); - data = this.$renderBuffer.getPixels(x, y, 1, 1); - } - return data; - }; - /** - * @inheritDoc - */ - RenderTexture.prototype.dispose = function () { - _super.prototype.dispose.call(this); - this.$renderBuffer = null; - }; - return RenderTexture; - }(egret.Texture)); - egret.RenderTexture = RenderTexture; - __reflect(RenderTexture.prototype, "egret.RenderTexture"); -})(egret || (egret = {})); -var egret; -(function (egret) { - /** - * @private - */ - var implMap = {}; - /** - * Adds an interface-name-to-implementation-class mapping to the registry. - * @param interfaceName the interface name to register. For example:"eui.IAssetAdapter","eui.Theme" - * @param instance the instance to register. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 注册一个接口实现。 - * @param interfaceName 注入的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @param instance 实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function registerImplementation(interfaceName, instance) { - implMap[interfaceName] = instance; - } - egret.registerImplementation = registerImplementation; - /** - * Returns the singleton instance of the implementation class that was registered for the specified interface. - * This method is usually called by egret framework. - * @param interfaceName The interface name to identify. For example:"eui.IAssetAdapter","eui.Theme" - * @returns the singleton instance of the implementation class - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个接口实现。此方法通常由框架内部调用。获取项目注入的自定义实现实例。 - * @param interfaceName 要获取的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @returns 返回实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function getImplementation(interfaceName) { - return implMap[interfaceName]; - } - egret.getImplementation = getImplementation; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * This class is used to create lightweight shapes using the drawing application program interface (API). The Shape - * class includes a graphics property, which lets you access methods from the Graphics class. - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language en_US - */ - /** - * 此类用于使用绘图应用程序编程接口 (API) 创建简单形状。Shape 类含有 graphics 属性,通过该属性您可以访问各种矢量绘图方法。 - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language zh_CN - */ - var Shape = (function (_super) { - __extends(Shape, _super); - /** - * Creates a new Shape object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Shape 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Shape() { - var _this = _super.call(this) || this; - _this.$graphics = new egret.Graphics(); - _this.$graphics.$setTarget(_this); - return _this; - } - Shape.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(8 /* GRAPHICS */); - }; - Object.defineProperty(Shape.prototype, "graphics", { - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$graphics; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - Shape.prototype.$measureContentBounds = function (bounds) { - this.$graphics.$measureContentBounds(bounds); - }; - Shape.prototype.$hitTest = function (stageX, stageY) { - var target = _super.prototype.$hitTest.call(this, stageX, stageY); - if (target == this) { - target = this.$graphics.$hitTest(stageX, stageY); - } - return target; - }; - /** - * @private - */ - Shape.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - if (this.$graphics) { - this.$graphics.$onRemoveFromStage(); - } - }; - return Shape; - }(egret.DisplayObject)); - egret.Shape = Shape; - __reflect(Shape.prototype, "egret.Shape"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Bitmap font, texture set of a font. It is generally used as the value of the BitmapText.font attribute. - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 Text(Containing the specific usage of the bitmap font ) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language en_US - */ - /** - * 位图字体,是一个字体的纹理集,通常作为BitmapText.font属性的值。 - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 文本(含位图字体具体用法) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language zh_CN - */ - var BitmapFont = (function (_super) { - __extends(BitmapFont, _super); - /** - * Create an egret.BitmapFont object - * @param texture {egret.Texture} Texture set that use TextureMerger create - * @param config {any} Configure data that use TextureMerger create - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapFont 对象 - * @param texture {egret.Texture} 使用TextureMerger生成的纹理集 - * @param config {any} 使用TextureMerger生成的配置数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function BitmapFont(texture, config) { - var _this = _super.call(this, texture) || this; - /** - * @private - */ - _this.firstCharHeight = 0; - if (typeof (config) == "string") { - _this.charList = _this.parseConfig(config); - } - else if (config && config.hasOwnProperty("frames")) { - _this.charList = config.frames; - } - else { - _this.charList = {}; - } - return _this; - } - /** - * Obtain corresponding texture through the name attribute - * @param name {string} name Attribute - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过 name 属性获取对应纹理 - * @param name {string} name属性 - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BitmapFont.prototype.getTexture = function (name) { - var texture = this._textureMap[name]; - if (!texture) { - var c = this.charList[name]; - if (!c) { - return null; - } - texture = this.createTexture(name, c.x, c.y, c.w, c.h, c.offX, c.offY, c.sourceW, c.sourceH); - this._textureMap[name] = texture; - } - return texture; - }; - /** - * @private - */ - BitmapFont.prototype.getConfig = function (name, key) { - if (!this.charList[name]) { - return 0; - } - return this.charList[name][key]; - }; - /** - * @private - * - * @returns - */ - BitmapFont.prototype._getFirstCharHeight = function () { - if (this.firstCharHeight == 0) { - for (var str in this.charList) { - var c = this.charList[str]; - if (c) { - var sourceH = c.sourceH; - if (sourceH === undefined) { - var h = c.h; - if (h === undefined) { - h = 0; - } - var offY = c.offY; - if (offY === undefined) { - offY = 0; - } - sourceH = h + offY; - } - if (sourceH <= 0) { - continue; - } - this.firstCharHeight = sourceH; - break; - } - } - } - return this.firstCharHeight; - }; - /** - * @private - * - * @param fntText - * @returns - */ - BitmapFont.prototype.parseConfig = function (fntText) { - fntText = fntText.split("\r\n").join("\n"); - var lines = fntText.split("\n"); - var charsCount = this.getConfigByKey(lines[3], "count"); - var chars = {}; - for (var i = 4; i < 4 + charsCount; i++) { - var charText = lines[i]; - var letter = String.fromCharCode(this.getConfigByKey(charText, "id")); - var c = {}; - chars[letter] = c; - c["x"] = this.getConfigByKey(charText, "x"); - c["y"] = this.getConfigByKey(charText, "y"); - c["w"] = this.getConfigByKey(charText, "width"); - c["h"] = this.getConfigByKey(charText, "height"); - c["offX"] = this.getConfigByKey(charText, "xoffset"); - c["offY"] = this.getConfigByKey(charText, "yoffset"); - c["xadvance"] = this.getConfigByKey(charText, "xadvance"); - } - return chars; - }; - /** - * @private - * - * @param configText - * @param key - * @returns - */ - BitmapFont.prototype.getConfigByKey = function (configText, key) { - var itemConfigTextList = configText.split(" "); - for (var i = 0, length_6 = itemConfigTextList.length; i < length_6; i++) { - var itemConfigText = itemConfigTextList[i]; - if (key == itemConfigText.substring(0, key.length)) { - var value = itemConfigText.substring(key.length + 1); - return parseInt(value); - } - } - return 0; - }; - return BitmapFont; - }(egret.SpriteSheet)); - egret.BitmapFont = BitmapFont; - __reflect(BitmapFont.prototype, "egret.BitmapFont"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Bitmap font adopts the Bitmap+SpriteSheet mode to render text. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language en_US - */ - /** - * 位图字体采用了Bitmap+SpriteSheet的方式来渲染文字。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language zh_CN - */ - var BitmapText = (function (_super) { - __extends(BitmapText, _super); - /** - * Create an egret.BitmapText object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapText 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function BitmapText() { - var _this = _super.call(this) || this; - _this.$smoothing = egret.Bitmap.defaultSmoothing; - _this.$text = ""; - _this.$textFieldWidth = NaN; - _this.$textLinesChanged = false; - _this.$textFieldHeight = NaN; - _this.$font = null; - _this.$fontStringChanged = false; - _this.$lineSpacing = 0; - _this.$letterSpacing = 0; - _this.$textAlign = egret.HorizontalAlign.LEFT; - _this.$verticalAlign = egret.VerticalAlign.TOP; - _this.$textWidth = NaN; - _this.$textHeight = NaN; - /** - * @private - */ - _this.$textOffsetX = 0; - /** - * @private - */ - _this.$textOffsetY = 0; - /** - * @private - */ - _this.$textStartX = 0; - /** - * @private - */ - _this.$textStartY = 0; - /** - * @private - */ - _this.textLines = []; - /** - * @private - */ - _this.$lineHeights = []; - if (!egret.nativeRender) { - _this.$renderNode = new egret.sys.BitmapNode(); - } - return _this; - } - BitmapText.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(11 /* BITMAP_TEXT */); - }; - Object.defineProperty(BitmapText.prototype, "smoothing", { - /** - * Whether or not is smoothed when scaled. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$smoothing; - }, - set: function (value) { - var self = this; - if (value == self.$smoothing) { - return; - } - self.$smoothing = value; - if (!egret.nativeRender) { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BitmapText.prototype, "text", { - /** - * A string to display in the text field. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要显示的文本内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$text; - }, - set: function (value) { - this.$setText(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - BitmapText.prototype.$setText = function (value) { - if (value == null) { - value = ""; - } - else { - value = String(value); - } - var self = this; - if (value == self.$text) - return false; - self.$text = value; - self.$invalidateContentBounds(); - return true; - }; - /** - * @private - */ - BitmapText.prototype.$getWidth = function () { - var self = this; - var w = self.$textFieldWidth; - return isNaN(w) ? self.$getContentBounds().width : w; - }; - /** - * @private - */ - BitmapText.prototype.$setWidth = function (value) { - var self = this; - if (value < 0 || value == self.$textFieldWidth) { - return false; - } - self.$textFieldWidth = value; - self.$invalidateContentBounds(); - return true; - }; - /** - * @private - */ - BitmapText.prototype.$invalidateContentBounds = function () { - this.$renderDirty = true; - this.$textLinesChanged = true; - //todo lcj - this.$updateRenderNode(); - }; - /** - * @private - */ - BitmapText.prototype.$getHeight = function () { - var self = this; - var h = self.$textFieldHeight; - return isNaN(h) ? self.$getContentBounds().height : h; - }; - /** - * @private - */ - BitmapText.prototype.$setHeight = function (value) { - var self = this; - if (value < 0 || value == self.$textFieldHeight) { - return false; - } - self.$textFieldHeight = value; - self.$invalidateContentBounds(); - return true; - }; - Object.defineProperty(BitmapText.prototype, "font", { - /** - * The name of the font to use, or a comma-separated list of font names, the type of value must be BitmapFont. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表,类型必须是 BitmapFont。 - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$font; - }, - set: function (value) { - this.$setFont(value); - }, - enumerable: true, - configurable: true - }); - BitmapText.prototype.$setFont = function (value) { - var self = this; - if (self.$font == value) { - return false; - } - self.$font = value; - self.$fontStringChanged = true; - this.$invalidateContentBounds(); - return true; - }; - Object.defineProperty(BitmapText.prototype, "lineSpacing", { - /** - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$lineSpacing; - }, - set: function (value) { - this.$setLineSpacing(value); - }, - enumerable: true, - configurable: true - }); - BitmapText.prototype.$setLineSpacing = function (value) { - var self = this; - if (self.$lineSpacing == value) - return false; - self.$lineSpacing = value; - self.$invalidateContentBounds(); - return true; - }; - Object.defineProperty(BitmapText.prototype, "letterSpacing", { - /** - * An integer representing the amount of distance between characters. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示字符之间的距离。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$letterSpacing; - }, - set: function (value) { - this.$setLetterSpacing(value); - }, - enumerable: true, - configurable: true - }); - BitmapText.prototype.$setLetterSpacing = function (value) { - var self = this; - if (self.$letterSpacing == value) { - return false; - } - self.$letterSpacing = value; - self.$invalidateContentBounds(); - return true; - }; - Object.defineProperty(BitmapText.prototype, "textAlign", { - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$textAlign; - }, - set: function (value) { - this.$setTextAlign(value); - }, - enumerable: true, - configurable: true - }); - BitmapText.prototype.$setTextAlign = function (value) { - var self = this; - if (self.$textAlign == value) { - return false; - } - self.$textAlign = value; - self.$invalidateContentBounds(); - return true; - }; - Object.defineProperty(BitmapText.prototype, "verticalAlign", { - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$verticalAlign; - }, - set: function (value) { - this.$setVerticalAlign(value); - }, - enumerable: true, - configurable: true - }); - BitmapText.prototype.$setVerticalAlign = function (value) { - var self = this; - if (self.$verticalAlign == value) { - return false; - } - self.$verticalAlign = value; - self.$invalidateContentBounds(); - return true; - }; - /** - * @private - */ - BitmapText.prototype.$updateRenderNode = function () { - var self = this; - var textLines = this.$getTextLines(); - var length = textLines.length; - if (length == 0) { - if (egret.nativeRender && self.$font) { - self.$nativeDisplayObject.setDataToBitmapNode(self.$nativeDisplayObject.id, self.$font.$texture, []); - self.$nativeDisplayObject.setWidth(0); - self.$nativeDisplayObject.setHeight(0); - } - return; - } - var drawArr = []; - var textLinesWidth = this.$textLinesWidth; - var bitmapFont = self.$font; - var node; - if (!egret.nativeRender) { - node = this.$renderNode; - if (bitmapFont.$texture) { - node.image = bitmapFont.$texture.$bitmapData; - } - node.smoothing = self.$smoothing; - } - var emptyHeight = bitmapFont._getFirstCharHeight(); - var emptyWidth = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR); - var hasSetHeight = !isNaN(self.$textFieldHeight); - var textWidth = self.$textWidth; - var textFieldWidth = self.$textFieldWidth; - var textFieldHeight = self.$textFieldHeight; - var align = self.$textAlign; - var yPos = this.$textOffsetY + this.$textStartY; - var lineHeights = this.$lineHeights; - for (var i = 0; i < length; i++) { - var lineHeight = lineHeights[i]; - if (hasSetHeight && i > 0 && yPos + lineHeight > textFieldHeight) { - break; - } - var line = textLines[i]; - var len = line.length; - var xPos = this.$textOffsetX; - if (align != egret.HorizontalAlign.LEFT) { - var countWidth = textFieldWidth > textWidth ? textFieldWidth : textWidth; - if (align == egret.HorizontalAlign.RIGHT) { - xPos += countWidth - textLinesWidth[i]; - } - else if (align == egret.HorizontalAlign.CENTER) { - xPos += Math.floor((countWidth - textLinesWidth[i]) / 2); - } - } - for (var j = 0; j < len; j++) { - var character = line.charAt(j); - var texture = bitmapFont.getTexture(character); - if (!texture) { - if (character == " ") { - xPos += emptyWidth; - } - else { - egret.$warn(1046, character); - } - continue; - } - var bitmapWidth = texture.$bitmapWidth; - var bitmapHeight = texture.$bitmapHeight; - if (egret.nativeRender) { - drawArr.push(texture.$bitmapX, texture.$bitmapY, bitmapWidth, bitmapHeight, xPos + texture.$offsetX, yPos + texture.$offsetY, texture.$getScaleBitmapWidth(), texture.$getScaleBitmapHeight(), texture.$sourceWidth, texture.$sourceHeight); - } - else { - node.imageWidth = texture.$sourceWidth; - node.imageHeight = texture.$sourceHeight; - node.drawImage(texture.$bitmapX, texture.$bitmapY, bitmapWidth, bitmapHeight, xPos + texture.$offsetX, yPos + texture.$offsetY, texture.$getScaleBitmapWidth(), texture.$getScaleBitmapHeight()); - } - xPos += (bitmapFont.getConfig(character, "xadvance") || texture.$getTextureWidth()) + self.$letterSpacing; - } - yPos += lineHeight + self.$lineSpacing; - } - if (egret.nativeRender) { - self.$nativeDisplayObject.setDataToBitmapNode(self.$nativeDisplayObject.id, bitmapFont.$texture, drawArr); - var bounds = self.$getContentBounds(); - self.$nativeDisplayObject.setWidth(bounds.width); - self.$nativeDisplayObject.setHeight(bounds.height); - } - }; - /** - * @private - */ - BitmapText.prototype.$measureContentBounds = function (bounds) { - var lines = this.$getTextLines(); - if (lines.length == 0) { - bounds.setEmpty(); - } - else { - bounds.setTo(this.$textOffsetX + this.$textStartX, this.$textOffsetY + this.$textStartY, this.$textWidth - this.$textOffsetX, this.$textHeight - this.$textOffsetY); - } - }; - Object.defineProperty(BitmapText.prototype, "textWidth", { - /** - * Get the BitmapText measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getTextLines(); - return this.$textWidth; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BitmapText.prototype, "textHeight", { - /** - * Get Text BitmapText height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getTextLines(); - return this.$textHeight; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - BitmapText.prototype.$getTextLines = function () { - var self = this; - if (!self.$textLinesChanged) { - return self.textLines; - } - var textLines = []; - self.textLines = textLines; - var textLinesWidth = []; - self.$textLinesWidth = textLinesWidth; - self.$textLinesChanged = false; - var lineHeights = []; - self.$lineHeights = lineHeights; - if (!self.$text || !self.$font) { - self.$textWidth = 0; - self.$textHeight = 0; - return textLines; - } - var lineSpacing = self.$lineSpacing; - var letterSpacing = self.$letterSpacing; - var textWidth = 0; - var textHeight = 0; - var textOffsetX = 0; - var textOffsetY = 0; - var hasWidthSet = !isNaN(self.$textFieldWidth); - var textFieldWidth = self.$textFieldWidth; - var textFieldHeight = self.$textFieldHeight; - var bitmapFont = self.$font; - var emptyHeight = bitmapFont._getFirstCharHeight(); - var emptyWidth = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR); - var text = self.$text; - var textArr = text.split(/(?:\r\n|\r|\n)/); - var length = textArr.length; - var isFirstLine = true; - var isFirstChar; - var isLastChar; - var lineHeight; - var xPos; - for (var i = 0; i < length; i++) { - var line = textArr[i]; - var len = line.length; - lineHeight = 0; - xPos = 0; - isFirstChar = true; - isLastChar = false; - for (var j = 0; j < len; j++) { - if (!isFirstChar) { - xPos += letterSpacing; - } - var character = line.charAt(j); - var texureWidth = void 0; - var textureHeight = void 0; - var offsetX = 0; - var offsetY = 0; - var texture = bitmapFont.getTexture(character); - if (!texture) { - if (character == " ") { - texureWidth = emptyWidth; - textureHeight = emptyHeight; - } - else { - egret.$warn(1046, character); - if (isFirstChar) { - isFirstChar = false; - } - continue; - } - } - else { - texureWidth = texture.$getTextureWidth(); - textureHeight = texture.$getTextureHeight(); - offsetX = texture.$offsetX; - offsetY = texture.$offsetY; - } - if (isFirstChar) { - isFirstChar = false; - // textOffsetX = Math.min(offsetX, textOffsetX); - } - if (isFirstLine) { - isFirstLine = false; - // textOffsetY = Math.min(offsetY, textOffsetY); - } - if (hasWidthSet && j > 0 && xPos + texureWidth > textFieldWidth) { - if (!setLineData(line.substring(0, j))) - break; - line = line.substring(j); - len = line.length; - j = 0; - //最后一个字符要计算纹理宽度,而不是xadvance - if (j == len - 1) { - xPos = texureWidth; - } - else { - xPos = bitmapFont.getConfig(character, "xadvance") || texureWidth; - } - lineHeight = textureHeight; - continue; - } - //最后一个字符要计算纹理宽度,而不是xadvance - if (j == len - 1) { - xPos += texureWidth; - } - else { - xPos += bitmapFont.getConfig(character, "xadvance") || texureWidth; - } - lineHeight = Math.max(textureHeight, lineHeight); - } - if (textFieldHeight && i > 0 && textHeight > textFieldHeight) { - break; - } - isLastChar = true; - if (!setLineData(line)) - break; - } - function setLineData(str) { - if (textFieldHeight && textLines.length > 0 && textHeight > textFieldHeight) { - return false; - } - textHeight += lineHeight + lineSpacing; - if (!isFirstChar && !isLastChar) { - xPos -= letterSpacing; - } - textLines.push(str); - lineHeights.push(lineHeight); - textLinesWidth.push(xPos); - textWidth = Math.max(xPos, textWidth); - return true; - } - textHeight -= lineSpacing; - self.$textWidth = textWidth; - self.$textHeight = textHeight; - this.$textOffsetX = textOffsetX; - this.$textOffsetY = textOffsetY; - this.$textStartX = 0; - this.$textStartY = 0; - var alignType; - if (textFieldWidth > textWidth) { - alignType = self.$textAlign; - if (alignType == egret.HorizontalAlign.RIGHT) { - this.$textStartX = textFieldWidth - textWidth; - } - else if (alignType == egret.HorizontalAlign.CENTER) { - this.$textStartX = Math.floor((textFieldWidth - textWidth) / 2); - } - } - if (textFieldHeight > textHeight) { - alignType = self.$verticalAlign; - if (alignType == egret.VerticalAlign.BOTTOM) { - this.$textStartY = textFieldHeight - textHeight; - } - else if (alignType == egret.VerticalAlign.MIDDLE) { - this.$textStartY = Math.floor((textFieldHeight - textHeight) / 2); - } - } - return textLines; - }; - /** - * A ratio of the width of the space character. This value is multiplied by the height of the first character is the space character width. - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个空格字符的宽度比例。这个数值乘以第一个字符的高度即为空格字符的宽。 - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BitmapText.EMPTY_FACTOR = 0.33; - return BitmapText; - }(egret.DisplayObject)); - egret.BitmapText = BitmapText; - __reflect(BitmapText.prototype, "egret.BitmapText"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The HorizontalAlign class defines the possible values for the horizontal alignment. - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HorizontalAlign 类为水平对齐方式定义可能的值。 - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var HorizontalAlign = (function () { - function HorizontalAlign() { - } - /** - * Horizontally align content to the left of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的左侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HorizontalAlign.LEFT = "left"; - /** - * Horizontally align content to the right of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的右侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HorizontalAlign.RIGHT = "right"; - /** - * Horizontally align content in the center of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的水平中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HorizontalAlign.CENTER = "center"; - /** - * Horizontal alignment with both edges. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 水平两端对齐。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HorizontalAlign.JUSTIFY = "justify"; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Width \" of the container \". - * The Content Width \" of the container \" is the size of the max. child item. If the size of all child items are less than the width of the container, they will be adjusted to the width of the container. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容宽度"。 - * 容器的"内容宽度"是最大子项的大小,如果所有子项都小于容器的宽度,则会将所有子项的大小调整为容器的宽度。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HorizontalAlign.CONTENT_JUSTIFY = "contentJustify"; - return HorizontalAlign; - }()); - egret.HorizontalAlign = HorizontalAlign; - __reflect(HorizontalAlign.prototype, "egret.HorizontalAlign"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language zh_CN - */ - var HtmlTextParser = (function () { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function HtmlTextParser() { - this.replaceArr = []; - /** - * @private - */ - this.resutlArr = []; - this.initReplaceArr(); - } - HtmlTextParser.prototype.initReplaceArr = function () { - this.replaceArr = []; - this.replaceArr.push([/</g, "<"]); - this.replaceArr.push([/>/g, ">"]); - this.replaceArr.push([/&/g, "&"]); - this.replaceArr.push([/"/g, "\""]); - this.replaceArr.push([/'/g, "\'"]); - }; - /** - * @private - * - * @param value - * @returns - */ - HtmlTextParser.prototype.replaceSpecial = function (value) { - for (var i = 0; i < this.replaceArr.length; i++) { - var k = this.replaceArr[i][0]; - var v = this.replaceArr[i][1]; - value = value.replace(k, v); - } - return value; - }; - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @param htmltext {string} Text in html - * @returns {Array} 可赋值给 egret.TextField#textFlow Object that can be assigned to the egret.TextField#textFlow property - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @param htmltext {string} html文本 - * @returns {Array} 可赋值给 egret.TextField#textFlow 属性的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - HtmlTextParser.prototype.parse = function (htmltext) { - this.stackArray = []; - this.resutlArr = []; - var firstIdx = 0; //文本段开始位置 - var length = htmltext.length; - while (firstIdx < length) { - var starIdx = htmltext.indexOf("<", firstIdx); - if (starIdx < 0) { - this.addToResultArr(htmltext.substring(firstIdx)); - firstIdx = length; - } - else { - this.addToResultArr(htmltext.substring(firstIdx, starIdx)); - var fontEnd = htmltext.indexOf(">", starIdx); - if (fontEnd == -1) { - egret.$error(1038); - fontEnd = starIdx; - } - else if (htmltext.charAt(starIdx + 1) == "\/") { - this.stackArray.pop(); - } - else { - this.addToArray(htmltext.substring(starIdx + 1, fontEnd)); - } - firstIdx = fontEnd + 1; - } - } - return this.resutlArr; - }; - HtmlTextParser.prototype.parser = function (htmltext) { - return this.parse(htmltext); - }; - /** - * @private - * - * @param value - */ - HtmlTextParser.prototype.addToResultArr = function (value) { - if (value == "") { - return; - } - value = this.replaceSpecial(value); - if (this.stackArray.length > 0) { - this.resutlArr.push({ text: value, style: this.stackArray[this.stackArray.length - 1] }); - } - else { - this.resutlArr.push({ text: value }); - } - }; - //将字符数据转成Json数据 - HtmlTextParser.prototype.changeStringToObject = function (str) { - str = str.trim(); - var info = {}; - var header = []; - if (str.charAt(0) == "i" || str.charAt(0) == "b" || str.charAt(0) == "u") { - this.addProperty(info, str, "true"); - } - else if (header = str.match(/^(font|a)\s/)) { - str = str.substring(header[0].length).trim(); - var next = 0; - var titles = void 0; - while (titles = str.match(this.getHeadReg())) { - var title = titles[0]; - var value = ""; - str = str.substring(title.length).trim(); - if (str.charAt(0) == "\"") { - next = str.indexOf("\"", 1); - value = str.substring(1, next); - next += 1; - } - else if (str.charAt(0) == "\'") { - next = str.indexOf("\'", 1); - value = str.substring(1, next); - next += 1; - } - else { - value = str.match(/(\S)+/)[0]; - next = value.length; - } - this.addProperty(info, title.substring(0, title.length - 1).trim(), value.trim()); - str = str.substring(next).trim(); - } - } - return info; - }; - /** - * @private - * - * @returns - */ - HtmlTextParser.prototype.getHeadReg = function () { - return /^(color|textcolor|strokecolor|stroke|b|bold|i|italic|u|size|fontfamily|href|target)(\s)*=/; - }; - /** - * @private - * - * @param info - * @param head - * @param value - */ - HtmlTextParser.prototype.addProperty = function (info, head, value) { - switch (head.toLowerCase()) { - case "color": - case "textcolor": - value = value.replace(/#/, "0x"); - info.textColor = parseInt(value); - break; - case "strokecolor": - value = value.replace(/#/, "0x"); - info.strokeColor = parseInt(value); - break; - case "stroke": - info.stroke = parseInt(value); - break; - case "b": - case "bold": - info.bold = value == "true"; - break; - case "u": - info.underline = value == "true"; - break; - case "i": - case "italic": - info.italic = value == "true"; - break; - case "size": - info.size = parseInt(value); - break; - case "fontfamily": - info.fontFamily = value; - break; - case "href": - info.href = this.replaceSpecial(value); - break; - case "target": - info.target = this.replaceSpecial(value); - break; - } - }; - /** - * @private - * - * @param infoStr - */ - HtmlTextParser.prototype.addToArray = function (infoStr) { - var info = this.changeStringToObject(infoStr); - if (this.stackArray.length == 0) { - this.stackArray.push(info); - } - else { - var lastInfo = this.stackArray[this.stackArray.length - 1]; - for (var key in lastInfo) { - if (info[key] == null) { - info[key] = lastInfo[key]; - } - } - this.stackArray.push(info); - } - }; - return HtmlTextParser; - }()); - egret.HtmlTextParser = HtmlTextParser; - __reflect(HtmlTextParser.prototype, "egret.HtmlTextParser"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - var InputController = (function (_super) { - __extends(InputController, _super); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function InputController() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.stageTextAdded = false; - /** - * @private - */ - _this._text = null; - /** - * @private - */ - _this._isFocus = false; - return _this; - } - /** - * - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - InputController.prototype.init = function (text) { - this._text = text; - this.stageText = new egret.StageText(); - this.stageText.$setTextField(this._text); - }; - /** - * @private - * - */ - InputController.prototype._addStageText = function () { - if (this.stageTextAdded) { - return; - } - if (!this._text.$inputEnabled) { - this._text.$touchEnabled = true; - } - this.tempStage = this._text.stage; - this.stageText.$addToStage(); - this.stageText.addEventListener("updateText", this.updateTextHandler, this); - this._text.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this); - this.stageText.addEventListener("blur", this.blurHandler, this); - this.stageText.addEventListener("focus", this.focusHandler, this); - this.stageTextAdded = true; - }; - /** - * @private - * - */ - InputController.prototype._removeStageText = function () { - if (!this.stageTextAdded) { - return; - } - if (!this._text.$inputEnabled) { - this._text.$touchEnabled = false; - } - this.stageText.$removeFromStage(); - this.stageText.removeEventListener("updateText", this.updateTextHandler, this); - this._text.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this); - this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); - this.stageText.removeEventListener("blur", this.blurHandler, this); - this.stageText.removeEventListener("focus", this.focusHandler, this); - this.stageTextAdded = false; - }; - /** - * @private - * - * @returns - */ - InputController.prototype._getText = function () { - return this.stageText.$getText(); - }; - /** - * @private - * - * @param value - */ - InputController.prototype._setText = function (value) { - this.stageText.$setText(value); - }; - /** - * @private - */ - InputController.prototype._setColor = function (value) { - this.stageText.$setColor(value); - }; - /** - * @private - * - * @param event - */ - InputController.prototype.focusHandler = function (event) { - //不再显示竖线,并且输入框显示最开始 - if (!this._isFocus) { - this._isFocus = true; - if (!event["showing"]) { - this._text.$setIsTyping(true); - } - this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_IN, true)); - } - }; - /** - * @private - * - * @param event - */ - InputController.prototype.blurHandler = function (event) { - if (this._isFocus) { - //不再显示竖线,并且输入框显示最开始 - this._isFocus = false; - this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); - this._text.$setIsTyping(false); - //失去焦点后调用 - this.stageText.$onBlur(); - this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_OUT, true)); - } - }; - //点中文本 - InputController.prototype.onMouseDownHandler = function (event) { - this.$onFocus(); - }; - InputController.prototype.$onFocus = function () { - var _this = this; - var self = this; - if (!this._text.visible) { - return; - } - if (this._isFocus) { - return; - } - this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); - egret.callLater(function () { - _this.tempStage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.onStageDownHandler, _this); - }, this); - if (egret.nativeRender) { - this.stageText.$setText(this._text.$TextField[13 /* text */]); - } - //强制更新输入框位置 - this.stageText.$show(); - }; - //未点中文本 - InputController.prototype.onStageDownHandler = function (event) { - if (event.$target != this._text) { - this.stageText.$hide(); - } - }; - /** - * @private - * - * @param event - */ - InputController.prototype.updateTextHandler = function (event) { - var values = this._text.$TextField; - var textValue = this.stageText.$getText(); - var isChanged = false; - var reg; - var result; - if (values[35 /* restrictAnd */] != null) { - reg = new RegExp("[" + values[35 /* restrictAnd */] + "]", "g"); - result = textValue.match(reg); - if (result) { - textValue = result.join(""); - } - else { - textValue = ""; - } - isChanged = true; - } - if (values[36 /* restrictNot */] != null) { - reg = new RegExp("[^" + values[36 /* restrictNot */] + "]", "g"); - result = textValue.match(reg); - if (result) { - textValue = result.join(""); - } - else { - textValue = ""; - } - isChanged = true; - } - if (isChanged && this.stageText.$getText() != textValue) { - this.stageText.$setText(textValue); - } - this.resetText(); - //抛出change事件 - this._text.dispatchEvent(new egret.Event(egret.Event.CHANGE, true)); - }; - /** - * @private - * - */ - InputController.prototype.resetText = function () { - this._text.$setBaseText(this.stageText.$getText()); - }; - /** - * @private - * - */ - InputController.prototype._hideInput = function () { - this.stageText.$removeFromStage(); - }; - /** - * @private - * - */ - InputController.prototype.updateInput = function () { - if (!this._text.$visible && this.stageText) { - this._hideInput(); - } - }; - /** - * @private - * - */ - InputController.prototype._updateProperties = function () { - if (this._isFocus) { - //整体修改 - this.stageText.$resetStageText(); - this.updateInput(); - return; - } - this.stageText.$setText(this._text.$TextField[13 /* text */]); - //整体修改 - this.stageText.$resetStageText(); - this.updateInput(); - }; - return InputController; - }(egret.HashObject)); - egret.InputController = InputController; - __reflect(InputController.prototype, "egret.InputController"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var SplitRegex = new RegExp("(?=[\\u00BF-\\u1FFF\\u2C00-\\uD7FF]|\\b|\\s)(?![。,!、》…))}”】\\.\\,\\!\\?\\]\\:])"); - /** - * @private - * 根据样式测量文本宽度 - */ - function measureTextWidth(text, values, style) { - style = style || {}; - var italic = style.italic == null ? values[16 /* italic */] : style.italic; - var bold = style.bold == null ? values[15 /* bold */] : style.bold; - var size = style.size == null ? values[0 /* fontSize */] : style.size; - var fontFamily = style.fontFamily || values[8 /* fontFamily */] || TextField.default_fontFamily; - return egret.sys.measureText(text, fontFamily, size, bold, italic); - } - /** - * TextField is the text rendering class of egret. It conducts rendering by using the browser / device API. Due to different ways of font rendering in different browsers / devices, there may be differences in the rendering - * If developers expect no differences among all platforms, please use BitmapText - * @see http://edn.egret.com/cn/docs/page/141 Create Text - * - * @event egret.Event.CHANGE Dispatched when entering text user input。 - * @event egret.FocusEvent.FOCUS_IN Dispatched after the focus to enter text. - * @event egret.FocusEvent.FOCUS_OUT Enter the text loses focus after dispatch. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language en_US - */ - /** - * TextField是egret的文本渲染类,采用浏览器/设备的API进行渲染,在不同的浏览器/设备中由于字体渲染方式不一,可能会有渲染差异 - * 如果开发者希望所有平台完全无差异,请使用BitmapText - * @see http://edn.egret.com/cn/docs/page/141 创建文本 - * - * @event egret.Event.CHANGE 输入文本有用户输入时调度。 - * @event egret.FocusEvent.FOCUS_IN 聚焦输入文本后调度。 - * @event egret.FocusEvent.FOCUS_OUT 输入文本失去焦点后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language zh_CN - */ - var TextField = (function (_super) { - __extends(TextField, _super); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function TextField() { - var _this = _super.call(this) || this; - _this.$inputEnabled = false; - _this.inputUtils = null; - /** - * @private - */ - _this.$graphicsNode = null; - /** - * @private - */ - _this.isFlow = false; - /** - * @private - */ - _this.textArr = []; - /** - * @private - */ - _this.linesArr = []; - /** - * @private - */ - _this.$isTyping = false; - var textNode = new egret.sys.TextNode(); - textNode.fontFamily = TextField.default_fontFamily; - _this.textNode = textNode; - _this.$renderNode = textNode; - _this.$TextField = { - 0: TextField.default_size, - 1: 0, - 2: TextField.default_textColor, - 3: NaN, - 4: NaN, - 5: 0, - 6: 0, - 7: 0, - 8: TextField.default_fontFamily, - 9: "left", - 10: "top", - 11: "#ffffff", - 12: "", - 13: "", - 14: [], - 15: false, - 16: false, - 17: true, - 18: false, - 19: false, - 20: false, - 21: 0, - 22: 0, - 23: 0, - 24: egret.TextFieldType.DYNAMIC, - 25: 0x000000, - 26: "#000000", - 27: 0, - 28: -1, - 29: 0, - 30: false, - 31: false, - 32: 0x000000, - 33: false, - 34: 0xffffff, - 35: null, - 36: null, - 37: egret.TextFieldInputType.TEXT, - 38: false //textLinesChangedForNativeRender - }; - return _this; - } - TextField.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(7 /* TEXT */); - }; - /** - * @private - */ - TextField.prototype.isInput = function () { - return this.$TextField[24 /* type */] == egret.TextFieldType.INPUT; - }; - TextField.prototype.$setTouchEnabled = function (value) { - _super.prototype.$setTouchEnabled.call(this, value); - if (this.isInput()) { - this.$inputEnabled = true; - } - }; - Object.defineProperty(TextField.prototype, "fontFamily", { - /** - * The name of the font to use, or a comma-separated list of font names. - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表。 - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[8 /* fontFamily */]; - }, - set: function (value) { - this.$setFontFamily(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setFontFamily = function (value) { - var values = this.$TextField; - if (values[8 /* fontFamily */] == value) { - return false; - } - values[8 /* fontFamily */] = value; - this.invalidateFontString(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setFontFamily(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "size", { - /** - * The size in pixels of text - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的字号大小。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[0 /* fontSize */]; - }, - set: function (value) { - this.$setSize(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setSize = function (value) { - var values = this.$TextField; - if (values[0 /* fontSize */] == value) { - return false; - } - values[0 /* fontSize */] = value; - this.invalidateFontString(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setFontSize(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "bold", { - /** - * Specifies whether the text is boldface. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为粗体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[15 /* bold */]; - }, - set: function (value) { - this.$setBold(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setBold = function (value) { - var values = this.$TextField; - if (value == values[15 /* bold */]) { - return false; - } - values[15 /* bold */] = value; - this.invalidateFontString(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setBold(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "italic", { - /** - * Determines whether the text is italic font. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为斜体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[16 /* italic */]; - }, - set: function (value) { - this.$setItalic(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setItalic = function (value) { - var values = this.$TextField; - if (value == values[16 /* italic */]) { - return false; - } - values[16 /* italic */] = value; - this.invalidateFontString(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setItalic(value); - } - return true; - }; - /** - * @private - * - */ - TextField.prototype.invalidateFontString = function () { - this.$TextField[17 /* fontStringChanged */] = true; - this.$invalidateTextField(); - }; - Object.defineProperty(TextField.prototype, "textAlign", { - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[9 /* textAlign */]; - }, - set: function (value) { - this.$setTextAlign(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setTextAlign = function (value) { - var values = this.$TextField; - if (values[9 /* textAlign */] == value) { - return false; - } - values[9 /* textAlign */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setTextAlign(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "verticalAlign", { - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[10 /* verticalAlign */]; - }, - set: function (value) { - this.$setVerticalAlign(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setVerticalAlign = function (value) { - var values = this.$TextField; - if (values[10 /* verticalAlign */] == value) { - return false; - } - values[10 /* verticalAlign */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setVerticalAlign(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "lineSpacing", { - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[1 /* lineSpacing */]; - }, - set: function (value) { - this.$setLineSpacing(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setLineSpacing = function (value) { - var values = this.$TextField; - if (values[1 /* lineSpacing */] == value) { - return false; - } - values[1 /* lineSpacing */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setLineSpacing(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "textColor", { - /** - * Color of the text. - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本颜色 - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[2 /* textColor */]; - }, - set: function (value) { - this.$setTextColor(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setTextColor = function (value) { - var values = this.$TextField; - if (values[2 /* textColor */] == value) { - return false; - } - values[2 /* textColor */] = value; - if (this.inputUtils) { - this.inputUtils._setColor(this.$TextField[2 /* textColor */]); - } - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setTextColor(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "wordWrap", { - /** - * A Boolean value that indicates whether the text field word wrap. If the value is true, then the text field by word wrap; - * if the value is false, the text field by newline characters. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个布尔值,表示文本字段是否按单词换行。如果值为 true,则该文本字段按单词换行; - * 如果值为 false,则该文本字段按字符换行。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$TextField[19 /* wordWrap */]; - }, - set: function (value) { - this.$setWordWrap(value); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.$setWordWrap = function (value) { - var values = this.$TextField; - if (value == values[19 /* wordWrap */]) { - return; - } - if (values[20 /* displayAsPassword */]) { - return; - } - values[19 /* wordWrap */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setWordWrap(value); - } - }; - Object.defineProperty(TextField.prototype, "type", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[24 /* type */]; - }, - /** - * Type of the text field. - * Any one of the following TextFieldType constants: TextFieldType.DYNAMIC (specifies the dynamic text field that users can not edit), or TextFieldType.INPUT (specifies the dynamic text field that users can edit). - * @default egret.TextFieldType.DYNAMIC - * @language en_US - */ - /** - * 文本字段的类型。 - * 以下 TextFieldType 常量中的任一个:TextFieldType.DYNAMIC(指定用户无法编辑的动态文本字段),或 TextFieldType.INPUT(指定用户可以编辑的输入文本字段)。 - * @default egret.TextFieldType.DYNAMIC - * @language zh_CN - */ - set: function (value) { - this.$setType(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setType = function (value) { - var values = this.$TextField; - if (values[24 /* type */] != value) { - values[24 /* type */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setType(value); - } - if (value == egret.TextFieldType.INPUT) { - if (isNaN(values[3 /* textFieldWidth */])) { - this.$setWidth(100); - } - if (isNaN(values[4 /* textFieldHeight */])) { - this.$setHeight(30); - } - this.$setTouchEnabled(true); - //创建stageText - if (this.inputUtils == null) { - this.inputUtils = new egret.InputController(); - } - this.inputUtils.init(this); - this.$invalidateTextField(); - if (this.$stage) { - this.inputUtils._addStageText(); - } - } - else { - if (this.inputUtils) { - this.inputUtils._removeStageText(); - this.inputUtils = null; - } - this.$setTouchEnabled(false); - } - return true; - } - return false; - }; - Object.defineProperty(TextField.prototype, "inputType", { - /** - * @version Egret 3.1.2 - * @platform Web,Native - */ - get: function () { - return this.$TextField[37 /* inputType */]; - }, - /** - * Pop-up keyboard type. - * Any of a TextFieldInputType constants. - * @language en_US - */ - /** - * 弹出键盘的类型。 - * TextFieldInputType 常量中的任一个。 - * @language zh_CN - */ - set: function (value) { - if (this.$TextField[37 /* inputType */] == value) { - return; - } - this.$TextField[37 /* inputType */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setInputType(value); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "text", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$getText(); - }, - /** - * Serve as a string of the current text field in the text - * @language en_US - */ - /** - * 作为文本字段中当前文本的字符串 - * @language zh_CN - */ - set: function (value) { - this.$setText(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - TextField.prototype.$getText = function () { - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - return this.inputUtils._getText(); - } - return this.$TextField[13 /* text */]; - }; - /** - * @private - * - * @param value - */ - TextField.prototype.$setBaseText = function (value) { - if (value == null) { - value = ""; - } - else { - value = value.toString(); - } - this.isFlow = false; - var values = this.$TextField; - if (values[13 /* text */] != value) { - this.$invalidateTextField(); - values[13 /* text */] = value; - var text = ""; - if (values[20 /* displayAsPassword */]) { - text = this.changeToPassText(value); - } - else { - text = value; - } - if (egret.nativeRender) { - this.$nativeDisplayObject.setText(text); - } - this.setMiddleStyle([{ text: text }]); - return true; - } - return false; - }; - /** - * @private - * - * @param value - */ - TextField.prototype.$setText = function (value) { - if (value == null) { - value = ""; - } - var result = this.$setBaseText(value); - if (this.inputUtils) { - this.inputUtils._setText(this.$TextField[13 /* text */]); - } - return result; - }; - Object.defineProperty(TextField.prototype, "displayAsPassword", { - /** - * Specify whether the text field is a password text field. - * If the value of this property is true, the text field is treated as a password text field and hides the input characters using asterisks instead of the actual characters. If false, the text field is not treated as a password text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否是密码文本字段。 - * 如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。 - * @default false - * @language zh_CN - */ - get: function () { - return this.$TextField[20 /* displayAsPassword */]; - }, - set: function (value) { - this.$setDisplayAsPassword(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setDisplayAsPassword = function (value) { - var values = this.$TextField; - if (values[20 /* displayAsPassword */] != value) { - values[20 /* displayAsPassword */] = value; - this.$invalidateTextField(); - var text = ""; - if (value) { - text = this.changeToPassText(values[13 /* text */]); - } - else { - text = values[13 /* text */]; - } - if (egret.nativeRender) { - this.$nativeDisplayObject.setText(text); - } - this.setMiddleStyle([{ text: text }]); - return true; - } - return false; - }; - Object.defineProperty(TextField.prototype, "strokeColor", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[25 /* strokeColor */]; - }, - /** - * Represent the stroke color of the text. - * Contain three 8-bit numbers with RGB color components; for example, 0xFF0000 is red, 0x00FF00 is green. - * @default 0x000000 - * @language en_US - */ - /** - * 表示文本的描边颜色。 - * 包含三个 8 位 RGB 颜色成分的数字;例如,0xFF0000 为红色,0x00FF00 为绿色。 - * @default 0x000000 - * @language zh_CN - */ - set: function (value) { - this.$setStrokeColor(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setStrokeColor = function (value) { - var values = this.$TextField; - if (values[25 /* strokeColor */] != value) { - this.$invalidateTextField(); - values[25 /* strokeColor */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setStrokeColor(value); - } - values[26 /* strokeColorString */] = egret.toColorString(value); - return true; - } - return false; - }; - Object.defineProperty(TextField.prototype, "stroke", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[27 /* stroke */]; - }, - /** - * Indicate the stroke width. - * 0 means no stroke. - * @default 0 - * @language en_US - */ - /** - * 表示描边宽度。 - * 0为没有描边。 - * @default 0 - * @language zh_CN - */ - set: function (value) { - this.$setStroke(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setStroke = function (value) { - if (this.$TextField[27 /* stroke */] != value) { - this.$invalidateTextField(); - this.$TextField[27 /* stroke */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setStroke(value); - } - return true; - } - return false; - }; - Object.defineProperty(TextField.prototype, "maxChars", { - /** - * The maximum number of characters that the text field can contain, as entered by a user. \n A script can insert more text than maxChars allows; the maxChars property indicates only how much text a user can enter. If the value of this property is 0, a user can enter an unlimited amount of text. - * The default value is 0. - * @default 0 - * @language en_US - */ - /** - * 文本字段中最多可包含的字符数(即用户输入的字符数)。 - * 脚本可以插入比 maxChars 允许的字符数更多的文本;maxChars 属性仅表示用户可以输入多少文本。如果此属性的值为 0,则用户可以输入无限数量的文本。 - * @default 0 - * @language zh_CN - */ - get: function () { - return this.$TextField[21 /* maxChars */]; - }, - set: function (value) { - this.$setMaxChars(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setMaxChars = function (value) { - if (this.$TextField[21 /* maxChars */] != value) { - this.$TextField[21 /* maxChars */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setMaxChars(value); - } - return true; - } - return false; - }; - Object.defineProperty(TextField.prototype, "scrollV", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return Math.min(Math.max(this.$TextField[28 /* scrollV */], 1), this.maxScrollV); - }, - /** - * Vertical position of text in a text field. scrollV property helps users locate specific passages in a long article, and create scrolling text fields. - * Vertically scrolling units are lines, and horizontal scrolling unit is pixels. - * If the first displayed line is the first line in the text field, scrollV is set to 1 (instead of 0). - * @language en_US - */ - /** - * 文本在文本字段中的垂直位置。scrollV 属性可帮助用户定位到长篇文章的特定段落,还可用于创建滚动文本字段。 - * 垂直滚动的单位是行,而水平滚动的单位是像素。 - * 如果显示的第一行是文本字段中的第一行,则 scrollV 设置为 1(而非 0)。 - * @language zh_CN - */ - set: function (value) { - value = Math.max(value, 1); - if (value == this.$TextField[28 /* scrollV */]) { - return; - } - this.$TextField[28 /* scrollV */] = value; - if (egret.nativeRender) { - this.$nativeDisplayObject.setScrollV(value); - } - this.$invalidateTextField(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "maxScrollV", { - /** - * The maximum value of scrollV - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * scrollV 的最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getLinesArr(); - return Math.max(this.$TextField[29 /* numLines */] - egret.TextFieldUtils.$getScrollNum(this) + 1, 1); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "selectionBeginIndex", { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "selectionEndIndex", { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "caretIndex", { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param beginIndex - * @param endIndex - */ - TextField.prototype.$setSelection = function (beginIndex, endIndex) { - return false; - }; - /** - * @private - * - * @returns - */ - TextField.prototype.$getLineHeight = function () { - return this.$TextField[1 /* lineSpacing */] + this.$TextField[0 /* fontSize */]; - }; - Object.defineProperty(TextField.prototype, "numLines", { - /** - * Number of lines of text. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本行数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getLinesArr(); - return this.$TextField[29 /* numLines */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "multiline", { - get: function () { - return this.$TextField[30 /* multiline */]; - }, - /** - * Indicate whether field is a multiline text field. Note that this property is valid only when the type is TextFieldType.INPUT. - * If the value is true, the text field is multiline; if the value is false, the text field is a single-line text field. In a field of type TextFieldType.INPUT, the multiline value determines whether the Enter key creates a new line (a value of false, and the Enter key is ignored). - * @default false - * @language en_US - */ - /** - * 表示字段是否为多行文本字段。注意,此属性仅在type为TextFieldType.INPUT时才有效。 - * 如果值为 true,则文本字段为多行文本字段;如果值为 false,则文本字段为单行文本字段。在类型为 TextFieldType.INPUT 的字段中,multiline 值将确定 Enter 键是否创建新行(如果值为 false,则将忽略 Enter 键)。 - * @default false - * @language zh_CN - */ - set: function (value) { - this.$setMultiline(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setMultiline = function (value) { - if (this.$TextField[30 /* multiline */] == value) { - return false; - } - this.$TextField[30 /* multiline */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setMultiline(value); - } - return true; - }; - Object.defineProperty(TextField.prototype, "restrict", { - get: function () { - var values = this.$TextField; - var str = null; - if (values[35 /* restrictAnd */] != null) { - str = values[35 /* restrictAnd */]; - } - if (values[36 /* restrictNot */] != null) { - if (str == null) { - str = ""; - } - str += "^" + values[36 /* restrictNot */]; - } - return str; - }, - /** - * Indicates a user can enter into the text field character set. If you restrict property is null, you can enter any character. If you restrict property is an empty string, you can not enter any character. If you restrict property is a string of characters, you can enter only characters in the string in the text field. The string is scanned from left to right. You can use a hyphen (-) to specify a range. Only restricts user interaction; a script may put any text into the text field.
    - * If the string of characters caret (^) at the beginning, all characters are initially accepted, then the string are excluded from receiving ^ character. If the string does not begin with a caret (^) to, any characters are initially accepted and then a string of characters included in the set of accepted characters.
    - * The following example allows only uppercase characters, spaces, and numbers in the text field:
    - * My_txt.restrict = "A-Z 0-9";
    - * The following example includes all characters except lowercase letters:
    - * My_txt.restrict = "^ a-z";
    - * If you need to enter characters \ ^, use two backslash "\\ -" "\\ ^":
    - * Can be used anywhere in the string ^ to rule out including characters and switch between characters, but can only be used to exclude a ^. The following code includes only uppercase letters except uppercase Q:
    - * My_txt.restrict = "A-Z ^ Q";
    - * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language en_US - */ - /** - * 表示用户可输入到文本字段中的字符集。如果 restrict 属性的值为 null,则可以输入任何字符。如果 restrict 属性的值为空字符串,则不能输入任何字符。如果 restrict 属性的值为一串字符,则只能在文本字段中输入该字符串中的字符。从左向右扫描该字符串。可以使用连字符 (-) 指定一个范围。只限制用户交互;脚本可将任何文本放入文本字段中。
    - * 如果字符串以尖号 (^) 开头,则先接受所有字符,然后从接受字符集中排除字符串中 ^ 之后的字符。如果字符串不以尖号 (^) 开头,则最初不接受任何字符,然后将字符串中的字符包括在接受字符集中。
    - * 下例仅允许在文本字段中输入大写字符、空格和数字:
    - * my_txt.restrict = "A-Z 0-9";
    - * 下例包含除小写字母之外的所有字符:
    - * my_txt.restrict = "^a-z";
    - * 如果需要输入字符 \ ^,请使用2个反斜杠 "\\-" "\\^" :
    - * 可在字符串中的任何位置使用 ^,以在包含字符与排除字符之间进行切换,但是最多只能有一个 ^ 用来排除。下面的代码只包含除大写字母 Q 之外的大写字母:
    - * my_txt.restrict = "A-Z^Q";
    - * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language zh_CN - */ - set: function (value) { - var values = this.$TextField; - if (value == null) { - values[35 /* restrictAnd */] = null; - values[36 /* restrictNot */] = null; - } - else { - var index = -1; - while (index < value.length) { - index = value.indexOf("^", index); - if (index == 0) { - break; - } - else if (index > 0) { - if (value.charAt(index - 1) != "\\") { - break; - } - index++; - } - else { - break; - } - } - if (index == 0) { - values[35 /* restrictAnd */] = null; - values[36 /* restrictNot */] = value.substring(index + 1); - } - else if (index > 0) { - values[35 /* restrictAnd */] = value.substring(0, index); - values[36 /* restrictNot */] = value.substring(index + 1); - } - else { - values[35 /* restrictAnd */] = value; - values[36 /* restrictNot */] = null; - } - } - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - TextField.prototype.$setWidth = function (value) { - if (egret.nativeRender) { - this.$nativeDisplayObject.setTextFieldWidth(value); - } - var values = this.$TextField; - if (isNaN(value)) { - if (isNaN(values[3 /* textFieldWidth */])) { - return false; - } - values[3 /* textFieldWidth */] = NaN; - } - else { - if (values[3 /* textFieldWidth */] == value) { - return false; - } - values[3 /* textFieldWidth */] = value; - } - value = +value; - if (value < 0) { - return false; - } - this.$invalidateTextField(); - return true; - }; - /** - * @private - * - * @param value - */ - TextField.prototype.$setHeight = function (value) { - if (egret.nativeRender) { - this.$nativeDisplayObject.setTextFieldHeight(value); - } - var values = this.$TextField; - if (isNaN(value)) { - if (isNaN(values[4 /* textFieldHeight */])) { - return false; - } - values[4 /* textFieldHeight */] = NaN; - } - else { - if (values[4 /* textFieldHeight */] == value) { - return false; - } - values[4 /* textFieldHeight */] = value; - } - value = +value; - if (value < 0) { - return false; - } - this.$invalidateTextField(); - return true; - }; - /** - * @private - * 获取显示宽度 - */ - TextField.prototype.$getWidth = function () { - var values = this.$TextField; - return isNaN(values[3 /* textFieldWidth */]) ? this.$getContentBounds().width : values[3 /* textFieldWidth */]; - }; - /** - * @private - * 获取显示宽度 - */ - TextField.prototype.$getHeight = function () { - var values = this.$TextField; - return isNaN(values[4 /* textFieldHeight */]) ? this.$getContentBounds().height : values[4 /* textFieldHeight */]; - }; - Object.defineProperty(TextField.prototype, "border", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[31 /* border */]; - }, - /** - * Specifies whether the text field has a border. - * If true, the text field has a border. If false, the text field has no border. - * Use borderColor property to set the border color. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有边框。 - * 如果为 true,则文本字段具有边框。如果为 false,则文本字段没有边框。 - * 使用 borderColor 属性来设置边框颜色。 - * @default false - * @language zh_CN - */ - set: function (value) { - this.$setBorder(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - TextField.prototype.$setBorder = function (value) { - value = !!value; - if (this.$TextField[31 /* border */] == value) { - return; - } - this.$TextField[31 /* border */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setBorder(value); - } - }; - Object.defineProperty(TextField.prototype, "borderColor", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[32 /* borderColor */]; - }, - /** - * The color of the text field border. - * Even currently is no border can be retrieved or set this property, but only if the text field has the border property is set to true, the color is visible. - * @default 0x000000 - * @language en_US - */ - /** - * 文本字段边框的颜色。 - * 即使当前没有边框,也可检索或设置此属性,但只有当文本字段已将 border 属性设置为 true 时,才可以看到颜色。 - * @default 0x000000 - * @language zh_CN - */ - set: function (value) { - this.$setBorderColor(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - TextField.prototype.$setBorderColor = function (value) { - value = +value || 0; - if (this.$TextField[32 /* borderColor */] == value) { - return; - } - this.$TextField[32 /* borderColor */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setBorderColor(value); - } - }; - Object.defineProperty(TextField.prototype, "background", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[33 /* background */]; - }, - /** - * Specifies whether the text field has a background fill. - * If true, the text field has a background fill. If false, the text field has no background fill. - * Use the backgroundColor property to set the background color of the text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有背景填充。 - * 如果为 true,则文本字段具有背景填充。如果为 false,则文本字段没有背景填充。 - * 使用 backgroundColor 属性来设置文本字段的背景颜色。 - * @default false - * @language zh_CN - */ - set: function (value) { - this.$setBackground(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - TextField.prototype.$setBackground = function (value) { - if (this.$TextField[33 /* background */] == value) { - return; - } - this.$TextField[33 /* background */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setBackground(value); - } - }; - Object.defineProperty(TextField.prototype, "backgroundColor", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$TextField[34 /* backgroundColor */]; - }, - /** - * Color of the text field background. - * Even currently is no background, can be retrieved or set this property, but only if the text field has the background property set to true, the color is visible. - * @default 0xFFFFFF - * @language en_US - */ - /** - * 文本字段背景的颜色。 - * 即使当前没有背景,也可检索或设置此属性,但只有当文本字段已将 background 属性设置为 true 时,才可以看到颜色。 - * @default 0xFFFFFF - * @language zh_CN - */ - set: function (value) { - this.$setBackgroundColor(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - TextField.prototype.$setBackgroundColor = function (value) { - if (this.$TextField[34 /* backgroundColor */] == value) { - return; - } - this.$TextField[34 /* backgroundColor */] = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setBackgroundColor(value); - } - }; - /** - * @private - * - */ - TextField.prototype.fillBackground = function (lines) { - var graphics = this.$graphicsNode; - if (graphics) { - graphics.clear(); - } - var values = this.$TextField; - if (values[33 /* background */] || values[31 /* border */] || (lines && lines.length > 0)) { - if (!graphics) { - graphics = this.$graphicsNode = new egret.sys.GraphicsNode(); - if (!egret.nativeRender) { - var groupNode = new egret.sys.GroupNode(); - groupNode.addNode(graphics); - groupNode.addNode(this.textNode); - this.$renderNode = groupNode; - } - else { - this.$renderNode = this.textNode; - } - } - var fillPath = void 0; - var strokePath = void 0; - //渲染背景 - if (values[33 /* background */]) { - fillPath = graphics.beginFill(values[34 /* backgroundColor */]); - fillPath.drawRect(0, 0, this.$getWidth(), this.$getHeight()); - } - //渲染边框 - if (values[31 /* border */]) { - strokePath = graphics.lineStyle(1, values[32 /* borderColor */]); - //1像素和3像素线条宽度的情况,会向右下角偏移0.5像素绘制。少画一像素宽度,正好能不超出文本测量边界。 - strokePath.drawRect(0, 0, this.$getWidth() - 1, this.$getHeight() - 1); - } - //渲染下划线 - if (lines && lines.length > 0) { - var textColor = values[2 /* textColor */]; - var lastColor = -1; - var length_7 = lines.length; - for (var i = 0; i < length_7; i += 4) { - var x = lines[i]; - var y = lines[i + 1]; - var w = lines[i + 2]; - var color = lines[i + 3] || textColor; - if (lastColor < 0 || lastColor != color) { - lastColor = color; - strokePath = graphics.lineStyle(2, color, 1, egret.CapsStyle.NONE); - } - strokePath.moveTo(x, y); - strokePath.lineTo(x + w, y); - } - } - } - if (graphics) { - var bounds = this.$getRenderBounds(); - graphics.x = bounds.x; - graphics.y = bounds.y; - graphics.width = bounds.width; - graphics.height = bounds.height; - egret.Rectangle.release(bounds); - } - }; - /** - * Enter the text automatically entered into the input state, the input type is text only and may only be invoked in the user interaction. - * @version Egret 3.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 输入文本自动进入到输入状态,仅在类型是输入文本并且是在用户交互下才可以调用。 - * @version Egret 3.0.8 - * @platform Web,Native - * @language zh_CN - */ - TextField.prototype.setFocus = function () { - if (this.type == egret.TextFieldType.INPUT && this.$stage) { - this.inputUtils.$onFocus(); - } - }; - /** - * @private - * - */ - TextField.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - this.removeEvent(); - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - this.inputUtils._removeStageText(); - } - if (this.textNode) { - this.textNode.clean(); - if (egret.nativeRender) { - egret_native.NativeDisplayObject.disposeTextData(this); - } - } - }; - /** - * @private - * - * @param stage - * @param nestLevel - */ - TextField.prototype.$onAddToStage = function (stage, nestLevel) { - _super.prototype.$onAddToStage.call(this, stage, nestLevel); - this.addEvent(); - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - this.inputUtils._addStageText(); - } - }; - TextField.prototype.$invalidateTextField = function () { - var self = this; - self.$renderDirty = true; - self.$TextField[18 /* textLinesChanged */] = true; - self.$TextField[38 /* textLinesChangedForNativeRender */] = true; - if (egret.nativeRender) { - // egret_native.dirtyTextField(this); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - TextField.prototype.$getRenderBounds = function () { - var bounds = this.$getContentBounds(); - var tmpBounds = egret.Rectangle.create(); - tmpBounds.copyFrom(bounds); - if (this.$TextField[31 /* border */]) { - tmpBounds.width += 2; - tmpBounds.height += 2; - } - var _strokeDouble = this.$TextField[27 /* stroke */] * 2; - if (_strokeDouble > 0) { - tmpBounds.width += _strokeDouble * 2; - tmpBounds.height += _strokeDouble * 2; - } - tmpBounds.x -= _strokeDouble + 2; //+2和+4 是为了webgl纹理太小导致裁切问题 - tmpBounds.y -= _strokeDouble + 2; - tmpBounds.width = Math.ceil(tmpBounds.width) + 4; - tmpBounds.height = Math.ceil(tmpBounds.height) + 4; - return tmpBounds; - }; - /** - * @private - */ - TextField.prototype.$measureContentBounds = function (bounds) { - this.$getLinesArr(); - var w = 0; - var h = 0; - if (egret.nativeRender) { - w = egret_native.nrGetTextFieldWidth(this.$nativeDisplayObject.id); - h = egret_native.nrGetTextFieldHeight(this.$nativeDisplayObject.id); - } - else { - w = !isNaN(this.$TextField[3 /* textFieldWidth */]) ? this.$TextField[3 /* textFieldWidth */] : this.$TextField[5 /* textWidth */]; - h = !isNaN(this.$TextField[4 /* textFieldHeight */]) ? this.$TextField[4 /* textFieldHeight */] : egret.TextFieldUtils.$getTextHeight(this); - } - bounds.setTo(0, 0, w, h); - }; - TextField.prototype.$updateRenderNode = function () { - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - this.inputUtils._updateProperties(); - if (this.$isTyping) { - this.fillBackground(); - return; - } - } - else if (this.$TextField[3 /* textFieldWidth */] == 0) { - var graphics = this.$graphicsNode; - if (graphics) { - graphics.clear(); - } - return; - } - var underLines = this.drawText(); - this.fillBackground(underLines); - //tudo 宽高很小的情况下webgl模式绘制异常 - var bounds = this.$getRenderBounds(); - var node = this.textNode; - node.x = bounds.x; - node.y = bounds.y; - node.width = Math.ceil(bounds.width); - node.height = Math.ceil(bounds.height); - egret.Rectangle.release(bounds); - }; - Object.defineProperty(TextField.prototype, "textFlow", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.textArr; - }, - /** - * Set rich text - * @language en_US - */ - /** - * 设置富文本 - * @see http://edn.egret.com/cn/index.php/article/index/id/146 - * @language zh_CN - */ - set: function (textArr) { - this.isFlow = true; - var text = ""; - if (textArr == null) - textArr = []; - for (var i = 0; i < textArr.length; i++) { - var element = textArr[i]; - text += element.text; - } - if (this.$TextField[20 /* displayAsPassword */]) { - this.$setBaseText(text); - } - else { - this.$TextField[13 /* text */] = text; - this.setMiddleStyle(textArr); - if (egret.nativeRender) { - this.$nativeDisplayObject.setTextFlow(textArr); - } - } - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param text - * @returns - */ - TextField.prototype.changeToPassText = function (text) { - if (this.$TextField[20 /* displayAsPassword */]) { - var passText = ""; - for (var i = 0, num = text.length; i < num; i++) { - switch (text.charAt(i)) { - case '\n': - passText += "\n"; - break; - case '\r': - break; - default: - passText += '*'; - } - } - return passText; - } - return text; - }; - /** - * @private - * - * @param textArr - */ - TextField.prototype.setMiddleStyle = function (textArr) { - this.$TextField[18 /* textLinesChanged */] = true; - this.$TextField[38 /* textLinesChangedForNativeRender */] = true; - this.textArr = textArr; - this.$invalidateTextField(); - }; - Object.defineProperty(TextField.prototype, "textWidth", { - /** - * Get the text measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getLinesArr(); - if (egret.nativeRender) { - return egret_native.nrGetTextWidth(this.$nativeDisplayObject.id); - } - return this.$TextField[5 /* textWidth */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "textHeight", { - /** - * Get Text measuring height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - this.$getLinesArr(); - if (egret.nativeRender) { - return egret_native.nrGetTextHeight(this.$nativeDisplayObject.id); - } - return egret.TextFieldUtils.$getTextHeight(this); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - TextField.prototype.appendText = function (text) { - this.appendElement({ text: text }); - }; - /** - * @private - * @param element - * @version Egret 2.4 - * @platform Web,Native - */ - TextField.prototype.appendElement = function (element) { - var text = this.$TextField[13 /* text */] + element.text; - if (egret.nativeRender) { - this.textArr.push(element); - this.$TextField[13 /* text */] = text; - this.$TextField[18 /* textLinesChanged */] = true; - this.$TextField[38 /* textLinesChangedForNativeRender */] = true; - this.$nativeDisplayObject.setTextFlow(this.textArr); - return; - } - if (this.$TextField[20 /* displayAsPassword */]) { - this.$setBaseText(text); - } - else { - this.$TextField[13 /* text */] = text; - this.textArr.push(element); - this.setMiddleStyle(this.textArr); - } - }; - TextField.prototype.$getLinesArr = function () { - var values = this.$TextField; - if (egret.nativeRender && values[38 /* textLinesChangedForNativeRender */]) { - egret_native.updateNativeRender(); - values[38 /* textLinesChangedForNativeRender */] = false; - return; - } - else { - return this.$getLinesArr2(); - } - }; - /** - * @private - * - * @returns - */ - TextField.prototype.$getLinesArr2 = function () { - var values = this.$TextField; - if (!values[18 /* textLinesChanged */]) { - return this.linesArr; - } - values[18 /* textLinesChanged */] = false; - var text2Arr = this.textArr; - this.linesArr.length = 0; - values[6 /* textHeight */] = 0; - values[5 /* textWidth */] = 0; - var textFieldWidth = values[3 /* textFieldWidth */]; - //宽度被设置为0 - if (!isNaN(textFieldWidth) && textFieldWidth == 0) { - values[29 /* numLines */] = 0; - return [{ width: 0, height: 0, charNum: 0, elements: [], hasNextLine: false }]; - } - var linesArr = this.linesArr; - var lineW = 0; - var lineCharNum = 0; - var lineH = 0; - var lineCount = 0; - var lineElement; - for (var i = 0, text2ArrLength = text2Arr.length; i < text2ArrLength; i++) { - var element = text2Arr[i]; - //可能设置为没有文本,忽略绘制 - if (!element.text) { - if (lineElement) { - lineElement.width = lineW; - lineElement.height = lineH; - lineElement.charNum = lineCharNum; - values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW); - values[6 /* textHeight */] += lineH; - } - continue; - } - element.style = element.style || {}; - var text = element.text.toString(); - var textArr = text.split(/(?:\r\n|\r|\n)/); - for (var j = 0, textArrLength = textArr.length; j < textArrLength; j++) { - if (linesArr[lineCount] == null) { - lineElement = { width: 0, height: 0, elements: [], charNum: 0, hasNextLine: false }; - linesArr[lineCount] = lineElement; - lineW = 0; - lineH = 0; - lineCharNum = 0; - } - if (values[24 /* type */] == egret.TextFieldType.INPUT) { - lineH = values[0 /* fontSize */]; - } - else { - lineH = Math.max(lineH, element.style.size || values[0 /* fontSize */]); - } - var isNextLine = true; - if (textArr[j] == "") { - if (j == textArrLength - 1) { - isNextLine = false; - } - } - else { - var w = measureTextWidth(textArr[j], values, element.style); - if (isNaN(textFieldWidth)) { - lineW += w; - lineCharNum += textArr[j].length; - lineElement.elements.push({ - width: w, - text: textArr[j], - style: element.style - }); - if (j == textArrLength - 1) { - isNextLine = false; - } - } - else { - if (lineW + w <= textFieldWidth) { - lineElement.elements.push({ - width: w, - text: textArr[j], - style: element.style - }); - lineW += w; - lineCharNum += textArr[j].length; - if (j == textArrLength - 1) { - isNextLine = false; - } - } - else { - var k = 0; - var ww = 0; - var word = textArr[j]; - var words = void 0; - if (values[19 /* wordWrap */]) { - words = word.split(SplitRegex); - } - else { - words = word.match(/./g); - } - var wl = words.length; - var charNum = 0; - for (; k < wl; k++) { - // detect 4 bytes unicode, refer https://mths.be/punycode - var codeLen = words[k].length; - var has4BytesUnicode = false; - if (codeLen == 1 && k < wl - 1) { - var charCodeHigh = words[k].charCodeAt(0); - var charCodeLow = words[k + 1].charCodeAt(0); - if (charCodeHigh >= 0xD800 && charCodeHigh <= 0xDBFF && (charCodeLow & 0xFC00) == 0xDC00) { - var realWord = words[k] + words[k + 1]; - codeLen = 2; - has4BytesUnicode = true; - w = measureTextWidth(realWord, values, element.style); - } - else { - w = measureTextWidth(words[k], values, element.style); - } - } - else { - w = measureTextWidth(words[k], values, element.style); - } - // w = measureTextWidth(words[k], values, element.style); - if (lineW != 0 && lineW + w > textFieldWidth && lineW + k != 0) { - break; - } - if (ww + w > textFieldWidth) { - var words2 = words[k].match(/./g); - for (var k2 = 0, wl2 = words2.length; k2 < wl2; k2++) { - // detect 4 bytes unicode, refer https://mths.be/punycode - var codeLen = words2[k2].length; - var has4BytesUnicode2 = false; - if (codeLen == 1 && k2 < wl2 - 1) { - var charCodeHigh = words2[k2].charCodeAt(0); - var charCodeLow = words2[k2 + 1].charCodeAt(0); - if (charCodeHigh >= 0xD800 && charCodeHigh <= 0xDBFF && (charCodeLow & 0xFC00) == 0xDC00) { - var realWord = words2[k2] + words2[k2 + 1]; - codeLen = 2; - has4BytesUnicode2 = true; - w = measureTextWidth(realWord, values, element.style); - } - else { - w = measureTextWidth(words2[k2], values, element.style); - } - } - else { - w = measureTextWidth(words2[k2], values, element.style); - } - // w = measureTextWidth(words2[k2], values, element.style); - if (k2 > 0 && lineW + w > textFieldWidth) { - break; - } - // charNum += words2[k2].length; - charNum += codeLen; - ww += w; - lineW += w; - lineCharNum += charNum; - if (has4BytesUnicode2) { - k2++; - } - } - } - else { - // charNum += words[k].length; - charNum += codeLen; - ww += w; - lineW += w; - lineCharNum += charNum; - } - if (has4BytesUnicode) { - k++; - } - } - if (k > 0) { - lineElement.elements.push({ - width: ww, - text: word.substring(0, charNum), - style: element.style - }); - var leftWord = word.substring(charNum); - var m = void 0; - var lwleng = leftWord.length; - for (m = 0; m < lwleng; m++) { - if (leftWord.charAt(m) != " ") { - break; - } - } - textArr[j] = leftWord.substring(m); - } - if (textArr[j] != "") { - j--; - isNextLine = false; - } - } - } - } - if (isNextLine) { - lineCharNum++; - lineElement.hasNextLine = true; - } - if (j < textArr.length - 1) { - lineElement.width = lineW; - lineElement.height = lineH; - lineElement.charNum = lineCharNum; - values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW); - values[6 /* textHeight */] += lineH; - //if (this._type == TextFieldType.INPUT && !this._multiline) { - // this._numLines = linesArr.length; - // return linesArr; - //} - lineCount++; - } - } - if (i == text2Arr.length - 1 && lineElement) { - lineElement.width = lineW; - lineElement.height = lineH; - lineElement.charNum = lineCharNum; - values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW); - values[6 /* textHeight */] += lineH; - } - } - values[29 /* numLines */] = linesArr.length; - return linesArr; - }; - /** - * @private - */ - TextField.prototype.$setIsTyping = function (value) { - this.$isTyping = value; - this.$invalidateTextField(); - if (egret.nativeRender) { - this.$nativeDisplayObject.setIsTyping(value); - } - }; - /** - * @private - * 返回要绘制的下划线列表 - */ - TextField.prototype.drawText = function () { - var node = this.textNode; - var values = this.$TextField; - //更新文本样式 - node.bold = values[15 /* bold */]; - node.fontFamily = values[8 /* fontFamily */] || TextField.default_fontFamily; - node.italic = values[16 /* italic */]; - node.size = values[0 /* fontSize */]; - node.stroke = values[27 /* stroke */]; - node.strokeColor = values[25 /* strokeColor */]; - node.textColor = values[2 /* textColor */]; - //先算出需要的数值 - var lines = this.$getLinesArr(); - if (values[5 /* textWidth */] == 0) { - return []; - } - var maxWidth = !isNaN(values[3 /* textFieldWidth */]) ? values[3 /* textFieldWidth */] : values[5 /* textWidth */]; - var textHeight = egret.TextFieldUtils.$getTextHeight(this); - var drawY = 0; - var startLine = egret.TextFieldUtils.$getStartLine(this); - var textFieldHeight = values[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight) && textFieldHeight > textHeight) { - var vAlign = egret.TextFieldUtils.$getValign(this); - drawY += vAlign * (textFieldHeight - textHeight); - } - drawY = Math.round(drawY); - var hAlign = egret.TextFieldUtils.$getHalign(this); - var drawX = 0; - var underLineData = []; - for (var i = startLine, numLinesLength = values[29 /* numLines */]; i < numLinesLength; i++) { - var line = lines[i]; - var h = line.height; - drawY += h / 2; - if (i != startLine) { - if (values[24 /* type */] == egret.TextFieldType.INPUT && !values[30 /* multiline */]) { - break; - } - if (!isNaN(textFieldHeight) && drawY > textFieldHeight) { - break; - } - } - drawX = Math.round((maxWidth - line.width) * hAlign); - for (var j = 0, elementsLength = line.elements.length; j < elementsLength; j++) { - var element = line.elements[j]; - var size = element.style.size || values[0 /* fontSize */]; - node.drawText(drawX, drawY + (h - size) / 2, element.text, element.style); - if (element.style.underline) { - underLineData.push(drawX, drawY + (h) / 2, element.width, element.style.textColor); - } - drawX += element.width; - } - drawY += h / 2 + values[1 /* lineSpacing */]; - } - return underLineData; - }; - //增加点击事件 - TextField.prototype.addEvent = function () { - this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapHandler, this); - }; - //释放点击事件 - TextField.prototype.removeEvent = function () { - this.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapHandler, this); - }; - //处理富文本中有href的 - TextField.prototype.onTapHandler = function (e) { - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - return; - } - var ele = egret.TextFieldUtils.$getTextElement(this, e.localX, e.localY); - if (ele == null) { - return; - } - var style = ele.style; - if (style && style.href) { - if (style.href.match(/^event:/)) { - var type = style.href.match(/^event:/)[0]; - egret.TextEvent.dispatchTextEvent(this, egret.TextEvent.LINK, style.href.substring(type.length)); - } - else { - open(style.href, style.target || "_blank"); - } - } - }; - /** - * default fontFamily - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字体 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TextField.default_fontFamily = "Arial"; - /** - * default size in pixels of text - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字号大小 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - TextField.default_size = 30; - /** - * default color of the text. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本颜色 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - TextField.default_textColor = 0xffffff; - return TextField; - }(egret.DisplayObject)); - egret.TextField = TextField; - __reflect(TextField.prototype, "egret.TextField"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * TextFieldInputType class is an enumeration of constant value used in setting the inputType property of the TextField class. - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldInputType 类是在设置 TextField 类的 inputType 属性时使用的常数值的枚举。 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - var TextFieldInputType = (function () { - function TextFieldInputType() { - } - /** - * The default - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 默认 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - TextFieldInputType.TEXT = "text"; - /** - * Telephone Number Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 电话号码 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - TextFieldInputType.TEL = "tel"; - /** - * Password Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * password 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - TextFieldInputType.PASSWORD = "password"; - return TextFieldInputType; - }()); - egret.TextFieldInputType = TextFieldInputType; - __reflect(TextFieldInputType.prototype, "egret.TextFieldInputType"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * TextFieldType class is an enumeration of constant value used in setting the type property of the TextField class. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldType 类是在设置 TextField 类的 type 属性时使用的常数值的枚举。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var TextFieldType = (function () { - function TextFieldType() { - } - /** - * Used to specify dynamic text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定动态文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TextFieldType.DYNAMIC = "dynamic"; - /** - * Used to specify the input text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定输入文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - TextFieldType.INPUT = "input"; - return TextFieldType; - }()); - egret.TextFieldType = TextFieldType; - __reflect(TextFieldType.prototype, "egret.TextFieldType"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - var TextFieldUtils = (function () { - function TextFieldUtils() { - } - /** - * 获取第一个绘制的行数 - * @param textfield 文本 - * @returns {number} 行数,从0开始 - * @private - */ - TextFieldUtils.$getStartLine = function (textfield) { - var values = textfield.$TextField; - var textHeight = TextFieldUtils.$getTextHeight(textfield); - var startLine = 0; - var textFieldHeight = values[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight)) { - if (textHeight < textFieldHeight) { - } - else if (textHeight > textFieldHeight) { - startLine = Math.max(values[28 /* scrollV */] - 1, 0); - startLine = Math.min(values[29 /* numLines */] - 1, startLine); - } - if (!values[30 /* multiline */]) { - startLine = Math.max(values[28 /* scrollV */] - 1, 0); - if (values[29 /* numLines */] > 0) { - startLine = Math.min(values[29 /* numLines */] - 1, startLine); - } - } - } - return startLine; - }; - /** - * 获取水平比例 - * @param textfield 文本 - * @returns {number} 水平比例 - * @private - */ - TextFieldUtils.$getHalign = function (textfield) { - var lineArr = textfield.$getLinesArr2(); - var halign = 0; - if (textfield.$TextField[9 /* textAlign */] == egret.HorizontalAlign.CENTER) { - halign = 0.5; - } - else if (textfield.$TextField[9 /* textAlign */] == egret.HorizontalAlign.RIGHT) { - halign = 1; - } - if (textfield.$TextField[24 /* type */] == egret.TextFieldType.INPUT && !textfield.$TextField[30 /* multiline */] && lineArr.length > 1) { - halign = 0; - } - return halign; - }; - /** - * @private - * - * @param textfield - * @returns - */ - TextFieldUtils.$getTextHeight = function (textfield) { - var textHeight = (egret.TextFieldType.INPUT == textfield.$TextField[24 /* type */] - && !textfield.$TextField[30 /* multiline */]) ? textfield.$TextField[0 /* fontSize */] : (textfield.$TextField[6 /* textHeight */] + (textfield.$TextField[29 /* numLines */] - 1) * textfield.$TextField[1 /* lineSpacing */]); - return textHeight; - }; - /** - * 获取垂直比例 - * @param textfield 文本 - * @returns {number} 垂直比例 - * @private - */ - TextFieldUtils.$getValign = function (textfield) { - var textHeight = TextFieldUtils.$getTextHeight(textfield); - //if (textfield.$TextField[sys.TextKeys.type] == egret.TextFieldType.INPUT) { - // if (textfield.$TextField[sys.TextKeys.multiline]) { - //return 0; - //} - //return 0.5; - //} - var textFieldHeight = textfield.$TextField[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight)) { - if (textHeight < textFieldHeight) { - var valign = 0; - if (textfield.$TextField[10 /* verticalAlign */] == egret.VerticalAlign.MIDDLE) - valign = 0.5; - else if (textfield.$TextField[10 /* verticalAlign */] == egret.VerticalAlign.BOTTOM) - valign = 1; - return valign; - } - } - return 0; - }; - /** - * 根据x、y获取文本项 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本单项 - * @private - */ - TextFieldUtils.$getTextElement = function (textfield, x, y) { - var hitTextEle = TextFieldUtils.$getHit(textfield, x, y); - var lineArr = textfield.$getLinesArr2(); - if (hitTextEle && lineArr[hitTextEle.lineIndex] && lineArr[hitTextEle.lineIndex].elements[hitTextEle.textElementIndex]) { - return lineArr[hitTextEle.lineIndex].elements[hitTextEle.textElementIndex]; - } - return null; - }; - /** - * 获取文本点击块 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本点击块 - * @private - */ - TextFieldUtils.$getHit = function (textfield, x, y) { - var lineArr = textfield.$getLinesArr2(); - if (textfield.$TextField[3 /* textFieldWidth */] == 0) { - return null; - } - var line = 0; - var textHeight = TextFieldUtils.$getTextHeight(textfield); - var startY = 0; - var textFieldHeight = textfield.$TextField[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight) && textFieldHeight > textHeight) { - var valign = TextFieldUtils.$getValign(textfield); - startY = valign * (textFieldHeight - textHeight); - if (startY != 0) { - y -= startY; - } - } - var startLine = TextFieldUtils.$getStartLine(textfield); - var lineH = 0; - for (var i = startLine; i < lineArr.length; i++) { - var lineEle = lineArr[i]; - if (lineH + lineEle.height >= y) { - if (lineH < y) { - line = i + 1; - } - break; - } - else { - lineH += lineEle.height; - } - if (lineH + textfield.$TextField[1 /* lineSpacing */] > y) { - return null; - } - lineH += textfield.$TextField[1 /* lineSpacing */]; - } - if (line == 0) { - return null; - } - var lineElement = lineArr[line - 1]; - var textFieldWidth = textfield.$TextField[3 /* textFieldWidth */]; - if (isNaN(textFieldWidth)) { - textFieldWidth = textfield.textWidth; - } - var halign = TextFieldUtils.$getHalign(textfield); - x -= halign * (textFieldWidth - lineElement.width); - var lineW = 0; - for (var i = 0; i < lineElement.elements.length; i++) { - var iwTE = lineElement.elements[i]; - if (lineW + iwTE.width <= x) { - lineW += iwTE.width; - } - else if (lineW < x) { - return { "lineIndex": line - 1, "textElementIndex": i }; - } - } - return null; - }; - /** - * 获取当前显示多少行 - * @param textfield 文本 - * @returns {number} 显示的行数 - * @private - */ - TextFieldUtils.$getScrollNum = function (textfield) { - var scrollNum = 1; - if (textfield.$TextField[30 /* multiline */]) { - var height = textfield.height; - var size = textfield.size; - var lineSpacing = textfield.lineSpacing; - scrollNum = Math.floor(height / (size + lineSpacing)); - var leftH = height - (size + lineSpacing) * scrollNum; - if (leftH > size / 2) { - scrollNum++; - } - } - return scrollNum; - }; - return TextFieldUtils; - }()); - egret.TextFieldUtils = TextFieldUtils; - __reflect(TextFieldUtils.prototype, "egret.TextFieldUtils"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/** - * @private - */ -var egret; -(function (egret) { - var sys; - (function (sys) { - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The VerticalAlign class defines the possible values for the vertical alignment. - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * VerticalAlign 类为垂直对齐方式定义可能的值。 - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var VerticalAlign = (function () { - function VerticalAlign() { - } - /** - * Vertically align content to the top of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的顶部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - VerticalAlign.TOP = "top"; - /** - * Vertically align content to the bottom of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的底部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - VerticalAlign.BOTTOM = "bottom"; - /** - * Vertically align content in the middle of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的垂直中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - VerticalAlign.MIDDLE = "middle"; - /** - * Vertical alignment with both edges - * Note: TextFiled does not support this alignment method." - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直两端对齐 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - VerticalAlign.JUSTIFY = "justify"; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Height \" of the container \". - * The Content Height \" of the container \" is the size of the max. child item. If the size of all child items are less than the height of the container, they will be adjusted to the height of the container. - * Note: TextFiled does not support this alignment method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容高度"。 - * 容器的"内容高度"是最大子项的大小,如果所有子项都小于容器的高度,则会将所有子项的大小调整为容器的高度。 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - VerticalAlign.CONTENT_JUSTIFY = "contentJustify"; - return VerticalAlign; - }()); - egret.VerticalAlign = VerticalAlign; - __reflect(VerticalAlign.prototype, "egret.VerticalAlign"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @language en_US - * The Base64Util class provides methods for encoding and decoding base64. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - /** - * @language zh_CN - * Base64Util 类提供用于编解码base64的方法。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - var Base64Util = (function () { - function Base64Util() { - } - /** - * @language en_US - * encode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 编码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - Base64Util.encode = function (arraybuffer) { - var bytes = new Uint8Array(arraybuffer); - var len = bytes.length; - var base64 = ''; - for (var i = 0; i < len; i += 3) { - base64 += chars[bytes[i] >> 2]; - base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)]; - base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)]; - base64 += chars[bytes[i + 2] & 63]; - } - if ((len % 3) === 2) { - base64 = base64.substring(0, base64.length - 1) + '='; - } - else if (len % 3 === 1) { - base64 = base64.substring(0, base64.length - 2) + '=='; - } - return base64; - }; - /** - * @language en_US - * decode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 解码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - Base64Util.decode = function (base64) { - var bufferLength = base64.length * 0.75; - var len = base64.length; - var p = 0; - var encoded1 = 0; - var encoded2 = 0; - var encoded3 = 0; - var encoded4 = 0; - if (base64[base64.length - 1] === '=') { - bufferLength--; - if (base64[base64.length - 2] === '=') { - bufferLength--; - } - } - var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer); - for (var i = 0; i < len; i += 4) { - encoded1 = lookup[base64.charCodeAt(i)]; - encoded2 = lookup[base64.charCodeAt(i + 1)]; - encoded3 = lookup[base64.charCodeAt(i + 2)]; - encoded4 = lookup[base64.charCodeAt(i + 3)]; - bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); - bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2); - bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63); - } - return arraybuffer; - }; - return Base64Util; - }()); - egret.Base64Util = Base64Util; - __reflect(Base64Util.prototype, "egret.Base64Util"); -})(egret || (egret = {})); -/** - * @private - */ -var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -/** - * @private - */ -var lookup = new Uint8Array(256); -for (var i = 0; i < chars.length; i++) { - lookup[chars.charCodeAt(i)] = i; -} -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Endian class contains values that denote the byte order used to represent multibyte numbers. - * The byte order is either bigEndian (most significant byte first) or littleEndian (least significant byte first). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Endian 类中包含一些值,它们表示用于表示多字节数字的字节顺序。 - * 字节顺序为 bigEndian(最高有效字节位于最前)或 littleEndian(最低有效字节位于最前)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var Endian = (function () { - function Endian() { - } - /** - * Indicates the least significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最低有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Endian.LITTLE_ENDIAN = "littleEndian"; - /** - * Indicates the most significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最高有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Endian.BIG_ENDIAN = "bigEndian"; - return Endian; - }()); - egret.Endian = Endian; - __reflect(Endian.prototype, "egret.Endian"); - /** - * The ByteArray class provides methods and attributes for optimized reading and writing as well as dealing with binary data. - * Note: The ByteArray class is applied to the advanced developers who need to access data at the byte layer. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language en_US - */ - /** - * ByteArray 类提供用于优化读取、写入以及处理二进制数据的方法和属性。 - * 注意:ByteArray 类适用于需要在字节层访问数据的高级开发人员。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language zh_CN - */ - var ByteArray = (function () { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function ByteArray(buffer, bufferExtSize) { - if (bufferExtSize === void 0) { bufferExtSize = 0; } - /** - * @private - */ - this.bufferExtSize = 0; //Buffer expansion size - /** - * @private - */ - this.EOF_byte = -1; - /** - * @private - */ - this.EOF_code_point = -1; - if (bufferExtSize < 0) { - bufferExtSize = 0; - } - this.bufferExtSize = bufferExtSize; - var bytes, wpos = 0; - if (buffer) { - var uint8 = void 0; - if (buffer instanceof Uint8Array) { - uint8 = buffer; - wpos = buffer.length; - } - else { - wpos = buffer.byteLength; - uint8 = new Uint8Array(buffer); - } - if (bufferExtSize == 0) { - bytes = new Uint8Array(wpos); - } - else { - var multi = (wpos / bufferExtSize | 0) + 1; - bytes = new Uint8Array(multi * bufferExtSize); - } - bytes.set(uint8); - } - else { - bytes = new Uint8Array(bufferExtSize); - } - this.write_position = wpos; - this._position = 0; - this._bytes = bytes; - this.data = new DataView(bytes.buffer); - this.endian = Endian.BIG_ENDIAN; - } - Object.defineProperty(ByteArray.prototype, "endian", { - /** - * Changes or reads the byte order; egret.EndianConst.BIG_ENDIAN or egret.EndianConst.LITTLE_EndianConst. - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改或读取数据的字节顺序;egret.EndianConst.BIG_ENDIAN 或 egret.EndianConst.LITTLE_ENDIAN。 - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$endian == 0 /* LITTLE_ENDIAN */ ? Endian.LITTLE_ENDIAN : Endian.BIG_ENDIAN; - }, - set: function (value) { - this.$endian = value == Endian.LITTLE_ENDIAN ? 0 /* LITTLE_ENDIAN */ : 1 /* BIG_ENDIAN */; - }, - enumerable: true, - configurable: true - }); - /** - * @deprecated - * @version Egret 2.4 - * @platform Web,Native - */ - ByteArray.prototype.setArrayBuffer = function (buffer) { - }; - Object.defineProperty(ByteArray.prototype, "readAvailable", { - /** - * 可读的剩余字节数 - * - * @returns - * - * @memberOf ByteArray - */ - get: function () { - return this.write_position - this._position; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "buffer", { - get: function () { - return this.data.buffer.slice(0, this.write_position); - }, - /** - * @private - */ - set: function (value) { - var wpos = value.byteLength; - var uint8 = new Uint8Array(value); - var bufferExtSize = this.bufferExtSize; - var bytes; - if (bufferExtSize == 0) { - bytes = new Uint8Array(wpos); - } - else { - var multi = (wpos / bufferExtSize | 0) + 1; - bytes = new Uint8Array(multi * bufferExtSize); - } - bytes.set(uint8); - this.write_position = wpos; - this._bytes = bytes; - this.data = new DataView(bytes.buffer); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "rawBuffer", { - get: function () { - return this.data.buffer; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "bytes", { - get: function () { - return this._bytes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "dataView", { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.data; - }, - /** - * @private - */ - set: function (value) { - this.buffer = value.buffer; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "bufferOffset", { - /** - * @private - */ - get: function () { - return this.data.byteOffset; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "position", { - /** - * The current position of the file pointer (in bytes) to move or return to the ByteArray object. The next time you start reading reading method call in this position, or will start writing in this position next time call a write method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将文件指针的当前位置(以字节为单位)移动或返回到 ByteArray 对象中。下一次调用读取方法时将在此位置开始读取,或者下一次调用写入方法时将在此位置开始写入。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._position; - }, - set: function (value) { - this._position = value; - if (value > this.write_position) { - this.write_position = value; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ByteArray.prototype, "length", { - /** - * The length of the ByteArray object (in bytes). - * If the length is set to be larger than the current length, the right-side zero padding byte array. - * If the length is set smaller than the current length, the byte array is truncated. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * ByteArray 对象的长度(以字节为单位)。 - * 如果将长度设置为大于当前长度的值,则用零填充字节数组的右侧。 - * 如果将长度设置为小于当前长度的值,将会截断该字节数组。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.write_position; - }, - set: function (value) { - this.write_position = value; - if (this.data.byteLength > value) { - this._position = value; - } - this._validateBuffer(value); - }, - enumerable: true, - configurable: true - }); - ByteArray.prototype._validateBuffer = function (value) { - if (this.data.byteLength < value) { - var be = this.bufferExtSize; - var tmp = void 0; - if (be == 0) { - tmp = new Uint8Array(value); - } - else { - var nLen = ((value / be >> 0) + 1) * be; - tmp = new Uint8Array(nLen); - } - tmp.set(this._bytes); - this._bytes = tmp; - this.data = new DataView(tmp.buffer); - } - }; - Object.defineProperty(ByteArray.prototype, "bytesAvailable", { - /** - * The number of bytes that can be read from the current position of the byte array to the end of the array data. - * When you access a ByteArray object, the bytesAvailable property in conjunction with the read methods each use to make sure you are reading valid data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 可从字节数组的当前位置到数组末尾读取的数据的字节数。 - * 每次访问 ByteArray 对象时,将 bytesAvailable 属性与读取方法结合使用,以确保读取有效的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.data.byteLength - this._position; - }, - enumerable: true, - configurable: true - }); - /** - * Clears the contents of the byte array and resets the length and position properties to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除字节数组的内容,并将 length 和 position 属性重置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.clear = function () { - var buffer = new ArrayBuffer(this.bufferExtSize); - this.data = new DataView(buffer); - this._bytes = new Uint8Array(buffer); - this._position = 0; - this.write_position = 0; - }; - /** - * Read a Boolean value from the byte stream. Read a simple byte. If the byte is non-zero, it returns true; otherwise, it returns false. - * @return If the byte is non-zero, it returns true; otherwise, it returns false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取布尔值。读取单个字节,如果字节非零,则返回 true,否则返回 false - * @return 如果字节不为零,则返回 true,否则返回 false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readBoolean = function () { - if (this.validate(1 /* SIZE_OF_BOOLEAN */)) - return !!this._bytes[this.position++]; - }; - /** - * Read signed bytes from the byte stream. - * @return An integer ranging from -128 to 127 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取带符号的字节 - * @return 介于 -128 和 127 之间的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readByte = function () { - if (this.validate(1 /* SIZE_OF_INT8 */)) - return this.data.getInt8(this.position++); - }; - /** - * Read data byte number specified by the length parameter from the byte stream. Starting from the position specified by offset, read bytes into the ByteArray object specified by the bytes parameter, and write bytes into the target ByteArray - * @param bytes ByteArray object that data is read into - * @param offset Offset (position) in bytes. Read data should be written from this position - * @param length Byte number to be read Default value 0 indicates reading all available data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取 length 参数指定的数据字节数。从 offset 指定的位置开始,将字节读入 bytes 参数指定的 ByteArray 对象中,并将字节写入目标 ByteArray 中 - * @param bytes 要将数据读入的 ByteArray 对象 - * @param offset bytes 中的偏移(位置),应从该位置写入读取的数据 - * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readBytes = function (bytes, offset, length) { - if (offset === void 0) { offset = 0; } - if (length === void 0) { length = 0; } - if (!bytes) { - return; - } - var pos = this._position; - var available = this.write_position - pos; - if (available < 0) { - egret.$error(1025); - return; - } - if (length == 0) { - length = available; - } - else if (length > available) { - egret.$error(1025); - return; - } - var position = bytes._position; - bytes._position = 0; - bytes.validateBuffer(offset + length); - bytes._position = position; - bytes._bytes.set(this._bytes.subarray(pos, pos + length), offset); - this.position += length; - }; - /** - * Read an IEEE 754 double-precision (64 bit) floating point number from the byte stream - * @return Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 双精度(64 位)浮点数 - * @return 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readDouble = function () { - if (this.validate(8 /* SIZE_OF_FLOAT64 */)) { - var value = this.data.getFloat64(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 8 /* SIZE_OF_FLOAT64 */; - return value; - } - }; - /** - * Read an IEEE 754 single-precision (32 bit) floating point number from the byte stream - * @return Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 单精度(32 位)浮点数 - * @return 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readFloat = function () { - if (this.validate(4 /* SIZE_OF_FLOAT32 */)) { - var value = this.data.getFloat32(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_FLOAT32 */; - return value; - } - }; - /** - * Read a 32-bit signed integer from the byte stream. - * @return A 32-bit signed integer ranging from -2147483648 to 2147483647 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 32 位整数 - * @return 介于 -2147483648 和 2147483647 之间的 32 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readInt = function () { - if (this.validate(4 /* SIZE_OF_INT32 */)) { - var value = this.data.getInt32(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_INT32 */; - return value; - } - }; - /** - * Read a 16-bit signed integer from the byte stream. - * @return A 16-bit signed integer ranging from -32768 to 32767 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 16 位整数 - * @return 介于 -32768 和 32767 之间的 16 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readShort = function () { - if (this.validate(2 /* SIZE_OF_INT16 */)) { - var value = this.data.getInt16(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 2 /* SIZE_OF_INT16 */; - return value; - } - }; - /** - * Read unsigned bytes from the byte stream. - * @return A unsigned integer ranging from 0 to 255 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取无符号的字节 - * @return 介于 0 和 255 之间的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readUnsignedByte = function () { - if (this.validate(1 /* SIZE_OF_UINT8 */)) - return this._bytes[this.position++]; - }; - /** - * Read a 32-bit unsigned integer from the byte stream. - * @return A 32-bit unsigned integer ranging from 0 to 4294967295 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 32 位整数 - * @return 介于 0 和 4294967295 之间的 32 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readUnsignedInt = function () { - if (this.validate(4 /* SIZE_OF_UINT32 */)) { - var value = this.data.getUint32(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_UINT32 */; - return value; - } - }; - /** - * Read a 16-bit unsigned integer from the byte stream. - * @return A 16-bit unsigned integer ranging from 0 to 65535 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 16 位整数 - * @return 介于 0 和 65535 之间的 16 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readUnsignedShort = function () { - if (this.validate(2 /* SIZE_OF_UINT16 */)) { - var value = this.data.getUint16(this._position, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 2 /* SIZE_OF_UINT16 */; - return value; - } - }; - /** - * Read a UTF-8 character string from the byte stream Assume that the prefix of the character string is a short unsigned integer (use byte to express length) - * @return UTF-8 character string - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 UTF-8 字符串。假定字符串的前缀是无符号的短整型(以字节表示长度) - * @return UTF-8 编码的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readUTF = function () { - var length = this.readUnsignedShort(); - if (length > 0) { - return this.readUTFBytes(length); - } - else { - return ""; - } - }; - /** - * Read a UTF-8 byte sequence specified by the length parameter from the byte stream, and then return a character string - * @param Specify a short unsigned integer of the UTF-8 byte length - * @return A character string consists of UTF-8 bytes of the specified length - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个由 length 参数指定的 UTF-8 字节序列,并返回一个字符串 - * @param length 指明 UTF-8 字节长度的无符号短整型数 - * @return 由指定长度的 UTF-8 字节组成的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.readUTFBytes = function (length) { - if (!this.validate(length)) { - return; - } - var data = this.data; - var bytes = new Uint8Array(data.buffer, data.byteOffset + this._position, length); - this.position += length; - return this.decodeUTF8(bytes); - }; - /** - * Write a Boolean value. A single byte is written according to the value parameter. If the value is true, write 1; if the value is false, write 0. - * @param value A Boolean value determining which byte is written. If the value is true, write 1; if the value is false, write 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 写入布尔值。根据 value 参数写入单个字节。如果为 true,则写入 1,如果为 false,则写入 0 - * @param value 确定写入哪个字节的布尔值。如果该参数为 true,则该方法写入 1;如果该参数为 false,则该方法写入 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeBoolean = function (value) { - this.validateBuffer(1 /* SIZE_OF_BOOLEAN */); - this._bytes[this.position++] = +value; - }; - /** - * Write a byte into the byte stream - * The low 8 bits of the parameter are used. The high 24 bits are ignored. - * @param value A 32-bit integer. The low 8 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个字节 - * 使用参数的低 8 位。忽略高 24 位 - * @param value 一个 32 位整数。低 8 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeByte = function (value) { - this.validateBuffer(1 /* SIZE_OF_INT8 */); - this._bytes[this.position++] = value & 0xff; - }; - /** - * Write the byte sequence that includes length bytes in the specified byte array, bytes, (starting at the byte specified by offset, using a zero-based index), into the byte stream - * If the length parameter is omitted, the default length value 0 is used and the entire buffer starting at offset is written. If the offset parameter is also omitted, the entire buffer is written - * If the offset or length parameter is out of range, they are clamped to the beginning and end of the bytes array. - * @param bytes ByteArray Object - * @param offset A zero-based index specifying the position into the array to begin writing - * @param length An unsigned integer specifying how far into the buffer to write - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定字节数组 bytes(起始偏移量为 offset,从零开始的索引)中包含 length 个字节的字节序列写入字节流 - * 如果省略 length 参数,则使用默认长度 0;该方法将从 offset 开始写入整个缓冲区。如果还省略了 offset 参数,则写入整个缓冲区 - * 如果 offset 或 length 超出范围,它们将被锁定到 bytes 数组的开头和结尾 - * @param bytes ByteArray 对象 - * @param offset 从 0 开始的索引,表示在数组中开始写入的位置 - * @param length 一个无符号整数,表示在缓冲区中的写入范围 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeBytes = function (bytes, offset, length) { - if (offset === void 0) { offset = 0; } - if (length === void 0) { length = 0; } - var writeLength; - if (offset < 0) { - return; - } - if (length < 0) { - return; - } - else if (length == 0) { - writeLength = bytes.length - offset; - } - else { - writeLength = Math.min(bytes.length - offset, length); - } - if (writeLength > 0) { - this.validateBuffer(writeLength); - this._bytes.set(bytes._bytes.subarray(offset, offset + writeLength), this._position); - this.position = this._position + writeLength; - } - }; - /** - * Write an IEEE 754 double-precision (64 bit) floating point number into the byte stream - * @param value Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 双精度(64 位)浮点数 - * @param value 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeDouble = function (value) { - this.validateBuffer(8 /* SIZE_OF_FLOAT64 */); - this.data.setFloat64(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 8 /* SIZE_OF_FLOAT64 */; - }; - /** - * Write an IEEE 754 single-precision (32 bit) floating point number into the byte stream - * @param value Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 单精度(32 位)浮点数 - * @param value 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeFloat = function (value) { - this.validateBuffer(4 /* SIZE_OF_FLOAT32 */); - this.data.setFloat32(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_FLOAT32 */; - }; - /** - * Write a 32-bit signed integer into the byte stream - * @param value An integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个带符号的 32 位整数 - * @param value 要写入字节流的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeInt = function (value) { - this.validateBuffer(4 /* SIZE_OF_INT32 */); - this.data.setInt32(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_INT32 */; - }; - /** - * Write a 16-bit integer into the byte stream. The low 16 bits of the parameter are used. The high 16 bits are ignored. - * @param value A 32-bit integer. Its low 16 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 16 位整数。使用参数的低 16 位。忽略高 16 位 - * @param value 32 位整数,该整数的低 16 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeShort = function (value) { - this.validateBuffer(2 /* SIZE_OF_INT16 */); - this.data.setInt16(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 2 /* SIZE_OF_INT16 */; - }; - /** - * Write a 32-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 32 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeUnsignedInt = function (value) { - this.validateBuffer(4 /* SIZE_OF_UINT32 */); - this.data.setUint32(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 4 /* SIZE_OF_UINT32 */; - }; - /** - * Write a 16-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 16 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeUnsignedShort = function (value) { - this.validateBuffer(2 /* SIZE_OF_UINT16 */); - this.data.setUint16(this._position, value, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 2 /* SIZE_OF_UINT16 */; - }; - /** - * Write a UTF-8 string into the byte stream. The length of the UTF-8 string in bytes is written first, as a 16-bit integer, followed by the bytes representing the characters of the string - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。先写入以字节表示的 UTF-8 字符串长度(作为 16 位整数),然后写入表示字符串字符的字节 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeUTF = function (value) { - var utf8bytes = this.encodeUTF8(value); - var length = utf8bytes.length; - this.validateBuffer(2 /* SIZE_OF_UINT16 */ + length); - this.data.setUint16(this._position, length, this.$endian == 0 /* LITTLE_ENDIAN */); - this.position += 2 /* SIZE_OF_UINT16 */; - this._writeUint8Array(utf8bytes, false); - }; - /** - * Write a UTF-8 string into the byte stream. Similar to the writeUTF() method, but the writeUTFBytes() method does not prefix the string with a 16-bit length word - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。类似于 writeUTF() 方法,但 writeUTFBytes() 不使用 16 位长度的词为字符串添加前缀 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ByteArray.prototype.writeUTFBytes = function (value) { - this._writeUint8Array(this.encodeUTF8(value)); - }; - /** - * - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - ByteArray.prototype.toString = function () { - return "[ByteArray] length:" + this.length + ", bytesAvailable:" + this.bytesAvailable; - }; - /** - * @private - * 将 Uint8Array 写入字节流 - * @param bytes 要写入的Uint8Array - * @param validateBuffer - */ - ByteArray.prototype._writeUint8Array = function (bytes, validateBuffer) { - if (validateBuffer === void 0) { validateBuffer = true; } - var pos = this._position; - var npos = pos + bytes.length; - if (validateBuffer) { - this.validateBuffer(npos); - } - this.bytes.set(bytes, pos); - this.position = npos; - }; - /** - * @param len - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - ByteArray.prototype.validate = function (len) { - var bl = this._bytes.length; - if (bl > 0 && this._position + len <= bl) { - return true; - } - else { - egret.$error(1025); - } - }; - /**********************/ - /* PRIVATE METHODS */ - /**********************/ - /** - * @private - * @param len - * @param needReplace - */ - ByteArray.prototype.validateBuffer = function (len) { - this.write_position = len > this.write_position ? len : this.write_position; - len += this._position; - this._validateBuffer(len); - }; - /** - * @private - * UTF-8 Encoding/Decoding - */ - ByteArray.prototype.encodeUTF8 = function (str) { - var pos = 0; - var codePoints = this.stringToCodePoints(str); - var outputBytes = []; - while (codePoints.length > pos) { - var code_point = codePoints[pos++]; - if (this.inRange(code_point, 0xD800, 0xDFFF)) { - this.encoderError(code_point); - } - else if (this.inRange(code_point, 0x0000, 0x007f)) { - outputBytes.push(code_point); - } - else { - var count = void 0, offset = void 0; - if (this.inRange(code_point, 0x0080, 0x07FF)) { - count = 1; - offset = 0xC0; - } - else if (this.inRange(code_point, 0x0800, 0xFFFF)) { - count = 2; - offset = 0xE0; - } - else if (this.inRange(code_point, 0x10000, 0x10FFFF)) { - count = 3; - offset = 0xF0; - } - outputBytes.push(this.div(code_point, Math.pow(64, count)) + offset); - while (count > 0) { - var temp = this.div(code_point, Math.pow(64, count - 1)); - outputBytes.push(0x80 + (temp % 64)); - count -= 1; - } - } - } - return new Uint8Array(outputBytes); - }; - /** - * @private - * - * @param data - * @returns - */ - ByteArray.prototype.decodeUTF8 = function (data) { - var fatal = false; - var pos = 0; - var result = ""; - var code_point; - var utf8_code_point = 0; - var utf8_bytes_needed = 0; - var utf8_bytes_seen = 0; - var utf8_lower_boundary = 0; - while (data.length > pos) { - var _byte = data[pos++]; - if (_byte == this.EOF_byte) { - if (utf8_bytes_needed != 0) { - code_point = this.decoderError(fatal); - } - else { - code_point = this.EOF_code_point; - } - } - else { - if (utf8_bytes_needed == 0) { - if (this.inRange(_byte, 0x00, 0x7F)) { - code_point = _byte; - } - else { - if (this.inRange(_byte, 0xC2, 0xDF)) { - utf8_bytes_needed = 1; - utf8_lower_boundary = 0x80; - utf8_code_point = _byte - 0xC0; - } - else if (this.inRange(_byte, 0xE0, 0xEF)) { - utf8_bytes_needed = 2; - utf8_lower_boundary = 0x800; - utf8_code_point = _byte - 0xE0; - } - else if (this.inRange(_byte, 0xF0, 0xF4)) { - utf8_bytes_needed = 3; - utf8_lower_boundary = 0x10000; - utf8_code_point = _byte - 0xF0; - } - else { - this.decoderError(fatal); - } - utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); - code_point = null; - } - } - else if (!this.inRange(_byte, 0x80, 0xBF)) { - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - pos--; - code_point = this.decoderError(fatal, _byte); - } - else { - utf8_bytes_seen += 1; - utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); - if (utf8_bytes_seen !== utf8_bytes_needed) { - code_point = null; - } - else { - var cp = utf8_code_point; - var lower_boundary = utf8_lower_boundary; - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - if (this.inRange(cp, lower_boundary, 0x10FFFF) && !this.inRange(cp, 0xD800, 0xDFFF)) { - code_point = cp; - } - else { - code_point = this.decoderError(fatal, _byte); - } - } - } - } - //Decode string - if (code_point !== null && code_point !== this.EOF_code_point) { - if (code_point <= 0xFFFF) { - if (code_point > 0) - result += String.fromCharCode(code_point); - } - else { - code_point -= 0x10000; - result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); - result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); - } - } - } - return result; - }; - /** - * @private - * - * @param code_point - */ - ByteArray.prototype.encoderError = function (code_point) { - egret.$error(1026, code_point); - }; - /** - * @private - * - * @param fatal - * @param opt_code_point - * @returns - */ - ByteArray.prototype.decoderError = function (fatal, opt_code_point) { - if (fatal) { - egret.$error(1027); - } - return opt_code_point || 0xFFFD; - }; - /** - * @private - * - * @param a - * @param min - * @param max - */ - ByteArray.prototype.inRange = function (a, min, max) { - return min <= a && a <= max; - }; - /** - * @private - * - * @param n - * @param d - */ - ByteArray.prototype.div = function (n, d) { - return Math.floor(n / d); - }; - /** - * @private - * - * @param string - */ - ByteArray.prototype.stringToCodePoints = function (string) { - /** @type {Array.} */ - var cps = []; - // Based on http://www.w3.org/TR/WebIDL/#idl-DOMString - var i = 0, n = string.length; - while (i < string.length) { - var c = string.charCodeAt(i); - if (!this.inRange(c, 0xD800, 0xDFFF)) { - cps.push(c); - } - else if (this.inRange(c, 0xDC00, 0xDFFF)) { - cps.push(0xFFFD); - } - else { - if (i == n - 1) { - cps.push(0xFFFD); - } - else { - var d = string.charCodeAt(i + 1); - if (this.inRange(d, 0xDC00, 0xDFFF)) { - var a = c & 0x3FF; - var b = d & 0x3FF; - i += 1; - cps.push(0x10000 + (a << 10) + b); - } - else { - cps.push(0xFFFD); - } - } - } - i += 1; - } - return cps; - }; - return ByteArray; - }()); - egret.ByteArray = ByteArray; - __reflect(ByteArray.prototype, "egret.ByteArray"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Sprite class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language en_US - */ - /** - * Sprite 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language zh_CN - */ - var Sprite = (function (_super) { - __extends(Sprite, _super); - /** - * Creates a new Sprite instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Sprite() { - var _this = _super.call(this) || this; - _this.$graphics = new egret.Graphics(); - _this.$graphics.$setTarget(_this); - return _this; - } - Sprite.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(9 /* SPRITE */); - }; - Object.defineProperty(Sprite.prototype, "graphics", { - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$graphics; - }, - enumerable: true, - configurable: true - }); - Sprite.prototype.$hitTest = function (stageX, stageY) { - if (!this.$visible) { - return null; - } - var m = this.$getInvertedConcatenatedMatrix(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - var rect = this.$scrollRect ? this.$scrollRect : this.$maskRect; - if (rect && !rect.contains(localX, localY)) { - return null; - } - if (this.$mask && !this.$mask.$hitTest(stageX, stageY)) { - return null; - } - var children = this.$children; - var found = false; - var target = null; - for (var i = children.length - 1; i >= 0; i--) { - var child = children[i]; - if (child.$maskedObject) { - continue; - } - target = child.$hitTest(stageX, stageY); - if (target) { - found = true; - if (target.$touchEnabled) { - break; - } - else { - target = null; - } - } - } - if (target) { - if (this.$touchChildren) { - return target; - } - return this; - } - if (found) { - return this; - } - target = egret.DisplayObject.prototype.$hitTest.call(this, stageX, stageY); - if (target) { - target = this.$graphics.$hitTest(stageX, stageY); - } - return target; - }; - /** - * @private - */ - Sprite.prototype.$measureContentBounds = function (bounds) { - this.$graphics.$measureContentBounds(bounds); - }; - /** - * @private - */ - Sprite.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - if (this.$graphics) { - this.$graphics.$onRemoveFromStage(); - } - }; - return Sprite; - }(egret.DisplayObjectContainer)); - egret.Sprite = Sprite; - __reflect(Sprite.prototype, "egret.Sprite"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Registers the runtime class information for a class.This method adds some strings which represent the class name or - * some interface names to the class definition. After the registration,you can use egret.is() method to do the type checking - * for the instance of this class.
    - * Note:If you use the TypeScript programming language, the egret command line tool will automatically generate the registration code line. - * You don't need to manually call this method. - * - * @example the following code shows how to register the runtime class information for the EventDispatcher class and do the type checking: - *
    -     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
    -     *      let dispatcher = new egret.EventDispatcher();
    -     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
    -     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
    -     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
    -     * 
    - * @param classDefinition the class definition to be registered. - * @param className a unique identification string of the specific class - * @param interfaceNames a list of unique identification string of the specific interfaces. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为一个类定义注册运行时类信息,用此方法往类定义上注册它自身以及所有接口对应的字符串。 - * 在运行时,这个类的实例将可以使用 egret.is() 方法传入一个字符串来判断实例类型。 - * @example 以下代码演示了如何为EventDispatcher类注册运行时类信息并判断类型: - *
    -     *      //为egret.EventDispatcher类注册运行时类信息,由于它实现了IEventDispatcher接口,这里应同时传入接口名对应的字符串。
    -     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
    -     *      let dispatcher = new egret.EventDispatcher();
    -     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
    -     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
    -     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
    -     * 
    - * 注意:若您使用 TypeScript 来编写程序,egret 命令行会自动帮您生成类信息注册代码行到最终的 Javascript 文件中。因此您不需要手动调用此方法。 - * - * @param classDefinition 要注册的类定义。 - * @param className 要注册的类名。 - * @param interfaceNames 要注册的类所实现的接口名列表。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function registerClass(classDefinition, className, interfaceNames) { - if (true) { - if (!classDefinition) { - egret.$error(1003, "classDefinition"); - } - if (!classDefinition.prototype) { - egret.$error(1012, "classDefinition"); - } - if (className === void 0) { - egret.$error(1003, "className"); - } - } - var prototype = classDefinition.prototype; - Object.defineProperty(prototype, '__class__', { - value: className, - enumerable: false, - writable: true - }); - var types = [className]; - if (interfaceNames) { - types = types.concat(interfaceNames); - } - var superTypes = prototype.__types__; - if (prototype.__types__) { - var length_8 = superTypes.length; - for (var i = 0; i < length_8; i++) { - var name_1 = superTypes[i]; - if (types.indexOf(name_1) == -1) { - types.push(name_1); - } - } - } - Object.defineProperty(prototype, '__types__', { - value: types, - enumerable: false, - writable: true - }); - } - egret.registerClass = registerClass; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The BitmapFillMode class defines the image fill mode of Bitmap. - * The BitmapFillMode class defines a pattern enumeration for adjusting size. These patterns determine how Bitmap fill the size designated by the layout system. - * @see http://edn.egret.com/cn/docs/page/134 Texture filling way - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language en_US - */ - /** - * BitmapFillMode 类定义Bitmap的图像填充方式。 - * BitmapFillMode 类定义了调整大小模式的一个枚举,这些模式确定 Bitmap 如何填充由布局系统指定的尺寸。 - * @see http://edn.egret.com/cn/docs/page/134 纹理的填充方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language zh_CN - */ - egret.BitmapFillMode = { - /** - * Repeat the bitmap to fill area. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 重复位图以填充区域。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - REPEAT: "repeat", - /** - * Scale bitmap fill to fill area. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 位图填充拉伸以填充区域。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - SCALE: "scale", - /** - * The bitmap ends at the edge of the region. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在区域的边缘处截断不显示位图。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - CLIP: "clip" - }; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Logger is an entrance for the log processing namespace of the engine - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Logger是引擎的日志处理模块入口 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var Logger = (function () { - function Logger() { - } - Object.defineProperty(Logger, "logLevel", { - /** - * Set the current need to open the log level. Grade level are: ALL - * This feature is only in DEBUG mode to take effect.
    - *
      - *
    • Logger.ALL - all levels of log can be printed out. - *
    • Logger.DEBUG - print debug, info, log, warn, error. - *
    • Logger.INFO - print info, log, warn, error. - *
    • Logger.WARN - can print warn, error. - *
    • Logger.ERROR - You can print error. - *
    • Logger.OFF - all closed. - * - *param LogType from this level to start printing. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置当前需要开启的log级别。级别等级分别为:ALL < DEBUG < INFO < WARN < ERROR < OFF
      - * 此功能只在 DEBUG 模式下才生效。
      - *
        - *
      • Logger.ALL -- 所有等级的log都可以打印出来。
      • - *
      • Logger.DEBUG -- 可以打印debug、info、log、warn、error。
      • - *
      • Logger.INFO -- 可以打印info、log、warn、error。
      • - *
      • Logger.WARN -- 可以打印warn、error。
      • - *
      • Logger.ERROR -- 可以打印error。
      • - *
      • Logger.OFF -- 全部关闭。
      • - *
      - * @param logType 从这个等级开始打印。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - set: function (logType) { - }, - enumerable: true, - configurable: true - }); - /** - * open all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全开 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.ALL = "all"; - /** - * level: DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.DEBUG = "debug"; - /** - * level: INFO - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 INFO - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.INFO = "info"; - /** - * level: WARN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 WARN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.WARN = "warn"; - /** - * level: ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.ERROR = "error"; - /** - * close all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全关 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Logger.OFF = "off"; - return Logger; - }()); - egret.Logger = Logger; - __reflect(Logger.prototype, "egret.Logger"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - var NumberUtils = (function () { - function NumberUtils() { - } - /** - * Judge whether it is a numerical value - * @param value Parameter that needs to be judged - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 判断是否是数值 - * @param value 需要判断的参数 - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - NumberUtils.isNumber = function (value) { - return typeof (value) === "number" && !isNaN(value); - }; - /** - * Obtain the approximate sin value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} sin value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 得到对应角度值的sin近似值 - * @param value {number} 角度值 - * @returns {number} sin值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - NumberUtils.sin = function (value) { - var valueFloor = Math.floor(value); - var valueCeil = valueFloor + 1; - var resultFloor = NumberUtils.sinInt(valueFloor); - if (valueFloor == value) { - return resultFloor; - } - var resultCeil = NumberUtils.sinInt(valueCeil); - return (value - valueFloor) * resultCeil + (valueCeil - value) * resultFloor; - }; - /** - * @private - * - * @param value - * @returns - */ - NumberUtils.sinInt = function (value) { - value = value % 360; - if (value < 0) { - value += 360; - } - return egret_sin_map[value]; - }; - /** - * Obtain the approximate cos value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} cos value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 得到对应角度值的cos近似值 - * @param value {number} 角度值 - * @returns {number} cos值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - NumberUtils.cos = function (value) { - var valueFloor = Math.floor(value); - var valueCeil = valueFloor + 1; - var resultFloor = NumberUtils.cosInt(valueFloor); - if (valueFloor == value) { - return resultFloor; - } - var resultCeil = NumberUtils.cosInt(valueCeil); - return (value - valueFloor) * resultCeil + (valueCeil - value) * resultFloor; - }; - /** - * @private - * - * @param value - * @returns - */ - NumberUtils.cosInt = function (value) { - value = value % 360; - if (value < 0) { - value += 360; - } - return egret_cos_map[value]; - }; - NumberUtils.convertStringToHashCode = function (str) { - if (str.length === 0) { - return 0; - } - var hash = 0; - for (var i = 0, length_9 = str.length; i < length_9; ++i) { - var chr = str.charCodeAt(i); - hash = ((hash << 5) - hash) + chr; - hash |= 0; // Convert to 32bit integer - } - return hash; - }; - return NumberUtils; - }()); - egret.NumberUtils = NumberUtils; - __reflect(NumberUtils.prototype, "egret.NumberUtils"); -})(egret || (egret = {})); -/** - * @private - */ -var egret_sin_map = {}; -/** - * @private - */ -var egret_cos_map = {}; -/** - * @private - */ -var DEG_TO_RAD = Math.PI / 180; -for (var NumberUtils_i = 0; NumberUtils_i < 360; NumberUtils_i++) { - egret_sin_map[NumberUtils_i] = Math.sin(NumberUtils_i * DEG_TO_RAD); - egret_cos_map[NumberUtils_i] = Math.cos(NumberUtils_i * DEG_TO_RAD); -} -egret_sin_map[90] = 1; -egret_cos_map[90] = 0; -egret_sin_map[180] = 0; -egret_cos_map[180] = -1; -egret_sin_map[270] = -1; -egret_cos_map[270] = 0; -//对未提供bind的浏览器实现bind机制 -if (!Function.prototype.bind) { - Function.prototype.bind = function (oThis) { - if (typeof this !== "function") { - // closest thing possible to the ECMAScript 5 internal IsCallable function - egret.$error(1029); - } - var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function () { - }, fBound = function () { - return fToBind.apply(this instanceof fNOP && oThis - ? this - : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); - }; - fNOP.prototype = this.prototype; - fBound.prototype = new fNOP(); - return fBound; - }; -} -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the start() - * method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.
      - * You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. Depending - * on the framerate or the runtime environment (available memory and other factors), the runtime may dispatchEvent events at - * slightly offset intervals. - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - * @language en_US - */ - /** - * Timer 类是计时器的接口,它使您能按指定的时间序列运行代码。 - * 使用 start() 方法来启动计时器。为 timer 事件添加事件侦听器,以便将代码设置为按计时器间隔运行。 - * 可以创建 Timer 对象以运行一次或按指定间隔重复运行,从而按计划执行代码。 - * 根据 Egret 的帧速率或运行时环境(可用内存和其他因素),运行时调度事件的间隔可能稍有不同。 - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - * @language zh_CN - */ - var Timer = (function (_super) { - __extends(Timer, _super); - /** - * Constructs a new Timer object with the specified delay and repeatCount states. - * @param delay The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended. - * Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @param repeatCount Specifies the number of repetitions. If zero, the timer repeats indefinitely.If nonzero, - * the timer runs the specified number of times and then stops. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 delay 和 repeatCount 状态构造新的 Timer 对象。 - * @param delay 计时器事件间的延迟(以毫秒为单位)。建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @param repeatCount 指定重复次数。如果为零,则计时器将持续不断重复运行。如果不为 0,则将运行计时器,运行次数为指定的次数,然后停止。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Timer(delay, repeatCount) { - if (repeatCount === void 0) { repeatCount = 0; } - var _this = _super.call(this) || this; - /** - * @private - */ - _this._delay = 0; - /** - * @private - */ - _this._currentCount = 0; - /** - * @private - */ - _this._running = false; - /** - * @private - */ - _this.updateInterval = 1000; - /** - * @private - */ - _this.lastCount = 1000; - /** - * @private - */ - _this.lastTimeStamp = 0; - _this.delay = delay; - _this.repeatCount = +repeatCount | 0; - return _this; - } - Object.defineProperty(Timer.prototype, "delay", { - /** - * The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended.
      - * Note: Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器事件间的延迟(以毫秒为单位)。如果在计时器正在运行时设置延迟间隔,则计时器将按相同的 repeatCount 迭代重新启动。
      - * 注意:建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._delay; - }, - set: function (value) { - if (value < 1) { - value = 1; - } - if (this._delay == value) { - return; - } - this._delay = value; - this.lastCount = this.updateInterval = Math.round(60 * value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Timer.prototype, "currentCount", { - /** - * The total number of times the timer has fired since it started at zero. If the timer has been reset, only the fires since the reset are counted. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器从 0 开始后触发的总次数。如果已重置了计时器,则只会计入重置后的触发次数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._currentCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Timer.prototype, "running", { - /** - * The timer's current state; true if the timer is running, otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器的当前状态;如果计时器正在运行,则为 true,否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._running; - }, - enumerable: true, - configurable: true - }); - /** - * Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch. - * Then, when start() is called, the timer instance runs for the specified number of repetitions, as set by the repeatCount value. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果计时器正在运行,则停止计时器,并将 currentCount 属性设回为 0,这类似于秒表的重置按钮。然后,在调用 start() 后,将运行计时器实例,运行次数为指定的重复次数(由 repeatCount 值设置)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Timer.prototype.reset = function () { - this.stop(); - this._currentCount = 0; - }; - /** - * Starts the timer, if it is not already running. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果计时器尚未运行,则启动计时器。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Timer.prototype.start = function () { - if (this._running) - return; - this.lastCount = this.updateInterval; - this.lastTimeStamp = egret.getTimer(); - egret.ticker.$startTick(this.$update, this); - this._running = true; - }; - /** - * Stops the timer. When start() is called after stop(), the timer instance runs for the remaining number of - * repetitions, as set by the repeatCount property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止计时器。如果在调用 stop() 后调用 start(),则将继续运行计时器实例,运行次数为剩余的 重复次数(由 repeatCount 属性设置)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Timer.prototype.stop = function () { - if (!this._running) - return; - egret.stopTick(this.$update, this); - this._running = false; - }; - /** - * @private - * Ticker以60FPS频率刷新此方法 - */ - Timer.prototype.$update = function (timeStamp) { - var deltaTime = timeStamp - this.lastTimeStamp; - if (deltaTime >= this._delay) { - this.lastCount = this.updateInterval; - } - else { - this.lastCount -= 1000; - if (this.lastCount > 0) { - return false; - } - this.lastCount += this.updateInterval; - } - this.lastTimeStamp = timeStamp; - this._currentCount++; - var complete = (this.repeatCount > 0 && this._currentCount >= this.repeatCount); - if (this.repeatCount == 0 || this._currentCount <= this.repeatCount) { - egret.TimerEvent.dispatchTimerEvent(this, egret.TimerEvent.TIMER); - } - if (complete) { - this.stop(); - egret.TimerEvent.dispatchTimerEvent(this, egret.TimerEvent.TIMER_COMPLETE); - } - return false; - }; - return Timer; - }(egret.EventDispatcher)); - egret.Timer = Timer; - __reflect(Timer.prototype, "egret.Timer"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - egret.$callLaterFunctionList = []; - /** - * @private - */ - egret.$callLaterThisList = []; - /** - * @private - */ - egret.$callLaterArgsList = []; - /** - * Delay the function to run unless screen is redrawn. - * @param method {Function} The function to be delayed to run - * @param thisObject {any} this reference of callback function - * @param ...args {any} Function parameter list - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - * @language en_US - */ - /** - * 延迟函数到屏幕重绘前执行。 - * @param method {Function} 要延迟执行的函数 - * @param thisObject {any} 回调函数的this引用 - * @param ...args {any} 函数参数列表 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - * @language zh_CN - */ - function callLater(method, thisObject) { - var args = []; - for (var _i = 2; _i < arguments.length; _i++) { - args[_i - 2] = arguments[_i]; - } - egret.$callLaterFunctionList.push(method); - egret.$callLaterThisList.push(thisObject); - egret.$callLaterArgsList.push(args); - } - egret.callLater = callLater; - /** - * @private - */ - egret.$callAsyncFunctionList = []; - /** - * @private - */ - egret.$callAsyncThisList = []; - /** - * @private - */ - egret.$callAsyncArgsList = []; - /** - * 异步调用函数 - * @param method {Function} 要异步调用的函数 - * @param thisObject {any} 函数的this引用 - * @param ...args {any} 函数参数列表 - * @private - */ - function $callAsync(method, thisObject) { - var args = []; - for (var _i = 2; _i < arguments.length; _i++) { - args[_i - 2] = arguments[_i]; - } - egret.$callAsyncFunctionList.push(method); - egret.$callAsyncThisList.push(thisObject); - egret.$callAsyncArgsList.push(args); - } - egret.$callAsync = $callAsync; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -//function __extends(d, b) { -// for (let p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; -// function __() { -// this.constructor = d; -// } -// -// __.prototype = b.prototype; -// d.prototype = new __(); -//} -var egret; -(function (egret) { - /** - * Call setter properties of the parent class, instead of the other writing languages, such as super.alpha = 1; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @param values Value passed to the parent class - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - * @language en_US - */ - /** - * 调用父类的setter属性,代替其他语言的写法,如 super.alpha = 1; - * @param currentClass 当前 class 类名,非字符串 - * @param thisObj 当前对象。永远都this - * @param type 需要调用的setter属性名称 - * @param values 传给父类的值 - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - * @language zh_CN - */ - function superSetter(currentClass, thisObj, type) { - var values = []; - for (var _i = 3; _i < arguments.length; _i++) { - values[_i - 3] = arguments[_i]; - } - var cla = currentClass.prototype; - var seters; - if (!currentClass.hasOwnProperty("__sets__")) { - Object.defineProperty(currentClass, "__sets__", { "value": {} }); - } - seters = currentClass["__sets__"]; - var setF = seters[type]; - if (setF) { - return setF.apply(thisObj, values); - } - var d = Object.getPrototypeOf(cla); - if (d == null) { - return; - } - while (!d.hasOwnProperty(type)) { - d = Object.getPrototypeOf(d); - if (d == null) { - return; - } - } - setF = Object.getOwnPropertyDescriptor(d, type).set; - seters[type] = setF; - setF.apply(thisObj, values); - } - egret.superSetter = superSetter; - /** - * Get getter property value of the parent class. Instead of writing in other languages, such as super.alpha; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @returns {any} The value returned by the parent - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - * @language en_US - */ - /** - * 获取父类的getter属性值。代替其他语言的写法,如 super.alpha; - * @param currentClass 当前 class 类名,非字符串 - * @param thisObj 当前对象。永远都this - * @param type 需要调用的getter属性名称 - * @returns {any} 父类返回的值 - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - * @language zh_CN - */ - function superGetter(currentClass, thisObj, type) { - var cla = currentClass.prototype; - var geters; - if (!currentClass.hasOwnProperty("__gets__")) { - Object.defineProperty(currentClass, "__gets__", { "value": {} }); - } - geters = currentClass["__gets__"]; - var getF = geters[type]; - if (getF) { - return getF.call(thisObj); - } - var d = Object.getPrototypeOf(cla); - if (d == null) { - return; - } - while (!d.hasOwnProperty(type)) { - d = Object.getPrototypeOf(d); - if (d == null) { - return; - } - } - getF = Object.getOwnPropertyDescriptor(d, type).get; - geters[type] = getF; - return getF.call(thisObj); - } - egret.superGetter = superGetter; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - var getDefinitionByNameCache = {}; - /** - * Returns a reference to the class object of the class specified by the name parameter. - * @param name The name of a class. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - * @language en_US - */ - /** - * 返回 name 参数指定的类的类对象引用。 - * @param name 类的名称。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - * @language zh_CN - */ - function getDefinitionByName(name) { - if (!name) - return null; - var definition = getDefinitionByNameCache[name]; - if (definition) { - return definition; - } - var paths = name.split("."); - var length = paths.length; - definition = global; - for (var i = 0; i < length; i++) { - var path = paths[i]; - definition = definition[path]; - if (!definition) { - return null; - } - } - getDefinitionByNameCache[name] = definition; - return definition; - } - egret.getDefinitionByName = getDefinitionByName; - if (true) { - egret["cleanCache"] = function () { - getDefinitionByNameCache = {}; - }; - } -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Return the fully qualified class name of an object - * @param value The object for which a fully qualified class name is desired. Any JavaScript value may be passed to - * this method including all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A string containing the fully qualified class name. - * @example - *
      -     *  egret.getQualifiedClassName(egret.DisplayObject) //return "egret.DisplayObject"
      -     * 
      - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - * @language en_US - */ - /** - * 返回对象的完全限定类名。 - * @param value 需要完全限定类名称的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型 - * (如number)和类对象 - * @returns 包含完全限定类名称的字符串。 - * @example - *
      -     *  egret.getQualifiedClassName(egret.DisplayObject) //返回 "egret.DisplayObject"
      -     * 
      - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - * @language zh_CN - */ - function getQualifiedClassName(value) { - var type = typeof value; - if (!value || (type != "object" && !value.prototype)) { - return type; - } - var prototype = value.prototype ? value.prototype : Object.getPrototypeOf(value); - if (prototype.hasOwnProperty("__class__")) { - return prototype["__class__"]; - } - var constructorString = prototype.constructor.toString().trim(); - var index = constructorString.indexOf("("); - var className = constructorString.substring(9, index); - Object.defineProperty(prototype, "__class__", { - value: className, - enumerable: false, - writable: true - }); - return className; - } - egret.getQualifiedClassName = getQualifiedClassName; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Returns the fully qualified class name of the base class of the object specified by the value parameter. - * @param value The object for which a parent class is desired. Any JavaScript value may be passed to this method including - * all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A fully qualified base class name, or null if none exists. - * @example - *
      -     *  egret.getQualifiedSuperclassName(egret.Bitmap) //return "egret.DisplayObject"
      -     * 
      - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts - * @language en_US - */ - /** - * 返回 value 参数指定的对象的基类的完全限定类名。 - * @param value 需要取得父类的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型(如number)和类对象 - * @returns 完全限定的基类名称,或 null(如果不存在基类名称)。 - * @example - *
      -     *  egret.getQualifiedSuperclassName(egret.Sprite) //返回 "egret.DisplayObject"
      -     * 
      - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts - * @language zh_CN - */ - function getQualifiedSuperclassName(value) { - if (!value || (typeof value != "object" && !value.prototype)) { - return null; - } - var prototype = value.prototype ? value.prototype : Object.getPrototypeOf(value); - var superProto = Object.getPrototypeOf(prototype); - if (!superProto) { - return null; - } - var superClass = egret.getQualifiedClassName(superProto.constructor); - if (!superClass) { - return null; - } - return superClass; - } - egret.getQualifiedSuperclassName = getQualifiedSuperclassName; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Used to compute relative time.this method returns the number of milliseconds since the Egret framework was initialized - * @returns The number of milliseconds since the Egret framework was initialized - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getTimer.ts - * @language en_US - */ - /** - * 用于计算相对时间。此方法返回自启动 Egret 框架以来经过的毫秒数。 - * @returns 启动 Egret 框架以来经过的毫秒数。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getTimer.ts - * @language zh_CN - */ - function getTimer() { - return Date.now() - egret.sys.$START_TIME; - } - egret.getTimer = getTimer; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Check whether a public definition exists in the specified application domain. The definition can be that of a class, a naming space or a function. - * @param name {string} Name of the definition. - * @returns {boolean} Whether the public definition exists - * @example - * egret.hasDefinition("egret.DisplayObject") //return true - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts - * @language en_US - */ - /** - * 检查指定的应用程序域之内是否存在一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。 - * @param name {string} 定义的名称。 - * @returns {boolean} 公共定义是否存在 - * @example - * egret.hasDefinition("egret.DisplayObject") //返回 true - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts - * @language zh_CN - */ - function hasDefinition(name) { - var definition = egret.getDefinitionByName(name); - return definition ? true : false; - } - egret.hasDefinition = hasDefinition; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Indicates whether an object is a instance of the class or interface specified as the parameter.This method has better performance - * compared width the instanceOf operator,and it can indicate whether an object is a instance of the specific interface. - * @param instance the instance to be checked. - * @param typeName the string value representing a specific class or interface. - * @returns A value of true if the object is a instance of the class or interface specified as the parameter. - * @example - *
      -     *     let instance = new egret.Sprite();
      -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
      -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
      -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
      -     * 
      - * @see egret.registerClass() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查指定对象是否为 Egret 框架内指定接口或类或其子类的实例。此方法与使用 instanceOf 关键字相比具有更高的性能,并且能判断接口的实现。 - * @param instance 要判断的实例。 - * @param typeName 类或接口的完全名称. - * @returns 返回true表示当前对象是指定类或接口的实例。 - * @example - *
      -     *     let instance = new egret.Sprite();
      -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
      -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
      -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
      -     * 
      - * @see egret.registerClass() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function is(instance, typeName) { - if (!instance || typeof instance != "object") { - return false; - } - var prototype = Object.getPrototypeOf(instance); - var types = prototype ? prototype.__types__ : null; - if (!types) { - return false; - } - return (types.indexOf(typeName) !== -1); - } - egret.is = is; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Register and start a timer,which will notify the callback method at a rate of 60 FPS ,and pass the current time stamp as parameters.
      - * Note: After the registration,it will notify the callback method continuously,you can call the stopTick () method to stop it. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 注册并启动一个计时器,通常会以60FPS的速率触发回调方法,并传入当前时间戳。注意:注册后将会持续触发回调方法,若要停止回调,需要手动调用stopTick()方法。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function startTick(callBack, thisObject) { - if (true && !callBack) { - egret.$error(1003, "callBack"); - } - egret.ticker.$startTick(callBack, thisObject); - } - egret.startTick = startTick; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Stops the timer started by the egret.startTick() method. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止之前用 startTick() 方法启动的计时器。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function stopTick(callBack, thisObject) { - if (true && !callBack) { - egret.$error(1003, "callBack"); - } - egret.ticker.$stopTick(callBack, thisObject); - } - egret.stopTick = stopTick; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Transfer number to color character string - * @param value {number} color value ,such as 0xffffff - * @returns {string} Color character string, for example, #ffffff. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/toColorString.ts - * @language en_US - */ - /** - * 转换数字为颜色字符串 - * @param value {number} 颜色值,例如 0xffffff - * @returns {string} 颜色字符串,例如"#ffffff"。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/toColorString.ts - * @language zh_CN - */ - function toColorString(value) { - if (value < 0) - value = 0; - if (value > 16777215) - value = 16777215; - var color = value.toString(16).toUpperCase(); - while (color.length > 6) { - color = color.slice(1, color.length); - } - while (color.length < 6) { - color = "0" + color; - } - return "#" + color; - } - egret.toColorString = toColorString; -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// diff --git a/demo/libs/modules/egret/egret.min.js b/demo/libs/modules/egret/egret.min.js deleted file mode 100644 index 14bfe681..00000000 --- a/demo/libs/modules/egret/egret.min.js +++ /dev/null @@ -1,7 +0,0 @@ -var __reflect=this&&this.__reflect||function(t,e,i){t.__class__=e,i?i.push(e):i=[e],t.__types__=t.__types__?i.concat(t.__types__):i},__extends=this&&this.__extends||function(t,e){function i(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);i.prototype=e.prototype,t.prototype=new i};if("undefined"==typeof global)var global=window;if("undefined"==typeof __global)var __global=global;var __define=this&&this.__define||function(t,e,i,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:i,set:r})},egret;!function(t){t.$hashCount=1;var e=function(){function e(){this.$hashCode=t.$hashCount++}return Object.defineProperty(e.prototype,"hashCode",{get:function(){return this.$hashCode},enumerable:!0,configurable:!0}),e}();t.HashObject=e,__reflect(e.prototype,"egret.HashObject",["egret.IHashObject"])}(egret||(egret={}));var egret;!function(t){var e=[],i=function(i){function r(t){void 0===t&&(t=null);var e=i.call(this)||this;return e.$EventDispatcher={0:t?t:e,1:{},2:{},3:0},e}return __extends(r,i),r.prototype.$getEventMap=function(t){var e=this.$EventDispatcher,i=t?e[2]:e[1];return i},r.prototype.addEventListener=function(t,e,i,r,n){this.$addListener(t,e,i,r,n)},r.prototype.once=function(t,e,i,r,n){this.$addListener(t,e,i,r,n,!0)},r.prototype.$addListener=function(t,e,i,r,n,a){var o=this.$EventDispatcher,s=r?o[2]:o[1],h=s[t];h?0!==o[3]&&(s[t]=h=h.concat()):h=s[t]=[],this.$insertEventBin(h,t,e,i,r,n,a)},r.prototype.$insertEventBin=function(t,e,i,r,n,a,o){a=0|+a;for(var s=-1,h=t.length,c=0;h>c;c++){var l=t[c];if(l.listener==i&&l.thisObject==r&&l.target==this)return!1;-1==s&&l.priorityn;n++){var a=t[n];if(a.listener==e&&a.thisObject==i&&a.target==this)return t.splice(n,1),!0}return!1},r.prototype.hasEventListener=function(t){var e=this.$EventDispatcher;return!(!e[1][t]&&!e[2][t])},r.prototype.willTrigger=function(t){return this.hasEventListener(t)},r.prototype.dispatchEvent=function(t){return t.$currentTarget=this.$EventDispatcher[0],t.$setTarget(t.$currentTarget),this.$notifyListener(t,!1)},r.prototype.$notifyListener=function(t,i){var r=this.$EventDispatcher,n=i?r[2]:r[1],a=n[t.$type];if(!a)return!0;var o=a.length;if(0==o)return!0;var s=e;r[3]++;for(var h=0;o>h;h++){var c=a[h];if(c.listener.call(c.thisObject,t),c.dispatchOnce&&s.push(c),t.$isPropagationImmediateStopped)break}for(r[3]--;s.length;){var c=s.pop();c.target.removeEventListener(c.type,c.listener,c.thisObject,c.useCapture)}return!t.$isDefaultPrevented},r.prototype.dispatchEventWith=function(e,i,r,n){if(i||this.hasEventListener(e)){var a=t.Event.create(t.Event,e,i,n);a.data=r;var o=this.dispatchEvent(a);return t.Event.release(a),o}return!0},r}(t.HashObject);t.EventDispatcher=i,__reflect(i.prototype,"egret.EventDispatcher",["egret.IEventDispatcher"])}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.type=null,i.$id=null,i.paddingTop=0,i.paddingBottom=0,i.paddingLeft=0,i.paddingRight=0,i.$uniforms={},t.nativeRender&&egret_native.NativeDisplayObject.createFilter(i),i}return __extends(i,e),i.prototype.$toJson=function(){return""},i.prototype.updatePadding=function(){},i.prototype.onPropertyChange=function(){var e=this;e.updatePadding(),t.nativeRender&&(egret_native.NativeDisplayObject.setFilterPadding(e.$id,e.paddingTop,e.paddingBottom,e.paddingLeft,e.paddingRight),egret_native.NativeDisplayObject.setDataToFilter(e))},i}(t.HashObject);t.Filter=e,__reflect(e.prototype,"egret.Filter")}(egret||(egret={}));var egret;!function(t){function e(t){return t%=360,t>180?t-=360:-180>t&&(t+=360),t}var i=function(i){function r(){var e=i.call(this)||this;return e.$children=null,e.$name="",e.$parent=null,e.$stage=null,e.$nestLevel=0,e.$useTranslate=!1,e.$matrix=new t.Matrix,e.$matrixDirty=!1,e.$x=0,e.$y=0,e.$scaleX=1,e.$scaleY=1,e.$rotation=0,e.$skewX=0,e.$skewXdeg=0,e.$skewY=0,e.$skewYdeg=0,e.$explicitWidth=0/0,e.$explicitHeight=0/0,e.$anchorOffsetX=0,e.$anchorOffsetY=0,e.$visible=!0,e.$displayList=null,e.$cacheAsBitmap=!1,e.$cacheDirty=!1,e.$alpha=1,e.$touchEnabled=r.defaultTouchEnabled,e.$scrollRect=null,e.$blendMode=0,e.$maskedObject=null,e.$mask=null,e.$maskRect=null,e.$parentDisplayList=null,e.$renderNode=null,e.$renderDirty=!1,e.$renderMode=null,e._tint=0,e.$tintRGB=0,e.$sortDirty=!1,e._zIndex=0,e.$lastSortedIndex=0,e.sortableChildren=!1,t.nativeRender&&e.createNativeDisplayObject(),e.tint=16777215,e}return __extends(r,i),r.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(0)},Object.defineProperty(r.prototype,"name",{get:function(){return this.$name},set:function(t){this.$name=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"parent",{get:function(){return this.$parent},enumerable:!0,configurable:!0}),r.prototype.$setParent=function(t){this.$parent=t},r.prototype.$onAddToStage=function(e,i){var r=this;r.$stage=e,r.$nestLevel=i,r.$hasAddToStage=!0,t.Sprite.$EVENT_ADD_TO_STAGE_LIST.push(r)},r.prototype.$onRemoveFromStage=function(){var e=this;e.$nestLevel=0,t.Sprite.$EVENT_REMOVE_FROM_STAGE_LIST.push(e)},r.prototype.$updateUseTransform=function(){var t=this;1==t.$scaleX&&1==t.$scaleY&&0==t.$skewX&&0==t.$skewY?t.$useTranslate=!1:t.$useTranslate=!0},Object.defineProperty(r.prototype,"stage",{get:function(){return this.$stage},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"matrix",{get:function(){return this.$getMatrix().clone()},set:function(t){this.$setMatrix(t)},enumerable:!0,configurable:!0}),r.prototype.$getMatrix=function(){var t=this;return t.$matrixDirty&&(t.$matrixDirty=!1,t.$matrix.$updateScaleAndRotation(t.$scaleX,t.$scaleY,t.$skewX,t.$skewY)),t.$matrix.tx=t.$x,t.$matrix.ty=t.$y,t.$matrix},r.prototype.$setMatrix=function(i,r){void 0===r&&(r=!0);var n=this,a=n.$matrix;a.a=i.a,a.b=i.b,a.c=i.c,a.d=i.d,n.$x=i.tx,n.$y=i.ty,n.$matrixDirty=!1,1==a.a&&0==a.b&&0==a.c&&1==a.d?n.$useTranslate=!1:n.$useTranslate=!0,r&&(n.$scaleX=a.$getScaleX(),n.$scaleY=a.$getScaleY(),n.$skewX=i.$getSkewX(),n.$skewY=i.$getSkewY(),n.$skewXdeg=e(180*n.$skewX/Math.PI),n.$skewYdeg=e(180*n.$skewY/Math.PI),n.$rotation=e(180*n.$skewY/Math.PI)),t.nativeRender&&n.$nativeDisplayObject.setMatrix(i.a,i.b,i.c,i.d,i.tx,i.ty)},r.prototype.$getConcatenatedMatrix=function(){var e=this,i=e.$concatenatedMatrix;i||(i=e.$concatenatedMatrix=new t.Matrix),e.$parent?e.$parent.$getConcatenatedMatrix().$preMultiplyInto(e.$getMatrix(),i):i.copyFrom(e.$getMatrix());var r=e.$anchorOffsetX,n=e.$anchorOffsetY,a=e.$scrollRect;return a?i.$preMultiplyInto(t.$TempMatrix.setTo(1,0,0,1,-a.x-r,-a.y-n),i):(0!=r||0!=n)&&i.$preMultiplyInto(t.$TempMatrix.setTo(1,0,0,1,-r,-n),i),e.$concatenatedMatrix},r.prototype.$getInvertedConcatenatedMatrix=function(){var e=this;return e.$invertedConcatenatedMatrix||(e.$invertedConcatenatedMatrix=new t.Matrix),e.$getConcatenatedMatrix().$invertInto(e.$invertedConcatenatedMatrix),e.$invertedConcatenatedMatrix},Object.defineProperty(r.prototype,"x",{get:function(){return this.$getX()},set:function(t){this.$setX(t)},enumerable:!0,configurable:!0}),r.prototype.$getX=function(){return this.$x},r.prototype.$setX=function(e){var i=this;if(i.$x==e)return!1;if(i.$x=e,t.nativeRender)i.$nativeDisplayObject.setX(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}return!0},Object.defineProperty(r.prototype,"y",{get:function(){return this.$getY()},set:function(t){this.$setY(t)},enumerable:!0,configurable:!0}),r.prototype.$getY=function(){return this.$y},r.prototype.$setY=function(e){var i=this;if(i.$y==e)return!1;if(i.$y=e,t.nativeRender)i.$nativeDisplayObject.setY(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}return!0},Object.defineProperty(r.prototype,"scaleX",{get:function(){return this.$getScaleX()},set:function(t){this.$setScaleX(t)},enumerable:!0,configurable:!0}),r.prototype.$getScaleX=function(){return this.$scaleX},r.prototype.$setScaleX=function(e){var i=this;if(i.$scaleX!=e)if(i.$scaleX=e,i.$matrixDirty=!0,i.$updateUseTransform(),t.nativeRender)i.$nativeDisplayObject.setScaleX(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"scaleY",{get:function(){return this.$getScaleY()},set:function(t){this.$setScaleY(t)},enumerable:!0,configurable:!0}),r.prototype.$getScaleY=function(){return this.$scaleY},r.prototype.$setScaleY=function(e){var i=this;if(i.$scaleY!=e)if(i.$scaleY=e,i.$matrixDirty=!0,i.$updateUseTransform(),t.nativeRender)i.$nativeDisplayObject.setScaleY(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"rotation",{get:function(){return this.$getRotation()},set:function(t){this.$setRotation(t)},enumerable:!0,configurable:!0}),r.prototype.$getRotation=function(){return this.$rotation},r.prototype.$setRotation=function(i){i=e(i);var r=this;if(i!=r.$rotation){var n=i-r.$rotation,a=n/180*Math.PI;if(r.$skewX+=a,r.$skewY+=a,r.$rotation=i,r.$matrixDirty=!0,r.$updateUseTransform(),t.nativeRender)r.$nativeDisplayObject.setRotation(i);else{var o=r.$parent;o&&!o.$cacheDirty&&(o.$cacheDirty=!0,o.$cacheDirtyUp());var s=r.$maskedObject;s&&!s.$cacheDirty&&(s.$cacheDirty=!0,s.$cacheDirtyUp())}}},Object.defineProperty(r.prototype,"skewX",{get:function(){return this.$skewXdeg},set:function(t){this.$setSkewX(t)},enumerable:!0,configurable:!0}),r.prototype.$setSkewX=function(i){var r=this;if(i!=r.$skewXdeg)if(r.$skewXdeg=i,i=e(i),i=i/180*Math.PI,r.$skewX=i,r.$matrixDirty=!0,r.$updateUseTransform(),t.nativeRender)r.$nativeDisplayObject.setSkewX(r.$skewXdeg);else{var n=r.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=r.$maskedObject;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"skewY",{get:function(){return this.$skewYdeg},set:function(t){this.$setSkewY(t)},enumerable:!0,configurable:!0}),r.prototype.$setSkewY=function(i){var r=this;if(i!=r.$skewYdeg)if(r.$skewYdeg=i,i=e(i),i=(i+r.$rotation)/180*Math.PI,r.$skewY=i,r.$matrixDirty=!0,r.$updateUseTransform(),t.nativeRender)r.$nativeDisplayObject.setSkewY(r.$skewYdeg);else{var n=r.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=r.$maskedObject;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"width",{get:function(){return this.$getWidth()},set:function(t){this.$setWidth(t)},enumerable:!0,configurable:!0}),r.prototype.$getWidth=function(){var t=this;return isNaN(t.$explicitWidth)?t.$getOriginalBounds().width:t.$explicitWidth},r.prototype.$setWidth=function(t){t=isNaN(t)?0/0:t,this.$explicitWidth!=t&&(this.$explicitWidth=t)},Object.defineProperty(r.prototype,"height",{get:function(){return this.$getHeight()},set:function(t){this.$setHeight(t)},enumerable:!0,configurable:!0}),r.prototype.$getHeight=function(){var t=this;return isNaN(t.$explicitHeight)?t.$getOriginalBounds().height:t.$explicitHeight},r.prototype.$setHeight=function(t){t=isNaN(t)?0/0:t,this.$explicitHeight!=t&&(this.$explicitHeight=t)},Object.defineProperty(r.prototype,"measuredWidth",{get:function(){return this.$getOriginalBounds().width},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"measuredHeight",{get:function(){return this.$getOriginalBounds().height},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"anchorOffsetX",{get:function(){return this.$anchorOffsetX},set:function(t){this.$setAnchorOffsetX(t)},enumerable:!0,configurable:!0}),r.prototype.$setAnchorOffsetX=function(e){var i=this;if(i.$anchorOffsetX!=e)if(i.$anchorOffsetX=e,t.nativeRender)i.$nativeDisplayObject.setAnchorOffsetX(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"anchorOffsetY",{get:function(){return this.$anchorOffsetY},set:function(t){this.$setAnchorOffsetY(t)},enumerable:!0,configurable:!0}),r.prototype.$setAnchorOffsetY=function(e){var i=this;if(i.$anchorOffsetY!=e)if(i.$anchorOffsetY=e,t.nativeRender)i.$nativeDisplayObject.setAnchorOffsetY(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"visible",{get:function(){return this.$visible},set:function(t){this.$setVisible(t)},enumerable:!0,configurable:!0}),r.prototype.$setVisible=function(e){var i=this;if(i.$visible!=e)if(i.$visible=e,t.nativeRender)i.$nativeDisplayObject.setVisible(e);else{i.$updateRenderMode();var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"cacheAsBitmap",{get:function(){return this.$cacheAsBitmap},set:function(e){var i=this;i.$cacheAsBitmap=e,t.nativeRender?i.$nativeDisplayObject.setCacheAsBitmap(e):i.$setHasDisplayList(e)},enumerable:!0,configurable:!0}),r.prototype.$setHasDisplayList=function(e){var i=this,r=!!i.$displayList;if(r!=e)if(e){var n=t.sys.DisplayList.create(i);n&&(i.$displayList=n,i.$cacheDirty=!0)}else i.$displayList=null},r.prototype.$cacheDirtyUp=function(){var t=this.$parent;t&&!t.$cacheDirty&&(t.$cacheDirty=!0,t.$cacheDirtyUp())},Object.defineProperty(r.prototype,"alpha",{get:function(){return this.$alpha},set:function(t){this.$setAlpha(t)},enumerable:!0,configurable:!0}),r.prototype.$setAlpha=function(e){var i=this;if(i.$alpha!=e)if(i.$alpha=e,t.nativeRender)i.$nativeDisplayObject.setAlpha(e);else{i.$updateRenderMode();var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"touchEnabled",{get:function(){return this.$getTouchEnabled()},set:function(t){this.$setTouchEnabled(t)},enumerable:!0,configurable:!0}),r.prototype.$getTouchEnabled=function(){return this.$touchEnabled},r.prototype.$setTouchEnabled=function(t){this.$touchEnabled=!!t},Object.defineProperty(r.prototype,"scrollRect",{get:function(){return this.$scrollRect},set:function(t){this.$setScrollRect(t)},enumerable:!0,configurable:!0}),r.prototype.$setScrollRect=function(e){var i=this;if(!e&&!i.$scrollRect)return void i.$updateRenderMode();if(e?(i.$scrollRect||(i.$scrollRect=new t.Rectangle),i.$scrollRect.copyFrom(e),t.nativeRender&&i.$nativeDisplayObject.setScrollRect(e.x,e.y,e.width,e.height)):(i.$scrollRect=null,t.nativeRender&&i.$nativeDisplayObject.setScrollRect(0,0,0,0)),!t.nativeRender){i.$updateRenderMode();var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(r.prototype,"blendMode",{get:function(){return t.sys.numberToBlendMode(this.$blendMode)},set:function(e){var i=this,r=t.sys.blendModeToNumber(e);if(i.$blendMode!=r)if(i.$blendMode=r,t.nativeRender)i.$nativeDisplayObject.setBlendMode(r);else{i.$updateRenderMode();var n=i.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=i.$maskedObject;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp())}},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"mask",{get:function(){var t=this;return t.$mask?t.$mask:t.$maskRect},set:function(e){var i=this;if(e!==i){if(e)if(e instanceof r){if(e==i.$mask)return;e.$maskedObject&&(e.$maskedObject.mask=null),e.$maskedObject=i,i.$mask=e,t.nativeRender||e.$updateRenderMode(),i.$maskRect&&(t.nativeRender&&i.$nativeDisplayObject.setMaskRect(0,0,0,0),i.$maskRect=null),t.nativeRender&&i.$nativeDisplayObject.setMask(e.$nativeDisplayObject.id)}else i.$maskRect||(i.$maskRect=new t.Rectangle),i.$maskRect.copyFrom(e),t.nativeRender&&i.$nativeDisplayObject.setMaskRect(e.x,e.y,e.width,e.height),i.$mask&&(i.$mask.$maskedObject=null,t.nativeRender||i.$mask.$updateRenderMode()),i.mask&&(t.nativeRender&&i.$nativeDisplayObject.setMask(-1),i.$mask=null);else i.$mask&&(i.$mask.$maskedObject=null,t.nativeRender||i.$mask.$updateRenderMode()),i.mask&&(t.nativeRender&&i.$nativeDisplayObject.setMask(-1),i.$mask=null),i.$maskRect&&(t.nativeRender&&i.$nativeDisplayObject.setMaskRect(0,0,0,0),i.$maskRect=null);t.nativeRender||i.$updateRenderMode()}},enumerable:!0,configurable:!0}),r.prototype.$setMaskRect=function(e){var i=this;(e||i.$maskRect)&&(e?(i.$maskRect||(i.$maskRect=new t.Rectangle),i.$maskRect.copyFrom(e)):i.$maskRect=null)},Object.defineProperty(r.prototype,"filters",{get:function(){return this.$filters},set:function(e){var i=this,r=i.$filters;if(r||e){if(e&&e.length?(e=e.concat(),i.$filters=e,t.nativeRender&&i.$nativeDisplayObject.setFilters(e)):(i.$filters=e,t.nativeRender&&i.$nativeDisplayObject.setFilters(null)),!t.nativeRender){i.$updateRenderMode();var n=i.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=i.$maskedObject;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp())}}else if(i.$filters=e,t.nativeRender)i.$nativeDisplayObject.setFilters(null);else{i.$updateRenderMode();var n=i.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=i.$maskedObject;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp())}},enumerable:!0,configurable:!0}),r.prototype.getTransformedBounds=function(t,e){return t=t||this,this.$getTransformedBounds(t,e)},r.prototype.getBounds=function(t,e){void 0===e&&(e=!0);var i=this;return t=i.$getTransformedBounds(i,t),e&&(0!=i.$anchorOffsetX&&(t.x-=i.$anchorOffsetX),0!=i.$anchorOffsetY&&(t.y-=i.$anchorOffsetY)),t},r.prototype.$getTransformedBounds=function(e,i){var r=this,n=r.$getOriginalBounds();if(i||(i=new t.Rectangle),i.copyFrom(n),e==r)return i;var a;if(e){a=t.$TempMatrix;var o=e.$getInvertedConcatenatedMatrix();o.$preMultiplyInto(r.$getConcatenatedMatrix(),a)}else a=r.$getConcatenatedMatrix();return a.$transformBounds(i),i},r.prototype.globalToLocal=function(e,i,r){if(void 0===e&&(e=0),void 0===i&&(i=0),t.nativeRender){egret_native.updateNativeRender();var n=egret_native.nrGlobalToLocal(this.$nativeDisplayObject.id,e,i),a=n.split(","),o=parseFloat(a[0]),s=parseFloat(a[1]);return r?r.setTo(o,s):r=new t.Point(o,s),r}var h=this.$getInvertedConcatenatedMatrix();return h.transformPoint(e,i,r)},r.prototype.localToGlobal=function(e,i,r){if(void 0===e&&(e=0),void 0===i&&(i=0),t.nativeRender){egret_native.updateNativeRender();var n=egret_native.nrLocalToGlobal(this.$nativeDisplayObject.id,e,i),a=n.split(","),o=parseFloat(a[0]),s=parseFloat(a[1]);return r?r.setTo(o,s):r=new t.Point(o,s),r}var h=this.$getConcatenatedMatrix();return h.transformPoint(e,i,r)},r.prototype.$getOriginalBounds=function(){var t=this,e=t.$getContentBounds();t.$measureChildBounds(e);var i=t.$measureFiltersOffset(!1);return i&&(e.x+=i.minX,e.y+=i.minY,e.width+=-i.minX+i.maxX,e.height+=-i.minY+i.maxY),e},r.prototype.$measureChildBounds=function(t){},r.prototype.$getContentBounds=function(){var e=t.$TempRectangle;return e.setEmpty(),this.$measureContentBounds(e),e},r.prototype.$measureContentBounds=function(t){},r.prototype.$getRenderNode=function(){var t=this,e=t.$renderNode;return e?(t.$renderDirty&&(e.cleanBeforeRender(),t.$updateRenderNode(),t.$renderDirty=!1,e=t.$renderNode),e):null},r.prototype.$updateRenderMode=function(){var t=this;!t.$visible||t.$alpha<=0||t.$maskedObject?t.$renderMode=1:t.filters&&t.filters.length>0?t.$renderMode=2:0!==t.$blendMode||t.$mask&&t.$mask.$stage?t.$renderMode=3:t.$scrollRect||t.$maskRect?t.$renderMode=4:t.$renderMode=null},r.prototype.$measureFiltersOffset=function(e){for(var i=this,r=0,n=0,a=0,o=0;i;){var s=i.$filters;if(s&&s.length)for(var h=s.length,c=0;h>c;c++){var l=s[c];if("blur"==l.type){var u=l.blurX,p=l.blurY;r-=u,n-=p,a+=u,o+=p}else if("glow"==l.type){var u=l.blurX,p=l.blurY;r-=u,n-=p,a+=u,o+=p;var d=l.distance||0,f=l.angle||0,g=0,$=0;0!=d&&(g=d*t.NumberUtils.cos(f),g=g>0?Math.ceil(g):Math.floor(g),$=d*t.NumberUtils.sin(f),$=$>0?Math.ceil($):Math.floor($),r+=g,a+=g,n+=$,o+=$)}else if("custom"==l.type){var y=l.padding;r-=y,n-=y,a+=y,o+=y}}i=e?i.$parent:null}return r=Math.min(r,0),n=Math.min(n,0),a=Math.max(a,0),o=Math.max(o,0),{minX:r,minY:n,maxX:a,maxY:o}},r.prototype.$getConcatenatedMatrixAt=function(e,i){var r=e.$getInvertedConcatenatedMatrix();if(0===r.a||0===r.d){var n=this,a=e.$nestLevel;for(i.identity();n.$nestLevel>a;){var o=n.$scrollRect;o&&i.concat(t.$TempMatrix.setTo(1,0,0,1,-o.x,-o.y)),i.concat(n.$getMatrix()),n=n.$parent}}else r.$preMultiplyInto(i,i)},r.prototype.$updateRenderNode=function(){},r.prototype.$hitTest=function(e,i){var r=this;if(!t.nativeRender&&!r.$renderNode||!r.$visible||0==r.$scaleX||0==r.$scaleY)return null;var n=r.$getInvertedConcatenatedMatrix();if(0==n.a&&0==n.b&&0==n.c&&0==n.d)return null;var a=r.$getContentBounds(),o=n.a*e+n.c*i+n.tx,s=n.b*e+n.d*i+n.ty;if(a.contains(o,s)){if(!r.$children){var h=r.$scrollRect?r.$scrollRect:r.$maskRect;if(h&&!h.contains(o,s))return null;if(r.$mask&&!r.$mask.$hitTest(e,i))return null}return r}return null},r.prototype.hitTestPoint=function(e,i,r){var n=this;if(r){var a=n.$getInvertedConcatenatedMatrix(),o=a.a*e+a.c*i+a.tx,s=a.b*e+a.d*i+a.ty,h=void 0;if(t.nativeRender){var c=t.sys.customHitTestBuffer;c.resize(3,3),egret_native.forHitTest=!0,egret_native.activateBuffer(c),egret_native.updateNativeRender(),egret_native.nrRenderDisplayObject2(n.$nativeDisplayObject.id,1-o,1-s,!0);try{h=new Uint8Array(4),egret_native.nrGetPixels(1,1,1,1,h)}catch(l){throw new Error(t.sys.tr(1039))}return egret_native.activateBuffer(null),egret_native.forHitTest=!1,0===h[3]?!1:!0}var u=n.$displayList;if(u){var c=u.renderBuffer;try{h=c.getPixels(o-u.offsetX,s-u.offsetY)}catch(l){throw new Error(t.sys.tr(1039))}}else{var c=t.sys.customHitTestBuffer;c.resize(3,3);var p=t.Matrix.create();p.identity(),p.translate(1-o,1-s),t.sys.systemRenderer.render(this,c,p,!0),t.Matrix.release(p);try{h=c.getPixels(1,1)}catch(l){throw new Error(t.sys.tr(1039))}}return 0===h[3]?!1:!0}if(0==n.$scaleX||0==n.$scaleY)return!1;var a=n.$getInvertedConcatenatedMatrix(),d=n.getBounds(null,!1),o=a.a*e+a.c*i+a.tx,s=a.b*e+a.d*i+a.ty;if(d.contains(o,s)){var f=n.$scrollRect?n.$scrollRect:n.$maskRect;return f&&!f.contains(o,s)?!1:!0}return!1},r.prototype.$addListener=function(e,n,a,o,s,h){i.prototype.$addListener.call(this,e,n,a,o,s,h);var c=e==t.Event.ENTER_FRAME;if(c||e==t.Event.RENDER){var l=c?r.$enterFrameCallBackList:r.$renderCallBackList;-1==l.indexOf(this)&&l.push(this)}},r.prototype.removeEventListener=function(e,n,a,o){i.prototype.removeEventListener.call(this,e,n,a,o);var s=e==t.Event.ENTER_FRAME;if((s||e==t.Event.RENDER)&&!this.hasEventListener(e)){var h=s?r.$enterFrameCallBackList:r.$renderCallBackList,c=h.indexOf(this);-1!==c&&h.splice(c,1)}},r.prototype.dispatchEvent=function(t){if(!t.$bubbles)return i.prototype.dispatchEvent.call(this,t);var e=this.$getPropagationList(this),r=.5*e.length;return t.$setTarget(this),this.$dispatchPropagationEvent(t,e,r),!t.$isDefaultPrevented},r.prototype.$getPropagationList=function(t){for(var e=[];t;)e.push(t),t=t.$parent;var i=e.concat();return i.reverse(),e=i.concat(e)},r.prototype.$dispatchPropagationEvent=function(t,e,i){for(var r=e.length,n=i-1,a=0;r>a;a++){var o=e[a];if(t.$currentTarget=o,n>a?t.$eventPhase=1:a==i||a==n?t.$eventPhase=2:t.$eventPhase=3,o.$notifyListener(t,i>a),t.$isPropagationStopped||t.$isPropagationImmediateStopped)return}},r.prototype.willTrigger=function(t){for(var e=this;e;){if(e.hasEventListener(t))return!0;e=e.$parent}return!1},Object.defineProperty(r.prototype,"tint",{get:function(){return this._tint},set:function(t){this._tint=t,this.$tintRGB=(t>>16)+(65280&t)+((255&t)<<16)},enumerable:!0,configurable:!0}),r.prototype.sortChildren=function(){this.$sortDirty=!1},Object.defineProperty(r.prototype,"zIndex",{get:function(){return this._zIndex},set:function(t){this._zIndex=t,this.parent&&(this.parent.$sortDirty=!0)},enumerable:!0,configurable:!0}),r.defaultTouchEnabled=!1,r.$enterFrameCallBackList=[],r.$renderCallBackList=[],r}(t.EventDispatcher);t.DisplayObject=i,__reflect(i.prototype,"egret.DisplayObject")}(egret||(egret={}));var egret;!function(t){t.$TextureScaleFactor=1;var e=function(e){function i(){var t=e.call(this)||this;return t.disposeBitmapData=!0,t.$bitmapX=0,t.$bitmapY=0,t.$bitmapWidth=0,t.$bitmapHeight=0,t.$offsetX=0,t.$offsetY=0,t.$textureWidth=0,t.$textureHeight=0,t.$sourceWidth=0,t.$sourceHeight=0,t.$bitmapData=null,t.$ktxData=null,t.$rotated=!1,t}return __extends(i,e),Object.defineProperty(i.prototype,"textureWidth",{get:function(){return this.$getTextureWidth()},enumerable:!0,configurable:!0}),i.prototype.$getTextureWidth=function(){return this.$textureWidth},Object.defineProperty(i.prototype,"textureHeight",{get:function(){return this.$getTextureHeight()},enumerable:!0,configurable:!0}),i.prototype.$getTextureHeight=function(){return this.$textureHeight},i.prototype.$getScaleBitmapWidth=function(){return this.$bitmapWidth*t.$TextureScaleFactor},i.prototype.$getScaleBitmapHeight=function(){return this.$bitmapHeight*t.$TextureScaleFactor},Object.defineProperty(i.prototype,"bitmapData",{get:function(){return this.$bitmapData},set:function(t){this.$ktxData=null,this._setBitmapData(t)},enumerable:!0,configurable:!0}),i.prototype._setBitmapData=function(e){this.$bitmapData=e;var i=t.$TextureScaleFactor,r=e.width*i,n=e.height*i;this.$initData(0,0,r,n,0,0,r,n,e.width,e.height)},Object.defineProperty(i.prototype,"ktxData",{get:function(){return this.$ktxData},set:function(t){this._setKtxData(t)},enumerable:!0,configurable:!0}),i.prototype._setKtxData=function(e){if(!e)return void t.error("ktx data is null");if(e!=this.$ktxData){var i=new t.KTXContainer(e,1);if(i.isInvalid)return void t.error("ktx data is invalid");this.$ktxData=e;var r=new t.BitmapData(e);r.format="ktx",i.uploadLevels(r,!1),this._setBitmapData(r)}},i.prototype.$initData=function(e,i,r,n,a,o,s,h,c,l,u){void 0===u&&(u=!1);var p=t.$TextureScaleFactor;this.$bitmapX=e/p,this.$bitmapY=i/p,this.$bitmapWidth=r/p,this.$bitmapHeight=n/p,this.$offsetX=a,this.$offsetY=o,this.$textureWidth=s,this.$textureHeight=h,this.$sourceWidth=c,this.$sourceHeight=l,this.$rotated=u,t.BitmapData.$invalidate(this.$bitmapData)},i.prototype.getPixel32=function(t,e){throw new Error},i.prototype.getPixels=function(t,e,i,r){throw void 0===i&&(i=1),void 0===r&&(r=1),new Error},i.prototype.toDataURL=function(t,e,i){throw new Error},i.prototype.saveToFile=function(t,e,i){throw new Error},i.prototype.dispose=function(){this.$bitmapData&&(this.disposeBitmapData&&this.$bitmapData.$dispose(),this.$bitmapData=null)},i}(t.HashObject);t.Texture=e,__reflect(e.prototype,"egret.Texture")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i,r,n){var a=t.call(this)||this;return a.$eventPhase=2,a.$currentTarget=null,a.$target=null,a.$isDefaultPrevented=!1,a.$isPropagationStopped=!1,a.$isPropagationImmediateStopped=!1,a.$type=e,a.$bubbles=!!i,a.$cancelable=!!r,a.data=n,a}return __extends(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return this.$type},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bubbles",{get:function(){return this.$bubbles},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cancelable",{get:function(){return this.$cancelable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"eventPhase",{get:function(){return this.$eventPhase},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentTarget",{get:function(){return this.$currentTarget},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this.$target},enumerable:!0,configurable:!0}),e.prototype.$setTarget=function(t){return this.$target=t,!0},e.prototype.isDefaultPrevented=function(){return this.$isDefaultPrevented},e.prototype.preventDefault=function(){this.$cancelable&&(this.$isDefaultPrevented=!0)},e.prototype.stopPropagation=function(){this.$bubbles&&(this.$isPropagationStopped=!0)},e.prototype.stopImmediatePropagation=function(){this.$bubbles&&(this.$isPropagationImmediateStopped=!0)},e.prototype.clean=function(){this.data=this.$currentTarget=null,this.$setTarget(null)},e.dispatchEvent=function(t,i,r,n){void 0===r&&(r=!1);var a=e.create(e,i,r),o=e._getPropertyData(e);void 0!=n&&(o.data=n);var s=t.dispatchEvent(a);return e.release(a),s},e._getPropertyData=function(t){var e=t._props;return e||(e=t._props={}),e},e.create=function(t,e,i,r){var n,a=t.hasOwnProperty("eventPool");if(a&&(n=t.eventPool),n||(n=t.eventPool=[]),n.length){var o=n.pop();return o.$type=e,o.$bubbles=!!i,o.$cancelable=!!r,o.$isDefaultPrevented=!1,o.$isPropagationStopped=!1,o.$isPropagationImmediateStopped=!1,o.$eventPhase=2,o}return new t(e,i,r)},e.release=function(t){t.clean();var e=Object.getPrototypeOf(t).constructor;e.eventPool.push(t)},e.ADDED_TO_STAGE="addedToStage",e.REMOVED_FROM_STAGE="removedFromStage",e.ADDED="added",e.REMOVED="removed",e.ENTER_FRAME="enterFrame",e.RENDER="render",e.RESIZE="resize",e.CHANGE="change",e.CHANGING="changing",e.COMPLETE="complete",e.LOOP_COMPLETE="loopComplete",e.FOCUS_IN="focusIn",e.FOCUS_OUT="focusOut",e.ENDED="ended",e.ACTIVATE="activate",e.DEACTIVATE="deactivate",e.CLOSE="close",e.CONNECT="connect",e.LEAVE_STAGE="leaveStage",e.SOUND_COMPLETE="soundComplete",e}(t.HashObject);t.Event=e,__reflect(e.prototype,"egret.Event")}(egret||(egret={}));var egret;!function(t){function e(){return""}function i(t){throw new Error("#"+t)}function r(){}function n(){}t.getString=e,t.$error=i,t.$warn=r,t.$markCannotUse=n}(egret||(egret={}));var egret;!function(t){var e=[],i=Math.PI/180,r=function(r){function n(t,e){void 0===t&&(t=0),void 0===e&&(e=0);var i=r.call(this)||this;return i.x=t,i.y=e,i}return __extends(n,r),n.release=function(t){t&&e.push(t)},n.create=function(t,i){var r=e.pop();return r||(r=new n),r.setTo(t,i)},Object.defineProperty(n.prototype,"length",{get:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},enumerable:!0,configurable:!0}),n.prototype.setTo=function(t,e){return this.x=t,this.y=e,this},n.prototype.clone=function(){return new n(this.x,this.y)},n.prototype.equals=function(t){return this.x==t.x&&this.y==t.y},n.distance=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},n.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},n.prototype.add=function(t){return new n(this.x+t.x,this.y+t.y)},n.interpolate=function(t,e,i){var r=1-i;return new n(t.x*i+e.x*r,t.y*i+e.y*r)},n.prototype.normalize=function(t){if(0!=this.x||0!=this.y){var e=t/this.length;this.x*=e,this.y*=e}},n.prototype.offset=function(t,e){this.x+=t,this.y+=e},n.polar=function(e,r){return new n(e*t.NumberUtils.cos(r/i),e*t.NumberUtils.sin(r/i))},n.prototype.subtract=function(t){return new n(this.x-t.x,this.y-t.y)},n.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")"},n}(t.HashObject);t.Point=r,__reflect(r.prototype,"egret.Point"),t.$TempPoint=new r}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.$touchChildren=!0,t.$children=[],t}return __extends(i,e),Object.defineProperty(i.prototype,"numChildren",{get:function(){return this.$children.length},enumerable:!0,configurable:!0}),i.prototype.setChildrenSortMode=function(e){t.nativeRender&&this.$nativeDisplayObject.setChildrenSortMode&&this.$nativeDisplayObject.setChildrenSortMode(e) -},i.prototype.addChild=function(t){var e=this.$children.length;return t.$parent==this&&e--,this.$doAddChild(t,e)},i.prototype.addChildAt=function(t,e){return e=0|+e,(0>e||e>=this.$children.length)&&(e=this.$children.length,t.$parent==this&&e--),this.$doAddChild(t,e)},i.prototype.$doAddChild=function(e,r,n){void 0===n&&(n=!0);var a=this,o=e.$parent;if(o==a)return a.doSetChildIndex(e,r),e;o&&o.removeChild(e),a.$children.splice(r,0,e),e.$setParent(a),t.nativeRender&&a.$nativeDisplayObject.addChildAt(e.$nativeDisplayObject.id,r);var s=a.$stage;if(s&&e.$onAddToStage(s,a.$nestLevel+1),n&&e.dispatchEventWith(t.Event.ADDED,!0),s)for(var h=i.$EVENT_ADD_TO_STAGE_LIST;h.length;){var c=h.shift();c.$stage&&n&&c.dispatchEventWith(t.Event.ADDED_TO_STAGE)}if(!t.nativeRender&&(e.$maskedObject&&e.$maskedObject.$updateRenderMode(),!a.$cacheDirty)){a.$cacheDirty=!0;var l=a.$parent;l&&!l.$cacheDirty&&(l.$cacheDirty=!0,l.$cacheDirtyUp());var u=a.$maskedObject;u&&!u.$cacheDirty&&(u.$cacheDirty=!0,u.$cacheDirtyUp())}return this.$childAdded(e,r),e},i.prototype.contains=function(t){for(;t;){if(t==this)return!0;t=t.$parent}return!1},i.prototype.getChildAt=function(t){return t=0|+t,t>=0&&tn;n++)if(e=i[n],e.name==t)return e;return null},i.prototype.removeChild=function(t){var e=this.$children.indexOf(t);return e>=0?this.$doRemoveChild(e):null},i.prototype.removeChildAt=function(t){return t=0|+t,t>=0&&t0;){var h=s.shift();r&&h.$hasAddToStage&&(h.$hasAddToStage=!1,h.dispatchEventWith(t.Event.REMOVED_FROM_STAGE)),h.$hasAddToStage=!1,h.$stage=null}}this.$displayList||this.$parentDisplayList;o.$setParent(null);var c=a.indexOf(o);if(-1!=c&&a.splice(c,1),t.nativeRender)n.$nativeDisplayObject.removeChild(o.$nativeDisplayObject.id);else if(o.$maskedObject&&o.$maskedObject.$updateRenderMode(),!n.$cacheDirty){n.$cacheDirty=!0;var l=n.$parent;l&&!l.$cacheDirty&&(l.$cacheDirty=!0,l.$cacheDirtyUp());var u=n.$maskedObject;u&&!u.$cacheDirty&&(u.$cacheDirty=!0,u.$cacheDirtyUp())}return o},i.prototype.setChildIndex=function(t,e){e=0|+e,(0>e||e>=this.$children.length)&&(e=this.$children.length-1),this.doSetChildIndex(t,e)},i.prototype.doSetChildIndex=function(e,i){var r=this,n=this.$children.indexOf(e);if(n!=i)if(this.$childRemoved(e,n),this.$children.splice(n,1),this.$children.splice(i,0,e),this.$childAdded(e,i),t.nativeRender)this.$nativeDisplayObject.removeChild(e.$nativeDisplayObject.id),this.$nativeDisplayObject.addChildAt(e.$nativeDisplayObject.id,i);else if(!r.$cacheDirty){r.$cacheDirty=!0;var a=r.$parent;a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp());var o=r.$maskedObject;o&&!o.$cacheDirty&&(o.$cacheDirty=!0,o.$cacheDirtyUp())}},i.prototype.swapChildrenAt=function(t,e){t=0|+t,e=0|+e,t>=0&&t=0&&ei){var n=i;i=e,e=n}else if(e==i)return;var a=this.$children,o=a[e],s=a[i];if(this.$childRemoved(o,e),this.$childRemoved(s,i),a[e]=s,a[i]=o,this.$childAdded(s,e),this.$childAdded(o,i),t.nativeRender)this.$nativeDisplayObject.swapChild(e,i);else if(!r.$cacheDirty){r.$cacheDirty=!0;var h=r.$parent;h&&!h.$cacheDirty&&(h.$cacheDirty=!0,h.$cacheDirtyUp());var c=r.$maskedObject;c&&!c.$cacheDirty&&(c.$cacheDirty=!0,c.$cacheDirtyUp())}},i.prototype.removeChildren=function(){for(var t=this.$children,e=t.length-1;e>=0;e--)this.$doRemoveChild(e)},i.prototype.$childAdded=function(t,e){},i.prototype.$childRemoved=function(t,e){},i.prototype.$onAddToStage=function(t,i){e.prototype.$onAddToStage.call(this,t,i);var r=this.$children,n=r.length;i++;for(var a=0;n>a;a++){var o=this.$children[a];o.$onAddToStage(t,i),o.$maskedObject&&o.$maskedObject.$updateRenderMode()}},i.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this);for(var t=this.$children,i=t.length,r=0;i>r;r++){var n=t[r];n.$onRemoveFromStage()}},i.prototype.$measureChildBounds=function(e){var i=this.$children,r=i.length;if(0!=r){for(var n=0,a=0,o=0,s=0,h=!1,c=-1;r>c;c++){var l=void 0;-1==c?l=e:(i[c].getBounds(t.$TempRectangle),i[c].$getMatrix().$transformBounds(t.$TempRectangle),l=t.$TempRectangle),l.isEmpty()||(h?(n=Math.min(n,l.x),a=Math.max(a,l.x+l.width),o=Math.min(o,l.y),s=Math.max(s,l.y+l.height)):(h=!0,n=l.x,a=n+l.width,o=l.y,s=o+l.height))}e.setTo(n,o,a-n,s-o)}},Object.defineProperty(i.prototype,"touchChildren",{get:function(){return this.$getTouchChildren()},set:function(t){this.$setTouchChildren(!!t)},enumerable:!0,configurable:!0}),i.prototype.$getTouchChildren=function(){return this.$touchChildren},i.prototype.$setTouchChildren=function(t){return this.$touchChildren==t?!1:(this.$touchChildren=t,!0)},i.prototype.$hitTest=function(t,i){if(!this.$visible)return null;var r=this.$getInvertedConcatenatedMatrix(),n=r.a*t+r.c*i+r.tx,a=r.b*t+r.d*i+r.ty,o=this.$scrollRect?this.$scrollRect:this.$maskRect;if(o&&!o.contains(n,a))return null;if(this.$mask&&!this.$mask.$hitTest(t,i))return null;for(var s=this.$children,h=!1,c=null,l=s.length-1;l>=0;l--){var u=s[l];if(!u.$maskedObject&&(c=u.$hitTest(t,i))){if(h=!0,c.$touchEnabled)break;c=null}}return c?this.$touchChildren?c:this:h?this:e.prototype.$hitTest.call(this,t,i)},i.prototype._sortChildrenFunc=function(t,e){return t.zIndex===e.zIndex?t.$lastSortedIndex-e.$lastSortedIndex:t.zIndex-e.zIndex},i.prototype.sortChildren=function(){e.prototype.sortChildren.call(this),this.$sortDirty=!1;for(var t=!1,i=this.$children,r=null,n=0,a=i.length;a>n;++n)r=i[n],r.$lastSortedIndex=n,t||0===r.zIndex||(t=!0);t&&i.length>1&&i.sort(this._sortChildrenFunc)},i.$EVENT_ADD_TO_STAGE_LIST=[],i.$EVENT_REMOVE_FROM_STAGE_LIST=[],i}(t.DisplayObject);t.DisplayObjectContainer=e,__reflect(e.prototype,"egret.DisplayObjectContainer")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(i){var r=e.call(this)||this;return r._bitmapX=0,r._bitmapY=0,r._textureMap=t.createMap(),r.$texture=i,r._bitmapX=i.$bitmapX-i.$offsetX,r._bitmapY=i.$bitmapY-i.$offsetY,r}return __extends(i,e),i.prototype.getTexture=function(t){return this._textureMap[t]},i.prototype.createTexture=function(e,i,r,n,a,o,s,h,c){void 0===o&&(o=0),void 0===s&&(s=0),void 0===h&&(h=o+n),void 0===c&&(c=s+a);var l=new t.Texture;return l.disposeBitmapData=!1,l.$bitmapData=this.$texture.$bitmapData,l.$initData(this._bitmapX+i,this._bitmapY+r,n,a,o,s,h,c,this.$texture.$sourceWidth,this.$texture.$sourceHeight),this._textureMap[e]=l,l},i.prototype.dispose=function(){this.$texture&&this.$texture.dispose()},i}(t.HashObject);t.SpriteSheet=e,__reflect(e.prototype,"egret.SpriteSheet")}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$language="en_US"}(egret||(egret={})),function(t){var e;!function(e){function i(e){for(var i=[],r=1;ro;o++)n=n.replace("{"+o+"}",i[o]);return n}e.tr=i}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(r){var n=e.call(this)||this;return n.$texture=null,n.$bitmapData=null,n.$bitmapX=0,n.$bitmapY=0,n.$bitmapWidth=0,n.$bitmapHeight=0,n.$offsetX=0,n.$offsetY=0,n.$textureWidth=0,n.$textureHeight=0,n.$sourceWidth=0,n.$sourceHeight=0,n.$smoothing=i.defaultSmoothing,n.$explicitBitmapWidth=0/0,n.$explicitBitmapHeight=0/0,n.$scale9Grid=null,n.$fillMode="scale",n._pixelHitTest=!1,n.$renderNode=new t.sys.NormalBitmapNode,n.$setTexture(r),r&&(n.$renderNode.rotated=r.$rotated),n}return __extends(i,e),i.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(1)},i.prototype.$onAddToStage=function(i,r){e.prototype.$onAddToStage.call(this,i,r);var n=this.$texture;n&&n.$bitmapData&&t.BitmapData.$addDisplayObject(this,n.$bitmapData)},i.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this);var i=this.$texture;i&&t.BitmapData.$removeDisplayObject(this,i.$bitmapData)},Object.defineProperty(i.prototype,"texture",{get:function(){return this.$texture},set:function(t){var e=this;e.$setTexture(t),t&&e.$renderNode&&(e.$renderNode.rotated=t.$rotated)},enumerable:!0,configurable:!0}),i.prototype.$setTexture=function(e){var i=this,r=i.$texture;if(e==r)return!1;if(i.$texture=e,!e){r&&t.BitmapData.$removeDisplayObject(i,r.$bitmapData),i.setImageData(null,0,0,0,0,0,0,0,0,0,0),i.$renderDirty=!0;var n=i.$parent;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp());var a=i.$maskedObject;return a&&!a.$cacheDirty&&(a.$cacheDirty=!0,a.$cacheDirtyUp()),t.nativeRender&&this.setBitmapDataToWasm(null),!0}if(i.$refreshImageData(),i.$stage){if(r&&r.$bitmapData){var o=r.$bitmapData.hashCode,s=e.$bitmapData?e.$bitmapData.hashCode:-1;if(o==s){i.$renderDirty=!0;var h=i.$parent;h&&!h.$cacheDirty&&(h.$cacheDirty=!0,h.$cacheDirtyUp());var c=i.$maskedObject;return c&&!c.$cacheDirty&&(c.$cacheDirty=!0,c.$cacheDirtyUp()),!0}t.BitmapData.$removeDisplayObject(i,r.$bitmapData)}t.BitmapData.$addDisplayObject(i,e.$bitmapData)}i.$renderDirty=!0;var l=i.$parent;l&&!l.$cacheDirty&&(l.$cacheDirty=!0,l.$cacheDirtyUp());var u=i.$maskedObject;return u&&!u.$cacheDirty&&(u.$cacheDirty=!0,u.$cacheDirtyUp()),!0},i.prototype.$setBitmapData=function(t){this.$setTexture(t)},i.prototype.setBitmapDataToWasm=function(t){this.$nativeDisplayObject.setTexture(t)},i.prototype.$refreshImageData=function(){var e=this.$texture;e?(t.nativeRender&&this.setBitmapDataToWasm(e),this.setImageData(e.$bitmapData,e.$bitmapX,e.$bitmapY,e.$bitmapWidth,e.$bitmapHeight,e.$offsetX,e.$offsetY,e.$getTextureWidth(),e.$getTextureHeight(),e.$sourceWidth,e.$sourceHeight)):t.nativeRender&&this.setBitmapDataToWasm(null)},i.prototype.setImageData=function(t,e,i,r,n,a,o,s,h,c,l){this.$bitmapData=t,this.$bitmapX=e,this.$bitmapY=i,this.$bitmapWidth=r,this.$bitmapHeight=n,this.$offsetX=a,this.$offsetY=o,this.$textureWidth=s,this.$textureHeight=h,this.$sourceWidth=c,this.$sourceHeight=l},Object.defineProperty(i.prototype,"scale9Grid",{get:function(){return this.$scale9Grid},set:function(t){this.$setScale9Grid(t)},enumerable:!0,configurable:!0}),i.prototype.$setScale9Grid=function(e){var i=this;if(i.$scale9Grid=e,i.$renderDirty=!0,t.nativeRender)e?i.$nativeDisplayObject.setScale9Grid(e.x,e.y,e.width,e.height):i.$nativeDisplayObject.setScale9Grid(0,0,-1,-1);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},Object.defineProperty(i.prototype,"fillMode",{get:function(){return this.$fillMode},set:function(t){this.$setFillMode(t)},enumerable:!0,configurable:!0}),i.prototype.$setFillMode=function(e){var i=this;if(e==i.$fillMode)return!1;if(i.$fillMode=e,t.nativeRender)i.$nativeDisplayObject.setBitmapFillMode(i.$fillMode);else{i.$renderDirty=!0;var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}return!0},Object.defineProperty(i.prototype,"smoothing",{get:function(){return this.$smoothing},set:function(e){var i=this;if(e!=this.$smoothing&&(this.$smoothing=e,this.$renderNode.smoothing=e,!t.nativeRender)){var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},enumerable:!0,configurable:!0}),i.prototype.$setWidth=function(e){var i=this;if(0>e||e==i.$explicitBitmapWidth)return!1;if(i.$explicitBitmapWidth=e,i.$renderDirty=!0,t.nativeRender)i.$nativeDisplayObject.setWidth(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}return!0},i.prototype.$setHeight=function(e){var i=this;if(0>e||e==i.$explicitBitmapHeight)return!1;if(i.$explicitBitmapHeight=e,i.$renderDirty=!0,t.nativeRender)i.$nativeDisplayObject.setHeight(e);else{var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}return!0},i.prototype.$getWidth=function(){return isNaN(this.$explicitBitmapWidth)?this.$getContentBounds().width:this.$explicitBitmapWidth},i.prototype.$getHeight=function(){return isNaN(this.$explicitBitmapHeight)?this.$getContentBounds().height:this.$explicitBitmapHeight},i.prototype.$measureContentBounds=function(t){if(this.$bitmapData){var e=isNaN(this.$explicitBitmapWidth)?this.$textureWidth:this.$explicitBitmapWidth,i=isNaN(this.$explicitBitmapHeight)?this.$textureHeight:this.$explicitBitmapHeight;t.setTo(0,0,e,i)}else{var e=isNaN(this.$explicitBitmapWidth)?0:this.$explicitBitmapWidth,i=isNaN(this.$explicitBitmapHeight)?0:this.$explicitBitmapHeight;t.setTo(0,0,e,i)}},i.prototype.$updateRenderNode=function(){if(this.$texture){var e=isNaN(this.$explicitBitmapWidth)?this.$textureWidth:this.$explicitBitmapWidth,i=isNaN(this.$explicitBitmapHeight)?this.$textureHeight:this.$explicitBitmapHeight,r=this.scale9Grid||this.$texture.scale9Grid;r?(this.$renderNode instanceof t.sys.NormalBitmapNode&&(this.$renderNode=new t.sys.BitmapNode),t.sys.BitmapNode.$updateTextureDataWithScale9Grid(this.$renderNode,this.$bitmapData,r,this.$bitmapX,this.$bitmapY,this.$bitmapWidth,this.$bitmapHeight,this.$offsetX,this.$offsetY,this.$textureWidth,this.$textureHeight,e,i,this.$sourceWidth,this.$sourceHeight,this.$smoothing)):(this.fillMode==t.BitmapFillMode.REPEAT&&this.$renderNode instanceof t.sys.NormalBitmapNode&&(this.$renderNode=new t.sys.BitmapNode),t.sys.BitmapNode.$updateTextureData(this.$renderNode,this.$bitmapData,this.$bitmapX,this.$bitmapY,this.$bitmapWidth,this.$bitmapHeight,this.$offsetX,this.$offsetY,this.$textureWidth,this.$textureHeight,e,i,this.$sourceWidth,this.$sourceHeight,this.$fillMode,this.$smoothing))}},Object.defineProperty(i.prototype,"pixelHitTest",{get:function(){return this._pixelHitTest},set:function(t){this._pixelHitTest=!!t},enumerable:!0,configurable:!0}),i.prototype.$hitTest=function(t,i){var r=e.prototype.$hitTest.call(this,t,i);if(r&&this._pixelHitTest){var n=this.hitTestPoint(t,i,!0);n||(r=null)}return r},i.defaultSmoothing=!0,i}(t.DisplayObject);t.Bitmap=e,__reflect(e.prototype,"egret.Bitmap")}(egret||(egret={}));var egret;!function(t){var e;!function(t){var e=function(){function t(){this.type=0,this.drawData=[],this.renderCount=0}return t.prototype.cleanBeforeRender=function(){this.drawData.length=0,this.renderCount=0},t.prototype.$getRenderCount=function(){return this.renderCount},t}();t.RenderNode=e,__reflect(e.prototype,"egret.sys.RenderNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){var e=function(){function t(){this.type=0,this.$commands=[],this.$data=[],this.commandPosition=0,this.dataPosition=0,this.$lastX=0,this.$lastY=0}return t.prototype.moveTo=function(t,e){this.$commands[this.commandPosition++]=1;var i=this.dataPosition;this.$data[i++]=t,this.$data[i++]=e,this.dataPosition=i},t.prototype.lineTo=function(t,e){this.$commands[this.commandPosition++]=2;var i=this.dataPosition;this.$data[i++]=t,this.$data[i++]=e,this.dataPosition=i},t.prototype.curveTo=function(t,e,i,r){this.$commands[this.commandPosition++]=3;var n=this.dataPosition;this.$data[n++]=t,this.$data[n++]=e,this.$data[n++]=i,this.$data[n++]=r,this.dataPosition=n},t.prototype.cubicCurveTo=function(t,e,i,r,n,a){this.$commands[this.commandPosition++]=4;var o=this.dataPosition;this.$data[o++]=t,this.$data[o++]=e,this.$data[o++]=i,this.$data[o++]=r,this.$data[o++]=n,this.$data[o++]=a,this.dataPosition=o},t.prototype.drawRect=function(t,e,i,r){var n=t+i,a=e+r;this.moveTo(t,e),this.lineTo(n,e),this.lineTo(n,a),this.lineTo(t,a),this.lineTo(t,e)},t.prototype.drawRoundRect=function(t,e,i,r,n,a){var o=.5*n|0,s=a?.5*a|0:o;if(!o||!s)return void this.drawRect(t,e,i,r);var h=.5*i,c=.5*r;if(o>h&&(o=h),s>c&&(s=c),h===o&&c===s)return void(o===s?this.drawCircle(t+o,e+s,o):this.drawEllipse(t,e,2*o,2*s));var l=t+i,u=e+r,p=t+o,d=l-o,f=e+s,g=u-s;this.moveTo(l,g),this.curveTo(l,u,d,u),this.lineTo(p,u),this.curveTo(t,u,t,g),this.lineTo(t,f),this.curveTo(t,e,p,e),this.lineTo(d,e),this.curveTo(l,e,l,f),this.lineTo(l,g)},t.prototype.drawCircle=function(t,e,i){this.arcToBezier(t,e,i,i,0,2*Math.PI)},t.prototype.drawEllipse=function(t,e,i,r){var n=.5*i,a=.5*r;t+=n,e+=a,this.arcToBezier(t,e,n,a,0,2*Math.PI)},t.prototype.drawArc=function(t,e,i,r,n,a){a?n>=r&&(n-=2*Math.PI):r>=n&&(n+=2*Math.PI),this.arcToBezier(t,e,i,i,r,n,a)},t.prototype.arcToBezier=function(t,e,i,r,n,a,o){var s=.5*Math.PI,h=n,c=h;o?(c+=-s-h%s,a>c&&(c=a)):(c+=s-h%s,c>a&&(c=a));var l=t+Math.cos(h)*i,u=e+Math.sin(h)*r;(this.$lastX!=l||this.$lastY!=u)&&this.moveTo(l,u);for(var p=Math.cos(h),d=Math.sin(h),f=0;4>f;f++){var g=c-h,$=4*Math.tan(g/4)/3,y=l-d*$*i,v=u+p*$*r;p=Math.cos(c),d=Math.sin(c),l=t+p*i,u=e+d*r;var m=l+d*$*i,b=u-p*$*r;if(this.cubicCurveTo(y,v,m,b,l,u),c===a)break;h=c,o?(c=h-s,a>c&&(c=a)):(c=h+s,c>a&&(c=a))}},t}();t.Path2D=e,__reflect(e.prototype,"egret.sys.Path2D")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){t.fontMapping={}}(egret||(egret={}));var egret;!function(t){function e(){var t=Object.create(null);return t.__v8__=void 0,delete t.__v8__,t}t.createMap=e}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i,r,n,a,o,s,h){void 0===e&&(e=16711680),void 0===i&&(i=1),void 0===r&&(r=6),void 0===n&&(n=6),void 0===a&&(a=2),void 0===o&&(o=1),void 0===s&&(s=!1),void 0===h&&(h=!1);var c=t.call(this)||this,l=c;return l.type="glow",l.$color=e,l.$blue=255&e,l.$green=(65280&e)>>8,l.$red=e>>16,l.$alpha=i,l.$blurX=r,l.$blurY=n,l.$strength=a,l.$quality=o,l.$inner=s,l.$knockout=h,l.$uniforms.color={x:c.$red/255,y:c.$green/255,z:c.$blue/255,w:1},l.$uniforms.alpha=i,l.$uniforms.blurX=r,l.$uniforms.blurY=n,l.$uniforms.strength=a,l.$uniforms.inner=s?1:0,l.$uniforms.knockout=h?0:1,l.$uniforms.dist=0,l.$uniforms.angle=0,l.$uniforms.hideObject=0,l.onPropertyChange(),c}return __extends(e,t),Object.defineProperty(e.prototype,"color",{get:function(){return this.$color},set:function(t){this.$color!=t&&(this.$color=t,this.$blue=255&t,this.$green=(65280&t)>>8,this.$red=t>>16,this.$uniforms.color.x=this.$red/255,this.$uniforms.color.y=this.$green/255,this.$uniforms.color.z=this.$blue/255)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this.$alpha},set:function(t){this.$alpha!=t&&(this.$alpha=t,this.$uniforms.alpha=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurX",{get:function(){return this.$blurX},set:function(t){var e=this;e.$blurX!=t&&(e.$blurX=t,e.$uniforms.blurX=t,e.onPropertyChange())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurY",{get:function(){return this.$blurY},set:function(t){var e=this;e.$blurY!=t&&(e.$blurY=t,e.$uniforms.blurY=t,e.onPropertyChange())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"strength",{get:function(){return this.$strength},set:function(t){this.$strength!=t&&(this.$strength=t,this.$uniforms.strength=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"quality",{get:function(){return this.$quality},set:function(t){this.$quality!=t&&(this.$quality=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inner",{get:function(){return this.$inner},set:function(t){this.$inner!=t&&(this.$inner=t,this.$uniforms.inner=t?1:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"knockout",{get:function(){return this.$knockout},set:function(t){this.$knockout!=t&&(this.$knockout=t,this.$uniforms.knockout=t?0:1)},enumerable:!0,configurable:!0}),e.prototype.$toJson=function(){return'{"color": '+this.$color+', "red": '+this.$red+', "green": '+this.$green+', "blue": '+this.$blue+', "alpha": '+this.$alpha+', "blurX": '+this.$blurX+', "blurY": '+this.blurY+', "strength": '+this.$strength+', "quality": '+this.$quality+', "inner": '+this.$inner+', "knockout": '+this.$knockout+"}"},e.prototype.updatePadding=function(){var t=this;t.paddingLeft=t.blurX,t.paddingRight=t.blurX,t.paddingTop=t.blurY,t.paddingBottom=t.blurY},e}(t.Filter);t.GlowFilter=e,__reflect(e.prototype,"egret.GlowFilter")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.$stageWidth=0,i.$stageHeight=0,i.$scaleMode=t.StageScaleMode.SHOW_ALL,i.$orientation=t.OrientationMode.AUTO,i.$maxTouches=99,i.$stage=i,i.$nestLevel=1,i}return __extends(i,e),i.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(13)},Object.defineProperty(i.prototype,"frameRate",{get:function(){return t.ticker.$frameRate},set:function(e){t.ticker.$setFrameRate(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"stageWidth",{get:function(){return this.$stageWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"stageHeight",{get:function(){return this.$stageHeight},enumerable:!0,configurable:!0}),i.prototype.invalidate=function(){t.sys.$invalidateRenderFlag=!0},i.prototype.registerImplementation=function(e,i){t.registerImplementation(e,i)},i.prototype.getImplementation=function(e){return t.getImplementation(e)},Object.defineProperty(i.prototype,"scaleMode",{get:function(){return this.$scaleMode},set:function(t){this.$scaleMode!=t&&(this.$scaleMode=t,this.$screen.updateScreenSize())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"orientation",{get:function(){return this.$orientation},set:function(t){this.$orientation!=t&&(this.$orientation=t,this.$screen.updateScreenSize())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textureScaleFactor",{get:function(){return t.$TextureScaleFactor},set:function(e){t.$TextureScaleFactor=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"maxTouches",{get:function(){return this.$maxTouches},set:function(t){this.$maxTouches!=t&&(this.$maxTouches=t,this.$screen.updateMaxTouches())},enumerable:!0,configurable:!0}),i.prototype.setContentSize=function(t,e){this.$screen.setContentSize(t,e)},i}(t.DisplayObjectContainer);t.Stage=e,__reflect(e.prototype,"egret.Stage")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.NORMAL="normal",t.ADD="add",t.ERASE="erase",t}();t.BlendMode=e,__reflect(e.prototype,"egret.BlendMode")}(egret||(egret={})),function(t){var e;!function(t){function e(t){var e=n[t];return void 0===e?0:e}function i(t){var e=r[t];return void 0===e?"normal":e}for(var r=["normal","add","erase"],n={},a=r.length,o=0;a>o;o++){var s=r[o];n[s]=o}t.blendModeToNumber=e,t.numberToBlendMode=i}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){t.ChildrenSortMode={DEFAULT:"default",INCREASE_Y:"increaseY",DECREASE_Y:"decreaseY"}}(egret||(egret={}));var egret;!function(t){t.CapsStyle={NONE:"none",ROUND:"round",SQUARE:"square"}}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){}return e.compileProgram=function(i,r,n){var a=e.compileFragmentShader(i,n),o=e.compileVertexShader(i,r),s=i.createProgram();return i.attachShader(s,o),i.attachShader(s,a),i.linkProgram(s),i.getProgramParameter(s,i.LINK_STATUS)||t.$warn(1020),s},e.compileFragmentShader=function(t,i){return e._compileShader(t,i,t.FRAGMENT_SHADER)},e.compileVertexShader=function(t,i){return e._compileShader(t,i,t.VERTEX_SHADER)},e._compileShader=function(t,e,i){var r=t.createShader(i);return t.shaderSource(r,e),t.compileShader(r),t.getShaderParameter(r,t.COMPILE_STATUS)?r:null},e.checkCanUseWebGL=function(){if(void 0==e.canUseWebGL)try{var t=document.createElement("canvas");e.canUseWebGL=!(!window.WebGLRenderingContext||!t.getContext("webgl")&&!t.getContext("experimental-webgl"))}catch(i){e.canUseWebGL=!1}return e.canUseWebGL},e.deleteWebGLTexture=function(e){if(e&&!e[t.engine_default_empty_texture]){var i=e[t.glContext];i&&i.deleteTexture(e)}},e.premultiplyTint=function(t,e){if(1===e)return(255*e<<24)+t;if(0===e)return 0;var i=t>>16&255,r=t>>8&255,n=255&t;return i=i*e+.5|0,r=r*e+.5|0,n=n*e+.5|0,(255*e<<24)+(i<<16)+(r<<8)+n},e}();t.WebGLUtils=e,__reflect(e.prototype,"egret.WebGLUtils")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i,r){return void 0===i&&(i=!1),void 0===r&&(r=!1),t.call(this,e,i,r)||this}return __extends(e,t),e.FOCUS_IN="focusIn",e.FOCUS_OUT="focusOut",e}(t.Event);t.FocusEvent=e,__reflect(e.prototype,"egret.FocusEvent")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.PERMISSION_DENIED="permissionDenied",e.UNAVAILABLE="unavailable",e}(t.Event);t.GeolocationEvent=e,__reflect(e.prototype,"egret.GeolocationEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r){void 0===i&&(i=!1),void 0===r&&(r=!1);var n=e.call(this,t,i,r)||this;return n._status=0,n}return __extends(i,e),Object.defineProperty(i.prototype,"status",{get:function(){return this._status},enumerable:!0,configurable:!0}),i.dispatchHTTPStatusEvent=function(e,r){var n=t.Event.create(i,i.HTTP_STATUS);n._status=r;var a=e.dispatchEvent(n);return t.Event.release(n),a},i.HTTP_STATUS="httpStatus",i}(t.Event);t.HTTPStatusEvent=e,__reflect(e.prototype,"egret.HTTPStatusEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r){return void 0===i&&(i=!1),void 0===r&&(r=!1),e.call(this,t,i,r)||this}return __extends(i,e),i.dispatchIOErrorEvent=function(e){var r=t.Event.create(i,i.IO_ERROR),n=e.dispatchEvent(r);return t.Event.release(r),n},i.IO_ERROR="ioError",i}(t.Event);t.IOErrorEvent=e,__reflect(e.prototype,"egret.IOErrorEvent")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Event);t.MotionEvent=e,__reflect(e.prototype,"egret.MotionEvent")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Event);t.OrientationEvent=e,__reflect(e.prototype,"egret.OrientationEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r,n,a){void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n=0),void 0===a&&(a=0);var o=e.call(this,t,i,r)||this;return o.bytesLoaded=0,o.bytesTotal=0,o.bytesLoaded=n,o.bytesTotal=a,o}return __extends(i,e),i.dispatchProgressEvent=function(e,r,n,a){void 0===n&&(n=0),void 0===a&&(a=0);var o=t.Event.create(i,r);o.bytesLoaded=n,o.bytesTotal=a;var s=e.dispatchEvent(o);return t.Event.release(o),s},i.PROGRESS="progress",i.SOCKET_DATA="socketData",i}(t.Event);t.ProgressEvent=e,__reflect(e.prototype,"egret.ProgressEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r){return void 0===i&&(i=!1),void 0===r&&(r=!1),e.call(this,t,i,r)||this}return __extends(i,e),i.dispatchStageOrientationEvent=function(e,r){var n=t.Event.create(i,r),a=e.dispatchEvent(n);return t.Event.release(n),a},i.ORIENTATION_CHANGE="orientationChange",i}(t.Event);t.StageOrientationEvent=e,__reflect(e.prototype,"egret.StageOrientationEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r,n){void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n="");var a=e.call(this,t,i,r)||this;return a.text=n,a}return __extends(i,e),i.dispatchTextEvent=function(e,r,n){var a=t.Event.create(i,r);a.text=n;var o=e.dispatchEvent(a);return t.Event.release(a),o},i.LINK="link",i}(t.Event);t.TextEvent=e,__reflect(e.prototype,"egret.TextEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r){return e.call(this,t,i,r)||this}return __extends(i,e),i.prototype.updateAfterEvent=function(){t.sys.$requestRenderingFlag=!0},i.dispatchTimerEvent=function(e,r,n,a){var o=t.Event.create(i,r,n,a),s=e.dispatchEvent(o);return t.Event.release(o),s},i.TIMER="timer",i.TIMER_COMPLETE="timerComplete",i}(t.Event);t.TimerEvent=e,__reflect(e.prototype,"egret.TimerEvent")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t}();t.CompressedTextureData=e,__reflect(e.prototype,"egret.CompressedTextureData"),t.etc_alpha_mask="etc_alpha_mask",t.engine_default_empty_texture="engine_default_empty_texture",t.is_compressed_texture="is_compressed_texture",t.glContext="glContext",t.UNPACK_PREMULTIPLY_ALPHA_WEBGL="UNPACK_PREMULTIPLY_ALPHA_WEBGL";var i=function(e){function i(i){var r=e.call(this)||this;if(r.format="image",r.$deleteSource=!0,r.compressedTextureData=[],r.debugCompressedTextureURL="",r.etcAlphaMask=null,t.nativeRender){var n=new egret_native.NativeBitmapData;n.$init(),r.$nativeBitmapData=n}return r.source=i,r.source=i,r.source&&(r.width=+i.width,r.height=+i.height),r}return __extends(i,e),Object.defineProperty(i.prototype,"source",{get:function(){return this.$source},set:function(e){this.$source=e,t.nativeRender&&egret_native.NativeDisplayObject.setSourceToNativeBitmapData(this.$nativeBitmapData,e)},enumerable:!0,configurable:!0}),i.create=function(e,r,n){var a="";a="arraybuffer"===e?t.Base64Util.encode(r):r;var o="image/png";"/"===a.charAt(0)?o="image/jpeg":"R"===a.charAt(0)?o="image/gif":"i"===a.charAt(0)&&(o="image/png");var s=new Image;s.src="data:"+o+";base64,"+a,s.crossOrigin="*";var h=new i(s);return s.onload=function(){s.onload=void 0,h.source=s,h.height=s.height,h.width=s.width,n&&n(h)},h},i.prototype.$dispose=function(){"webgl"==t.Capabilities.renderMode&&this.webGLTexture&&(t.WebGLUtils.deleteWebGLTexture(this.webGLTexture),this.webGLTexture=null),this.source&&this.source.dispose&&this.source.dispose(),this.source&&this.source.src&&(this.source.src=""),this.source=null,this.clearCompressedTextureData(),this.debugCompressedTextureURL="",this.etcAlphaMask=null,t.nativeRender&&egret_native.NativeDisplayObject.disposeNativeBitmapData(this.$nativeBitmapData),i.$dispose(this)},i.$addDisplayObject=function(t,e){if(e){var r=e.hashCode;if(r){if(!i._displayList[r])return void(i._displayList[r]=[t]);var n=i._displayList[r];n.indexOf(t)<0&&n.push(t)}}},i.$removeDisplayObject=function(t,e){if(e){var r=e.hashCode;if(r&&i._displayList[r]){var n=i._displayList[r],a=n.indexOf(t);a>=0&&n.splice(a,1)}}},i.$invalidate=function(e){if(e){var r=e.hashCode;if(r&&i._displayList[r])for(var n=i._displayList[r],a=0;at;t++)this.matrix2[t]=this.$matrix[t];return this.matrix2},set:function(t){this.setMatrix(t)},enumerable:!0,configurable:!0}),e.prototype.setMatrix=function(t){if(t)for(var e=0;20>e;e++)this.$matrix[e]=t[e];else for(var e=0;20>e;e++)this.$matrix[e]=0==e||6==e||12==e||18==e?1:0;for(var i=this.$matrix,r=this.$uniforms.matrix,n=this.$uniforms.colorAdd,e=0,a=0;et;t++)8===t||13===t||18===t||23===t?n[t]="-":14===t?n[t]="4":(2>=a&&(a=33554432+16777216*Math.random()|0),e=15&a,a>>=4,n[t]=r[19===t?3&e|8:e]);return n.join("")},s=function(e){function r(t,r,n){void 0===n&&(n={});var a=e.call(this)||this;a.$padding=0,a.$vertexSrc=t,a.$fragmentSrc=r;var s=t+r;return i[s]||(i[s]=o()),a.$shaderKey=i[s],a.$uniforms=n,a.type="custom",a}return __extends(r,e),Object.defineProperty(r.prototype,"padding",{get:function(){return this.$padding},set:function(t){var e=this;e.$padding!=t&&(e.$padding=t,e.onPropertyChange())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"uniforms",{get:function(){return this.$uniforms},enumerable:!0,configurable:!0}),r.prototype.onPropertyChange=function(){if(t.nativeRender){var e=this;egret_native.NativeDisplayObject.setFilterPadding(e.$id,e.$padding,e.$padding,e.$padding,e.$padding),egret_native.NativeDisplayObject.setDataToFilter(e)}},r}(t.Filter);t.CustomFilter=s,__reflect(s.prototype,"egret.CustomFilter")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,r,n,a,o,s,h,c,l,u){void 0===t&&(t=4),void 0===i&&(i=45),void 0===r&&(r=0),void 0===n&&(n=1),void 0===a&&(a=4),void 0===o&&(o=4),void 0===s&&(s=1),void 0===h&&(h=1),void 0===c&&(c=!1),void 0===l&&(l=!1),void 0===u&&(u=!1);var p=e.call(this,r,n,a,o,s,h,c,l)||this,d=p;return d.$distance=t,d.$angle=i,d.$hideObject=u,d.$uniforms.dist=t,d.$uniforms.angle=i/180*Math.PI,d.$uniforms.hideObject=u?1:0,d.onPropertyChange(),p}return __extends(i,e),Object.defineProperty(i.prototype,"distance",{get:function(){return this.$distance},set:function(t){var e=this;e.$distance!=t&&(e.$distance=t,e.$uniforms.dist=t,e.onPropertyChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"angle",{get:function(){return this.$angle},set:function(t){var e=this;e.$angle!=t&&(e.$angle=t,e.$uniforms.angle=t/180*Math.PI,e.onPropertyChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hideObject",{get:function(){return this.$hideObject},set:function(t){this.$hideObject!=t&&(this.$hideObject=t,this.$uniforms.hideObject=t?1:0)},enumerable:!0,configurable:!0}),i.prototype.$toJson=function(){return'{"distance": '+this.$distance+', "angle": '+this.$angle+', "color": '+this.$color+', "red": '+this.$red+', "green": '+this.$green+', "blue": '+this.$blue+', "alpha": '+this.$alpha+', "blurX": '+this.$blurX+', "blurY": '+this.blurY+', "strength": '+this.$strength+', "quality": '+this.$quality+', "inner": '+this.$inner+', "knockout": '+this.$knockout+', "hideObject": '+this.$hideObject+"}"},i.prototype.updatePadding=function(){var e=this;e.paddingLeft=e.blurX,e.paddingRight=e.blurX,e.paddingTop=e.blurY,e.paddingBottom=e.blurY;var i=e.distance||0,r=e.angle||0,n=0,a=0;0!=i&&(n=i*t.NumberUtils.cos(r),n=n>0?Math.ceil(n):Math.floor(n),a=i*t.NumberUtils.sin(r),a=a>0?Math.ceil(a):Math.floor(a),e.paddingLeft+=n,e.paddingRight+=n,e.paddingTop+=a,e.paddingBottom+=a)},i}(t.GlowFilter);t.DropShadowFilter=e,__reflect(e.prototype,"egret.DropShadowFilter")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.LINEAR="linear",t.RADIAL="radial",t}();t.GradientType=e,__reflect(e.prototype,"egret.GradientType")}(egret||(egret={}));var egret;!function(t){function e(t){return t%=2*Math.PI,0>t&&(t+=2*Math.PI),t}function i(t,e){for(var i=[],n=0;e>n;n++){var a=r(t,n/e);a&&i.push(a)}return i}function r(e,i){var r=0,o=0,s=0,h=e.length;if(h/2==3){var c=e[r++],l=e[r++],u=e[r++],p=e[r++],d=e[r++],f=e[r++];o=n(c,u,d,i),s=n(l,p,f,i)}else if(h/2==4){var c=e[r++],l=e[r++],u=e[r++],p=e[r++],d=e[r++],f=e[r++],g=e[r++],$=e[r++];o=a(c,u,d,g,i),s=a(l,p,f,$,i)}return t.Point.create(o,s)}function n(t,e,i,r){var n=Math.pow(1-r,2)*t+2*r*(1-r)*e+Math.pow(r,2)*i;return n}function a(t,e,i,r,n){var a=Math.pow(1-n,3)*t+3*n*Math.pow(1-n,2)*e+3*(1-n)*Math.pow(n,2)*i+Math.pow(n,3)*r;return a}var o=function(r){function n(){var e=r.call(this)||this;return e.lastX=0,e.lastY=0,e.fillPath=null,e.strokePath=null,e.topLeftStrokeWidth=0,e.bottomRightStrokeWidth=0,e.minX=1/0,e.minY=1/0,e.maxX=-(1/0),e.maxY=-(1/0),e.includeLastPosition=!0,e.$renderNode=new t.sys.GraphicsNode,e}return __extends(n,r),n.prototype.$setTarget=function(e){this.$targetDisplay&&(this.$targetDisplay.$renderNode=null),e.$renderNode=this.$renderNode,this.$targetDisplay=e,this.$targetIsSprite=e instanceof t.Sprite},n.prototype.setStrokeWidth=function(t){switch(t){case 1:this.topLeftStrokeWidth=0,this.bottomRightStrokeWidth=1;break;case 3:this.topLeftStrokeWidth=1,this.bottomRightStrokeWidth=2;break;default:var e=0|Math.ceil(.5*t);this.topLeftStrokeWidth=e,this.bottomRightStrokeWidth=e}},n.prototype.beginFill=function(e,i){void 0===i&&(i=1),e=+e||0,i=+i||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setBeginFill(e,i),this.fillPath=this.$renderNode.beginFill(e,i,this.strokePath),this.$renderNode.drawData.length>1&&this.fillPath.moveTo(this.lastX,this.lastY)},n.prototype.beginGradientFill=function(e,i,r,n,a){void 0===a&&(a=null),t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setBeginGradientFill(e,i,r,n,a),this.fillPath=this.$renderNode.beginGradientFill(e,i,r,n,a,this.strokePath),this.$renderNode.drawData.length>1&&this.fillPath.moveTo(this.lastX,this.lastY)},n.prototype.endFill=function(){t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setEndFill(),this.fillPath=null},n.prototype.lineStyle=function(e,i,r,n,a,o,s,h,c){void 0===e&&(e=0/0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=!1),void 0===a&&(a="normal"),void 0===o&&(o=null),void 0===s&&(s=null),void 0===h&&(h=3),e=+e||0,i=+i||0,r=+r||0,h=+h||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setLineStyle(e,i,r,n,a,o,s,h),0>=e?(this.strokePath=null,this.setStrokeWidth(0)):(this.setStrokeWidth(e),this.strokePath=this.$renderNode.lineStyle(e,i,r,o,s,h,c),this.$renderNode.drawData.length>1&&this.strokePath.moveTo(this.lastX,this.lastY))},n.prototype.drawRect=function(e,i,r,n){e=+e||0,i=+i||0,r=+r||0,n=+n||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setDrawRect(e,i,r,n);var a=this.fillPath,o=this.strokePath;a&&a.drawRect(e,i,r,n),o&&o.drawRect(e,i,r,n),this.extendBoundsByPoint(e+r,i+n),this.updatePosition(e,i),this.dirty()},n.prototype.drawRoundRect=function(e,i,r,n,a,o){e=+e||0,i=+i||0,r=+r||0,n=+n||0,a=+a||0,o=+o||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setDrawRoundRect(e,i,r,n,a,o);var s=this.fillPath,h=this.strokePath;s&&s.drawRoundRect(e,i,r,n,a,o),h&&h.drawRoundRect(e,i,r,n,a,o);var c=.5*a|0,l=o?.5*o|0:c,u=e+r,p=i+n,d=p-l;this.extendBoundsByPoint(e,i),this.extendBoundsByPoint(u,p),this.updatePosition(u,d),this.dirty()},n.prototype.drawCircle=function(e,i,r){e=+e||0,i=+i||0,r=+r||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setDrawCircle(e,i,r);var n=this.fillPath,a=this.strokePath;n&&n.drawCircle(e,i,r),a&&a.drawCircle(e,i,r),this.extendBoundsByPoint(e-r-1,i-r-1),this.extendBoundsByPoint(e+r+2,i+r+2),this.updatePosition(e+r,i),this.dirty()},n.prototype.drawEllipse=function(e,i,r,n){e=+e||0,i=+i||0,r=+r||0,n=+n||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setDrawEllipse(e,i,r,n);var a=this.fillPath,o=this.strokePath;a&&a.drawEllipse(e,i,r,n),o&&o.drawEllipse(e,i,r,n),this.extendBoundsByPoint(e-1,i-1),this.extendBoundsByPoint(e+r+2,i+n+2),this.updatePosition(e+r,i+.5*n),this.dirty()},n.prototype.moveTo=function(e,i){e=+e||0,i=+i||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setMoveTo(e,i);var r=this.fillPath,n=this.strokePath;r&&r.moveTo(e,i),n&&n.moveTo(e,i),this.includeLastPosition=!1,this.lastX=e,this.lastY=i,this.dirty()},n.prototype.lineTo=function(e,i){e=+e||0,i=+i||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setLineTo(e,i);var r=this.fillPath,n=this.strokePath;r&&r.lineTo(e,i),n&&n.lineTo(e,i),this.updatePosition(e,i),this.dirty()},n.prototype.curveTo=function(e,r,n,a){e=+e||0,r=+r||0,n=+n||0,a=+a||0,t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setCurveTo(e,r,n,a);var o=this.fillPath,s=this.strokePath;o&&o.curveTo(e,r,n,a),s&&s.curveTo(e,r,n,a);for(var h=this.lastX||0,c=this.lastY||0,l=i([h,c,e,r,n,a],50),u=0;un||a===o)){i=+i||0,r=+r||0,n=+n||0,a=+a||0,o=+o||0,s=!!s,a=e(a),o=e(o),t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setDrawArc(i,r,n,a,o,s);var h=this.fillPath,c=this.strokePath;h&&(h.$lastX=this.lastX,h.$lastY=this.lastY,h.drawArc(i,r,n,a,o,s)),c&&(c.$lastX=this.lastX,c.$lastY=this.lastY,c.drawArc(i,r,n,a,o,s)),s?this.arcBounds(i,r,n,o,a):this.arcBounds(i,r,n,a,o);var l=i+Math.cos(o)*n,u=r+Math.sin(o)*n;this.updatePosition(l,u),this.dirty()}},n.prototype.dirty=function(){var e=this;if(e.$renderNode.dirtyRender=!0,!t.nativeRender){var i=e.$targetDisplay;i.$cacheDirty=!0;var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},n.prototype.arcBounds=function(t,e,i,r,n){var a=Math.PI;if(Math.abs(r-n)<.01)return this.extendBoundsByPoint(t-i,e-i),void this.extendBoundsByPoint(t+i,e+i);r>n&&(n+=2*a);for(var o=Math.cos(r)*i,s=Math.cos(n)*i,h=Math.min(o,s),c=Math.max(o,s),l=Math.sin(r)*i,u=Math.sin(n)*i,p=Math.min(l,u),d=Math.max(l,u),f=r/(.5*a),g=n/(.5*a),$=Math.ceil(f);g>=$;$++)switch($%4){case 0:c=i;break;case 1:d=i;break;case 2:h=-i;break;case 3:p=-i}h=Math.floor(h),p=Math.floor(p),c=Math.ceil(c),d=Math.ceil(d),this.extendBoundsByPoint(h+t,p+e),this.extendBoundsByPoint(c+t,d+e)},n.prototype.clear=function(){t.nativeRender&&this.$targetDisplay.$nativeDisplayObject.setGraphicsClear(),this.$renderNode.clear(),this.updatePosition(0,0),this.minX=1/0,this.minY=1/0,this.maxX=-(1/0),this.maxY=-(1/0),this.dirty()},n.prototype.extendBoundsByPoint=function(t,e){this.extendBoundsByX(t),this.extendBoundsByY(e)},n.prototype.extendBoundsByX=function(t){this.minX=Math.min(this.minX,t-this.topLeftStrokeWidth),this.maxX=Math.max(this.maxX,t+this.bottomRightStrokeWidth),this.updateNodeBounds()},n.prototype.extendBoundsByY=function(t){this.minY=Math.min(this.minY,t-this.topLeftStrokeWidth),this.maxY=Math.max(this.maxY,t+this.bottomRightStrokeWidth),this.updateNodeBounds()},n.prototype.updateNodeBounds=function(){var t=this.$renderNode;t.x=this.minX,t.y=this.minY,t.width=Math.ceil(this.maxX-this.minX),t.height=Math.ceil(this.maxY-this.minY)},n.prototype.updatePosition=function(t,e){this.includeLastPosition||(this.extendBoundsByPoint(this.lastX,this.lastY),this.includeLastPosition=!0),this.lastX=t,this.lastY=e,this.extendBoundsByPoint(t,e)},n.prototype.$measureContentBounds=function(t){this.minX===1/0?t.setEmpty():t.setTo(this.minX,this.minY,this.maxX-this.minX,this.maxY-this.minY)},n.prototype.$hitTest=function(e,i){var r=this.$targetDisplay,n=r.$getInvertedConcatenatedMatrix(),a=n.a*e+n.c*i+n.tx,o=n.b*e+n.d*i+n.ty,s=t.sys.canvasHitTestBuffer;s.resize(3,3);var h=this.$renderNode,c=t.Matrix.create();c.identity(),c.translate(1-a,1-o),t.sys.canvasRenderer.drawNodeToBuffer(h,s,c,!0),t.Matrix.release(c);try{var l=s.getPixels(1,1);if(0===l[3])return null}catch(u){throw new Error(t.sys.tr(1039))}return r},n.prototype.$onRemoveFromStage=function(){this.$renderNode&&this.$renderNode.clean(),t.nativeRender&&egret_native.NativeDisplayObject.disposeGraphicData(this)},n}(t.HashObject);t.Graphics=o,__reflect(o.prototype,"egret.Graphics")}(egret||(egret={}));var egret;!function(t){var e=Math.PI,i=2*e,r=e/180,n=[],a=function(a){function o(t,e,i,r,n,o){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=0),void 0===o&&(o=0);var s=a.call(this)||this;return s.a=t,s.b=e,s.c=i,s.d=r,s.tx=n,s.ty=o,s}return __extends(o,a),o.release=function(t){t&&n.push(t)},o.create=function(){var t=n.pop();return t||(t=new o),t},o.prototype.clone=function(){return new o(this.a,this.b,this.c,this.d,this.tx,this.ty)},o.prototype.concat=function(t){var e=this.a*t.a,i=0,r=0,n=this.d*t.d,a=this.tx*t.a+t.tx,o=this.ty*t.d+t.ty;(0!==this.b||0!==this.c||0!==t.b||0!==t.c)&&(e+=this.b*t.c,n+=this.c*t.b,i+=this.a*t.b+this.b*t.d,r+=this.c*t.a+this.d*t.c,a+=this.ty*t.c,o+=this.tx*t.b),this.a=e,this.b=i,this.c=r,this.d=n,this.tx=a,this.ty=o},o.prototype.copyFrom=function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},o.prototype.identity=function(){this.a=this.d=1,this.b=this.c=this.tx=this.ty=0},o.prototype.invert=function(){this.$invertInto(this)},o.prototype.$invertInto=function(t){var e=this.a,i=this.b,r=this.c,n=this.d,a=this.tx,o=this.ty;if(0==i&&0==r)return t.b=t.c=0,void(0==e||0==n?t.a=t.d=t.tx=t.ty=0:(e=t.a=1/e,n=t.d=1/n,t.tx=-e*a,t.ty=-n*o));var s=e*n-i*r;if(0==s)return void t.identity();s=1/s;var h=t.a=n*s;i=t.b=-i*s,r=t.c=-r*s,n=t.d=e*s,t.tx=-(h*a+r*o),t.ty=-(i*a+n*o)},o.prototype.rotate=function(e){if(e=+e,0!==e){e/=r;var i=t.NumberUtils.cos(e),n=t.NumberUtils.sin(e),a=this.a,o=this.b,s=this.c,h=this.d,c=this.tx,l=this.ty;this.a=a*i-o*n,this.b=a*n+o*i,this.c=s*i-h*n,this.d=s*n+h*i,this.tx=c*i-l*n,this.ty=c*n+l*i}},o.prototype.scale=function(t,e){1!==t&&(this.a*=t,this.c*=t,this.tx*=t),1!==e&&(this.b*=e,this.d*=e,this.ty*=e)},o.prototype.setTo=function(t,e,i,r,n,a){return this.a=t,this.b=e,this.c=i,this.d=r,this.tx=n,this.ty=a,this},o.prototype.transformPoint=function(e,i,r){var n=this.a*e+this.c*i+this.tx,a=this.b*e+this.d*i+this.ty;return r?(r.setTo(n,a),r):new t.Point(n,a)},o.prototype.translate=function(t,e){this.tx+=t,this.ty+=e},o.prototype.equals=function(t){return this.a==t.a&&this.b==t.b&&this.c==t.c&&this.d==t.d&&this.tx==t.tx&&this.ty==t.ty},o.prototype.prepend=function(t,e,i,r,n,a){var o=this.tx;if(1!=t||0!=e||0!=i||1!=r){var s=this.a,h=this.c;this.a=s*t+this.b*i,this.b=s*e+this.b*r,this.c=h*t+this.d*i,this.d=h*e+this.d*r}return this.tx=o*t+this.ty*i+n,this.ty=o*e+this.ty*r+a,this},o.prototype.append=function(t,e,i,r,n,a){var o=this.a,s=this.b,h=this.c,c=this.d;return(1!=t||0!=e||0!=i||1!=r)&&(this.a=t*o+e*h,this.b=t*s+e*c,this.c=i*o+r*h,this.d=i*s+r*c),this.tx=n*o+a*h+this.tx,this.ty=n*s+a*c+this.ty,this},o.prototype.deltaTransformPoint=function(e){var i=this,r=i.a*e.x+i.c*e.y,n=i.b*e.x+i.d*e.y;return new t.Point(r,n)},o.prototype.toString=function(){return"(a="+this.a+", b="+this.b+", c="+this.c+", d="+this.d+", tx="+this.tx+", ty="+this.ty+")"},o.prototype.createBox=function(e,i,n,a,o){void 0===n&&(n=0),void 0===a&&(a=0),void 0===o&&(o=0);var s=this;if(0!==n){n/=r;var h=t.NumberUtils.cos(n),c=t.NumberUtils.sin(n);s.a=h*e,s.b=c*i,s.c=-c*e,s.d=h*i}else s.a=e,s.b=0,s.c=0,s.d=i;s.tx=a,s.ty=o},o.prototype.createGradientBox=function(t,e,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),this.createBox(t/1638.4,e/1638.4,i,r+t/2,n+e/2)},o.prototype.$transformBounds=function(t){var e=this.a,i=this.b,r=this.c,n=this.d,a=this.tx,o=this.ty,s=t.x,h=t.y,c=s+t.width,l=h+t.height,u=e*s+r*h+a,p=i*s+n*h+o,d=e*c+r*h+a,f=i*c+n*h+o,g=e*c+r*l+a,$=i*c+n*l+o,y=e*s+r*l+a,v=i*s+n*l+o,m=0;u>d&&(m=u,u=d,d=m),g>y&&(m=g,g=y,y=m),t.x=Math.floor(g>u?u:g),t.width=Math.ceil((d>y?d:y)-t.x),p>f&&(m=p,p=f,f=m),$>v&&(m=$,$=v,v=m),t.y=Math.floor($>p?p:$),t.height=Math.ceil((f>v?f:v)-t.y)},o.prototype.getDeterminant=function(){return this.a*this.d-this.b*this.c},o.prototype.$getScaleX=function(){var t=this;if(0==t.b)return t.a;var e=Math.sqrt(t.a*t.a+t.b*t.b);return this.getDeterminant()<0?-e:e},o.prototype.$getScaleY=function(){var t=this;if(0==t.c)return t.d;var e=Math.sqrt(t.c*t.c+t.d*t.d);return this.getDeterminant()<0?-e:e},o.prototype.$getSkewX=function(){return this.d<0?Math.atan2(this.d,this.c)+e/2:Math.atan2(this.d,this.c)-e/2},o.prototype.$getSkewY=function(){return this.a<0?Math.atan2(this.b,this.a)-e:Math.atan2(this.b,this.a)},o.prototype.$updateScaleAndRotation=function(e,n,a,o){if(!(0!=a&&a!=i||0!=o&&o!=i))return this.a=e,this.b=this.c=0,void(this.d=n);a/=r,o/=r;var s=t.NumberUtils.cos(a),h=t.NumberUtils.sin(a);a==o?(this.a=s*e,this.b=h*e):(this.a=t.NumberUtils.cos(o)*e,this.b=t.NumberUtils.sin(o)*e),this.c=-h*n,this.d=s*n},o.prototype.$preMultiplyInto=function(t,e){var i=t.a*this.a,r=0,n=0,a=t.d*this.d,o=t.tx*this.a+this.tx,s=t.ty*this.d+this.ty;(0!==t.b||0!==t.c||0!==this.b||0!==this.c)&&(i+=t.b*this.c,a+=t.c*this.b,r+=t.a*this.b+t.b*this.d,n+=t.c*this.a+t.d*this.c,o+=t.ty*this.c,s+=t.tx*this.b),e.a=i,e.b=r,e.c=n,e.d=a,e.tx=o,e.ty=s},o}(t.HashObject);t.Matrix=a,__reflect(a.prototype,"egret.Matrix"),t.$TempMatrix=new a}(egret||(egret={}));var egret;!function(t){var e=[],i=function(i){function r(t,e,r,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),void 0===n&&(n=0);var a=i.call(this)||this;return a.x=t,a.y=e,a.width=r,a.height=n,a}return __extends(r,i),r.release=function(t){t&&e.push(t)},r.create=function(){var t=e.pop();return t||(t=new r),t},Object.defineProperty(r.prototype,"right",{get:function(){return this.x+this.width},set:function(t){this.width=t-this.x},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bottom",{get:function(){return this.y+this.height},set:function(t){this.height=t-this.y},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"left",{get:function(){return this.x},set:function(t){this.width+=this.x-t,this.x=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"top",{get:function(){return this.y},set:function(t){this.height+=this.y-t,this.y=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"topLeft",{get:function(){return new t.Point(this.left,this.top)},set:function(t){this.top=t.y,this.left=t.x},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bottomRight",{get:function(){return new t.Point(this.right,this.bottom)},set:function(t){this.bottom=t.y,this.right=t.x},enumerable:!0,configurable:!0}),r.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this},r.prototype.setTo=function(t,e,i,r){return this.x=t,this.y=e,this.width=i,this.height=r,this},r.prototype.contains=function(t,e){return this.x<=t&&this.x+this.width>=t&&this.y<=e&&this.y+this.height>=e},r.prototype.intersection=function(t){return this.clone().$intersectInPlace(t)},r.prototype.inflate=function(t,e){this.x-=t,this.width+=2*t,this.y-=e,this.height+=2*e},r.prototype.$intersectInPlace=function(t){var e=this.x,i=this.y,r=t.x,n=t.y,a=Math.max(e,r),o=Math.min(e+this.width,r+t.width);if(o>=a){var s=Math.max(i,n),h=Math.min(i+this.height,n+t.height);if(h>=s)return this.setTo(a,s,o-a,h-s),this}return this.setEmpty(),this},r.prototype.intersects=function(t){return Math.max(this.x,t.x)<=Math.min(this.right,t.right)&&Math.max(this.y,t.y)<=Math.min(this.bottom,t.bottom)},r.prototype.isEmpty=function(){return this.width<=0||this.height<=0},r.prototype.setEmpty=function(){this.x=0,this.y=0,this.width=0,this.height=0},r.prototype.clone=function(){return new r(this.x,this.y,this.width,this.height)},r.prototype.containsPoint=function(t){return this.x<=t.x&&this.x+this.width>t.x&&this.y<=t.y&&this.y+this.height>t.y?!0:!1},r.prototype.containsRect=function(t){var e=t.x+t.width,i=t.y+t.height,r=this.x+this.width,n=this.y+this.height;return t.x>=this.x&&t.x=this.y&&t.ythis.x&&r>=e&&i>this.y&&n>=i},r.prototype.equals=function(t){return this===t?!0:this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},r.prototype.inflatePoint=function(t){this.inflate(t.x,t.y)},r.prototype.offset=function(t,e){this.x+=t,this.y+=e},r.prototype.offsetPoint=function(t){this.offset(t.x,t.y)},r.prototype.toString=function(){return"(x="+this.x+", y="+this.y+", width="+this.width+", height="+this.height+")"},r.prototype.union=function(t){var e=this.clone();if(t.isEmpty())return e;if(e.isEmpty())return e.copyFrom(t),e;var i=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return e.setTo(i,r,Math.max(e.right,t.right)-i,Math.max(e.bottom,t.bottom)-r),e},r.prototype.$getBaseWidth=function(t){var e=Math.abs(Math.cos(t)),i=Math.abs(Math.sin(t));return e*this.width+i*this.height},r.prototype.$getBaseHeight=function(t){var e=Math.abs(Math.cos(t)),i=Math.abs(Math.sin(t));return i*this.width+e*this.height},r}(t.HashObject);t.Rectangle=i,__reflect(i.prototype,"egret.Rectangle"),t.$TempRectangle=new i}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$locale_strings.en_US=t.$locale_strings.en_US||{};var e=t.$locale_strings.en_US;e[1001]="Could not find Egret entry class: {0}。",e[1002]="Egret entry class '{0}' must inherit from egret.DisplayObject.",e[1003]="Parameter {0} must be non-null.",e[1004]="An object cannot be added as a child to one of it's children (or children's children, etc.).",e[1005]="An object cannot be added as a child of itself.",e[1006]="The supplied DisplayObject must be a child of the caller.",e[1007]="An index specified for a parameter was out of range.",e[1008]="Instantiate singleton error,singleton class {0} can not create multiple instances.",e[1009]='the Class {0} cannot use the property "{1}"',e[1010]='the property "{1}" of the Class "{0}" is readonly',e[1011]="Stream Error. URL: {0}",e[1012]="The type of parameter {0} must be Class.",e[1013]="Variable assignment is NaN, please see the code!",e[1014]='the constant "{1}" of the Class "{0}" is read-only',e[1015]="xml not found!",e[1016]="{0}has been obsoleted",e[1017]="The format of JSON file is incorrect: {0}\ndata: {1}",e[1018]="the scale9Grid is not correct",e[1019]="Network ab:{0}",e[1020]="Cannot initialize Shader",e[1021]="Current browser does not support webgl",e[1022]="{0} ArgumentError",e[1023]="This method is not available in the ScrollView!",e[1025]="end of the file",e[1026]="! EncodingError The code point {0} could not be encoded.",e[1027]="DecodingError",e[1028]=". called injection is not configured rule: {0}, please specify configuration during its initial years of injection rule, and then call the corresponding single case.",e[1029]="Function.prototype.bind - what is trying to be bound is not callable",e[1033]="Photos can not be used across domains toDataURL to convert base64",e[1034]='Music file decoding failed: "{0}", please use the standard conversion tool reconversion under mp3.',e[1035]="Native does not support this feature!",e[1036]="Sound has stopped, please recall Sound.play () to play the sound!",e[1037]="Non-load the correct blob!",e[1038]="XML format error!",e[1039]="Cross domains pictures can not get pixel information!",e[1040]="hitTestPoint can not detect crossOrigin images! Please check if the display object has crossOrigin elements.",e[1041]="{0} is deprecated, please use {1} replace",e[1042]="The parameters passed in the region needs is an integer in drawToTexture method. Otherwise, some browsers will draw abnormal.",e[1043]="Compile errors in {0}, the attribute name: {1}, the attribute value: {2}.",e[1044]="The current version of the Runtime does not support video playback, please use the latest version",e[1045]="The resource url is not found",e[1046]="BitmapText no corresponding characters: {0}, please check the configuration file",e[1047]="egret.localStorage.setItem save failed,key={0}&value={1}",e[1048]="Video loading failed",e[1049]="In the absence of sound is not allowed to play after loading",e[1050]="ExternalInterface calls the method without js registration: {0}",e[1051]="runtime only support webgl render mode",e[1052]="network request timeout{0}",e[3e3]="Theme configuration file failed to load: {0}",e[3001]="Cannot find the skin name which is configured in Theme: {0}",e[3002]='Index:"{0}" is out of the collection element index range',e[3003]="Cannot be available in this component. If this component is container, please continue to use",e[3004]="addChild(){0}addElement() replace",e[3005]="addChildAt(){0}addElementAt() replace",e[3006]="removeChild(){0}removeElement() replace",e[3007]="removeChildAt(){0}removeElementAt() replace",e[3008]="setChildIndex(){0}setElementIndex() replace",e[3009]="swapChildren(){0}swapElements() replace",e[3010]="swapChildrenAt(){0}swapElementsAt() replace",e[3011]='Index:"{0}" is out of the visual element index range',e[3012]="This method is not available in Scroller component!",e[3013]="UIStage is GUI root container, and only one such instant is in the display list!",e[3014]="set fullscreen error",e[3100]="Current browser does not support WebSocket",e[3101]="Please connect Socket firstly",e[3102]="Please set the type of binary type",e[3200]="getResByUrl must be called after loadConfig",e[4e3]="An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)",e[4001]="Abstract class can not be instantiated!",e[4002]="Unnamed data!",e[4003]="Nonsupport version!",e[4500]="The platform does not support {0} adapter mode and has been automatically replaced with {1} mode, please modify your code adapter logic"}(egret||(egret={}));var egret;!function(t){t.JointStyle={BEVEL:"bevel",MITER:"miter",ROUND:"round"}}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$locale_strings.zh_CN=t.$locale_strings.zh_CN||{};var e=t.$locale_strings.zh_CN;e[1001]="找不到Egret入口类: {0}。",e[1002]="Egret入口类 {0} 必须继承自egret.DisplayObject。",e[1003]="参数 {0} 不能为 null。",e[1004]="无法将对象添加为它的一个子对象(或子对象的子对象等)的子对象。",e[1005]="不能将对象添加为其自身的子对象。",e[1006]="提供的 DisplayObject 必须是调用者的子级。",e[1007]="为参数指定的索引不在范围内。",e[1008]="实例化单例出错,不允许实例化多个 {0} 对象。",e[1009]="类 {0} 不可以使用属性 {1}",e[1010]="类 {0} 属性 {1} 是只读的",e[1011]="流错误。URL: {0}",e[1012]="参数 {0} 的类型必须为 Class。",e[1013]="变量赋值为NaN,请查看代码!",e[1014]="类 {0} 常量 {1} 是只读的",e[1015]="xml not found!",e[1016]="{0}已经废弃",e[1017]="JSON文件格式不正确: {0}\ndata: {1}",e[1018]="9宫格设置错误",e[1019]="网络异常:{0}",e[1020]="无法初始化着色器",e[1021]="当前浏览器不支持webgl",e[1022]="{0} ArgumentError",e[1023]="此方法在ScrollView内不可用!",e[1025]="遇到文件尾",e[1026]="EncodingError! The code point {0} could not be encoded.",e[1027]="DecodingError",e[1028]="调用了未配置的注入规则:{0}。 请先在项目初始化里配置指定的注入规则,再调用对应单例。",e[1029]="Function.prototype.bind - what is trying to be bound is not callable",e[1033]="跨域图片不可以使用toDataURL来转换成base64",e[1034]='音乐文件解码失败:"{0}",请使用标准的转换工具重新转换下mp3。',e[1035]="Native 下暂未实现此功能!",e[1036]="声音已停止,请重新调用 Sound.play() 来播放声音!",e[1037]="非正确的blob加载!",e[1038]="XML 格式错误!",e[1039]="跨域图片不能获取像素信息!",e[1040]="hitTestPoint 不能对跨域图片进行检测! 请检查该显示对象内是否含有跨域元素",e[1041]="{0} 已废弃,请使用 {1} 代替",e[1042]="drawToTexture方法传入的区域各个参数需要为整数,否则某些浏览器绘制会出现异常",e[1043]="{0} 中存在编译错误,属性名 : {1},属性值 : {2}",e[1044]="当前的 runtime 版本不支持视频播放,请使用最新的版本",e[1045]="没有设置要加载的资源地址",e[1046]="BitmapText 找不到对应字符:{0},请检查配置文件",e[1047]="egret.localStorage.setItem保存失败,key={0}&value={1}",e[1048]="视频加载失败",e[1049]="声音在没有加载完之前不允许播放",e[1050]="ExternalInterface调用了js没有注册的方法: {0}",e[1051]="runtime 只支持 webgl 渲染模式",e[1052]="网络请求超时:{0}",e[3e3]="主题配置文件加载失败: {0}",e[3001]="找不到主题中所配置的皮肤类名: {0}",e[3002]='索引:"{0}"超出集合元素索引范围',e[3003]="在此组件中不可用,若此组件为容器类,请使用",e[3004]="addChild(){0}addElement()代替",e[3005]="addChildAt(){0}addElementAt()代替",e[3006]="removeChild(){0}removeElement()代替",e[3007]="removeChildAt(){0}removeElementAt()代替",e[3008]="setChildIndex(){0}setElementIndex()代替",e[3009]="swapChildren(){0}swapElements()代替",e[3010]="swapChildrenAt(){0}swapElementsAt()代替",e[3011]='索引:"{0}"超出可视元素索引范围',e[3012]="此方法在Scroller组件内不可用!",e[3013]="UIStage是GUI根容器,只能有一个此实例在显示列表中!",e[3014]="设置全屏模式失败",e[3100]="当前浏览器不支持WebSocket",e[3101]="请先连接WebSocket",e[3102]="请先设置type为二进制类型",e[3200]="getResByUrl 必须在 loadConfig 之后调用",e[4e3]="An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)",e[4001]="Abstract class can not be instantiated!",e[4002]="Unnamed data!",e[4003]="Nonsupport version!",e[4500]="该平台不支持 {0} 适配模式,已经自动替换为 {1} 模式,请修改您的代码适配逻辑" -}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.localStorage||(t.localStorage={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){function e(t){r.indexOf(t)<0&&r.push(t)}function i(t){var e=r.indexOf(t);return e>=0?(r.splice(e,1),!0):!1}var r=[];t.$pushSoundChannel=e,t.$popSoundChannel=i}(e=t.sys||(t.sys={}))}(egret||(egret={})),function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e;!function(t){t.GET="GET",t.POST="POST"}(e=t.HttpMethod||(t.HttpMethod={}))}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.TEXT="text",t.ARRAY_BUFFER="arraybuffer",t}();t.HttpResponseType=e,__reflect(e.prototype,"egret.HttpResponseType")}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(i){function r(r){var n=i.call(this)||this;return n.isStage=!1,n.$renderNode=new e.BitmapNode,n.renderBuffer=null,n.offsetX=0,n.offsetY=0,n.offsetMatrix=new t.Matrix,n.$canvasScaleX=1,n.$canvasScaleY=1,n.root=r,n.isStage=r instanceof t.Stage,n}return __extends(r,i),r.create=function(i){var r=new t.sys.DisplayList(i);try{var n=new e.RenderBuffer;r.renderBuffer=n}catch(a){return null}return r.root=i,r},r.prototype.$getRenderNode=function(){return this.$renderNode},r.prototype.setClipRect=function(t,e){t*=r.$canvasScaleX,e*=r.$canvasScaleY,this.renderBuffer.resize(t,e)},r.prototype.drawToSurface=function(){var i=0;this.$canvasScaleX=this.offsetMatrix.a=r.$canvasScaleX,this.$canvasScaleY=this.offsetMatrix.d=r.$canvasScaleY,this.isStage||this.changeSurfaceSize();var n=this.renderBuffer;if(n.clear(),i=e.systemRenderer.render(this.root,n,this.offsetMatrix),!this.isStage){var a=n.surface,o=this.$renderNode;o.drawData.length=0;var s=a.width,h=a.height;this.bitmapData?(this.bitmapData.source=a,this.bitmapData.width=s,this.bitmapData.height=h):this.bitmapData=new t.BitmapData(a),o.image=this.bitmapData,o.imageWidth=s,o.imageHeight=h,o.drawImage(0,0,s,h,-this.offsetX,-this.offsetY,s/this.$canvasScaleX,h/this.$canvasScaleY)}return i},r.prototype.changeSurfaceSize=function(){var t=(this.root,this.offsetX),e=this.offsetY,i=this.root.$getOriginalBounds(),r=this.$canvasScaleX,n=this.$canvasScaleY;this.offsetX=-i.x,this.offsetY=-i.y,this.offsetMatrix.setTo(this.offsetMatrix.a,0,0,this.offsetMatrix.d,this.offsetX,this.offsetY);var a=this.renderBuffer,o=Math.max(257,i.width*r),s=Math.max(257,i.height*n);(this.offsetX!=t||this.offsetY!=e||a.surface.width!=o||a.surface.height!=s)&&a.resize(o,s)},r.$setCanvasScale=function(e,i){r.$canvasScaleX=e,r.$canvasScaleY=i,t.nativeRender&&egret_native.nrSetCanvasScaleFactor(r.$canvasScaleFactor,e,i)},r.$canvasScaleFactor=1,r.$canvasScaleX=1,r.$canvasScaleY=1,r}(t.HashObject);e.DisplayList=i,__reflect(i.prototype,"egret.sys.DisplayList")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e;!function(e){function i(t){for(var e=[],i=0;in;n++)r+=arguments[n]+" ";e.$logToFPS(r),console.log.apply(console,i(arguments))},t.warn=function(){for(var t=arguments.length,r="",n=0;t>n;n++)r+=arguments[n]+" ";e.$warnToFPS(r),console.warn.apply(console,i(arguments))},t.error=function(){for(var t=arguments.length,r="",n=0;t>n;n++)r+=arguments[n]+" ";e.$errorToFPS(r),console.error.apply(console,i(arguments))}),this.showFPS=!!r,this.showLog=h,!n){n=new FPS(this.stage,r,h,c,l);for(var u=a.length,p=0;u>p;p++)n.updateInfo(a[p]);a=null;for(var d=o.length,p=0;d>p;p++)n.updateWarn(o[p]);o=null;for(var f=s.length,p=0;f>p;p++)n.updateError(s[p]);s=null}},h}(t.HashObject);e.Player=r,__reflect(r.prototype,"egret.sys.Player");var n,a=[],o=[],s=[];e.$logToFPS=function(t){return n?void n.updateInfo(t):void a.push(t)},e.$warnToFPS=function(t){return n?void n.updateWarn(t):void o.push(t)},e.$errorToFPS=function(t){return n?void n.updateError(t):void s.push(t)};var h=function(){function e(e,i,r,n,a){this.showFPS=i,this.showLog=r,this.logFilter=n,this.styles=a,this.infoLines=[],this.totalTime=0,this.totalTick=0,this.lastTime=0,this.drawCalls=0,this.costRender=0,this.costTicker=0,this.infoLines=[],this.totalTime=0,this.totalTick=0,this.lastTime=0,this.drawCalls=0,this.costRender=0,this.costTicker=0,this._stage=e,this.showFPS=i,this.showLog=r,this.logFilter=n,this.styles=a,this.fpsDisplay=new t.FPSDisplay(e,i,r,n,a);var o;try{o=n?new RegExp(n):null}catch(s){t.log(s)}this.filter=function(t){return o?o.test(t):!n||0==t.indexOf(n)}}return e.prototype.update=function(e,i,r){var n=t.getTimer();if(this.totalTime+=n-this.lastTime,this.lastTime=n,this.totalTick++,this.drawCalls+=e,this.costRender+=i,this.costTicker+=r,this.totalTime>=1e3){var a=Math.min(Math.ceil(1e3*this.totalTick/this.totalTime),t.ticker.$frameRate),o=Math.round(this.drawCalls/this.totalTick),s=Math.round(this.costRender/this.totalTick),h=Math.round(this.costTicker/this.totalTick);this.fpsDisplay.update({fps:a,draw:o,costTicker:h,costRender:s}),this.totalTick=0,this.totalTime=this.totalTime%1e3,this.drawCalls=0,this.costRender=0,this.costTicker=0}},e.prototype.updateInfo=function(t){t&&this.showLog&&this.filter(t)&&this.fpsDisplay.updateInfo(t)},e.prototype.updateWarn=function(t){t&&this.showLog&&this.filter(t)&&(this.fpsDisplay.updateWarn?this.fpsDisplay.updateWarn(t):this.fpsDisplay.updateInfo("[Warning]"+t))},e.prototype.updateError=function(t){t&&this.showLog&&this.filter(t)&&(this.fpsDisplay.updateError?this.fpsDisplay.updateError(t):this.fpsDisplay.updateInfo("[Error]"+t))},e}();__reflect(h.prototype,"FPSImpl"),__global.FPS=h,t.warn=function(){console.warn.apply(console,i(arguments))},t.error=function(){console.error.apply(console,i(arguments))},t.assert=function(){console.assert.apply(console,i(arguments))},t.log=function(){console.log.apply(console,i(arguments))}}(e=t.sys||(t.sys={}))}(egret||(egret={})),function(t){if(t.nativeRender=__global.nativeRender,t.nativeRender){var e=egret_native.nrABIVersion,i=egret_native.nrMinEgretVersion,r=5;if(r>e){t.nativeRender=!1;var n="需要升级微端版本到 0.1.14 才可以开启原生渲染加速";t.sys.$warnToFPS(n),t.warn(n)}else if(e>r){t.nativeRender=!1;var n="需要升级引擎版本到 "+i+" 才可以开启原生渲染加速";t.sys.$warnToFPS(n),t.warn(n)}}}(egret||(egret={}));var egret;!function(t){var e=function(){function e(t,i,r,n){this.arrayBuffer=t,this.isInvalid=!1;var a=new Uint8Array(this.arrayBuffer,0,12);if(171!==a[0]||75!==a[1]||84!==a[2]||88!==a[3]||32!==a[4]||49!==a[5]||49!==a[6]||187!==a[7]||13!==a[8]||10!==a[9]||26!==a[10]||10!==a[11])return this.isInvalid=!0,void console.error("texture missing KTX identifier");var o=Uint32Array.BYTES_PER_ELEMENT,s=new DataView(this.arrayBuffer,12,13*o),h=s.getUint32(0,!0),c=67305985===h;return this.glType=s.getUint32(1*o,c),this.glTypeSize=s.getUint32(2*o,c),this.glFormat=s.getUint32(3*o,c),this.glInternalFormat=s.getUint32(4*o,c),this.glBaseInternalFormat=s.getUint32(5*o,c),this.pixelWidth=s.getUint32(6*o,c),this.pixelHeight=s.getUint32(7*o,c),this.pixelDepth=s.getUint32(8*o,c),this.numberOfArrayElements=s.getUint32(9*o,c),this.numberOfFaces=s.getUint32(10*o,c),this.numberOfMipmapLevels=s.getUint32(11*o,c),this.bytesOfKeyValueData=s.getUint32(12*o,c),0!==this.glType?void console.error("only compressed formats currently supported"):(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0===this.pixelHeight||0!==this.pixelDepth?void console.error("only 2D textures currently supported"):0!==this.numberOfArrayElements?void console.error("texture arrays not currently supported"):this.numberOfFaces!==i?void console.error("number of faces expected"+i+", but found "+this.numberOfFaces):void(this.loadType=e.COMPRESSED_2D))}return e.prototype.uploadLevels=function(t,i){this.loadType===e.COMPRESSED_2D&&this._upload2DCompressedLevels(t,i)},e.prototype._upload2DCompressedLevels=function(i,r){i.clearCompressedTextureData();for(var n=i.compressedTextureData,a=e.HEADER_LEN+this.bytesOfKeyValueData,o=this.pixelWidth,s=this.pixelHeight,h=r?this.numberOfMipmapLevels:1,c=0;h>c;c++){var l=new Int32Array(this.arrayBuffer,a,1)[0];a+=4;for(var u=[],p=0;pu?s=Math.round(c*l):o=Math.round(h*u);break;case t.StageScaleMode.SHOW_ALL:l>u?o=Math.round(h*u):s=Math.round(c*l);break;case t.StageScaleMode.FIXED_NARROW:l>u?h=Math.round(i/u):c=Math.round(r/l);break;case t.StageScaleMode.FIXED_WIDE:l>u?c=Math.round(r/l):h=Math.round(i/u);break;default:h=i,c=r}return t.Capabilities.runtimeType!=t.RuntimeType.WXGAME&&(h%2!=0&&(h+=1),c%2!=0&&(c+=1),o%2!=0&&(o+=1),s%2!=0&&(s+=1)),{stageWidth:h,stageHeight:c,displayWidth:o,displayHeight:s}},i}(t.HashObject);e.DefaultScreenAdapter=i,__reflect(i.prototype,"egret.sys.DefaultScreenAdapter",["egret.sys.IScreenAdapter"])}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.NO_SCALE="noScale",t.SHOW_ALL="showAll",t.NO_BORDER="noBorder",t.EXACT_FIT="exactFit",t.FIXED_WIDTH="fixedWidth",t.FIXED_HEIGHT="fixedHeight",t.FIXED_NARROW="fixedNarrow",t.FIXED_WIDE="fixedWide",t}();t.StageScaleMode=e,__reflect(e.prototype,"egret.StageScaleMode")}(egret||(egret={}));var egret;!function(t){var e;!function(t){function e(t,e){return console.error("empty sys.mainCanvas = "+t+", "+e),null}function i(t,e){return console.error("empty sys.createCanvas = "+t+", "+e),null}function r(t,e,i,r){console.error("empty sys.resizeContext = "+t+", "+e+", "+i+", "+r)}function n(t){return console.error("empty sys.getContextWebGL = "+t),null}function a(t){return console.error("empty sys.getContext2d = "+t),null}function o(t,e){return console.error("empty sys.createTexture = "+e),null}function s(t,e,i,r){return console.error("empty sys._createTexture = "+e+", "+i+", "+r),null}function h(t,e,i){return console.error("empty sys.drawTextureElements = "+t+", "+e+", "+i),0}function c(t,e){return console.error("empty sys.measureTextWith = "+t+", "+e),0}function l(t,e,i,r){return console.error("empty sys.createCanvasRenderBufferSurface = "+e+", "+i),null}function u(t,e,i,r){console.error("empty sys.resizeContext = "+t+", "+e+", "+i+", "+r)}t.mainCanvas=e,t.createCanvas=i,t.resizeContext=r,t.getContextWebGL=n,t.getContext2d=a,t.createTexture=o,t._createTexture=s,t.drawTextureElements=h,t.measureTextWith=c,t.createCanvasRenderBufferSurface=l,t.resizeCanvasRenderBuffer=u}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){e.$START_TIME=0,e.$invalidateRenderFlag=!1,e.$requestRenderingFlag=!1;var i=function(){function i(){this.playerList=[],this.callBackList=[],this.thisObjectList=[],this.$frameRate=30,this.lastTimeStamp=0,this.costEnterFrame=0,this.isPaused=!1,e.$START_TIME=Date.now(),this.frameDeltaTime=1e3/this.$frameRate,this.lastCount=this.frameInterval=Math.round(6e4/this.$frameRate)}return i.prototype.$addPlayer=function(t){-1==this.playerList.indexOf(t)&&(this.playerList=this.playerList.concat(),this.playerList.push(t))},i.prototype.$removePlayer=function(t){var e=this.playerList.indexOf(t);if(-1!==e){this.playerList=this.playerList.concat(),this.playerList.splice(e,1)}},i.prototype.$startTick=function(t,e){var i=this.getTickIndex(t,e);-1==i&&(this.concatTick(),this.callBackList.push(t),this.thisObjectList.push(e))},i.prototype.$stopTick=function(t,e){var i=this.getTickIndex(t,e);-1!=i&&(this.concatTick(),this.callBackList.splice(i,1),this.thisObjectList.splice(i,1))},i.prototype.getTickIndex=function(t,e){for(var i=this.callBackList,r=this.thisObjectList,n=i.length-1;n>=0;n--)if(i[n]==t&&r[n]==e)return n;return-1},i.prototype.concatTick=function(){this.callBackList=this.callBackList.concat(),this.thisObjectList=this.thisObjectList.concat()},i.prototype.$setFrameRate=function(t){return 0>=t?!1:this.$frameRate==t?!1:(this.$frameRate=t,t>60&&(t=60),this.frameDeltaTime=1e3/t,this.lastCount=this.frameInterval=Math.round(6e4/t),!0)},i.prototype.pause=function(){this.isPaused=!0},i.prototype.resume=function(){this.isPaused=!1},i.prototype.update=function(i){for(var r=t.getTimer(),n=this.callBackList,a=this.thisObjectList,o=n.length,s=e.$requestRenderingFlag,h=t.getTimer(),c=t.lifecycle.contexts,l=0,u=c;ld;d++)n[d].call(a[d],h)&&(s=!0);var f=t.getTimer(),g=h-this.lastTimeStamp;if(this.lastTimeStamp=h,g>=this.frameDeltaTime||i)this.lastCount=this.frameInterval;else{if(this.lastCount-=1e3,this.lastCount>0)return void(s&&this.render(!1,this.costEnterFrame+f-r));this.lastCount+=this.frameInterval}this.render(!0,this.costEnterFrame+f-r);var $=t.getTimer();this.broadcastEnterFrame();var y=t.getTimer();this.costEnterFrame=y-$},i.prototype.render=function(t,i){var r=this.playerList,n=r.length;if(0!=n){this.callLaters(),e.$invalidateRenderFlag&&(this.broadcastRender(),e.$invalidateRenderFlag=!1);for(var a=0;n>a;a++)r[a].$render(t,i);e.$requestRenderingFlag=!1}},i.prototype.broadcastEnterFrame=function(){var e=t.DisplayObject.$enterFrameCallBackList,i=e.length;if(0!=i){e=e.concat();for(var r=0;i>r;r++)e[r].dispatchEventWith(t.Event.ENTER_FRAME)}},i.prototype.broadcastRender=function(){var e=t.DisplayObject.$renderCallBackList,i=e.length;if(0!=i){e=e.concat();for(var r=0;i>r;r++)e[r].dispatchEventWith(t.Event.RENDER)}},i.prototype.callLaters=function(){var e,i,r;if(t.$callLaterFunctionList.length>0&&(e=t.$callLaterFunctionList,t.$callLaterFunctionList=[],i=t.$callLaterThisList,t.$callLaterThisList=[],r=t.$callLaterArgsList,t.$callLaterArgsList=[]),e)for(var n=e.length,a=0;n>a;a++){var o=e[a];null!=o&&o.apply(i[a],r[a])}},i.prototype.callLaterAsyncs=function(){if(t.$callAsyncFunctionList.length>0){var e=t.$callAsyncFunctionList,i=t.$callAsyncThisList,r=t.$callAsyncArgsList;t.$callAsyncFunctionList=[],t.$callAsyncThisList=[],t.$callAsyncArgsList=[];for(var n=0;n=this.maxTouches)){this.lastTouchX=e,this.lastTouchY=i;var n=this.findTarget(e,i);null==this.touchDownTarget[r]&&(this.touchDownTarget[r]=n,this.useTouchesCount++),t.TouchEvent.dispatchTouchEvent(n,t.TouchEvent.TOUCH_BEGIN,!0,!0,e,i,r,!0)}},i.prototype.onTouchMove=function(e,i,r){if(null!=this.touchDownTarget[r]&&(this.lastTouchX!=e||this.lastTouchY!=i)){this.lastTouchX=e,this.lastTouchY=i;var n=this.findTarget(e,i);t.TouchEvent.dispatchTouchEvent(n,t.TouchEvent.TOUCH_MOVE,!0,!0,e,i,r,!0)}},i.prototype.onTouchEnd=function(e,i,r){if(null!=this.touchDownTarget[r]){var n=this.findTarget(e,i),a=this.touchDownTarget[r];delete this.touchDownTarget[r],this.useTouchesCount--,t.TouchEvent.dispatchTouchEvent(n,t.TouchEvent.TOUCH_END,!0,!0,e,i,r,!1),a==n?t.TouchEvent.dispatchTouchEvent(n,t.TouchEvent.TOUCH_TAP,!0,!0,e,i,r,!1):t.TouchEvent.dispatchTouchEvent(a,t.TouchEvent.TOUCH_RELEASE_OUTSIDE,!0,!0,e,i,r,!1)}},i.prototype.findTarget=function(t,e){var i=this.stage.$hitTest(t,e);return i||(i=this.stage),i},i}(t.HashObject);e.TouchHandler=i,__reflect(i.prototype,"egret.sys.TouchHandler")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(e){function i(){var t=e.call(this)||this;return t.image=null,t.smoothing=!0,t.blendMode=null,t.alpha=0/0,t.filter=null,t.rotated=!1,t.type=1,t}return __extends(i,e),i.prototype.drawImage=function(t,e,i,r,n,a,o,s){this.drawData.push(t,e,i,r,n,a,o,s),this.renderCount++},i.prototype.cleanBeforeRender=function(){e.prototype.cleanBeforeRender.call(this),this.image=null,this.matrix=null,this.blendMode=null,this.alpha=0/0,this.filter=null},i.$updateTextureData=function(e,r,n,a,o,s,h,c,l,u,p,d,f,g,$,y){if(r){var v=t.$TextureScaleFactor;if(e.smoothing=y,e.image=r,e.imageWidth=f,e.imageHeight=g,$==t.BitmapFillMode.SCALE){var m=p/l*v,b=d/u*v;e.drawImage(n,a,o,s,m*h,b*c,m*o,b*s)}else if($==t.BitmapFillMode.CLIP){var x=Math.min(l,p),T=Math.min(u,d),_=o*v,D=s*v;i.drawClipImage(e,v,n,a,_,D,h,c,x,T)}else for(var _=o*v,D=s*v,O=0;p>O;O+=l)for(var w=0;d>w;w+=u){var x=Math.min(p-O,l),T=Math.min(d-w,u);i.drawClipImage(e,v,n,a,_,D,h,c,x,T,O,w)}}},i.$updateTextureDataWithScale9Grid=function(e,i,r,n,a,o,s,h,c,l,u,p,d,f,g,$){e.smoothing=$,e.image=i,e.imageWidth=f,e.imageHeight=g;var y=o,v=s;p-=l-o*t.$TextureScaleFactor,d-=u-s*t.$TextureScaleFactor;var m=r.x-h,b=r.y-c,x=m/t.$TextureScaleFactor,T=b/t.$TextureScaleFactor,_=r.width/t.$TextureScaleFactor,D=r.height/t.$TextureScaleFactor;0==D&&(D=1,T>=v&&T--),0==_&&(_=1,x>=y&&x--);var O=n,w=O+x,E=w+_,R=y-x-_,S=a,C=S+T,F=C+D,P=v-T-D,M=R*t.$TextureScaleFactor,j=P*t.$TextureScaleFactor;if((x+R)*t.$TextureScaleFactor>p||(T+P)*t.$TextureScaleFactor>d)return void e.drawImage(n,a,o,s,h,c,p,d);var A=h,B=A+m,N=A+(p-M),k=p-m-M,L=c,I=L+b,U=L+d-j,H=d-b-j;T>0&&(x>0&&e.drawImage(O,S,x,T,A,L,m,b),_>0&&e.drawImage(w,S,_,T,B,L,k,b),R>0&&e.drawImage(E,S,R,T,N,L,M,b)),D>0&&(x>0&&e.drawImage(O,C,x,D,A,I,m,H),_>0&&e.drawImage(w,C,_,D,B,I,k,H),R>0&&e.drawImage(E,C,R,D,N,I,M,H)),P>0&&(x>0&&e.drawImage(O,F,x,P,A,U,m,j),_>0&&e.drawImage(w,F,_,P,B,U,k,j),R>0&&e.drawImage(E,F,R,P,N,U,M,j))},i.drawClipImage=function(t,e,i,r,n,a,o,s,h,c,l,u){void 0===l&&(l=0),void 0===u&&(u=0);var p=o+n-h;p>0&&(n-=p),p=s+a-c,p>0&&(a-=p),t.drawImage(i,r,n/e,a/e,l+o,u+s,n,a)},i}(e.RenderNode);e.BitmapNode=i,__reflect(i.prototype,"egret.sys.BitmapNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=["none","round","square"],r=["bevel","miter","round"],n=function(n){function a(){var t=n.call(this)||this;return t.dirtyRender=!0,t.type=3,t}return __extends(a,n),a.prototype.beginFill=function(t,i,r){void 0===i&&(i=1);var n=new e.FillPath;if(n.fillColor=t,n.fillAlpha=i,r){var a=this.drawData.lastIndexOf(r);this.drawData.splice(a,0,n)}else this.drawData.push(n);return this.renderCount++,n},a.prototype.beginGradientFill=function(i,r,n,a,o,s){var h=new t.Matrix;o?(h.a=819.2*o.a,h.b=819.2*o.b,h.c=819.2*o.c,h.d=819.2*o.d,h.tx=o.tx,h.ty=o.ty):(h.a=100,h.d=100);var c=new e.GradientFillPath;if(c.gradientType=i,c.colors=r,c.alphas=n,c.ratios=a,c.matrix=h,s){var l=this.drawData.lastIndexOf(s);this.drawData.splice(l,0,c)}else this.drawData.push(c);return this.renderCount++,c},a.prototype.lineStyle=function(n,a,o,s,h,c,l){void 0===o&&(o=1),void 0===c&&(c=3),void 0===l&&(l=[]),-1==i.indexOf(s)&&(s="round"),-1==r.indexOf(h)&&(h="round");var u=new e.StrokePath;return u.lineWidth=n,u.lineColor=a,u.lineAlpha=o,u.caps=s||t.CapsStyle.ROUND,u.joints=h,u.miterLimit=c,u.lineDash=l,this.drawData.push(u),this.renderCount++,u},a.prototype.clear=function(){this.drawData.length=0,this.dirtyRender=!0,this.renderCount=0},a.prototype.cleanBeforeRender=function(){},a.prototype.clean=function(){this.$texture&&(t.WebGLUtils.deleteWebGLTexture(this.$texture),this.$texture=null,this.dirtyRender=!0)},a}(e.RenderNode);e.GraphicsNode=n,__reflect(n.prototype,"egret.sys.GraphicsNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.type=4,e}return __extends(e,t),e.prototype.addNode=function(t){this.drawData.push(t)},e.prototype.cleanBeforeRender=function(){for(var t=this.drawData,e=t.length-1;e>=0;e--)t[e].cleanBeforeRender()},e.prototype.$getRenderCount=function(){for(var t=0,e=this.drawData,i=e.length-1;i>=0;i--)t+=e[i].$getRenderCount();return t},e}(t.RenderNode);t.GroupNode=e,__reflect(e.prototype,"egret.sys.GroupNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(e){function i(){var i=e.call(this)||this;return i.image=null,i.smoothing=!0,i.bounds=new t.Rectangle,i.blendMode=null,i.alpha=0/0,i.filter=null,i.rotated=!1,i.type=5,i.vertices=[],i.uvs=[],i.indices=[],i}return __extends(i,e),i.prototype.drawMesh=function(t,e,i,r,n,a,o,s){this.drawData.push(t,e,i,r,n,a,o,s),this.renderCount++},i.prototype.cleanBeforeRender=function(){e.prototype.cleanBeforeRender.call(this),this.image=null,this.matrix=null},i}(e.RenderNode);e.MeshNode=i,__reflect(i.prototype,"egret.sys.MeshNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.image=null,e.smoothing=!0,e.rotated=!1,e.type=6,e}return __extends(e,t),e.prototype.drawImage=function(t,e,i,r,n,a,o,s){var h=this;h.sourceX=t,h.sourceY=e,h.sourceW=i,h.sourceH=r,h.drawX=n,h.drawY=a,h.drawW=o,h.drawH=s,h.renderCount=1},e.prototype.cleanBeforeRender=function(){t.prototype.cleanBeforeRender.call(this),this.image=null},e}(t.RenderNode);t.NormalBitmapNode=e,__reflect(e.prototype,"egret.sys.NormalBitmapNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(i){var r=e.call(this,i)||this;return r._verticesDirty=!0,r._bounds=new t.Rectangle,r.$renderNode=new t.sys.MeshNode,r}return __extends(i,e),i.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(12)},i.prototype.setBitmapDataToWasm=function(t){this.$nativeDisplayObject.setBitmapDataToMesh(t)},i.prototype.$updateRenderNode=function(){var e=this.$bitmapData;if(e){var i=(t.$TextureScaleFactor,this.$renderNode);i.smoothing=this.$smoothing,i.image=e,i.imageWidth=this.$sourceWidth,i.imageHeight=this.$sourceHeight;var r=isNaN(this.$explicitBitmapWidth)?this.$textureWidth:this.$explicitBitmapWidth,n=isNaN(this.$explicitBitmapHeight)?this.$textureHeight:this.$explicitBitmapHeight,a=r/this.$textureWidth,o=n/this.$textureHeight,s=this.$bitmapWidth,h=this.$bitmapHeight;i.drawMesh(this.$bitmapX,this.$bitmapY,s,h,this.$offsetX*a,this.$offsetY*o,a*s,o*h)}},i.prototype.$updateVertices=function(){var e=this;if(e._verticesDirty=!0,e.$renderDirty=!0,t.nativeRender){var i=this.$renderNode;this.$nativeDisplayObject.setDataToMesh(i.vertices,i.indices,i.uvs)}else{var r=e.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=e.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},i.prototype.$measureContentBounds=function(t){if(this._verticesDirty){this._verticesDirty=!1;var e=this.$renderNode,i=e.vertices;if(i.length){this._bounds.setTo(Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var r=0,n=i.length;n>r;r+=2){var a=i[r],o=i[r+1];this._bounds.x>a&&(this._bounds.x=a),this._bounds.widtho&&(this._bounds.y=o),this._bounds.height>16,r=t>>8&255,n=255&t;return"rgba("+i+","+r+","+n+","+e+")"}function r(e,r,n,a,o,s){var h;h=r==t.GradientType.LINEAR?e.createLinearGradient(-1,0,1,0):e.createRadialGradient(0,0,0,0,0,1);for(var c=n.length,l=0;c>l;l++)h.addColorStop(o[l]/255,i(n[l],a[l]));return h}function n(t,e,i){void 0===i&&(i=0);for(var r=0,n=e.length;n>r;r++)t[r+i]=e[r]}function a(t,e,i,r){for(var n=r[0],a=r[1],o=r[2],s=r[3],h=r[4],c=r[5],l=r[6],u=r[7],p=r[8],d=r[9],f=r[10],g=r[11],$=r[12],y=r[13],v=r[14],m=r[15],b=r[16],x=r[17],T=r[18],_=r[19],D=0,O=e*i*4;O>D;D+=4){var w=t[D+0],E=t[D+1],R=t[D+2],S=t[D+3];t[D+0]=n*w+a*E+o*R+s*S+h,t[D+1]=c*w+l*E+u*R+p*S+d,t[D+2]=f*w+g*E+$*R+y*S+v,t[D+3]=m*w+b*E+x*R+T*S+_}}function o(t,e,i,r,n){s(t,e,i,r),h(t,e,i,n)}function s(t,e,i,r){var a;a=_?new Uint8ClampedArray(4*e):new Array(4*e);for(var o=4*e,s=2*r+1,h=0;i>h;h++){for(var c=h*o,l=0,u=0,p=0,d=0,f=0,g=0,$=4*-r,y=4*r+4;y>$;$+=4){var v=c+$;c>v||v>=c+o||(f=t[v+3],l+=t[v+0]*f,u+=t[v+1]*f,p+=t[v+2]*f,d+=f)}for(var $=c,y=c+o,m=0,b=$-4*r,x=$+4*(r+1);y>$;$+=4,m+=4,x+=4,b+=4)0===d?(a[m+0]=0,a[m+1]=0,a[m+2]=0,a[m+3]=0):(a[m+0]=l/d,a[m+1]=u/d,a[m+2]=p/d,a[m+3]=d/s),f=t[x+3],g=t[b+3],f||0==f?g||0==g?(l+=t[x+0]*f-t[b+0]*g,u+=t[x+1]*f-t[b+1]*g,p+=t[x+2]*f-t[b+2]*g,d+=f-g):(l+=t[x+0]*f,u+=t[x+1]*f,p+=t[x+2]*f,d+=f):(g||0==g)&&(l+=-t[b+0]*g,u+=-t[b+1]*g,p+=-t[b+2]*g,d+=-g);_?t.set(a,c):n(t,a,c)}}function h(t,e,i,r){var n;n=_?new Uint8ClampedArray(4*i):new Array(4*i);for(var a=4*e,o=2*r+1,s=0;e>s;s++){for(var h=4*s,c=0,l=0,u=0,p=0,d=0,f=0,g=-r*a,$=r*a+a;$>g;g+=a){var y=h+g;h>y||y>=h+i*a||(d=t[y+3],c+=t[y+0]*d,l+=t[y+1]*d,u+=t[y+2]*d,p+=d)}for(var g=h,$=h+i*a,v=0,m=h-r*a,b=h+(r+1)*a;$>g;g+=a,v+=4,b+=a,m+=a)0===p?(n[v+0]=0,n[v+1]=0,n[v+2]=0,n[v+3]=0):(n[v+0]=c/p,n[v+1]=l/p,n[v+2]=u/p,n[v+3]=p/o),d=t[b+3],f=t[m+3],d||0==d?f||0==f?(c+=t[b+0]*d-t[m+0]*f,l+=t[b+1]*d-t[m+1]*f,u+=t[b+2]*d-t[m+2]*f,p+=d-f):(c+=t[b+0]*d,l+=t[b+1]*d,u+=t[b+2]*d,p+=d):(f||0==f)&&(c+=-t[m+0]*f,l+=-t[m+1]*f,u+=-t[m+2]*f,p+=-f);for(var x=4*s,$=x+i*a,T=0;$>x;x+=a,T+=4)t[x+0]=n[T+0],t[x+1]=n[T+1],t[x+2]=n[T+2],t[x+3]=n[T+3]}}function c(t,e,i,r,a,s,h,c,f){var g=l(t,r);u(g,e,i,h,c),o(g,e,i,a,s),p(g,f),d(g,t),t.set(g),_?t.set(g):n(t,g)}function l(t,e){e||(e=[0,0,0,0]);var i;_?i=new Uint8ClampedArray(t):(i=new Array(t.length),n(i,t));for(var r=e[0],a=e[1],o=e[2],s=e[3],h=0,c=i.length;c>h;h+=4){var l=i[h+3];i[h+0]=r*l,i[h+1]=a*l,i[h+2]=o*l,i[h+3]=s*l}return i}function u(t,e,i,r,a){var o,s,h=Math.sin(r)*a|0,c=Math.cos(r)*a|0;if(_){o=new Int32Array(t.buffer),s=new Int32Array(o.length);for(var l=0;i>l;l++){var u=l+h;if(!(0>u||u>i))for(var p=0;e>p;p++){var d=p+c;0>d||d>e||(s[u*e+d]=o[l*e+p])}}o.set(s)}else{o=t,s=new Array(o.length);for(var l=0;i>l;l++){var u=l+h;if(!(0>u||u>i))for(var p=0;e>p;p++){var d=p+c;0>d||d>e||(s[4*(u*e+d)+0]=o[4*(l*e+p)+0],s[4*(u*e+d)+1]=o[4*(l*e+p)+1],s[4*(u*e+d)+2]=o[4*(l*e+p)+2],s[4*(u*e+d)+3]=o[4*(l*e+p)+3])}}n(o,s)}}function p(t,e){for(var i=0,r=t.length;r>i;i+=4)t[i+3]*=e}function d(t,e){for(var i=0,r=t.length;r>i;i+=4){var n=t[i+0],a=t[i+1],o=t[i+2],s=t[i+3]/255,h=e[i+0],c=e[i+1],l=e[i+2],u=e[i+3]/255;t[i+0]=h+n*(1-u),t[i+1]=c+a*(1-u),t[i+2]=l+o*(1-u),t[i+3]=255*(u+s*(1-u))}}function f(t,e,i){return t*(1-i)+e*i}function g(t,e,i,r,a,o,s,h,c,l,u,p){var d;d=_?new Uint8ClampedArray(t.length):new Array(t.length);for(var g,$,y=r[3],v=0,m=0,b=h*Math.cos(s),x=h*Math.sin(s),T=7,D=12,O=3.141592653589793,w=a/T,E=o/T,R=0;e>R;R++)for(var S=0;i>S;S++){for(var C=0,F=S*e*4+4*R,P=0,M=0,j=t[F+0]/255,A=t[F+1]/255,B=t[F+2]/255,N=t[F+3]/255,k=0;2*O>=k;k+=2*O/D){g=Math.cos(k+C),$=Math.sin(k+C);for(var L=0;T>L;L++){v=L*w*g,m=L*E*$;var I=Math.round(R+v-b),U=Math.round(S+m-x),H=0;if(I>=e||0>I||0>U||U>=i)H=0;else{var X=U*e*4+4*I;H=t[X+3]/255}P+=(T-L)*H,M+=T-L}}N=Math.max(N,1e-4);var Y=P/M*c*y*(1-l)*Math.max(Math.min(p,u),1-N),W=(M-P)/M*c*y*l*N;N=Math.max(N*u*(1-p),1e-4);var G=W/(W+N),z=f(j,r[0],G),V=f(A,r[1],G),q=f(B,r[2],G),K=Y/(W+N+Y),J=f(z,r[0],K),Q=f(V,r[1],K),Z=f(q,r[2],K),te=Math.min(N+Y+W,1); -d[F+0]=255*J,d[F+1]=255*Q,d[F+2]=255*Z,d[F+3]=255*te}_?t.set(d):n(t,d)}var $=["source-over","lighter","destination-out"],y="source-over",v="#000000",m={none:"butt",square:"square",round:"round"},b=[],x=[],T=function(){function n(){this.nestLevel=0,this.renderingMask=!1}return n.prototype.render=function(e,i,r,n){this.nestLevel++;var a=i.context;a.transform(r.a,r.b,r.c,r.d,0,0);var o=this.drawDisplayObject(e,a,r.tx,r.ty,!0),s=t.Matrix.create();if(r.$invertInto(s),a.transform(s.a,s.b,s.c,s.d,0,0),t.Matrix.release(s),this.nestLevel--,0===this.nestLevel){b.length>6&&(b.length=6);for(var h=b.length,c=0;h>c;c++)b[c].resize(0,0)}return o},n.prototype.drawDisplayObject=function(e,i,r,n,a){var o,s=0,h=e.$displayList;if(h&&!a?((e.$cacheDirty||e.$renderDirty||h.$canvasScaleX!=t.sys.DisplayList.$canvasScaleX||h.$canvasScaleY!=t.sys.DisplayList.$canvasScaleY)&&(s+=h.drawToSurface()),o=h.$renderNode):o=e.$renderDirty?e.$getRenderNode():e.$renderNode,e.$cacheDirty=!1,o){switch(s++,i.$offsetX=r,i.$offsetY=n,o.type){case 1:this.renderBitmap(o,i);break;case 2:this.renderText(o,i);break;case 3:this.renderGraphics(o,i);break;case 4:this.renderGroup(o,i);break;case 5:this.renderMesh(o,i);break;case 6:this.renderNormalBitmap(o,i)}i.$offsetX=0,i.$offsetY=0}if(h&&!a)return s;var c=e.$children;if(c)for(var l=c.length,u=0;l>u;u++){var p=c[u],d=void 0,f=void 0;if(p.$useTranslate){var g=p.$getMatrix();d=r+p.$x,f=n+p.$y,i.save(),i.transform(g.a,g.b,g.c,g.d,d,f),d=-p.$anchorOffsetX,f=-p.$anchorOffsetY}else d=r+p.$x-p.$anchorOffsetX,f=n+p.$y-p.$anchorOffsetY;var $=void 0;switch(1!=p.$alpha&&($=i.globalAlpha,i.globalAlpha*=p.$alpha),p.$renderMode){case 1:break;case 2:s+=this.drawWithFilter(p,i,d,f);break;case 3:s+=this.drawWithClip(p,i,d,f);break;case 4:s+=this.drawWithScrollRect(p,i,d,f);break;default:s+=this.drawDisplayObject(p,i,d,f)}p.$useTranslate?i.restore():$&&(i.globalAlpha=$)}return s},n.prototype.drawWithFilter=function(t,e,i,r){if(t.$children&&0==t.$children.length&&(!t.$renderNode||0==t.$renderNode.$getRenderCount()))return 0;var n,s=0,h=t.$filters,l=h.length,u=0!==t.$blendMode;u&&(n=$[t.$blendMode],n||(n=y));var p=t.$getOriginalBounds(),d=p.x,f=p.y,v=p.width,m=p.height;if(0>=v||0>=m)return s;var b=this.createRenderBuffer(v-d,m-f,!0),T=b.context;if(s+=t.$mask?this.drawWithClip(t,T,-d,-f):t.$scrollRect||t.$maskRect?this.drawWithScrollRect(t,T,-d,-f):this.drawDisplayObject(t,T,-d,-f),s>0){u&&(e.globalCompositeOperation=n),s++;for(var _=T.getImageData(0,0,b.surface.width,b.surface.height),D=0;l>D;D++){var O=h[D];if("colorTransform"==O.type)a(_.data,b.surface.width,b.surface.height,O.$matrix);else if("blur"==O.type)o(_.data,b.surface.width,b.surface.height,O.$blurX,O.$blurY);else if("glow"==O.type){var w=O.$red,E=O.$green,R=O.$blue,S=O.$alpha;O.$inner||O.$knockout||O.$hideObject?g(_.data,b.surface.width,b.surface.height,[w/255,E/255,R/255,S],O.$blurX,O.$blurY,O.$angle?O.$angle/180*Math.PI:0,O.$distance||0,O.$strength,O.$inner?1:0,O.$knockout?0:1,O.$hideObject?1:0):c(_.data,b.surface.width,b.surface.height,[w/255,E/255,R/255,S],O.$blurX,O.$blurY,O.$angle?O.$angle/180*Math.PI:0,O.$distance||0,O.$strength)}else"custom"==O.type}T.putImageData(_,0,0),e.drawImage(b.surface,i+d,r+f),u&&(e.globalCompositeOperation=y)}return x.push(b),s},n.prototype.drawWithClip=function(e,i,r,n){var a,o=0,s=0!==e.$blendMode;s&&(a=$[e.$blendMode],a||(a=y));var h=e.$scrollRect?e.$scrollRect:e.$maskRect,c=e.$mask;if(c){var l=c.$getMatrix();if(0==l.a&&0==l.b||0==l.c&&0==l.d)return o}if(!(c||e.$children&&0!=e.$children.length))return h&&(i.save(),i.beginPath(),i.rect(h.x+r,h.y+n,h.width,h.height),i.clip()),s&&(i.globalCompositeOperation=a),o+=this.drawDisplayObject(e,i,r,n),s&&(i.globalCompositeOperation=y),h&&i.restore(),o;if(c){var u=c.$getRenderNode();if((!c.$children||0==c.$children.length)&&u&&3==u.type&&1==u.drawData.length&&1==u.drawData[0].type&&1==u.drawData[0].fillAlpha){this.renderingMask=!0,i.save();var p=t.Matrix.create();p.copyFrom(c.$getConcatenatedMatrix()),c.$getConcatenatedMatrixAt(e,p),p.prepend(1,0,0,1,r,n),i.transform(p.a,p.b,p.c,p.d,p.tx,p.ty);var d=this.drawDisplayObject(c,i,0,0);return this.renderingMask=!1,p.$invertInto(p),i.transform(p.a,p.b,p.c,p.d,p.tx,p.ty),t.Matrix.release(p),h&&(i.beginPath(),i.rect(h.x+r,h.y+n,h.width,h.height),i.clip()),d+=this.drawDisplayObject(e,i,r,n),i.restore(),d}}var f=e.$getOriginalBounds(),g=f.x,v=f.y,m=f.width,x=f.height;if(0>=m||0>=x)return o;var T=this.createRenderBuffer(m,x),_=T.context;if(!_)return o+=this.drawDisplayObject(e,i,r,n);if(o+=this.drawDisplayObject(e,_,-g,-v),c){var u=c.$getRenderNode(),p=t.Matrix.create();if(p.copyFrom(c.$getConcatenatedMatrix()),c.$getConcatenatedMatrixAt(e,p),p.translate(-g,-v),u&&1==u.$getRenderCount()||c.$displayList)_.globalCompositeOperation="destination-in",_.save(),_.setTransform(p.a,p.b,p.c,p.d,p.tx,p.ty),o+=this.drawDisplayObject(c,_,0,0),_.restore();else{var D=this.createRenderBuffer(m,x),O=D.context;O.setTransform(p.a,p.b,p.c,p.d,p.tx,p.ty),o+=this.drawDisplayObject(c,O,0,0),_.globalCompositeOperation="destination-in",_.drawImage(D.surface,0,0),b.push(D)}t.Matrix.release(p)}return o>0&&(o++,s&&(i.globalCompositeOperation=a),h&&(i.save(),i.beginPath(),i.rect(h.x+r,h.y+n,h.width,h.height),i.clip()),i.drawImage(T.surface,r+g,n+v),h&&i.restore(),s&&(i.globalCompositeOperation=y)),b.push(T),o},n.prototype.drawWithScrollRect=function(t,e,i,r){var n=0,a=t.$scrollRect?t.$scrollRect:t.$maskRect;return a.isEmpty()?n:(t.$scrollRect&&(i-=a.x,r-=a.y),e.save(),e.beginPath(),e.rect(a.x+i,a.y+r,a.width,a.height),e.clip(),n+=this.drawDisplayObject(t,e,i,r),e.restore(),n)},n.prototype.drawNodeToBuffer=function(t,e,i,r){var n=e.context;n.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty),this.renderNode(t,n,r)},n.prototype.drawDisplayToBuffer=function(t,e,i){var r=e.context;i&&r.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty);var n;n=t.$renderDirty?t.$getRenderNode():t.$renderNode;var a=0;if(n)switch(a++,n.type){case 1:this.renderBitmap(n,r);break;case 2:this.renderText(n,r);break;case 3:this.renderGraphics(n,r);break;case 4:this.renderGroup(n,r);break;case 5:this.renderMesh(n,r);break;case 6:this.renderNormalBitmap(n,r)}var o=t.$children;if(o)for(var s=o.length,h=0;s>h;h++){var c=o[h];switch(c.$renderMode){case 1:break;case 2:a+=this.drawWithFilter(c,r,0,0);break;case 3:a+=this.drawWithClip(c,r,0,0);break;case 4:a+=this.drawWithScrollRect(c,r,0,0);break;default:a+=this.drawDisplayObject(c,r,0,0)}}return a},n.prototype.renderNode=function(t,e,i){var r=0;switch(t.type){case 1:r=this.renderBitmap(t,e);break;case 2:r=1,this.renderText(t,e);break;case 3:r=this.renderGraphics(t,e,i);break;case 4:r=this.renderGroup(t,e);break;case 5:r=this.renderMesh(t,e);break;case 6:r+=this.renderNormalBitmap(t,e)}return r},n.prototype.renderNormalBitmap=function(t,e){var i=t.image;if(!i||!i.source)return 0;if(e.$imageSmoothingEnabled!=t.smoothing&&(e.imageSmoothingEnabled=t.smoothing,e.$imageSmoothingEnabled=t.smoothing),t.rotated){var r=t.sourceX,n=t.sourceY,a=t.sourceW,o=t.sourceH,s=t.drawX,h=t.drawY,c=t.drawW,l=t.drawH;e.save(),e.transform(0,-1,1,0,0,l),e.drawImage(i.source,r,n,o,a,s+e.$offsetX,h+e.$offsetY,l,c),e.restore()}else e.drawImage(i.source,t.sourceX,t.sourceY,t.sourceW,t.sourceH,t.drawX+e.$offsetX,t.drawY+e.$offsetY,t.drawW,t.drawH);return 1},n.prototype.renderBitmap=function(t,e){var i=t.image;if(!i||!i.source)return 0;e.$imageSmoothingEnabled!=t.smoothing&&(e.imageSmoothingEnabled=t.smoothing,e.$imageSmoothingEnabled=t.smoothing);var r,n,o=t.drawData,s=o.length,h=0,c=t.matrix,l=t.blendMode,u=t.alpha,p=!1;c&&(e.save(),p=!0,(0!=e.$offsetX||0!=e.$offsetY)&&(e.translate(e.$offsetX,e.$offsetY),r=e.$offsetX,n=e.$offsetY,e.$offsetX=e.$offsetY=0),e.transform(c.a,c.b,c.c,c.d,c.tx,c.ty)),l&&(e.globalCompositeOperation=$[l]);var d;u==u&&(d=e.globalAlpha,e.globalAlpha*=u);var f=0,g=t.filter;if(g&&8==s){var v=o[0],m=o[1],x=o[2],T=o[3],_=o[4],D=o[5],O=o[6],w=o[7];t.rotated&&(x=o[3],T=o[2],O=o[7],w=o[6]);var E=this.createRenderBuffer(O,w),R=E.context;f++,t.rotated&&e.transform(0,-1,1,0,0,O),R.drawImage(i.source,v,m,x,T,0,0,O,w),f++;var S=R.getImageData(0,0,O,w);a(S.data,O,w,g.$matrix),R.putImageData(S,0,0),e.drawImage(E.surface,0,0,O,w,_+e.$offsetX,D+e.$offsetY,O,w),b.push(E)}else for(;s>h;)if(f++,t.rotated){var v=o[h++],m=o[h++],T=o[h++],x=o[h++],C=o[h++],F=o[h++],w=o[h++],O=o[h++];e.save(),e.transform(0,-1,1,0,0,O),e.drawImage(i.source,v,m,x,T,C+e.$offsetX,F+e.$offsetY,O,w),e.restore()}else e.drawImage(i.source,o[h++],o[h++],o[h++],o[h++],o[h++]+e.$offsetX,o[h++]+e.$offsetY,o[h++],o[h++]);return p?e.restore():(l&&(e.globalCompositeOperation=y),u==u&&(e.globalAlpha=d)),r&&(e.$offsetX=r),n&&(e.$offsetY=n),f},n.prototype.renderMesh=function(t,e){return 0},n.prototype.renderText=function(i,r){r.textAlign="left",r.textBaseline="middle",r.lineJoin="round";for(var n=i.drawData,a=n.length,o=0;a>o;){var s=n[o++],h=n[o++],c=n[o++],l=n[o++];r.font=e(i,l);var u=null==l.textColor?i.textColor:l.textColor,p=null==l.strokeColor?i.strokeColor:l.strokeColor,d=null==l.stroke?i.stroke:l.stroke;r.fillStyle=t.toColorString(u),r.strokeStyle=t.toColorString(p),d&&(r.lineWidth=2*d,r.strokeText(c,s+r.$offsetX,h+r.$offsetY)),r.fillText(c,s+r.$offsetX,h+r.$offsetY)}},n.prototype.renderGraphics=function(t,e,n){var a=t.drawData,o=a.length;n=!!n;for(var s=0;o>s;s++){var h=a[s];switch(h.type){case 1:var c=h;e.fillStyle=n?v:i(c.fillColor,c.fillAlpha),this.renderPath(h,e),this.renderingMask?e.clip():e.fill();break;case 2:var l=h;e.fillStyle=n?v:r(e,l.gradientType,l.colors,l.alphas,l.ratios,l.matrix),e.save();var u=l.matrix;this.renderPath(h,e),e.transform(u.a,u.b,u.c,u.d,u.tx,u.ty),e.fill(),e.restore();break;case 3:var p=h,d=p.lineWidth;e.lineWidth=d,e.strokeStyle=n?v:i(p.lineColor,p.lineAlpha),e.lineCap=m[p.caps],e.lineJoin=p.joints,e.miterLimit=p.miterLimit,e.setLineDash&&e.setLineDash(p.lineDash);var f=1===d||3===d;f&&e.translate(.5,.5),this.renderPath(h,e),e.stroke(),f&&e.translate(-.5,-.5)}}return 0==o?0:1},n.prototype.renderPath=function(t,e){e.beginPath();for(var i=t.$data,r=t.$commands,n=r.length,a=0,o=0;n>o;o++){var s=r[o];switch(s){case 4:e.bezierCurveTo(i[a++]+e.$offsetX,i[a++]+e.$offsetY,i[a++]+e.$offsetX,i[a++]+e.$offsetY,i[a++]+e.$offsetX,i[a++]+e.$offsetY);break;case 3:e.quadraticCurveTo(i[a++]+e.$offsetX,i[a++]+e.$offsetY,i[a++]+e.$offsetX,i[a++]+e.$offsetY);break;case 2:e.lineTo(i[a++]+e.$offsetX,i[a++]+e.$offsetY);break;case 1:e.moveTo(i[a++]+e.$offsetX,i[a++]+e.$offsetY)}}},n.prototype.renderGroup=function(t,e){var i,r,n=t.matrix,a=!1;n&&(e.save(),a=!0,(0!=e.$offsetX||0!=e.$offsetY)&&(e.translate(e.$offsetX,e.$offsetY),i=e.$offsetX,r=e.$offsetY,e.$offsetX=e.$offsetY=0),e.transform(n.a,n.b,n.c,n.d,n.tx,n.ty));for(var o=0,s=t.drawData,h=s.length,c=0;h>c;c++){var l=s[c];o+=this.renderNode(l,e)}return a&&e.restore(),i&&(e.$offsetX=i),r&&(e.$offsetY=r),o},n.prototype.createRenderBuffer=function(e,i,r){var n=r?x.pop():b.pop();return n?n.resize(e,i,!0):n=new t.sys.CanvasRenderBuffer(e,i),n},n}();t.CanvasRenderer=T,__reflect(T.prototype,"egret.CanvasRenderer"),t.getFontString=e,t.getRGBAString=i;var _=!1;try{_=void 0!==typeof Uint8ClampedArray}catch(D){}}(egret||(egret={}));var egret;!function(t){t.DeviceOrientation=null}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e;!function(t){t.WEB="web",t.NATIVE="native",t.RUNTIME2="runtime2",t.MYGAME="mygame",t.WXGAME="wxgame",t.BAIDUGAME="baidugame",t.QGAME="qgame",t.OPPOGAME="oppogame",t.QQGAME="qqgame",t.VIVOGAME="vivogame"}(e=t.RuntimeType||(t.RuntimeType={}));var i=function(){function e(){}return e.language="zh-CN",e.os="Unknown",e.runtimeType=t.RuntimeType.WEB,e.engineVersion="5.2.33",e.renderMode="Unknown",e.boundingClientWidth=0,e.boundingClientHeight=0,e}();t.Capabilities=i,__reflect(i.prototype,"egret.Capabilities")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var i=e.call(this)||this;i.$renderBuffer=new t.sys.RenderBuffer;var r=new t.BitmapData(i.$renderBuffer.surface);return r.$deleteSource=!1,i._setBitmapData(r),i}return __extends(i,e),i.prototype.drawToTexture=function(e,i,r){if(void 0===r&&(r=1),i&&(0==i.width||0==i.height))return!1;var n=i||e.$getOriginalBounds();if(0==n.width||0==n.height)return!1;r/=t.$TextureScaleFactor;var a=(n.x+n.width)*r,o=(n.y+n.height)*r;i&&(a=n.width*r,o=n.height*r);var s=this.$renderBuffer;if(!s)return!1;if(s.resize(a,o),this.$bitmapData.width=a,this.$bitmapData.height=o,t.nativeRender){egret_native.activateBuffer(this.$renderBuffer);var h=!1,c=0,l=0,u=0,p=0;i&&(h=!0,c=i.x,l=i.y,u=i.width,p=i.height),egret_native.updateNativeRender(),egret_native.nrRenderDisplayObject(e.$nativeDisplayObject.id,r,h,c,l,u,p),egret_native.activateBuffer(null)}else{var d=t.Matrix.create();d.identity(),d.scale(r,r),i&&d.translate(-i.x,-i.y),t.sys.systemRenderer.render(e,s,d,!0),t.Matrix.release(d)}return this.$initData(0,0,a,o,0,0,a,o,a,o),!0},i.prototype.getPixel32=function(e,i){var r;if(this.$renderBuffer){var n=t.$TextureScaleFactor;e=Math.round(e/n),i=Math.round(i/n),r=this.$renderBuffer.getPixels(e,i,1,1)}return r},i.prototype.dispose=function(){e.prototype.dispose.call(this),this.$renderBuffer=null},i}(t.Texture);t.RenderTexture=e,__reflect(e.prototype,"egret.RenderTexture")}(egret||(egret={}));var egret;!function(t){function e(t,e){r[t]=e}function i(t){return r[t]}var r={};t.registerImplementation=e,t.getImplementation=i}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.$graphics=new t.Graphics,i.$graphics.$setTarget(i),i}return __extends(i,e),i.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(8)},Object.defineProperty(i.prototype,"graphics",{get:function(){return this.$graphics},enumerable:!0,configurable:!0}),i.prototype.$measureContentBounds=function(t){this.$graphics.$measureContentBounds(t)},i.prototype.$hitTest=function(t,i){var r=e.prototype.$hitTest.call(this,t,i);return r==this&&(r=this.$graphics.$hitTest(t,i)),r},i.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this),this.$graphics&&this.$graphics.$onRemoveFromStage()},i}(t.DisplayObject);t.Shape=e,__reflect(e.prototype,"egret.Shape")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i){var r=t.call(this,e)||this;return r.firstCharHeight=0,"string"==typeof i?r.charList=r.parseConfig(i):i&&i.hasOwnProperty("frames")?r.charList=i.frames:r.charList={},r}return __extends(e,t),e.prototype.getTexture=function(t){var e=this._textureMap[t];if(!e){var i=this.charList[t];if(!i)return null;e=this.createTexture(t,i.x,i.y,i.w,i.h,i.offX,i.offY,i.sourceW,i.sourceH),this._textureMap[t]=e}return e},e.prototype.getConfig=function(t,e){return this.charList[t]?this.charList[t][e]:0},e.prototype._getFirstCharHeight=function(){if(0==this.firstCharHeight)for(var t in this.charList){var e=this.charList[t];if(e){var i=e.sourceH;if(void 0===i){var r=e.h;void 0===r&&(r=0);var n=e.offY;void 0===n&&(n=0),i=r+n}if(0>=i)continue;this.firstCharHeight=i;break}}return this.firstCharHeight},e.prototype.parseConfig=function(t){t=t.split("\r\n").join("\n");for(var e=t.split("\n"),i=this.getConfigByKey(e[3],"count"),r={},n=4;4+i>n;n++){var a=e[n],o=String.fromCharCode(this.getConfigByKey(a,"id")),s={};r[o]=s,s.x=this.getConfigByKey(a,"x"),s.y=this.getConfigByKey(a,"y"),s.w=this.getConfigByKey(a,"width"),s.h=this.getConfigByKey(a,"height"),s.offX=this.getConfigByKey(a,"xoffset"),s.offY=this.getConfigByKey(a,"yoffset"),s.xadvance=this.getConfigByKey(a,"xadvance")}return r},e.prototype.getConfigByKey=function(t,e){for(var i=t.split(" "),r=0,n=i.length;n>r;r++){var a=i[r];if(e==a.substring(0,e.length)){var o=a.substring(e.length+1);return parseInt(o)}}return 0},e}(t.SpriteSheet);t.BitmapFont=e,__reflect(e.prototype,"egret.BitmapFont")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.$smoothing=t.Bitmap.defaultSmoothing,i.$text="",i.$textFieldWidth=0/0,i.$textLinesChanged=!1,i.$textFieldHeight=0/0,i.$font=null,i.$fontStringChanged=!1,i.$lineSpacing=0,i.$letterSpacing=0,i.$textAlign=t.HorizontalAlign.LEFT,i.$verticalAlign=t.VerticalAlign.TOP,i.$textWidth=0/0,i.$textHeight=0/0,i.$textOffsetX=0,i.$textOffsetY=0,i.$textStartX=0,i.$textStartY=0,i.textLines=[],i.$lineHeights=[],t.nativeRender||(i.$renderNode=new t.sys.BitmapNode),i}return __extends(i,e),i.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(11)},Object.defineProperty(i.prototype,"smoothing",{get:function(){return this.$smoothing},set:function(e){var i=this;if(e!=i.$smoothing&&(i.$smoothing=e,!t.nativeRender)){var r=i.$parent;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp());var n=i.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"text",{get:function(){return this.$text},set:function(t){this.$setText(t)},enumerable:!0,configurable:!0}),i.prototype.$setText=function(t){t=null==t?"":String(t);var e=this;return t==e.$text?!1:(e.$text=t,e.$invalidateContentBounds(),!0)},i.prototype.$getWidth=function(){var t=this,e=t.$textFieldWidth;return isNaN(e)?t.$getContentBounds().width:e},i.prototype.$setWidth=function(t){var e=this;return 0>t||t==e.$textFieldWidth?!1:(e.$textFieldWidth=t,e.$invalidateContentBounds(),!0)},i.prototype.$invalidateContentBounds=function(){this.$renderDirty=!0,this.$textLinesChanged=!0,this.$updateRenderNode()},i.prototype.$getHeight=function(){var t=this,e=t.$textFieldHeight;return isNaN(e)?t.$getContentBounds().height:e},i.prototype.$setHeight=function(t){var e=this;return 0>t||t==e.$textFieldHeight?!1:(e.$textFieldHeight=t,e.$invalidateContentBounds(),!0)},Object.defineProperty(i.prototype,"font",{get:function(){return this.$font},set:function(t){this.$setFont(t)},enumerable:!0,configurable:!0}),i.prototype.$setFont=function(t){var e=this;return e.$font==t?!1:(e.$font=t,e.$fontStringChanged=!0,this.$invalidateContentBounds(),!0)},Object.defineProperty(i.prototype,"lineSpacing",{get:function(){return this.$lineSpacing},set:function(t){this.$setLineSpacing(t)},enumerable:!0,configurable:!0}),i.prototype.$setLineSpacing=function(t){var e=this;return e.$lineSpacing==t?!1:(e.$lineSpacing=t,e.$invalidateContentBounds(),!0)},Object.defineProperty(i.prototype,"letterSpacing",{get:function(){return this.$letterSpacing},set:function(t){this.$setLetterSpacing(t)},enumerable:!0,configurable:!0}),i.prototype.$setLetterSpacing=function(t){var e=this;return e.$letterSpacing==t?!1:(e.$letterSpacing=t,e.$invalidateContentBounds(),!0)},Object.defineProperty(i.prototype,"textAlign",{get:function(){return this.$textAlign},set:function(t){this.$setTextAlign(t)},enumerable:!0,configurable:!0}),i.prototype.$setTextAlign=function(t){var e=this;return e.$textAlign==t?!1:(e.$textAlign=t,e.$invalidateContentBounds(),!0)},Object.defineProperty(i.prototype,"verticalAlign",{get:function(){return this.$verticalAlign},set:function(t){this.$setVerticalAlign(t)},enumerable:!0,configurable:!0}),i.prototype.$setVerticalAlign=function(t){var e=this;return e.$verticalAlign==t?!1:(e.$verticalAlign=t,e.$invalidateContentBounds(),!0)},i.prototype.$updateRenderNode=function(){var e=this,r=this.$getTextLines(),n=r.length;if(0==n)return void(t.nativeRender&&e.$font&&(e.$nativeDisplayObject.setDataToBitmapNode(e.$nativeDisplayObject.id,e.$font.$texture,[]),e.$nativeDisplayObject.setWidth(0),e.$nativeDisplayObject.setHeight(0)));var a,o=[],s=this.$textLinesWidth,h=e.$font;t.nativeRender||(a=this.$renderNode,h.$texture&&(a.image=h.$texture.$bitmapData),a.smoothing=e.$smoothing);for(var c=h._getFirstCharHeight(),l=Math.ceil(c*i.EMPTY_FACTOR),u=!isNaN(e.$textFieldHeight),p=e.$textWidth,d=e.$textFieldWidth,f=e.$textFieldHeight,g=e.$textAlign,$=this.$textOffsetY+this.$textStartY,y=this.$lineHeights,v=0;n>v;v++){var m=y[v];if(u&&v>0&&$+m>f)break;var b=r[v],x=b.length,T=this.$textOffsetX;if(g!=t.HorizontalAlign.LEFT){var _=d>p?d:p;g==t.HorizontalAlign.RIGHT?T+=_-s[v]:g==t.HorizontalAlign.CENTER&&(T+=Math.floor((_-s[v])/2))}for(var D=0;x>D;D++){var O=b.charAt(D),w=h.getTexture(O);if(w){var E=w.$bitmapWidth,R=w.$bitmapHeight;t.nativeRender?o.push(w.$bitmapX,w.$bitmapY,E,R,T+w.$offsetX,$+w.$offsetY,w.$getScaleBitmapWidth(),w.$getScaleBitmapHeight(),w.$sourceWidth,w.$sourceHeight):(a.imageWidth=w.$sourceWidth,a.imageHeight=w.$sourceHeight,a.drawImage(w.$bitmapX,w.$bitmapY,E,R,T+w.$offsetX,$+w.$offsetY,w.$getScaleBitmapWidth(),w.$getScaleBitmapHeight())),T+=(h.getConfig(O,"xadvance")||w.$getTextureWidth())+e.$letterSpacing}else" "==O?T+=l:t.$warn(1046,O)}$+=m+e.$lineSpacing}if(t.nativeRender){e.$nativeDisplayObject.setDataToBitmapNode(e.$nativeDisplayObject.id,h.$texture,o);var S=e.$getContentBounds();e.$nativeDisplayObject.setWidth(S.width),e.$nativeDisplayObject.setHeight(S.height)}},i.prototype.$measureContentBounds=function(t){var e=this.$getTextLines();0==e.length?t.setEmpty():t.setTo(this.$textOffsetX+this.$textStartX,this.$textOffsetY+this.$textStartY,this.$textWidth-this.$textOffsetX,this.$textHeight-this.$textOffsetY)},Object.defineProperty(i.prototype,"textWidth",{get:function(){return this.$getTextLines(),this.$textWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textHeight",{get:function(){return this.$getTextLines(),this.$textHeight},enumerable:!0,configurable:!0}),i.prototype.$getTextLines=function(){function e(t){return m&&n.length>0&&f>m?!1:(f+=c+u,s||h||(l-=p),n.push(t),o.push(c),a.push(l),d=Math.max(l,d),!0)}var r=this;if(!r.$textLinesChanged)return r.textLines;var n=[];r.textLines=n;var a=[];r.$textLinesWidth=a,r.$textLinesChanged=!1;var o=[];if(r.$lineHeights=o,!r.$text||!r.$font)return r.$textWidth=0,r.$textHeight=0,n;for(var s,h,c,l,u=r.$lineSpacing,p=r.$letterSpacing,d=0,f=0,g=0,$=0,y=!isNaN(r.$textFieldWidth),v=r.$textFieldWidth,m=r.$textFieldHeight,b=r.$font,x=b._getFirstCharHeight(),T=Math.ceil(x*i.EMPTY_FACTOR),_=r.$text,D=_.split(/(?:\r\n|\r|\n)/),O=D.length,w=!0,E=0;O>E;E++){var R=D[E],S=R.length;c=0,l=0,s=!0,h=!1;for(var C=0;S>C;C++){s||(l+=p);var F=R.charAt(C),P=void 0,M=void 0,j=0,A=0,B=b.getTexture(F);if(B)P=B.$getTextureWidth(),M=B.$getTextureHeight(),j=B.$offsetX,A=B.$offsetY;else{if(" "!=F){t.$warn(1046,F),s&&(s=!1);continue}P=T,M=x}if(s&&(s=!1),w&&(w=!1),y&&C>0&&l+P>v){if(!e(R.substring(0,C)))break;R=R.substring(C),S=R.length,C=0,l=C==S-1?P:b.getConfig(F,"xadvance")||P,c=M}else l+=C==S-1?P:b.getConfig(F,"xadvance")||P,c=Math.max(M,c)}if(m&&E>0&&f>m)break;if(h=!0,!e(R))break}f-=u,r.$textWidth=d,r.$textHeight=f,this.$textOffsetX=g,this.$textOffsetY=$,this.$textStartX=0,this.$textStartY=0;var N;return v>d&&(N=r.$textAlign,N==t.HorizontalAlign.RIGHT?this.$textStartX=v-d:N==t.HorizontalAlign.CENTER&&(this.$textStartX=Math.floor((v-d)/2))),m>f&&(N=r.$verticalAlign,N==t.VerticalAlign.BOTTOM?this.$textStartY=m-f:N==t.VerticalAlign.MIDDLE&&(this.$textStartY=Math.floor((m-f)/2))),n},i.EMPTY_FACTOR=.33,i}(t.DisplayObject);t.BitmapText=e,__reflect(e.prototype,"egret.BitmapText")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.LEFT="left",t.RIGHT="right",t.CENTER="center",t.JUSTIFY="justify",t.CONTENT_JUSTIFY="contentJustify",t}();t.HorizontalAlign=e,__reflect(e.prototype,"egret.HorizontalAlign")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){this.replaceArr=[],this.resutlArr=[],this.initReplaceArr()}return e.prototype.initReplaceArr=function(){this.replaceArr=[],this.replaceArr.push([/</g,"<"]),this.replaceArr.push([/>/g,">"]),this.replaceArr.push([/&/g,"&"]),this.replaceArr.push([/"/g,'"']),this.replaceArr.push([/'/g,"'"])},e.prototype.replaceSpecial=function(t){for(var e=0;ei;){var n=e.indexOf("<",i);if(0>n)this.addToResultArr(e.substring(i)),i=r;else{this.addToResultArr(e.substring(i,n));var a=e.indexOf(">",n);-1==a?(t.$error(1038),a=n):"/"==e.charAt(n+1)?this.stackArray.pop():this.addToArray(e.substring(n+1,a)),i=a+1}}return this.resutlArr},e.prototype.parser=function(t){return this.parse(t)},e.prototype.addToResultArr=function(t){""!=t&&(t=this.replaceSpecial(t),this.stackArray.length>0?this.resutlArr.push({text:t,style:this.stackArray[this.stackArray.length-1]}):this.resutlArr.push({text:t}))},e.prototype.changeStringToObject=function(t){t=t.trim();var e={},i=[];if("i"==t.charAt(0)||"b"==t.charAt(0)||"u"==t.charAt(0))this.addProperty(e,t,"true");else if(i=t.match(/^(font|a)\s/)){t=t.substring(i[0].length).trim();for(var r=0,n=void 0;n=t.match(this.getHeadReg());){var a=n[0],o="";t=t.substring(a.length).trim(),'"'==t.charAt(0)?(r=t.indexOf('"',1),o=t.substring(1,r),r+=1):"'"==t.charAt(0)?(r=t.indexOf("'",1),o=t.substring(1,r),r+=1):(o=t.match(/(\S)+/)[0],r=o.length),this.addProperty(e,a.substring(0,a.length-1).trim(),o.trim()),t=t.substring(r).trim()}}return e},e.prototype.getHeadReg=function(){return/^(color|textcolor|strokecolor|stroke|b|bold|i|italic|u|size|fontfamily|href|target)(\s)*=/},e.prototype.addProperty=function(t,e,i){switch(e.toLowerCase()){case"color":case"textcolor":i=i.replace(/#/,"0x"),t.textColor=parseInt(i);break;case"strokecolor":i=i.replace(/#/,"0x"),t.strokeColor=parseInt(i);break;case"stroke":t.stroke=parseInt(i);break;case"b":case"bold":t.bold="true"==i;break;case"u":t.underline="true"==i;break;case"i":case"italic":t.italic="true"==i;break;case"size":t.size=parseInt(i);break;case"fontfamily":t.fontFamily=i;break;case"href":t.href=this.replaceSpecial(i);break;case"target":t.target=this.replaceSpecial(i)}},e.prototype.addToArray=function(t){var e=this.changeStringToObject(t);if(0==this.stackArray.length)this.stackArray.push(e);else{var i=this.stackArray[this.stackArray.length-1];for(var r in i)null==e[r]&&(e[r]=i[r]);this.stackArray.push(e)}},e}();t.HtmlTextParser=e,__reflect(e.prototype,"egret.HtmlTextParser")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.stageTextAdded=!1,t._text=null,t._isFocus=!1,t}return __extends(i,e),i.prototype.init=function(e){this._text=e,this.stageText=new t.StageText,this.stageText.$setTextField(this._text)},i.prototype._addStageText=function(){this.stageTextAdded||(this._text.$inputEnabled||(this._text.$touchEnabled=!0),this.tempStage=this._text.stage,this.stageText.$addToStage(),this.stageText.addEventListener("updateText",this.updateTextHandler,this),this._text.addEventListener(t.TouchEvent.TOUCH_BEGIN,this.onMouseDownHandler,this),this.stageText.addEventListener("blur",this.blurHandler,this),this.stageText.addEventListener("focus",this.focusHandler,this),this.stageTextAdded=!0)},i.prototype._removeStageText=function(){this.stageTextAdded&&(this._text.$inputEnabled||(this._text.$touchEnabled=!1),this.stageText.$removeFromStage(),this.stageText.removeEventListener("updateText",this.updateTextHandler,this),this._text.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onMouseDownHandler,this),this.tempStage.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),this.stageText.removeEventListener("blur",this.blurHandler,this),this.stageText.removeEventListener("focus",this.focusHandler,this),this.stageTextAdded=!1)},i.prototype._getText=function(){return this.stageText.$getText()},i.prototype._setText=function(t){this.stageText.$setText(t)},i.prototype._setColor=function(t){this.stageText.$setColor(t)},i.prototype.focusHandler=function(e){this._isFocus||(this._isFocus=!0,e.showing||this._text.$setIsTyping(!0),this._text.dispatchEvent(new t.FocusEvent(t.FocusEvent.FOCUS_IN,!0)))},i.prototype.blurHandler=function(e){this._isFocus&&(this._isFocus=!1,this.tempStage.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),this._text.$setIsTyping(!1),this.stageText.$onBlur(),this._text.dispatchEvent(new t.FocusEvent(t.FocusEvent.FOCUS_OUT,!0)))},i.prototype.onMouseDownHandler=function(t){this.$onFocus()},i.prototype.$onFocus=function(){var e=this;this._text.visible&&(this._isFocus||(this.tempStage.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),t.callLater(function(){e.tempStage.addEventListener(t.TouchEvent.TOUCH_BEGIN,e.onStageDownHandler,e)},this),t.nativeRender&&this.stageText.$setText(this._text.$TextField[13]),this.stageText.$show()))},i.prototype.onStageDownHandler=function(t){t.$target!=this._text&&this.stageText.$hide()},i.prototype.updateTextHandler=function(e){var i,r,n=this._text.$TextField,a=this.stageText.$getText(),o=!1;null!=n[35]&&(i=new RegExp("["+n[35]+"]","g"),r=a.match(i),a=r?r.join(""):"",o=!0),null!=n[36]&&(i=new RegExp("[^"+n[36]+"]","g"),r=a.match(i),a=r?r.join(""):"",o=!0),o&&this.stageText.$getText()!=a&&this.stageText.$setText(a),this.resetText(),this._text.dispatchEvent(new t.Event(t.Event.CHANGE,!0))},i.prototype.resetText=function(){this._text.$setBaseText(this.stageText.$getText())},i.prototype._hideInput=function(){this.stageText.$removeFromStage()},i.prototype.updateInput=function(){!this._text.$visible&&this.stageText&&this._hideInput()},i.prototype._updateProperties=function(){return this._isFocus?(this.stageText.$resetStageText(),void this.updateInput()):(this.stageText.$setText(this._text.$TextField[13]),this.stageText.$resetStageText(),void this.updateInput())},i}(t.HashObject);t.InputController=e,__reflect(e.prototype,"egret.InputController")}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){function e(e,i,n){n=n||{};var a=null==n.italic?i[16]:n.italic,o=null==n.bold?i[15]:n.bold,s=null==n.size?i[0]:n.size,h=n.fontFamily||i[8]||r.default_fontFamily;return t.sys.measureText(e,h,s,o,a)}var i=new RegExp("(?=[\\u00BF-\\u1FFF\\u2C00-\\uD7FF]|\\b|\\s)(?![。,!、》…))}”】\\.\\,\\!\\?\\]\\:])"),r=function(r){function n(){var e=r.call(this)||this;e.$inputEnabled=!1,e.inputUtils=null,e.$graphicsNode=null,e.isFlow=!1,e.textArr=[],e.linesArr=[],e.$isTyping=!1;var i=new t.sys.TextNode;return i.fontFamily=n.default_fontFamily,e.textNode=i,e.$renderNode=i,e.$TextField={0:n.default_size,1:0,2:n.default_textColor,3:0/0,4:0/0,5:0,6:0,7:0,8:n.default_fontFamily,9:"left",10:"top",11:"#ffffff",12:"",13:"",14:[],15:!1,16:!1,17:!0,18:!1,19:!1,20:!1,21:0,22:0,23:0,24:t.TextFieldType.DYNAMIC,25:0,26:"#000000",27:0,28:-1,29:0,30:!1,31:!1,32:0,33:!1,34:16777215,35:null,36:null,37:t.TextFieldInputType.TEXT,38:!1},e}return __extends(n,r),n.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(7)},n.prototype.isInput=function(){return this.$TextField[24]==t.TextFieldType.INPUT},n.prototype.$setTouchEnabled=function(t){r.prototype.$setTouchEnabled.call(this,t),this.isInput()&&(this.$inputEnabled=!0)},Object.defineProperty(n.prototype,"fontFamily",{get:function(){return this.$TextField[8]},set:function(t){this.$setFontFamily(t)},enumerable:!0,configurable:!0}),n.prototype.$setFontFamily=function(e){var i=this.$TextField;return i[8]==e?!1:(i[8]=e,this.invalidateFontString(),t.nativeRender&&this.$nativeDisplayObject.setFontFamily(e),!0)},Object.defineProperty(n.prototype,"size",{get:function(){return this.$TextField[0]},set:function(t){this.$setSize(t)},enumerable:!0,configurable:!0}),n.prototype.$setSize=function(e){var i=this.$TextField;return i[0]==e?!1:(i[0]=e,this.invalidateFontString(),t.nativeRender&&this.$nativeDisplayObject.setFontSize(e),!0)},Object.defineProperty(n.prototype,"bold",{get:function(){return this.$TextField[15]},set:function(t){this.$setBold(t)},enumerable:!0,configurable:!0}),n.prototype.$setBold=function(e){var i=this.$TextField;return e==i[15]?!1:(i[15]=e,this.invalidateFontString(),t.nativeRender&&this.$nativeDisplayObject.setBold(e),!0)},Object.defineProperty(n.prototype,"italic",{get:function(){return this.$TextField[16] -},set:function(t){this.$setItalic(t)},enumerable:!0,configurable:!0}),n.prototype.$setItalic=function(e){var i=this.$TextField;return e==i[16]?!1:(i[16]=e,this.invalidateFontString(),t.nativeRender&&this.$nativeDisplayObject.setItalic(e),!0)},n.prototype.invalidateFontString=function(){this.$TextField[17]=!0,this.$invalidateTextField()},Object.defineProperty(n.prototype,"textAlign",{get:function(){return this.$TextField[9]},set:function(t){this.$setTextAlign(t)},enumerable:!0,configurable:!0}),n.prototype.$setTextAlign=function(e){var i=this.$TextField;return i[9]==e?!1:(i[9]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setTextAlign(e),!0)},Object.defineProperty(n.prototype,"verticalAlign",{get:function(){return this.$TextField[10]},set:function(t){this.$setVerticalAlign(t)},enumerable:!0,configurable:!0}),n.prototype.$setVerticalAlign=function(e){var i=this.$TextField;return i[10]==e?!1:(i[10]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setVerticalAlign(e),!0)},Object.defineProperty(n.prototype,"lineSpacing",{get:function(){return this.$TextField[1]},set:function(t){this.$setLineSpacing(t)},enumerable:!0,configurable:!0}),n.prototype.$setLineSpacing=function(e){var i=this.$TextField;return i[1]==e?!1:(i[1]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setLineSpacing(e),!0)},Object.defineProperty(n.prototype,"textColor",{get:function(){return this.$TextField[2]},set:function(t){this.$setTextColor(t)},enumerable:!0,configurable:!0}),n.prototype.$setTextColor=function(e){var i=this.$TextField;return i[2]==e?!1:(i[2]=e,this.inputUtils&&this.inputUtils._setColor(this.$TextField[2]),this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setTextColor(e),!0)},Object.defineProperty(n.prototype,"wordWrap",{get:function(){return this.$TextField[19]},set:function(t){this.$setWordWrap(t)},enumerable:!0,configurable:!0}),n.prototype.$setWordWrap=function(e){var i=this.$TextField;e!=i[19]&&(i[20]||(i[19]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setWordWrap(e)))},Object.defineProperty(n.prototype,"type",{get:function(){return this.$TextField[24]},set:function(t){this.$setType(t)},enumerable:!0,configurable:!0}),n.prototype.$setType=function(e){var i=this.$TextField;return i[24]!=e?(i[24]=e,t.nativeRender&&this.$nativeDisplayObject.setType(e),e==t.TextFieldType.INPUT?(isNaN(i[3])&&this.$setWidth(100),isNaN(i[4])&&this.$setHeight(30),this.$setTouchEnabled(!0),null==this.inputUtils&&(this.inputUtils=new t.InputController),this.inputUtils.init(this),this.$invalidateTextField(),this.$stage&&this.inputUtils._addStageText()):(this.inputUtils&&(this.inputUtils._removeStageText(),this.inputUtils=null),this.$setTouchEnabled(!1)),!0):!1},Object.defineProperty(n.prototype,"inputType",{get:function(){return this.$TextField[37]},set:function(e){this.$TextField[37]!=e&&(this.$TextField[37]=e,t.nativeRender&&this.$nativeDisplayObject.setInputType(e))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"text",{get:function(){return this.$getText()},set:function(t){this.$setText(t)},enumerable:!0,configurable:!0}),n.prototype.$getText=function(){return this.$TextField[24]==t.TextFieldType.INPUT?this.inputUtils._getText():this.$TextField[13]},n.prototype.$setBaseText=function(e){e=null==e?"":e.toString(),this.isFlow=!1;var i=this.$TextField;if(i[13]!=e){this.$invalidateTextField(),i[13]=e;var r="";return r=i[20]?this.changeToPassText(e):e,t.nativeRender&&this.$nativeDisplayObject.setText(r),this.setMiddleStyle([{text:r}]),!0}return!1},n.prototype.$setText=function(t){null==t&&(t="");var e=this.$setBaseText(t);return this.inputUtils&&this.inputUtils._setText(this.$TextField[13]),e},Object.defineProperty(n.prototype,"displayAsPassword",{get:function(){return this.$TextField[20]},set:function(t){this.$setDisplayAsPassword(t)},enumerable:!0,configurable:!0}),n.prototype.$setDisplayAsPassword=function(e){var i=this.$TextField;if(i[20]!=e){i[20]=e,this.$invalidateTextField();var r="";return r=e?this.changeToPassText(i[13]):i[13],t.nativeRender&&this.$nativeDisplayObject.setText(r),this.setMiddleStyle([{text:r}]),!0}return!1},Object.defineProperty(n.prototype,"strokeColor",{get:function(){return this.$TextField[25]},set:function(t){this.$setStrokeColor(t)},enumerable:!0,configurable:!0}),n.prototype.$setStrokeColor=function(e){var i=this.$TextField;return i[25]!=e?(this.$invalidateTextField(),i[25]=e,t.nativeRender&&this.$nativeDisplayObject.setStrokeColor(e),i[26]=t.toColorString(e),!0):!1},Object.defineProperty(n.prototype,"stroke",{get:function(){return this.$TextField[27]},set:function(t){this.$setStroke(t)},enumerable:!0,configurable:!0}),n.prototype.$setStroke=function(e){return this.$TextField[27]!=e?(this.$invalidateTextField(),this.$TextField[27]=e,t.nativeRender&&this.$nativeDisplayObject.setStroke(e),!0):!1},Object.defineProperty(n.prototype,"maxChars",{get:function(){return this.$TextField[21]},set:function(t){this.$setMaxChars(t)},enumerable:!0,configurable:!0}),n.prototype.$setMaxChars=function(e){return this.$TextField[21]!=e?(this.$TextField[21]=e,t.nativeRender&&this.$nativeDisplayObject.setMaxChars(e),!0):!1},Object.defineProperty(n.prototype,"scrollV",{get:function(){return Math.min(Math.max(this.$TextField[28],1),this.maxScrollV)},set:function(e){e=Math.max(e,1),e!=this.$TextField[28]&&(this.$TextField[28]=e,t.nativeRender&&this.$nativeDisplayObject.setScrollV(e),this.$invalidateTextField())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxScrollV",{get:function(){return this.$getLinesArr(),Math.max(this.$TextField[29]-t.TextFieldUtils.$getScrollNum(this)+1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectionBeginIndex",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectionEndIndex",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"caretIndex",{get:function(){return 0},enumerable:!0,configurable:!0}),n.prototype.$setSelection=function(t,e){return!1},n.prototype.$getLineHeight=function(){return this.$TextField[1]+this.$TextField[0]},Object.defineProperty(n.prototype,"numLines",{get:function(){return this.$getLinesArr(),this.$TextField[29]},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"multiline",{get:function(){return this.$TextField[30]},set:function(t){this.$setMultiline(t)},enumerable:!0,configurable:!0}),n.prototype.$setMultiline=function(e){return this.$TextField[30]==e?!1:(this.$TextField[30]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setMultiline(e),!0)},Object.defineProperty(n.prototype,"restrict",{get:function(){var t=this.$TextField,e=null;return null!=t[35]&&(e=t[35]),null!=t[36]&&(null==e&&(e=""),e+="^"+t[36]),e},set:function(t){var e=this.$TextField;if(null==t)e[35]=null,e[36]=null;else{for(var i=-1;i0&&"\\"==t.charAt(i-1);)i++;0==i?(e[35]=null,e[36]=t.substring(i+1)):i>0?(e[35]=t.substring(0,i),e[36]=t.substring(i+1)):(e[35]=t,e[36]=null)}},enumerable:!0,configurable:!0}),n.prototype.$setWidth=function(e){t.nativeRender&&this.$nativeDisplayObject.setTextFieldWidth(e);var i=this.$TextField;if(isNaN(e)){if(isNaN(i[3]))return!1;i[3]=0/0}else{if(i[3]==e)return!1;i[3]=e}return e=+e,0>e?!1:(this.$invalidateTextField(),!0)},n.prototype.$setHeight=function(e){t.nativeRender&&this.$nativeDisplayObject.setTextFieldHeight(e);var i=this.$TextField;if(isNaN(e)){if(isNaN(i[4]))return!1;i[4]=0/0}else{if(i[4]==e)return!1;i[4]=e}return e=+e,0>e?!1:(this.$invalidateTextField(),!0)},n.prototype.$getWidth=function(){var t=this.$TextField;return isNaN(t[3])?this.$getContentBounds().width:t[3]},n.prototype.$getHeight=function(){var t=this.$TextField;return isNaN(t[4])?this.$getContentBounds().height:t[4]},Object.defineProperty(n.prototype,"border",{get:function(){return this.$TextField[31]},set:function(t){this.$setBorder(t)},enumerable:!0,configurable:!0}),n.prototype.$setBorder=function(e){e=!!e,this.$TextField[31]!=e&&(this.$TextField[31]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setBorder(e))},Object.defineProperty(n.prototype,"borderColor",{get:function(){return this.$TextField[32]},set:function(t){this.$setBorderColor(t)},enumerable:!0,configurable:!0}),n.prototype.$setBorderColor=function(e){e=+e||0,this.$TextField[32]!=e&&(this.$TextField[32]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setBorderColor(e))},Object.defineProperty(n.prototype,"background",{get:function(){return this.$TextField[33]},set:function(t){this.$setBackground(t)},enumerable:!0,configurable:!0}),n.prototype.$setBackground=function(e){this.$TextField[33]!=e&&(this.$TextField[33]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setBackground(e))},Object.defineProperty(n.prototype,"backgroundColor",{get:function(){return this.$TextField[34]},set:function(t){this.$setBackgroundColor(t)},enumerable:!0,configurable:!0}),n.prototype.$setBackgroundColor=function(e){this.$TextField[34]!=e&&(this.$TextField[34]=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setBackgroundColor(e))},n.prototype.fillBackground=function(e){var i=this.$graphicsNode;i&&i.clear();var r=this.$TextField;if(r[33]||r[31]||e&&e.length>0){if(!i)if(i=this.$graphicsNode=new t.sys.GraphicsNode,t.nativeRender)this.$renderNode=this.textNode;else{var n=new t.sys.GroupNode;n.addNode(i),n.addNode(this.textNode),this.$renderNode=n}var a=void 0,o=void 0;if(r[33]&&(a=i.beginFill(r[34]),a.drawRect(0,0,this.$getWidth(),this.$getHeight())),r[31]&&(o=i.lineStyle(1,r[32]),o.drawRect(0,0,this.$getWidth()-1,this.$getHeight()-1)),e&&e.length>0)for(var s=r[2],h=-1,c=e.length,l=0;c>l;l+=4){var u=e[l],p=e[l+1],d=e[l+2],f=e[l+3]||s;(0>h||h!=f)&&(h=f,o=i.lineStyle(2,f,1,t.CapsStyle.NONE)),o.moveTo(u,p),o.lineTo(u+d,p)}}if(i){var g=this.$getRenderBounds();i.x=g.x,i.y=g.y,i.width=g.width,i.height=g.height,t.Rectangle.release(g)}},n.prototype.setFocus=function(){this.type==t.TextFieldType.INPUT&&this.$stage&&this.inputUtils.$onFocus()},n.prototype.$onRemoveFromStage=function(){r.prototype.$onRemoveFromStage.call(this),this.removeEvent(),this.$TextField[24]==t.TextFieldType.INPUT&&this.inputUtils._removeStageText(),this.textNode&&(this.textNode.clean(),t.nativeRender&&egret_native.NativeDisplayObject.disposeTextData(this))},n.prototype.$onAddToStage=function(e,i){r.prototype.$onAddToStage.call(this,e,i),this.addEvent(),this.$TextField[24]==t.TextFieldType.INPUT&&this.inputUtils._addStageText()},n.prototype.$invalidateTextField=function(){var e=this;if(e.$renderDirty=!0,e.$TextField[18]=!0,e.$TextField[38]=!0,t.nativeRender);else{var i=e.$parent;i&&!i.$cacheDirty&&(i.$cacheDirty=!0,i.$cacheDirtyUp());var r=e.$maskedObject;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp())}},n.prototype.$getRenderBounds=function(){var e=this.$getContentBounds(),i=t.Rectangle.create();i.copyFrom(e),this.$TextField[31]&&(i.width+=2,i.height+=2);var r=2*this.$TextField[27];return r>0&&(i.width+=2*r,i.height+=2*r),i.x-=r+2,i.y-=r+2,i.width=Math.ceil(i.width)+4,i.height=Math.ceil(i.height)+4,i},n.prototype.$measureContentBounds=function(e){this.$getLinesArr();var i=0,r=0;t.nativeRender?(i=egret_native.nrGetTextFieldWidth(this.$nativeDisplayObject.id),r=egret_native.nrGetTextFieldHeight(this.$nativeDisplayObject.id)):(i=isNaN(this.$TextField[3])?this.$TextField[5]:this.$TextField[3],r=isNaN(this.$TextField[4])?t.TextFieldUtils.$getTextHeight(this):this.$TextField[4]),e.setTo(0,0,i,r)},n.prototype.$updateRenderNode=function(){if(this.$TextField[24]==t.TextFieldType.INPUT){if(this.inputUtils._updateProperties(),this.$isTyping)return void this.fillBackground()}else if(0==this.$TextField[3]){var e=this.$graphicsNode;return void(e&&e.clear())}var i=this.drawText();this.fillBackground(i);var r=this.$getRenderBounds(),n=this.textNode;n.x=r.x,n.y=r.y,n.width=Math.ceil(r.width),n.height=Math.ceil(r.height),t.Rectangle.release(r)},Object.defineProperty(n.prototype,"textFlow",{get:function(){return this.textArr},set:function(e){this.isFlow=!0;var i="";null==e&&(e=[]);for(var r=0;ri;i++)switch(t.charAt(i)){case"\n":e+="\n";break;case"\r":break;default:e+="*"}return e}return t},n.prototype.setMiddleStyle=function(t){this.$TextField[18]=!0,this.$TextField[38]=!0,this.textArr=t,this.$invalidateTextField()},Object.defineProperty(n.prototype,"textWidth",{get:function(){return this.$getLinesArr(),t.nativeRender?egret_native.nrGetTextWidth(this.$nativeDisplayObject.id):this.$TextField[5]},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"textHeight",{get:function(){return this.$getLinesArr(),t.nativeRender?egret_native.nrGetTextHeight(this.$nativeDisplayObject.id):t.TextFieldUtils.$getTextHeight(this)},enumerable:!0,configurable:!0}),n.prototype.appendText=function(t){this.appendElement({text:t})},n.prototype.appendElement=function(e){var i=this.$TextField[13]+e.text;return t.nativeRender?(this.textArr.push(e),this.$TextField[13]=i,this.$TextField[18]=!0,this.$TextField[38]=!0,void this.$nativeDisplayObject.setTextFlow(this.textArr)):void(this.$TextField[20]?this.$setBaseText(i):(this.$TextField[13]=i,this.textArr.push(e),this.setMiddleStyle(this.textArr)))},n.prototype.$getLinesArr=function(){var e=this.$TextField;return t.nativeRender&&e[38]?(egret_native.updateNativeRender(),void(e[38]=!1)):this.$getLinesArr2()},n.prototype.$getLinesArr2=function(){var r=this.$TextField;if(!r[18])return this.linesArr;r[18]=!1;var n=this.textArr;this.linesArr.length=0,r[6]=0,r[5]=0;var a=r[3];if(!isNaN(a)&&0==a)return r[29]=0,[{width:0,height:0,charNum:0,elements:[],hasNextLine:!1}];for(var o,s=this.linesArr,h=0,c=0,l=0,u=0,p=0,d=n.length;d>p;p++){var f=n[p];if(f.text){f.style=f.style||{};for(var g=f.text.toString(),$=g.split(/(?:\r\n|\r|\n)/),y=0,v=$.length;v>y;y++){null==s[u]&&(o={width:0,height:0,elements:[],charNum:0,hasNextLine:!1},s[u]=o,h=0,l=0,c=0),l=r[24]==t.TextFieldType.INPUT?r[0]:Math.max(l,f.style.size||r[0]);var m=!0;if(""==$[y])y==v-1&&(m=!1);else{var b=e($[y],r,f.style);if(isNaN(a))h+=b,c+=$[y].length,o.elements.push({width:b,text:$[y],style:f.style}),y==v-1&&(m=!1);else if(a>=h+b)o.elements.push({width:b,text:$[y],style:f.style}),h+=b,c+=$[y].length,y==v-1&&(m=!1);else{var x=0,T=0,_=$[y],D=void 0;D=r[19]?_.split(i):_.match(/./g);for(var O=D.length,w=0;O>x;x++){var E=D[x].length,R=!1;if(1==E&&O-1>x){var S=D[x].charCodeAt(0),C=D[x+1].charCodeAt(0);if(S>=55296&&56319>=S&&56320==(64512&C)){var F=D[x]+D[x+1];E=2,R=!0,b=e(F,r,f.style)}else b=e(D[x],r,f.style)}else b=e(D[x],r,f.style);if(0!=h&&h+b>a&&h+x!=0)break;if(T+b>a)for(var P=D[x].match(/./g),M=0,j=P.length;j>M;M++){var E=P[M].length,A=!1;if(1==E&&j-1>M){var S=P[M].charCodeAt(0),C=P[M+1].charCodeAt(0);if(S>=55296&&56319>=S&&56320==(64512&C)){var F=P[M]+P[M+1];E=2,A=!0,b=e(F,r,f.style)}else b=e(P[M],r,f.style)}else b=e(P[M],r,f.style);if(M>0&&h+b>a)break;w+=E,T+=b,h+=b,c+=w,A&&M++}else w+=E,T+=b,h+=b,c+=w;R&&x++}if(x>0){o.elements.push({width:T,text:_.substring(0,w),style:f.style});var B=_.substring(w),N=void 0,k=B.length;for(N=0;k>N&&" "==B.charAt(N);N++);$[y]=B.substring(N)}""!=$[y]&&(y--,m=!1)}}m&&(c++,o.hasNextLine=!0),y<$.length-1&&(o.width=h,o.height=l,o.charNum=c,r[5]=Math.max(r[5],h),r[6]+=l,u++)}p==n.length-1&&o&&(o.width=h,o.height=l,o.charNum=c,r[5]=Math.max(r[5],h),r[6]+=l)}else o&&(o.width=h,o.height=l,o.charNum=c,r[5]=Math.max(r[5],h),r[6]+=l)}return r[29]=s.length,s},n.prototype.$setIsTyping=function(e){this.$isTyping=e,this.$invalidateTextField(),t.nativeRender&&this.$nativeDisplayObject.setIsTyping(e)},n.prototype.drawText=function(){var e=this.textNode,i=this.$TextField;e.bold=i[15],e.fontFamily=i[8]||n.default_fontFamily,e.italic=i[16],e.size=i[0],e.stroke=i[27],e.strokeColor=i[25],e.textColor=i[2];var r=this.$getLinesArr();if(0==i[5])return[];var a=isNaN(i[3])?i[5]:i[3],o=t.TextFieldUtils.$getTextHeight(this),s=0,h=t.TextFieldUtils.$getStartLine(this),c=i[4];if(!isNaN(c)&&c>o){var l=t.TextFieldUtils.$getValign(this);s+=l*(c-o)}s=Math.round(s);for(var u=t.TextFieldUtils.$getHalign(this),p=0,d=[],f=h,g=i[29];g>f;f++){var $=r[f],y=$.height;if(s+=y/2,f!=h){if(i[24]==t.TextFieldType.INPUT&&!i[30])break;if(!isNaN(c)&&s>c)break}p=Math.round((a-$.width)*u);for(var v=0,m=$.elements.length;m>v;v++){var b=$.elements[v],x=b.style.size||i[0];e.drawText(p,s+(y-x)/2,b.text,b.style),b.style.underline&&d.push(p,s+y/2,b.width,b.style.textColor),p+=b.width}s+=y/2+i[1]}return d},n.prototype.addEvent=function(){this.addEventListener(t.TouchEvent.TOUCH_TAP,this.onTapHandler,this)},n.prototype.removeEvent=function(){this.removeEventListener(t.TouchEvent.TOUCH_TAP,this.onTapHandler,this)},n.prototype.onTapHandler=function(e){if(this.$TextField[24]!=t.TextFieldType.INPUT){var i=t.TextFieldUtils.$getTextElement(this,e.localX,e.localY);if(null!=i){var r=i.style;if(r&&r.href)if(r.href.match(/^event:/)){var n=r.href.match(/^event:/)[0];t.TextEvent.dispatchTextEvent(this,t.TextEvent.LINK,r.href.substring(n.length))}else open(r.href,r.target||"_blank")}}},n.default_fontFamily="Arial",n.default_size=30,n.default_textColor=16777215,n}(t.DisplayObject);t.TextField=r,__reflect(r.prototype,"egret.TextField")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.TEXT="text",t.TEL="tel",t.PASSWORD="password",t}();t.TextFieldInputType=e,__reflect(e.prototype,"egret.TextFieldInputType")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.DYNAMIC="dynamic",t.INPUT="input",t}();t.TextFieldType=e,__reflect(e.prototype,"egret.TextFieldType")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){}return e.$getStartLine=function(t){var i=t.$TextField,r=e.$getTextHeight(t),n=0,a=i[4];return isNaN(a)||(a>r||r>a&&(n=Math.max(i[28]-1,0),n=Math.min(i[29]-1,n)),i[30]||(n=Math.max(i[28]-1,0),i[29]>0&&(n=Math.min(i[29]-1,n)))),n},e.$getHalign=function(e){var i=e.$getLinesArr2(),r=0;return e.$TextField[9]==t.HorizontalAlign.CENTER?r=.5:e.$TextField[9]==t.HorizontalAlign.RIGHT&&(r=1),e.$TextField[24]==t.TextFieldType.INPUT&&!e.$TextField[30]&&i.length>1&&(r=0),r},e.$getTextHeight=function(e){var i=t.TextFieldType.INPUT!=e.$TextField[24]||e.$TextField[30]?e.$TextField[6]+(e.$TextField[29]-1)*e.$TextField[1]:e.$TextField[0];return i},e.$getValign=function(i){var r=e.$getTextHeight(i),n=i.$TextField[4];if(!isNaN(n)&&n>r){var a=0;return i.$TextField[10]==t.VerticalAlign.MIDDLE?a=.5:i.$TextField[10]==t.VerticalAlign.BOTTOM&&(a=1),a}return 0},e.$getTextElement=function(t,i,r){var n=e.$getHit(t,i,r),a=t.$getLinesArr2();return n&&a[n.lineIndex]&&a[n.lineIndex].elements[n.textElementIndex]?a[n.lineIndex].elements[n.textElementIndex]:null},e.$getHit=function(t,i,r){var n=t.$getLinesArr2();if(0==t.$TextField[3])return null;var a=0,o=e.$getTextHeight(t),s=0,h=t.$TextField[4];if(!isNaN(h)&&h>o){var c=e.$getValign(t);s=c*(h-o),0!=s&&(r-=s)}for(var l=e.$getStartLine(t),u=0,p=l;p=r){r>u&&(a=p+1);break}if(u+=d.height,u+t.$TextField[1]>r)return null;u+=t.$TextField[1]}if(0==a)return null;var f=n[a-1],g=t.$TextField[3];isNaN(g)&&(g=t.textWidth);var $=e.$getHalign(t);i-=$*(g-f.width);for(var y=0,p=0;py)return{lineIndex:a-1,textElementIndex:p}}return null},e.$getScrollNum=function(t){var e=1;if(t.$TextField[30]){var i=t.height,r=t.size,n=t.lineSpacing;e=Math.floor(i/(r+n));var a=i-(r+n)*e;a>r/2&&e++}return e},e}();t.TextFieldUtils=e,__reflect(e.prototype,"egret.TextFieldUtils")}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.TOP="top",t.BOTTOM="bottom",t.MIDDLE="middle",t.JUSTIFY="justify",t.CONTENT_JUSTIFY="contentJustify",t}();t.VerticalAlign=e,__reflect(e.prototype,"egret.VerticalAlign")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.encode=function(t){for(var e=new Uint8Array(t),i=e.length,r="",n=0;i>n;n+=3)r+=chars[e[n]>>2],r+=chars[(3&e[n])<<4|e[n+1]>>4],r+=chars[(15&e[n+1])<<2|e[n+2]>>6],r+=chars[63&e[n+2]];return i%3===2?r=r.substring(0,r.length-1)+"=":i%3===1&&(r=r.substring(0,r.length-2)+"=="),r},t.decode=function(t){var e=.75*t.length,i=t.length,r=0,n=0,a=0,o=0,s=0;"="===t[t.length-1]&&(e--,"="===t[t.length-2]&&e--);for(var h=new ArrayBuffer(e),c=new Uint8Array(h),l=0;i>l;l+=4)n=lookup[t.charCodeAt(l)],a=lookup[t.charCodeAt(l+1)],o=lookup[t.charCodeAt(l+2)],s=lookup[t.charCodeAt(l+3)],c[r++]=n<<2|a>>4,c[r++]=(15&a)<<4|o>>2,c[r++]=(3&o)<<6|63&s;return h},t}();t.Base64Util=e,__reflect(e.prototype,"egret.Base64Util")}(egret||(egret={}));for(var chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lookup=new Uint8Array(256),i=0;ii&&(i=0),this.bufferExtSize=i;var r,n=0;if(t){var a=void 0;if(t instanceof Uint8Array?(a=t,n=t.length):(n=t.byteLength,a=new Uint8Array(t)),0==i)r=new Uint8Array(n);else{var o=(n/i|0)+1;r=new Uint8Array(o*i)}r.set(a)}else r=new Uint8Array(i);this.write_position=n,this._position=0,this._bytes=r,this.data=new DataView(r.buffer),this.endian=e.BIG_ENDIAN}return Object.defineProperty(i.prototype,"endian",{get:function(){return 0==this.$endian?e.LITTLE_ENDIAN:e.BIG_ENDIAN},set:function(t){this.$endian=t==e.LITTLE_ENDIAN?0:1},enumerable:!0,configurable:!0}),i.prototype.setArrayBuffer=function(t){},Object.defineProperty(i.prototype,"readAvailable",{get:function(){return this.write_position-this._position},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"buffer",{get:function(){return this.data.buffer.slice(0,this.write_position)},set:function(t){var e,i=t.byteLength,r=new Uint8Array(t),n=this.bufferExtSize;if(0==n)e=new Uint8Array(i);else{var a=(i/n|0)+1;e=new Uint8Array(a*n)}e.set(r),this.write_position=i,this._bytes=e,this.data=new DataView(e.buffer)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rawBuffer",{get:function(){return this.data.buffer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bytes",{get:function(){return this._bytes},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"dataView",{get:function(){return this.data},set:function(t){this.buffer=t.buffer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bufferOffset",{get:function(){return this.data.byteOffset},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(t){this._position=t,t>this.write_position&&(this.write_position=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"length",{get:function(){return this.write_position},set:function(t){this.write_position=t,this.data.byteLength>t&&(this._position=t),this._validateBuffer(t)},enumerable:!0,configurable:!0}),i.prototype._validateBuffer=function(t){if(this.data.byteLength>0)+1)*e;i=new Uint8Array(r)}i.set(this._bytes),this._bytes=i,this.data=new DataView(i.buffer)}},Object.defineProperty(i.prototype,"bytesAvailable",{get:function(){return this.data.byteLength-this._position},enumerable:!0,configurable:!0}),i.prototype.clear=function(){var t=new ArrayBuffer(this.bufferExtSize);this.data=new DataView(t),this._bytes=new Uint8Array(t),this._position=0,this.write_position=0},i.prototype.readBoolean=function(){return this.validate(1)?!!this._bytes[this.position++]:void 0},i.prototype.readByte=function(){return this.validate(1)?this.data.getInt8(this.position++):void 0},i.prototype.readBytes=function(e,i,r){if(void 0===i&&(i=0),void 0===r&&(r=0),e){var n=this._position,a=this.write_position-n;if(0>a)return void t.$error(1025);if(0==r)r=a;else if(r>a)return void t.$error(1025);var o=e._position;e._position=0,e.validateBuffer(i+r),e._position=o,e._bytes.set(this._bytes.subarray(n,n+r),i),this.position+=r}},i.prototype.readDouble=function(){if(this.validate(8)){var t=this.data.getFloat64(this._position,0==this.$endian);return this.position+=8,t}},i.prototype.readFloat=function(){if(this.validate(4)){var t=this.data.getFloat32(this._position,0==this.$endian);return this.position+=4,t}},i.prototype.readInt=function(){if(this.validate(4)){var t=this.data.getInt32(this._position,0==this.$endian);return this.position+=4,t}},i.prototype.readShort=function(){if(this.validate(2)){var t=this.data.getInt16(this._position,0==this.$endian);return this.position+=2,t}},i.prototype.readUnsignedByte=function(){return this.validate(1)?this._bytes[this.position++]:void 0},i.prototype.readUnsignedInt=function(){if(this.validate(4)){var t=this.data.getUint32(this._position,0==this.$endian);return this.position+=4,t}},i.prototype.readUnsignedShort=function(){if(this.validate(2)){var t=this.data.getUint16(this._position,0==this.$endian);return this.position+=2,t}},i.prototype.readUTF=function(){var t=this.readUnsignedShort();return t>0?this.readUTFBytes(t):""},i.prototype.readUTFBytes=function(t){if(this.validate(t)){var e=this.data,i=new Uint8Array(e.buffer,e.byteOffset+this._position,t);return this.position+=t,this.decodeUTF8(i)}},i.prototype.writeBoolean=function(t){this.validateBuffer(1),this._bytes[this.position++]=+t},i.prototype.writeByte=function(t){this.validateBuffer(1),this._bytes[this.position++]=255&t},i.prototype.writeBytes=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var r;0>e||0>i||(r=0==i?t.length-e:Math.min(t.length-e,i),r>0&&(this.validateBuffer(r),this._bytes.set(t._bytes.subarray(e,e+r),this._position),this.position=this._position+r))},i.prototype.writeDouble=function(t){this.validateBuffer(8),this.data.setFloat64(this._position,t,0==this.$endian),this.position+=8},i.prototype.writeFloat=function(t){this.validateBuffer(4),this.data.setFloat32(this._position,t,0==this.$endian),this.position+=4},i.prototype.writeInt=function(t){this.validateBuffer(4),this.data.setInt32(this._position,t,0==this.$endian),this.position+=4},i.prototype.writeShort=function(t){this.validateBuffer(2),this.data.setInt16(this._position,t,0==this.$endian),this.position+=2},i.prototype.writeUnsignedInt=function(t){this.validateBuffer(4),this.data.setUint32(this._position,t,0==this.$endian),this.position+=4},i.prototype.writeUnsignedShort=function(t){this.validateBuffer(2),this.data.setUint16(this._position,t,0==this.$endian),this.position+=2},i.prototype.writeUTF=function(t){var e=this.encodeUTF8(t),i=e.length;this.validateBuffer(2+i),this.data.setUint16(this._position,i,0==this.$endian),this.position+=2,this._writeUint8Array(e,!1)},i.prototype.writeUTFBytes=function(t){this._writeUint8Array(this.encodeUTF8(t))},i.prototype.toString=function(){return"[ByteArray] length:"+this.length+", bytesAvailable:"+this.bytesAvailable},i.prototype._writeUint8Array=function(t,e){void 0===e&&(e=!0);var i=this._position,r=i+t.length;e&&this.validateBuffer(r),this.bytes.set(t,i),this.position=r},i.prototype.validate=function(e){var i=this._bytes.length;return i>0&&this._position+e<=i?!0:void t.$error(1025)},i.prototype.validateBuffer=function(t){this.write_position=t>this.write_position?t:this.write_position,t+=this._position,this._validateBuffer(t)},i.prototype.encodeUTF8=function(t){for(var e=0,i=this.stringToCodePoints(t),r=[];i.length>e;){var n=i[e++];if(this.inRange(n,55296,57343))this.encoderError(n);else if(this.inRange(n,0,127))r.push(n);else{var a=void 0,o=void 0;for(this.inRange(n,128,2047)?(a=1,o=192):this.inRange(n,2048,65535)?(a=2,o=224):this.inRange(n,65536,1114111)&&(a=3,o=240),r.push(this.div(n,Math.pow(64,a))+o);a>0;){var s=this.div(n,Math.pow(64,a-1));r.push(128+s%64),a-=1}}}return new Uint8Array(r)},i.prototype.decodeUTF8=function(t){for(var e,i=!1,r=0,n="",a=0,o=0,s=0,h=0;t.length>r;){var c=t[r++];if(c==this.EOF_byte)e=0!=o?this.decoderError(i):this.EOF_code_point;else if(0==o)this.inRange(c,0,127)?e=c:(this.inRange(c,194,223)?(o=1,h=128,a=c-192):this.inRange(c,224,239)?(o=2,h=2048,a=c-224):this.inRange(c,240,244)?(o=3,h=65536,a=c-240):this.decoderError(i),a*=Math.pow(64,o),e=null);else if(this.inRange(c,128,191))if(s+=1,a+=(c-128)*Math.pow(64,o-s),s!==o)e=null;else{var l=a,u=h;a=0,o=0,s=0,h=0,e=this.inRange(l,u,1114111)&&!this.inRange(l,55296,57343)?l:this.decoderError(i,c)}else a=0,o=0,s=0,h=0,r--,e=this.decoderError(i,c);null!==e&&e!==this.EOF_code_point&&(65535>=e?e>0&&(n+=String.fromCharCode(e)):(e-=65536,n+=String.fromCharCode(55296+(e>>10&1023)),n+=String.fromCharCode(56320+(1023&e))))}return n},i.prototype.encoderError=function(e){t.$error(1026,e)},i.prototype.decoderError=function(e,i){return e&&t.$error(1027),i||65533},i.prototype.inRange=function(t,e,i){return t>=e&&i>=t},i.prototype.div=function(t,e){return Math.floor(t/e)},i.prototype.stringToCodePoints=function(t){for(var e=[],i=0,r=t.length;i=0;l--){var u=s[l];if(!u.$maskedObject&&(c=u.$hitTest(e,i))){if(h=!0,c.$touchEnabled)break;c=null}}return c?this.$touchChildren?c:this:h?this:(c=t.DisplayObject.prototype.$hitTest.call(this,e,i),c&&(c=this.$graphics.$hitTest(e,i)),c)},i.prototype.$measureContentBounds=function(t){this.$graphics.$measureContentBounds(t)},i.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this),this.$graphics&&this.$graphics.$onRemoveFromStage()},i}(t.DisplayObjectContainer);t.Sprite=e,__reflect(e.prototype,"egret.Sprite")}(egret||(egret={}));var egret;!function(t){function e(t,e,i){var r=t.prototype;Object.defineProperty(r,"__class__",{value:e,enumerable:!1,writable:!0});var n=[e];i&&(n=n.concat(i));var a=r.__types__;if(r.__types__)for(var o=a.length,s=0;o>s;s++){var h=a[s];-1==n.indexOf(h)&&n.push(h)}Object.defineProperty(r,"__types__",{value:n,enumerable:!1,writable:!0})}t.registerClass=e}(egret||(egret={}));var egret;!function(t){t.BitmapFillMode={REPEAT:"repeat",SCALE:"scale",CLIP:"clip"}}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return Object.defineProperty(t,"logLevel",{set:function(t){},enumerable:!0,configurable:!0}),t.ALL="all",t.DEBUG="debug",t.INFO="info",t.WARN="warn",t.ERROR="error",t.OFF="off",t}();t.Logger=e,__reflect(e.prototype,"egret.Logger") -}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.isNumber=function(t){return"number"==typeof t&&!isNaN(t)},t.sin=function(e){var i=Math.floor(e),r=i+1,n=t.sinInt(i);if(i==e)return n;var a=t.sinInt(r);return(e-i)*a+(r-e)*n},t.sinInt=function(t){return t%=360,0>t&&(t+=360),egret_sin_map[t]},t.cos=function(e){var i=Math.floor(e),r=i+1,n=t.cosInt(i);if(i==e)return n;var a=t.cosInt(r);return(e-i)*a+(r-e)*n},t.cosInt=function(t){return t%=360,0>t&&(t+=360),egret_cos_map[t]},t.convertStringToHashCode=function(t){if(0===t.length)return 0;for(var e=0,i=0,r=t.length;r>i;++i){var n=t.charCodeAt(i);e=(e<<5)-e+n,e|=0}return e},t}();t.NumberUtils=e,__reflect(e.prototype,"egret.NumberUtils")}(egret||(egret={}));for(var egret_sin_map={},egret_cos_map={},DEG_TO_RAD=Math.PI/180,NumberUtils_i=0;360>NumberUtils_i;NumberUtils_i++)egret_sin_map[NumberUtils_i]=Math.sin(NumberUtils_i*DEG_TO_RAD),egret_cos_map[NumberUtils_i]=Math.cos(NumberUtils_i*DEG_TO_RAD);egret_sin_map[90]=1,egret_cos_map[90]=0,egret_sin_map[180]=0,egret_cos_map[180]=-1,egret_sin_map[270]=-1,egret_cos_map[270]=0,Function.prototype.bind||(Function.prototype.bind=function(t){"function"!=typeof this&&egret.$error(1029);var e=Array.prototype.slice.call(arguments,1),i=this,r=function(){},n=function(){return i.apply(this instanceof r&&t?this:t,e.concat(Array.prototype.slice.call(arguments)))};return r.prototype=this.prototype,n.prototype=new r,n});var egret;!function(t){var e=function(e){function i(t,i){void 0===i&&(i=0);var r=e.call(this)||this;return r._delay=0,r._currentCount=0,r._running=!1,r.updateInterval=1e3,r.lastCount=1e3,r.lastTimeStamp=0,r.delay=t,r.repeatCount=0|+i,r}return __extends(i,e),Object.defineProperty(i.prototype,"delay",{get:function(){return this._delay},set:function(t){1>t&&(t=1),this._delay!=t&&(this._delay=t,this.lastCount=this.updateInterval=Math.round(60*t))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"currentCount",{get:function(){return this._currentCount},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"running",{get:function(){return this._running},enumerable:!0,configurable:!0}),i.prototype.reset=function(){this.stop(),this._currentCount=0},i.prototype.start=function(){this._running||(this.lastCount=this.updateInterval,this.lastTimeStamp=t.getTimer(),t.ticker.$startTick(this.$update,this),this._running=!0)},i.prototype.stop=function(){this._running&&(t.stopTick(this.$update,this),this._running=!1)},i.prototype.$update=function(e){var i=e-this.lastTimeStamp;if(i>=this._delay)this.lastCount=this.updateInterval;else{if(this.lastCount-=1e3,this.lastCount>0)return!1;this.lastCount+=this.updateInterval}this.lastTimeStamp=e,this._currentCount++;var r=this.repeatCount>0&&this._currentCount>=this.repeatCount;return(0==this.repeatCount||this._currentCount<=this.repeatCount)&&t.TimerEvent.dispatchTimerEvent(this,t.TimerEvent.TIMER),r&&(this.stop(),t.TimerEvent.dispatchTimerEvent(this,t.TimerEvent.TIMER_COMPLETE)),!1},i}(t.EventDispatcher);t.Timer=e,__reflect(e.prototype,"egret.Timer")}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){function e(e,i){for(var r=[],n=2;na;a++){var o=r[a];if(e=e[o],!e)return null}return i[t]=e,e}var i={};t.getDefinitionByName=e}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){function e(t){var e=typeof t;if(!t||"object"!=e&&!t.prototype)return e;var i=t.prototype?t.prototype:Object.getPrototypeOf(t);if(i.hasOwnProperty("__class__"))return i.__class__;var r=i.constructor.toString().trim(),n=r.indexOf("("),a=r.substring(9,n);return Object.defineProperty(i,"__class__",{value:a,enumerable:!1,writable:!0}),a}t.getQualifiedClassName=e}(egret||(egret={}));var egret;!function(t){function e(e){if(!e||"object"!=typeof e&&!e.prototype)return null;var i=e.prototype?e.prototype:Object.getPrototypeOf(e),r=Object.getPrototypeOf(i);if(!r)return null;var n=t.getQualifiedClassName(r.constructor);return n?n:null}t.getQualifiedSuperclassName=e}(egret||(egret={}));var egret;!function(t){function e(){return Date.now()-t.sys.$START_TIME}t.getTimer=e}(egret||(egret={}));var egret;!function(t){function e(e){var i=t.getDefinitionByName(e);return i?!0:!1}t.hasDefinition=e}(egret||(egret={}));var egret;!function(t){function e(t,e){if(!t||"object"!=typeof t)return!1;var i=Object.getPrototypeOf(t),r=i?i.__types__:null;return r?-1!==r.indexOf(e):!1}t.is=e}(egret||(egret={}));var egret;!function(t){function e(e,i){t.ticker.$startTick(e,i)}t.startTick=e}(egret||(egret={}));var egret;!function(t){function e(e,i){t.ticker.$stopTick(e,i)}t.stopTick=e}(egret||(egret={}));var egret;!function(t){function e(t){0>t&&(t=0),t>16777215&&(t=16777215);for(var e=t.toString(16).toUpperCase();e.length>6;)e=e.slice(1,e.length);for(;e.length<6;)e="0"+e;return"#"+e}t.toColorString=e}(egret||(egret={})); \ No newline at end of file diff --git a/demo/libs/modules/egret/egret.web.js b/demo/libs/modules/egret/egret.web.js deleted file mode 100644 index 15d58a73..00000000 --- a/demo/libs/modules/egret/egret.web.js +++ /dev/null @@ -1,9806 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var WebGeolocation = (function (_super) { - __extends(WebGeolocation, _super); - /** - * @private - */ - function WebGeolocation(option) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.onUpdate = function (position) { - var event = new egret.GeolocationEvent(egret.Event.CHANGE); - var coords = position.coords; - event.altitude = coords.altitude; - event.heading = coords.heading; - event.accuracy = coords.accuracy; - event.latitude = coords.latitude; - event.longitude = coords.longitude; - event.speed = coords.speed; - event.altitudeAccuracy = coords.altitudeAccuracy; - _this.dispatchEvent(event); - }; - /** - * @private - */ - _this.onError = function (error) { - var errorType = egret.GeolocationEvent.UNAVAILABLE; - if (error.code == error.PERMISSION_DENIED) - errorType = egret.GeolocationEvent.PERMISSION_DENIED; - var event = new egret.GeolocationEvent(egret.IOErrorEvent.IO_ERROR); - event.errorType = errorType; - event.errorMessage = error.message; - _this.dispatchEvent(event); - }; - _this.geolocation = navigator.geolocation; - return _this; - } - /** - * @private - * - */ - WebGeolocation.prototype.start = function () { - var geo = this.geolocation; - if (geo) - this.watchId = geo.watchPosition(this.onUpdate, this.onError); - else - this.onError({ - code: 2, - message: egret.sys.tr(3004), - PERMISSION_DENIED: 1, - POSITION_UNAVAILABLE: 2 - }); - }; - /** - * @private - * - */ - WebGeolocation.prototype.stop = function () { - var geo = this.geolocation; - geo.clearWatch(this.watchId); - }; - return WebGeolocation; - }(egret.EventDispatcher)); - web.WebGeolocation = WebGeolocation; - __reflect(WebGeolocation.prototype, "egret.web.WebGeolocation", ["egret.Geolocation"]); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var WebMotion = (function (_super) { - __extends(WebMotion, _super); - function WebMotion() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.onChange = function (e) { - var event = new egret.MotionEvent(egret.Event.CHANGE); - var acceleration = { - x: e.acceleration.x, - y: e.acceleration.y, - z: e.acceleration.z - }; - var accelerationIncludingGravity = { - x: e.accelerationIncludingGravity.x, - y: e.accelerationIncludingGravity.y, - z: e.accelerationIncludingGravity.z - }; - var rotation = { - alpha: e.rotationRate.alpha, - beta: e.rotationRate.beta, - gamma: e.rotationRate.gamma - }; - event.acceleration = acceleration; - event.accelerationIncludingGravity = accelerationIncludingGravity; - event.rotationRate = rotation; - _this.dispatchEvent(event); - }; - return _this; - } - /** - * @private - * - */ - WebMotion.prototype.start = function () { - window.addEventListener("devicemotion", this.onChange); - }; - /** - * @private - * - */ - WebMotion.prototype.stop = function () { - window.removeEventListener("devicemotion", this.onChange); - }; - return WebMotion; - }(egret.EventDispatcher)); - web.WebMotion = WebMotion; - __reflect(WebMotion.prototype, "egret.web.WebMotion", ["egret.Motion"]); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - function getOption(key) { - if (window.location) { - var search = location.search; - if (search == "") { - return ""; - } - search = search.slice(1); - var searchArr = search.split("&"); - var length_1 = searchArr.length; - for (var i = 0; i < length_1; i++) { - var str = searchArr[i]; - var arr = str.split("="); - if (arr[0] == key) { - return arr[1]; - } - } - } - return ""; - } - web.getOption = getOption; - egret.getOption = getOption; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - * @inheritDoc - */ - var HtmlSoundChannel = (function (_super) { - __extends(HtmlSoundChannel, _super); - /** - * @private - */ - function HtmlSoundChannel(audio) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$startTime = 0; - /** - * @private - */ - _this.audio = null; - //声音是否已经播放完成 - _this.isStopped = false; - _this.canPlay = function () { - _this.audio.removeEventListener("canplay", _this.canPlay); - try { - _this.audio.currentTime = _this.$startTime; - } - catch (e) { - } - finally { - _this.audio.play(); - } - }; - /** - * @private - */ - _this.onPlayEnd = function () { - if (_this.$loops == 1) { - _this.stop(); - _this.dispatchEventWith(egret.Event.SOUND_COMPLETE); - return; - } - if (_this.$loops > 0) { - _this.$loops--; - } - ///////////// - //this.audio.load(); - _this.$play(); - }; - /** - * @private - */ - _this._volume = 1; - audio.addEventListener("ended", _this.onPlayEnd); - _this.audio = audio; - return _this; - } - HtmlSoundChannel.prototype.$play = function () { - if (this.isStopped) { - egret.$error(1036); - return; - } - try { - //this.audio.pause(); - this.audio.volume = this._volume; - this.audio.currentTime = this.$startTime; - } - catch (e) { - this.audio.addEventListener("canplay", this.canPlay); - return; - } - this.audio.play(); - }; - /** - * @private - * @inheritDoc - */ - HtmlSoundChannel.prototype.stop = function () { - if (!this.audio) - return; - if (!this.isStopped) { - egret.sys.$popSoundChannel(this); - } - this.isStopped = true; - var audio = this.audio; - audio.removeEventListener("ended", this.onPlayEnd); - audio.removeEventListener("canplay", this.canPlay); - audio.volume = 0; - this._volume = 0; - this.audio = null; - var url = this.$url; - //延迟一定时间再停止,规避chrome报错 - window.setTimeout(function () { - audio.pause(); - web.HtmlSound.$recycle(url, audio); - }, 200); - }; - Object.defineProperty(HtmlSoundChannel.prototype, "volume", { - /** - * @private - * @inheritDoc - */ - get: function () { - return this._volume; - }, - /** - * @inheritDoc - */ - set: function (value) { - if (this.isStopped) { - egret.$error(1036); - return; - } - this._volume = value; - if (!this.audio) - return; - this.audio.volume = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(HtmlSoundChannel.prototype, "position", { - /** - * @private - * @inheritDoc - */ - get: function () { - if (!this.audio) - return 0; - return this.audio.currentTime; - }, - enumerable: true, - configurable: true - }); - return HtmlSoundChannel; - }(egret.EventDispatcher)); - web.HtmlSoundChannel = HtmlSoundChannel; - __reflect(HtmlSoundChannel.prototype, "egret.web.HtmlSoundChannel", ["egret.SoundChannel", "egret.IEventDispatcher"]); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var WebAudioDecode = (function () { - function WebAudioDecode() { - } - /** - * @private - * - */ - WebAudioDecode.decodeAudios = function () { - if (WebAudioDecode.decodeArr.length <= 0) { - return; - } - if (WebAudioDecode.isDecoding) { - return; - } - WebAudioDecode.isDecoding = true; - var decodeInfo = WebAudioDecode.decodeArr.shift(); - WebAudioDecode.ctx.decodeAudioData(decodeInfo["buffer"], function (audioBuffer) { - decodeInfo["self"].audioBuffer = audioBuffer; - if (decodeInfo["success"]) { - decodeInfo["success"](); - } - WebAudioDecode.isDecoding = false; - WebAudioDecode.decodeAudios(); - }, function () { - egret.log('sound decode error'); - if (decodeInfo["fail"]) { - decodeInfo["fail"](); - } - WebAudioDecode.isDecoding = false; - WebAudioDecode.decodeAudios(); - }); - }; - /** - * @private - */ - WebAudioDecode.decodeArr = []; - /** - * @private - */ - WebAudioDecode.isDecoding = false; - return WebAudioDecode; - }()); - web.WebAudioDecode = WebAudioDecode; - __reflect(WebAudioDecode.prototype, "egret.web.WebAudioDecode"); - /** - * @private - * @inheritDoc - */ - var WebAudioSound = (function (_super) { - __extends(WebAudioSound, _super); - /** - * @private - * @inheritDoc - */ - function WebAudioSound() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.loaded = false; - return _this; - } - Object.defineProperty(WebAudioSound.prototype, "length", { - get: function () { - if (this.audioBuffer) { - return this.audioBuffer.duration; - } - throw new Error("sound not loaded!"); - //return 0; - }, - enumerable: true, - configurable: true - }); - /** - * @inheritDoc - */ - WebAudioSound.prototype.load = function (url) { - var self = this; - this.url = url; - if (true && !url) { - egret.$error(3002); - } - var request = new XMLHttpRequest(); - request.open("GET", url, true); - request.responseType = "arraybuffer"; - request.addEventListener("load", function () { - var ioError = (request.status >= 400); - if (ioError) { - self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - } - else { - WebAudioDecode.decodeArr.push({ - "buffer": request.response, - "success": onAudioLoaded, - "fail": onAudioError, - "self": self, - "url": self.url - }); - WebAudioDecode.decodeAudios(); - } - }); - request.addEventListener("error", function () { - self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - }); - request.send(); - function onAudioLoaded() { - self.loaded = true; - self.dispatchEventWith(egret.Event.COMPLETE); - } - function onAudioError() { - self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - } - }; - /** - * @inheritDoc - */ - WebAudioSound.prototype.play = function (startTime, loops) { - startTime = +startTime || 0; - loops = +loops || 0; - if (true && this.loaded == false) { - egret.$error(1049); - } - var channel = new web.WebAudioSoundChannel(); - channel.$url = this.url; - channel.$loops = loops; - channel.$audioBuffer = this.audioBuffer; - channel.$startTime = startTime; - channel.$play(); - egret.sys.$pushSoundChannel(channel); - return channel; - }; - /** - * @inheritDoc - */ - WebAudioSound.prototype.close = function () { - }; - /** - * Background music - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 背景音乐 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - WebAudioSound.MUSIC = "music"; - /** - * EFFECT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音效 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - WebAudioSound.EFFECT = "effect"; - return WebAudioSound; - }(egret.EventDispatcher)); - web.WebAudioSound = WebAudioSound; - __reflect(WebAudioSound.prototype, "egret.web.WebAudioSound", ["egret.Sound"]); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - * @inheritDoc - */ - var WebAudioSoundChannel = (function (_super) { - __extends(WebAudioSoundChannel, _super); - /** - * @private - */ - function WebAudioSoundChannel() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$startTime = 0; - /** - * @private - */ - _this.bufferSource = null; - /** - * @private - */ - _this.context = web.WebAudioDecode.ctx; - //声音是否已经播放完成 - _this.isStopped = false; - /** - * @private - */ - _this._currentTime = 0; - /** - * @private - */ - _this._volume = 1; - /** - * @private - */ - _this.onPlayEnd = function () { - if (_this.$loops == 1) { - _this.stop(); - _this.dispatchEventWith(egret.Event.SOUND_COMPLETE); - return; - } - if (_this.$loops > 0) { - _this.$loops--; - } - ///////////// - _this.$play(); - }; - /** - * @private - */ - _this._startTime = 0; - if (_this.context["createGain"]) { - _this.gain = _this.context["createGain"](); - } - else { - _this.gain = _this.context["createGainNode"](); - } - return _this; - } - WebAudioSoundChannel.prototype.$play = function () { - if (this.isStopped) { - egret.$error(1036); - return; - } - if (this.bufferSource) { - this.bufferSource.onended = null; - this.bufferSource = null; - } - var context = this.context; - var gain = this.gain; - var bufferSource = context.createBufferSource(); - this.bufferSource = bufferSource; - bufferSource.buffer = this.$audioBuffer; - bufferSource.connect(gain); - gain.connect(context.destination); - bufferSource.onended = this.onPlayEnd; - this._startTime = Date.now(); - this.gain.gain.value = this._volume; - bufferSource.start(0, this.$startTime); - this._currentTime = 0; - }; - WebAudioSoundChannel.prototype.stop = function () { - if (this.bufferSource) { - var sourceNode = this.bufferSource; - if (sourceNode.stop) { - sourceNode.stop(0); - } - else { - sourceNode.noteOff(0); - } - sourceNode.onended = null; - sourceNode.disconnect(); - this.bufferSource = null; - this.$audioBuffer = null; - } - if (!this.isStopped) { - egret.sys.$popSoundChannel(this); - } - this.isStopped = true; - }; - Object.defineProperty(WebAudioSoundChannel.prototype, "volume", { - /** - * @private - * @inheritDoc - */ - get: function () { - return this._volume; - }, - /** - * @inheritDoc - */ - set: function (value) { - if (this.isStopped) { - egret.$error(1036); - return; - } - this._volume = value; - this.gain.gain.value = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebAudioSoundChannel.prototype, "position", { - /** - * @private - * @inheritDoc - */ - get: function () { - if (this.bufferSource) { - return (Date.now() - this._startTime) / 1000 + this.$startTime; - } - return 0; - }, - enumerable: true, - configurable: true - }); - return WebAudioSoundChannel; - }(egret.EventDispatcher)); - web.WebAudioSoundChannel = WebAudioSoundChannel; - __reflect(WebAudioSoundChannel.prototype, "egret.web.WebAudioSoundChannel", ["egret.SoundChannel", "egret.IEventDispatcher"]); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - * @inheritDoc - */ - var WebVideo = (function (_super) { - __extends(WebVideo, _super); - /** - * @inheritDoc - */ - function WebVideo(url, cache) { - if (cache === void 0) { cache = true; } - var _this = _super.call(this) || this; - /** - * @private - */ - _this.loaded = false; - /** - * @private - */ - _this.closed = false; - /** - * @private - */ - _this.heightSet = NaN; - /** - * @private - */ - _this.widthSet = NaN; - /** - * @private - * pc上视频卡住的时候不能暂停 - */ - _this.waiting = false; - /** - * @private - * 用户是否设置了 pause - */ - _this.userPause = false; - /** - * @private - * 用户是否设置了 play - */ - _this.userPlay = false; - _this.isPlayed = false; - _this.screenChanged = function (e) { - var isfullscreen = document.fullscreenEnabled || document.webkitIsFullScreen; - if (!isfullscreen) { - _this.checkFullScreen(false); - if (!egret.Capabilities.isMobile) { - _this._fullscreen = isfullscreen; - } - } - }; - _this._fullscreen = true; - /** - * @private - * - */ - _this.onVideoLoaded = function () { - _this.video.removeEventListener("canplay", _this.onVideoLoaded); - var video = _this.video; - _this.loaded = true; - //video.pause(); - if (_this.posterData) { - _this.posterData.width = _this.getPlayWidth(); - _this.posterData.height = _this.getPlayHeight(); - } - video.width = video.videoWidth; - video.height = video.videoHeight; - window.setTimeout(function () { - _this.dispatchEventWith(egret.Event.COMPLETE); - }, 200); - }; - _this.$renderNode = new egret.sys.BitmapNode(); - _this.src = url; - _this.once(egret.Event.ADDED_TO_STAGE, _this.loadPoster, _this); - if (url) { - _this.load(); - } - return _this; - } - WebVideo.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(1 /* BITMAP */); - }; - /** - * @inheritDoc - */ - WebVideo.prototype.load = function (url, cache) { - var _this = this; - if (cache === void 0) { cache = true; } - url = url || this.src; - this.src = url; - if (true && !url) { - egret.$error(3002); - } - if (this.video && this.video.src == url) { - return; - } - var video; - if (!this.video || egret.Capabilities.isMobile) { - video = document.createElement("video"); - this.video = video; - video.controls = null; - } - else { - video = this.video; - } - video.src = url; - video.setAttribute("autoplay", "autoplay"); - video.setAttribute("webkit-playsinline", "true"); - video.addEventListener("canplay", this.onVideoLoaded); - video.addEventListener("error", function () { return _this.onVideoError(); }); - video.addEventListener("ended", function () { return _this.onVideoEnded(); }); - var firstPause = false; - video.addEventListener("canplay", function () { - _this.waiting = false; - if (!firstPause) { - firstPause = true; - video.pause(); - } - else { - if (_this.userPause) { - _this.pause(); - } - else if (_this.userPlay) { - _this.play(); - } - } - }); - video.addEventListener("waiting", function () { - _this.waiting = true; - }); - video.load(); - this.videoPlay(); - video.style.position = "absolute"; - video.style.top = "0px"; - video.style.zIndex = "-88888"; - video.style.left = "0px"; - video.height = 1; - video.width = 1; - }; - /** - * @inheritDoc - */ - WebVideo.prototype.play = function (startTime, loop) { - var _this = this; - if (loop === void 0) { loop = false; } - if (this.loaded == false) { - this.load(this.src); - this.once(egret.Event.COMPLETE, function (e) { return _this.play(startTime, loop); }, this); - return; - } - this.isPlayed = true; - var video = this.video; - if (startTime != undefined) { - video.currentTime = +startTime || 0; - } - video.loop = !!loop; - if (egret.Capabilities.isMobile) { - video.style.zIndex = "-88888"; //移动端,就算设置成最小,只要全屏,都会在最上层,而且在自动退出去后,不担心挡住canvas - } - else { - video.style.zIndex = "9999"; - } - video.style.position = "absolute"; - video.style.top = "0px"; - video.style.left = "0px"; - video.height = video.videoHeight; - video.width = video.videoWidth; - if (egret.Capabilities.os != "Windows PC" && egret.Capabilities.os != "Mac OS") { - window.setTimeout(function () { - video.width = 0; - }, 1000); - } - this.checkFullScreen(this._fullscreen); - }; - WebVideo.prototype.videoPlay = function () { - this.userPause = false; - if (this.waiting) { - this.userPlay = true; - return; - } - this.userPlay = false; - this.video.play(); - }; - WebVideo.prototype.checkFullScreen = function (playFullScreen) { - var video = this.video; - if (playFullScreen) { - if (video.parentElement == null) { - video.removeAttribute("webkit-playsinline"); - document.body.appendChild(video); - } - egret.stopTick(this.markDirty, this); - this.goFullscreen(); - } - else { - if (video.parentElement != null) { - video.parentElement.removeChild(video); - } - video.setAttribute("webkit-playsinline", "true"); - this.setFullScreenMonitor(false); - egret.startTick(this.markDirty, this); - if (egret.Capabilities.isMobile) { - this.video.currentTime = 0; - this.onVideoEnded(); - return; - } - } - this.videoPlay(); - }; - WebVideo.prototype.goFullscreen = function () { - var video = this.video; - var fullscreenType; - fullscreenType = egret.web.getPrefixStyleName('requestFullscreen', video); - if (!video[fullscreenType]) { - fullscreenType = egret.web.getPrefixStyleName('requestFullScreen', video); - if (!video[fullscreenType]) { - return true; - } - } - video.removeAttribute("webkit-playsinline"); - video[fullscreenType](); - this.setFullScreenMonitor(true); - return true; - }; - WebVideo.prototype.setFullScreenMonitor = function (use) { - var video = this.video; - if (use) { - video.addEventListener("mozfullscreenchange", this.screenChanged); - video.addEventListener("webkitfullscreenchange", this.screenChanged); - video.addEventListener("mozfullscreenerror", this.screenError); - video.addEventListener("webkitfullscreenerror", this.screenError); - } - else { - video.removeEventListener("mozfullscreenchange", this.screenChanged); - video.removeEventListener("webkitfullscreenchange", this.screenChanged); - video.removeEventListener("mozfullscreenerror", this.screenError); - video.removeEventListener("webkitfullscreenerror", this.screenError); - } - }; - WebVideo.prototype.screenError = function () { - egret.$error(3014); - }; - WebVideo.prototype.exitFullscreen = function () { - //退出全屏 - if (document['exitFullscreen']) { - document['exitFullscreen'](); - } - else if (document['msExitFullscreen']) { - document['msExitFullscreen'](); - } - else if (document['mozCancelFullScreen']) { - document['mozCancelFullScreen'](); - } - else if (document['oCancelFullScreen']) { - document['oCancelFullScreen'](); - } - else if (document['webkitExitFullscreen']) { - document['webkitExitFullscreen'](); - } - else { - } - }; - /** - * @private - * - */ - WebVideo.prototype.onVideoEnded = function () { - this.pause(); - this.isPlayed = false; - this.dispatchEventWith(egret.Event.ENDED); - }; - /** - * @private - * - */ - WebVideo.prototype.onVideoError = function () { - this.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - }; - /** - * @inheritDoc - */ - WebVideo.prototype.close = function () { - var _this = this; - this.closed = true; - this.video.removeEventListener("canplay", this.onVideoLoaded); - this.video.removeEventListener("error", function () { return _this.onVideoError(); }); - this.video.removeEventListener("ended", function () { return _this.onVideoEnded(); }); - this.pause(); - if (this.loaded == false && this.video) - this.video.src = ""; - if (this.video && this.video.parentElement) { - this.video.parentElement.removeChild(this.video); - this.video = null; - } - this.loaded = false; - }; - /** - * @inheritDoc - */ - WebVideo.prototype.pause = function () { - this.userPlay = false; - if (this.waiting) { - this.userPause = true; - return; - } - this.userPause = false; - this.video.pause(); - egret.stopTick(this.markDirty, this); - }; - Object.defineProperty(WebVideo.prototype, "volume", { - /** - * @inheritDoc - */ - get: function () { - if (!this.video) - return 1; - return this.video.volume; - }, - /** - * @inheritDoc - */ - set: function (value) { - if (!this.video) - return; - this.video.volume = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebVideo.prototype, "position", { - /** - * @inheritDoc - */ - get: function () { - if (!this.video) - return 0; - return this.video.currentTime; - }, - /** - * @inheritDoc - */ - set: function (value) { - if (!this.video) - return; - this.video.currentTime = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebVideo.prototype, "fullscreen", { - /** - * @inheritDoc - */ - get: function () { - return this._fullscreen; - }, - /** - * @inheritDoc - */ - set: function (value) { - if (egret.Capabilities.isMobile) { - return; - } - this._fullscreen = !!value; - if (this.video && this.video.paused == false) { - this.checkFullScreen(this._fullscreen); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebVideo.prototype, "bitmapData", { - /** - * @inheritDoc - */ - get: function () { - if (!this.video || !this.loaded) - return null; - if (!this._bitmapData) { - this.video.width = this.video.videoWidth; - this.video.height = this.video.videoHeight; - this._bitmapData = new egret.BitmapData(this.video); - this._bitmapData.$deleteSource = false; - } - return this._bitmapData; - }, - enumerable: true, - configurable: true - }); - WebVideo.prototype.loadPoster = function () { - var _this = this; - var poster = this.poster; - if (!poster) - return; - var imageLoader = new egret.ImageLoader(); - imageLoader.once(egret.Event.COMPLETE, function (e) { - var posterData = imageLoader.data; - _this.posterData = imageLoader.data; - _this.$renderDirty = true; - _this.posterData.width = _this.getPlayWidth(); - _this.posterData.height = _this.getPlayHeight(); - if (egret.nativeRender) { - var texture = new egret.Texture(); - texture._setBitmapData(_this.posterData); - _this.$nativeDisplayObject.setTexture(texture); - } - }, this); - imageLoader.load(poster); - }; - /** - * @private - */ - WebVideo.prototype.$measureContentBounds = function (bounds) { - var bitmapData = this.bitmapData; - var posterData = this.posterData; - if (bitmapData) { - bounds.setTo(0, 0, this.getPlayWidth(), this.getPlayHeight()); - } - else if (posterData) { - bounds.setTo(0, 0, this.getPlayWidth(), this.getPlayHeight()); - } - else { - bounds.setEmpty(); - } - }; - WebVideo.prototype.getPlayWidth = function () { - if (!isNaN(this.widthSet)) { - return this.widthSet; - } - if (this.bitmapData) { - return this.bitmapData.width; - } - if (this.posterData) { - return this.posterData.width; - } - return NaN; - }; - WebVideo.prototype.getPlayHeight = function () { - if (!isNaN(this.heightSet)) { - return this.heightSet; - } - if (this.bitmapData) { - return this.bitmapData.height; - } - if (this.posterData) { - return this.posterData.height; - } - return NaN; - }; - /** - * @private - */ - WebVideo.prototype.$updateRenderNode = function () { - var node = this.$renderNode; - var bitmapData = this.bitmapData; - var posterData = this.posterData; - var width = this.getPlayWidth(); - var height = this.getPlayHeight(); - if ((!this.isPlayed || egret.Capabilities.isMobile) && posterData) { - node.image = posterData; - node.imageWidth = width; - node.imageHeight = height; - node.drawImage(0, 0, posterData.width, posterData.height, 0, 0, width, height); - } - else if (this.isPlayed && bitmapData) { - node.image = bitmapData; - node.imageWidth = bitmapData.width; - node.imageHeight = bitmapData.height; - egret.WebGLUtils.deleteWebGLTexture(bitmapData.webGLTexture); - bitmapData.webGLTexture = null; - node.drawImage(0, 0, bitmapData.width, bitmapData.height, 0, 0, width, height); - } - }; - WebVideo.prototype.markDirty = function () { - this.$renderDirty = true; - return true; - }; - /** - * @private - * 设置显示高度 - */ - WebVideo.prototype.$setHeight = function (value) { - this.heightSet = value; - if (this.paused) { - var self_1 = this; - this.$renderDirty = true; - window.setTimeout(function () { - self_1.$renderDirty = false; - }, 200); - } - _super.prototype.$setHeight.call(this, value); - }; - /** - * @private - * 设置显示宽度 - */ - WebVideo.prototype.$setWidth = function (value) { - this.widthSet = value; - if (this.paused) { - var self_2 = this; - this.$renderDirty = true; - window.setTimeout(function () { - self_2.$renderDirty = false; - }, 200); - } - _super.prototype.$setWidth.call(this, value); - }; - Object.defineProperty(WebVideo.prototype, "paused", { - get: function () { - if (this.video) { - return this.video.paused; - } - return true; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebVideo.prototype, "length", { - /** - * @inheritDoc - */ - get: function () { - if (this.video) { - return this.video.duration; - } - throw new Error("Video not loaded!"); - }, - enumerable: true, - configurable: true - }); - return WebVideo; - }(egret.DisplayObject)); - web.WebVideo = WebVideo; - __reflect(WebVideo.prototype, "egret.web.WebVideo", ["egret.Video", "egret.DisplayObject"]); - egret.Video = WebVideo; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var WebHttpRequest = (function (_super) { - __extends(WebHttpRequest, _super); - /** - * @private - */ - function WebHttpRequest() { - var _this = _super.call(this) || this; - /** - * - */ - _this.timeout = 0; - /** - * @private - */ - _this._url = ""; - _this._method = ""; - return _this; - } - Object.defineProperty(WebHttpRequest.prototype, "response", { - /** - * @private - * 本次请求返回的数据,数据类型根据responseType设置的值确定。 - */ - get: function () { - if (!this._xhr) { - return null; - } - if (this._xhr.response != undefined) { - return this._xhr.response; - } - if (this._responseType == "text") { - return this._xhr.responseText; - } - if (this._responseType == "arraybuffer" && /msie 9.0/i.test(navigator.userAgent)) { - var w = window; - return w.convertResponseBodyToText(this._xhr["responseBody"]); - } - if (this._responseType == "document") { - return this._xhr.responseXML; - } - /*if (this._xhr.responseXML) { - return this._xhr.responseXML; - } - if (this._xhr.responseText != undefined) { - return this._xhr.responseText; - }*/ - return null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebHttpRequest.prototype, "responseType", { - /** - * @private - * 设置返回的数据格式,请使用 HttpResponseType 里定义的枚举值。设置非法的值或不设置,都将使用HttpResponseType.TEXT。 - */ - get: function () { - return this._responseType; - }, - set: function (value) { - this._responseType = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WebHttpRequest.prototype, "withCredentials", { - /** - * @private - * 表明在进行跨站(cross-site)的访问控制(Access-Control)请求时,是否使用认证信息(例如cookie或授权的header)。 默认为 false。(这个标志不会影响同站的请求) - */ - get: function () { - return this._withCredentials; - }, - set: function (value) { - this._withCredentials = value; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - WebHttpRequest.prototype.getXHR = function () { - if (window["XMLHttpRequest"]) { - return new window["XMLHttpRequest"](); - } - else { - return new ActiveXObject("MSXML2.XMLHTTP"); - } - }; - /** - * @private - * 初始化一个请求.注意,若在已经发出请求的对象上调用此方法,相当于立即调用abort(). - * @param url 该请求所要访问的URL该请求所要访问的URL - * @param method 请求所使用的HTTP方法, 请使用 HttpMethod 定义的枚举值. - */ - WebHttpRequest.prototype.open = function (url, method) { - if (method === void 0) { method = "GET"; } - this._url = url; - this._method = method; - if (this._xhr) { - this._xhr.abort(); - this._xhr = null; - } - var xhr = this.getXHR(); //new XMLHttpRequest(); - if (window["XMLHttpRequest"]) { - xhr.addEventListener("load", this.onload.bind(this)); - xhr.addEventListener("error", this.onerror.bind(this)); - } - else { - xhr.onreadystatechange = this.onReadyStateChange.bind(this); - } - xhr.onprogress = this.updateProgress.bind(this); - xhr.ontimeout = this.onTimeout.bind(this); - xhr.open(this._method, this._url, true); - this._xhr = xhr; - }; - /** - * @private - * 发送请求. - * @param data 需要发送的数据 - */ - WebHttpRequest.prototype.send = function (data) { - if (this._responseType != null) { - this._xhr.responseType = this._responseType; - } - if (this._withCredentials != null) { - this._xhr.withCredentials = this._withCredentials; - } - if (this.headerObj) { - for (var key in this.headerObj) { - this._xhr.setRequestHeader(key, this.headerObj[key]); - } - } - this._xhr.timeout = this.timeout; - this._xhr.send(data); - }; - /** - * @private - * 如果请求已经被发送,则立刻中止请求. - */ - WebHttpRequest.prototype.abort = function () { - if (this._xhr) { - this._xhr.abort(); - } - }; - /** - * @private - * 返回所有响应头信息(响应头名和值), 如果响应头还没接受,则返回"". - */ - WebHttpRequest.prototype.getAllResponseHeaders = function () { - if (!this._xhr) { - return null; - } - var result = this._xhr.getAllResponseHeaders(); - return result ? result : ""; - }; - /** - * @private - * 给指定的HTTP请求头赋值.在这之前,您必须确认已经调用 open() 方法打开了一个url. - * @param header 将要被赋值的请求头名称. - * @param value 给指定的请求头赋的值. - */ - WebHttpRequest.prototype.setRequestHeader = function (header, value) { - if (!this.headerObj) { - this.headerObj = {}; - } - this.headerObj[header] = value; - }; - /** - * @private - * 返回指定的响应头的值, 如果响应头还没被接受,或该响应头不存在,则返回"". - * @param header 要返回的响应头名称 - */ - WebHttpRequest.prototype.getResponseHeader = function (header) { - if (!this._xhr) { - return null; - } - var result = this._xhr.getResponseHeader(header); - return result ? result : ""; - }; - /** - * @private - */ - WebHttpRequest.prototype.onTimeout = function () { - if (true) { - egret.$warn(1052, this._url); - } - this.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - }; - /** - * @private - */ - WebHttpRequest.prototype.onReadyStateChange = function () { - var xhr = this._xhr; - if (xhr.readyState == 4) { - var ioError_1 = (xhr.status >= 400 || xhr.status == 0); - var url_1 = this._url; - var self_3 = this; - window.setTimeout(function () { - if (ioError_1) { - if (true && !self_3.hasEventListener(egret.IOErrorEvent.IO_ERROR)) { - egret.$error(1011, url_1); - } - self_3.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - } - else { - self_3.dispatchEventWith(egret.Event.COMPLETE); - } - }, 0); - } - }; - /** - * @private - */ - WebHttpRequest.prototype.updateProgress = function (event) { - if (event.lengthComputable) { - egret.ProgressEvent.dispatchProgressEvent(this, egret.ProgressEvent.PROGRESS, event.loaded, event.total); - } - }; - /** - * @private - */ - WebHttpRequest.prototype.onload = function () { - var self = this; - var xhr = this._xhr; - var url = this._url; - var ioError = (xhr.status >= 400); - window.setTimeout(function () { - if (ioError) { - if (true && !self.hasEventListener(egret.IOErrorEvent.IO_ERROR)) { - egret.$error(1011, url); - } - self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - } - else { - self.dispatchEventWith(egret.Event.COMPLETE); - } - }, 0); - }; - /** - * @private - */ - WebHttpRequest.prototype.onerror = function () { - var url = this._url; - var self = this; - window.setTimeout(function () { - if (true && !self.hasEventListener(egret.IOErrorEvent.IO_ERROR)) { - egret.$error(1011, url); - } - self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - }, 0); - }; - return WebHttpRequest; - }(egret.EventDispatcher)); - web.WebHttpRequest = WebHttpRequest; - __reflect(WebHttpRequest.prototype, "egret.web.WebHttpRequest", ["egret.HttpRequest"]); - egret.HttpRequest = WebHttpRequest; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - var winURL = window["URL"] || window["webkitURL"]; - /** - * @private - * ImageLoader 类可用于加载图像(JPG、PNG 或 GIF)文件。使用 load() 方法来启动加载。被加载的图像对象数据将存储在 ImageLoader.data 属性上 。 - */ - var WebImageLoader = (function (_super) { - __extends(WebImageLoader, _super); - function WebImageLoader() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - * 使用 load() 方法加载成功的 BitmapData 图像数据。 - */ - _this.data = null; - /** - * @private - * 当从其他站点加载一个图片时,指定是否启用跨域资源共享(CORS),默认值为null。 - * 可以设置为"anonymous","use-credentials"或null,设置为其他值将等同于"anonymous"。 - */ - _this._crossOrigin = null; - /** - * @private - * 标记crossOrigin有没有被设置过,设置过之后使用设置的属性 - */ - _this._hasCrossOriginSet = false; - /** - * @private - */ - _this.currentImage = null; - /** - * @private - */ - _this.request = null; - return _this; - } - Object.defineProperty(WebImageLoader.prototype, "crossOrigin", { - get: function () { - return this._crossOrigin; - }, - set: function (value) { - this._hasCrossOriginSet = true; - this._crossOrigin = value; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 启动一次图像加载。注意:若之前已经调用过加载请求,重新调用 load() 将终止先前的请求,并开始新的加载。 - * @param url 要加载的图像文件的地址。 - */ - WebImageLoader.prototype.load = function (url) { - if (web.Html5Capatibility._canUseBlob - && url.indexOf("wxLocalResource:") != 0 //微信专用不能使用 blob - && url.indexOf("data:") != 0 - && url.indexOf("http:") != 0 - && url.indexOf("https:") != 0) { - var request = this.request; - if (!request) { - request = this.request = new egret.web.WebHttpRequest(); - request.addEventListener(egret.Event.COMPLETE, this.onBlobLoaded, this); - request.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onBlobError, this); - request.responseType = "blob"; - } - if (true) { - this.currentURL = url; - } - request.open(url); - request.send(); - } - else { - this.loadImage(url); - } - }; - /** - * @private - */ - WebImageLoader.prototype.onBlobLoaded = function (event) { - var blob = this.request.response; - this.request = undefined; - this.loadImage(winURL.createObjectURL(blob)); - }; - /** - * @private - */ - WebImageLoader.prototype.onBlobError = function (event) { - this.dispatchIOError(this.currentURL); - this.request = undefined; - }; - /** - * @private - */ - WebImageLoader.prototype.loadImage = function (src) { - var image = new Image(); - this.data = null; - this.currentImage = image; - if (this._hasCrossOriginSet) { - if (this._crossOrigin) { - image.crossOrigin = this._crossOrigin; - } - } - else { - if (WebImageLoader.crossOrigin) { - image.crossOrigin = WebImageLoader.crossOrigin; - } - } - /*else { - if (image.hasAttribute("crossOrigin")) {//兼容猎豹 - image.removeAttribute("crossOrigin"); - } - }*/ - image.onload = this.onImageComplete.bind(this); - image.onerror = this.onLoadError.bind(this); - image.src = src; - }; - /** - * @private - */ - WebImageLoader.prototype.onImageComplete = function (event) { - var image = this.getImage(event); - if (!image) { - return; - } - this.data = new egret.BitmapData(image); - var self = this; - window.setTimeout(function () { - self.dispatchEventWith(egret.Event.COMPLETE); - }, 0); - }; - /** - * @private - */ - WebImageLoader.prototype.onLoadError = function (event) { - var image = this.getImage(event); - if (!image) { - return; - } - this.dispatchIOError(image.src); - }; - WebImageLoader.prototype.dispatchIOError = function (url) { - var self = this; - window.setTimeout(function () { - if (true && !self.hasEventListener(egret.IOErrorEvent.IO_ERROR)) { - egret.$error(1011, url); - } - self.dispatchEventWith(egret.IOErrorEvent.IO_ERROR); - }, 0); - }; - /** - * @private - */ - WebImageLoader.prototype.getImage = function (event) { - var image = event.target; - var url = image.src; - if (url.indexOf("blob:") == 0) { - try { - winURL.revokeObjectURL(image.src); - } - catch (e) { - egret.$warn(1037); - } - } - image.onerror = null; - image.onload = null; - if (this.currentImage !== image) { - return null; - } - this.currentImage = null; - return image; - }; - /** - * @private - * 指定是否启用跨域资源共享,如果ImageLoader实例有设置过crossOrigin属性将使用设置的属性 - */ - WebImageLoader.crossOrigin = null; - return WebImageLoader; - }(egret.EventDispatcher)); - web.WebImageLoader = WebImageLoader; - __reflect(WebImageLoader.prototype, "egret.web.WebImageLoader", ["egret.ImageLoader"]); - egret.ImageLoader = WebImageLoader; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @classdesc - * @extends egret.StageText - * @private - */ - var HTML5StageText = (function (_super) { - __extends(HTML5StageText, _super); - /** - * @private - */ - function HTML5StageText() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this._isNeedShow = false; - /** - * @private - */ - _this.inputElement = null; - /** - * @private - */ - _this.inputDiv = null; - /** - * @private - */ - _this._gscaleX = 0; - /** - * @private - */ - _this._gscaleY = 0; - /** - * @private - */ - _this.textValue = ""; - /** - * @private - */ - _this.colorValue = 0xffffff; - /** - * @private - */ - _this._styleInfoes = {}; - return _this; - } - /** - * @private - * - * @param textfield - */ - HTML5StageText.prototype.$setTextField = function (textfield) { - this.$textfield = textfield; - return true; - }; - /** - * @private - * - */ - HTML5StageText.prototype.$addToStage = function () { - this.htmlInput = egret.web.$getTextAdapter(this.$textfield); - }; - /** - * @private - * - */ - HTML5StageText.prototype._initElement = function () { - var point = this.$textfield.localToGlobal(0, 0); - var x = point.x; - var y = point.y; - // let m = this.$textfield.$renderNode.renderMatrix; - // let cX = m.a; - // let cY = m.d; - var scaleX = this.htmlInput.$scaleX; - var scaleY = this.htmlInput.$scaleY; - this.inputDiv.style.left = x * scaleX + "px"; - this.inputDiv.style.top = y * scaleY + "px"; - if (this.$textfield.multiline && this.$textfield.height > this.$textfield.size) { - this.inputDiv.style.top = (y) * scaleY + "px"; - this.inputElement.style.top = (-this.$textfield.lineSpacing / 2) * scaleY + "px"; - } - else { - this.inputDiv.style.top = y * scaleY + "px"; - this.inputElement.style.top = 0 + "px"; - } - var node = this.$textfield; - var cX = 1; - var cY = 1; - var rotation = 0; - while (node.parent) { - cX *= node.scaleX; - cY *= node.scaleY; - rotation += node.rotation; - node = node.parent; - } - var transformKey = egret.web.getPrefixStyleName("transform"); - this.inputDiv.style[transformKey] = "rotate(" + rotation + "deg)"; - this._gscaleX = scaleX * cX; - this._gscaleY = scaleY * cY; - }; - /** - * @private - * - */ - HTML5StageText.prototype.$show = function () { - if (!this.htmlInput.isCurrentStageText(this)) { - this.inputElement = this.htmlInput.getInputElement(this); - if (!this.$textfield.multiline) { - this.inputElement.type = this.$textfield.inputType; - } - else { - this.inputElement.type = "text"; - } - this.inputDiv = this.htmlInput._inputDIV; - } - else { - this.inputElement.onblur = null; - } - this.htmlInput._needShow = true; - //标记当前文本被选中 - this._isNeedShow = true; - this._initElement(); - }; - /** - * @private - * - */ - HTML5StageText.prototype.onBlurHandler = function () { - this.htmlInput.clearInputElement(); - window.scrollTo(0, 0); - }; - /** - * @private - * - */ - HTML5StageText.prototype.onFocusHandler = function () { - //the soft keyboard will cover the input box in some cases - var self = this; - window.setTimeout(function () { - if (self.inputElement) { - self.inputElement.scrollIntoView(); - } - }, 200); - }; - /** - * @private - * - */ - HTML5StageText.prototype.executeShow = function () { - var self = this; - //打开 - this.inputElement.value = this.$getText(); - if (this.inputElement.onblur == null) { - this.inputElement.onblur = this.onBlurHandler.bind(this); - } - if (this.inputElement.onfocus == null) { - this.inputElement.onfocus = this.onFocusHandler.bind(this); - } - this.$resetStageText(); - if (this.$textfield.maxChars > 0) { - this.inputElement.setAttribute("maxlength", this.$textfield.maxChars); - } - else { - this.inputElement.removeAttribute("maxlength"); - } - this.inputElement.selectionStart = this.inputElement.value.length; - this.inputElement.selectionEnd = this.inputElement.value.length; - this.inputElement.focus(); - }; - /** - * @private - */ - HTML5StageText.prototype.$hide = function () { - if (this.htmlInput) { - this.htmlInput.disconnectStageText(this); - } - }; - /** - * @private - * - * @returns - */ - HTML5StageText.prototype.$getText = function () { - if (!this.textValue) { - this.textValue = ""; - } - return this.textValue; - }; - /** - * @private - * - * @param value - */ - HTML5StageText.prototype.$setText = function (value) { - this.textValue = value; - this.resetText(); - return true; - }; - /** - * @private - * - */ - HTML5StageText.prototype.resetText = function () { - if (this.inputElement) { - this.inputElement.value = this.textValue; - } - }; - HTML5StageText.prototype.$setColor = function (value) { - this.colorValue = value; - this.resetColor(); - return true; - }; - /** - * @private - * - */ - HTML5StageText.prototype.resetColor = function () { - if (this.inputElement) { - this.setElementStyle("color", egret.toColorString(this.colorValue)); - } - }; - HTML5StageText.prototype.$onBlur = function () { - }; - /** - * @private - * - */ - HTML5StageText.prototype._onInput = function () { - var self = this; - window.setTimeout(function () { - if (self.inputElement && self.inputElement.selectionStart == self.inputElement.selectionEnd) { - self.textValue = self.inputElement.value; - egret.Event.dispatchEvent(self, "updateText", false); - } - }, 0); - }; - HTML5StageText.prototype.setAreaHeight = function () { - var textfield = this.$textfield; - if (textfield.multiline) { - var textheight = egret.TextFieldUtils.$getTextHeight(textfield); - if (textfield.height <= textfield.size) { - this.setElementStyle("height", (textfield.size) * this._gscaleY + "px"); - this.setElementStyle("padding", "0px"); - this.setElementStyle("lineHeight", (textfield.size) * this._gscaleY + "px"); - } - else if (textfield.height < textheight) { - this.setElementStyle("height", (textfield.height) * this._gscaleY + "px"); - this.setElementStyle("padding", "0px"); - this.setElementStyle("lineHeight", (textfield.size + textfield.lineSpacing) * this._gscaleY + "px"); - } - else { - this.setElementStyle("height", (textheight + textfield.lineSpacing) * this._gscaleY + "px"); - var rap = (textfield.height - textheight) * this._gscaleY; - var valign = egret.TextFieldUtils.$getValign(textfield); - var top_1 = rap * valign; - var bottom = rap - top_1; - this.setElementStyle("padding", top_1 + "px 0px " + bottom + "px 0px"); - this.setElementStyle("lineHeight", (textfield.size + textfield.lineSpacing) * this._gscaleY + "px"); - } - } - }; - /** - * @private - * - * @param e - */ - HTML5StageText.prototype._onClickHandler = function (e) { - if (this._isNeedShow) { - e.stopImmediatePropagation(); - //e.preventDefault(); - this._isNeedShow = false; - this.executeShow(); - this.dispatchEvent(new egret.Event("focus")); - } - }; - /** - * @private - * - */ - HTML5StageText.prototype._onDisconnect = function () { - this.inputElement = null; - this.dispatchEvent(new egret.Event("blur")); - }; - /** - * @private - * - * @param style - * @param value - */ - HTML5StageText.prototype.setElementStyle = function (style, value) { - if (this.inputElement) { - if (this._styleInfoes[style] != value) { - this.inputElement.style[style] = value; - //this._styleInfoes[style] = value; - } - } - }; - /** - * @private - * - */ - HTML5StageText.prototype.$removeFromStage = function () { - if (this.inputElement) { - this.htmlInput.disconnectStageText(this); - } - }; - /** - * 修改位置 - * @private - */ - HTML5StageText.prototype.$resetStageText = function () { - if (this.inputElement) { - var textfield = this.$textfield; - this.setElementStyle("fontFamily", textfield.fontFamily); - this.setElementStyle("fontStyle", textfield.italic ? "italic" : "normal"); - this.setElementStyle("fontWeight", textfield.bold ? "bold" : "normal"); - this.setElementStyle("textAlign", textfield.textAlign); - this.setElementStyle("fontSize", textfield.size * this._gscaleY + "px"); - this.setElementStyle("color", egret.toColorString(textfield.textColor)); - var tw = void 0; - if (textfield.stage) { - tw = textfield.localToGlobal(0, 0).x; - tw = Math.min(textfield.width, textfield.stage.stageWidth - tw); - } - else { - tw = textfield.width; - } - this.setElementStyle("width", tw * this._gscaleX + "px"); - this.setElementStyle("verticalAlign", textfield.verticalAlign); - if (textfield.multiline) { - this.setAreaHeight(); - } - else { - this.setElementStyle("lineHeight", (textfield.size) * this._gscaleY + "px"); - if (textfield.height < textfield.size) { - this.setElementStyle("height", (textfield.size) * this._gscaleY + "px"); - var bottom = (textfield.size / 2) * this._gscaleY; - this.setElementStyle("padding", "0px 0px " + bottom + "px 0px"); - } - else { - this.setElementStyle("height", (textfield.size) * this._gscaleY + "px"); - var rap = (textfield.height - textfield.size) * this._gscaleY; - var valign = egret.TextFieldUtils.$getValign(textfield); - var top_2 = rap * valign; - var bottom = rap - top_2; - if (bottom < textfield.size / 2 * this._gscaleY) { - bottom = textfield.size / 2 * this._gscaleY; - } - this.setElementStyle("padding", top_2 + "px 0px " + bottom + "px 0px"); - } - } - this.inputDiv.style.clip = "rect(0px " + (textfield.width * this._gscaleX) + "px " + (textfield.height * this._gscaleY) + "px 0px)"; - this.inputDiv.style.height = textfield.height * this._gscaleY + "px"; - this.inputDiv.style.width = tw * this._gscaleX + "px"; - } - }; - return HTML5StageText; - }(egret.EventDispatcher)); - web.HTML5StageText = HTML5StageText; - __reflect(HTML5StageText.prototype, "egret.web.HTML5StageText", ["egret.StageText"]); - egret.StageText = HTML5StageText; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var HTMLInput = (function () { - function HTMLInput() { - /** - * @private - */ - this._needShow = false; - /** - * @private - */ - this.$scaleX = 1; - /** - * @private - */ - this.$scaleY = 1; - } - /** - * @private - * - * @returns - */ - HTMLInput.prototype.isInputOn = function () { - return this._stageText != null; - }; - /** - * @private - * - * @param stageText - * @returns - */ - HTMLInput.prototype.isCurrentStageText = function (stageText) { - return this._stageText == stageText; - }; - /** - * @private - * - * @param dom - */ - HTMLInput.prototype.initValue = function (dom) { - dom.style.position = "absolute"; - dom.style.left = "0px"; - dom.style.top = "0px"; - dom.style.border = "none"; - dom.style.padding = "0"; - }; - /** - * @private - * - */ - HTMLInput.prototype.$updateSize = function () { - if (!this.canvas) { - return; - } - this.$scaleX = egret.sys.DisplayList.$canvasScaleX; - this.$scaleY = egret.sys.DisplayList.$canvasScaleY; - this.StageDelegateDiv.style.left = this.canvas.style.left; - this.StageDelegateDiv.style.top = this.canvas.style.top; - var transformKey = egret.web.getPrefixStyleName("transform"); - this.StageDelegateDiv.style[transformKey] = this.canvas.style[transformKey]; - this.StageDelegateDiv.style[egret.web.getPrefixStyleName("transformOrigin")] = "0% 0% 0px"; - }; - /** - * @private - * - * @param container - * @param canvas - * @returns - */ - HTMLInput.prototype._initStageDelegateDiv = function (container, canvas) { - this.canvas = canvas; - var self = this; - var stageDelegateDiv; - if (!stageDelegateDiv) { - stageDelegateDiv = document.createElement("div"); - this.StageDelegateDiv = stageDelegateDiv; - stageDelegateDiv.id = "StageDelegateDiv"; - container.appendChild(stageDelegateDiv); - self.initValue(stageDelegateDiv); - self._inputDIV = document.createElement("div"); - self.initValue(self._inputDIV); - self._inputDIV.style.width = "0px"; - self._inputDIV.style.height = "0px"; - self._inputDIV.style.left = 0 + "px"; - self._inputDIV.style.top = "-100px"; - self._inputDIV.style[egret.web.getPrefixStyleName("transformOrigin")] = "0% 0% 0px"; - stageDelegateDiv.appendChild(self._inputDIV); - this.canvas.addEventListener("click", function (e) { - if (self._needShow) { - self._needShow = false; - self._stageText._onClickHandler(e); - self.show(); - } - else { - if (self._inputElement) { - self.clearInputElement(); - self._inputElement.blur(); - self._inputElement = null; - } - } - }); - self.initInputElement(true); - self.initInputElement(false); - } - }; - //初始化输入框 - HTMLInput.prototype.initInputElement = function (multiline) { - var self = this; - //增加1个空的textarea - var inputElement; - if (multiline) { - inputElement = document.createElement("textarea"); - inputElement.style["resize"] = "none"; - self._multiElement = inputElement; - inputElement.id = "egretTextarea"; - } - else { - inputElement = document.createElement("input"); - self._simpleElement = inputElement; - inputElement.id = "egretInput"; - } - inputElement.type = "text"; - self._inputDIV.appendChild(inputElement); - inputElement.setAttribute("tabindex", "-1"); - inputElement.style.width = "1px"; - inputElement.style.height = "12px"; - self.initValue(inputElement); - inputElement.style.outline = "thin"; - inputElement.style.background = "none"; - inputElement.style.overflow = "hidden"; - inputElement.style.wordBreak = "break-all"; - //隐藏输入框 - inputElement.style.opacity = 0; - inputElement.oninput = function () { - if (self._stageText) { - self._stageText._onInput(); - } - }; - }; - /** - * @private - * - */ - HTMLInput.prototype.show = function () { - var self = this; - var inputElement = self._inputElement; - //隐藏输入框 - egret.$callAsync(function () { - inputElement.style.opacity = 1; - }, self); - }; - /** - * @private - * - * @param stageText - */ - HTMLInput.prototype.disconnectStageText = function (stageText) { - if (this._stageText == null || this._stageText == stageText) { - if (this._inputElement) { - this._inputElement.blur(); - } - this.clearInputElement(); - } - this._needShow = false; - }; - /** - * @private - * - */ - HTMLInput.prototype.clearInputElement = function () { - var self = this; - if (self._inputElement) { - self._inputElement.value = ""; - self._inputElement.onblur = null; - self._inputElement.onfocus = null; - self._inputElement.style.width = "1px"; - self._inputElement.style.height = "12px"; - self._inputElement.style.left = "0px"; - self._inputElement.style.top = "0px"; - self._inputElement.style.opacity = 0; - var otherElement = void 0; - if (self._simpleElement == self._inputElement) { - otherElement = self._multiElement; - } - else { - otherElement = self._simpleElement; - } - otherElement.style.display = "block"; - self._inputDIV.style.left = 0 + "px"; - self._inputDIV.style.top = "-100px"; - self._inputDIV.style.height = 0 + "px"; - self._inputDIV.style.width = 0 + "px"; - } - if (self._stageText) { - self._stageText._onDisconnect(); - self._stageText = null; - this.canvas['userTyping'] = false; - } - }; - /** - * @private - * - * @param stageText - * @returns - */ - HTMLInput.prototype.getInputElement = function (stageText) { - var self = this; - self.clearInputElement(); - self._stageText = stageText; - this.canvas['userTyping'] = true; - if (self._stageText.$textfield.multiline) { - self._inputElement = self._multiElement; - } - else { - self._inputElement = self._simpleElement; - } - var otherElement; - if (self._simpleElement == self._inputElement) { - otherElement = self._multiElement; - } - else { - otherElement = self._simpleElement; - } - otherElement.style.display = "none"; - return self._inputElement; - }; - return HTMLInput; - }()); - web.HTMLInput = HTMLInput; - __reflect(HTMLInput.prototype, "egret.web.HTMLInput"); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -(function (egret) { - var web; - (function (web) { - var stageToTextLayerMap = {}; - var stageToCanvasMap = {}; - var stageToContainerMap = {}; - /** - * @private - * 获取 - */ - function $getTextAdapter(textfield) { - var stageHash = textfield.stage ? textfield.stage.$hashCode : 0; - var adapter = stageToTextLayerMap[stageHash]; - var canvas = stageToCanvasMap[stageHash]; - var container = stageToContainerMap[stageHash]; - if (canvas && container) { - //adapter._initStageDelegateDiv(container, canvas); - //adapter.$updateSize(); - delete stageToCanvasMap[stageHash]; - delete stageToContainerMap[stageHash]; - } - return adapter; - } - web.$getTextAdapter = $getTextAdapter; - /** - * @private - */ - function $cacheTextAdapter(adapter, stage, container, canvas) { - adapter._initStageDelegateDiv(container, canvas); - stageToTextLayerMap[stage.$hashCode] = adapter; - stageToCanvasMap[stage.$hashCode] = canvas; - stageToContainerMap[stage.$hashCode] = container; - } - web.$cacheTextAdapter = $cacheTextAdapter; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var context = null; - /** - * @private - */ - var fontCache = {}; - /** - * 测量文本在指定样式下的宽度。 - * @param text 要测量的文本内容。 - * @param fontFamily 字体名称 - * @param fontSize 字体大小 - * @param bold 是否粗体 - * @param italic 是否斜体 - */ - function measureText(text, fontFamily, fontSize, bold, italic) { - if (!context) { - createContext(); - } - var font = ""; - if (italic) - font += "italic "; - if (bold) - font += "bold "; - font += (fontSize || 12) + "px "; - font += (fontFamily || "Arial"); - context.font = font; - return egret.sys.measureTextWith(context, text); - } - /** - * @private - */ - function createContext() { - context = egret.sys.canvasHitTestBuffer.context; - context.textAlign = "left"; - context.textBaseline = "middle"; - } - egret.sys.measureText = measureText; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * 创建一个canvas。 - */ - function __createCanvas__(width, height) { - var canvas = egret.sys.createCanvas(width, height); - var context = canvas.getContext("2d"); - if (context["imageSmoothingEnabled"] === undefined) { - var keys = ["webkitImageSmoothingEnabled", "mozImageSmoothingEnabled", "msImageSmoothingEnabled"]; - var key_1; - for (var i = keys.length - 1; i >= 0; i--) { - key_1 = keys[i]; - if (context[key_1] !== void 0) { - break; - } - } - try { - Object.defineProperty(context, "imageSmoothingEnabled", { - get: function () { - return this[key_1]; - }, - set: function (value) { - this[key_1] = value; - } - }); - } - catch (e) { - context["imageSmoothingEnabled"] = context[key_1]; - } - } - return canvas; - } - var sharedCanvas; - /** - * @private - * Canvas2D渲染缓冲 - */ - var CanvasRenderBuffer = (function () { - function CanvasRenderBuffer(width, height, root) { - this.surface = egret.sys.createCanvasRenderBufferSurface(__createCanvas__, width, height, root); - this.context = this.surface.getContext("2d"); - if (this.context) { - this.context.$offsetX = 0; - this.context.$offsetY = 0; - } - this.resize(width, height); - } - Object.defineProperty(CanvasRenderBuffer.prototype, "width", { - /** - * 渲染缓冲的宽度,以像素为单位。 - * @readOnly - */ - get: function () { - return this.surface.width; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CanvasRenderBuffer.prototype, "height", { - /** - * 渲染缓冲的高度,以像素为单位。 - * @readOnly - */ - get: function () { - return this.surface.height; - }, - enumerable: true, - configurable: true - }); - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param width 改变后的宽 - * @param height 改变后的高 - * @param useMaxSize 若传入true,则将改变后的尺寸与已有尺寸对比,保留较大的尺寸。 - */ - CanvasRenderBuffer.prototype.resize = function (width, height, useMaxSize) { - egret.sys.resizeCanvasRenderBuffer(this, width, height, useMaxSize); - }; - /** - * 获取指定区域的像素 - */ - CanvasRenderBuffer.prototype.getPixels = function (x, y, width, height) { - if (width === void 0) { width = 1; } - if (height === void 0) { height = 1; } - return this.context.getImageData(x, y, width, height).data; - }; - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如: "image/png","image/jpeg" - */ - CanvasRenderBuffer.prototype.toDataURL = function (type, encoderOptions) { - return this.surface.toDataURL(type, encoderOptions); - }; - /** - * 清空缓冲区数据 - */ - CanvasRenderBuffer.prototype.clear = function () { - this.context.setTransform(1, 0, 0, 1, 0, 0); - this.context.clearRect(0, 0, this.surface.width, this.surface.height); - }; - /** - * 销毁绘制对象 - */ - CanvasRenderBuffer.prototype.destroy = function () { - this.surface.width = this.surface.height = 0; - }; - return CanvasRenderBuffer; - }()); - web.CanvasRenderBuffer = CanvasRenderBuffer; - __reflect(CanvasRenderBuffer.prototype, "egret.web.CanvasRenderBuffer", ["egret.sys.RenderBuffer"]); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided this the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var WebTouchHandler = (function (_super) { - __extends(WebTouchHandler, _super); - /** - * @private - */ - function WebTouchHandler(stage, canvas) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.onTouchBegin = function (event) { - var location = _this.getLocation(event); - _this.touch.onTouchBegin(location.x, location.y, event.identifier); - }; - _this.onMouseMove = function (event) { - if (event.buttons == 0) { - _this.onTouchEnd(event); - } - else { - _this.onTouchMove(event); - } - }; - /** - * @private - */ - _this.onTouchMove = function (event) { - var location = _this.getLocation(event); - _this.touch.onTouchMove(location.x, location.y, event.identifier); - }; - /** - * @private - */ - _this.onTouchEnd = function (event) { - var location = _this.getLocation(event); - _this.touch.onTouchEnd(location.x, location.y, event.identifier); - }; - /** - * @private - */ - _this.scaleX = 1; - /** - * @private - */ - _this.scaleY = 1; - /** - * @private - */ - _this.rotation = 0; - _this.canvas = canvas; - _this.touch = new egret.sys.TouchHandler(stage); - _this.addListeners(); - return _this; - } - /** - * @private - * 添加事件监听 - */ - WebTouchHandler.prototype.addListeners = function () { - var _this = this; - if (window.navigator.msPointerEnabled) { - this.canvas.addEventListener("MSPointerDown", function (event) { - event.identifier = event.pointerId; - _this.onTouchBegin(event); - _this.prevent(event); - }, false); - this.canvas.addEventListener("MSPointerMove", function (event) { - event.identifier = event.pointerId; - _this.onTouchMove(event); - _this.prevent(event); - }, false); - this.canvas.addEventListener("MSPointerUp", function (event) { - event.identifier = event.pointerId; - _this.onTouchEnd(event); - _this.prevent(event); - }, false); - } - else { - if (!egret.Capabilities.isMobile) { - this.addMouseListener(); - } - this.addTouchListener(); - } - }; - /** - * @private - * - */ - WebTouchHandler.prototype.addMouseListener = function () { - this.canvas.addEventListener("mousedown", this.onTouchBegin); - this.canvas.addEventListener("mousemove", this.onMouseMove); - this.canvas.addEventListener("mouseup", this.onTouchEnd); - }; - /** - * @private - * - */ - WebTouchHandler.prototype.addTouchListener = function () { - var _this = this; - this.canvas.addEventListener("touchstart", function (event) { - var l = event.changedTouches.length; - for (var i = 0; i < l; i++) { - _this.onTouchBegin(event.changedTouches[i]); - } - _this.prevent(event); - }, false); - this.canvas.addEventListener("touchmove", function (event) { - var l = event.changedTouches.length; - for (var i = 0; i < l; i++) { - _this.onTouchMove(event.changedTouches[i]); - } - _this.prevent(event); - }, false); - this.canvas.addEventListener("touchend", function (event) { - var l = event.changedTouches.length; - for (var i = 0; i < l; i++) { - _this.onTouchEnd(event.changedTouches[i]); - } - _this.prevent(event); - }, false); - this.canvas.addEventListener("touchcancel", function (event) { - var l = event.changedTouches.length; - for (var i = 0; i < l; i++) { - _this.onTouchEnd(event.changedTouches[i]); - } - _this.prevent(event); - }, false); - }; - /** - * @private - */ - WebTouchHandler.prototype.prevent = function (event) { - event.stopPropagation(); - if (event["isScroll"] != true && !this.canvas['userTyping']) { - event.preventDefault(); - } - }; - /** - * @private - */ - WebTouchHandler.prototype.getLocation = function (event) { - event.identifier = +event.identifier || 0; - var doc = document.documentElement; - var box = this.canvas.getBoundingClientRect(); - var left = box.left + window.pageXOffset - doc.clientLeft; - var top = box.top + window.pageYOffset - doc.clientTop; - var x = event.pageX - left, newx = x; - var y = event.pageY - top, newy = y; - if (this.rotation == 90) { - newx = y; - newy = box.width - x; - } - else if (this.rotation == -90) { - newx = box.height - y; - newy = x; - } - newx = newx / this.scaleX; - newy = newy / this.scaleY; - return egret.$TempPoint.setTo(Math.round(newx), Math.round(newy)); - }; - /** - * @private - * 更新屏幕当前的缩放比例,用于计算准确的点击位置。 - * @param scaleX 水平方向的缩放比例。 - * @param scaleY 垂直方向的缩放比例。 - */ - WebTouchHandler.prototype.updateScaleMode = function (scaleX, scaleY, rotation) { - this.scaleX = scaleX; - this.scaleY = scaleY; - this.rotation = rotation; - }; - /** - * @private - * 更新同时触摸点的数量 - */ - WebTouchHandler.prototype.$updateMaxTouches = function () { - this.touch.$initMaxTouches(); - }; - return WebTouchHandler; - }(egret.HashObject)); - web.WebTouchHandler = WebTouchHandler; - __reflect(WebTouchHandler.prototype, "egret.web.WebTouchHandler"); - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - web.WebLifeCycleHandler = function (context) { - var handleVisibilityChange = function () { - if (!document[hidden]) { - context.resume(); - } - else { - context.pause(); - } - }; - window.addEventListener("focus", context.resume, false); - window.addEventListener("blur", context.pause, false); - var hidden, visibilityChange; - if (typeof document.hidden !== "undefined") { - hidden = "hidden"; - visibilityChange = "visibilitychange"; - } - else if (typeof document["mozHidden"] !== "undefined") { - hidden = "mozHidden"; - visibilityChange = "mozvisibilitychange"; - } - else if (typeof document["msHidden"] !== "undefined") { - hidden = "msHidden"; - visibilityChange = "msvisibilitychange"; - } - else if (typeof document["webkitHidden"] !== "undefined") { - hidden = "webkitHidden"; - visibilityChange = "webkitvisibilitychange"; - } - else if (typeof document["oHidden"] !== "undefined") { - hidden = "oHidden"; - visibilityChange = "ovisibilitychange"; - } - if ("onpageshow" in window && "onpagehide" in window) { - window.addEventListener("pageshow", context.resume, false); - window.addEventListener("pagehide", context.pause, false); - } - if (hidden && visibilityChange) { - document.addEventListener(visibilityChange, handleVisibilityChange, false); - } - var ua = navigator.userAgent; - var isWX = /micromessenger/gi.test(ua); - var isQQBrowser = /mqq/ig.test(ua); - var isQQ = /mobile.*qq/gi.test(ua); - if (isQQ || isWX) { - isQQBrowser = false; - } - if (isQQBrowser) { - var browser = window["browser"] || {}; - browser.execWebFn = browser.execWebFn || {}; - browser.execWebFn.postX5GamePlayerMessage = function (event) { - var eventType = event.type; - if (eventType == "app_enter_background") { - context.pause(); - } - else if (eventType == "app_enter_foreground") { - context.resume(); - } - }; - window["browser"] = browser; - } - }; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var AudioType = (function () { - function AudioType() { - } - /** - * @private - */ - AudioType.WEB_AUDIO = 2; - /** - * @private - */ - AudioType.HTML5_AUDIO = 3; - return AudioType; - }()); - web.AudioType = AudioType; - __reflect(AudioType.prototype, "egret.web.AudioType"); - /** - * html5兼容性配置 - * @private - */ - var Html5Capatibility = (function (_super) { - __extends(Html5Capatibility, _super); - /** - * @private - */ - function Html5Capatibility() { - return _super.call(this) || this; - } - /** - * @private - * - */ - Html5Capatibility.$init = function () { - var ua = navigator.userAgent.toLowerCase(); - Html5Capatibility.ua = ua; - Html5Capatibility._canUseBlob = false; - var canUseWebAudio = window["AudioContext"] || window["webkitAudioContext"] || window["mozAudioContext"]; - var isIos = ua.indexOf("iphone") >= 0 || ua.indexOf("ipad") >= 0 || ua.indexOf("ipod") >= 0; - if (canUseWebAudio) { - try { - //防止某些chrome版本创建异常问题 - web.WebAudioDecode.ctx = new (window["AudioContext"] || window["webkitAudioContext"] || window["mozAudioContext"])(); - } - catch (e) { - canUseWebAudio = false; - } - } - var audioType = Html5Capatibility._audioType; - var checkAudioType; - if ((audioType == AudioType.WEB_AUDIO && canUseWebAudio) || audioType == AudioType.HTML5_AUDIO) { - checkAudioType = false; - Html5Capatibility.setAudioType(audioType); - } - else if (!isIos && ua.indexOf("safari") >= 0 && ua.indexOf("chrome") === -1) { - // In Safari browser on Mac,use web audio - checkAudioType = false; - Html5Capatibility.setAudioType(AudioType.WEB_AUDIO); - } - else { - checkAudioType = true; - Html5Capatibility.setAudioType(AudioType.HTML5_AUDIO); - } - if (ua.indexOf("android") >= 0) { - if (checkAudioType && canUseWebAudio) { - Html5Capatibility.setAudioType(AudioType.WEB_AUDIO); - } - } - else if (isIos) { - if (Html5Capatibility.getIOSVersion() >= 7) { - Html5Capatibility._canUseBlob = true; - if (checkAudioType && canUseWebAudio) { - Html5Capatibility.setAudioType(AudioType.WEB_AUDIO); - } - } - } - var winURL = window["URL"] || window["webkitURL"]; - if (!winURL) { - Html5Capatibility._canUseBlob = false; - } - if (ua.indexOf("egretnative") >= 0) { - Html5Capatibility.setAudioType(AudioType.HTML5_AUDIO); - Html5Capatibility._canUseBlob = true; - } - egret.Sound = Html5Capatibility._AudioClass; - }; - Html5Capatibility.setAudioType = function (type) { - Html5Capatibility._audioType = type; - switch (type) { - case AudioType.WEB_AUDIO: - Html5Capatibility._AudioClass = egret.web.WebAudioSound; - break; - case AudioType.HTML5_AUDIO: - Html5Capatibility._AudioClass = egret.web.HtmlSound; - break; - } - }; - /** - * @private - * 获取ios版本 - * @returns {string} - */ - Html5Capatibility.getIOSVersion = function () { - var matches = Html5Capatibility.ua.toLowerCase().match(/cpu [^\d]*\d.*like mac os x/); - if (!matches || matches.length == 0) { - return 0; - } - var value = matches[0]; - return parseInt(value.match(/\d+(_\d)*/)[0]) || 0; - }; - //当前浏览器版本是否支持blob - Html5Capatibility._canUseBlob = false; - //当前浏览器版本是否支持webaudio - Html5Capatibility._audioType = 0; - /** - * @private - */ - Html5Capatibility.ua = ""; - return Html5Capatibility; - }(egret.HashObject)); - web.Html5Capatibility = Html5Capatibility; - __reflect(Html5Capatibility.prototype, "egret.web.Html5Capatibility"); - /** - * @private - */ - var currentPrefix = null; - /** - * @private - */ - function getPrefixStyleName(name, element) { - var header = ""; - if (element != null) { - header = getPrefix(name, element); - } - else { - if (currentPrefix == null) { - var tempStyle = document.createElement('div').style; - currentPrefix = getPrefix("transform", tempStyle); - } - header = currentPrefix; - } - if (header == "") { - return name; - } - return header + name.charAt(0).toUpperCase() + name.substring(1, name.length); - } - web.getPrefixStyleName = getPrefixStyleName; - /** - * @private - */ - function getPrefix(name, element) { - if (name in element) { - return ""; - } - name = name.charAt(0).toUpperCase() + name.substring(1, name.length); - var transArr = ["webkit", "ms", "Moz", "O"]; - for (var i = 0; i < transArr.length; i++) { - var tempStyle = transArr[i] + name; - if (tempStyle in element) { - return transArr[i]; - } - } - return ""; - } - web.getPrefix = getPrefix; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * 创建一个canvas。 - */ - function mainCanvas(width, height) { - return createCanvas(width, height); - } - egret.sys.mainCanvas = mainCanvas; - function createCanvas(width, height) { - var canvas = document.createElement("canvas"); - if (!isNaN(width) && !isNaN(height)) { - canvas.width = width; - canvas.height = height; - } - return canvas; - } - egret.sys.createCanvas = createCanvas; - /** - * sys.resizeContext。 - */ - function resizeContext(renderContext, width, height, useMaxSize) { - if (!renderContext) { - return; - } - var webglrendercontext = renderContext; - var surface = webglrendercontext.surface; - if (useMaxSize) { - if (surface.width < width) { - surface.width = width; - } - if (surface.height < height) { - surface.height = height; - } - } - else { - if (surface.width !== width) { - surface.width = width; - } - if (surface.height !== height) { - surface.height = height; - } - } - webglrendercontext.onResize(); - } - web.resizeContext = resizeContext; - egret.sys.resizeContext = resizeContext; - /** - * sys.getContextWebGL - */ - function getContextWebGL(surface) { - var options = { - antialias: web.WebGLRenderContext.antialias, - stencil: true //设置可以使用模板(用于不规则遮罩) - }; - var gl = null; - //todo 是否使用chrome源码names - //let contextNames = ["moz-webgl", "webkit-3d", "experimental-webgl", "webgl", "3d"]; - var names = ["webgl", "experimental-webgl"]; - for (var i = 0; i < names.length; ++i) { - try { - gl = surface.getContext(names[i], options); - } - catch (e) { - } - if (gl) { - break; - } - } - if (!gl) { - egret.$error(1021); - } - return gl; - } - egret.sys.getContextWebGL = getContextWebGL; - /** - * sys.getContext2d - */ - function getContext2d(surface) { - return surface ? surface.getContext('2d') : null; - } - web.getContext2d = getContext2d; - egret.sys.getContext2d = getContext2d; - /** - * 创建一个WebGLTexture - */ - function createTexture(renderContext, bitmapData) { - var webglrendercontext = renderContext; - var gl = webglrendercontext.context; - var texture = gl.createTexture(); - if (!texture) { - //先创建texture失败,然后lost事件才发出来.. - webglrendercontext.contextLost = true; - return; - } - texture[egret.glContext] = gl; - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1); - texture[egret.UNPACK_PREMULTIPLY_ALPHA_WEBGL] = true; - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, bitmapData); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - return texture; - } - egret.sys.createTexture = createTexture; - /** - * 创建一个WebGLTexture - */ - function _createTexture(renderContext, width, height, data) { - var webglrendercontext = renderContext; - var gl = webglrendercontext.context; - var texture = gl.createTexture(); - if (!texture) { - //先创建texture失败,然后lost事件才发出来.. - webglrendercontext.contextLost = true; - return null; - } - // - texture[egret.glContext] = gl; - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1); - texture[egret.UNPACK_PREMULTIPLY_ALPHA_WEBGL] = true; - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, data); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - return texture; - } - egret.sys._createTexture = _createTexture; - /** - * 画texture - **/ - function drawTextureElements(renderContext, data, offset) { - var webglrendercontext = renderContext; - var gl = webglrendercontext.context; - gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, data.texture); - var size = data.count * 3; - gl.drawElements(gl.TRIANGLES, size, gl.UNSIGNED_SHORT, offset * 2); - return size; - } - egret.sys.drawTextureElements = drawTextureElements; - /** - * 测量文本的宽度 - * @param context - * @param text - */ - function measureTextWith(context, text) { - return context.measureText(text).width; - } - egret.sys.measureTextWith = measureTextWith; - /** - * 为CanvasRenderBuffer创建一个HTMLCanvasElement - * @param defaultFunc - * @param width - * @param height - * @param root - */ - function createCanvasRenderBufferSurface(defaultFunc, width, height, root) { - return defaultFunc(width, height); - } - egret.sys.createCanvasRenderBufferSurface = createCanvasRenderBufferSurface; - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param renderContext - * @param width - * @param height - * @param useMaxSize - */ - function resizeCanvasRenderBuffer(renderContext, width, height, useMaxSize) { - var canvasRenderBuffer = renderContext; - var surface = canvasRenderBuffer.surface; - if (useMaxSize) { - var change = false; - if (surface.width < width) { - surface.width = width; - change = true; - } - if (surface.height < height) { - surface.height = height; - change = true; - } - //尺寸没有变化时,将绘制属性重置 - if (!change) { - canvasRenderBuffer.context.globalCompositeOperation = "source-over"; - canvasRenderBuffer.context.setTransform(1, 0, 0, 1, 0, 0); - canvasRenderBuffer.context.globalAlpha = 1; - } - } - else { - if (surface.width != width) { - surface.width = width; - } - if (surface.height != height) { - surface.height = height; - } - } - canvasRenderBuffer.clear(); - } - egret.sys.resizeCanvasRenderBuffer = resizeCanvasRenderBuffer; - egret.Geolocation = egret.web.WebGeolocation; - egret.Motion = egret.web.WebMotion; - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - * 刷新所有Egret播放器的显示区域尺寸。仅当使用外部JavaScript代码动态修改了Egret容器大小时,需要手动调用此方法刷新显示区域。 - * 当网页尺寸发生改变时此方法会自动被调用。 - */ - function updateAllScreens() { - if (!isRunning) { - return; - } - var containerList = document.querySelectorAll(".egret-player"); - var length = containerList.length; - for (var i = 0; i < length; i++) { - var container = containerList[i]; - var player = container["egret-player"]; - player.updateScreenSize(); - } - } - var isRunning = false; - /** - * @private - * 网页加载完成,实例化页面中定义的Egret标签 - */ - function runEgret(options) { - if (isRunning) { - return; - } - isRunning = true; - if (!options) { - options = {}; - } - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("egretnative") >= 0 && ua.indexOf("egretwebview") == -1) { - egret.Capabilities["runtimeType" + ""] = egret.RuntimeType.RUNTIME2; - } - if (ua.indexOf("egretnative") >= 0 && egret.nativeRender) { - egret_native.addModuleCallback(function () { - web.Html5Capatibility.$init(); - // WebGL上下文参数自定义 - if (options.renderMode == "webgl") { - // WebGL抗锯齿默认关闭,提升PC及某些平台性能 - var antialias = options.antialias; - web.WebGLRenderContext.antialias = !!antialias; - } - egret.sys.CanvasRenderBuffer = web.CanvasRenderBuffer; - setRenderMode(options.renderMode); - egret_native.nrSetRenderMode(2); - var canvasScaleFactor; - if (options.canvasScaleFactor) { - canvasScaleFactor = options.canvasScaleFactor; - } - else if (options.calculateCanvasScaleFactor) { - canvasScaleFactor = options.calculateCanvasScaleFactor(egret.sys.canvasHitTestBuffer.context); - } - else { - canvasScaleFactor = window.devicePixelRatio; - } - egret.sys.DisplayList.$canvasScaleFactor = canvasScaleFactor; - var ticker = egret.ticker; - startTicker(ticker); - if (options.screenAdapter) { - egret.sys.screenAdapter = options.screenAdapter; - } - else if (!egret.sys.screenAdapter) { - egret.sys.screenAdapter = new egret.sys.DefaultScreenAdapter(); - } - var list = document.querySelectorAll(".egret-player"); - var length = list.length; - for (var i = 0; i < length; i++) { - var container = list[i]; - var player = new web.WebPlayer(container, options); - container["egret-player"] = player; - } - window.addEventListener("resize", function () { - if (isNaN(resizeTimer)) { - resizeTimer = window.setTimeout(doResize, 300); - } - }); - }, null); - egret_native.initNativeRender(); - } - else { - web.Html5Capatibility._audioType = options.audioType; - web.Html5Capatibility.$init(); - var renderMode = options.renderMode; - // WebGL上下文参数自定义 - if (renderMode == "webgl") { - // WebGL抗锯齿默认关闭,提升PC及某些平台性能 - var antialias = options.antialias; - web.WebGLRenderContext.antialias = !!antialias; - // WebGLRenderContext.antialias = (typeof antialias == undefined) ? true : antialias; - } - egret.sys.CanvasRenderBuffer = web.CanvasRenderBuffer; - if (ua.indexOf("egretnative") >= 0 && renderMode != "webgl") { - egret.$warn(1051); - renderMode = "webgl"; - } - setRenderMode(renderMode); - var canvasScaleFactor = void 0; - if (options.canvasScaleFactor) { - canvasScaleFactor = options.canvasScaleFactor; - } - else if (options.calculateCanvasScaleFactor) { - canvasScaleFactor = options.calculateCanvasScaleFactor(egret.sys.canvasHitTestBuffer.context); - } - else { - //based on : https://github.com/jondavidjohn/hidpi-canvas-polyfill - var context = egret.sys.canvasHitTestBuffer.context; - var backingStore = context.backingStorePixelRatio || - context.webkitBackingStorePixelRatio || - context.mozBackingStorePixelRatio || - context.msBackingStorePixelRatio || - context.oBackingStorePixelRatio || - context.backingStorePixelRatio || 1; - canvasScaleFactor = (window.devicePixelRatio || 1) / backingStore; - } - egret.sys.DisplayList.$canvasScaleFactor = canvasScaleFactor; - var ticker_1 = egret.ticker; - startTicker(ticker_1); - if (options.screenAdapter) { - egret.sys.screenAdapter = options.screenAdapter; - } - else if (!egret.sys.screenAdapter) { - egret.sys.screenAdapter = new egret.sys.DefaultScreenAdapter(); - } - var list = document.querySelectorAll(".egret-player"); - var length_2 = list.length; - for (var i = 0; i < length_2; i++) { - var container = list[i]; - var player = new web.WebPlayer(container, options); - container["egret-player"] = player; - } - window.addEventListener("resize", function () { - if (isNaN(resizeTimer)) { - resizeTimer = window.setTimeout(doResize, 300); - } - }); - } - } - /** - * 设置渲染模式。"auto","webgl","canvas" - * @param renderMode - */ - function setRenderMode(renderMode) { - if (renderMode == "webgl" && egret.WebGLUtils.checkCanUseWebGL()) { - egret.sys.RenderBuffer = web.WebGLRenderBuffer; - egret.sys.systemRenderer = new web.WebGLRenderer(); - egret.sys.canvasRenderer = new egret.CanvasRenderer(); - egret.sys.customHitTestBuffer = new web.WebGLRenderBuffer(3, 3); - egret.sys.canvasHitTestBuffer = new web.CanvasRenderBuffer(3, 3); - egret.Capabilities["renderMode" + ""] = "webgl"; - } - else { - egret.sys.RenderBuffer = web.CanvasRenderBuffer; - egret.sys.systemRenderer = new egret.CanvasRenderer(); - egret.sys.canvasRenderer = egret.sys.systemRenderer; - egret.sys.customHitTestBuffer = new web.CanvasRenderBuffer(3, 3); - egret.sys.canvasHitTestBuffer = egret.sys.customHitTestBuffer; - egret.Capabilities["renderMode" + ""] = "canvas"; - } - } - /** - * @private - * 启动心跳计时器。 - */ - function startTicker(ticker) { - var requestAnimationFrame = window["requestAnimationFrame"] || - window["webkitRequestAnimationFrame"] || - window["mozRequestAnimationFrame"] || - window["oRequestAnimationFrame"] || - window["msRequestAnimationFrame"]; - if (!requestAnimationFrame) { - requestAnimationFrame = function (callback) { - return window.setTimeout(callback, 1000 / 60); - }; - } - requestAnimationFrame(onTick); - function onTick() { - requestAnimationFrame(onTick); - ticker.update(); - } - } - //覆盖原生的isNaN()方法实现,在不同浏览器上有2~10倍性能提升。 - window["isNaN"] = function (value) { - value = +value; - return value !== value; - }; - egret.runEgret = runEgret; - egret.updateAllScreens = updateAllScreens; - var resizeTimer = NaN; - function doResize() { - resizeTimer = NaN; - egret.updateAllScreens(); - } - })(web = egret.web || (egret.web = {})); -})(egret || (egret = {})); -if (true) { - var language = navigator.language || navigator["browserLanguage"] || "en_US"; - language = language.replace("-", "_"); - if (language in egret.$locale_strings) - egret.$language = language; -} -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var web; - (function (web) { - /** - * @private - */ - var WebCapability = (function () { - function WebCapability() { - } - /** - * @private - * 检测系统属性 - */ - WebCapability.detect = function () { - var capabilities = egret.Capabilities; - var ua = navigator.userAgent.toLowerCase(); - capabilities["isMobile" + ""] = (ua.indexOf('mobile') != -1 || ua.indexOf('android') != -1); - if (capabilities.isMobile) { - if (ua.indexOf("windows") < 0 && (ua.indexOf("iphone") != -1 || ua.indexOf("ipad") != -1 || ua.indexOf("ipod") != -1)) { - capabilities["os" + ""] = "iOS"; - } - else if (ua.indexOf("android") != -1 && ua.indexOf("linux") != -1) { - capabilities["os" + ""] = "Android"; - } - else if (ua.indexOf("windows") != -1) { - capabilities["os" + ""] = "Windows Phone"; - } - } - else { - if (ua.indexOf("windows nt") != -1) { - capabilities["os" + ""] = "Windows PC"; - } - else if (navigator.platform == "MacIntel" && navigator.maxTouchPoints > 1) { - capabilities["os" + ""] = "iOS"; - capabilities["isMobile" + ""] = true; - } - else if (ua.indexOf("mac os") != -1) { - capabilities["os" + ""] = "Mac OS"; - } - } - var language = (navigator.language || navigator["browserLanguage"]).toLowerCase(); - var strings = language.split("-"); - if (strings.length > 1) { - strings[1] = strings[1].toUpperCase(); - } - capabilities["language" + ""] = strings.join("-"); - WebCapability.injectUIntFixOnIE9(); - }; - WebCapability.injectUIntFixOnIE9 = function () { - if (/msie 9.0/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) { - var IEBinaryToArray_ByteStr_Script = "\r\n" + - "\r\n\r\n\r\n";document.write(e)}},t}();t.WebCapability=r,__reflect(r.prototype,"egret.web.WebCapability"),r.detect()}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(){function t(t,r,i,n,a){if(this.showPanle=!0,this.fpsHeight=0,this.WIDTH=101,this.HEIGHT=20,this.bgCanvasColor="#18304b",this.fpsFrontColor="#18fefe",this.WIDTH_COST=50,this.cost1Color="#18fefe",this.cost3Color="#ff0000",this.arrFps=[],this.arrCost=[],this.arrLog=[],r||i){"canvas"==e.Capabilities.renderMode?this.renderMode="Canvas":this.renderMode="WebGL",this.panelX=void 0===a.x?0:parseInt(a.x),this.panelY=void 0===a.y?0:parseInt(a.y),this.fontColor=void 0===a.textColor?"#ffffff":a.textColor.replace("0x","#"),this.fontSize=void 0===a.size?12:parseInt(a.size),e.Capabilities.isMobile&&(this.fontSize-=2);var o=document.createElement("div");o.style.position="absolute",o.style.background="rgba(0,0,0,"+a.bgAlpha+")",o.style.left=this.panelX+"px",o.style.top=this.panelY+"px",o.style.pointerEvents="none",o.id="egret-fps-panel",document.body.appendChild(o);var s=document.createElement("div");s.style.color=this.fontColor,s.style.fontSize=this.fontSize+"px",s.style.lineHeight=this.fontSize+"px",s.style.margin="4px 4px 4px 4px",this.container=s,o.appendChild(s),r&&this.addFps(),i&&this.addLog()}}return t.prototype.addFps=function(){var e=document.createElement("div");e.style.display="inline-block",this.containerFps=e,this.container.appendChild(e);var t=document.createElement("div");t.style.paddingBottom="2px",this.fps=t,this.containerFps.appendChild(t),t.innerHTML="0 FPS "+this.renderMode+"
      min0 max0 avg0";var r=document.createElement("canvas");this.containerFps.appendChild(r),r.width=this.WIDTH,r.height=this.HEIGHT,this.canvasFps=r;var i=r.getContext("2d");this.contextFps=i,i.fillStyle=this.bgCanvasColor,i.fillRect(0,0,this.WIDTH,this.HEIGHT);var n=document.createElement("div");this.divDatas=n,this.containerFps.appendChild(n);var a=document.createElement("div");a.style["float"]="left",a.innerHTML="Draw
      Cost",n.appendChild(a);var o=document.createElement("div");o.style.paddingLeft=a.offsetWidth+20+"px",n.appendChild(o);var s=document.createElement("div");this.divDraw=s,s.innerHTML="0
      ",o.appendChild(s);var l=document.createElement("div");this.divCost=l,l.innerHTML='0 0',o.appendChild(l),r=document.createElement("canvas"),this.canvasCost=r,this.containerFps.appendChild(r),r.width=this.WIDTH,r.height=this.HEIGHT,i=r.getContext("2d"),this.contextCost=i,i.fillStyle=this.bgCanvasColor,i.fillRect(0,0,this.WIDTH,this.HEIGHT),i.fillStyle="#000000",i.fillRect(this.WIDTH_COST,0,1,this.HEIGHT),this.fpsHeight=this.container.offsetHeight},t.prototype.addLog=function(){var e=document.createElement("div");e.style.maxWidth=document.body.clientWidth-8-this.panelX+"px",e.style.wordWrap="break-word",this.log=e,this.container.appendChild(e)},t.prototype.update=function(e,t){void 0===t&&(t=!1);var r,i,n;t?(r=this.arrFps[this.arrFps.length-1],i=this.arrCost[this.arrCost.length-1][0],n=this.arrCost[this.arrCost.length-1][1]):(r=e.fps,i=e.costTicker,n=e.costRender,this.lastNumDraw=e.draw,this.arrFps.push(r),this.arrCost.push([i,n]));var a=0,o=this.arrFps.length;o>101&&(o=101,this.arrFps.shift(),this.arrCost.shift());for(var s=this.arrFps[0],l=this.arrFps[0],c=0;o>c;c++){var h=this.arrFps[c];a+=h,s>h?s=h:h>l&&(l=h)}var u=this.WIDTH,d=this.HEIGHT,f=this.contextFps;f.drawImage(this.canvasFps,1,0,u-1,d,0,0,u-1,d),f.fillStyle=this.bgCanvasColor,f.fillRect(u-1,0,1,d);var p=Math.floor(r/60*20);1>p&&(p=1),f.fillStyle=this.fpsFrontColor,f.fillRect(u-1,20-p,1,p);var v=this.WIDTH_COST;f=this.contextCost,f.drawImage(this.canvasCost,1,0,v-1,d,0,0,v-1,d),f.drawImage(this.canvasCost,v+2,0,v-1,d,v+1,0,v-1,d);var g=Math.floor(i/2);1>g?g=1:g>20&&(g=20);var x=Math.floor(n/2);1>x?x=1:x>20&&(x=20),f.fillStyle=this.bgCanvasColor,f.fillRect(v-1,0,1,d),f.fillRect(2*v,0,1,d),f.fillRect(3*v+1,0,1,d),f.fillStyle=this.cost1Color,f.fillRect(v-1,20-g,1,g),f.fillStyle=this.cost3Color,f.fillRect(2*v,20-x,1,x);var y=Math.floor(a/o),m=r+" FPS "+this.renderMode;this.showPanle&&(m+="
      min"+s+" max"+l+" avg"+y,this.divDraw.innerHTML=this.lastNumDraw+"
      ",this.divCost.innerHTML=''+i+' '+n+""),this.fps.innerHTML=m},t.prototype.updateInfo=function(e){this.arrLog.push(e),this.updateLogLayout()},t.prototype.updateWarn=function(e){this.arrLog.push("[Warning]"+e),this.updateLogLayout()},t.prototype.updateError=function(e){this.arrLog.push("[Error]"+e),this.updateLogLayout()},t.prototype.updateLogLayout=function(){for(this.log.innerHTML=this.arrLog.join("
      ");document.body.clientHeight")},t}();t.WebFps=r,__reflect(r.prototype,"egret.web.WebFps",["egret.FPSDisplay"]),e.FPSDisplay=r}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r;!function(r){function i(e){return window.localStorage.getItem(e)}function n(t,r){try{return window.localStorage.setItem(t,r),!0}catch(i){return e.$warn(1047,t,r),!1}}function a(e){window.localStorage.removeItem(e)}function o(){window.localStorage.clear()}t.getItem=i,t.setItem=n,t.removeItem=a,t.clear=o}(r=t.web||(t.web={}))}(t=e.localStorage||(e.localStorage={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(e,t){var i=r.call(this)||this;return i.init(e,t),i.initOrientation(),i}return __extends(i,r),i.prototype.init=function(r,i){console.log("Egret Engine Version:",e.Capabilities.engineVersion);var n=this.readOption(r,i),a=new e.Stage;a.$screen=this,a.$scaleMode=n.scaleMode,a.$orientation=n.orientation,a.$maxTouches=n.maxTouches,a.frameRate=n.frameRate,a.textureScaleFactor=n.textureScaleFactor;var o=new e.sys.RenderBuffer(void 0,void 0,!0),s=o.surface;this.attachCanvas(r,s);var l=new t.WebTouchHandler(a,s),c=new e.sys.Player(o,a,n.entryClassName);e.lifecycle.stage=a,e.lifecycle.addLifecycleListener(t.WebLifeCycleHandler);var h=new t.HTMLInput;(n.showFPS||n.showLog)&&(e.nativeRender||c.displayFPS(n.showFPS,n.showLog,n.logFilter,n.fpsStyles)),this.playerOption=n,this.container=r,this.canvas=s,this.stage=a,this.player=c,this.webTouchHandler=l,this.webInput=h,e.web.$cacheTextAdapter(h,a,r,s),this.updateScreenSize(),this.updateMaxTouches(),c.start()},i.prototype.initOrientation=function(){var t=this;window.addEventListener("orientationchange",function(){window.setTimeout(function(){e.StageOrientationEvent.dispatchStageOrientationEvent(t.stage,e.StageOrientationEvent.ORIENTATION_CHANGE)},350)})},i.prototype.readOption=function(t,r){var i={};i.entryClassName=t.getAttribute("data-entry-class"),i.scaleMode=t.getAttribute("data-scale-mode")||e.StageScaleMode.NO_SCALE,i.frameRate=+t.getAttribute("data-frame-rate")||30,i.contentWidth=+t.getAttribute("data-content-width")||480,i.contentHeight=+t.getAttribute("data-content-height")||800,i.orientation=t.getAttribute("data-orientation")||e.OrientationMode.AUTO,i.maxTouches=+t.getAttribute("data-multi-fingered")||2,i.textureScaleFactor=+t.getAttribute("texture-scale-factor")||1,i.showFPS="true"==t.getAttribute("data-show-fps");for(var n=t.getAttribute("data-show-fps-style")||"",a=n.split(","),o={},s=0;sa||l==e.OrientationMode.PORTRAIT&&a>o);var c=s?o:a,h=s?a:o;e.Capabilities.boundingClientWidth=c,e.Capabilities.boundingClientHeight=h;var u=e.sys.screenAdapter.calculateStageSize(this.stage.$scaleMode,c,h,r.contentWidth,r.contentHeight),d=u.stageWidth,f=u.stageHeight,p=u.displayWidth,v=u.displayHeight;t.style[e.web.getPrefixStyleName("transformOrigin")]="0% 0% 0px",t.width!=d&&(t.width=d),t.height!=f&&(t.height=f);var g=0;s?l==e.OrientationMode.LANDSCAPE?(g=90,t.style.top=n+(o-p)/2+"px",t.style.left=(a+v)/2+"px"):(g=-90,t.style.top=n+(o+p)/2+"px",t.style.left=(a-v)/2+"px"):(t.style.top=n+(o-v)/2+"px",t.style.left=(a-p)/2+"px");var x=p/d,y=v/f,m=x*e.sys.DisplayList.$canvasScaleFactor,b=y*e.sys.DisplayList.$canvasScaleFactor;"canvas"==e.Capabilities.renderMode&&(m=Math.ceil(m),b=Math.ceil(b));var w=e.Matrix.create();w.identity(),w.scale(x/m,y/b),w.rotate(g*Math.PI/180);var T="matrix("+w.a+","+w.b+","+w.c+","+w.d+","+w.tx+","+w.ty+")";e.Matrix.release(w),t.style[e.web.getPrefixStyleName("transform")]=T,e.sys.DisplayList.$setCanvasScale(m,b),this.webTouchHandler.updateScaleMode(x,y,g),this.webInput.$updateSize(),this.player.updateStageSize(d,f),e.nativeRender&&(t.width=d*m,t.height=f*b)}}},i.prototype.setContentSize=function(e,t){var r=this.playerOption;r.contentWidth=e,r.contentHeight=t,this.updateScreenSize()},i.prototype.updateMaxTouches=function(){this.webTouchHandler.$updateMaxTouches()},i}(e.HashObject);t.WebPlayer=r,__reflect(r.prototype,"egret.web.WebPlayer",["egret.sys.Screen"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){function r(t,r){s||(s=e.sys.createCanvas(),l=s.getContext("2d"));var i=t.$getTextureWidth(),n=t.$getTextureHeight();null==r&&(r=e.$TempRectangle,r.x=0,r.y=0,r.width=i,r.height=n),r.x=Math.min(r.x,i-1),r.y=Math.min(r.y,n-1),r.width=Math.min(r.width,i-r.x),r.height=Math.min(r.height,n-r.y);var a=r.width,o=r.height,c=s;if(c.style.width=a+"px",c.style.height=o+"px",s.width=a,s.height=o,"webgl"==e.Capabilities.renderMode){var h=void 0;t.$renderBuffer?h=t:(h=new e.RenderTexture,h.drawToTexture(new e.Bitmap(t)));for(var u=h.$renderBuffer.getPixels(r.x,r.y,a,o),d=new ImageData(a,o),f=0;fn;n++){var a=t.childNodes[n];if(1==a.nodeType)return i(a,null)}return null}function i(e,t){if("parsererror"==e.localName)throw new Error(e.textContent);for(var r=new a(e.localName,t,e.prefix,e.namespaceURI,e.nodeName),n=e.attributes,s=r.attributes,l=n.length,c=0;l>c;c++){var h=n[c],u=h.name;0!=u.indexOf("xmlns:")&&(s[u]=h.value,r["$"+u]=h.value)}var d=e.childNodes;l=d.length;for(var f=r.children,c=0;l>c;c++){var p=d[c],v=p.nodeType,g=null;if(1==v)g=i(p,r);else if(3==v){var x=p.textContent.trim();x&&(g=new o(x,r))}g&&f.push(g)}return r}var n=function(){function e(e,t){this.nodeType=e,this.parent=t}return e}();t.XMLNode=n,__reflect(n.prototype,"egret.web.XMLNode");var a=function(e){function t(t,r,i,n,a){var o=e.call(this,1,r)||this;return o.attributes={},o.children=[],o.localName=t,o.prefix=i,o.namespace=n,o.name=a,o}return __extends(t,e),t}(n);t.XML=a,__reflect(a.prototype,"egret.web.XML");var o=function(e){function t(t,r){var i=e.call(this,3,r)||this;return i.text=t,i}return __extends(t,e),t}(n);t.XMLText=o,__reflect(o.prototype,"egret.web.XMLText");var s=new DOMParser;e.XML={parse:r}}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(t){function r(){var r=null!==t&&t.apply(this,arguments)||this;return r.onChange=function(t){var i=new e.OrientationEvent(e.Event.CHANGE);i.beta=t.beta,i.gamma=t.gamma,i.alpha=t.alpha,r.dispatchEvent(i)},r}return __extends(r,t),r.prototype.start=function(){window.addEventListener("deviceorientation",this.onChange)},r.prototype.stop=function(){window.removeEventListener("deviceorientation",this.onChange)},r}(e.EventDispatcher);t.WebDeviceOrientation=r,__reflect(r.prototype,"egret.web.WebDeviceOrientation",["egret.DeviceOrientation"])}(t=e.web||(e.web={}))}(egret||(egret={})),egret.DeviceOrientation=egret.web.WebDeviceOrientation;var egret;!function(e){var t;!function(t){var r=function(){function e(){}return e.call=function(e,t){},e.addCallback=function(e,t){},e}();t.WebExternalInterface=r,__reflect(r.prototype,"egret.web.WebExternalInterface",["egret.ExternalInterface"]);var i=navigator.userAgent.toLowerCase();i.indexOf("egretnative")<0&&(e.ExternalInterface=r)}(t=e.web||(e.web={}))}(egret||(egret={})),function(e){var t;!function(t){function r(t){var r=JSON.parse(t),n=r.functionName,a=i[n];if(a){var o=r.value;a.call(null,o)}else e.$warn(1050,n)}var i={},n=function(){function e(){}return e.call=function(e,t){var r={};r.functionName=e,r.value=t,egret_native.sendInfoToPlugin(JSON.stringify(r))},e.addCallback=function(e,t){i[e]=t},e}();t.NativeExternalInterface=n,__reflect(n.prototype,"egret.web.NativeExternalInterface",["egret.ExternalInterface"]);var a=navigator.userAgent.toLowerCase();a.indexOf("egretnative")>=0&&(e.ExternalInterface=n,egret_native.receivedPluginInfo=r)}(t=e.web||(e.web={}))}(egret||(egret={})),function(e){var t;!function(t){var r={},i=function(){function t(){}return t.call=function(e,t){__global.ExternalInterface.call(e,t)},t.addCallback=function(e,t){r[e]=t},t.invokeCallback=function(t,i){var n=r[t];n?n.call(null,i):e.$warn(1050,t)},t}();t.WebViewExternalInterface=i,__reflect(i.prototype,"egret.web.WebViewExternalInterface",["egret.ExternalInterface"]);var n=navigator.userAgent.toLowerCase();n.indexOf("egretwebview")>=0&&(e.ExternalInterface=i)}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(){var e=r.call(this)||this;return e.loaded=!1,e}return __extends(i,r),Object.defineProperty(i.prototype,"length",{get:function(){if(this.originAudio)return this.originAudio.duration;throw new Error("sound not loaded!")},enumerable:!0,configurable:!0}),i.prototype.load=function(t){function r(){i.$recycle(o.url,s),a(),l.indexOf("firefox")>=0&&(s.pause(),s.muted=!1),c&&document.body.appendChild(s),o.loaded=!0,o.dispatchEventWith(e.Event.COMPLETE)}function n(){a(),o.dispatchEventWith(e.IOErrorEvent.IO_ERROR)}function a(){s.removeEventListener("canplaythrough",r),s.removeEventListener("error",n),c&&document.body.removeChild(s)}var o=this;this.url=t;var s=new Audio(t);s.addEventListener("canplaythrough",r),s.addEventListener("error",n);var l=navigator.userAgent.toLowerCase();l.indexOf("firefox")>=0&&(s.autoplay=!0,s.muted=!0);var c=l.indexOf("edge")>=0||l.indexOf("trident")>=0;c&&document.body.appendChild(s),s.load(),this.originAudio=s,i.clearAudios[this.url]&&delete i.clearAudios[this.url]},i.prototype.play=function(r,n){r=+r||0,n=+n||0;var a=i.$pop(this.url);null==a&&(a=this.originAudio.cloneNode()),a.autoplay=!0;var o=new t.HtmlSoundChannel(a);return o.$url=this.url,o.$loops=n,o.$startTime=r,o.$play(),e.sys.$pushSoundChannel(o),o},i.prototype.close=function(){this.loaded&&this.originAudio&&(this.originAudio.src=""),this.originAudio&&(this.originAudio=null),i.$clear(this.url),this.loaded=!1},i.$clear=function(e){i.clearAudios[e]=!0;var t=i.audios[e];t&&(t.length=0)},i.$pop=function(e){var t=i.audios[e];return t&&t.length>0?t.pop():null},i.$recycle=function(e,t){if(!i.clearAudios[e]){var r=i.audios[e];null==i.audios[e]&&(r=i.audios[e]=[]),r.push(t)}},i.MUSIC="music",i.EFFECT="effect",i.audios={},i.clearAudios={},i}(e.EventDispatcher);t.HtmlSound=r,__reflect(r.prototype,"egret.web.HtmlSound",["egret.Sound"])}(t=e.web||(e.web={}))}(egret||(egret={})); -var egret;!function(e){var t;!function(e){}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){var t=function(){function e(){this.drawData=[],this.drawDataLen=0}return e.prototype.pushDrawRect=function(){if(0==this.drawDataLen||1!=this.drawData[this.drawDataLen-1].type){var e=this.drawData[this.drawDataLen]||{};e.type=1,e.count=0,this.drawData[this.drawDataLen]=e,this.drawDataLen++}this.drawData[this.drawDataLen-1].count+=2},e.prototype.pushDrawTexture=function(e,t,r,i,n){if(void 0===t&&(t=2),r){var a=this.drawData[this.drawDataLen]||{};a.type=0,a.texture=e,a.filter=r,a.count=t,a.textureWidth=i,a.textureHeight=n,this.drawData[this.drawDataLen]=a,this.drawDataLen++}else{if(0==this.drawDataLen||0!=this.drawData[this.drawDataLen-1].type||e!=this.drawData[this.drawDataLen-1].texture||this.drawData[this.drawDataLen-1].filter){var a=this.drawData[this.drawDataLen]||{};a.type=0,a.texture=e,a.count=0,this.drawData[this.drawDataLen]=a,this.drawDataLen++}this.drawData[this.drawDataLen-1].count+=t}},e.prototype.pushChangeSmoothing=function(e,t){e.smoothing=t;var r=this.drawData[this.drawDataLen]||{};r.type=10,r.texture=e,r.smoothing=t,this.drawData[this.drawDataLen]=r,this.drawDataLen++},e.prototype.pushPushMask=function(e){void 0===e&&(e=1);var t=this.drawData[this.drawDataLen]||{};t.type=2,t.count=2*e,this.drawData[this.drawDataLen]=t,this.drawDataLen++},e.prototype.pushPopMask=function(e){void 0===e&&(e=1);var t=this.drawData[this.drawDataLen]||{};t.type=3,t.count=2*e,this.drawData[this.drawDataLen]=t,this.drawDataLen++},e.prototype.pushSetBlend=function(e){for(var t=this.drawDataLen,r=!1,i=t-1;i>=0;i--){var n=this.drawData[i];if(n){if((0==n.type||1==n.type)&&(r=!0),!r&&4==n.type){this.drawData.splice(i,1),this.drawDataLen--;continue}if(4==n.type){if(n.value==e)return;break}}}var a=this.drawData[this.drawDataLen]||{};a.type=4,a.value=e,this.drawData[this.drawDataLen]=a,this.drawDataLen++},e.prototype.pushResize=function(e,t,r){var i=this.drawData[this.drawDataLen]||{};i.type=5,i.buffer=e,i.width=t,i.height=r,this.drawData[this.drawDataLen]=i,this.drawDataLen++},e.prototype.pushClearColor=function(){var e=this.drawData[this.drawDataLen]||{};e.type=6,this.drawData[this.drawDataLen]=e,this.drawDataLen++},e.prototype.pushActivateBuffer=function(e){for(var t=this.drawDataLen,r=!1,i=t-1;i>=0;i--){var n=this.drawData[i];!n||(4!=n.type&&7!=n.type&&(r=!0),r||7!=n.type)||(this.drawData.splice(i,1),this.drawDataLen--)}var a=this.drawData[this.drawDataLen]||{};a.type=7,a.buffer=e,a.width=e.rootRenderTarget.width,a.height=e.rootRenderTarget.height,this.drawData[this.drawDataLen]=a,this.drawDataLen++},e.prototype.pushEnableScissor=function(e,t,r,i){var n=this.drawData[this.drawDataLen]||{};n.type=8,n.x=e,n.y=t,n.width=r,n.height=i,this.drawData[this.drawDataLen]=n,this.drawDataLen++},e.prototype.pushDisableScissor=function(){var e=this.drawData[this.drawDataLen]||{};e.type=9,this.drawData[this.drawDataLen]=e,this.drawDataLen++},e.prototype.clear=function(){for(var e=0;er;r+=6,i+=4)this.indices[r+0]=i+0,this.indices[r+1]=i+1,this.indices[r+2]=i+2,this.indices[r+3]=i+0,this.indices[r+4]=i+2,this.indices[r+5]=i+3}return t.prototype.reachMaxSize=function(e,t){return void 0===e&&(e=4),void 0===t&&(t=6),this.vertexIndex>this.maxVertexCount-e||this.indexIndex>this.maxIndicesCount-t},t.prototype.getVertices=function(){var e=this.vertices.subarray(0,this.vertexIndex*this.vertSize);return e},t.prototype.getIndices=function(){return this.indices},t.prototype.getMeshIndices=function(){return this.indicesForMesh},t.prototype.changeToMeshIndices=function(){if(!this.hasMesh){for(var e=0,t=this.indexIndex;t>e;++e)this.indicesForMesh[e]=this.indices[e];this.hasMesh=!0}},t.prototype.isMesh=function(){return this.hasMesh},t.prototype.cacheArrays=function(t,r,i,n,a,o,s,l,c,h,u,d,f,p,v){var g=t.globalAlpha;g=Math.min(g,1);var x=t.globalTintColor||16777215,y=t.currentTexture;g=1>g&&y&&y[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL]?e.WebGLUtils.premultiplyTint(x,g):x+(255*g<<24);var m=t.globalMatrix,b=m.a,w=m.b,T=m.c,E=m.d,_=m.tx,C=m.ty,S=t.$offsetX,R=t.$offsetY;if((0!=S||0!=R)&&(_=S*b+R*T+_,C=S*w+R*E+C),!f){(0!=o||0!=s)&&(_=o*b+s*T+_,C=o*w+s*E+C);var L=l/n;1!=L&&(b=L*b,w=L*w);var D=c/a;1!=D&&(T=D*T,E=D*E)}if(f){var A=this.vertices,I=this._verticesUint32View,$=this.vertexIndex*this.vertSize,M=0,B=0,O=0,P=0,W=0,k=0,G=0;for(M=0,O=d.length;O>M;M+=2)B=$+5*M/2,k=f[M],G=f[M+1],P=d[M],W=d[M+1],A[B+0]=b*k+T*G+_,A[B+1]=w*k+E*G+C,v?(A[B+2]=(r+(1-W)*a)/h,A[B+3]=(i+P*n)/u):(A[B+2]=(r+P*n)/h,A[B+3]=(i+W*a)/u),I[B+4]=g;if(this.hasMesh)for(var H=0,F=p.length;F>H;++H)this.indicesForMesh[this.indexIndex+H]=p[H]+this.vertexIndex;this.vertexIndex+=d.length/2,this.indexIndex+=p.length}else{var U=h,N=u,X=n,z=a;r/=U,i/=N;var A=this.vertices,I=this._verticesUint32View,$=this.vertexIndex*this.vertSize;if(v){var Y=n;n=a/U,a=Y/N,A[$++]=_,A[$++]=C,A[$++]=n+r,A[$++]=i,I[$++]=g,A[$++]=b*X+_,A[$++]=w*X+C,A[$++]=n+r,A[$++]=a+i,I[$++]=g,A[$++]=b*X+T*z+_,A[$++]=E*z+w*X+C,A[$++]=r,A[$++]=a+i,I[$++]=g,A[$++]=T*z+_,A[$++]=E*z+C,A[$++]=r,A[$++]=i,I[$++]=g}else n/=U,a/=N,A[$++]=_,A[$++]=C,A[$++]=r,A[$++]=i,I[$++]=g,A[$++]=b*X+_,A[$++]=w*X+C,A[$++]=n+r,A[$++]=i,I[$++]=g,A[$++]=b*X+T*z+_,A[$++]=E*z+w*X+C,A[$++]=n+r,A[$++]=a+i,I[$++]=g,A[$++]=T*z+_,A[$++]=E*z+C,A[$++]=r,A[$++]=a+i,I[$++]=g;if(this.hasMesh){var V=this.indicesForMesh;V[this.indexIndex+0]=0+this.vertexIndex,V[this.indexIndex+1]=1+this.vertexIndex,V[this.indexIndex+2]=2+this.vertexIndex,V[this.indexIndex+3]=0+this.vertexIndex,V[this.indexIndex+4]=2+this.vertexIndex,V[this.indexIndex+5]=3+this.vertexIndex}this.vertexIndex+=4,this.indexIndex+=6}},t.prototype.clear=function(){this.hasMesh=!1,this.vertexIndex=0,this.indexIndex=0},t}();t.WebGLVertexArrayObject=r,__reflect(r.prototype,"egret.web.WebGLVertexArrayObject")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function i(e,t,i){var n=r.call(this)||this;return n.clearColor=[0,0,0,0],n.useFrameBuffer=!0,n.gl=e,n._resize(t,i),n}return __extends(i,r),i.prototype._resize=function(e,t){e=e||1,t=t||1,1>e&&(e=1),1>t&&(t=1),this.width=e,this.height=t},i.prototype.resize=function(e,t){this._resize(e,t);var r=this.gl;this.frameBuffer&&(r.bindTexture(r.TEXTURE_2D,this.texture),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,this.width,this.height,0,r.RGBA,r.UNSIGNED_BYTE,null)),this.stencilBuffer&&(r.deleteRenderbuffer(this.stencilBuffer),this.stencilBuffer=null)},i.prototype.activate=function(){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer())},i.prototype.getFrameBuffer=function(){return this.useFrameBuffer?this.frameBuffer:null},i.prototype.initFrameBuffer=function(){if(!this.frameBuffer){var e=this.gl;this.texture=this.createTexture(),this.frameBuffer=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this.frameBuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.texture,0)}},i.prototype.createTexture=function(){var r=t.WebGLRenderContext.getInstance(0,0);return e.sys._createTexture(r,this.width,this.height,null)},i.prototype.clear=function(e){var t=this.gl;e&&this.activate(),t.colorMask(!0,!0,!0,!0),t.clearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),t.clear(t.COLOR_BUFFER_BIT)},i.prototype.enabledStencil=function(){if(this.frameBuffer&&!this.stencilBuffer){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,this.frameBuffer),this.stencilBuffer=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,this.stencilBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,this.width,this.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,this.stencilBuffer)}},i.prototype.dispose=function(){e.WebGLUtils.deleteWebGLTexture(this.texture)},i}(e.HashObject);t.WebGLRenderTarget=r,__reflect(r.prototype,"egret.web.WebGLRenderTarget")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r={},i=function(){function i(r,i){if(this._defaultEmptyTexture=null,this.glID=null,this.projectionX=0/0,this.projectionY=0/0,this.contextLost=!1,this._supportedCompressedTextureInfo=[],this.$scissorState=!1,this.vertSize=5,this.surface=e.sys.mainCanvas(r,i),!e.nativeRender){this.initWebGL(),this.$bufferStack=[];var n=this.context;this.vertexBuffer=n.createBuffer(),this.indexBuffer=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,this.vertexBuffer),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,this.indexBuffer),this.drawCmdManager=new t.WebGLDrawCmdManager,this.vao=new t.WebGLVertexArrayObject,this.setGlobalCompositeOperation("source-over")}}return i.getInstance=function(e,t){return this.instance?this.instance:(this.instance=new i(e,t),this.instance)},i.prototype.pushBuffer=function(e){this.$bufferStack.push(e),e!=this.currentBuffer&&(this.currentBuffer,this.drawCmdManager.pushActivateBuffer(e)),this.currentBuffer=e},i.prototype.popBuffer=function(){if(!(this.$bufferStack.length<=1)){var e=this.$bufferStack.pop(),t=this.$bufferStack[this.$bufferStack.length-1];e!=t&&this.drawCmdManager.pushActivateBuffer(t),this.currentBuffer=t}},i.prototype.activateBuffer=function(e,t,r){e.rootRenderTarget.activate(),this.bindIndices||this.uploadIndicesArray(this.vao.getIndices()),e.restoreStencil(),e.restoreScissor(),this.onResize(t,r)},i.prototype.uploadVerticesArray=function(e){var t=this.context;t.bufferData(t.ARRAY_BUFFER,e,t.STREAM_DRAW)},i.prototype.uploadIndicesArray=function(e){var t=this.context;t.bufferData(t.ELEMENT_ARRAY_BUFFER,e,t.STATIC_DRAW),this.bindIndices=!0},i.prototype.destroy=function(){this.surface.width=this.surface.height=0},i.prototype.onResize=function(e,t){e=e||this.surface.width,t=t||this.surface.height,this.projectionX=e/2,this.projectionY=-t/2,this.context&&this.context.viewport(0,0,e,t)},i.prototype.resize=function(t,r,i){e.sys.resizeContext(this,t,r,i)},i.prototype._buildSupportedCompressedTextureInfo=function(e){for(var t=[],r=0,i=e;rr;++r)for(var n=e[r],a=n.supportedFormats,o=0,s=a.length;s>o;++o)if(a[o][1]===t)return!0;return!1},i.prototype.$debugLogCompressedTextureNotSupported=function(t,i){if(!r[i]){r[i]=!0,e.log("internalFormat = "+i+":0x"+i.toString(16)+", the current hardware does not support the corresponding compression format.");for(var n=0,a=t.length;a>n;++n){var o=t[n];if(o.supportedFormats.length>0){e.log("support = "+o.extensionName);for(var s=0,l=o.supportedFormats.length;l>s;++s){var c=o.supportedFormats[s];e.log(c[0]+" : "+c[1]+" : 0x"+c[1].toString(16))}}}}},i.prototype.createCompressedTexture=function(t,r,i,n,a){var o=this.checkCompressedTextureInternalFormat(this._supportedCompressedTextureInfo,a);if(!o)return this.$debugLogCompressedTextureNotSupported(this._supportedCompressedTextureInfo,a),this.defaultEmptyTexture;var s=this.context,l=s.createTexture();return l?(l[e.glContext]=s,l[e.is_compressed_texture]=!0,s.bindTexture(s.TEXTURE_2D,l),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),l[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL]=!0,s.compressedTexImage2D(s.TEXTURE_2D,n,a,r,i,0,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.bindTexture(s.TEXTURE_2D,null),l):void(this.contextLost=!0)},i.prototype.updateTexture=function(e,t){var r=this.context;r.bindTexture(r.TEXTURE_2D,e),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t)},Object.defineProperty(i.prototype,"defaultEmptyTexture",{get:function(){if(!this._defaultEmptyTexture){var t=16,r=e.sys.createCanvas(t,t),i=e.sys.getContext2d(r);i.fillStyle="white",i.fillRect(0,0,t,t),this._defaultEmptyTexture=this.createTexture(r),this._defaultEmptyTexture[e.engine_default_empty_texture]=!0}return this._defaultEmptyTexture},enumerable:!0,configurable:!0}),i.prototype.getWebGLTexture=function(t){if(!t.webGLTexture){if("image"!=t.format||t.hasCompressed2d()){if(t.hasCompressed2d()){var r=t.getCompressed2dTextureData();t.webGLTexture=this.createCompressedTexture(r.byteArray,r.width,r.height,r.level,r.glInternalFormat);var i=t.etcAlphaMask;if(i){var n=this.getWebGLTexture(i);n&&(t.webGLTexture[e.etc_alpha_mask]=n)}}}else t.webGLTexture=this.createTexture(t.source);t.$deleteSource&&t.webGLTexture&&(t.source&&(t.source.src="",t.source=null),t.clearCompressedTextureData()),t.webGLTexture&&(t.webGLTexture.smoothing=!0)}return t.webGLTexture},i.prototype.clearRect=function(e,t,r,i){if(0!=e||0!=t||r!=this.surface.width||i!=this.surface.height){var n=this.currentBuffer;if(n.$hasScissor)this.setGlobalCompositeOperation("destination-out"),this.drawRect(e,t,r,i),this.setGlobalCompositeOperation("source-over");else{var a=n.globalMatrix;0==a.b&&0==a.c?(e=e*a.a+a.tx,t=t*a.d+a.ty,r*=a.a,i*=a.d,this.enableScissor(e,-t-i+n.height,r,i),this.clear(),this.disableScissor()):(this.setGlobalCompositeOperation("destination-out"),this.drawRect(e,t,r,i),this.setGlobalCompositeOperation("source-over"))}}else this.clear()},i.prototype.setGlobalCompositeOperation=function(e){this.drawCmdManager.pushSetBlend(e)},i.prototype.drawImage=function(e,t,r,i,n,a,o,s,l,c,h,u,d){var f=this.currentBuffer;if(!this.contextLost&&e&&f){var p,v,g;if(e.texture||e.source&&e.source.texture)p=e.texture||e.source.texture,f.saveTransform(),v=f.$offsetX,g=f.$offsetY,f.useOffset(),f.transform(1,0,0,-1,0,l+2*o);else{if(!e.source&&!e.webGLTexture)return;p=this.getWebGLTexture(e)}p&&(this.drawTexture(p,t,r,i,n,a,o,s,l,c,h,void 0,void 0,void 0,void 0,u,d),e.source&&e.source.texture&&(f.$offsetX=v,f.$offsetY=g,f.restoreTransform()))}},i.prototype.drawMesh=function(e,t,r,i,n,a,o,s,l,c,h,u,d,f,p,v,g){var x=this.currentBuffer;if(!this.contextLost&&e&&x){var y,m,b;if(e.texture||e.source&&e.source.texture)y=e.texture||e.source.texture,x.saveTransform(),m=x.$offsetX,b=x.$offsetY,x.useOffset(),x.transform(1,0,0,-1,0,l+2*o);else{if(!e.source&&!e.webGLTexture)return;y=this.getWebGLTexture(e)}y&&(this.drawTexture(y,t,r,i,n,a,o,s,l,c,h,u,d,f,p,v,g),(e.texture||e.source&&e.source.texture)&&(x.$offsetX=m,x.$offsetY=b,x.restoreTransform()))}},i.prototype.drawTexture=function(e,t,r,i,n,a,o,s,l,c,h,u,d,f,p,v,g){var x=this.currentBuffer;if(!this.contextLost&&e&&x){d&&f?this.vao.reachMaxSize(d.length/2,f.length)&&this.$drawWebGL():this.vao.reachMaxSize()&&this.$drawWebGL(),void 0!=g&&e.smoothing!=g&&this.drawCmdManager.pushChangeSmoothing(e,g),u&&this.vao.changeToMeshIndices();var y=f?f.length/3:2;this.drawCmdManager.pushDrawTexture(e,y,this.$filter,c,h),x.currentTexture=e,this.vao.cacheArrays(x,t,r,i,n,a,o,s,l,c,h,u,d,f,v)}},i.prototype.drawRect=function(e,t,r,i){var n=this.currentBuffer;!this.contextLost&&n&&(this.vao.reachMaxSize()&&this.$drawWebGL(),this.drawCmdManager.pushDrawRect(),n.currentTexture=null,this.vao.cacheArrays(n,0,0,r,i,e,t,r,i,r,i))},i.prototype.pushMask=function(e,t,r,i){var n=this.currentBuffer;!this.contextLost&&n&&(n.$stencilList.push({x:e,y:t,width:r,height:i}),this.vao.reachMaxSize()&&this.$drawWebGL(),this.drawCmdManager.pushPushMask(),n.currentTexture=null,this.vao.cacheArrays(n,0,0,r,i,e,t,r,i,r,i))},i.prototype.popMask=function(){var e=this.currentBuffer;if(!this.contextLost&&e){var t=e.$stencilList.pop();this.vao.reachMaxSize()&&this.$drawWebGL(),this.drawCmdManager.pushPopMask(),e.currentTexture=null,this.vao.cacheArrays(e,0,0,t.width,t.height,t.x,t.y,t.width,t.height,t.width,t.height)}},i.prototype.clear=function(){this.drawCmdManager.pushClearColor()},i.prototype.enableScissor=function(e,t,r,i){var n=this.currentBuffer;this.drawCmdManager.pushEnableScissor(e,t,r,i),n.$hasScissor=!0},i.prototype.disableScissor=function(){var e=this.currentBuffer;this.drawCmdManager.pushDisableScissor(),e.$hasScissor=!1},i.prototype.$drawWebGL=function(){if(0!=this.drawCmdManager.drawDataLen&&!this.contextLost){this.uploadVerticesArray(this.vao.getVertices()),this.vao.isMesh()&&this.uploadIndicesArray(this.vao.getMeshIndices());for(var e=this.drawCmdManager.drawDataLen,t=0,r=0;e>r;r++){var i=this.drawCmdManager.drawData[r];t=this.drawData(i,t),7==i.type&&(this.activatedBuffer=i.buffer),(0==i.type||1==i.type||2==i.type||3==i.type)&&this.activatedBuffer&&this.activatedBuffer.$computeDrawCall&&this.activatedBuffer.$drawCalls++}this.vao.isMesh()&&this.uploadIndicesArray(this.vao.getIndices()),this.drawCmdManager.clear(),this.vao.clear()}},i.prototype.drawData=function(r,i){if(r){var n,a=this.context,o=r.filter;switch(r.type){case 0:o?"custom"===o.type?n=t.EgretWebGLProgram.getProgram(a,o.$vertexSrc,o.$fragmentSrc,o.$shaderKey):"colorTransform"===o.type?r.texture[e.etc_alpha_mask]?(a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,r.texture[e.etc_alpha_mask]),n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.colorTransform_frag_etc_alphamask_frag,"colorTransform_frag_etc_alphamask_frag")):n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.colorTransform_frag,"colorTransform"):"blurX"===o.type?n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.blur_frag,"blur"):"blurY"===o.type?n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.blur_frag,"blur"):"glow"===o.type&&(n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.glow_frag,"glow")):r.texture[e.etc_alpha_mask]?(n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.texture_etc_alphamask_frag,e.etc_alpha_mask),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,r.texture[e.etc_alpha_mask])):n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.texture_frag,"texture"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawTextureElements(r,i);break;case 1:n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawRectElements(r,i);break;case 2:n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawPushMaskElements(r,i);break;case 3:n=t.EgretWebGLProgram.getProgram(a,t.EgretShaderLib.default_vert,t.EgretShaderLib.primitive_frag,"primitive"),this.activeProgram(a,n),this.syncUniforms(n,o,r.textureWidth,r.textureHeight),i+=this.drawPopMaskElements(r,i);break;case 4:this.setBlendMode(r.value);break;case 5:r.buffer.rootRenderTarget.resize(r.width,r.height),this.onResize(r.width,r.height);break;case 6:if(this.activatedBuffer){var s=this.activatedBuffer.rootRenderTarget;(0!=s.width||0!=s.height)&&s.clear(!0)}break;case 7:this.activateBuffer(r.buffer,r.width,r.height);break;case 8:var l=this.activatedBuffer;l&&(l.rootRenderTarget&&l.rootRenderTarget.enabledStencil(),l.enableScissor(r.x,r.y,r.width,r.height));break;case 9:l=this.activatedBuffer,l&&l.disableScissor();break;case 10:a.bindTexture(a.TEXTURE_2D,r.texture),r.smoothing?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR)):(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST))}return i}},i.prototype.activeProgram=function(e,t){if(t!=this.currentProgram){e.useProgram(t.id);var r=t.attributes;for(var i in r)"aVertexPosition"===i?(e.vertexAttribPointer(r.aVertexPosition.location,2,e.FLOAT,!1,20,0),e.enableVertexAttribArray(r.aVertexPosition.location)):"aTextureCoord"===i?(e.vertexAttribPointer(r.aTextureCoord.location,2,e.FLOAT,!1,20,8),e.enableVertexAttribArray(r.aTextureCoord.location)):"aColor"===i&&(e.vertexAttribPointer(r.aColor.location,4,e.UNSIGNED_BYTE,!0,20,16),e.enableVertexAttribArray(r.aColor.location));this.currentProgram=t}},i.prototype.syncUniforms=function(e,t,r,i){var n=e.uniforms;t&&"custom"===t.type;for(var a in n)if("projectionVector"===a)n[a].setValue({x:this.projectionX,y:this.projectionY});else if("uTextureSize"===a)n[a].setValue({x:r,y:i});else if("uSampler"===a)n[a].setValue(0);else if("uSamplerAlphaMask"===a)n[a].setValue(1);else{var o=t.$uniforms[a];void 0!==o&&n[a].setValue(o)}},i.prototype.drawTextureElements=function(t,r){return e.sys.drawTextureElements(this,t,r)},i.prototype.drawRectElements=function(e,t){var r=this.context,i=3*e.count;return r.drawElements(r.TRIANGLES,i,r.UNSIGNED_SHORT,2*t),i},i.prototype.drawPushMaskElements=function(e,t){var r=this.context,i=3*e.count,n=this.activatedBuffer;if(n){n.rootRenderTarget&&n.rootRenderTarget.enabledStencil(),0==n.stencilHandleCount&&(n.enableStencil(),r.clear(r.STENCIL_BUFFER_BIT));var a=n.stencilHandleCount;n.stencilHandleCount++,r.colorMask(!1,!1,!1,!1),r.stencilFunc(r.EQUAL,a,255),r.stencilOp(r.KEEP,r.KEEP,r.INCR),r.drawElements(r.TRIANGLES,i,r.UNSIGNED_SHORT,2*t),r.stencilFunc(r.EQUAL,a+1,255),r.colorMask(!0,!0,!0,!0),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)}return i},i.prototype.drawPopMaskElements=function(e,t){var r=this.context,i=3*e.count,n=this.activatedBuffer;if(n)if(n.stencilHandleCount--,0==n.stencilHandleCount)n.disableStencil();else{var a=n.stencilHandleCount;r.colorMask(!1,!1,!1,!1),r.stencilFunc(r.EQUAL,a+1,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR),r.drawElements(r.TRIANGLES,i,r.UNSIGNED_SHORT,2*t),r.stencilFunc(r.EQUAL,a,255),r.colorMask(!0,!0,!0,!0),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)}return i},i.prototype.setBlendMode=function(e){var t=this.context,r=i.blendModesForGL[e];r&&t.blendFunc(r[0],r[1])},i.prototype.drawTargetWidthFilters=function(e,r){var i,n=r,a=e.length;if(a>1)for(var o=0;a-1>o;o++){var s=e[o],l=r.rootRenderTarget.width,c=r.rootRenderTarget.height;i=t.WebGLRenderBuffer.create(l,c),i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,this.drawToRenderTarget(s,r,i),r!=n&&t.WebGLRenderBuffer.release(r),r=i}var h=e[a-1];this.drawToRenderTarget(h,r,this.currentBuffer),r!=n&&t.WebGLRenderBuffer.release(r)},i.prototype.drawToRenderTarget=function(e,r,i){if(!this.contextLost){this.vao.reachMaxSize()&&this.$drawWebGL(),this.pushBuffer(i);var n,a=r,o=r.rootRenderTarget.width,s=r.rootRenderTarget.height;if("blur"==e.type){var l=e.blurXFilter,c=e.blurYFilter;0!=l.blurX&&0!=c.blurY?(n=t.WebGLRenderBuffer.create(o,s),n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,this.drawToRenderTarget(e.blurXFilter,r,n),r!=a&&t.WebGLRenderBuffer.release(r),r=n,e=c):e=0===l.blurX?c:l}i.saveTransform(),i.transform(1,0,0,-1,0,s),i.currentTexture=r.rootRenderTarget.texture,this.vao.cacheArrays(i,0,0,o,s,0,0,o,s,o,s),i.restoreTransform(),this.drawCmdManager.pushDrawTexture(r.rootRenderTarget.texture,2,e,o,s),r!=a&&t.WebGLRenderBuffer.release(r),this.popBuffer()}},i.initBlendMode=function(){i.blendModesForGL={},i.blendModesForGL["source-over"]=[1,771],i.blendModesForGL.lighter=[1,1],i.blendModesForGL["lighter-in"]=[770,771],i.blendModesForGL["destination-out"]=[0,771],i.blendModesForGL["destination-in"]=[0,770]},i.glContextId=0,i.blendModesForGL=null,i}();t.WebGLRenderContext=i,__reflect(i.prototype,"egret.web.WebGLRenderContext",["egret.sys.RenderContext"]),i.initBlendMode()}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(r){function n(i,n,a){var o=r.call(this)||this;if(o.currentTexture=null,o.globalAlpha=1,o.globalTintColor=16777215,o.stencilState=!1,o.$stencilList=[],o.stencilHandleCount=0,o.$scissorState=!1,o.scissorRect=new e.Rectangle,o.$hasScissor=!1,o.$drawCalls=0,o.$computeDrawCall=!1,o.globalMatrix=new e.Matrix,o.savedGlobalMatrix=new e.Matrix,o.$offsetX=0,o.$offsetY=0,o.context=t.WebGLRenderContext.getInstance(i,n),e.nativeRender)return a?o.surface=o.context.surface:o.surface=new egret_native.NativeRenderSurface(o,i,n,a),o.rootRenderTarget=null,o;if(o.rootRenderTarget=new t.WebGLRenderTarget(o.context.context,3,3),i&&n&&o.resize(i,n),o.root=a,o.root)o.context.pushBuffer(o),o.surface=o.context.surface,o.$computeDrawCall=!0;else{var s=o.context.activatedBuffer;s&&s.rootRenderTarget.activate(),o.rootRenderTarget.initFrameBuffer(),o.surface=o.rootRenderTarget}return o}return __extends(n,r),n.prototype.enableStencil=function(){this.stencilState||(this.context.enableStencilTest(),this.stencilState=!0)},n.prototype.disableStencil=function(){this.stencilState&&(this.context.disableStencilTest(),this.stencilState=!1)},n.prototype.restoreStencil=function(){this.stencilState?this.context.enableStencilTest():this.context.disableStencilTest()},n.prototype.enableScissor=function(e,t,r,i){this.$scissorState||(this.$scissorState=!0,this.scissorRect.setTo(e,t,r,i),this.context.enableScissorTest(this.scissorRect))},n.prototype.disableScissor=function(){this.$scissorState&&(this.$scissorState=!1,this.scissorRect.setEmpty(),this.context.disableScissorTest())},n.prototype.restoreScissor=function(){this.$scissorState?this.context.enableScissorTest(this.scissorRect):this.context.disableScissorTest()},Object.defineProperty(n.prototype,"width",{get:function(){return e.nativeRender?this.surface.width:this.rootRenderTarget.width},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return e.nativeRender?this.surface.height:this.rootRenderTarget.height},enumerable:!0,configurable:!0}),n.prototype.resize=function(t,r,i){return t=t||1,r=r||1,e.nativeRender?void this.surface.resize(t,r):(this.context.pushBuffer(this),(t!=this.rootRenderTarget.width||r!=this.rootRenderTarget.height)&&(this.context.drawCmdManager.pushResize(this,t,r),this.rootRenderTarget.width=t,this.rootRenderTarget.height=r),this.root&&this.context.resize(t,r,i),this.context.clear(),void this.context.popBuffer())},n.prototype.getPixels=function(t,r,i,n){void 0===i&&(i=1),void 0===n&&(n=1);var a=new Uint8Array(4*i*n);if(e.nativeRender)egret_native.activateBuffer(this),egret_native.nrGetPixels(t,r,i,n,a),egret_native.activateBuffer(null);else{var o=this.rootRenderTarget.useFrameBuffer;this.rootRenderTarget.useFrameBuffer=!0,this.rootRenderTarget.activate(),this.context.getPixels(t,r,i,n,a),this.rootRenderTarget.useFrameBuffer=o,this.rootRenderTarget.activate()}for(var s=new Uint8Array(4*i*n),l=0;n>l;l++)for(var c=0;i>c;c++){var h=4*(i*(n-l-1)+c),u=4*(i*l+c),d=a[u+3];s[h]=Math.round(a[u]/d*255),s[h+1]=Math.round(a[u+1]/d*255),s[h+2]=Math.round(a[u+2]/d*255),s[h+3]=a[u+3]}return s},n.prototype.toDataURL=function(e,t){return this.context.surface.toDataURL(e,t)},n.prototype.destroy=function(){this.context.destroy()},n.prototype.onRenderFinish=function(){this.$drawCalls=0},n.prototype.drawFrameBufferToSurface=function(e,t,r,i,n,a,o,s,l){void 0===l&&(l=!1),this.rootRenderTarget.useFrameBuffer=!1,this.rootRenderTarget.activate(),this.context.disableStencilTest(),this.context.disableScissorTest(),this.setTransform(1,0,0,1,0,0),this.globalAlpha=1,this.context.setGlobalCompositeOperation("source-over"),l&&this.context.clear(),this.context.drawImage(this.rootRenderTarget,e,t,r,i,n,a,o,s,r,i,!1),this.context.$drawWebGL(),this.rootRenderTarget.useFrameBuffer=!0,this.rootRenderTarget.activate(),this.restoreStencil(),this.restoreScissor()},n.prototype.drawSurfaceToFrameBuffer=function(e,t,r,i,n,a,o,s,l){void 0===l&&(l=!1),this.rootRenderTarget.useFrameBuffer=!0,this.rootRenderTarget.activate(),this.context.disableStencilTest(),this.context.disableScissorTest(),this.setTransform(1,0,0,1,0,0),this.globalAlpha=1,this.context.setGlobalCompositeOperation("source-over"),l&&this.context.clear(),this.context.drawImage(this.context.surface,e,t,r,i,n,a,o,s,r,i,!1),this.context.$drawWebGL(),this.rootRenderTarget.useFrameBuffer=!1,this.rootRenderTarget.activate(),this.restoreStencil(),this.restoreScissor()},n.prototype.clear=function(){this.context.pushBuffer(this),this.context.clear(),this.context.popBuffer()},n.prototype.setTransform=function(e,t,r,i,n,a){var o=this.globalMatrix;o.a=e,o.b=t,o.c=r,o.d=i,o.tx=n,o.ty=a},n.prototype.transform=function(e,t,r,i,n,a){var o=this.globalMatrix,s=o.a,l=o.b,c=o.c,h=o.d;(1!=e||0!=t||0!=r||1!=i)&&(o.a=e*s+t*c,o.b=e*l+t*h,o.c=r*s+i*c,o.d=r*l+i*h),o.tx=n*s+a*c+o.tx,o.ty=n*l+a*h+o.ty},n.prototype.useOffset=function(){var e=this;(0!=e.$offsetX||0!=e.$offsetY)&&(e.globalMatrix.append(1,0,0,1,e.$offsetX,e.$offsetY),e.$offsetX=e.$offsetY=0)},n.prototype.saveTransform=function(){var e=this.globalMatrix,t=this.savedGlobalMatrix;t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.tx=e.tx,t.ty=e.ty},n.prototype.restoreTransform=function(){var e=this.globalMatrix,t=this.savedGlobalMatrix;e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e.tx=t.tx,e.ty=t.ty},n.create=function(e,t){var r=i.pop(); -if(r){r.resize(e,t);var a=r.globalMatrix;a.a=1,a.b=0,a.c=0,a.d=1,a.tx=0,a.ty=0,r.globalAlpha=1,r.$offsetX=0,r.$offsetY=0}else r=new n(e,t),r.$computeDrawCall=!1;return r},n.release=function(e){i.push(e)},n.autoClear=!0,n}(e.HashObject);t.WebGLRenderBuffer=r,__reflect(r.prototype,"egret.web.WebGLRenderBuffer",["egret.sys.RenderBuffer"]);var i=[]}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=["source-over","lighter","destination-out"],i="source-over",n=[],a=function(){function a(){this.wxiOS10=!1,this.nestLevel=0}return a.prototype.render=function(t,r,i,a){this.nestLevel++;var o=r,s=o.context;s.pushBuffer(o),o.transform(i.a,i.b,i.c,i.d,0,0),this.drawDisplayObject(t,o,i.tx,i.ty,!0),s.$drawWebGL();var l=o.$drawCalls;o.onRenderFinish(),s.popBuffer();var c=e.Matrix.create();if(i.$invertInto(c),o.transform(c.a,c.b,c.c,c.d,0,0),e.Matrix.release(c),this.nestLevel--,0===this.nestLevel){n.length>6&&(n.length=6);for(var h=n.length,u=0;h>u;u++)n[u].resize(0,0)}return l},a.prototype.drawDisplayObject=function(t,r,i,n,a){var o,s=0,l=t.$displayList;if(l&&!a?((t.$cacheDirty||t.$renderDirty||l.$canvasScaleX!=e.sys.DisplayList.$canvasScaleX||l.$canvasScaleY!=e.sys.DisplayList.$canvasScaleY)&&(s+=l.drawToSurface()),o=l.$renderNode):o=t.$renderDirty?t.$getRenderNode():t.$renderNode,t.$cacheDirty=!1,o){switch(s++,r.$offsetX=i,r.$offsetY=n,o.type){case 1:this.renderBitmap(o,r);break;case 2:this.renderText(o,r);break;case 3:this.renderGraphics(o,r);break;case 4:this.renderGroup(o,r);break;case 5:this.renderMesh(o,r);break;case 6:this.renderNormalBitmap(o,r)}r.$offsetX=0,r.$offsetY=0}if(l&&!a)return s;var c=t.$children;if(c){t.sortableChildren&&t.$sortDirty&&t.sortChildren();for(var h=c.length,u=0;h>u;u++){var d=c[u],f=void 0,p=void 0,v=void 0,g=void 0;1!=d.$alpha&&(v=r.globalAlpha,r.globalAlpha*=d.$alpha),16777215!==d.tint&&(g=r.globalTintColor,r.globalTintColor=d.$tintRGB);var x=void 0;if(d.$useTranslate){var y=d.$getMatrix();f=i+d.$x,p=n+d.$y;var m=r.globalMatrix;x=e.Matrix.create(),x.a=m.a,x.b=m.b,x.c=m.c,x.d=m.d,x.tx=m.tx,x.ty=m.ty,r.transform(y.a,y.b,y.c,y.d,f,p),f=-d.$anchorOffsetX,p=-d.$anchorOffsetY}else f=i+d.$x-d.$anchorOffsetX,p=n+d.$y-d.$anchorOffsetY;switch(d.$renderMode){case 1:break;case 2:s+=this.drawWithFilter(d,r,f,p);break;case 3:s+=this.drawWithClip(d,r,f,p);break;case 4:s+=this.drawWithScrollRect(d,r,f,p);break;default:s+=this.drawDisplayObject(d,r,f,p)}if(v&&(r.globalAlpha=v),g&&(r.globalTintColor=g),x){var y=r.globalMatrix;y.a=x.a,y.b=x.b,y.c=x.c,y.d=x.d,y.tx=x.tx,y.ty=x.ty,e.Matrix.release(x)}}}return s},a.prototype.drawWithFilter=function(t,a,o,s){var l=0;if(t.$children&&0==t.$children.length&&(!t.$renderNode||0==t.$renderNode.$getRenderCount()))return l;var c,h=t.$filters,u=0!==t.$blendMode;u&&(c=r[t.$blendMode],c||(c=i));var d=t.$getOriginalBounds(),f=d.x,p=d.y,v=d.width,g=d.height;if(0>=v||0>=g)return l;if(!t.mask&&1==h.length&&("colorTransform"==h[0].type||"custom"===h[0].type&&0===h[0].padding)){var x=this.getRenderCount(t);if(!t.$children||1==x)return u&&a.context.setGlobalCompositeOperation(c),a.context.$filter=h[0],l+=t.$mask?this.drawWithClip(t,a,o,s):t.$scrollRect||t.$maskRect?this.drawWithScrollRect(t,a,o,s):this.drawDisplayObject(t,a,o,s),a.context.$filter=null,u&&a.context.setGlobalCompositeOperation(i),l}var y=this.createRenderBuffer(v,g);if(y.context.pushBuffer(y),l+=t.$mask?this.drawWithClip(t,y,-f,-p):t.$scrollRect||t.$maskRect?this.drawWithScrollRect(t,y,-f,-p):this.drawDisplayObject(t,y,-f,-p),y.context.popBuffer(),l>0){u&&a.context.setGlobalCompositeOperation(c),l++,a.$offsetX=o+f,a.$offsetY=s+p;var m=e.Matrix.create(),b=a.globalMatrix;m.a=b.a,m.b=b.b,m.c=b.c,m.d=b.d,m.tx=b.tx,m.ty=b.ty,a.useOffset(),a.context.drawTargetWidthFilters(h,y),b.a=m.a,b.b=m.b,b.c=m.c,b.d=m.d,b.tx=m.tx,b.ty=m.ty,e.Matrix.release(m),u&&a.context.setGlobalCompositeOperation(i)}return n.push(y),l},a.prototype.getRenderCount=function(e){var t=0,r=e.$getRenderNode();if(r&&(t+=r.$getRenderCount()),e.$children)for(var i=0,n=e.$children;i0)return 2;if(a.$children)t+=this.getRenderCount(a);else{var s=a.$getRenderNode();s&&(t+=s.$getRenderCount())}}return t},a.prototype.drawWithClip=function(t,a,o,s){var l,c=0,h=0!==t.$blendMode;h&&(l=r[t.$blendMode],l||(l=i));var u=t.$scrollRect?t.$scrollRect:t.$maskRect,d=t.$mask;if(d){var f=d.$getMatrix();if(0==f.a&&0==f.b||0==f.c&&0==f.d)return c}if(d||t.$children&&0!=t.$children.length){var p=t.$getOriginalBounds(),v=p.x,g=p.y,x=p.width,y=p.height;if(0>=x||0>=y)return c;var m=this.createRenderBuffer(x,y);if(m.context.pushBuffer(m),c+=this.drawDisplayObject(t,m,-v,-g),d){var b=this.createRenderBuffer(x,y);b.context.pushBuffer(b);var w=e.Matrix.create();w.copyFrom(d.$getConcatenatedMatrix()),d.$getConcatenatedMatrixAt(t,w),w.translate(-v,-g),b.setTransform(w.a,w.b,w.c,w.d,w.tx,w.ty),e.Matrix.release(w),c+=this.drawDisplayObject(d,b,0,0),b.context.popBuffer(),m.context.setGlobalCompositeOperation("destination-in"),m.setTransform(1,0,0,-1,0,b.height);var T=b.rootRenderTarget.width,E=b.rootRenderTarget.height;m.context.drawTexture(b.rootRenderTarget.texture,0,0,T,E,0,0,T,E,T,E),m.setTransform(1,0,0,1,0,0),m.context.setGlobalCompositeOperation("source-over"),b.setTransform(1,0,0,1,0,0),n.push(b)}if(m.context.setGlobalCompositeOperation(i),m.context.popBuffer(),c>0){c++,h&&a.context.setGlobalCompositeOperation(l),u&&a.context.pushMask(u.x+o,u.y+s,u.width,u.height);var _=e.Matrix.create(),C=a.globalMatrix;_.a=C.a,_.b=C.b,_.c=C.c,_.d=C.d,_.tx=C.tx,_.ty=C.ty,C.append(1,0,0,-1,o+v,s+g+m.height);var S=m.rootRenderTarget.width,R=m.rootRenderTarget.height;a.context.drawTexture(m.rootRenderTarget.texture,0,0,S,R,0,0,S,R,S,R),u&&m.context.popMask(),h&&a.context.setGlobalCompositeOperation(i);var L=a.globalMatrix;L.a=_.a,L.b=_.b,L.c=_.c,L.d=_.d,L.tx=_.tx,L.ty=_.ty,e.Matrix.release(_)}return n.push(m),c}return u&&a.context.pushMask(u.x+o,u.y+s,u.width,u.height),h&&a.context.setGlobalCompositeOperation(l),c+=this.drawDisplayObject(t,a,o,s),h&&a.context.setGlobalCompositeOperation(i),u&&a.context.popMask(),c},a.prototype.drawWithScrollRect=function(e,t,r,i){var n=0,a=e.$scrollRect?e.$scrollRect:e.$maskRect;if(a.isEmpty())return n;e.$scrollRect&&(r-=a.x,i-=a.y);var o=t.globalMatrix,s=t.context,l=!1;if(t.$hasScissor||0!=o.b||0!=o.c)t.context.pushMask(a.x+r,a.y+i,a.width,a.height);else{var c=o.a,h=o.d,u=o.tx,d=o.ty,f=a.x+r,p=a.y+i,v=f+a.width,g=p+a.height,x=void 0,y=void 0,m=void 0,b=void 0;if(1==c&&1==h)x=f+u,y=p+d,m=v+u,b=g+d;else{var w=c*f+u,T=h*p+d,E=c*v+u,_=h*p+d,C=c*v+u,S=h*g+d,R=c*f+u,L=h*g+d,D=0;w>E&&(D=w,w=E,E=D),C>R&&(D=C,C=R,R=D),x=C>w?w:C,m=E>R?E:R,T>_&&(D=T,T=_,_=D),S>L&&(D=S,S=L,L=D),y=S>T?T:S,b=_>L?_:L}s.enableScissor(x,-b+t.height,m-x,b-y),l=!0}return n+=this.drawDisplayObject(e,t,r,i),l?s.disableScissor():s.popMask(),n},a.prototype.drawNodeToBuffer=function(e,t,r,i){var n=t;n.context.pushBuffer(n),n.setTransform(r.a,r.b,r.c,r.d,r.tx,r.ty),this.renderNode(e,t,0,0,i),n.context.$drawWebGL(),n.onRenderFinish(),n.context.popBuffer()},a.prototype.drawDisplayToBuffer=function(e,t,r){t.context.pushBuffer(t),r&&t.setTransform(r.a,r.b,r.c,r.d,r.tx,r.ty);var i;i=e.$renderDirty?e.$getRenderNode():e.$renderNode;var n=0;if(i)switch(n++,i.type){case 1:this.renderBitmap(i,t);break;case 2:this.renderText(i,t);break;case 3:this.renderGraphics(i,t);break;case 4:this.renderGroup(i,t);break;case 5:this.renderMesh(i,t);break;case 6:this.renderNormalBitmap(i,t)}var a=e.$children;if(a)for(var o=a.length,s=0;o>s;s++){var l=a[s];switch(l.$renderMode){case 1:break;case 2:n+=this.drawWithFilter(l,t,0,0);break;case 3:n+=this.drawWithClip(l,t,0,0);break;case 4:n+=this.drawWithScrollRect(l,t,0,0);break;default:n+=this.drawDisplayObject(l,t,0,0)}}return t.context.$drawWebGL(),t.onRenderFinish(),t.context.popBuffer(),n},a.prototype.renderNode=function(e,t,r,i,n){switch(t.$offsetX=r,t.$offsetY=i,e.type){case 1:this.renderBitmap(e,t);break;case 2:this.renderText(e,t);break;case 3:this.renderGraphics(e,t,n);break;case 4:this.renderGroup(e,t);break;case 5:this.renderMesh(e,t);break;case 6:this.renderNormalBitmap(e,t)}},a.prototype.renderNormalBitmap=function(e,t){var r=e.image;r&&t.context.drawImage(r,e.sourceX,e.sourceY,e.sourceW,e.sourceH,e.drawX,e.drawY,e.drawW,e.drawH,e.imageWidth,e.imageHeight,e.rotated,e.smoothing)},a.prototype.renderBitmap=function(t,n){var a=t.image;if(a){var o,s,l,c=t.drawData,h=c.length,u=0,d=t.matrix,f=t.blendMode,p=t.alpha;if(d){o=e.Matrix.create();var v=n.globalMatrix;o.a=v.a,o.b=v.b,o.c=v.c,o.d=v.d,o.tx=v.tx,o.ty=v.ty,s=n.$offsetX,l=n.$offsetY,n.useOffset(),n.transform(d.a,d.b,d.c,d.d,d.tx,d.ty)}f&&n.context.setGlobalCompositeOperation(r[f]);var g;if(p==p&&(g=n.globalAlpha,n.globalAlpha*=p),t.filter){for(n.context.$filter=t.filter;h>u;)n.context.drawImage(a,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],t.imageWidth,t.imageHeight,t.rotated,t.smoothing);n.context.$filter=null}else for(;h>u;)n.context.drawImage(a,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],t.imageWidth,t.imageHeight,t.rotated,t.smoothing);if(f&&n.context.setGlobalCompositeOperation(i),p==p&&(n.globalAlpha=g),d){var x=n.globalMatrix;x.a=o.a,x.b=o.b,x.c=o.c,x.d=o.d,x.tx=o.tx,x.ty=o.ty,n.$offsetX=s,n.$offsetY=l,e.Matrix.release(o)}}},a.prototype.renderMesh=function(t,n){var a,o,s,l=t.image,c=t.drawData,h=c.length,u=0,d=t.matrix,f=t.blendMode,p=t.alpha;if(d){a=e.Matrix.create();var v=n.globalMatrix;a.a=v.a,a.b=v.b,a.c=v.c,a.d=v.d,a.tx=v.tx,a.ty=v.ty,o=n.$offsetX,s=n.$offsetY,n.useOffset(),n.transform(d.a,d.b,d.c,d.d,d.tx,d.ty)}f&&n.context.setGlobalCompositeOperation(r[f]);var g;if(p==p&&(g=n.globalAlpha,n.globalAlpha*=p),t.filter){for(n.context.$filter=t.filter;h>u;)n.context.drawMesh(l,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],t.imageWidth,t.imageHeight,t.uvs,t.vertices,t.indices,t.bounds,t.rotated,t.smoothing);n.context.$filter=null}else for(;h>u;)n.context.drawMesh(l,c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],c[u++],t.imageWidth,t.imageHeight,t.uvs,t.vertices,t.indices,t.bounds,t.rotated,t.smoothing);if(f&&n.context.setGlobalCompositeOperation(i),p==p&&(n.globalAlpha=g),d){var x=n.globalMatrix;x.a=a.a,x.b=a.b,x.c=a.c,x.d=a.d,x.tx=a.tx,x.ty=a.ty,n.$offsetX=o,n.$offsetY=s,e.Matrix.release(a)}},a.prototype.___renderText____=function(r,i){var n=r.width-r.x,a=r.height-r.y;if(!(0>=n||0>=a)&&n&&a&&0!==r.drawData.length){var o=e.sys.DisplayList.$canvasScaleX,s=e.sys.DisplayList.$canvasScaleY,l=i.context.$maxTextureSize;n*o>l&&(o*=l/(n*o)),a*s>l&&(s*=l/(a*s)),n*=o,a*=s;var c=r.x*o,h=r.y*s;(r.$canvasScaleX!==o||r.$canvasScaleY!==s)&&(r.$canvasScaleX=o,r.$canvasScaleY=s,r.dirtyRender=!0),(c||h)&&i.transform(1,0,0,1,c/o,h/s),r.dirtyRender&&t.TextAtlasRender.analysisTextNodeAndFlushDrawLabel(r);var u=r[t.property_drawLabel];if(u&&u.length>0){for(var d=i.$offsetX,f=i.$offsetY,p=null,v=0,g=0,x=null,y=null,m=null,b=0,w=u.length;w>b;++b){p=u[b],v=p.anchorX,g=p.anchorY,x=p.textBlocks,i.$offsetX=d+v;for(var T=0,E=x.length;E>T;++T)y=x[T],T>0&&(i.$offsetX-=y.canvasWidthOffset),i.$offsetY=f+g-(y.measureHeight+(y.stroke2?y.canvasHeightOffset:0))/2,m=y.line.page,i.context.drawTexture(m.webGLTexture,y.u,y.v,y.contentWidth,y.contentHeight,0,0,y.contentWidth,y.contentHeight,m.pageWidth,m.pageHeight),i.$offsetX+=y.contentWidth-y.canvasWidthOffset}i.$offsetX=d,i.$offsetY=f}(c||h)&&i.transform(1,0,0,1,-c/o,-h/s),r.dirtyRender=!1}},a.prototype.renderText=function(r,i){if(t.textAtlasRenderEnable)return void this.___renderText____(r,i);var n=r.width-r.x,a=r.height-r.y;if(!(0>=n||0>=a)&&n&&a&&0!=r.drawData.length){var o=e.sys.DisplayList.$canvasScaleX,s=e.sys.DisplayList.$canvasScaleY,l=i.context.$maxTextureSize;n*o>l&&(o*=l/(n*o)),a*s>l&&(s*=l/(a*s)),n*=o,a*=s;var c=r.x*o,h=r.y*s;if((r.$canvasScaleX!=o||r.$canvasScaleY!=s)&&(r.$canvasScaleX=o,r.$canvasScaleY=s,r.dirtyRender=!0),this.wxiOS10?(this.canvasRenderer||(this.canvasRenderer=new e.CanvasRenderer),r.dirtyRender&&(this.canvasRenderBuffer=new t.CanvasRenderBuffer(n,a))):this.canvasRenderBuffer&&this.canvasRenderBuffer.context?r.dirtyRender&&this.canvasRenderBuffer.resize(n,a):(this.canvasRenderer=new e.CanvasRenderer,this.canvasRenderBuffer=new t.CanvasRenderBuffer(n,a)),this.canvasRenderBuffer.context){if((1!=o||1!=s)&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),c||h?(r.dirtyRender&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,-c,-h),i.transform(1,0,0,1,c/o,h/s)):(1!=o||1!=s)&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),r.dirtyRender){var u=this.canvasRenderBuffer.surface;if(this.canvasRenderer.renderText(r,this.canvasRenderBuffer.context),this.wxiOS10)u.isCanvas=!0,r.$texture=u;else{var d=r.$texture;d?i.context.updateTexture(d,u):(d=i.context.createTexture(u),r.$texture=d)}r.$textureWidth=u.width,r.$textureHeight=u.height}var f=r.$textureWidth,p=r.$textureHeight;i.context.drawTexture(r.$texture,0,0,f,p,0,0,f/o,p/s,f,p),(c||h)&&(r.dirtyRender&&this.canvasRenderBuffer.context.setTransform(o,0,0,s,0,0),i.transform(1,0,0,1,-c/o,-h/s)),r.dirtyRender=!1}}},a.prototype.renderGraphics=function(r,i,n){var a=r.width,o=r.height;if(!(0>=a||0>=o)&&a&&o&&0!=r.drawData.length){var s=e.sys.DisplayList.$canvasScaleX,l=e.sys.DisplayList.$canvasScaleY;(1>a*s||1>o*l)&&(s=l=1),(r.$canvasScaleX!=s||r.$canvasScaleY!=l)&&(r.$canvasScaleX=s,r.$canvasScaleY=l,r.dirtyRender=!0),a*=s,o*=l;var c=Math.ceil(a),h=Math.ceil(o);if(s*=c/a,l*=h/o,a=c,o=h,this.wxiOS10?(this.canvasRenderer||(this.canvasRenderer=new e.CanvasRenderer),r.dirtyRender&&(this.canvasRenderBuffer=new t.CanvasRenderBuffer(a,o))):this.canvasRenderBuffer&&this.canvasRenderBuffer.context?r.dirtyRender&&this.canvasRenderBuffer.resize(a,o):(this.canvasRenderer=new e.CanvasRenderer,this.canvasRenderBuffer=new t.CanvasRenderBuffer(a,o)),this.canvasRenderBuffer.context){(1!=s||1!=l)&&this.canvasRenderBuffer.context.setTransform(s,0,0,l,0,0),(r.x||r.y)&&((r.dirtyRender||n)&&this.canvasRenderBuffer.context.translate(-r.x,-r.y),i.transform(1,0,0,1,r.x,r.y));var u=this.canvasRenderBuffer.surface;if(n){this.canvasRenderer.renderGraphics(r,this.canvasRenderBuffer.context,!0);var d=void 0;this.wxiOS10?(u.isCanvas=!0,d=u):(e.WebGLUtils.deleteWebGLTexture(u),d=i.context.getWebGLTexture(u)),i.context.drawTexture(d,0,0,a,o,0,0,a,o,u.width,u.height)}else{if(r.dirtyRender){if(this.canvasRenderer.renderGraphics(r,this.canvasRenderBuffer.context),this.wxiOS10)u.isCanvas=!0,r.$texture=u;else{var d=r.$texture;d?i.context.updateTexture(d,u):(d=i.context.createTexture(u),r.$texture=d)}r.$textureWidth=u.width,r.$textureHeight=u.height}var f=r.$textureWidth,p=r.$textureHeight;i.context.drawTexture(r.$texture,0,0,f,p,0,0,f/s,p/l,f,p)}(r.x||r.y)&&((r.dirtyRender||n)&&this.canvasRenderBuffer.context.translate(r.x,r.y),i.transform(1,0,0,1,-r.x,-r.y)),n||(r.dirtyRender=!1)}}},a.prototype.renderGroup=function(t,r){var i,n,a,o=t.matrix;if(o){i=e.Matrix.create();var s=r.globalMatrix;i.a=s.a,i.b=s.b,i.c=s.c,i.d=s.d,i.tx=s.tx,i.ty=s.ty,n=r.$offsetX,a=r.$offsetY,r.useOffset(),r.transform(o.a,o.b,o.c,o.d,o.tx,o.ty)}for(var l=t.drawData,c=l.length,h=0;c>h;h++){var u=l[h];this.renderNode(u,r,r.$offsetX,r.$offsetY)}if(o){var d=r.globalMatrix;d.a=i.a,d.b=i.b,d.c=i.c,d.d=i.d,d.tx=i.tx,d.ty=i.ty,r.$offsetX=n,r.$offsetY=a,e.Matrix.release(i)}},a.prototype.createRenderBuffer=function(e,r){var i=n.pop();return i?i.resize(e,r):(i=new t.WebGLRenderBuffer(e,r),i.$computeDrawCall=!1),i},a}();t.WebGLRenderer=a,__reflect(a.prototype,"egret.web.WebGLRenderer",["egret.sys.SystemRenderer"])}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(t){var r=function(e){function t(t,r,i,n,a,o,s,l){var c=e.call(this)||this;return c._width=0,c._height=0,c._border=0,c.line=null,c.x=0,c.y=0,c.u=0,c.v=0,c.tag="",c.measureWidth=0,c.measureHeight=0,c.canvasWidthOffset=0,c.canvasHeightOffset=0,c.stroke2=0,c._width=t,c._height=r,c._border=l,c.measureWidth=i,c.measureHeight=n,c.canvasWidthOffset=a,c.canvasHeightOffset=o,c.stroke2=s,c}return __extends(t,e),Object.defineProperty(t.prototype,"border",{get:function(){return this._border},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width+2*this.border},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height+2*this.border},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contentWidth",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contentHeight",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"page",{get:function(){return this.line?this.line.page:null},enumerable:!0,configurable:!0}),t.prototype.updateUV=function(){var e=this.line;return e?(this.u=e.x+this.x+1*this.border,this.v=e.y+this.y+1*this.border,!0):!1},Object.defineProperty(t.prototype,"subImageOffsetX",{get:function(){var e=this.line;return e?e.x+this.x+this.border:0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subImageOffsetY",{get:function(){var e=this.line;return e?e.y+this.y+this.border:0},enumerable:!0,configurable:!0}),t}(e.HashObject);t.TextBlock=r,__reflect(r.prototype,"egret.web.TextBlock");var i=function(e){function t(t){var r=e.call(this)||this;return r.page=null,r.textBlocks=[],r.dynamicMaxHeight=0,r.maxWidth=0,r.x=0,r.y=0,r.maxWidth=t,r}return __extends(t,e),t.prototype.isCapacityOf=function(e){if(!e)return!1;var t=0,r=0,i=this.lastTextBlock();return i&&(t=i.x+i.width,r=i.y),t+e.width>this.maxWidth?!1:this.dynamicMaxHeight>0&&(e.height>this.dynamicMaxHeight||e.height/this.dynamicMaxHeight<.5)?!1:!0},t.prototype.lastTextBlock=function(){var e=this.textBlocks;return e.length>0?e[e.length-1]:null},t.prototype.addTextBlock=function(e,t){if(!e)return!1;if(t&&!this.isCapacityOf(e))return!1;var r=0,i=0,n=this.lastTextBlock();return n&&(r=n.x+n.width,i=n.y),e.x=r,e.y=i,e.line=this,this.textBlocks.push(e),this.dynamicMaxHeight=Math.max(this.dynamicMaxHeight,e.height),!0},t}(e.HashObject);t.Line=i,__reflect(i.prototype,"egret.web.Line");var n=function(e){function t(t,r){var i=e.call(this)||this;return i.lines=[],i.pageWidth=0,i.pageHeight=0,i.webGLTexture=null,i.pageWidth=t,i.pageHeight=r,i}return __extends(t,e),t.prototype.addLine=function(e){if(!e)return!1;var t=0,r=0,i=this.lines;if(i.length>0){var n=i[i.length-1];t=n.x,r=n.y+n.dynamicMaxHeight}return e.maxWidth>this.pageWidth?(console.error("line.maxWidth = "+e.maxWidth+", this.pageWidth = "+this.pageWidth),!1):r+e.dynamicMaxHeight>this.pageHeight?!1:(e.x=t,e.y=r,e.page=this,this.lines.push(e),!0)},t}(e.HashObject);t.Page=n,__reflect(n.prototype,"egret.web.Page");var a=function(e){function t(t,r){var i=e.call(this)||this;return i._pages=[],i._sortLines=[],i._maxSize=1024,i._border=1,i._maxSize=t,i._border=r,i}return __extends(t,e),t.prototype.addTextBlock=function(e){var t=this._addTextBlock(e);if(!t)return!1;e.updateUV();for(var r=!1,i=t,n=this._sortLines,a=0,o=n;athis._maxSize||e.height>this._maxSize)return null;for(var t=this._sortLines,r=0,n=t.length;n>r;++r){var a=t[r];if(a.isCapacityOf(e)&&a.addTextBlock(e,!1))return[a.page,a]}var o=new i(this._maxSize);if(!o.addTextBlock(e,!0))return console.error("_addTextBlock !newLine.addTextBlock(textBlock, true)"),null;for(var s=this._pages,r=0,l=s.length;l>r;++r){var c=s[r];if(c.addLine(o))return[c,o]}var h=this.createPage(this._maxSize,this._maxSize);return h.addLine(o)?[h,o]:(console.error("_addText newPage.addLine failed"),null)},t.prototype.createPage=function(e,t){var r=new n(e,t);return this._pages.push(r),r},t.prototype.sort=function(){if(!(this._sortLines.length<=1)){var e=function(e,t){return e.dynamicMaxHeight=0)return void console.error("DrawLabel.back repeat");e.clear(),i.push(e)}},t.pool=[],t}(e.HashObject);t.DrawLabel=i,__reflect(i.prototype,"egret.web.DrawLabel");var n=function(t){function i(i,n){var a=t.call(this)||this;a.format=null;var o=0;r&&(o=i.textColor,i.textColor=16711680),a.textColor=i.textColor,a.strokeColor=i.strokeColor,a.size=i.size,a.stroke=i.stroke,a.bold=i.bold,a.italic=i.italic,a.fontFamily=i.fontFamily,a.format=n,a.font=e.getFontString(i,a.format);var s=n.textColor?n.textColor:i.textColor,l=n.strokeColor?n.strokeColor:i.strokeColor,c=n.stroke?n.stroke:i.stroke,h=n.size?n.size:i.size;return a.description=""+a.font+"-"+h,a.description+="-"+e.toColorString(s),a.description+="-"+e.toColorString(l),c&&(a.description+="-"+2*c),r&&(i.textColor=o),a}return __extends(i,t),i}(e.HashObject);__reflect(n.prototype,"StyleInfo");var a=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e["char"]="",e.styleInfo=null,e.hashCodeString="",e.charWithStyleHashCode=0,e.measureWidth=0,e.measureHeight=0,e.canvasWidthOffset=0,e.canvasHeightOffset=0,e.stroke2=0,e}return __extends(r,t),r.prototype.reset=function(t,r){return this["char"]=t,this.styleInfo=r,this.hashCodeString=t+":"+r.description,this.charWithStyleHashCode=e.NumberUtils.convertStringToHashCode(this.hashCodeString),this.canvasWidthOffset=0,this.canvasHeightOffset=0,this.stroke2=0,this},r.prototype.measureAndDraw=function(t){var r=t;if(r){var i=this["char"],n=this.styleInfo.format,a=n.textColor?n.textColor:this.styleInfo.textColor,o=n.strokeColor?n.strokeColor:this.styleInfo.strokeColor,s=n.stroke?n.stroke:this.styleInfo.stroke,l=n.size?n.size:this.styleInfo.size;this.measureWidth=this.measure(i,this.styleInfo,l),this.measureHeight=l;var c=this.measureWidth,h=this.measureHeight,u=2*s;u>0&&(c+=2*u,h+=2*u),this.stroke2=u,r.width=c=Math.ceil(c)+4,r.height=h=Math.ceil(h)+4,this.canvasWidthOffset=(r.width-this.measureWidth)/2,this.canvasHeightOffset=(r.height-this.measureHeight)/2;var d=3,f=Math.pow(10,d);this.canvasWidthOffset=Math.floor(this.canvasWidthOffset*f)/f,this.canvasHeightOffset=Math.floor(this.canvasHeightOffset*f)/f;var p=e.sys.getContext2d(r);p.save(),p.textAlign="center",p.textBaseline="middle",p.lineJoin="round",p.font=this.styleInfo.font,p.fillStyle=e.toColorString(a),p.strokeStyle=e.toColorString(o),p.clearRect(0,0,r.width,r.height),s&&(p.lineWidth=2*s,p.strokeText(i,r.width/2,r.height/2)),p.fillText(i,r.width/2,r.height/2),p.restore()}},r.prototype.measure=function(t,i,n){var a=r.chineseCharactersRegExp.test(t);if(a&&r.chineseCharacterMeasureFastMap[i.font])return r.chineseCharacterMeasureFastMap[i.font];var o=e.sys.measureText(t,i.fontFamily,n||i.size,i.bold,i.italic);return a&&(r.chineseCharacterMeasureFastMap[i.font]=o),o},r.chineseCharactersRegExp=new RegExp("^[一-龥]$"),r.chineseCharacterMeasureFastMap={},r}(e.HashObject);__reflect(a.prototype,"CharImageRender");var o=function(o){function s(e,r,i){var n=o.call(this)||this;return n.book=null,n.charImageRender=new a,n.textBlockMap={},n._canvas=null,n.textAtlasTextureCache=[],n.webglRenderContext=null,n.webglRenderContext=e,n.book=new t.Book(r,i),n}return __extends(s,o),s.analysisTextNodeAndFlushDrawLabel=function(a){if(a){if(!t.__textAtlasRender__){var o=e.web.WebGLRenderContext.getInstance(0,0);t.__textAtlasRender__=new s(o,512,r?12:1)}a[t.property_drawLabel]=a[t.property_drawLabel]||[];for(var l=a[t.property_drawLabel],c=0,h=l;cm;m+=d){p=f[m+0],v=f[m+1],g=f[m+2],x=f[m+3]||{},y.length=0,t.__textAtlasRender__.convertLabelStringToTextAtlas(g,new n(a,x),y);var u=i.create();u.anchorX=p,u.anchorY=v,u.textBlocks=[].concat(y),l.push(u)}}},s.prototype.convertLabelStringToTextAtlas=function(t,i,n){for(var a=this.canvas,o=this.charImageRender,s=this.textBlockMap,l=0,c=t;la;a++){var o=t.getActiveAttrib(r,a),s=o.name,l=new e.EgretWebGLAttribute(t,r,o);i[s]=l}return i}function n(t,r){for(var i={},n=t.getProgramParameter(r,t.ACTIVE_UNIFORMS),a=0;n>a;a++){var o=t.getActiveUniform(r,a),s=o.name,l=new e.EgretWebGLUniform(t,r,o);i[s]=l}return i}var a=function(){function e(e,a,o){this.vshaderSource=a,this.fshaderSource=o,this.vertexShader=t(e,e.VERTEX_SHADER,this.vshaderSource),this.fragmentShader=t(e,e.FRAGMENT_SHADER,this.fshaderSource),this.id=r(e,this.vertexShader,this.fragmentShader),this.uniforms=n(e,this.id),this.attributes=i(e,this.id)}return e.getProgram=function(t,r,i,n){return this.programCache[n]||(this.programCache[n]=new e(t,r,i)),this.programCache[n]},e.deleteProgram=function(e,t,r,i){},e.programCache={},e}();e.EgretWebGLProgram=a,__reflect(a.prototype,"egret.web.EgretWebGLProgram")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){var t=function(){function e(e,t,r){this.gl=e,this.name=r.name,this.type=r.type,this.size=r.size,this.location=e.getUniformLocation(t,this.name),this.setDefaultValue(),this.generateSetValue(),this.generateUpload()}return e.prototype.setDefaultValue=function(){var e=this.type;switch(e){case 5126:case 35678:case 35680:case 35670:case 5124:this.value=0;break;case 35664:case 35671:case 35667:this.value=[0,0];break;case 35665:case 35672:case 35668:this.value=[0,0,0];break;case 35666:case 35673:case 35669:this.value=[0,0,0,0];break;case 35674:this.value=new Float32Array([1,0,0,1]);break;case 35675:this.value=new Float32Array([1,0,0,0,1,0,0,0,1]);break;case 35676:this.value=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}},e.prototype.generateSetValue=function(){var e=this.type;switch(e){case 5126:case 35678:case 35680:case 35670:case 5124:this.setValue=function(e){var t=this.value!==e;this.value=e,t&&this.upload()};break;case 35664:case 35671:case 35667:this.setValue=function(e){var t=this.value[0]!==e.x||this.value[1]!==e.y;this.value[0]=e.x,this.value[1]=e.y,t&&this.upload()};break;case 35665:case 35672:case 35668:this.setValue=function(e){this.value[0]=e.x,this.value[1]=e.y,this.value[2]=e.z,this.upload()};break;case 35666:case 35673:case 35669:this.setValue=function(e){this.value[0]=e.x,this.value[1]=e.y,this.value[2]=e.z,this.value[3]=e.w,this.upload()};break;case 35674:case 35675:case 35676:this.setValue=function(e){this.value.set(e),this.upload()}}},e.prototype.generateUpload=function(){var e=this.gl,t=this.type,r=this.location;switch(t){case 5126:this.upload=function(){var t=this.value;e.uniform1f(r,t)};break;case 35664:this.upload=function(){var t=this.value;e.uniform2f(r,t[0],t[1])};break;case 35665:this.upload=function(){var t=this.value;e.uniform3f(r,t[0],t[1],t[2])};break;case 35666:this.upload=function(){var t=this.value;e.uniform4f(r,t[0],t[1],t[2],t[3])};break;case 35678:case 35680:case 35670:case 5124:this.upload=function(){var t=this.value;e.uniform1i(r,t)};break;case 35671:case 35667:this.upload=function(){var t=this.value;e.uniform2i(r,t[0],t[1])};break;case 35672:case 35668:this.upload=function(){var t=this.value;e.uniform3i(r,t[0],t[1],t[2])};break;case 35673:case 35669:this.upload=function(){var t=this.value;e.uniform4i(r,t[0],t[1],t[2],t[3])};break;case 35674:this.upload=function(){var t=this.value;e.uniformMatrix2fv(r,!1,t)};break;case 35675:this.upload=function(){var t=this.value;e.uniformMatrix3fv(r,!1,t)};break;case 35676:this.upload=function(){var t=this.value;e.uniformMatrix4fv(r,!1,t)}}},e}();e.EgretWebGLUniform=t,__reflect(t.prototype,"egret.web.EgretWebGLUniform")}(t=e.web||(e.web={}))}(egret||(egret={}));var egret;!function(e){var t;!function(e){var t=function(){function e(){}return e.blur_frag="precision mediump float;\r\nuniform vec2 blur;\r\nuniform sampler2D uSampler;\r\nvarying vec2 vTextureCoord;\r\nuniform vec2 uTextureSize;\r\nvoid main()\r\n{\r\n const int sampleRadius = 5;\r\n const int samples = sampleRadius * 2 + 1;\r\n vec2 blurUv = blur / uTextureSize;\r\n vec4 color = vec4(0, 0, 0, 0);\r\n vec2 uv = vec2(0.0, 0.0);\r\n blurUv /= float(sampleRadius);\r\n\r\n for (int i = -sampleRadius; i <= sampleRadius; i++) {\r\n uv.x = vTextureCoord.x + float(i) * blurUv.x;\r\n uv.y = vTextureCoord.y + float(i) * blurUv.y;\r\n color += texture2D(uSampler, uv);\r\n }\r\n\r\n color /= float(samples);\r\n gl_FragColor = color;\r\n}",e.colorTransform_frag="precision mediump float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform mat4 matrix;\r\nuniform vec4 colorAdd;\r\nuniform sampler2D uSampler;\r\n\r\nvoid main(void) {\r\n vec4 texColor = texture2D(uSampler, vTextureCoord);\r\n if(texColor.a > 0.) {\r\n // 抵消预乘的alpha通道\r\n texColor = vec4(texColor.rgb / texColor.a, texColor.a);\r\n }\r\n vec4 locColor = clamp(texColor * matrix + colorAdd, 0., 1.);\r\n gl_FragColor = vColor * vec4(locColor.rgb * locColor.a, locColor.a);\r\n}",e.default_vert="attribute vec2 aVertexPosition;\r\nattribute vec2 aTextureCoord;\r\nattribute vec4 aColor;\r\n\r\nuniform vec2 projectionVector;\r\n// uniform vec2 offsetVector;\r\n\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\n\r\nconst vec2 center = vec2(-1.0, 1.0);\r\n\r\nvoid main(void) {\r\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\r\n vTextureCoord = aTextureCoord;\r\n vColor = aColor;\r\n}",e.glow_frag="precision highp float;\r\nvarying vec2 vTextureCoord;\r\n\r\nuniform sampler2D uSampler;\r\n\r\nuniform float dist;\r\nuniform float angle;\r\nuniform vec4 color;\r\nuniform float alpha;\r\nuniform float blurX;\r\nuniform float blurY;\r\n// uniform vec4 quality;\r\nuniform float strength;\r\nuniform float inner;\r\nuniform float knockout;\r\nuniform float hideObject;\r\n\r\nuniform vec2 uTextureSize;\r\n\r\nfloat random(vec2 scale)\r\n{\r\n return fract(sin(dot(gl_FragCoord.xy, scale)) * 43758.5453);\r\n}\r\n\r\nvoid main(void) {\r\n vec2 px = vec2(1.0 / uTextureSize.x, 1.0 / uTextureSize.y);\r\n // TODO 自动调节采样次数?\r\n const float linearSamplingTimes = 7.0;\r\n const float circleSamplingTimes = 12.0;\r\n vec4 ownColor = texture2D(uSampler, vTextureCoord);\r\n vec4 curColor;\r\n float totalAlpha = 0.0;\r\n float maxTotalAlpha = 0.0;\r\n float curDistanceX = 0.0;\r\n float curDistanceY = 0.0;\r\n float offsetX = dist * cos(angle) * px.x;\r\n float offsetY = dist * sin(angle) * px.y;\r\n\r\n const float PI = 3.14159265358979323846264;\r\n float cosAngle;\r\n float sinAngle;\r\n float offset = PI * 2.0 / circleSamplingTimes * random(vec2(12.9898, 78.233));\r\n float stepX = blurX * px.x / linearSamplingTimes;\r\n float stepY = blurY * px.y / linearSamplingTimes;\r\n for (float a = 0.0; a <= PI * 2.0; a += PI * 2.0 / circleSamplingTimes) {\r\n cosAngle = cos(a + offset);\r\n sinAngle = sin(a + offset);\r\n for (float i = 1.0; i <= linearSamplingTimes; i++) {\r\n curDistanceX = i * stepX * cosAngle;\r\n curDistanceY = i * stepY * sinAngle;\r\n if (vTextureCoord.x + curDistanceX - offsetX >= 0.0 && vTextureCoord.y + curDistanceY + offsetY <= 1.0){\r\n curColor = texture2D(uSampler, vec2(vTextureCoord.x + curDistanceX - offsetX, vTextureCoord.y + curDistanceY + offsetY));\r\n totalAlpha += (linearSamplingTimes - i) * curColor.a;\r\n }\r\n maxTotalAlpha += (linearSamplingTimes - i);\r\n }\r\n }\r\n\r\n ownColor.a = max(ownColor.a, 0.0001);\r\n ownColor.rgb = ownColor.rgb / ownColor.a;\r\n\r\n float outerGlowAlpha = (totalAlpha / maxTotalAlpha) * strength * alpha * (1. - inner) * max(min(hideObject, knockout), 1. - ownColor.a);\r\n float innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * strength * alpha * inner * ownColor.a;\r\n\r\n ownColor.a = max(ownColor.a * knockout * (1. - hideObject), 0.0001);\r\n vec3 mix1 = mix(ownColor.rgb, color.rgb, innerGlowAlpha / (innerGlowAlpha + ownColor.a));\r\n vec3 mix2 = mix(mix1, color.rgb, outerGlowAlpha / (innerGlowAlpha + ownColor.a + outerGlowAlpha));\r\n float resultAlpha = min(ownColor.a + outerGlowAlpha + innerGlowAlpha, 1.);\r\n gl_FragColor = vec4(mix2 * resultAlpha, resultAlpha);\r\n}",e.primitive_frag="precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\n\r\nvoid main(void) {\r\n gl_FragColor = vColor;\r\n}",e.texture_frag="precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform sampler2D uSampler;\r\n\r\nvoid main(void) {\r\n gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;\r\n}",e.texture_etc_alphamask_frag="precision lowp float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform sampler2D uSampler;\r\nuniform sampler2D uSamplerAlphaMask;\r\nvoid main(void) {\r\nfloat alpha = texture2D(uSamplerAlphaMask, vTextureCoord).r;\r\nif (alpha < 0.0039) { discard; }\r\nvec4 v4Color = texture2D(uSampler, vTextureCoord);\r\nv4Color.rgb = v4Color.rgb * alpha;\r\nv4Color.a = alpha;\r\ngl_FragColor = v4Color * vColor;\r\n}",e.colorTransform_frag_etc_alphamask_frag="precision mediump float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform mat4 matrix;\r\nuniform vec4 colorAdd;\r\nuniform sampler2D uSampler;\r\nuniform sampler2D uSamplerAlphaMask;\r\n\r\nvoid main(void){\r\nfloat alpha = texture2D(uSamplerAlphaMask, vTextureCoord).r;\r\nif (alpha < 0.0039) { discard; }\r\nvec4 texColor = texture2D(uSampler, vTextureCoord);\r\nif(texColor.a > 0.0) {\r\n // 抵消预乘的alpha通道\r\ntexColor = vec4(texColor.rgb / texColor.a, texColor.a);\r\n}\r\nvec4 v4Color = clamp(texColor * matrix + colorAdd, 0.0, 1.0);\r\nv4Color.rgb = v4Color.rgb * alpha;\r\nv4Color.a = alpha;\r\ngl_FragColor = v4Color * vColor;\r\n}",e -}();e.EgretShaderLib=t,__reflect(t.prototype,"egret.web.EgretShaderLib")}(t=e.web||(e.web={}))}(egret||(egret={})); \ No newline at end of file diff --git a/demo/libs/modules/eui/eui.d.ts b/demo/libs/modules/eui/eui.d.ts deleted file mode 100644 index 88d866f8..00000000 --- a/demo/libs/modules/eui/eui.d.ts +++ /dev/null @@ -1,15047 +0,0 @@ -declare namespace eui.sys { - /** - * @private - * 失效验证管理器 - */ - class Validator extends egret.EventDispatcher { - /** - * @private - * 创建一个Validator对象 - */ - constructor(); - /** - * @private - */ - private targetLevel; - /** - * @private - */ - private invalidatePropertiesFlag; - /** - * @private - */ - private invalidateClientPropertiesFlag; - /** - * @private - */ - private invalidatePropertiesQueue; - /** - * @private - * 标记组件属性失效 - */ - invalidateProperties(client: UIComponent): void; - /** - * @private - * 验证失效的属性 - */ - private validateProperties(); - /** - * @private - */ - private invalidateSizeFlag; - /** - * @private - */ - private invalidateClientSizeFlag; - /** - * @private - */ - private invalidateSizeQueue; - /** - * @private - * 标记需要重新测量尺寸 - */ - invalidateSize(client: UIComponent): void; - /** - * @private - * 测量尺寸 - */ - private validateSize(); - /** - * @private - */ - private invalidateDisplayListFlag; - /** - * @private - */ - private invalidateDisplayListQueue; - /** - * @private - * 标记需要重新布局 - */ - invalidateDisplayList(client: UIComponent): void; - /** - * @private - * 重新布局 - */ - private validateDisplayList(); - /** - * @private - */ - private eventDisplay; - /** - * @private - * 是否已经添加了事件监听 - */ - private listenersAttached; - /** - * @private - * 添加事件监听 - */ - private attachListeners(); - /** - * @private - * 执行属性应用 - */ - private doPhasedInstantiationCallBack(event?); - /** - * @private - * - */ - private doPhasedInstantiation(); - /** - * @private - * 使大于等于指定组件层级的元素立即应用属性 - * @param target 要立即应用属性的组件 - */ - validateClient(target: UIComponent): void; - } -} -declare namespace eui { - /** - * Register a property for a class definition in running, - * so that the EUI can get type of property accurate when parsing a EXML. - * This need not be called directly in most of time. Only when you have a custom UI - * component need to be described in EXML, you may invoke this method explicitly. - * - * Contains no following: - * When the property is the basic data type(boolean, number, string or Array), you only need set a correct initial value - * for he custom property then the EXML parser can get the correct property type in running. - * - * If you can not set the correct initial value (such as null), the EXML parser will treat this property as - * string. If there is no inital value, EUI will throw an error. But you can invoked this method to register - * a property in this case. - * - * - * @param classDefinition The class definition need to be registered. - * @param property The property need to be registered. Note that the property - * name cannot start with "_" or "$". - * @param type The type need to be registered, - * such as “boolean","number","string","Array","egret.Rectangle" and so on. - * @param asDefault Whether register this property as a default property of component. - * One component can register only on default property. And the default property can be spare in an EXML. - * - * @example: - *
      -     *      
      -     *          
      -     *          
      -     *          
      -     *      
      -     * 
      - * Cuz viewport is the default property of Scroller. So you can write as follow: - *
      -     *      
      -     *          
      -     *      
      -     * 
      - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 为一个类定义注册运行时属性类型,以便运行时的EXML文件解析过程能获取准确的属性类型。大多数情况下,您都不需要手动调用此方法显式注册属性类型。 - * 仅当您有一个自定义的 UI 组件,需要在EXML中用标签描述时可能需要显式注册,但以下情况除外: - * 当属性类型为基本数据类型:boolean,number,string,Array这四种其中之一时,您只需要为自定义的属性赋值上正确的初始值, - * 运行时EXML解析器就能通过初始值自动分析出正确的属性类型。 - * 若您无法为属性赋值上正确的初始值时(有初始值,比如null),运行时EXML解析器会把此属性当做string来处理,若完全没有初始值,将会报错找不到节点属性, - * 这种情况下可以手动调用此方法显式注册属性类型。 - * - * @param classDefinition 要注册的类定义。 - * @param property 要注册的属性,注意属性名不能以 _ 或 $ 符开头。 - * @param type 要注册的类型,例如:“boolean","number","string","Array","egret.Rectangle" - * @param asDefault 是否将此属性注册为组件的默认属性,一个组件只可以设置一个默认属性。注册了组件默认属性后,在EXML中可以使用省略属性节点的写法, - * @example: - *
      -     * 
      -     *     
      -     *         
      -     *     
      -     * 
      -     * 
      - * 因为 viewport 已经注册为 Scroller 的默认属性,上面的例子可以等效为: - *
      -     * 
      -     *     
      -     * 
      -     * 
      - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function registerProperty(classDefinition: any, property: string, type: string, asDefault?: boolean): void; -} -declare namespace eui { - /** - * The State class defines a view state, a particular view of a component. - * - * For example, a product thumbnail could have two view states; - * a base view state with minimal information, and a rich view state with - * additional information. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * State 类定义视图状态,即组件的特定视图。 - * - * 例如,产品缩略图可以有两个视图状态,包含最少信息的基本视图状态和包含附加信息的丰富视图状态。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class State extends egret.HashObject { - /** - * Constructor. - * - * @param name The name of the view state. - * State names must be unique for a given component. - * This property must be set. - * @param overrides The overrides for this view state, as an Array of objects that implement - * the IOverride interface. These overrides are applied in order when the - * state is entered, and removed in reverse order when the state is exited. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个State实例。 - * - * @param name 视图状态的名称。给定组件的状态名称必须唯一。必须设置此属性。 - * @param overrides 该视图状态的覆盖,表现为实现 IOverride 接口的对象的数组。 - * 这些覆盖在进入状态时按顺序应用,在退出状态时按相反的顺序删除。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(name: string, overrides?: IOverride[]); - /** - * The name of the view state. - * State names must be unique for a given component. - * This property must be set. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 视图状态的名称。给定组件的状态名称必须唯一。必须设置此属性。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * The overrides for this view state, as an Array of objects that implement - * the IOverride interface. These overrides are applied in order when the - * state is entered, and removed in reverse order when the state is exited. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 该视图状态的覆盖,表现为实现 IOverride 接口的对象的数组。 - * 这些覆盖在进入状态时按顺序应用,在退出状态时按相反的顺序删除。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - overrides: IOverride[]; - /** - * The state groups that this view state belongs to as an array of String. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此视图状态作为 string 数组所属的状态组。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - stateGroups: string[]; - /** - * Initialize this state and all of its overrides. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 初始化视图状态 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - initialize(host: any, stage: egret.Stage): void; - } -} -declare namespace eui.sys { - /** - * @private - */ - class StateClient { - /** - * @private - */ - $stateValues: StateValues; - /** - * @private - * 为此组件定义的视图状态。 - */ - states: eui.State[]; - /** - * @private - * 组件的当前视图状态。将其设置为 "" 或 null 可将组件重置回其基本状态。 - */ - currentState: string; - /** - * @private - * 应用当前的视图状态。子类覆盖此方法在视图状态发生改变时执行相应更新操作。 - */ - private commitCurrentState(); - /** - * @private - * 返回是否含有指定名称的视图状态 - * @param stateName 要检查的视图状态名称 - */ - hasState(stateName: string): boolean; - /** - * @private - * 初始化所有视图状态 - */ - private initializeStates(stage); - } - /** - * @private - */ - class StateValues { - /** - * @private - */ - intialized: boolean; - /** - * @private - */ - statesMap: any; - /** - * @private - */ - states: eui.State[]; - /** - * @private - */ - oldState: string; - /** - * @private - */ - explicitState: string; - /** - * @private - */ - currentState: string; - /** - * @private - */ - parent: egret.DisplayObjectContainer; - /** - * @private - */ - stateIsDirty: boolean; - } -} -declare namespace eui { - function getAssets(source: string, callback: (content: any) => void, thisObject: any): void; - function getTheme(source: string, callback: (content: any) => void): void; - /** - * The UIComponent class is the base class for all visual components, both skinnable and nonskinnable. - * - * @event egret.Event.RESIZE Dispatch when the component is resized. - * @event eui.UIEvent.MOVE Dispatch when the object has moved. - * @event eui.UIEvent.CREATION_COMPLETE Dispatch when the component has finished its construction, - * property processing, measuring, layout, and drawing. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * UIComponent 类是所有可视组件(可定制皮肤和不可定制皮肤)的基类。 - * - * @event egret.Event.RESIZE 当UI组件的尺寸发生改变时调度 - * @event eui.UIEvent.MOVE 当UI组件在父级容器中的位置发生改变时调度 - * @event eui.UIEvent.CREATION_COMPLETE 当UI组件第一次被添加到舞台并完成初始化后调度 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - interface UIComponent extends egret.DisplayObject { - /** - * @private - */ - $UIComponent: Object; - /** - * @private - */ - $includeInLayout: boolean; - /** - * Specifies whether this component is included in the layout of the - * parent container. - * If false, the object size and position are not affected by its parent container's - * layout. - * This value is different with visible. the object size and position is still affected by its parent - * container's layout when the visible is false. - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指定此组件是否包含在父容器的布局中。若为false,则父级容器在测量和布局阶段都忽略此组件。 - * 注意,visible属性与此属性不同,设置visible为false,父级容器仍会对其布局。 - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - includeInLayout: boolean; - /** - * The horizontal distance in pixels from the left edge of the component to the - * anchor target's left edge. - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 距父级容器离左边距离。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - left: any; - /** - * The horizontal distance in pixels from the right edge of the component to the - * anchor target's right edge. - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 距父级容器右边距离。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - right: any; - /** - * The vertical distance in pixels from the top edge of the component to the - * anchor target's top edge. - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 距父级容器顶部距离。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - top: any; - /** - * The vertical distance in pixels from the bottom edge of the component to the - * anchor target's bottom edge. - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 距父级容器底部距离。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - bottom: any; - /** - * The horizontal distance in pixels from the center of the component to the - * center of the anchor target's content area. - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在父级容器中距水平中心位置的距离。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - horizontalCenter: any; - /** - * The vertical distance in pixels from the center of the component to the - * center of the anchor target's content area. - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在父级容器中距竖直中心位置的距离。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - verticalCenter: any; - /** - * Specifies the width of a component as a percentage - * of its parent's size. Allowed values are 0-100. - * Setting the width or explicitWidth properties - * resets this property to NaN. - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 相对父级容器宽度的百分比。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - percentWidth: number; - /** - * Specifies the height of a component as a percentage - * of its parent's size. Allowed values are 0-100. - * Setting the height or explicitHeight properties - * resets this property to NaN. - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 相对父级容器高度的百分比。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - percentHeight: number; - /** - * Number that specifies the explicit width of the component, - * in pixels, in the component's coordinates. - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 外部显式指定的宽度。 - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - readonly explicitWidth: number; - /** - * Number that specifies the explicit height of the component, - * in pixels, in the component's coordinates. - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 外部显式指定的高度。 - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - readonly explicitHeight: number; - /** - * The minimum recommended width of the component to be considered - * by the parent during layout. This value is in the - * component's coordinates, in pixels. The default value depends on - * the component's implementation. - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件的最小宽度,此属性设置为大于maxWidth的值时无效。同时影响测量和自动布局的尺寸。 - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - minWidth: number; - /** - * The maximum recommended width of the component to be considered - * by the parent during layout. This value is in the - * component's coordinates, in pixels. The default value of this property is - * set by the component developer. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件的最大高度。同时影响测量和自动布局的尺寸。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - maxWidth: number; - /** - * The minimum recommended height of the component to be considered - * by the parent during layout. This value is in the - * component's coordinates, in pixels. The default value depends on - * the component's implementation. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件的最小高度,此属性设置为大于maxHeight的值时无效。同时影响测量和自动布局的尺寸。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - minHeight: number; - /** - * The maximum recommended height of the component to be considered - * by the parent during layout. This value is in the - * component's coordinates, in pixels. The default value of this property is - * set by the component developer. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件的最大高度,同时影响测量和自动布局的尺寸。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - maxHeight: number; - /** - * Set the result of measuring. - * @param width measured width - * @param height measured height - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置测量结果。 - * @param width 测量宽度 - * @param height 测量高度 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - setMeasuredSize(width: number, height: number): void; - /** - * Marks a component so that its commitProperties() - * method gets called during a later screen update.

      - * - * Invalidation is a useful mechanism for eliminating duplicate - * work by delaying processing of changes to a component until a - * later screen update.

      - * - * For example, if you want to change the text color and size, - * it would be wasteful to update the color immediately after you - * change it and then update the size when it gets set. - * It is more efficient to change both properties and then render - * the text with its new size and color once.

      - * - * Invalidation methods rarely get called. - * In general, setting a property on a component automatically - * calls the appropriate invalidation method. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 标记提交过需要延迟应用的属性,以便在稍后屏幕更新期间调用该组件的 commitProperties() 方法。

      - * - * 这是一个很有用的机制,可将组件更改延迟到稍后屏幕更新时进行处理,从而消除了重复的工作。

      - * - * 例如,要更改文本颜色和大小,如果在更改颜色后立即进行更新,然后在设置大小后再更新大小,就有些浪费。 - * 同时更改两个属性后再使用新的大小和颜色一次性呈示文本,效率会更高。

      - * - * 很少调用 Invalidation 方法。通常,在组件上设置属性会自动调用合适的 invalidation 方法。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - invalidateProperties(): void; - /** - * Used by layout logic to validate the properties of a component - * by calling the commitProperties() method. - * In general, subclassers should - * override the commitProperties() method and not this method. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 由布局逻辑用于通过调用 commitProperties() 方法来验证组件的属性。 - * 通常,子类应覆盖 commitProperties() 方法,而不是覆盖此方法。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - validateProperties(): void; - /** - * Marks a component so that its measure() - * method gets called during a later screen update.

      - * - * Invalidation is a useful mechanism for eliminating duplicate - * work by delaying processing of changes to a component until a - * later screen update.

      - * - * For example, if you want to change the text and font size, - * it would be wasteful to update the text immediately after you - * change it and then update the size when it gets set. - * It is more efficient to change both properties and then render - * the text with its new size once.

      - * - * Invalidation methods rarely get called. - * In general, setting a property on a component automatically - * calls the appropriate invalidation method. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 标记提交过需要验证组件尺寸,以便在稍后屏幕更新期间调用该组件的 measure() 方法。

      - * - * Invalidation 是一个很有用的机制,可将组件更改延迟到稍后屏幕更新时进行处理,从而消除了重复的工作。

      - * - * 例如,要更改文本和字体大小,如果在更改文本后立即进行更新,然后在设置大小后再更新大小,就有些浪费。 - * 更改两个属性后再使用新的大小一次性呈示文本,效率会更高。

      - * - * 很少调用 Invalidation 方法。通常,在组件上设置属性会自动调用合适的 invalidation 方法。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - invalidateSize(): void; - /** - * Validates the measured size of the component. - * @param recursive If true, call this method - * on the objects children. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 验证组件的尺寸。 - * @param recursive 如果为 true,则调用对象子项的此方法。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - validateSize(recursive?: boolean): void; - /** - * Marks a component so that its updateDisplayList() - * method gets called during a later screen update.

      - * - * Invalidation is a useful mechanism for eliminating duplicate - * work by delaying processing of changes to a component until a - * later screen update.

      - * - * For example, if you want to change the width and height, - * it would be wasteful to update the component immediately after you - * change the width and then update again with the new height. - * It is more efficient to change both properties and then render - * the component with its new size once.

      - * - * Invalidation methods rarely get called. - * In general, setting a property on a component automatically - * calls the appropriate invalidation method. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 标记需要验证显示列表,以便在稍后屏幕更新期间调用该组件的 updateDisplayList() 方法。

      - * - * Invalidation 是一个很有用的机制,可将组件更改延迟到稍后屏幕更新时进行处理,从而消除了重复的工作。

      - * - * 例如,要更改宽度和高度,如果在更改宽度后立即更新组件,然后在设置新高度后再次更新组件,就有些浪费。 - * 更改两个属性后再使用新的大小一次性呈示组件,效率会更高。

      - * - * 很少调用 Invalidation 方法。通常,在组件上设置属性会自动调用合适的 invalidation 方法。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - invalidateDisplayList(): void; - /** - * Validates the position and size of children and draws other - * visuals. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 验证子项的位置和大小,并绘制其他可视内容。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - validateDisplayList(): void; - /** - * Validate and update the properties and layout of this object - * and redraw it, if necessary.

      - * - * Processing properties that require substantial computation are normally - * not processed until the script finishes executing.

      - * - * For example setting the width property is delayed, because it can - * require recalculating the widths of the objects children or its parent. - * Delaying the processing prevents it from being repeated - * multiple times if the script sets the width property more than once. - * This method lets you manually override this behavior. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 验证并更新此对象的属性和布局,如果需要的话重绘对象。

      - * - * 通常只有当脚本执行完毕后,才会处理要求进行大量计算的处理属性。

      - * - * 例如,对 width 属性的设置可能会延迟,因为此设置需要重新计算这些对象的子项或父项的宽度。 - * 如果脚本多次设置了 width 属性,则延迟处理可防止进行多次处理。此方法允许您手动覆盖此行为。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - validateNow(): void; - /** - * Sets the layout size of the element. - * This is the size that the element uses to draw on screen.

      - * - * If the width and/or height parameters are left unspecified (NaN), - * EUI sets the element's layout size to its preferred width and/or preferred height.

      - * - * Note that calls to the setLayoutBoundSize() method can affect the layout position, so - * call setLayoutBoundPosition() after calling setLayoutBoundSize().

      - * - * @param layoutWidth The element's layout width. - * @param layoutHeight The element's layout height. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置元素的布局大小。这是元素在屏幕上进行绘制时所用的大小。

      - * - * 如果 width 和/或 height 参数尚未指定 (NaN)),则 EUI 会将该元素的布局大小设置为首选宽度和/或首选高度。

      - * - * 请注意,调用 setLayoutBoundSize() 方法会影响布局位置,因此请在调用 setLayoutBoundSize() - * 之后再调用 setLayoutBoundPosition()。 - * - * @param layoutWidth 元素的布局宽度。 - * @param layoutHeight 元素的布局高度。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - setLayoutBoundsSize(layoutWidth: number, layoutHeight: number): void; - /** - * Sets the coordinates that the element uses to draw on screen.

      - * - * Note that calls to the setLayoutBoundSize() method can affect the layout position, so - * call setLayoutBoundPosition() after calling setLayoutBoundSize().

      - * - * @param x The x-coordinate of the top-left corner of the bounding box. - * @param y The y-coordinate of the top-left corner of the bounding box. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置元素在屏幕上进行绘制时所用的布局坐标。

      - * - * 请注意,调用 setLayoutBoundSize() 方法会影响布局位置,因此请在调用 setLayoutBoundSize() - * 之后再调用 setLayoutBoundPosition()。 - * - * @param x 边框左上角的 X 坐标。 - * @param y 边框左上角的 Y 坐标。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - setLayoutBoundsPosition(x: number, y: number): void; - /** - * Get the layout bounds that the element uses to draw on screen. - * Commonly used in the updateDisplayList() method in parent container.

      - * Priority: layout > explicit > measure.

      - * The result of this method is contains scale and rotation. - * - * @param bounds the instance of egret.Rectangle can set result. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件的布局尺寸,常用于父级的updateDisplayList()方法中。

      - * 按照:布局尺寸>外部显式设置尺寸>测量尺寸 的优先级顺序返回尺寸。

      - * 注意此方法返回值已经包含scale和rotation。 - * - * @param bounds 可以放置结果的egret.Rectangle实例。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - getLayoutBounds(bounds: egret.Rectangle): void; - /** - * Get the element's preferred bounds。 - * Commonly used in the measure() method in parent container.

      - * Priority: explicit > measure.

      - * The result of this method is contains scale and rotation. - * - * @param bounds the instance of egret.Rectangle can set result. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取组件的首选尺寸,常用于父级的measure()方法中。

      - * 按照:外部显式设置尺寸>测量尺寸 的优先级顺序返回尺寸。

      - * 注意此方法返回值已经包含scale和rotation。 - * - * @param bounds 可以放置结果的egret.Rectangle实例。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - getPreferredBounds(bounds: egret.Rectangle): void; - } -} -declare namespace eui.sys { - /** - * @private - */ - const enum UIKeys { - left = 0, - right = 1, - top = 2, - bottom = 3, - horizontalCenter = 4, - verticalCenter = 5, - percentWidth = 6, - percentHeight = 7, - explicitWidth = 8, - explicitHeight = 9, - width = 10, - height = 11, - minWidth = 12, - maxWidth = 13, - minHeight = 14, - maxHeight = 15, - measuredWidth = 16, - measuredHeight = 17, - oldPreferWidth = 18, - oldPreferHeight = 19, - oldX = 20, - oldY = 21, - oldWidth = 22, - oldHeight = 23, - invalidatePropertiesFlag = 24, - invalidateSizeFlag = 25, - invalidateDisplayListFlag = 26, - layoutWidthExplicitlySet = 27, - layoutHeightExplicitlySet = 28, - initialized = 29, - } - /** - * @private - * EUI 显示对象基类模板。仅作为 UIComponent 的默认实现,为egret.sys.implemenetUIComponenet()方法提供代码模板。 - * 注意:在此类里不允许直接使用super关键字访问父类方法。一律使用this.$super属性访问。 - */ - class UIComponentImpl extends egret.DisplayObject implements eui.UIComponent { - /** - * @private - * 构造函数 - */ - constructor(); - /** - * @private - * UIComponentImpl 定义的所有变量请不要添加任何初始值,必须统一在此处初始化。 - */ - private initializeUIValues(); - /** - * @private - * 子类覆盖此方法可以执行一些初始化子项操作。此方法仅在组件第一次添加到舞台时回调一次。 - * 请务必调用super.createChildren()以完成父类组件的初始化 - */ - protected createChildren(): void; - /** - * @private - * 子项创建完成,此方法在createChildren()之后执行。 - */ - protected childrenCreated(): void; - /** - * @private - * 提交属性,子类在调用完invalidateProperties()方法后,应覆盖此方法以应用属性 - */ - protected commitProperties(): void; - /** - * @private - * 测量组件尺寸 - */ - protected measure(): void; - /** - * @private - * 更新显示列表 - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - $super: any; - $UIComponent: Object; - $includeInLayout: boolean; - /** - * @private - * 指定此组件是否包含在父容器的布局中。若为false,则父级容器在测量和布局阶段都忽略此组件。默认值为true。 - * 注意,visible属性与此属性不同,设置visible为false,父级容器仍会对其布局。 - */ - includeInLayout: boolean; - /** - * @private - * - * @param stage - * @param nestLevel - */ - $onAddToStage(stage: egret.Stage, nestLevel: number): void; - /** - * @private - * 检查属性失效标记并应用 - */ - private checkInvalidateFlag(event?); - /** - * @private - * 距父级容器离左边距离 - */ - left: any; - /** - * @private - * 距父级容器右边距离 - */ - right: any; - /** - * @private - * 距父级容器顶部距离 - */ - top: any; - /** - * @private - * 距父级容器底部距离 - */ - bottom: any; - /** - * @private - * 在父级容器中距水平中心位置的距离 - */ - horizontalCenter: any; - /** - * @private - * 在父级容器中距竖直中心位置的距离 - */ - verticalCenter: any; - /** - * @private - * 相对父级容器宽度的百分比 - */ - percentWidth: number; - /** - * @private - * 相对父级容器高度的百分比 - */ - percentHeight: number; - /** - * @private - * 外部显式指定的宽度 - */ - readonly explicitWidth: number; - /** - * @private - * 外部显式指定的高度 - */ - readonly explicitHeight: number; - /** - * @private - * 组件宽度,默认值为egret.NaN,设置为NaN将使用组件的measure()方法自动计算尺寸 - */ - $getWidth(): number; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * 立即验证自身的尺寸。 - */ - private validateSizeNow(); - /** - * @private - * 组件高度,默认值为NaN,设置为NaN将使用组件的measure()方法自动计算尺寸 - */ - $getHeight(): number; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * 组件的最小宽度,此属性设置为大于maxWidth的值时无效。同时影响测量和自动布局的尺寸。 - */ - minWidth: number; - /** - * @private - * 组件的最大高度。同时影响测量和自动布局的尺寸。 - */ - maxWidth: number; - /** - * @private - * 组件的最小高度,此属性设置为大于maxHeight的值时无效。同时影响测量和自动布局的尺寸。 - */ - minHeight: number; - /** - * @private - * 组件的最大高度,同时影响测量和自动布局的尺寸。 - */ - maxHeight: number; - /** - * @private - * 设置测量结果。 - * @param width 测量宽度 - * @param height 测量高度 - */ - setMeasuredSize(width: number, height: number): void; - /** - * @private - * 设置组件的宽高。此方法不同于直接设置width,height属性, - * 不会影响显式标记尺寸属性 - */ - private setActualSize(w, h); - /** - * @private - */ - protected $updateUseTransform(): void; - /** - * @private - */ - $setMatrix(matrix: egret.Matrix, needUpdateProperties?: boolean): boolean; - /** - * @private - */ - $setAnchorOffsetX(value: number): boolean; - /** - * @private - */ - $setAnchorOffsetY(value: number): boolean; - /** - * @private - * - * @param value - * @returns - */ - $setX(value: number): boolean; - /** - * @private - * - * @param value - * @returns - */ - $setY(value: number): boolean; - /** - * @private - * 标记属性失效 - */ - invalidateProperties(): void; - /** - * @private - * 验证组件的属性 - */ - validateProperties(): void; - /** - * @private - * 标记提交过需要验证组件尺寸 - */ - invalidateSize(): void; - /** - * @private - * 验证组件的尺寸 - */ - validateSize(recursive?: boolean): void; - /** - * @private - * 测量组件尺寸,返回尺寸是否发生变化 - */ - private measureSizes(); - /** - * @private - * 标记需要验证显示列表 - */ - invalidateDisplayList(): void; - /** - * @private - * 验证子项的位置和大小,并绘制其他可视内容 - */ - validateDisplayList(): void; - /** - * @private - * 更新最终的组件宽高 - */ - private updateFinalSize(); - /** - * @private - * 立即应用组件及其子项的所有属性 - */ - validateNow(): void; - /** - * @private - * 标记父级容器的尺寸和显示列表为失效 - */ - protected invalidateParentLayout(): void; - /** - * @private - * 设置组件的布局宽高 - */ - setLayoutBoundsSize(layoutWidth: number, layoutHeight: number): void; - /** - * @private - * 设置组件的布局位置 - */ - setLayoutBoundsPosition(x: number, y: number): void; - /** - * @private - * 组件的布局尺寸,常用于父级的updateDisplayList()方法中 - * 按照:布局尺寸>外部显式设置尺寸>测量尺寸 的优先级顺序返回尺寸, - * 注意此方法返回值已经包含scale和rotation。 - */ - getLayoutBounds(bounds: egret.Rectangle): void; - /** - * @private - * - * @returns - */ - private getPreferredUWidth(); - /** - * @private - * - * @returns - */ - private getPreferredUHeight(); - /** - * @private - * 获取组件的首选尺寸,常用于父级的measure()方法中 - * 按照:外部显式设置尺寸>测量尺寸 的优先级顺序返回尺寸, - * 注意此方法返回值已经包含scale和rotation。 - */ - getPreferredBounds(bounds: egret.Rectangle): void; - /** - * @private - */ - private applyMatrix(bounds, w, h); - /** - * @private - */ - private getAnchorMatrix(); - } - /** - * @private - * 拷贝模板类的方法体和属性到目标类上。 - * @param target 目标类 - * @param template 模板类 - */ - function mixin(target: any, template: any): void; - /** - * @private - * 自定义类实现UIComponent的步骤: - * 1.在自定义类的构造函数里调用:this.initializeUIValues(); - * 2.拷贝UIComponent接口定义的所有内容(包括注释掉的protected函数)到自定义类,将所有子类需要覆盖的方法都声明为空方法体。 - * 3.在定义类结尾的外部调用sys.implementUIComponent(),并传入自定义类。 - * 4.若覆盖了某个UIComponent的方法,需要手动调用UIComponentImpl.prototype["方法名"].call(this); - * @param descendant 自定义的UIComponent子类 - * @param base 自定义子类继承的父类 - */ - function implementUIComponent(descendant: any, base: any, isContainer?: boolean): void; -} -declare namespace eui { - /** - * The Group class is defines the base class for layout component. - * If the contents of the sub items are too large to scroll to show, you can wrap a Scroller component outside the - * group (Give the instance of Group to viewport property of Scroller component). - * The scroller component can adds a scrolling touch operation for the Group. - * - * @see http://edn.egret.com/cn/article/index/id/608 Simple container - * @defaultProperty elementsContent - * @includeExample extension/eui/components/GroupExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * Group 是自动布局的容器基类。如果包含的子项内容太大需要滚动显示,可以在在 Group 外部包裹一层 Scroller 组件 - * (将 Group 实例赋值给 Scroller 组件的 viewport 属性)。Scroller 会为 Group 添加滚动的触摸操作功能,并显示垂直或水平的滚动条。 - * - * @see http://edn.egret.com/cn/article/index/id/608 简单容器 - * @defaultProperty elementsContent - * @includeExample extension/eui/components/GroupExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class Group extends egret.DisplayObjectContainer implements IViewport { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - $Group: Object; - /** - * This property is Usually invoked in resolving an EXML for adding multiple children quickly. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此属性通常在 EXML 的解析器中调用,便于快速添加多个子项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - elementsContent: egret.DisplayObject[]; - /** - * @private - */ - $layout: LayoutBase; - /** - * The layout object for this container. - * This object is responsible for the measurement and layout of - * the UIcomponent in the container. - * - * @default eui.BasicLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此容器的布局对象。 - * - * s@default eui.BasicLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - layout: LayoutBase; - /** - * @private - * - * @param value - */ - $setLayout(value: LayoutBase): boolean; - /** - * @copy eui.IViewport#contentWidth - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - readonly contentWidth: number; - /** - * @copy eui.IViewport#contentHeight - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - readonly contentHeight: number; - /** - * - * Sets the contentWidth and contentHeight - * properties. - * - * This method is intended for layout class developers who should - * call it from updateDisplayList() methods. - * - * @param width The new value of contentWidth. - * @param height The new value of contentHeight. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * - * 设置 contentWidthcontentHeight 属性。 - * 此方法由布局来调用,开发者应该在布局类的 updateDisplayList() 方法中对其进行调用。 - * - * @param width contentWidth 的新值。 - * @param height contentHeight 的新值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - setContentSize(width: number, height: number): void; - /** - * @copy eui.IViewport#scrollEnabled - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - scrollEnabled: boolean; - /** - * @copy eui.IViewport#scrollH - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - scrollH: number; - /** - * @copy eui.IViewport#scrollV - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - scrollV: number; - /** - * @private - * - * @returns - */ - private updateScrollRect(); - /** - * The number of layout element in this container. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 布局元素子项的数量。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - readonly numElements: number; - /** - * Returns the layout element at the specified index. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个布局元素子项。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - getElementAt(index: number): egret.DisplayObject; - getVirtualElementAt(index: number): egret.DisplayObject; - /** - * Set the index range of the sub Visual element in container which support virtual layout. - * This method is invalid in container which do not support virtual layout. - * This method is usually invoked before layout. Override this method to release the invisible elements. - * - * @param startIndex the start index of sub visual elements(include) - * @param endIndex the end index of sub visual elements(include) - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在支持虚拟布局的容器中,设置容器内可见的子元素索引范围。此方法在不支持虚拟布局的容器中无效。 - * 通常在即将重新布局子项之前会被调用一次,容器覆盖此方法提前释放已经不可见的子元素。 - * - * @param startIndex 可视元素起始索引(包括) - * @param endIndex 可视元素结束索引(包括) - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - setVirtualElementIndicesInView(startIndex: number, endIndex: number): void; - /** - * When true, this property - * ensures that the entire bounds of the Group respond to - * touch events such as begin. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触摸组件的背景透明区域是否可以穿透。设置为true表示可以穿透,反之透明区域也会响应触摸事件。默认 false。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - touchThrough: boolean; - /** - * @private - */ - $hitTest(stageX: number, stageY: number): egret.DisplayObject; - /** - * @private - */ - $stateValues: sys.StateValues; - /** - * The list of state for this component. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 为此组件定义的视图状态。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - states: State[]; - /** - * @copy eui.Component#currentState - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - currentState: string; - /** - * @copy eui.Skin#hasState() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - hasState: (stateName: string) => boolean; - /** - * @private - * 初始化所有视图状态 - */ - private initializeStates; - /** - * @private - * 应用当前的视图状态。子类覆盖此方法在视图状态发生改变时执行相应更新操作。 - */ - private commitCurrentState; - /** - * @copy eui.Component#invalidateState() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateState(): void; - /** - * @copy eui.Component#getCurrentState() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getCurrentState(): string; - /** - * @private - * UIComponentImpl 定义的所有变量请不要添加任何初始值,必须统一在此处初始化。 - */ - private initializeUIValues; - /** - * @copy eui.Component#createChildren() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected createChildren(): void; - /** - * @copy eui.Component#childrenCreated() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected childrenCreated(): void; - /** - * @copy eui.Component#commitProperties() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected commitProperties(): void; - /** - * @copy eui.Component#measure() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected measure(): void; - /** - * @copy eui.Component#updateDisplayList() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * @copy eui.Component#invalidateParentLayout() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected invalidateParentLayout(): void; - /** - * @private - */ - $UIComponent: Object; - /** - * @private - */ - $includeInLayout: boolean; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - includeInLayout: boolean; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - left: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - right: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - top: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - bottom: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - horizontalCenter: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - verticalCenter: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setMeasuredSize(width: number, height: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateSize(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateSize(recursive?: boolean): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateNow(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsSize(layoutWidth: number, layoutHeight: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsPosition(x: number, y: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getLayoutBounds(bounds: egret.Rectangle): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getPreferredBounds(bounds: egret.Rectangle): void; - } -} -declare namespace eui { - /** - * Register a property of an instance is can be bound. - * This method is ususally invoked by Watcher class. - * - * @param instance the instance to be registered. - * @param property the property of specified instance to be registered. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 标记实例的一个属性是可绑定的,此方法通常由 Watcher 类调用。 - * - * @param instance 要标记的实例 - * @param property 可绑定的属性。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function registerBindable(instance: any, property: string): void; -} -declare namespace eui.sys { - /** - * @private - */ - const enum ComponentKeys { - hostComponentKey = 0, - skinName = 1, - explicitState = 2, - enabled = 3, - stateIsDirty = 4, - skinNameExplicitlySet = 5, - explicitTouchChildren = 6, - explicitTouchEnabled = 7, - skin = 8, - } -} -declare namespace eui { - /** - * The Component class defines the base class for skinnable components. - * The skins used by a Component class are typically child classes of - * the Skin class.

      - * - * Associate a skin class with a component class by setting the skinName property of the - * component class. - * @event egret.Event.COMPLETE Dispatch when skinName property is set the path of external EXML file and the EXML file is resolved. - * - * @includeExample extension/eui/components/ComponentExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * Component 类定义可设置外观的组件的基类。Component 类所使用的外观通常是 Skin 类的子类。

      - * 通过设置 component 类的 skinName 属性,将 skin 类与 component 类相关联。 - * @event egret.Event.COMPLETE 当设置skinName为外部exml文件路径时,加载并完成EXML解析后调度。 - * - * @includeExample extension/eui/components/ComponentExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class Component extends egret.DisplayObjectContainer implements UIComponent { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - $Component: Object; - /** - * A identifier of host component which can determine only one component names. - * Usually used for quering a default skin name in theme. - * @default null - * @see eui.Theme#getSkinName() - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 主机组件标识符。用于唯一确定一个组件的名称。通常用于在主题中查询默认皮肤名。 - * - * @default null - * @see eui.Theme#getSkinName() - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - hostComponentKey: string; - /** - * Identifier of skin. Valid values: class definition of skin, - * class name of skin, instance of skin, EXML or external EXML file path. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤标识符。有效值可为:皮肤类定义,皮肤类名,皮肤实例,EXML文件内容,或外部EXML文件路径, - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - skinName: any; - /** - * @private - * 解析skinName - */ - $parseSkinName(): void; - /** - * @private - * @param clazz - * @param url - */ - private onExmlLoaded(clazz, url); - /** - * The instance of the skin class for this component instance. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤对象实例。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - readonly skin: Skin; - /** - * Setter for the skin instance. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置皮肤实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected setSkin(skin: Skin): void; - /** - * Find the skin parts in the skin class and assign them to the properties of the component. - * You do not call this method directly. This method will be invoked automatically when using a EXML as skin. - * The ID for a tag in an EXML will be passed in as partName, and the instance of the tag will be - * passed in as instance. - * @param partName name of a skin part - * @param instance instance of a skin part - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 关联一个对象到逻辑组件的指定皮肤部件上。通常您不需要手动调用此方法,当使用EXML文件作为组件皮肤,此方法将会被自动调用。 - * 在运行时,EXML文件内声明的id名称将作为此方法的partName参数,而id所对应的节点对象,将作为此方法的instance参数被依次传入。 - * @param partName 皮肤部件名称 - * @param instance 皮肤部件实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - setSkinPart(partName: string, instance: any): void; - /** - * Called when a skin part is added. - * You do not call this method directly. - * EUI calls it automatically when it calls the setSkinPart() method.

      - * - * Override this function to attach behavior to the part, such as add event listener or - * assign property values cached. - * @param partName name of a skin part to add. - * @param instance instance of a skin part to add. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 添加皮肤部件时调用。 - * 您无需直接调用此方法。 - * EUI 会在调用 setSkinPart()方法时自动调用此方法。

      - * - * 子类覆盖此方法,以在皮肤部件第一次附加时对其执行一些初始化操作,例如添加事件监听,赋值缓存的属性值等。 - * @param partName 要附加的皮肤部件名称。 - * @param instance 要附加的皮肤部件实例。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected partAdded(partName: string, instance: any): void; - /** - * Called when an instance of a skin part is being removed. - * You do not call this method directly. - * EUI calls it automatically when it calls the setSkinPart() method.

      - * - * Override this function to clean behavior of the part, such as remove event listener or - * disconnect the cache reference - * @param partName name of a skin part to remove. - * @param instance instance of a skin part to remove. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 正删除外观部件的实例时调用。 - * 您无需直接调用此方法。 - * EUI 会在调用 setSkinPart()方法时自动调用此方法。

      - * - * 子类覆盖此方法,以在皮肤部件从逻辑组件卸载时对其执行一些清理操作,例如移除事件监听,断开缓存的引用等。 - * @param partName 要卸载的皮肤部件名称 - * @param instance 要卸载的皮肤部件实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected partRemoved(partName: string, instance: any): void; - /** - * @private - * - * @param value - */ - $setTouchChildren(value: boolean): boolean; - /** - * @private - * - * @param value - */ - $setTouchEnabled(value: boolean): void; - /** - * Whether the component can accept user interaction. - * After setting the enabled property to false, components will disabled touch event - * (set touchEnabled and touchChildren to false) and set state of skin to "disabled". - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件是否可以接受用户交互。 - * 将 enabled 属性设置为 false 后, - * 组件会自动禁用触摸事件(将 touchEnabled 和 touchChildren 同时设置为 false), - * 部分组件可能还会将皮肤的视图状态设置为"disabled",使其所有子项的颜色变暗。 - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - enabled: boolean; - /** - * @private - * - * @param value - */ - $setEnabled(value: boolean): boolean; - /** - * The current view state of the component. When you use this property to set a component's state, - * EUI will explicit update state of skin and ignore the return of getCurrentState(). - * - * Set to "" or null to reset the component back to its base state. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件的当前视图状态。显式设置此属性, - * 将采用显式设置的值去更新皮肤状态,而忽略组件内部 getCurrentState() 方法返回的值。 - * - * 将其设置为 "" 或 null 可将取消组件外部显式设置的视图状态名称,从而采用内部 getCurrentState() 方法返回的状态。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - currentState: string; - /** - * Marks the component so that the new state of the skin is set during a later screen update. - * A subclass of SkinnableComponent must override getCurrentState() to return a value. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 标记组件当前的视图状态失效,调用此方法后,子类应该覆盖 getCurrentState() 方法来返回当前的视图状态名称。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - invalidateState(): void; - /** - * Returns the name of the state to be applied to the skin.

      - * A subclass of SkinnableComponent must override this method to return a value. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 返回组件当前的皮肤状态名称,子类覆盖此方法定义各种状态名 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected getCurrentState(): string; - /** - * @private - * UIComponentImpl 定义的所有变量请不要添加任何初始值,必须统一在此处初始化。 - */ - private initializeUIValues; - /** - * Create child objects of the component. This is an advanced method that you might override - * when creating a subclass of Component. This method will be called once it be added to stage. - * You must invoke super.createChildren() to complete initialization of the parent class - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 子类覆盖此方法可以执行一些初始化子项操作。此方法仅在组件第一次添加到舞台时回调一次。 - * 请务必调用super.createChildren()以完成父类组件的初始化 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected createChildren(): void; - /** - * Performs any final processing after child objects are created. - * This is an advanced method that you might override - * when creating a subclass of Component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建子对象后执行任何最终处理。此方法在创建 Component 的子类时覆盖。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected childrenCreated(): void; - /** - * Processes the properties set on the component. - * You can override this method when creating a subclass of Component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 提交属性,子类在调用完invalidateProperties()方法后,应覆盖此方法以应用属性 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected commitProperties(): void; - /** - * Calculates the default size. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 测量组件尺寸 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected measure(): void; - /** - * Draws the object and/or sizes and positions its children. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 更新显示列表 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * Method to invalidate parent size and display list if - * this object affects its layout (includeInLayout is true). - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此对象影响其布局时(includeInLayout 为 true),使父代大小和显示列表失效的方法。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected invalidateParentLayout(): void; - /** - * @private - */ - $UIComponent: Object; - /** - * @private - */ - $includeInLayout: boolean; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - includeInLayout: boolean; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - left: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - right: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - top: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - bottom: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - horizontalCenter: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - verticalCenter: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setMeasuredSize(width: number, height: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateSize(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateSize(recursive?: boolean): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateNow(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsSize(layoutWidth: number, layoutHeight: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsPosition(x: number, y: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getLayoutBounds(bounds: egret.Rectangle): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getPreferredBounds(bounds: egret.Rectangle): void; - } -} -declare namespace eui { - /** - * The DataGroup class is the base container class for data items. - * The DataGroup class converts data items to visual elements for display. - * While this container can hold visual elements, it is often used only - * to hold data items as children. - * - * @see eui.Group - * @see http://edn.egret.com/cn/article/index/id/527 Data container - * @see http://edn.egret.com/cn/article/index/id/528 Array collection - * @defaultProperty dataProvider - * @includeExample extension/eui/components/DataGroupExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * DataGroup 类将数据项目转换为可视元素以进行显示。 - * 尽管此容器可以包含可视元素,但它通常仅用于包含作为子项的数据项目。 - * - * @see eui.Group - * @see http://edn.egret.com/cn/article/index/id/527 数据容器 - * @see http://edn.egret.com/cn/article/index/id/528 数组集合 - * @defaultProperty dataProvider - * @includeExample extension/eui/components/DataGroupExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class DataGroup extends Group { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - $DataGroup: Object; - /** - * @copy eui.LayoutBase#useVirtualLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - useVirtualLayout: boolean; - /** - * @private - * - * @param value - */ - $setLayout(value: LayoutBase): boolean; - /** - * @private - * 是否使用虚拟布局标记改变 - */ - private onUseVirtualLayoutChanged(event?); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setVirtualElementIndicesInView(startIndex: number, endIndex: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getElementAt(index: number): egret.DisplayObject; - /** - * @inheritDoc - * - * @version Egret 2.5.2 - * @version eui 1.0 - * @platform Web,Native - */ - getVirtualElementAt(index: number): UIComponent; - /** - * @private - * 释放指定索引处的项呈示器 - */ - private freeRendererByIndex(index); - /** - * @private - * - * @param renderer - */ - private doFreeRenderer(renderer); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateSize(): void; - /** - * @private - * 为指定索引创建虚拟的项呈示器 - */ - private createVirtualRenderer(item); - /** - * @private - * 根据rendererClass创建一个Renderer,并添加到显示列表 - */ - private createOneRenderer(rendererClass); - /** - * @private - * 设置项呈示器的默认皮肤 - */ - private setItemRenderSkinName(renderer, skinName); - /** - * @private - */ - $dataProviderChanged: boolean; - /** - * @private - */ - $dataProvider: ICollection; - /** - * The data provider for this DataGroup. - * It must be an ICollection, such as ArrayCollection - * - * @see eui.ICollection - * @see eui.ArrayCollection - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 列表数据源,请使用实现了ICollection接口的数据类型,例如 ArrayCollection - * - * @see eui.ICollection - * @see eui.ArrayCollection - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - dataProvider: ICollection; - /** - * @private - * - * @param value - */ - $setDataProvider(value: ICollection): boolean; - /** - * @private - * 移除数据源监听 - */ - private removeDataProviderListener(); - /** - * Called when contents within the dataProvider changes. We will catch certain - * events and update our children based on that. - * - * @param event 事件eui.CollectionEvent的对象。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据源改变事件处理。 - * - * @param event 事件eui.CollectionEvent的对象。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onCollectionChange(event: CollectionEvent): void; - /** - * @private - * 数据源添加项目事件处理 - */ - private itemAddedHandler(items, index); - /** - * @private - * 数据源移除项目事件处理 - */ - private itemRemovedHandler(items, location); - /** - * Adds the item for the specified dataProvider item to this DataGroup. - * - * This method is called as needed by the DataGroup implementation, - * it should not be called directly. - * - * @param item The item that was added, the value of dataProvider[index]. - * @param index The index where the dataProvider item was added. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 添加一个指定的数据到数据源。 - * - * 这个方法不应该由开发者直接调用,而用于本类自动内调用。 - * - * @param item 添加的数据项。 - * @param index 被添加到的索引。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected itemAdded(item: any, index: number): void; - /** - * Removes the itemRenderer for the specified dataProvider item from this DataGroup. - * - * This method is called as needed by the DataGroup implementation, - * it should not be called directly. - * - * @param item The item that is being removed. - * @param index The index of the item that is being removed. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 删除数据源中指定的项。 - * - * 这个方法不应该由开发者直接调用,而用于本类自动内调用。 - * - * @param item 移除的数据项。 - * @param index 被移除的索引。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected itemRemoved(item: any, index: number): void; - /** - * @private - * 更新当前所有项的索引 - */ - private resetRenderersIndices(); - /** - * @private - * 数据源更新或替换项目事件处理 - */ - private itemUpdatedHandler(item, location); - /** - * @private - * 调整指定项呈示器的索引值 - */ - private resetRendererItemIndex(index); - /** - * The item renderer to use for data items. - * The class must implement the IItemRenderer interface. - * If defined, the itemRendererFunction property - * takes precedence over this property. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 用于数据项目的项呈示器。您应该直接为此属性赋值自定义类的类定义,而不是一个实例。注意:该类必须实现 IItemRenderer 接口。
      - * rendererClass获取顺序:itemRendererFunction > itemRenderer > 默认ItemRenerer。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - itemRenderer: any; - /** - * The skinName property of the itemRenderer.This property will be passed to itemRenderer.skinName as default value,if you - * did not set it explicitly.
      - * Note: This property is invalid if the itemRenderer is not a subclass of the Component class. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 条目渲染器的可选皮肤标识符。在实例化itemRenderer时,若其内部没有设置过skinName,则将此属性的值赋值给它的skinName。 - * 注意:若 itemRenderer 不是 Component 的子类,则此属性无效。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - itemRendererSkinName: any; - /** - * Function that returns an item renderer for a - * specific item. - * - * If defined, this property - * takes precedence over the itemRenderer property. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 为某个特定数据项返回一个项呈示器类定义的函数。 - * rendererClass获取顺序:itemRendererFunction > itemRenderer > 默认ItemRenerer。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - itemRendererFunction: (item: any) => any; - /** - * @private - * 为特定的数据项返回项呈示器的工厂实例 - */ - private itemToRendererClass(item); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected createChildren(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected commitProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected measure(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * @private - * 确保测量过默认条目大小。 - */ - private ensureTypicalLayoutElement(); - /** - * @private - * 测量项呈示器默认尺寸 - */ - private measureRendererSize(); - /** - * @private - * 设置项目默认大小 - */ - private setTypicalLayoutRect(rect); - /** - * @private - * 索引到项呈示器的转换数组 - */ - $indexToRenderer: IItemRenderer[]; - /** - * @private - * 移除所有项呈示器 - */ - private removeAllRenderers(); - /** - * @private - * 为数据项创建项呈示器 - */ - private createRenderers(); - /** - * Updates the renderer for reuse. - * This method first prepares the item - * renderer for reuse by cleaning out any stale properties - * as well as updating it with new properties.

      - * - * The last thing this method should do is set the data property - * of the item renderer. - * - * @param renderer The item renderer. - * @param itemIndex The index of the data in the data provider. - * @param data The data object this item renderer is representing. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此方法首先会准备项呈示器以重用,方法是清除任何旧属性,同时使用新属性进行更新。

      - * - * 最后,此方法应对项呈示器设置 data 属性。 - * - * @param renderer 项呈示器。 - * @param itemIndex 数据提供程序中的数据索引。 - * @param data 此项呈示器正在表示的数据对象。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - updateRenderer(renderer: IItemRenderer, itemIndex: number, data: any): IItemRenderer; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - readonly numElements: number; - /** - * Adds the itemRenderer for the specified dataProvider item to this DataGroup. - * - * This method is called as needed by the DataGroup implementation, - * it should not be called directly. - * - * @param renderer The renderer that was added. - * @param index The index where the dataProvider item was added. - * @param item The item that was added, the value of dataProvider[index]. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 项呈示器被添加. - * - * 这个方法不能直接调用,它是由该类自身自动调用的。 - * - * @param renderer 添加的项呈示器 - * @param index 项呈示器的索引 - * @param item 项呈示器对应的数据 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected rendererAdded(renderer: IItemRenderer, index: number, item: any): void; - /** - * Removes the itemRenderer for the specified dataProvider item from this DataGroup. - * - * This method is called as needed by the DataGroup implementation, - * it should not be called directly. - * - * @param renderer The renderer that is being removed. - * @param index The index of the item that is being removed. - * @param item The item that is being removed. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 项呈示器被移除。 - * 这个方法不能直接调用,它是由该类自身自动调用的。 - * - * @param renderer 移除的项呈示器 - * @param index 项呈示器的索引 - * @param item 项呈示器对应的数据 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected rendererRemoved(renderer: IItemRenderer, index: number, item: any): void; - } -} -declare namespace eui { - /** - * The Button component is a commonly used rectangular button. - * The Button component looks like it can be pressed. - * The default skin has a text label and a icon display object. - * - * @event egret.TouchEvent.TOUCH_CANCEL canceled the touch - * - * @state up Button up state - * @state down Button down state - * @state disabled Button disabled state - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ButtonExample.ts - * @language en_US - */ - /** - * Button 组件是常用的矩形按钮。Button 组件看起来可以按压。默认外观具有一个文本标签和图标显示对象。 - * - * @event egret.TouchEvent.TOUCH_CANCEL 取消触摸事件 - * - * @state up 按钮弹起状态 - * @state down 按钮按下状态 - * @state disabled 按钮禁用状态 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ButtonExample.ts - * @language zh_CN - */ - class Button extends Component { - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个按钮实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * [SkinPart] A skin part that defines the label of the button. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart] 按钮上的文本标签。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - labelDisplay: IDisplayText; - /** - * @private - */ - private _label; - /** - * Text to appear on the Button control. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要在按钮上显示的文本。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - label: string; - /** - * [SkinPart] A skin part that defines an optional icon for the button. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart] 按钮上的图标显示对象。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - iconDisplay: Image; - /** - * @private - */ - private _icon; - /** - * Icon to appear on the Button control. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要在按钮上显示的图标数据 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - icon: string | egret.Texture; - /** - * @private - * 指示第一次分派 TouchEvent.TOUCH_BEGIN 时,触摸点是否在按钮上。 - */ - private touchCaptured; - /** - * This method handles the touchCancle events - * @param The egret.TouchEvent object. - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 解除触碰事件处理。 - * @param event 事件 egret.TouchEvent 的对象。 - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onTouchCancle(event: egret.TouchEvent): void; - /** - * This method handles the touch events - * @param The egret.TouchEvent object. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触碰事件处理。 - * @param event 事件 egret.TouchEvent 的对象。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onTouchBegin(event: egret.TouchEvent): void; - /** - * @private - * 舞台上触摸弹起事件 - */ - private onStageTouchEnd(event); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getCurrentState(): string; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected partAdded(partName: string, instance: any): void; - /** - * This method is called when handling a egret.TouchEvent.TOUCH_END event - * when the user touches on the button. It is only called when the button - * is the target and when touchCaptured is true. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当在用户单击按钮之后处理 egret.TouchEvent.TOUCH_END 事件时,将调用此方法。 - * 仅当以按钮为目标,并且 touchCapturedtrue 时,才会调用此方法。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected buttonReleased(): void; - } -} -declare namespace eui.sys { - /** - * @private - */ - const enum RangeKeys { - maximum = 0, - maxChanged = 1, - minimum = 2, - minChanged = 3, - value = 4, - changedValue = 5, - valueChanged = 6, - snapInterval = 7, - snapIntervalChanged = 8, - explicitSnapInterval = 9, - } -} -declare namespace eui { - /** - * The Range class holds a value and an allowed range for that - * value, defined by minimum and maximum properties. - * - * The value property - * is always constrained to be between the current minimum and - * maximum, and the minimum, - * and maximum are always constrained - * to be in the proper numerical order, such that - * (minimum <= value <= maximum) is true. - * - * If the value of the snapInterval property is not 0, - * then the value property is also constrained to be a multiple of - * snapInterval. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/supportClasses/RangeExample.ts - * @language en_US - */ - /** - * 范围选取组件,该组件包含一个值和这个值所允许的最大最小约束范围。 - * - * value属性的值永远被限制于当前的minimum和 - * maximum之间,并且minimummaximum永远按照固定的顺序排列, - * 即(minimum <= value <= maximum) 为真。 - * - * 如果snapInterval属性的值不是0,那么value的值也会被snapInterval所约束。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/supportClasses/RangeExample.ts - * @language zh_CN - */ - class Range extends Component { - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Range 实例。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - $Range: Object; - /** - * The maximum valid value.

      - * - * Changes to the value property are constrained - * by commitProperties() to be less than or equal to - * maximum with the nearestValidValue() method. - * - * @default 100 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 最大有效值。

      - * - * 规定value属性的值不能够超过的最大值。该修正过程 - * 将在nearestValidValue()方法中进行。 - * - * @default 100 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - maximum: number; - /** - * The minimum valid value.

      - * - * Changes to the value property are constrained - * by commitProperties() to be greater than or equal to - * minimum with the nearestValidValue() method. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 最小有效值

      - * - * 规定value属性的值不能够低于的最小值。该修正过程 - * 将在nearestValidValue()方法中进行。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - minimum: number; - /** - * The current value for this range.

      - * - * Changes to the value property are constrained - * by commitProperties() to be greater than or equal to - * the minimum property, less than or equal to the maximum property, and a - * multiple of snapInterval with the nearestValidValue() - * method. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此范围的当前值。

      - * - * 改变的value属性将在commitProperties()方法中被minimum属性 - * 和minimum属性所限制。此修正过程将在nearestValidValue()方法中进行。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - value: number; - /** - * @private - * - * @param newValue - */ - $setValue(newValue: number): boolean; - /** - * The snapInterval property controls the valid values of the value property. - * - * If nonzero, valid values are the sum of the minimum and integer multiples - * of this property, for all sums that are less than or equal to the maximum.

      - * - * For example, if minimum is 10, maximum is 20, and this property is 3, then the - * valid values of this Range are 10, 13, 16, 19, and 20.

      - * - * If the value of this property is zero, then valid values are only constrained - * to be between minimum and maximum inclusive. - * - * @default 1 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * snapInterval 属性定义 value 属性的有效值。 - * 如果为非零,则有效值为 minimum 与此属性的整数倍数之和,且小于或等于 maximum。

      - * - * 例如,如果 minimum 为 10,maximum 为 20,而此属性为 3,则可能的有效值为 10、13、16、19 和 20.

      - * - * 如果此属性的值为零,则仅会将有效值约束到介于 minimum 和 maximum 之间(包括两者)。 - * - * @default 1 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - snapInterval: number; - /** - * Processes the properties set on the component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 处理对组件设置的属性 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected commitProperties(): void; - /** - * @private - * 修正size到最接近snapInterval的整数倍 - */ - private nearestValidSize(size); - /** - * Returns the sum of the minimum with an integer multiple of interval that's - * closest to value, unless value is closer to the maximum limit, - * in which case the maximum is returned.

      - * - * If interval is equal to 0, the value is clipped to the minimum and maximum - * limits.

      - * - * The valid values for a range are defined by the sum of the minimum property - * with multiples of the interval and also defined to be less than or equal to the - * maximum property. - * The maximum need not be a multiple of snapInterval.

      - * - * For example, if minimum is equal to 1, maximum is equal to 6, - * and snapInterval is equal to 2, the valid - * values for the Range are 1, 3, 5, 6. - * - * Similarly, if minimum is equal to 2, maximum is equal to 9, - * and snapInterval is equal to 1.5, the valid - * values for the Range are 2, 3.5, 5, 6.5, 8, and 9. - * - * @param value The input value. - * @param interval The value of snapInterval or an integer multiple of snapInterval. - * @return The valid value that's closest to the input. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 minimum 与最接近 valueinterval 的整数倍数之和, - * 除非 value 接近最大值限制的时候会返回 maximum。

      - * - * 如果 interval 等于 0,则会将该值剪裁到限制的最小值和最大值。

      - * - * 范围的有效值由 minimum 属性与 interval 的倍数之和决定, - * 与此同时也要小于等于 maximum 属性。 - * 最大值不能是 snapInterval 属性的倍数。

      - * - * 例如,如果 minimum 等于 1,maximum 等于 6,且 snapInterval 等于 3, - * 则 Range 的有效值有 1、2、5、6。 - * - * 类似地,如果 minimum 等于 2,maximum 等于 9, - * 且 snapInterval 等于 1.5,则 Range 的有效值有 2、3.5、5、6.5、8 和 9。 - * - * - * @param value 输入值。 - * @param interval snapInterval 的值,或 snapInterval 的整数倍数。 - * @return 最近接输入值的有效值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected nearestValidValue(value: number, interval: number): number; - /** - * Sets the current value for the value property.

      - * - * This method assumes that the caller has already used the nearestValidValue() method - * to constrain the value parameter - * - * @param value The new value of the value property. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置当前值。

      - * - * 此方法假定调用者已经使用了 nearestValidValue() 方法来约束 value 参数。 - * - * @param value value属性的新值 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected setValue(value: number): void; - /** - * Draws the object and/or sizes and positions its children. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制对象和/或设置其子项的大小和位置 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected updateDisplayList(w: number, h: number): void; - /** - * Update size and visible of skin parts.

      - * Subclasses override this method to update skin parts display based on minimum, maximum - * and value properties. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 更新皮肤部件(通常为滑块)的大小和可见性。

      - * 子类覆盖此方法以基于 minimum、maximum 和 value 属性更新滑块的大小、位置和可见性。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected updateSkinDisplayList(): void; - } -} -declare namespace eui { - /** - * The LayoutBase class defines the base class for all Spark layouts. - * To create a custom layout that works with the Spark containers, - * you must extend LayoutBase or one of its subclasses. - * - *

      Subclasses must implement the updateDisplayList() - * method, which positions and sizes the target GroupBase's elements, and - * the measure() method, which calculates the default - * size of the target.

      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 容器布局基类。若要创建使用 Group 容器的自定义布局,必须扩展 LayoutBase 或其子类之一。 - * - *

      子类必须实现 updateDisplayList() 方法 - * (定位 target Group 的子项并调整这些子项的大小)和 measure() 方法 - * (计算 target 的默认大小)。

      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class LayoutBase extends egret.EventDispatcher { - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - $target: Group; - /** - * The Group container whose elements are measured, sized and positioned - * by this layout. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此布局将测量其元素、调整其元素的大小并定位其元素的 Group 容器。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - target: Group; - /** - * @private - */ - $useVirtualLayout: boolean; - /** - * To configure a container to use virtual layout, set the useVirtualLayout property - * to true for the layout associated with the container. - * Only DataGroup with layout set to VerticalLayout, - * HorizontalLayout, or TileLayout supports virtual layout. - * Layout subclasses that do not support virtualization must prevent changing - * this property. - * - * @default false - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 若要配置容器使用虚拟布局,请为与容器关联的布局的 useVirtualLayout 属性设置为 true。 - * 只有布局设置为 VerticalLayout、HorizontalLayout 或 TileLayout 的 DataGroup 才支持虚拟布局。 - * 不支持虚拟化的布局子类必须禁止更改此属性。 - * - * @default false - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - useVirtualLayout: boolean; - /** - * @private - */ - $typicalWidth: number; - /** - * @private - */ - $typicalHeight: number; - /** - * Set this size of a typical element - * - * @param width the height of element - * @param height the width of element - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置一个典型元素的大小 - * - * @param width 元素的宽 - * @param height 元素的高 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - setTypicalSize(width: number, height: number): void; - /** - * Called when the verticalScrollPosition or - * horizontalScrollPosition properties change. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * verticalScrollPositionhorizontalScrollPosition - * 属性更改时调用。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - scrollPositionChanged(): void; - /** - * When useVirtualLayout is true, - * this method can be used by the layout target - * to clear cached layout information when the target changes. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果 useVirtualLayouttrue, - * 则当布局目标改变时,布局目标可以使用此方法来清除已缓存布局信息。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - clearVirtualLayoutCache(): void; - /** - * Called by the target after a layout element - * has been added and before the target's size and display list are - * validated. - * Layouts that cache per element state, like virtual layouts, can - * override this method to update their cache. - * - * @param index The index of the element that was added. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在已添加布局元素之后且在验证目标的大小和显示列表之前,由目标调用。 - * 按元素状态缓存的布局(比如虚拟布局)可以覆盖此方法以更新其缓存。 - * - * @param index 发生改变的子项索引 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - elementAdded(index: number): void; - /** - * This method must is called by the target after a layout element - * has been removed and before the target's size and display list are - * validated. - * Layouts that cache per element state, like virtual layouts, can - * override this method to update their cache. - * - * @param index The index of the element that was added. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * - * 必须在已删除布局元素之后且在验证目标的大小和显示列表之前,由目标调用此方法。 - * 按元素状态缓存的布局(比如虚拟布局)可以覆盖此方法以更新其缓存。 - * - * @param index 发生改变的子项索引 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - elementRemoved(index: number): void; - /** - * Return the indices of the element visible within this Group. - * - * @return The indices of the visible element. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此 Group 中可见的元素的索引。 - * - * @return 可见的元素的索引。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - getElementIndicesInView(): number[]; - /** - * Measures the target's default size based on its content. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 基于目标的内容测量其默认大小 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - measure(): void; - /** - * Sizes and positions the target's elements. - * - * @param unscaledWidth Specifies the width of the target, in pixels, - * in the targets's coordinates. - * - * @param unscaledHeight Specifies the height of the component, in pixels, - * in the target's coordinates. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 调整目标的元素的大小并定位这些元素。 - * - * @param unscaledWidth 指定目标在目标坐标中的宽度(以像素为单位)。 - * @param unscaledHeight 指定组件在目标坐标中的高度(以像素为单位)。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - updateDisplayList(width: number, height: number): void; - } -} -declare namespace eui.sys { - /** - * @private - */ - const enum ListBaseKeys { - /** - * @private - */ - requireSelection = 0, - /** - * @private - */ - requireSelectionChanged = 1, - /** - * @private - */ - proposedSelectedIndex = 2, - /** - * @private - */ - selectedIndex = 3, - /** - * @private - */ - dispatchChangeAfterSelection = 4, - /** - * @private - */ - pendingSelectedItem = 5, - /** - * @private - */ - selectedIndexAdjusted = 6, - /** - * @private - */ - touchDownItemRenderer = 7, - /** - * @private - */ - touchCancle = 8, - } -} -declare namespace eui { - /** - * The ListBase class is the base class for list component. - * It can display items of list as vertical or horizontal such as SELECT of HTML. - * @event egret.Event.CHANGE Dispatched after the selection has changed. - * This event is dispatched when the user interacts with the control. - * @event egret.Event.CHANGING Dispatched when the selection is going to change. - * Calling the preventDefault() method - * on the event prevents the selection from changing.

      - * This event is dispatched when the user interacts with the control. - * - * @event eui.ItemTapEvent.ITEM_TAP dispatched when the user tap an item in the control. - * @event egret.TouchEvent.TOUCH_CANCEL canceled the touch - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * ListBase 是列表控件基类。可显示垂直或水平的项目列表。其功能与 HTML 中的 SELECT 表单元素的功能相似。 - * @event egret.Event.CHANGE 选中的索引已经发生改变,注意:此事件仅在索引改变是由用户触摸操作引起时才抛出。 - * @event egret.Event.CHANGING 选中的索引即将发生改变,可以通过调用事件对象的 preventDefault() 方法来阻止改变。

      - * 注意:此事件仅在索引改变是由用户触摸操作引起时才抛出。 - * - * @event eui.ItemTapEvent.ITEM_TAP 项呈示器单击事件。 - * @event egret.TouchEvent.TOUCH_CANCEL 取消触摸事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class ListBase extends DataGroup { - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - $ListBase: Object; - /** - * Static constant representing the value "no selection". - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 未选中任何项时的索引值 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static NO_SELECTION: number; - /** - * Static constant representing no proposed selection. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 未设置缓存选中项的值 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static NO_PROPOSED_SELECTION: number; - /** - * If true, a data item must always be selected in the control. - * If the value is true, the selectedIndex property - * is always set to a value between 0 and (dataProvider.length - 1). - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果为 true,则控件中必须含有选中的数据项目。 - * 如果该值为 true,则始终将 selectedIndex 属性设置为 0 和 (dataProvider.length - 1) 之间的一个值。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - requireSelection: boolean; - /** - * he 0-based index of the selected item, or -1 if no item is selected. - * Setting the selectedIndex property deselects the currently selected - * item and selects the data item at the specified index.

      - * - * The value is always between -1 and (dataProvider.length - 1). - * If items at a lower index than selectedIndex are - * removed from the component, the selected index is adjusted downward - * accordingly.

      - * - * If the selected item is removed, the selected index is set to:

      - * - *

        - *
      • -1 if requireSelection == false or there are no remaining items.
      • - *
      • 0 if requireSelection == true and there is at least one item.
      • - *

      - * - * When the user changes the selectedIndex property by interacting with the control, - * the control dispatches the change and changing events. - * When you change the value of the selectedIndex property programmatically, - * it does not dispatches the change and changing events.

      - * - * @default -1 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 选中项目的基于 0 的索引。 - * 或者如果未选中项目,则为-1。设置 selectedIndex 属性会取消选择当前选定的项目并选择指定索引位置的数据项目。

      - * - * 这个值会之中在-1到(dataProvider.length - 1)之间。如果从该组件中删除一个低于 - * selectedIndex的值,则selectedIndex也会相应的调节选定的索引。

      - * - * 如果删除的项为当前选中项,则该值会变为:

      - * - *

        - *
      • -1: 如果 requireSelection == false 或者已经没有剩余项目。
      • - *
      • 0: 如果 requireSelection == true 并且当前至少还有一个剩余项目。
      • - *

      - * 当用户通过与控件交互来更改 selectedIndex 属性时,此控件将分派 change 和 changing 事件。 - * 当以编程方式更改 selectedIndex 属性的值时,此控件不分派 change 和 changing 事件。 - * - * @default -1 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - selectedIndex: number; - /** - * @private - * - * @returns - */ - $getSelectedIndex(): number; - /** - * Used internally to specify whether the selectedIndex changed programmatically or due to - * user interaction. - * @param value the new index need to select. - * @param dispatchChangeEvent if true, the component will dispatch a "change" event if the - * value has changed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 由程序或者用户设置选中项。 - * @param value 索引值。 - * @param dispatchChangeEvent 当索引值发生改变,且该参数为true的时候,组件派发出一个“change”事件。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected setSelectedIndex(value: number, dispatchChangeEvent?: boolean): void; - /** - * The item that is currently selected. - * Setting this property deselects the currently selected - * item and selects the newly specified item.

      - * - * Setting selectedItem to an item that is not - * in this component results in no selection, - * and selectedItem being set to undefined.

      - * - * If the selected item is removed, the selected item is set to:

      - *

        - *
      • undefined if requireSelection == false - * or there are no remaining items.
      • - *
      • The first item if requireSelection = true - * and there is at least one item.
      • - *

      - * - * When the user changes the selectedItem property by interacting with the control, - * the control dispatches the change and changing events. - * When you change the value of the selectedIndex property programmatically, - * it does not dispatches the change and changing events.

      - * - * @default undefined - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当前已选中的项目。设置此属性会取消选中当前选定的项目并选择新指定的项目。

      - * - * 如果设置的selectedItem不在当前列表里那么selectedItem将被设置 - * 为undefined

      - * - * 如果选择项目被移除,那选择项会被设置为:

      - *

        - *
      • undefined: 如果 requireSelection == false - * 或者已经没有剩余项。
      • - *
      • 第一项: 当 requireSelection == true - * 并且列表中还至少存有一项.
      • - *

      - * - * 当用户通过与控件交互来更改 selectedItem 属性时,此控件将分派 change 和 changing 事件。 - * 当以编程方式更改 selectedItem 属性的值时,此控件不分派 change 和 changing 事件。

      - * - * @default undefined - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - selectedItem: any; - /** - * Used internally to specify whether the selectedItem changed programmatically or due to - * user interaction. - * @param value the new item need to select. - * @param dispatchChangeEvent if true, the component will dispatch a "change" event if the - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 由程序或用户设置选中项数据源。 - * @param value 要选中的项。 - * @param dispatchChangeEvent 当索引值发生改变,且该参数为true的时候,组件派发出一个“change”事件。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected setSelectedItem(value: any, dispatchChangeEvent?: boolean): void; - /** - * Processes the properties set on the component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 处理对组件设置的属性 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected commitProperties(): void; - /** - * Updates an item renderer for use or reuse. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 更新项呈示器,以备使用或重用 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - updateRenderer(renderer: IItemRenderer, itemIndex: number, data: any): IItemRenderer; - /** - * Called when an item is selected or deselected. - * Subclasses must override this method to display the selection. - * @param index The item index that was selected. - * @param selected true if the item is selected, - * and false if it is deselected. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 选中或取消选中项目时调用。子类必须覆盖此方法才可设置选中项。 - * @param index 已选中的项目索引。 - * @param selected true为选中,false取消选中 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected itemSelected(index: number, selected: boolean): void; - /** - * @private - * 返回指定索引是否等于当前选中索引 - */ - $isItemIndexSelected(index: number): boolean; - /** - * The selection validation and commitment workhorse method. - * Called to commit the pending selected index. This method dispatches - * the "changing" event, and if the event is not cancelled, - * commits the selection change and then dispatches the "change" - * event. - * @param dispatchChangedEvents if dispatch a "changed" event. - * @return true if the selection was committed, or false if the selection - * was cancelled. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 提交选中项属性。该方法会派发一个“changing”事件,如果该事件没有被阻止, - * 该方法将会提交选择项病根据参数派发“change”事件。 - * @param dispatchChangedEvents 是否派发一个“changed”事件。 - * @return true 表示提交成功, false表示被取消 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected commitSelection(dispatchChangedEvents?: boolean): boolean; - /** - * Adjusts the selected index to account for items being added to or - * removed from this component. - * It does not dispatch a change event because the change did not - * occur as a direct result of user-interaction. Moreover, - * it does not dispatch a changing event - * or allow the cancellation of the selection. - * It also does not call the itemSelected() method, - * since the same item is selected; - * @param newIndex The new index. - * @param add true if an item was added to the component, - * and false if an item was removed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 仅调整选中索引值而不更新选中项,即在提交属性阶段itemSelected方法不会被调用,也不会触发changing和change事件。 - * @param newIndex 新索引。 - * @param add 如果已将项目添加到组件,则为true;如果已删除项目,则为false。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected adjustSelection(newIndex: number, add?: boolean): void; - /** - * Called when an item has been added to this component. Selection - * and caret related properties are adjusted accordingly. - * @param item The item being added. - * @param index The index of the item being added. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据项添加 - * @param item 被添加的项。 - * @param index 被添加的项的索引。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected itemAdded(item: any, index: number): void; - /** - * Called when an item has been removed from this component. - * Selection and caret related properties are adjusted - * accordingly. - * @param item The item being removed. - * @param index The index of the item being removed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据项移除 - * @param item 被移除的项。 - * @param index 被移除的项的索引。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected itemRemoved(item: any, index: number): void; - /** - * Event Listener of source data changed. - * @param The egret.gui.CollectionEvent object. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据源改变事件处理。 - * @param event 事件 egret.gui.CollectionEvent 的对象。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onCollectionChange(event: CollectionEvent): void; - /** - * Default response to dataProvider refresh events: clear the selection and caret. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据源刷新时触发。此方法不从组件外部调用,仅用于编写自定义组件时,子类覆盖父类的此方法,以便在数据源发生改变时,自动执行一些额外的根据数据刷新视图的操作。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected dataProviderRefreshed(): void; - /** - * Called when an item has been added to this component. - * @param renderer the renderer being added. - * @param index the index of renderer - * @param item the data of renderer - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 项呈示器被添加 - * @param renderer 添加的项呈示器 - * @param index 项呈示器的索引 - * @param item 项呈示器对应的数据 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected rendererAdded(renderer: IItemRenderer, index: number, item: any): void; - /** - * Called when an item has been removed to this component. - * @param renderer the renderer being removed. - * @param index the index of renderer. - * @param item the data of renderer. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 项呈示器被移除 - * @param renderer 移除的项呈示器 - * @param index 项呈示器的索引 - * @param item 项呈示器对应的数据 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected rendererRemoved(renderer: IItemRenderer, index: number, item: any): void; - /** - * Handles egret.TouchEvent.TOUCH_BEGIN events from any of the - * item renderers. This method handles egret.TouchEvent.TOUCH_END. - * @param event The egret.TouchEvent object. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 侦听项呈示器egret.TouchEvent.TOUCH_BEGIN事件的方法。同时会添加对舞台egret.TouchEvent.TOUCH_END - * 事件的侦听。 - * @param event 事件egret.TouchEvent的对象。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onRendererTouchBegin(event: egret.TouchEvent): void; - /** - * Handles egret.TouchEvent.TOUCH_CANCEL events from any of the - * item renderers. This method will cancel the handles egret.TouchEvent.TOUCH_END and egret.TouchEvent.TOUCH_TAP. - * @param event The egret.TouchEvent object. - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 侦听项呈示器egret.TouchEvent.TOUCH_CANCEL事件的方法。触发时会取消对舞台egret.TouchEvent.TOUCH_END - * 和egret.TouchEvent.TOUCH_TAP事件的侦听。 - * @param event 事件egret.TouchEvent的对象。 - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onRendererTouchCancle(event: egret.TouchEvent): void; - /** - * Handles egret.TouchEvent.TOUCH_END events and dispatch ItemTapEvent.ITEM_TAP event. - * @param event The egret.TouchEvent object. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触摸在项呈示器上结束,抛出ItemTapEvent.ITEM_TAP事件。 - * @param event 事件egret.TouchEvent的对象。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onRendererTouchEnd(event: egret.TouchEvent): void; - /** - * @private - * 触摸在舞台上结束 - */ - private stage_touchEndHandler(event); - } -} -declare namespace eui { - /** - * The ScrollBarBase class helps to position - * the portion of data that is displayed when there is too much data - * to fit in a display area. - * The ScrollBarBase class displays a pair of viewport and a thumb. - * viewport is a instance that implements IViewport. - * - * @see eui.IViewport - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * ScrollBarBase 滚动条基类,该类帮助在因数据太多而不能在显示区域完全显示时定位显示的数据部分。 - * ScrollBarBase 类显示视区的一部分和一个指示滑块。 - * 视区是一个IViewport接口实现的实例。 - * - * @see eui.IViewport - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class ScrollBarBase extends Component { - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个ScrollBarBase实例。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * [SkinPart] Thumb display object. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart]滑块显示对象。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - thumb: eui.UIComponent; - /** - * @private - */ - $viewport: IViewport; - /** - * The viewport controlled by this scrollbar. - * - * If a viewport is specified, then changes to its actual size, content - * size, and scroll position cause the corresponding ScrollBarBase methods to - * run: - *

        - *
      • onViewportResize()
      • - *
      • onPropertyChanged()
      • - *

      - * - * The VScrollBar and HScrollBar classes override these methods to keep their properties in - * sync with the viewport. - * - * @default null - * @see eui.VScrollBar - * @see eui.HScrollBar - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 由该滚动条控制的视区。 - * - * 如果指定了视区,则对其实际大小、内容大小和滚动位置的更改会导致运行相对应的 ScrollBarBase 方法: - *

        - *
      • onViewportResize()
      • - *
      • onPropertyChanged()
      • - *

      - * - * VScrollBar 和 HScrollBar 类需要重写这些方法以保证属性与视区的同步。 - * - * @default null - * @see eui.VScrollBar - * @see eui.HScrollBar - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - viewport: IViewport; - /** - * @private - * - * @param event - */ - private onViewportResize(event?); - /** - * Properties of viewport changed. - * @param event - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 视区属性发生改变。 - * @param event - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onPropertyChanged(event: eui.PropertyEvent): void; - /** - * Whether the scrollbar can be autohide. - * @version Egret 3.0.2 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 是否自动隐藏 scrollbar - * @version Egret 3.0.2 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - autoVisibility: boolean; - } -} -declare namespace eui { - /** - * @private - */ - const enum Keys { - clickOffsetX = 0, - clickOffsetY = 1, - moveStageX = 2, - moveStageY = 3, - touchDownTarget = 4, - animation = 5, - slideDuration = 6, - pendingValue = 7, - slideToValue = 8, - liveDragging = 9, - } - /** - * The SliderBase class lets users select a value by moving a slider thumb between - * the end points of the slider track. - * The current value of the slider is determined by the relative location of - * the thumb between the end points of the slider, - * corresponding to the slider's minimum and maximum values. - * The SliderBase class is a base class for HSlider and VSlider. - * - * @event eui.UIEvent.CHANGE_START Dispatched when the scroll position is going to change - * @event eui.UIEvent.CHANGE_END Dispatched when the scroll position changed complete - * @event egret.Event.CHANGE Dispatched when the scroll position is changing - * - * @see eui.HSlider - * @see eui.VSlider - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 滑块控件基类,通过使用 SliderBase 类,用户可以在滑块轨道的端点之间移动滑块来选择值。 - * 滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。 - * SliderBase 类是 HSlider 和 VSlider 的基类。 - * - * @event eui.UIEvent.CHANGE_START 滚动位置改变开始 - * @event eui.UIEvent.CHANGE_END 滚动位置改变结束 - * @event egret.Event.CHANGE 滚动位置改变的时候 - * - * @see eui.HSlider - * @see eui.VSlider - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class SliderBase extends Range { - /** - * Constructor - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 SliderBase 实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - $SliderBase: Object; - /** - * [SkinPart] Highlight of track. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart] 轨道高亮显示对象。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - trackHighlight: egret.DisplayObject; - /** - * [SkinPart] Thumb display object. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart]滑块显示对象。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - thumb: eui.UIComponent; - /** - * [SkinPart] Track display object. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart]轨道显示对象。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - track: eui.UIComponent; - /** - * Duration in milliseconds for the sliding animation when you tap on the track to move a thumb. - * - * @default 300 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在轨道上单击以移动滑块时,滑动动画持续的时间(以毫秒为单位)。设置为0将不执行缓动。 - * - * @default 300 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - slideDuration: number; - /** - * Converts a track-relative x,y pixel location into a value between - * the minimum and maximum, inclusive. - * - * @param x The x coordinate of the location relative to the track's origin. - * @param y The y coordinate of the location relative to the track's origin. - * @return A value between the minimum and maximum, inclusive. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 将相对于轨道的 x,y 像素位置转换为介于最小值和最大值(包括两者)之间的一个值。 - * - * @param x 相对于轨道原点的位置的x坐标。 - * @param y 相对于轨道原点的位置的y坐标。 - * @return 介于最小值和最大值(包括两者)之间的一个值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected pointToValue(x: number, y: number): number; - /** - * Specifies whether live dragging is enabled for the slider. If true, sets the value - * and values properties and dispatches the change event continuously as - * the user moves the thumb. - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果为 true,则将在沿着轨道拖动滑块时,而不是在释放滑块按钮时,提交此滑块的值。 - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - liveDragging: boolean; - /** - * The value the slider will have when the touch is end. - * This property is updated when the slider thumb moves, even if liveDragging is false.

      - * If the liveDragging style is false, then the slider's value is only set - * when the touch is end. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触摸结束时滑块将具有的值。 - * 无论 liveDragging 是否为 true,在滑块拖动期间始终更新此属性。 - * 而 value 属性在当 liveDragging 为 false 时,只在触摸释放时更新一次。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - pendingValue: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected setValue(value: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected partAdded(partName: string, instance: any): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected partRemoved(partName: string, instance: any): void; - /** - * @private - * 滑块或轨道尺寸改变事件 - */ - private onTrackOrThumbResize(event); - /** - * Handle touch-begin events on the scroll thumb. Records the touch begin point in clickOffset. - * - * @param The egret.TouchEvent object. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 滑块触摸开始事件,记录触碰开始的坐标偏移量。 - * - * @param event 事件 egret.TouchEvent 的对象. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onThumbTouchBegin(event: egret.TouchEvent): void; - /** - * @private - * 舞台上触摸移动事件 - */ - private onStageTouchMove(event); - /** - * Capture touch-move events anywhere on or off the stage. - * @param newValue new value - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 监听舞台的触碰移动事件。 - * @param newValue 新的值 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected updateWhenTouchMove(newValue: number): void; - /** - * Handle touch-end events anywhere on or off the stage. - * - * @param The egret.Event object. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触摸结束事件 - * - * @param event 事件 egret.Event 的对象。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onStageTouchEnd(event: egret.Event): void; - /** - * @private - * 当在组件上按下时记录被按下的子显示对象 - */ - private onTouchBegin(event); - /** - * @private - * 当结束时,若不是在 touchDownTarget 上弹起,而是另外的子显示对象上弹起时,额外抛出一个触摸单击事件。 - */ - private stageTouchEndHandler(event); - /** - * @private - * 动画播放更新数值 - */ - $animationUpdateHandler(animation: sys.Animation): void; - /** - * @private - * 动画播放完毕 - */ - private animationEndHandler(animation); - /** - * @private - * 停止播放动画 - */ - private stopAnimation(); - /** - * Handle touch-begin events for the slider track. We - * calculate the value based on the new position and then - * move the thumb to the correct location as well as - * commit the value. - * @param The egret.TouchEvent object. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 轨道的触碰开始事件。我们会在这里根据新的坐标位置计算value,然后移动滑块到当前位置。 - * - * @param event 事件 egret.TouchEvent 的对象. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onTrackTouchBegin(event: egret.TouchEvent): void; - } -} -declare namespace eui.sys { - /** - * @private - * EXML配置管理器实例 - */ - let exmlConfig: EXMLConfig; - /** - * @private - */ - class EXMLParser { - /** - * @private - */ - constructor(); - /** - * @private - * 获取重复的ID名 - */ - getRepeatedIds: (xml: egret.XML) => string[]; - /** - * @private - */ - private getIds; - /** - * @private - */ - private repeatedIdMap; - /** - * @private - */ - private checkDeclarations; - /** - * @private - * 当前类 - */ - private currentClass; - /** - * 当前exml的根节点是否为Skin - */ - private isSkinClass; - /** - * @private - * 当前编译的类名 - */ - private currentClassName; - /** - * @private - * 当前要编译的EXML文件 - */ - private currentXML; - /** - * @private - * id缓存字典 - */ - private idDic; - /** - * @private - * 状态代码列表 - */ - private stateCode; - /** - * @private - */ - private stateNames; - /** - * @private - * 需要单独创建的实例id列表 - */ - private stateIds; - /** - * @private - */ - private skinParts; - /** - * @private - */ - private bindings; - /** - * @private - */ - private declarations; - /** - * @private - * 延迟赋值字典 - */ - private delayAssignmentDic; - /** - * @private - * 将已有javascript代码注册 - * @param codeText 执行的javascript代码 - * @param classStr 类名 - */ - $parseCode(codeText: string, classStr: string): { - new (): any; - }; - /** - * @private - * 编译指定的XML对象为JavaScript代码。 - * @param xmlData 要编译的EXML文件内容 - * - */ - parse(text: string): { - new (): any; - }; - /** - * @private - * 编译指定的XML对象为CpClass对象。 - */ - private parseClass(xmlData, className); - /** - * @private - * 开始编译 - */ - private startCompile(); - /** - * @private - * 添加必须的id - */ - private addIds(items); - /** - * @private - * 是否为内部类。 - */ - private isInnerClass(node); - /** - * @private - * 检测指定节点的属性是否含有视图状态 - */ - private containsState(node); - /** - * @private - * 为指定节点创建id属性 - */ - private createIdForNode(node); - /** - * @private - * 获取节点ID - */ - private getNodeId(node); - /** - * @private - * 为指定节点创建变量 - */ - private createVarForNode(node); - /** - * @private - * 为指定节点创建初始化函数,返回函数名引用 - */ - private createFuncForNode(node); - /** - * @private - * 检查目标类名是否是基本数据类型 - */ - private isBasicTypeData(className); - /** - * @private - * 为指定基本数据类型节点实例化,返回实例化后的值。 - */ - private createBasicTypeForNode(node); - /** - * @private - * 将节点属性赋值语句添加到代码块 - */ - private addAttributesToCodeBlock(cb, varName, node); - /** - * @private - * 初始化子项 - */ - private initlizeChildNode(node, cb, varName); - /** - * @private - * 解析内部类节点,并返回类名。 - */ - private parseInnerClass(node); - /** - * @private - * 添加多个子节点到指定的属性 - */ - private addChildrenToProp(children, type, prop, cb, varName, errorInfo, propList, node); - /** - * @private - * 指定节点是否是属性节点 - */ - private isProperty(node); - /** - * @private - * 是否是普通赋值的key - */ - private isNormalKey(key); - /** - * @private - * 格式化key - */ - private formatKey(key, value); - /** - * @private - * 格式化值 - */ - private formatValue(key, value, node); - /** - * @private - * 格式化字符串 - */ - private formatString(value); - private formatBinding(key, value, node); - private parseTemplates(value); - /** - * @private - /** - * 转换HTML实体字符为普通字符 - */ - private unescapeHTMLEntity(str); - /** - * @private - * 创建构造函数 - */ - private createConstructFunc(); - /** - * @private - * 是否含有includeIn和excludeFrom属性 - */ - private isStateNode(node); - /** - * @private - * 获取视图状态名称列表 - */ - private getStateNames(); - /** - * @private - * 解析视图状态代码 - */ - private createStates(parentNode); - /** - * @private - * 检查指定的ID是否创建了类成员变量,若没创建则为其创建。 - */ - private checkIdForState(node); - /** - * @private - * 通过视图状态名称获取对应的视图状态 - */ - private getStateByName(name, node); - /** - * @private - * 寻找节点的临近节点ID和位置 - */ - private findNearNodeId(node); - /** - * @private - * 获取节点的完整类名,包括模块名 - */ - private getClassNameOfNode(node); - } -} -declare namespace eui { - /** - * The ToggleButton component defines a toggle button. - * Clicking the button toggles it between the up and an down states. - * If you click the button while it is in the up state, - * it toggles to the down state. You must click the button again - * to toggle it back to the up state. - *

      You can get or set this state programmatically - * by using the selected property.

      - * - * @event egret.Event.CHANGE Dispatched when the selected property - * changes for the ToggleButton control. - * This event is dispatched only when the - * user interacts with the control by touching. - * - * @state up Button up state - * @state down Button down state - * @state disabled Button disabled state - * @state upAndSelected Up state when the button is selected - * @state downAndSelected Down state when the button is selected - * @state disabledAndSelected Disabled state when the button is selected - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ToggleButtonExample.ts - * @language en_US - */ - /** - * ToggleButton 组件定义切换按钮。单击该按钮会在弹起状态和按下状态之间进行切换。 - * 如果在按钮处于弹起状态时单击该按钮,则它会切换到按下状态。必须再次单击该按钮才可将其切换回弹起状态。 - *

      可以使用 selected 属性以编程方式获取或设置此状态。

      - * - * @event egret.Event.CHANGE ToggleButtonBase 控件的 selected 属性更改时分派。 - * 仅当用户通过触摸与控件交互时,才分派此事件。 - * - * @state up 按钮弹起状态 - * @state down 按钮按下状态 - * @state disabled 按钮禁用状态 - * @state upAndSelected 按钮选择时的弹起状态 - * @state downAndSelected 按钮选择时的按下状态 - * @state disabledAndSelected 按钮选择时的禁用状态 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ToggleButtonExample.ts - * @language zh_CN - */ - class ToggleButton extends Button { - /** - * @private - */ - $selected: boolean; - /** - * Contains true if the button is in the down state, - * and false if it is in the up state. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 按钮处于按下状态时为 true,而按钮处于弹起状态时为 false。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - selected: boolean; - /** - * @private - * - * @param value - */ - $setSelected(value: boolean): boolean; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getCurrentState(): string; - /** - * @private - * 是否根据触摸事件自动变换选中状态,默认true。仅框架内使用。 - */ - $autoSelected: boolean; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected buttonReleased(): void; - } -} -declare namespace eui { - /** - * Linear layout base class, usually as the parent class of - * HorizontalLayout and VerticalLayout. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 线性布局基类,通常作为 HorizontalLayoutVerticalLayout 的父类。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class LinearLayoutBase extends LayoutBase { - /** - * @private - */ - $horizontalAlign: string; - /** - * The horizontal alignment of layout elements. - *

      The egret.HorizontalAlign and eui.JustifyAlign class - * defines the possible values for this property.

      - * - * @default "left" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 布局元素的水平对齐策略。 - *

      egret.HorizontalAlign 和 - * eui.JustifyAlign类定义此属性的可能值。

      - * - * @default "left" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - horizontalAlign: string; - /** - * @private - */ - $verticalAlign: string; - /** - * The vertical alignment of layout elements. - *

      The egret.VerticalAlign and eui.JustifyAlign class - * defines the possible values for this property.

      - * - * @default "top" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 布局元素的垂直对齐策略。请使用 VerticalAlign 定义的常量。 - *

      egret.VerticalAlign 和 - * eui.JustifyAlign类定义此属性的可能值。

      - * - * @default "top" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - verticalAlign: string; - /** - * @private - */ - $gap: number; - /** - * The space between layout elements, in pixels. - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 布局元素之间的间隔(以像素为单位)。 - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - gap: number; - /** - * @private - */ - $paddingLeft: number; - /** - * Number of pixels between the container's left edge - * and the left edge of the first layout element. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 容器的左边缘与第一个布局元素的左边缘之间的像素数。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - paddingLeft: number; - /** - * @private - */ - $paddingRight: number; - /** - * Number of pixels between the container's right edge - * and the right edge of the last layout element. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 容器的右边缘与最后一个布局元素的右边缘之间的像素数。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - paddingRight: number; - /** - * @private - */ - $paddingTop: number; - /** - * The minimum number of pixels between the container's top edge and - * the top of all the container's layout elements. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 容器的顶边缘与所有容器的布局元素的顶边缘之间的最少像素数。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - paddingTop: number; - /** - * @private - */ - $paddingBottom: number; - /** - * The minimum number of pixels between the container's bottom edge and - * the bottom of all the container's layout elements. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 容器的底边缘与所有容器的布局元素的底边缘之间的最少像素数。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - paddingBottom: number; - /** - * Convenience function for subclasses that invalidates the - * target's size and displayList so that both layout's measure() - * and updateDisplayList methods get called. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 失效目标容器的尺寸和显示列表的简便方法,调用目标容器的 - * measure()updateDisplayList方法 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected invalidateTargetLayout(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - measure(): void; - /** - * Compute exact values for measuredWidth and measuredHeight. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 计算目标容器 measuredWidth 和 measuredHeight 的精确值 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected measureReal(): void; - /** - * Compute potentially approximate values for measuredWidth and measuredHeight. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 计算目标容器 measuredWidth 和 measuredHeight 的近似值 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected measureVirtual(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - updateDisplayList(width: number, height: number): void; - /** - * An Array of the virtual layout elements size cache. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 虚拟布局使用的尺寸缓存。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected elementSizeTable: number[]; - /** - * Gets the starting position of the specified index element - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取指定索引元素的起始位置 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected getStartPosition(index: number): number; - /** - * Gets the size of the specified index element - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取指定索引元素的尺寸 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected getElementSize(index: number): number; - /** - * Gets the sum of the size of cached elements - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取缓存的子对象尺寸总和 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected getElementTotalSize(): number; - /** - * @inheritDoc - * - * @param index - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - elementRemoved(index: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - clearVirtualLayoutCache(): void; - /** - * The binary search to find the specified index position of the display object - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 折半查找法寻找指定位置的显示对象索引 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected findIndexAt(x: number, i0: number, i1: number): number; - /** - * The first element index in the view of the virtual layout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 虚拟布局使用的当前视图中的第一个元素索引 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected startIndex: number; - /** - * The last element index in the view of the virtual layout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 虚拟布局使用的当前视图中的最后一个元素的索引 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected endIndex: number; - /** - * A Flag of the first element and the end element has been calculated. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 视图的第一个和最后一个元素的索引值已经计算好的标志 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected indexInViewCalculated: boolean; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - scrollPositionChanged(): void; - /** - * Get the index of the first and last element in the view, - * and to return whether or not to change. - * - * @return has the index changed - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取视图中第一个和最后一个元素的索引,返回是否发生改变。 - * - * @return 索引是否已改变 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected getIndexInView(): boolean; - /** - * The maximum size of elements - * - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 子元素最大的尺寸 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected maxElementSize: number; - /** - * Update the layout of the virtualized elements - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 更新虚拟布局的显示列表 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected updateDisplayListVirtual(width: number, height: number): void; - /** - * Update the layout of the reality elements - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 更新真实布局的显示列表 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected updateDisplayListReal(width: number, height: number): void; - /** - * Allocate blank area for each variable size element. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 为每个可变尺寸的子项分配空白区域。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected flexChildrenProportionally(spaceForChildren: number, spaceToDistribute: number, totalPercent: number, childInfoArray: any[]): void; - } -} -declare namespace eui.sys { - /** - * @private - */ - class ChildInfo { - /** - * @private - */ - layoutElement: eui.UIComponent; - /** - * @private - */ - size: number; - /** - * @private - */ - percent: number; - /** - * @private - */ - min: number; - /** - * @private - */ - max: number; - } -} -declare namespace eui { - /** - * The HSlider (horizontal slider) control lets users select a value - * by moving a slider thumb between the end points of the slider track. - * The current value of the slider is determined by the relative location of the thumb between - * the end points of the slider, corresponding to the slider's minimum and maximum values. - * - * @includeExample extension/eui/components/HSliderExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 使用 HSlider(水平滑块)控件,用户可通过在滑块轨道的端点之间移动滑块来选择值。 - * 滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。 - * - * @includeExample extension/eui/components/HSliderExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class HSlider extends SliderBase { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected pointToValue(x: number, y: number): number; - /** - * @private - * - * @returns - */ - private getThumbRange(); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateSkinDisplayList(): void; - } -} -declare namespace eui { - /** - * Default instance of interface IAssetAdapter. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/supportClasses/DefaultAssetAdapterExample.ts - * @language en_US - */ - /** - * 默认的IAssetAdapter接口实现。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/supportClasses/DefaultAssetAdapterExample.ts - * @language zh_CN - */ - class DefaultAssetAdapter implements IAssetAdapter { - /** - * resolve asset. - * @param source the identifier of new asset need to be resolved - * @param callBack callback function when resolving complete - * example:callBack(content:any,source:string):void; - * @param thisObject this object of callback method - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 解析素材 - * @param source 待解析的新素材标识符 - * @param callBack 解析完成回调函数,示例:callBack(content:any,source:string):void; - * @param thisObject callBack的 this 引用 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - getAsset(source: string, callBack: (data: any, source: string) => void, thisObject: any): void; - /** - * @private - * - * @param event - */ - private onLoadFinish(event); - } -} -declare namespace eui { - /** - * The Image control lets you show JPEG, PNG, and GIF files - * at runtime. Image inherit Bitmap,so you can set the bitmapData property - * to show the data. you can also set the source property, Image will auto load - * and show the url image or the bitmapData. - * - * @event egret.Event.COMPLETE Dispatched when the image loaded complete. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ImageExample.ts - * @language en_US - */ - /** - * Image 控件允许您在运行时显示 JPEG、PNG 等图片文件文件。Image 继承至 Bitmap,因此您可以直接对其 bitmapData 属性, - * 赋值从外部加载得到的位图数据以显示对应图片。同时,Image 还提供了更加方便的 source 属性,source 属性可以接受一个网络图片url作为值, - * 赋值为url后,它内部会自动去加载并显示图片。并且您同样也可以直接把 BitmapData 对象赋值给 source 属性以显示图片。 - * - * @event egret.Event.COMPLETE 当图片加载完成后调度 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ImageExample.ts - * @language zh_CN - */ - class Image extends egret.Bitmap implements UIComponent { - /** - * Constructor. - * - * @param source The source used for the bitmap fill. the value can be - * a string or an instance of egret.Texture - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @param source 用于位图填充的源。可以是一个字符串或者 egret.Texture 对象 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(source?: string | egret.Texture); - /** - * Represent a Rectangle Area that the 9 scale area of Image. - * Notice: This property is valid only when fillMode - * is BitmapFillMode.SCALE. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形区域,它定义素材对象的九个缩放区域。 - * 注意:此属性仅在fillModeBitmapFillMode.SCALE时有效。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - scale9Grid: egret.Rectangle; - /** - * Determines how the bitmap fills in the dimensions. - *

      When set to BitmapFillMode.CLIP, the bitmap - * ends at the edge of the region.

      - *

      When set to BitmapFillMode.REPEAT, the bitmap - * repeats to fill the region.

      - *

      When set to BitmapFillMode.SCALE, the bitmap - * stretches to fill the region.

      - * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 确定位图填充尺寸的方式。 - *

      设置为 BitmapFillMode.CLIP时,位图将在边缘处被截断。

      - *

      设置为 BitmapFillMode.REPEAT时,位图将重复以填充区域。

      - *

      设置为 BitmapFillMode.SCALE时,位图将拉伸以填充区域。

      - * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - fillMode: string; - $setFillMode(value: string): boolean; - /** - * @private - */ - private sourceChanged; - /** - * @private - */ - private _source; - /** - * The source used for the bitmap fill. the value can be - * a string or an instance of egret.Texture - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 用于位图填充的源。可以是一个字符串或者 egret.Texture 对象 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - source: string | egret.Texture; - $setTexture(value: egret.Texture): boolean; - /** - * @private - * 解析source - */ - private parseSource(); - $measureContentBounds(bounds: egret.Rectangle): void; - /** - * @private - * - * @param context - */ - /** - * @private - * UIComponentImpl 定义的所有变量请不要添加任何初始值,必须统一在此处初始化。 - */ - private initializeUIValues; - /** - * @copy eui.UIComponent#createChildren - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected createChildren(): void; - /** - * @private - * 设置组件的宽高。此方法不同于直接设置width,height属性, - * 不会影响显式标记尺寸属性 - */ - protected setActualSize(w: number, h: number): void; - /** - * @copy eui.UIComponent#childrenCreated - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected childrenCreated(): void; - /** - * @copy eui.UIComponent#commitProperties - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected commitProperties(): void; - /** - * @copy eui.UIComponent#measure - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected measure(): void; - /** - * @copy eui.UIComponent#updateDisplayList - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * @copy eui.UIComponent#invalidateParentLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected invalidateParentLayout(): void; - /** - * @private - */ - $UIComponent: Object; - /** - * @private - */ - $includeInLayout: boolean; - /** - * @copy eui.UIComponent#includeInLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - includeInLayout: boolean; - /** - * @copy eui.UIComponent#left - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - left: any; - /** - * @copy eui.UIComponent#right - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - right: any; - /** - * @copy eui.UIComponent#top - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - top: any; - /** - * @copy eui.UIComponent#bottom - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - bottom: any; - /** - * @copy eui.UIComponent#horizontalCenter - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - horizontalCenter: any; - /** - * @copy eui.UIComponent#verticalCenter - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - verticalCenter: any; - /** - * @copy eui.UIComponent#percentWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentWidth: number; - /** - * @copy eui.UIComponent#percentHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentHeight: number; - /** - * @copy eui.UIComponent#explicitWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitWidth: number; - /** - * @copy eui.UIComponent#explicitHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitHeight: number; - /** - * @copy eui.UIComponent#minWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minWidth: number; - /** - * @copy eui.UIComponent#maxWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxWidth: number; - /** - * @copy eui.UIComponent#minHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minHeight: number; - /** - * @copy eui.UIComponent#maxHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setMeasuredSize(width: number, height: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateSize(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateSize(recursive?: boolean): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateNow(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsSize(layoutWidth: number, layoutHeight: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsPosition(x: number, y: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getLayoutBounds(bounds: egret.Rectangle): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getPreferredBounds(bounds: egret.Rectangle): void; - } -} -declare namespace eui { - /** - * The ItemRenderer class is the base class for item renderers. - * - * @state up Up state - * @state down Down state - * @state upAndSelected Up state when the button is selected - * @state downAndSelected Down state when the button is selected - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ItemRendererExample.ts - * @language en_US - */ - /** - * ItemRenderer 类是项呈示器的基类。 - * - * @state up 弹起状态 - * @state down 按下状态 - * @state upAndSelected 选择时的弹起状态 - * @state downAndSelected 选择时的按下状态 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ItemRendererExample.ts - * @language zh_CN - */ - class ItemRenderer extends Component implements IItemRenderer { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - private _data; - /** - * The data to render or edit. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要呈示或编辑的数据。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - data: any; - /** - * Update the view when the data property changes. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当数据改变时,更新视图。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected dataChanged(): void; - /** - * @private - */ - private _selected; - /** - * Contains true if the item renderer - * can show itself as selected. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果项呈示器可以将其自身显示为已选中,则为 true。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - selected: boolean; - /** - * The index of the item in the data provider - * of the host component of the item renderer. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 项呈示器的数据提供程序中的项目索引。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - itemIndex: number; - /** - * @private - * 指示第一次分派 TouchEvent.TOUCH_BEGIN 时,触摸点是否在按钮上。 - */ - private touchCaptured; - /** - * Dispatched when an event of some kind occurred that canceled the touch. - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 由于某个事件取消了触摸时触发 - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onTouchCancle(event: egret.TouchEvent): void; - /** - * Handles TouchEvent.TOUCH_BEGIN events - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触碰开始时触发事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onTouchBegin(event: egret.TouchEvent): void; - /** - * @private - * 舞台上触摸弹起事件 - */ - private onStageTouchEnd(event); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getCurrentState(): string; - } -} -declare namespace eui { - /** - * Label is an UIComponent that can render one or more lines of text. - * The text to be displayed is determined by the text property. - * The formatting of the text is specified by the styles, - * such as fontFamily and size. - * - *

      Because Label is fast and lightweight, it is especially suitable - * for use cases that involve rendering many small pieces of non-interactive - * text, such as item renderers and labels in Button skins.

      - * - *

      In Label, three character sequences are recognized - * as explicit line breaks: CR ("\r"), LF ("\n"), - * and CR+LF ("\r\n").

      - * - *

      If you don't specify any kind of width for a Label, - * then the longest line, as determined by these explicit line breaks, - * determines the width of the Label.

      - * - *

      If you do specify some kind of width, then the specified text is - * word-wrapped at the right edge of the component's bounds. - * If the text extends below the bottom of the component, - * it is clipped.

      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/LabelExample.ts - * @language en_US - */ - /** - * Label 是可以呈示一行或多行统一格式文本的UI组件。要显示的文本由 text 属性确定。文本格式由样式属性指定,例如 fontFamily 和 size。 - * 因为 Label 运行速度快且占用内存少,所以它特别适合用于显示多个小型非交互式文本的情况,例如,项呈示器和 Button 外观中的标签。 - * 在 Label 中,将以下三个字符序列识别为显式换行符:CR(“\r”)、LF(“\n”)和 CR+LF(“\r\n”)。 - * 如果没有为 Label 指定宽度,则由这些显式换行符确定的最长行确定 Label 的宽度。 - * 如果指定了宽度,则指定文本将在组件边界的右边缘换行,如果文本扩展到低于组件底部,则将被剪切。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/LabelExample.ts - * @language zh_CN - */ - class Label extends egret.TextField implements UIComponent, IDisplayText { - /** - * Constructor. - * - * @param text The text displayed by this text component. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @param text 此文本组件所显示的文本。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(text?: string); - /** - * style中属性是否允许被赋值,当主动赋值过属性之后将不允许被赋值 - */ - private $styleSetMap; - private $revertStyle; - private $style; - private $changeFromStyle; - /** - * The style of text. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 文本样式。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - style: string; - $setStyle(value: string): void; - $setFontFamily(value: string): boolean; - $setSize(value: number): boolean; - $setBold(value: boolean): boolean; - $setItalic(value: boolean): boolean; - $setTextAlign(value: string): boolean; - $setVerticalAlign(value: string): boolean; - $setLineSpacing(value: number): boolean; - $setTextColor(value: number): boolean; - $setWordWrap(value: boolean): void; - $setDisplayAsPassword(value: boolean): boolean; - $setStrokeColor(value: number): boolean; - $setStroke(value: number): boolean; - $setMaxChars(value: number): boolean; - $setMultiline(value: boolean): boolean; - $setBorder(value: boolean): void; - $setBorderColor(value: number): void; - $setBackground(value: boolean): void; - $setBackgroundColor(value: number): void; - /** - * @private - * - */ - $invalidateTextField(): void; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - /** - * @private - */ - private _widthConstraint; - /** - * @private - * UIComponentImpl 定义的所有变量请不要添加任何初始值,必须统一在此处初始化。 - */ - private initializeUIValues; - /** - * @copy eui.UIComponent#createChildren - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected createChildren(): void; - /** - * @copy eui.UIComponent#childrenCreated - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected childrenCreated(): void; - /** - * @copy eui.UIComponent#commitProperties - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected commitProperties(): void; - /** - * @copy eui.UIComponent#measure - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected measure(): void; - /** - * @copy eui.UIComponent#updateDisplayList - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * @copy eui.UIComponent#invalidateParentLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected invalidateParentLayout(): void; - /** - * @private - */ - $UIComponent: Object; - /** - * @private - */ - $includeInLayout: boolean; - /** - * @copy eui.UIComponent#includeInLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - includeInLayout: boolean; - /** - * @copy eui.UIComponent#left - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - left: any; - /** - * @copy eui.UIComponent#right - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - right: any; - /** - * @copy eui.UIComponent#top - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - top: any; - /** - * @copy eui.UIComponent#bottom - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - bottom: any; - /** - * @copy eui.UIComponent#horizontalCenter - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - horizontalCenter: any; - /** - * @copy eui.UIComponent#verticalCenter - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - verticalCenter: any; - /** - * @copy eui.UIComponent#percentWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentWidth: number; - /** - * @copy eui.UIComponent#percentHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentHeight: number; - /** - * @copy eui.UIComponent#explicitWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitWidth: number; - /** - * @copy eui.UIComponent#explicitHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitHeight: number; - /** - * @copy eui.UIComponent#minWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minWidth: number; - /** - * @copy eui.UIComponent#maxWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxWidth: number; - /** - * @copy eui.UIComponent#minHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minHeight: number; - /** - * @copy eui.UIComponent#maxHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setMeasuredSize(width: number, height: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateSize(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateSize(recursive?: boolean): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateNow(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsSize(layoutWidth: number, layoutHeight: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsPosition(x: number, y: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getLayoutBounds(bounds: egret.Rectangle): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getPreferredBounds(bounds: egret.Rectangle): void; - } -} -declare namespace eui { - /** - * The List control displays a vertical or horizontal list of items. - * The user can select one or more items from the list, depending - * on the value of the allowMultipleSelection property. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ListExample.ts - * @language en_US - */ - /** - * List 控件可显示垂直或水平的项目列表。用户可以根据 allowMultipleSelection 属性的值从列表中选择一个或多个项目。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ListExample.ts - * @language zh_CN - */ - class List extends ListBase { - /** - * whether are allowed to multiple selection. - * If true tap an unselected item will be selected, - * and tap the item again will cancel selection. - * - * @default false - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 是否允许同时选中多项,设置为 true 时,触摸按下未选中的项呈示器,将会设置该项选中,再次按下将会取消选中。 - * 可以设置多项为选中状态。 - * - * @default false - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - allowMultipleSelection: boolean; - /** - * @private - */ - private _selectedIndices; - /** - * @private - */ - private _proposedSelectedIndices; - /** - * An Array of numbers representing the indices of the currently selected - * item or items. - * - * @default [] - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当前选中的一个或多个项目的索引列表。 - * - * @default [] - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - selectedIndices: number[]; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - selectedIndex: number; - /** - * An Array representing the currently selected data items. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 表示当前选定数据项的列表 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - selectedItems: any[]; - /** - * Specify whether the selectedIndices changed programmatically or due to - * user interaction. - * - * @param value An array of numbers representing the indices of the selected - * @param dispatchChangeEvent whether dispatched a change event. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置多个选中项。 - * - * @param value 选中项索引的数组 - * @param dispatchChangeEvent 是否派发changed事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected setSelectedIndices(value: number[], dispatchChangeEvent?: boolean): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected commitProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected commitSelection(dispatchChangedEvents?: boolean): boolean; - /** - * @private - * 是否是有效的索引 - */ - private isValidIndex; - /** - * Given a new selection interval, figure out which - * items are newly added/removed from the selection interval and update - * selection properties and view accordingly. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 从给定的选择区间中找出新增或者移除的项,并更新属性。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected commitMultipleSelection(): void; - /** - * @private - * - * @param index - * @returns - */ - $isItemIndexSelected(index: number): boolean; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - dataProviderRefreshed(): void; - /** - * @private - * 计算当前的选中项列表 - */ - private calculateSelectedIndices(index); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected onRendererTouchEnd(event: egret.TouchEvent): void; - } -} -declare namespace eui { - /** - * The Panel class defines a container that includes a title bar, - * a closeButton, a moveArea, and a content area for its children. - * - * @event eui.UIEvent.CLOSING Dispatched when the close button is taped - * you can use event.preventDefault() to prevent close. - * - * @defaultProperty elementsContent - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/PanelExample.ts - * @language en_US - */ - /** - * Panel 类定义一个容器,该容器为其子代提供标题栏、关闭按钮、可移动区域和内容区域。 - * - * @event eui.UIEvent.CLOSING 面板即将关闭事件,在关闭按钮被点击后抛出, - * 监听此事件并调用event.preventDefault()能够阻止面板被关闭。 - * - * @defaultProperty elementsContent - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/PanelExample.ts - * @language zh_CN - */ - class Panel extends Component { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - * 在窗体上按下时前置窗口 - */ - private onWindowTouchBegin(event); - /** - * write-only property,This property is Usually invoked in resolving an EXML for adding multiple children quickly. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 只写属性,此属性通常在 EXML 的解析器中调用,便于快速添加多个子项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - elementsContent: egret.DisplayObject[]; - /** - * The skin part that defines the appearance of the close button. - * When taped, the close button dispatches a closing event. - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭按钮 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - closeButton: Button; - /** - * The area where the user must drag to move the window. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 可移动区域 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - moveArea: egret.DisplayObject; - /** - * The skin part that defines the appearance of the - * title text in the container. - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 标题显示对象 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - titleDisplay: IDisplayText; - /** - * @private - */ - private _title; - /** - * Title or caption displayed in the title bar. - * - * @default "" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 标题栏中显示的标题。 - * - * @default "" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - title: string; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected partAdded(partName: string, instance: any): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected partRemoved(partName: string, instance: any): void; - /** - * Dispatch the "closing" event when the closeButton is clicked. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当 closeButton 被点击时派发 “closing” 事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onCloseButtonClick(event: egret.TouchEvent): void; - /** - * Close the panel and remove from the parent container. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭面板,从父级容器移除自身。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - close(): void; - /** - * @private - * 触摸按下时的偏移量 - */ - private offsetPointX; - /** - * @private - */ - private offsetPointY; - /** - * Called when the user starts dragging a Panel. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在可移动区域按下 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onTouchBegin(event: egret.TouchEvent): void; - /** - * Called when the user drags a Panel. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触摸拖拽时的移动事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onTouchMove(event: egret.TouchEvent): void; - /** - * Called when the user releases the Panel. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在舞台上弹起事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected onTouchEnd(event: egret.TouchEvent): void; - } -} -declare namespace eui { - /** - * The ProgressBar control provides a visual representation of the progress of a task over time. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ProgressBarExample.ts - * @language en_US - */ - /** - * ProgressBar 控件为随时间而变的任务进度提供了形象化的表示。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ProgressBarExample.ts - * @language zh_CN - */ - class ProgressBar extends Range { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * this hightlight component of the progressbar. - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 进度高亮显示对象。 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - thumb: eui.UIComponent; - /** - * the label of the progressbar. - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 进度条文本 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - labelDisplay: Label; - /** - * @private - */ - private _labelFunction; - /** - * a text format callback function。example: - * labelFunction(value:Number,maximum:Number):String; - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 进度条文本格式化回调函数。示例: - * labelFunction(value:Number,maximum:Number):String; - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - labelFunction: (value: number, maximum: number) => string; - /** - * Convert the current value to display text - * - * @param value the current value - * @param maximum the maximum value - * - * @return a converted text - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 将当前value转换成文本 - * - * @param value 当前值 - * @param maximum 最大值 - * - * @return 转换后的文本 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - protected valueToLabel(value: number, maximum: number): string; - /** - * @private - */ - private _slideDuration; - /** - * Duration in milliseconds for a sliding animation - * when the value changing. If the vlaue is 0, no animation will be done. - * - * @default 500 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * value改变时更新视图的缓动动画时间(毫秒为单位)。设置为0则不执行缓动。 - * - * @default 500 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - slideDuration: number; - /** - * @private - */ - private _direction; - /** - * Direction in which the fill of the ProgressBar expands toward completion. - * you should use the Direction class constants to set the property. - * - * @default Direction.LTR - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * ProgressBar 填充在逐步完成过程中扩展的方向。使用 Direction 类定义的常量。 - * - * @default Direction.LTR - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - direction: string; - /** - * @private - * 动画实例 - */ - private animation; - /** - * @private - * 动画播放结束时要到达的value。 - */ - private slideToValue; - /** - * @private - * - * @param newValue - */ - $setValue(newValue: number): boolean; - /** - * @private - */ - private animationValue; - /** - * @private - * 动画播放更新数值 - */ - private animationUpdateHandler(animation); - /** - * @private - */ - private thumbInitX; - /** - * @private - */ - private thumbInitY; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected partAdded(partName: string, instance: any): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected partRemoved(partName: string, instance: any): void; - /** - * @private - * thumb的位置或尺寸发生改变 - */ - private onThumbResize(event); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateSkinDisplayList(): void; - } -} -declare namespace eui { - /** - * The RadioButton component allows the user make a single choice - * within a set of mutually exclusive choices. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/RadioButtonExample.ts - * @language en_US - */ - /** - * RadioButton 组件使用户可在一组互相排斥的选择中做出一种选择 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/RadioButtonExample.ts - * @language zh_CN - */ - class RadioButton extends ToggleButton { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - * 在RadioButtonGroup中的索引 - */ - $indexNumber: number; - /** - * @private - * 所属的RadioButtonGroup - */ - $radioButtonGroup: RadioButtonGroup; - /** - * The RadioButton component is enabled if the - * RadioButtonGroup is enabled and the RadioButton itself is enabled. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果 RadioButtonGroup 启用且 RadioButton 本身也启用,则 RadioButton 组件启用。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - enabled: boolean; - /** - * @private - */ - private _group; - /** - * The RadioButtonGroup component to which this RadioButton belongs. - * If this property is not set, - * a unique RadioButtonGroup is created automatically based on the groupName property. - * - * @see eui.RadioButton#groupName - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此 RadioButton 所属的 RadioButtonGroup 组件。 - * 若不设置此属性,则根据groupName属性自动创建一个唯一的RadioButtonGroup。 - * - * @see eui.RadioButton#groupName - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - group: RadioButtonGroup; - /** - * @private - */ - private groupChanged; - /** - * @private - */ - private _groupName; - /** - * Specifies the name of the group to which this RadioButton component belongs - * - * @default “radioGroup” - * - * @see eui.RadioButton#group - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * RadioButton 组件所属的组的名称 - * - * @default “radioGroup” - * - * @see eui.RadioButton#group - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - groupName: string; - /** - * @private - * - * @param value - */ - $setSelected(value: boolean): boolean; - /** - * @private - */ - private _value; - /** - * Optional user-defined value - * that is associated with a RadioButton component. - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 与 RadioButton 组件关联的可选用户定义值。 - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - value: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected commitProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected buttonReleased(): void; - /** - * @private - * 添此单选按钮加到组 - */ - private addToGroup(); - } -} -declare namespace eui { - /** - * The RadioButtonGroup component defines a group of RadioButton components - * that act as a single mutually exclusive component; therefore, - * a user can select only one RadioButton component at a time. - * - * @event egret.Event.CHANGE Dispatched when the value of the selected RadioButton component in - * this group changes. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/RadioButtonGroupExample.ts - * @language en_US - */ - /** - * RadioButtonGroup 组件定义一组 RadioButton 组件,这些组件相互排斥;因此,用户每次只能选择一个 RadioButton 组件 - * - * @event egret.Event.CHANGE 此组中所选 RadioButton 组件的值更改时分派。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/RadioButtonGroupExample.ts - * @language zh_CN - */ - class RadioButtonGroup extends egret.EventDispatcher { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - * 组名 - */ - $name: string; - /** - * @private - * 单选按钮列表 - */ - private radioButtons; - /** - * Returns the RadioButton component at the specified index. - * - * @param index The 0-based index of the RadioButton in the - * RadioButtonGroup. - * - * @return The specified RadioButton component if index is between - * 0 and numRadioButtons - 1. Returns - * null if the index is invalid. - * - * @see eui.RadioButtonGroup#numRadioButtons - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 返回指定索引处的 RadioButton 组件。 - * - * @param index RadioButtonGroup 中的 RadioButton 的从零开始的索引。 - * - * @return 当索引位于 0 和 numRadioButtons 之间时,指定的 RadioButton 组件为 1。 - * 如果索引无效,则返回 null。 - * - * @see eui.RadioButtonGroup#numRadioButtons - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - getRadioButtonAt(index: number): RadioButton; - /** - * @private - */ - $enabled: boolean; - /** - * Determines whether selection is allowed. Note that the value returned - * only reflects the value that was explicitly set on the - * RadioButtonGroup and does not reflect any values explicitly - * set on the individual RadioButtons. - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 确定是否允许选择。请注意,返回的值仅反映对 RadioButtonGroup 显式设置的值, - * 而不反映对各个 RadioButton 显式设置的任何值。 - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - enabled: boolean; - /** - * The number of RadioButtons that belong to this RadioButtonGroup. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 属于此 RadioButtonGroup 的 RadioButton 数。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - readonly numRadioButtons: number; - /** - * @private - */ - private _selectedValue; - /** - * The value property of the selected - * RadioButton component in the group, if it has been set, - * otherwise, the label property of the selected RadioButton. - * If no RadioButton is selected, this property is null. - * - *

      If you set selectedValue, selects the - * first RadioButton component whose value or - * label property matches this value.

      - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组中所选 RadioButton 组件的 value 属性(如果未设置), - * 否则为所选 RadioButton 组件的 label 属性。 - * 如果未选择任何 RadioButton,则此属性为 null。 - * - *

      如果设置了 selectedValue,则会选择 valuelabel 属性 - * 与此值匹配的第一个 RadioButton 组件。

      - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - selectedValue: any; - /** - * @private - */ - private _selection; - /** - * Contains a reference to the currently selected - * RadioButton component in the group.This property is valid only - * when the target RadioButton is displayed on the display list - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当前被选中的单选按钮引用。此属性仅当目标RadioButton在显示列表时有效。 - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - selection: RadioButton; - /** - * @private - * 添加单选按钮到组内 - */ - $addInstance(instance: RadioButton): void; - /** - * @private - * 从组里移除单选按钮 - */ - $removeInstance(instance: RadioButton, addListener?: boolean): void; - /** - * @private - * 设置选中的单选按钮 - */ - $setSelection(value: RadioButton, fireChange?: boolean): boolean; - /** - * @private - * 改变选中项 - */ - private changeSelection(index, fireChange?); - /** - * @private - * 单选按钮添加到显示列表 - */ - private addedHandler(event); - /** - * @private - * 单选按钮从显示列表移除 - */ - private removedHandler(event); - } -} -declare namespace eui { - /** - * The Rect component is a rectangular shape. It can be touched. - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * Rect 组件矩形绘图元素。此组件可响应鼠标事件。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class Rect extends Component { - constructor(width?: number, height?: number, fillColor?: number); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $graphics: egret.Graphics; - readonly graphics: egret.Graphics; - /** - * @private - */ - $measureContentBounds(bounds: egret.Rectangle): void; - private $fillColor; - /** - * Fill color - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 填充颜色 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - fillColor: number; - private $fillAlpha; - /** - * Fill alpha - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 填充透明度,默认值为1。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - fillAlpha: number; - private $strokeColor; - /** - * The line's color inside the rect border. Caution: when the strokeWeight is 0, a line is not drawn - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 边框颜色,注意:当 strokeWeight 为 0 时,不显示边框。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - strokeColor: number; - private $strokeAlpha; - /** - * The line's alpha inside the rect border. Caution: when the strokeWeight is 0, a line is not drawn - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 边框透明度,注意:当 strokeWeight 为0时,不显示边框。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - strokeAlpha: number; - private $strokeWeight; - /** - * The line's thickness inside the rect border. Caution: when the strokeWeight is 0, a line is not drawn - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 边框粗细(像素),注意:当 strokeWeight 为 0 时,不显示边框。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - strokeWeight: number; - private $ellipseWidth; - /** - * Width used to draw an ellipse with rounded corners (in pixels). - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 用于绘制圆角的椭圆的宽度(以像素为单位) - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ellipseWidth: number; - private $ellipseHeight; - /** - * Height used to draw an ellipse with rounded corners (in pixels). If no value is specified, the default value matches the value of the ellipseWidth parameter. - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 用于绘制圆角的椭圆的高度 (以像素为单位)。如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ellipseHeight: number; - /** - * @copy eui.UIComponent#updateDisplayList - * - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace eui { - /** - * The Scroller component displays a single scrollable component, - * called a viewport, and horizontal and vertical scroll bars. - * The viewport must implement the IViewport interface. - *

      The Group components implement the IViewport interface - * and can be used as the children of the Scroller control, - * as the following example shows:

      - *
      -     *       
      -     *           
      -     *               
      -     *           
      -     *       
      -     * 
      - *

      The size of the Image control is set larger than that of its parent Group container. - * By default, the child extends past the boundaries of the parent container. - * Rather than allow the child to extend past the boundaries of the parent container, - * the Scroller specifies to clip the child to the boundaries and display scroll bars.

      - * - * @event eui.UIEvent.CHANGE_START Dispatched when the scroll position is going to change - * @event eui.UIEvent.CHANGE_END Dispatched when the scroll position changed complete - * @event egret.Event.CHANGE Dispatched when the scroll position is changing - * @event egret.TouchEvent.TOUCH_CANCEL canceled the touch - * - * @defaultProperty viewport - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ScrollerExample.ts - * @language en_US - */ - /** - * Scroller 组件显示一个称为视域的单个可滚动组件,以及水平滚动条和垂直滚动条。该视域必须实现 IViewport 接口。 - *

      Group 组件实现 IViewport 接口,且可以用作 Scroller 控件的子代,如下例所示:

      - *
      -     *       
      -     *           
      -     *               
      -     *           
      -     *       
      -     * 
      - * Image 控件的大小比其父 Group 容器设置得大。默认情况下,子代超过父容器的边界。 - * Scroller 会指定将子代剪切到边界并显示滚动条,而不是让子代超过父容器的边界。 - * - * @event eui.UIEvent.CHANGE_START 滚动位置改变开始 - * @event eui.UIEvent.CHANGE_END 滚动位置改变结束 - * @event egret.Event.CHANGE 滚动位置改变的时候 - * @event egret.TouchEvent.TOUCH_CANCEL 取消触摸事件 - * - * @defaultProperty viewport - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ScrollerExample.ts - * @language zh_CN - */ - class Scroller extends Component { - /** - * The threshold value(in pixels) trigger the rolling. - * when the touch points deviate from the initial touch point than this value will trigger the rolling. - * - * @default 5 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 开始触发滚动的阈值(以像素为单位),当触摸点偏离初始触摸点的距离超过这个值时才会触发滚动。 - * - * @default 5 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static scrollThreshold: number; - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - private $bounces; - /** - * Whether to enable rebound, rebound When enabled, ScrollView contents allowed to continue to drag the border after arriving at the end user drag operation, and then bounce back boundary position - * @default true - * @version Egret 2.5.6 - * @language en_US - */ - /** - * 是否启用回弹,当启用回弹后,ScrollView中内容在到达边界后允许继续拖动,在用户拖动操作结束后,再反弹回边界位置 - * @default true - * @version Egret 2.5.6 - * @language zh_CN - */ - bounces: boolean; - /** - * Adjust the speed to get out of the slide end.When equal to 0,the scroll animation will not be play. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 调节滑动结束时滚出的速度。等于0时,没有滚动动画 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - throwSpeed: number; - /** - * @private - */ - $getThrowInfo(currentPos: number, toPos: number): eui.ScrollerThrowEvent; - /** - * @private - */ - $Scroller: Object; - /** - * the horizontal scroll bar - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 水平滚动条 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - horizontalScrollBar: eui.HScrollBar; - /** - * the vertical scroll bar - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直滚动条 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - verticalScrollBar: eui.VScrollBar; - /** - * Indicates under what conditions the scroller can be moved and the vertical scroll bar is displayed. - *

      ScrollPolicy.ON - the scroller can be moved, and the scroll bar is displayed when it's move.

      - *

      ScrollPolicy.OFF - the scroller can not be moved, the scroll bar is never displayed.

      - *

      ScrollPolicy.AUTO - the scroller can not be moved when - * the viewport's contentHeight is larger than its height. the scroll bar is displayed when it's move. - * - * @default ScrollPolicy.AUTO - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示在哪些条件可以滚动并且显示垂直滑动条。 - *

      ScrollPolicy.ON - 可以滚动,滚动时显示滚动条。

      - *

      ScrollPolicy.OFF - 不可以滚动并且不显示滚动条。

      - *

      ScrollPolicy.AUTO - 当视域的 contentHeight 大于其自身的高度时可以滚动,滚动时显示滚动条。

      - * - * @default ScrollPolicy.AUTO - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - scrollPolicyV: string; - /** - * Indicates under what conditions the scroller can be moved and the horizontal scroll bar is displayed. - *

      ScrollPolicy.ON - the scroller can be moved, and the scroll bar is displayed when it's move.

      - *

      ScrollPolicy.OFF - the scroller can not be moved, the scroll bar is never displayed.

      - *

      ScrollPolicy.AUTO - the can not be moved when - * the viewport's contentWidth is larger than its width. the scroll bar is displayed when it's move. - * - * @default ScrollPolicy.AUTO - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示在哪些条件下可以滚动并且显示水平滑动条。 - *

      ScrollPolicy.ON - 可以滚动,滚动时显示滚动条。

      - *

      ScrollPolicy.OFF - 不可以滚动并且不显示滚动条。

      - *

      ScrollPolicy.AUTO - 当视域的 contentWidth 大于其自身的宽度时可以滚动,滚动时显示滚动条。

      - * - * @default ScrollPolicy.AUTO - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - scrollPolicyH: string; - /** - * Stop the scroller animation - * @version Egret 3.0.2 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 停止滚动的动画 - * - * @version Egret 3.0.2 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - stopAnimation(): void; - /** - * The viewport component to be scrolled. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要滚动的视域组件。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - viewport: IViewport; - /** - * @private - * 安装并初始化视域组件 - */ - private installViewport(); - /** - * @private - * 卸载视域组件 - */ - private uninstallViewport(); - private onViewPortRemove(event); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected setSkin(skin: Skin): void; - /** - * @private - * @param event - */ - private onTouchBeginCapture(event); - /** - * @private - * @param event - */ - private onTouchEndCapture(event); - /** - * @private - * @param event - */ - private onTouchTapCapture(event); - /** - * @private - * 检查当前滚动策略,若有一个方向可以滚动,返回true。 - */ - private checkScrollPolicy(); - /** - * @private - * 记录按下的对象,touchCancle时使用 - */ - private downTarget; - private tempStage; - /** - * @private - * - * @param event - */ - private onTouchBegin(event); - /** - * @private - * - * @param event - */ - private onTouchMove(event); - /** - * @private - * @param event - */ - private onTouchCancel(event); - /** - * @private - * @param event - */ - private dispatchBubbleEvent(event); - /** - * @private - * @param event - */ - private dispatchCancelEvent(event); - /** - * @private - * @param event - */ - private onTouchEnd(event); - /** - * @private - */ - private onRemoveListeners(); - /** - * @private - * - * @param scrollPos - */ - private horizontalUpdateHandler(scrollPos); - /** - * @private - * - * @param scrollPos - */ - private verticalUpdateHandler(scrollPos); - /** - * @private - * - */ - private horizontalEndHandler(); - /** - * @private - * - */ - private verticalEndHanlder(); - /** - * @private - * - */ - private onChangeEnd(); - /** - * @private - * - * @param event - */ - private onAutoHideTimer(event); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected partAdded(partName: string, instance: any): void; - } -} -declare namespace eui { - /** - * The Skin class defines the base class for all skins. - * You typically don't need to manually create the instance of this class. - * It can be created by resolving a EXML.

      - * - * @example You typically write the skin classes in EXML, as the followiong example shows:

      - *

      -     *      
      -     *      
      -     *          
      -     *              
      -     *          
      -     *          
      -     *      
      -     * 
      - * - * @defaultProperty elementsContent - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/SkinExample.ts - * @language en_US - */ - /** - * 皮肤基类。通常情况下,您不需要手动创建这个类的实例,而是通过解析EXML文件后自动生成。

      - * - * @example 通常您可以按照如下方式写EXML代码:

      - *

      -     *      
      -     *      
      -     *          
      -     *              
      -     *          
      -     *          
      -     *      
      -     * 
      - * - * @defaultProperty elementsContent - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/SkinExample.ts - * @language zh_CN - */ - class Skin extends egret.EventDispatcher { - /** - * The list of skin parts name - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤部件名称列表 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - skinParts: string[]; - /** - * The maximum recommended width of the component to be considered. - * This property can only affect measure result of host component. - * - * @default 100000 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤的最大宽度。仅影响主机组件的测量结果。 - * - * @default 100000 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - maxWidth: number; - /** - * The minimum recommended width of the component to be considered. - * This property can only affect measure result of host component. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤的最小宽度,此属性设置为大于maxWidth的值时无效。仅影响主机组件的测量结果。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - minWidth: number; - /** - * The maximum recommended height of the component to be considered. - * This property can only affect measure result of host component. - * - * @default 100000 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤的最大高度。仅影响主机组件的测量结果。 - * - * @default 100000 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - maxHeight: number; - /** - * The minimum recommended height of the component to be considered. - * This property can only affect measure result of host component. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤的最小高度,此属性设置为大于maxHeight的值时无效。仅影响主机组件的测量结果。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - minHeight: number; - /** - * Number that specifies the explicit width of the skin. - * This property can only affect measure result of host component. - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤显式设置宽度,设置为 NaN 表示不显式设置。仅影响主机组件的测量结果。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * Number that specifies the explicit height of the skin. - * This property can only affect measure result of host component. - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤显式设置高度,设置为 NaN 表示不显式设置。仅影响主机组件的测量结果。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - height: number; - /** - * @private - */ - $elementsContent: egret.DisplayObject[]; - elementsContent: egret.DisplayObject[]; - /** - * @private - */ - private _hostComponent; - /** - * The host component which the skin will be attached. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此皮肤附加到的主机组件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - hostComponent: Component; - /** - * @private - * - * @param event - */ - private onAddedToStage(event?); - /** - * @private - */ - $stateValues: sys.StateValues; - /** - * The list of state for host component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 为此组件定义的视图状态。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - states: State[]; - /** - * The current state of host component. - * Set to "" or null to reset the component back to its base state. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件的当前视图状态。将其设置为 "" 或 null 可将组件重置回其基本状态。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - currentState: string; - /** - * Check if contains the specifies state name. - * @param stateName the state name need to be checked - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 返回是否含有指定名称的视图状态 - * @param stateName 要检查的视图状态名称 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - hasState: (stateName: string) => boolean; - /** - * @private - * 初始化所有视图状态 - */ - private initializeStates; - /** - * @private - * 应用当前的视图状态。子类覆盖此方法在视图状态发生改变时执行相应更新操作。 - */ - private commitCurrentState; - } -} -declare namespace eui { - /** - * The TabBar class displays a set of identical tabs. - * One tab can be selected at a time, and the first tab is selected by default. - *

      The set of tabs is defined by the dataProvider property. - * The appearance of each tab is defined by the ItemRenderer class.

      - *

      You can use the TabBar control to set the active child of a ViewStack container, - * as the following example shows:

      - *
      -     *       
      -     *       
      -     *          
      -     *          
      -     *          
      -     *       
      -     * 
      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TabBarExample.ts - * @language en_US - */ - /** - * TabBar 类显示一组相同的选项卡。一次可以选择一个选项卡,且默认情况下选择第一个选项卡。 - *

      该组选项卡由 dataProvider 属性定义。 - * 每个选项卡的外观由 ItemRenderer 定义。

      - *

      可以使用 TabBar 控件设置 ViewStack 容器的活动子代,如下例所示:

      - *
      -     *       
      -     *       
      -     *          
      -     *          
      -     *          
      -     *       
      -     * 
      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TabBarExample.ts - * @language zh_CN - */ - class TabBar extends ListBase { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected createChildren(): void; - /** - * @private - * - * @param value - */ - $setDataProvider(value: ICollection): boolean; - /** - * @private - */ - private indexBeingUpdated; - /** - * @private - * 触摸点击的选中项改变 - */ - private onIndexChanged(event); - /** - * @private - * ViewStack选中项发生改变 - */ - private onViewStackIndexChange(event); - } -} -declare namespace eui.sys { - /** - * @private - */ - const enum TextInputKeys { - prompt = 0, - displayAsPassword = 1, - textColor = 2, - maxChars = 3, - maxWidth = 4, - maxHeight = 5, - text = 6, - restrict = 7, - inputType = 8, - } -} -declare namespace eui { - /** - * - */ - /** - * The TextInput is a textfield input component, the user can input and edit the text. - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TextInputExample.ts - * @language en_US - */ - /** - * TextInput 是一个文本输入控件,供用户输入和编辑统一格式文本 - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TextInputExample.ts - * @language zh_CN - */ - class TextInput extends Component { - constructor(); - /** - * @private - */ - $TextInput: Object; - /** - * [SkinPart] The TextInput display - * @skinPart - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart] 实体文本输入组件 - * @skinPart - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - textDisplay: EditableText; - /** - * [SkinPart] When the property of the text is empty, it will show the defalut string. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - /** - * [SkinPart] 当text属性为空字符串时要显示的文本。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - promptDisplay: Label; - /** - * @copy eui.EditableText#prompt - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @copy eui.EditableText#prompt - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - prompt: string; - /** - * @copy egret.TextField#displayAsPassword - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @copy egret.TextField#displayAsPassword - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - displayAsPassword: boolean; - /** - * @copy egret.TextField#inputType - * - * @version Egret 3.1.6 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @copy egret.TextField#inputType - * - * @version Egret 3.1.6 - * @version eui 1.0 - * @platform Web,Native - */ - inputType: string; - /** - * @copy egret.TextField#textColor - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @copy egret.TextField#textColor - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - textColor: number; - /** - * @copy egret.TextField#maxChars - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @copy egret.TextField#maxChars - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - maxChars: number; - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - maxWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - maxHeight: number; - /** - * @copy egret.TextField#text - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @copy egret.TextField#text - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - text: string; - /** - * @copy egret.TextField#restrict - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @copy egret.TextField#restrict - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - restrict: string; - /** - * @private - */ - private isFocus; - /** - * @private - * 焦点移入 - */ - private focusInHandler(event); - /** - * @private - * 焦点移出 - */ - private focusOutHandler(event); - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - protected getCurrentState(): string; - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - protected partAdded(partName: string, instance: any): void; - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - protected partRemoved(partName: string, instance: any): void; - /** - * @private - */ - private textDisplayAdded(); - /** - * @private - */ - private textDisplayRemoved(); - } -} -declare namespace eui { - /** - * The CheckBox component consists of an optional label and a small box - * that can contain a check mark or not.

      - * - * When a user clicks a CheckBox component or its associated text, - * the CheckBox component sets its selected property - * to true for checked, and to false for unchecked. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/CheckboxExample.ts - * @language en_US - */ - /** - * CheckBox 组件包含一个可选标签和一个小方框,该方框内可以包含/不包含复选标记。

      - * 用户单击 CheckBox 组件或其关联文本时,CheckBox 组件会将其 selected 属性设置为 true(表示选中)或 false(表示取消选中)。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/CheckboxExample.ts - * @language zh_CN - */ - class CheckBox extends ToggleButton { - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个CheckBox - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - } -} -declare namespace eui { - /** - * The ToggleSwitch control defines an on-off control. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ToggleSwitchExample.ts - * @language en_US - */ - /** - * ToggleSwitch 表示一个开关组件。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ToggleSwitchExample.ts - * @language zh_CN - */ - class ToggleSwitch extends ToggleButton { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - } -} -declare namespace eui { - /** - * The UILayer class is the subclass of the Group class.It not only has the standard function of the Group class,but also - * can keep its size the same to the stage size (Stage.stageWidth,Stage.stageHeight).Its size will changes as the stage size changes. - * like any normal container class,you can create multiple instance of the UILayer class,but it is usually used as the root of the UI display list. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * UILayer 是 Group 的子类,它除了具有容器的所有标准功能,还能够自动保持自身尺寸始终与舞台尺寸相同(Stage.stageWidth,Stage.stageHeight)。 - * 当舞台尺寸发生改变时,它会跟随舞台尺寸改变。UILayer 跟普通容器一样,允许创建多个实例,但通常都将它作为UI显示列表的根节点使用。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class UILayer extends Group { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - * 添加到舞台 - */ - private onAddToStage(event?); - /** - * @private - * 从舞台移除 - */ - private onRemoveFromStage(event); - /** - * @private - * 舞台尺寸改变 - */ - private onResize(event?); - } -} -declare namespace eui { - /** - * The VScrollBar (vertical scrollbar) control lets you control - * the portion of data that is displayed when there is too much data - * to fit vertically in a display area. - * - *

      Although you can use the VScrollBar control as a stand-alone control, - * you usually combine it as part of another group of components to - * provide scrolling functionality.

      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VScrollBarExample.ts - * @language en_US - */ - /** - * VScrollBar(垂直 ScrollBar)控件可以在因数据太多而不能在显示区域中以垂直方向完全显示时控制显示的数据部分。 - *

      虽然 VScrollBar 控件可以单独使用,但通常将它与其他组件一起使用来提供滚动功能。

      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VScrollBarExample.ts - * @language zh_CN - */ - class VScrollBar extends ScrollBarBase { - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected onPropertyChanged(event: eui.PropertyEvent): void; - } -} -declare namespace eui { - /** - * The VSlider (vertical slider) control lets users select a value - * by moving a slider thumb between the end points of the slider track. - * The current value of the slider is determined by the relative location of the thumb between - * the end points of the slider, corresponding to the slider's minimum and maximum values. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VSliderExample.ts - * @language en_US - */ - /** - * 使用 VSlider(垂直滑块)控件,用户可通过在滑块轨道的端点之间移动滑块来选择值。 - * 滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VSliderExample.ts - * @language zh_CN - */ - class VSlider extends SliderBase { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected pointToValue(x: number, y: number): number; - /** - * @private - * - * @returns - */ - private getThumbRange(); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - updateSkinDisplayList(): void; - } -} -declare namespace eui { - /** - * An ViewStack navigator container consists of a collection of child - * containers stacked on top of each other, where only one child - * at a time is visible. - * When a different child container is selected, it seems to replace - * the old one because it appears in the same location. - * However, the old child container still exists; it is just invisible. - * - * @event eui.CollectionEvent.COLLECTION_CHANGE Dispatched when the ICollection has been updated in some way. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ViewStackExample.ts - * @language en_US - */ - /** - * ViewStack 导航器容器由一组彼此上下堆叠的子容器组成,其中一次只可以显示一个子容器。 - * 选择另一个子容器后,它将显示在原来子容器的位置处,所以看起来好像此子容器替换了原来的子容器。 - * 但是,原来的子容器仍然存在,只不过它现在处于不可见状态。 - * - * @event eui.CollectionEvent.COLLECTION_CHANGE 以某种方式更新 ICollection 后分派。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ViewStackExample.ts - * @language zh_CN - */ - class ViewStack extends Group implements ICollection { - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * The layout object for this container. - * This object is responsible for the measurement and layout of - * the visual elements in the container. - * - * @default eui.BasicLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此容器的 layout 对象。此对象负责容器中可视元素的测量和布局。 - * - * @default eui.BasicLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - readonly layout: LayoutBase; - /** - * @private - */ - private _selectedChild; - /** - * A reference to the currently visible child container. - * The default is a reference to the first child. - * If there are no children, this property is null. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 对当前可见子容器的引用。默认设置为对第一个子容器的引用。如果没有子项,则此属性为 null。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - selectedChild: egret.DisplayObject; - /** - * @private - * 在属性提交前缓存选中项索引 - */ - private proposedSelectedIndex; - /** - * @private - */ - _selectedIndex: number; - /** - * The zero-based index of the currently visible child container. - * Child indexes are in the range 0, 1, 2, ..., n - 1, - * where n is the number of children. - * The default value is 0, corresponding to the first child. - * If there are no children, the value of this property is -1. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当前可见子容器的从零开始的索引。子索引的范围是 0、1、2、...、n - 1,其中 n 是子项的数目。 - * 默认值是 0,对应于第一个子项。如果不存在子容器,则此属性的值为 -1。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - selectedIndex: number; - /** - * @private - * 设置选中项索引 - */ - private setSelectedIndex(value); - /** - * @private - * 一个子项被添加到容器内,此方法不仅在操作addChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - $childAdded(child: egret.DisplayObject, index: number): void; - /** - * @private - * 一个子项从容器内移除,此方法不仅在操作removeChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - $childRemoved(child: egret.DisplayObject, index: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected commitProperties(): void; - /** - * @private - * - * @param newIndex - */ - private commitSelection(newIndex); - /** - * @private - * - * @param child - * @param visible - */ - private showOrHide(child, visible); - /** - * number of children - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 子项数量 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - readonly length: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getItemAt(index: number): any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getItemIndex(item: any): number; - } -} -declare namespace eui.sys { - /** - * @private - * 数值缓动工具类 - */ - class Animation { - /** - * @private - */ - constructor(updateFunction: (animation: Animation) => void, thisObject: any); - /** - * @private - * 此动画的缓动行为。设置为null意味着不使用缓动,默认值为 sineInOut - */ - easerFunction: (fraction: number) => number; - /** - * @private - */ - private thisObject; - /** - * @private - * 是否正在播放动画,不包括延迟等待和暂停的阶段 - */ - isPlaying: boolean; - /** - * @private - * 动画持续时间,单位毫秒,默认值500 - */ - duration: number; - /** - * @private - * 动画到当前时间对应的值。 - */ - currentValue: number; - /** - * @private - * 起始值 - */ - from: number; - /** - * @private - * 终点值。 - */ - to: number; - /** - * @private - * 动画启动时刻 - */ - private startTime; - /** - * @private - * 动画播放结束时的回调函数 - */ - endFunction: (animation: Animation) => void; - /** - * @private - * 动画更新时的回调函数 - */ - updateFunction: Function; - /** - * @private - * 开始正向播放动画,无论何时调用都重新从零时刻开始,若设置了延迟会首先进行等待。 - */ - play(): void; - /** - * @private - * 开始播放动画 - */ - private start(); - /** - * @private - * 停止播放动画 - */ - stop(): void; - /** - * @private - * 计算当前值并返回动画是否结束 - */ - private doInterval(currentTime); - } -} -declare namespace eui { - /** - * Default instance of interface IThemeAdapter. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 默认的IThemeAdapter接口实现。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class DefaultThemeAdapter implements IThemeAdapter { - /** - * 解析主题 - * @param url 待解析的主题url - * @param compFunc 解析完成回调函数,示例:compFunc(e:egret.Event):void; - * @param errorFunc 解析失败回调函数,示例:errorFunc():void; - * @param thisObject 回调的this引用 - */ - getTheme(url: string, compFunc: Function, errorFunc: Function, thisObject: any): void; - } -} -declare namespace eui { - /** - * The Watcher class defines utility method that you can use with bindable properties. - * These methods let you define an event handler that is executed whenever a bindable property is updated. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/binding/WatcherExample.ts - * @language en_US - */ - /** - * Watcher 类能够监视可绑定属性的改变,您可以定义一个事件处理函数作为 Watcher 的回调方法,在每次可绑定属性的值改变时都执行此函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/binding/WatcherExample.ts - * @language zh_CN - */ - class Watcher { - /** - * Creates and starts a Watcher instance. - * The Watcher can only watch the property of a Object which host is instance of egret.IEventDispatcher. - * @param host The object that hosts the property or property chain to be watched. - * You can use the use the reset() method to change the value of the host argument - * after creating the Watcher instance. - * The host maintains a list of handlers to invoke when prop changes. - * @param chain A value specifying the property or chain to be watched. - * For example, to watch the property host.a.b.c, - * call the method as: watch(host, ["a","b","c"], ...). - * @param handler An event handler function called when the value of the watched property - * (or any property in a watched chain) is modified. - * @param thisObject this object of which binding with handler - * @returns he ChangeWatcher instance, if at least one property name has been specified to - * the chain argument; null otherwise. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建并启动 Watcher 实例。注意:Watcher 只能监视 host 为 egret.IEventDispatcher 对象的属性改变。若属性链中某个属性所对应的实例不是 egret.IEventDispatcher, - * 则属性链中在它之后的属性改变将无法检测到。 - * @param host 用于承载要监视的属性或属性链的对象。 - * 创建Watcher实例后,您可以利用reset()方法更改host参数的值。 - * 当prop改变的时候,会使得host对应的一系列handlers被触发。 - * @param chain 用于指定要监视的属性链的值。例如,要监视属性 host.a.b.c,需按以下形式调用此方法:watch¬(host, ["a","b","c"], ...)。 - * @param handler 在监视的目标属性链中任何属性的值发生改变时调用的事件处理函数。 - * @param thisObject handler 方法绑定的this对象 - * @returns 如果已为 chain 参数至少指定了一个属性名称,则返回 Watcher 实例;否则返回 null。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static watch(host: any, chain: string[], handler: (value: any) => void, thisObject: any): Watcher; - /** - * @private - * 检查属性是否可以绑定。若还未绑定,尝试添加绑定事件。若是只读或只写属性,返回false。 - */ - private static checkBindable(host, property); - /** - * Constructor. - * Not for public use. This method is called only from the watch() method. - * See the watch() method for parameter usage. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数,非公开。只能从 watch() 方法中调用此方法。有关参数用法,请参阅 watch() 方法。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(property: string, handler: (value: any) => void, thisObject: any, next?: Watcher); - /** - * @private - */ - private host; - /** - * @private - */ - private property; - /** - * @private - */ - private handler; - /** - * @private - */ - private thisObject; - /** - * @private - */ - private next; - /** - * @private - */ - private isExecuting; - /** - * Detaches this Watcher instance, and its handler function, from the current host. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 从当前宿主中断开此 Watcher 实例及其处理函数。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - unwatch(): void; - /** - * Retrieves the current value of the watched property or property chain, or null if the host object is null. - * @example - *
      -         * watch(obj, ["a","b","c"], ...).getValue() === obj.a.b.c
      -         * 
      - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 检索观察的属性或属性链的当前值,当宿主对象为空时此值为空。 - * @example - *
      -         * watch(obj, ["a","b","c"], ...).getValue() === obj.a.b.c
      -         * 
      - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - getValue(): any; - /** - * Sets the handler function.s - * @param handler The handler function. This argument must not be null. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置处理函数。 - * @param handler 处理函数,此参数必须为非空。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - setHandler(handler: (value: any) => void, thisObject: any): void; - /** - * Resets this ChangeWatcher instance to use a new host object. - * You can call this method to reuse a watcher instance on a different host. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 重置此 Watcher 实例使用新的宿主对象。 - * 您可以通过该方法实现一个Watcher实例用于不同的宿主。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - reset(newHost: egret.IEventDispatcher): void; - /** - * @private - * - * @returns - */ - private getHostPropertyValue(); - /** - * @private - */ - private wrapHandler(event); - /** - * @private - */ - private onPropertyChange(property); - } -} -declare namespace eui { - /** - * The Binding class defines utility methods for performing data binding. - * You can use the methods defined in this class to configure data bindings. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/binding/BindingExample.ts - * @language en_US - */ - /** - * 绑定工具类,用于执行数据绑定用的方法集。您可以使用此类中定义的方法来配置数据绑定。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/binding/BindingExample.ts - * @language zh_CN - */ - class Binding { - /** - * Binds a property, prop on the target Object, to a bindable property or peoperty chain. - * @param host The object that hosts the property or property chain to be watched. - * The host maintains a list of targets to update theirs prop when chain changes. - * @param chain A value specifying the property or chain to be watched. For example, when watch the property host.a.b.c, - * you need call the method like this: indProperty(host, ["a","b","c"], ...) - * @param target The Object defining the property to be bound to chain. - * @param prop The name of the public property defined in the site Object to be bound. - * @returns A ChangeWatcher instance, if at least one property name has been specified - * to the chain argument; null otherwise. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 绑定一个对象的属性值到要监视的对象属性上。 - * @param host 用于承载要监视的属性或属性链的对象。 - * 当 hostchain所对应的值发生改变时,target上的prop属性将被自动更新。 - * @param chain 用于指定要监视的属性链的值。例如,要监视属性 host.a.b.c,需按以下形式调用此方法:bindProperty(host, ["a","b","c"], ...)。 - * @param target 本次绑定要更新的目标对象。 - * @param prop 本次绑定要更新的目标属性名称。 - * @returns 如果已为 chain 参数至少指定了一个属性名称,则返回 Watcher 实例;否则返回 null。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static bindProperty(host: any, chain: string[], target: any, prop: string): Watcher; - /** - * Binds a callback, handler on the target Object, to a bindable property or peoperty chain. - * Callback method to invoke with an argument of the current value of chain when that value changes. - * @param host The object that hosts the property or property chain to be watched. - * @param chain A value specifying the property or chain to be watched. For example, when watch the property host.a.b.c, - * you need call the method like this: indProperty(host, ["a","b","c"], ...) - * @param handler method to invoke with an argument of the current value of chain when that value changes. - * @param thisObject this object of binding method - * @returns A ChangeWatcher instance, if at least one property name has been specified to the chain argument; null otherwise. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 绑定一个回调函数到要监视的对象属性上。当 host上 chain 所对应的值发生改变时,handler 方法将被自动调用。 - * @param host 用于承载要监视的属性或属性链的对象。 - * @param chain 用于指定要监视的属性链的值。例如,要监视属性 host.a.b.c,需按以下形式调用此方法:bindSetter(host, ["a","b","c"], ...)。 - * @param handler 在监视的目标属性链中任何属性的值发生改变时调用的事件处理函数。 - * @param thisObject handler 方法绑定的this对象 - * @returns 如果已为 chain 参数至少指定了一个属性名称,则返回 Watcher 实例;否则返回 null。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static bindHandler(host: any, chain: string[], handler: (value: any) => void, thisObject: any): Watcher; - static $bindProperties(host: any, templates: any[], chainIndex: number[], target: any, prop: string): Watcher; - } -} -declare namespace eui { - /** - * The ArrayCollection class is a wrapper class that exposes an any[] as a collection that can be - * accessed and manipulated using the methods and properties of the ICollection interfaces. - * ArrayCollection can notify the view to update item when data source changed. - * - * @event eui.CollectionEvent.COLLECTION_CHANGE Dispatched when the ArrayCollection has been updated in some way. - * - * @defaultProperty source - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/collections/ArrayCollectionExample.ts - * @language en_US - */ - /** - * ArrayCollection 类是数组的集合类数据结构包装器,可使用ICollection接口的方法和属性对其进行访问和处理。 - * 使用这种数据结构包装普通数组,能在数据源发生改变的时候主动通知视图刷新变更数据项。 - * - * @event eui.CollectionEvent.COLLECTION_CHANGE 当 ArrayCollection 更新的的时候会派发此事件。 - * - * @defaultProperty source - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/collections/ArrayCollectionExample.ts - * @language zh_CN - */ - class ArrayCollection extends egret.EventDispatcher implements ICollection { - /** - * Constructor.

      - * Creates a new ArrayCollection using the specified source array. - * If no array is specified an empty array will be used. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。

      - * 用指定的原始数组创建一个 ArrayCollection 实例。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(source?: any[]); - /** - * @private - */ - private _source; - /** - * The source of data in the ArrayCollection. - * The ArrayCollection object does not represent any changes that you make - * directly to the source array. Always use the ICollection methods to view the collection. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据源 - * 通常情况下请不要直接调用Array的方法操作数据源,否则对应的视图无法收到数据改变的通知。通常都是通过ICollection的接口方法来查看数据。 - * 若对数据源进行了修改,请手动调用refresh()方法刷新数据。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - source: any[]; - /** - * Applies the sort and filter to the view. - * The ArrayCollection does not detect source data changes automatically, - * so you must call the refresh() - * method to update the view after changing the source data. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在对数据源进行排序或过滤操作后可以手动调用此方法刷新所有数据,以更新视图。 - * ArrayCollection 不会自动检原始数据进行了改变,所以你必须调用refresh()方法去更新显示。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - refresh(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - readonly length: number; - /** - * Adds the specified item to the end of the list. - * Equivalent to addItemAt(item, length). - * @param item The item to add. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 向列表末尾添加指定项目。等效于 addItemAt(item, length)。 - * @param item 要被添加的项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - addItem(item: any): void; - /** - * Adds the item at the specified index. - * The index of any item greater than the index of the added item is increased by one. - * If the the specified index is less than zero or greater than the length - * of the list, a Error which code is 1007 is thrown. - * @param item The item to place at the index. - * @param index The index at which to place the item. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在指定的索引处添加项目。 - * 任何大于已添加项目的索引的项目索引都会增加 1。 - * 如果指定的索引比0小或者比最大长度要大。则会抛出1007异常。 - * @param item 要添加的项 - * @param index 要添加的指定索引位置 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - addItemAt(item: any, index: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getItemAt(index: number): any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getItemIndex(item: any): number; - /** - * Notifies the view that an item has been updated. - * @param item The item within the view that was updated. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 通知视图,某个项目的属性已更新。 - * @param item 视图中需要被更新的项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - itemUpdated(item: any): void; - /** - * Removes all items from the list. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 删除列表中的所有项目。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - removeAll(): void; - /** - * Removes the item at the specified index and returns it. - * Any items that were after this index are now one index earlier. - * @param index The index from which to remove the item. - * @return The item that was removed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 删除指定索引处的项目并返回该项目。原先位于此索引之后的所有项目的索引现在都向前移动一个位置。 - * @param index 要被移除的项的索引。 - * @return 被移除的项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - removeItemAt(index: number): any; - /** - * Replaces the item at the specified index. - * @param item The new item to be placed at the specified index. - * @param index The index at which to place the item. - * @return The item that was replaced, or null if none. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 替换在指定索引处的项目,并返回该项目。 - * @param item 要在指定索引放置的新的项。 - * @param index 要被替换的项的索引位置。 - * @return 被替换的项目,如果没有该项则返回null 。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - replaceItemAt(item: any, index: number): any; - /** - * Replaces all items with a new source data, this method can not reset the scroller position of view. - * @param newSource new source data. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 用新数据源替换原始数据源,此方法与直接设置source不同,它不会导致目标视图重置滚动位置。 - * @param newSource 新数据。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - replaceAll(newSource: any[]): void; - /** - * @private - * 抛出事件 - */ - private dispatchCoEvent(kind, location?, oldLocation?, items?, oldItems?); - } -} -declare namespace eui.sys { - /** - * @private - */ - const enum EditableTextKeys { - promptText = 0, - textColorUser = 1, - asPassword = 2, - } -} -declare namespace eui { - /** - * Editable text for displaying, - * scrolling, selecting, and editing text. - * @includeExample extension/eui/components/EditablTextExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 可编辑文本,用于显示、滚动、选择和编辑文本。 - * @includeExample extension/eui/components/EditablTextExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class EditableText extends egret.TextField implements UIComponent, IDisplayText { - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - $EditableText: Object; - /** - * @private - * - */ - $invalidateTextField(): void; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * - * @param value - */ - $getText(): string; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - /** - * @private - */ - private _widthConstraint; - /** - * @private - * - * @param stage - * @param nestLevel - */ - $onAddToStage(stage: egret.Stage, nestLevel: number): void; - /** - * @private - * - */ - $onRemoveFromStage(): void; - /** - * @private - */ - private $isShowPrompt; - /** - * When the property of the text is empty, it will show the defalut string. - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当text属性为空字符串时要显示的文本内容。 - * 先创建文本控件时将显示提示文本。控件获得焦点时或控件的 text 属性为非空字符串时,提示文本将消失。 - * 控件失去焦点时提示文本将重新显示,但仅当未输入文本时(如果文本字段的值为空字符串)。

      - * 对于文本控件,如果用户输入文本,但随后又将其删除,则控件失去焦点后,提示文本将重新显示。 - * 您还可以通过编程方式将文本控件的 text 属性设置为空字符串使提示文本重新显示。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - prompt: string; - /** - * @private - */ - private $promptColor; - /** - * @private - */ - private $isFocusIn; - /** - * The color of the defalut string. - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本的颜色 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - promptColor: number; - /** - * @private - */ - private onfocusOut(); - /** - * @private - */ - private $isTouchCancle; - /** - * @private - */ - private onTouchBegin(); - /** - * @private - */ - private onTouchCancle(); - /** - * @private - */ - private onfocusIn(); - /** - * @private - */ - private showPromptText(); - /** - * @private - */ - $setTextColor(value: number): boolean; - /** - * @private - */ - $setDisplayAsPassword(value: boolean): boolean; - /** - * @private - * UIComponentImpl 定义的所有变量请不要添加任何初始值,必须统一在此处初始化。 - */ - private initializeUIValues; - /** - * @copy eui.Component#createChildren() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected createChildren(): void; - /** - * @copy eui.Component#childrenCreated() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected childrenCreated(): void; - /** - * @copy eui.Component#commitProperties() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected commitProperties(): void; - /** - * @copy eui.Component#measure() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected measure(): void; - /** - * @copy eui.Component#updateDisplayList() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * @copy eui.Component#invalidateParentLayout() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected invalidateParentLayout(): void; - /** - * @private - */ - $UIComponent: Object; - /** - * @private - */ - $includeInLayout: boolean; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - includeInLayout: boolean; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - left: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - right: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - top: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - bottom: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - horizontalCenter: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - verticalCenter: any; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxWidth: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setMeasuredSize(width: number, height: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateSize(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateSize(recursive?: boolean): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateNow(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsSize(layoutWidth: number, layoutHeight: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsPosition(x: number, y: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getLayoutBounds(bounds: egret.Rectangle): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getPreferredBounds(bounds: egret.Rectangle): void; - } -} -declare namespace eui.sys { - /** - * @private - * 一个工具类,用于容器的滚屏拖动操作,计算在一段时间持续滚动后释放,应该继续滚动到的值和缓动时间。 - * 使用此工具类,您需要创建一个 ScrollThrown 实例,并在滚动发生时调用start()方法,然后在触摸移动过程中调用update()更新当前舞台坐标。 - * 内部将会启动一个计时器定时根据当前位置计算出速度值,并缓存下来最后4个值。当停止滚动时,再调用finish()方法, - * 将立即停止记录位移,并将计算出的最终结果存储到 Thrown.scrollTo 和 Thrown.duration 属性上。 - */ - class TouchScroll { - /** - * @private - * 创建一个 TouchScroll 实例 - * @param updateFunction 滚动位置更新回调函数 - */ - constructor(updateFunction: (scrollPos: number) => void, endFunction: () => void, target: egret.IEventDispatcher); - /** - * @private - * 当前容器滚动外界可调节的系列 - */ - $scrollFactor: number; - /** - * @private - */ - private target; - /** - * @private - */ - private updateFunction; - /** - * @private - */ - private endFunction; - /** - * @private - */ - private previousTime; - /** - * @private - */ - private velocity; - /** - * @private - */ - private previousVelocity; - /** - * @private - */ - private currentPosition; - /** - * @private - */ - private previousPosition; - /** - * @private - */ - private currentScrollPos; - /** - * @private - */ - private maxScrollPos; - /** - * @private - * 触摸按下时的偏移量 - */ - private offsetPoint; - /** - * @private - * 停止触摸时继续滚动的动画实例 - */ - private animation; - $bounces: boolean; - /** - * @private - * 正在播放缓动动画的标志。 - */ - isPlaying(): boolean; - /** - * @private - * 如果正在执行缓动滚屏,停止缓动。 - */ - stop(): void; - private started; - /** - * @private - * true表示已经调用过start方法。 - */ - isStarted(): boolean; - /** - * @private - * 开始记录位移变化。注意:当使用完毕后,必须调用 finish() 方法结束记录,否则该对象将无法被回收。 - * @param touchPoint 起始触摸位置,以像素为单位,通常是stageX或stageY。 - */ - start(touchPoint: number): void; - /** - * @private - * 更新当前移动到的位置 - * @param touchPoint 当前触摸位置,以像素为单位,通常是stageX或stageY。 - */ - update(touchPoint: number, maxScrollValue: number, scrollValue: any): void; - /** - * @private - * 停止记录位移变化,并计算出目标值和继续缓动的时间。 - * @param currentScrollPos 容器当前的滚动值。 - * @param maxScrollPos 容器可以滚动的最大值。当目标值不在 0~maxValue之间时,将会应用更大的摩擦力,从而影响缓动时间的长度。 - */ - finish(currentScrollPos: number, maxScrollPos: number): void; - /** - * @private - * - * @param timeStamp - * @returns - */ - private onTick(timeStamp); - /** - * @private - * - * @param animation - */ - private finishScrolling(animation?); - /** - * @private - * 缓动到水平滚动位置 - */ - private throwTo(hspTo, duration?); - /** - * @private - * 更新水平滚动位置 - */ - private onScrollingUpdate(animation); - } -} -declare namespace eui { - /** - * Defines values for setting the direction property - * of the ProgressBar class. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/DirectionExample.ts - * @language en_US - */ - /** - * 定义进度条等控件增长方向的常量 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/DirectionExample.ts - * @language zh_CN - */ - class Direction { - /** - * Specifies left-to-right direction. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 水平从左到右增长 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static LTR: string; - /** - * Specifies right-to-left direction. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 水平从右到左增长 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static RTL: string; - /** - * Specifies top-to-bottom direction. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 竖直从上到下增长 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static TTB: string; - /** - * Specifies bottom-to-top direction. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 竖直从下到上增长 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static BTT: string; - } -} -declare namespace eui { - interface IAssetAdapter { - getAsset(source: string, callBack: (content: any, source: string) => void, thisObject: any): void; - } -} -declare namespace eui { - /** - * The IDisplayText interface defines the properties - * for simple text display.。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * IDisplayText 接口定义简单文本显示的属性. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - interface IDisplayText { - /** - * The text displayed by this text component. - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此文本组件所显示的文本。 - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - text: string; - } -} -declare namespace eui { - /** - * The IItemRenderer interface defines the basic set of APIs - * that used for List class. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 列表类组件的项呈示器接口。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - interface IItemRenderer extends UIComponent { - /** - * The data to render or edit. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要呈示或编辑的数据。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - data: any; - /** - * Contains true if the item renderer - * can show itself as selected. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果项呈示器可以将其自身显示为已选中,则为 true。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - selected: boolean; - /** - * The index of the item in the data provider - * of the host component of the item renderer. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 项呈示器的数据提供程序中的项目索引。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - itemIndex: number; - } -} -declare namespace eui { - interface IThemeAdapter { - getTheme(url: string, compFunc: Function, errorFunc: Function, thisObject: any): void; - } -} -declare namespace eui { - /** - * The IViewport interface is implemented by components that support a viewport. - * - * If a component's children are larger than the component, - * and you want to clip the children to the component boundaries, you can define a viewport. - * - * A viewport is a rectangular subset of the area of a component that you want to display, - * rather than displaying the entire component. - * - * @see eui.Scroller - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 支持视区的组件接口。 - * - * 如果组件的内容子项比组件要大,而且您向往子项可以在父级组件的边缘处被裁减,您可以定义一个视区。 - * - * 视区是您希望显示的组件的区域的矩形子集,而不是显示整个组件。 - * - * @see eui.Scroller - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - interface IViewport extends UIComponent { - /** - * The width of the viewport's contents. - * - * If scrollEnabled is true, the viewport's - * contentWidth defines the limit for horizontal scrolling - * and the viewport's actual width defines how much of the content is visible. - * - * To scroll through the content horizontally, vary the - * scrollH between 0 and - * contentWidth - width. - * - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 视域的内容的宽度。 - * - * 如果 scrollEnabled 为 true, 则视域的 contentWidth 为水平滚动定义限制, - * 且视域的实际宽度定义可见的内容量。 - * - * 要在内容中水平滚动, 请在 0 和 contentWidth - width 之间更改 scrollH 。 - * - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - contentWidth: number; - /** - * The height of the viewport's content. - * - * If scrollEnabled is true, the viewport's - * contentHeight defines the limit for vertical scrolling - * and the viewport's actual height defines how much of the content is visible. - * - * To scroll through the content vertically, vary the - * scrollV between 0 and - * contentHeight - height. - * - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 视域的内容的高度。 - * - * 如果 scrollEnabled 为 true,则视域的 contentHeight 为垂直滚动定义限制, - * 且视域的实际高度定义可见的内容量。要在内容中垂直滚动,请在 0 和 contentHeight - height - * 之间更改 scrollV。 - * - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - contentHeight: number; - /** - * The x coordinate of the origin of the viewport in the component's coordinate system, - * where the default value is (0,0) corresponding to the upper-left corner of the component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 可视区域水平方向起始点。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - scrollH: number; - /** - * The y coordinate of the origin of the viewport in the component's coordinate system, - * where the default value is (0,0) corresponding to the upper-left corner of the component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 可视区域竖直方向起始点。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - scrollV: number; - /** - * If true, specifies to clip the children to the boundaries of the viewport. - * If false, the container children extend past the container boundaries, - * regardless of the size specification of the component. - * - * @default false - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 是否启用容器滚动。如果为 true,则将子项剪切到视区的边界,配合设置scrollH和scrollV属性将能滚动视区。 - * 如果为 false,则容器子代会从容器边界扩展过去,而设置scrollH和scrollV也无效。默认false。 - * - * @default false - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - scrollEnabled: boolean; - } -} -declare namespace eui { - /** - * Values for the horizontalCanScroll and - * verticalCanScroll properties of the Scroller classes. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/ScrollPolicyExample.ts - * @language en_US - */ - /** - * 滚动条显示策略常量。 - * Scroller 类的 horizontalCanScrollverticalCanScroll 属性的值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/ScrollPolicyExample.ts - * @language zh_CN - */ - class ScrollPolicy { - /** - * Show the scrollbar if the children exceed the owner's dimension. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果子项超出父级的尺寸,则允许滚动,反之不允许滚动。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static AUTO: string; - /** - * Never show the scrollbar. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 从不允许滚动。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static OFF: string; - /** - * Always show the scrollbar. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 总是允许滚动。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static ON: string; - } -} -declare namespace eui { - /** - * Note: The skin name values in the skin theme are used as default values,which can not be changed while running. - * You can change the skin of a component with the skinName property. - * @event egret.Event.COMPLETE Dispatch when EXML used in this theme is loaded and parsed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/ThemeExample.ts - * @language en_US - */ - /** - * 皮肤主题。注意:皮肤主题是一次性设置的默认值,并不能运行时切换所有组件默认皮肤。切换单个皮肤您可以自行对Component.skinName赋值来修改。 - * @event egret.Event.COMPLETE 当主题关联的EXML加载解析完成时派发 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/ThemeExample.ts - * @language zh_CN - */ - class Theme extends egret.EventDispatcher { - private $configURL; - /** - * Create an instance of Theme - * @param configURL the external theme path. if null, you need to register the default skin name with - * mapSkin() manually. - * @param stage current stage. - * If null, you need to register with egret.registerImplementation("eui.Theme",theme) - * manually. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个主题实例 - * @param configURL 要加载并解析的外部主题配置文件路径。若传入 null,将不进行配置文件加载, - * 之后需要在外部以代码方式手动调用 mapSkin() 方法完成每条默认皮肤名的注册。 - * @param stage 当前舞台引用。 - * 若传入null,需要在外部手动调用 egret.registerImplementation("eui.Theme",theme) 来完成主题的注册。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(configURL: string, stage?: egret.Stage); - /** - * @private - */ - private initialized; - /** - * @private - * - * @param url - */ - private load(url); - /** - * @private - * - * @param str - */ - private onConfigLoaded(str); - private onLoaded(classes?, urls?); - /** - * @private - */ - private delayList; - /** - * @private - * - */ - private handleDelayList(); - /** - * @private - */ - private skinMap; - /** - * According to the host component to get the default skin name. - * Search rules are as follows: - *

    • 1. Use the hostComponentKey of client to search.
    • - *
    • 2. Use the class name of client to search.
    • - *
    • 3. Use the parent class name of client to search.
    • - *
    • 4. Repeat step 3 until find the skin name or the parent is eui.Component.
    • - * @param client the component need to get the default skin. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 根据主机组件,获取对应的默认皮肤名。查询规则如下: - *
    • 1.使用client的hostComponentKey作为键查询默认皮肤名。
    • - *
    • 2.使用client的类名作为键查询默认皮肤名。
    • - *
    • 3.使用client的父类名作为键查询默认皮肤名。
    • - *
    • 4.不断重复3直到查询到皮肤名或父类为eui.Component时停止。
    • - * @param client 要获取默认皮肤的组件。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - getSkinName(client: Component): string; - /** - * @private - */ - private findSkinName(prototype); - /** - * Map a default skin for the specified host component. - * @param hostComponentKey the name of host component, such as "eui.Button". - * @param skinName the name of skin, such as "app.MyButtonSkin". - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 为指定的主机组件映射一个默认皮肤。 - * @param hostComponentKey 主机组件名称,例如:“eui.Button”。 - * @param skinName 皮肤名称 例如:"app.MyButtonSkin"。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - mapSkin(hostComponentKey: string, skinName: string): void; - /** - * @private - * styles 配置信息 - */ - private $styles; - $getStyleConfig(style: string): any; - } -} -declare namespace eui { - /** - * The eui.CollectionEvent class represents an event that is - * dispatched when the associated collection changes. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/CollectionEventExample.ts - * @language en_US - */ - /** - * 集合类型数据改变事件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/CollectionEventExample.ts - * @language zh_CN - */ - class CollectionEvent extends egret.Event { - /** - * Dispatched when a collection has changed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 集合类数据发生改变 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static COLLECTION_CHANGE: string; - /** - * Constructor. - * - * @param type The event type; indicates the action that triggered the event. - * @param bubbles Specifies whether the event can bubble - * up the display list hierarchy. - * @param cancelable Specifies whether the behavior - * associated with the event can be prevented. - * @param kind Indicates the kind of event that occured. - * The parameter value can be one of the values in the CollectionEventKind - * class, or null, which indicates that the kind is unknown. - * @param location When the kind is - * CollectionEventKind.ADD, - * CollectionEventKind.REMOVE, - * CollectionEventKind.REPLACE,or - * CollectionEventKind.UPDATE - * this value indicates at what location the item(s) specified - * in the items property can be found - * within the target collection. - * @param oldLocation this value indicates - * the old location within the target collection - * of the item(s) specified in the items property. - * @param items Array of objects with information about the items - * affected by the event. - * @param oldItems When the kine is CollectionEventKind.REPLACE the value represents - * a list of items before replaced. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 CollectionEvent 实例 - * - * @param type 事件类型;指示触发事件的动作。 - * @param bubbles 指定该事件是否可以在显示列表层次结构得到冒泡处理。 - * @param cancelable 指定是否可以防止与事件相关联的行为。 - * @param kind 指示发生的事件类型。此属性值可以是 CollectionEventKind 类中的一个值,也可以是 null,用于指示类型未知。 - * @param location 如果 kind 值为 CollectionEventKind.ADD, - * CollectionEventKind.REMOVE, - * CollectionEventKind.REPLACE,或 - * CollectionEventKind.UPDATE - * 则此属性为 items 属性中指定的项目集合中零号元素的的索引。 - * @param oldLocation 此值指示 items 属性中指定的项目在目标集合中的原位置。 - * @param items 受事件影响的项目的列表。 - * @param oldItems 仅当kind的值为CollectionEventKind.REPLACE时,表示替换前的项目列表。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, kind?: string, location?: number, oldLocation?: number, items?: any[], oldItems?: any[]); - /** - * @private - * - * @param kind - * @param location - * @param oldLocation - * @param items - * @param oldItems - */ - $initTo(kind?: string, location?: number, oldLocation?: number, items?: any[], oldItems?: any[]): void; - /** - * Indicates the kind of event that occured. - * The parameter value can be one of the values in the CollectionEventKind - * class, or null, which indicates that the kind is unknown. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示发生的事件类型。此属性值可以是 CollectionEventKind 类中的一个值,也可以是 null,用于指示类型未知。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - kind: string; - /** - * Array of objects with information about the items. - * affected by the event. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 受事件影响的项目的列表。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - items: any[]; - /** - * When the kine is CollectionEventKind.REPLACE the value represents - * a list of items before replaced. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 仅当kind的值为CollectionEventKind.REPLACE时,表示替换前的项目列表。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - oldItems: any[]; - /** - * When the kind is - * CollectionEventKind.ADD, - * CollectionEventKind.REMOVE, - * CollectionEventKind.REPLACE,or - * CollectionEventKind.UPDATE - * this value indicates at what location the item(s) specified - * in the items property can be found - * within the target collection. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果 kind 值为 CollectionEventKind.ADD、 - * CollectionEventKind.REMOVE 或 CollectionEventKind.REPLACE, - * CollectionEventKind.UPDATE - * 则此属性为 items 属性中指定的项目集合中零号元素的的索引。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - location: number; - /** - * this value indicates - * the old location within the target collection - * of the item(s) specified in the items property. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此属性为 items 属性中指定的项目在目标集合中原来位置的从零开始的索引。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - oldLocation: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected clean(): void; - /** - * Dispatch an event with specified EventDispatcher. The dispatched event will be cached in the object pool, - * for the next cycle of reuse. - * - * @param target the target of event dispatcher. - * @param eventType The event type; indicates the action that triggered the event. - * @param kind Indicates the kind of event that occured. - * The parameter value can be one of the values in the CollectionEventKind - * class, or null, which indicates that the kind is unknown. - * @param location When the kind is - * CollectionEventKind.ADD, - * CollectionEventKind.REMOVE, - * CollectionEventKind.REPLACE,or - * CollectionEventKind.UPDATE - * this value indicates at what location the item(s) specified - * in the items property can be found - * within the target collection. - * @param oldLocation this value indicates - * the old location within the target collection - * of the item(s) specified in the items property. - * @param items Array of objects with information about the items - * affected by the event. - * @param oldItems When the kine is CollectionEventKind.REPLACE the value represents - * a list of items before replaced. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * - * @param target 事件派发目标。 - * @param eventType 事件类型;指示触发事件的动作。 - * @param kind 指示发生的事件类型。此属性值可以是 CollectionEventKind 类中的一个值,也可以是 null,用于指示类型未知。 - * @param location 如果 kind 值为 CollectionEventKind.ADD, - * CollectionEventKind.REMOVE, - * CollectionEventKind.REPLACE,或 - * CollectionEventKind.UPDATE - * 则此属性为 items 属性中指定的项目集合中零号元素的的索引。 - * @param oldLocation 此值指示 items 属性中指定的项目在目标集合中的原位置。 - * @param items 受事件影响的项目的列表。 - * @param oldItems 仅当kind的值为CollectionEventKind.REPLACE时,表示替换前的项目列表。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static dispatchCollectionEvent(target: egret.IEventDispatcher, eventType: string, kind?: string, location?: number, oldLocation?: number, items?: any[], oldItems?: any[]): boolean; - } -} -declare namespace eui { - /** - * The CollectionEventKind class contains constants for the valid values - * of the CollectionEvent class kind property. - * These constants indicate the kind of change that was made to the collection. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 定义 CollectionEventkind 属性的有效值的常量。 - * 这些常量指示对集合进行的更改类型。 - - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class CollectionEventKind { - /** - * Indicates that the collection added an item or items. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示集合添加了一个或多个项目。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static readonly ADD: string; - /** - * Indicates that the collection applied a sort, a filter, or both. - * This change can potentially be easier to handle than a RESET. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示集合应用了排序或/和筛选。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static readonly REFRESH: string; - /** - * Indicates that the collection removed an item or items. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示集合删除了一个或多个项目。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static readonly REMOVE: string; - /** - * Indicates that the item at the position identified by the - * CollectionEvent location property has been replaced. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示已替换由 CollectionEvent.location 属性确定的位置处的项目。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static readonly REPLACE: string; - /** - * Indicates that the collection has changed so drastically that - * a reset is required. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示集合已彻底更改,需要进行重置。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static readonly RESET: string; - /** - * Indicates that one or more items were updated within the collection. - * The affected item(s) - * are stored in the CollectionEvent.items property. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示集合中一个或多个项目进行了更新。受影响的项目将存储在 CollectionEvent.items 属性中。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static readonly UPDATE: string; - } -} -declare namespace eui { - /** - * Represents events that are dispatched when a item has been touched. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/ItemTapEventExample.ts - * @language en_US - */ - /** - * 列表项触碰事件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/ItemTapEventExample.ts - * @language zh_CN - */ - class ItemTapEvent extends egret.Event { - /** - * The type of the event object for an itemTap event. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * itemTap 事件的对象类型。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static ITEM_TAP: string; - /** - * The item in the data provider of the associated item. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触发触摸事件的项呈示器数据源项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - item: any; - /** - * The item renderer in the list of the associated item. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触发触摸事件的项呈示器。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - itemRenderer: IItemRenderer; - /** - * The index of the associated navigation item. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触发触摸事件的项索引 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - itemIndex: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected clean(): void; - /** - * Dispatch an event with specified EventDispatcher. The dispatched event will be cached in the object pool, - * for the next cycle of reuse. - * - * @param target the target of event dispatcher. - * @param eventType The event type; indicates the action that triggered the event. - * @param itemRenderer The item renderer in the list of the associated item. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 EventDispatcher 对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * - * @param target 事件派发目标 - * @param eventType 事件类型;指示触发事件的动作。 - * @param itemRenderer 触发触摸事件的项呈示器。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static dispatchItemTapEvent(target: egret.IEventDispatcher, eventType: string, itemRenderer?: IItemRenderer): boolean; - } -} -declare namespace eui { - /** - * The PropertyChangeEvent class represents the event object - * passed to the event listener when one of the properties of - * an object has changed, and provides information about the change. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/PropertyEventExample.ts - * @language en_US - */ - /** - * 对象的一个属性发生更改时传递到事件侦听器的事件。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/PropertyEventExample.ts - * @language zh_CN - */ - class PropertyEvent extends egret.Event { - /** - * Dispatch when a property changed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 属性改变。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static PROPERTY_CHANGE: string; - /** - * Constructor. - * - * @param type The event type; indicates the action that triggered the event. - * @param bubbles Specifies whether the event can bubble - * up the display list hierarchy. - * @param cancelable Specifies whether the behavior - * associated with the event can be prevented. - * @param property Name of the property that changed. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个属性改变事件。 - * - * @param type 事件类型;指示触发事件的动作。 - * @param bubbles 指定该事件是否可以在显示列表层次结构得到冒泡处理。 - * @param cancelable 指定是否可以防止与事件相关联的行为。 - * @param property 发生改变的属性名称。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, property?: string); - /** - * Name of the property that changed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 发生改变的属性名称。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - property: string; - /** - * Dispatch an event with specified EventDispatcher. The dispatched event will be cached in the object pool, - * for the next cycle of reuse. - * - * @param target the target of event dispatcher. - * @param eventType The event type; indicates the action that triggered the event. - * @param property Name of the property that changed. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 EventDispatcher 对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * - * @param target 事件派发目标 - * @param eventType 事件类型;指示触发事件的动作。 - * @param property 发生改变的属性名称。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static dispatchPropertyEvent(target: egret.IEventDispatcher, eventType: string, property?: string): boolean; - } -} -declare namespace eui { - /** - * @private - */ - class ScrollerThrowEvent extends egret.Event { - static THROW: string; - /** - * 滚动区域当前滚动位置 - */ - currentPos: number; - /** - * 要滚动到的位置 - * 修改当前值会修改要滚动到得位置,但是当 moveFlag 为 false 时修改此值依然不会滚动,若此时依然要调整滚动区域的位置可以自己设置 - */ - toPos: number; - /** - * 动画信息,可调节或修改 - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, currentPos?: number, toPos?: number); - } -} -declare namespace eui { - /** - * The UIEvent class represents the event object passed to - * the event listener for many UI events. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/UIEventExample.ts - * @language en_US - */ - /** - * UI事件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/UIEventExample.ts - * @language zh_CN - */ - class UIEvent extends egret.Event { - /** - * Constructor. - * - * @param type The event type; indicates the action that triggered the event. - * @param bubbles Specifies whether the event can bubble - * up the display list hierarchy. - * @param cancelable Specifies whether the behavior - * associated with the event can be prevented. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 UIEvent 实例 - * - * @param type 事件类型;指示触发事件的动作。 - * @param bubbles 指定该事件是否可以在显示列表层次结构得到冒泡处理。 - * @param cancelable 指定是否可以防止与事件相关联的行为。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * creation complete of component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件创建完成 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static CREATION_COMPLETE: string; - /** - * the ending of change. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 改变结束 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static CHANGE_END: string; - /** - * The beginning of change. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 改变开始 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static CHANGE_START: string; - /** - * Before close the panel. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 即将关闭面板事件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static CLOSING: string; - /** - * The coordinates of the UI components changed in it's parent. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * UI组件在父级容器中的坐标发生改变事件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static MOVE: string; - /** - * Dispatch an event with specified EventDispatcher. The dispatched event will be cached in the object pool, - * for the next cycle of reuse. - * - * @param target the target of event dispatcher. - * @param eventType The event type; indicates the action that triggered the event. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * - * @param target 事件派发目标。 - * @param eventType 事件类型;指示触发事件的动作。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static dispatchUIEvent(target: egret.IEventDispatcher, eventType: string, bubbles?: boolean, cancelable?: boolean): boolean; - } -} -declare namespace eui.sys { - /** - * @private - * 代码生成工具基类 - */ - class CodeBase { - /** - * @private - * - * @returns - */ - toCode(): string; - /** - * @private - */ - indent: number; - /** - * @private - * 获取缩进字符串 - */ - getIndent(indent?: number): string; - } - /** - * @private - */ - class EXClass extends CodeBase { - /** - * @private - * 构造函数代码块 - */ - constructCode: EXCodeBlock; - /** - * @private - * 类名,不包括模块名 - */ - className: string; - /** - * @private - * 父类类名,包括完整模块名 - */ - superClass: string; - /** - * @private - * 内部类区块 - */ - private innerClassBlock; - /** - * @private - * 添加一个内部类 - */ - addInnerClass(clazz: EXClass): void; - /** - * @private - * 变量定义区块 - */ - private variableBlock; - /** - * @private - * 添加变量 - */ - addVariable(variableItem: EXVariable): void; - /** - * @private - * 根据变量名获取变量定义 - */ - getVariableByName(name: string): EXVariable; - /** - * @private - * 函数定义区块 - */ - private functionBlock; - /** - * @private - * 添加函数 - */ - addFunction(functionItem: EXFunction): void; - /** - * @private - * 根据函数名返回函数定义块 - */ - getFuncByName(name: string): EXFunction; - /** - * @private - * - * @returns - */ - toCode(): string; - } - /** - * @private - */ - class EXCodeBlock extends CodeBase { - /** - * @private - * 添加变量声明语句 - * @param name 变量名 - * @param value 变量初始值 - */ - addVar(name: string, value?: string): void; - /** - * @private - * 添加赋值语句 - * @param target 要赋值的目标 - * @param value 值 - * @param prop 目标的属性(用“.”访问),不填则是对目标赋值 - */ - addAssignment(target: string, value: string, prop?: string): void; - /** - * @private - * 添加返回值语句 - */ - addReturn(data: string): void; - /** - * @private - * 添加一条空行 - */ - addEmptyLine(): void; - /** - * @private - * 开始添加if语句块,自动调用startBlock(); - */ - startIf(expression: string): void; - /** - * @private - * 开始else语句块,自动调用startBlock(); - */ - startElse(): void; - /** - * @private - * 开始else if语句块,自动调用startBlock(); - */ - startElseIf(expression: string): void; - /** - * @private - * 添加一个左大括号,开始新的语句块 - */ - startBlock(): void; - /** - * @private - * 添加一个右大括号,结束当前的语句块 - */ - endBlock(): void; - /** - * @private - * 添加执行函数语句块 - * @param functionName 要执行的函数名称 - * @param args 函数参数列表 - */ - doFunction(functionName: string, args: string[]): void; - /** - * @private - */ - private lines; - /** - * @private - * 添加一行代码 - */ - addCodeLine(code: string): void; - /** - * @private - * 添加一行代码到指定行 - */ - addCodeLineAt(code: string, index: number): void; - /** - * @private - * 是否存在某行代码内容 - */ - containsCodeLine(code: string): boolean; - /** - * @private - * 在结尾追加另一个代码块的内容 - */ - concat(cb: EXCodeBlock): void; - /** - * @private - * - * @returns - */ - toCode(): string; - } - /** - * @private - */ - class EXFunction extends CodeBase { - /** - * @private - * 代码块 - */ - codeBlock: EXCodeBlock; - /** - * @private - */ - isGet: boolean; - /** - * @private - * 函数名 - */ - name: string; - /** - * @private - * - * @returns - */ - toCode(): string; - } - /** - * @private - */ - class EXVariable extends CodeBase { - /** - * @private - */ - constructor(name: string, defaultValue?: string); - /** - * @private - * 变量名 - */ - name: string; - /** - * @private - * 默认值 - */ - defaultValue: string; - /** - * @private - * - * @returns - */ - toCode(): string; - } - /** - * @private - */ - class EXState extends CodeBase { - /** - * @private - */ - constructor(name: string, stateGroups?: any[]); - /** - * @private - * 视图状态名称 - */ - name: string; - /** - * @private - */ - stateGroups: any[]; - /** - * @private - */ - addItems: any[]; - /** - * @private - */ - setProperty: any[]; - /** - * @private - * 添加一个覆盖 - */ - addOverride(item: CodeBase): void; - /** - * @private - * - * @returns - */ - toCode(): string; - } - /** - * @private - */ - class EXAddItems extends CodeBase { - /** - * @private - */ - constructor(target: string, property: string, position: number, relativeTo: string); - /** - * @private - * 要添加的实例 - */ - target: string; - /** - * @private - * 要添加到的属性 - */ - property: string; - /** - * @private - * 添加的位置 - */ - position: number; - /** - * @private - * 相对的显示元素 - */ - relativeTo: string; - /** - * @private - * - * @returns - */ - toCode(): string; - } - /** - * @private - */ - class EXSetProperty extends CodeBase { - /** - * @private - */ - constructor(target: string, name: string, value: string); - /** - * @private - * 要修改的属性名 - */ - name: string; - /** - * @private - * 目标实例名 - */ - target: string; - /** - * @private - * 属性值 - */ - value: string; - /** - * @private - * - * @returns - */ - toCode(): string; - } - /** - * @private - */ - class EXSetStateProperty extends CodeBase { - /** - * @private - */ - constructor(target: string, property: string, templates: string[], chainIndex: number[]); - /** - * @private - * 目标实例名 - */ - target: string; - /** - * @private - * 目标属性名 - */ - property: string; - /** - * @private - * 绑定的模板列表 - */ - templates: string[]; - /** - * @private - * chainIndex是一个索引列表,每个索引指向templates中的一个值,该值是代表属性链。 - */ - chainIndex: number[]; - /** - * @private - * - * @returns - */ - toCode(): string; - } - /** - * @private - */ - class EXBinding extends CodeBase { - /** - * @private - */ - constructor(target: string, property: string, templates: string[], chainIndex: number[]); - /** - * @private - * 目标实例名 - */ - target: string; - /** - * @private - * 目标属性名 - */ - property: string; - /** - * @private - * 绑定的模板列表 - */ - templates: string[]; - /** - * @private - * chainIndex是一个索引列表,每个索引指向templates中的一个值,该值是代表属性链。 - */ - chainIndex: number[]; - /** - * @private - * - * @returns - */ - toCode(): string; - } -} -declare namespace eui { - /** - * BitmapLabel is one line or multiline uneditable BitmapText - * @version Egret 2.5.3 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapLabel 组件是一行或多行不可编辑的位图文本 - * @version Egret 2.5.3 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class BitmapLabel extends egret.BitmapText implements UIComponent, IDisplayText { - constructor(text?: string); - /** - * @private - */ - $invalidateContentBounds(): void; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - private $fontForBitmapLabel; - $setFont(value: any): boolean; - private $createChildrenCalled; - private $fontChanged; - /** - * 解析source - */ - private $parseFont(); - $setFontData(value: egret.BitmapFont, font?: string): boolean; - /** - * @private - */ - private _widthConstraint; - /** - * @private - */ - private _heightConstraint; - /** - * @private - * UIComponentImpl 定义的所有变量请不要添加任何初始值,必须统一在此处初始化。 - */ - private initializeUIValues; - /** - * @copy eui.UIComponent#createChildren - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected createChildren(): void; - /** - * @copy eui.UIComponent#childrenCreated - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected childrenCreated(): void; - /** - * @copy eui.UIComponent#commitProperties - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected commitProperties(): void; - /** - * @copy eui.UIComponent#measure - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected measure(): void; - /** - * @copy eui.UIComponent#updateDisplayList - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * @copy eui.UIComponent#invalidateParentLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected invalidateParentLayout(): void; - /** - * @private - */ - $UIComponent: Object; - /** - * @private - */ - $includeInLayout: boolean; - /** - * @copy eui.UIComponent#includeInLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - includeInLayout: boolean; - /** - * @copy eui.UIComponent#left - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - left: any; - /** - * @copy eui.UIComponent#right - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - right: any; - /** - * @copy eui.UIComponent#top - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - top: any; - /** - * @copy eui.UIComponent#bottom - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - bottom: any; - /** - * @copy eui.UIComponent#horizontalCenter - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - horizontalCenter: any; - /** - * @copy eui.UIComponent#verticalCenter - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - verticalCenter: any; - /** - * @copy eui.UIComponent#percentWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentWidth: number; - /** - * @copy eui.UIComponent#percentHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - percentHeight: number; - /** - * @copy eui.UIComponent#explicitWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitWidth: number; - /** - * @copy eui.UIComponent#explicitHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - explicitHeight: number; - /** - * @copy eui.UIComponent#minWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minWidth: number; - /** - * @copy eui.UIComponent#maxWidth - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxWidth: number; - /** - * @copy eui.UIComponent#minHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - minHeight: number; - /** - * @copy eui.UIComponent#maxHeight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - maxHeight: number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setMeasuredSize(width: number, height: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateProperties(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateSize(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateSize(recursive?: boolean): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - invalidateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateDisplayList(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - validateNow(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsSize(layoutWidth: number, layoutHeight: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - setLayoutBoundsPosition(x: number, y: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getLayoutBounds(bounds: egret.Rectangle): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - getPreferredBounds(bounds: egret.Rectangle): void; - } -} -declare namespace EXML { - /** - * Set a prefix url. - * The prefix url will add to the front of the Exml file path when it’s loading. - * @param text the text of a EXML file. - * - * @version Egret 2.5.3 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置 EXML 文件加载的根路径。 - * 设置后,再加载 EXML 文件时会自动把根路径加到文件路径前面 - * @version Egret 2.5.3 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - let prefixURL: string; - /** - * Parsing a text of EXML file for a definition of class. You can declare the class property in the root - * node of the EXML to register to the global as a class name. - * - * It will be fail to register and output a warning if the specified name already exists. You can get a definition - * of a class through egret.getDefinitionByName(className). - * - * @param text the text of a EXML file. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 解析一个 EXML 文件的文本内容为一个类定义。您可以在 EXML 文件的根节点上声明 class 属性作为要注册到全局的类名。 - * 若指定的类名已经存在,将会注册失败,并输出一个警告。注册成功后,您也可以通过 egret.getDefinitionByName(className) 方法获取这个 EXML 文件对应的类定义。 - * - * @param text 要解析的 EXML 文件内容。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function parse(text: string): { - new (): any; - }; - /** - * Load and parse an external EXML file for a class definition. You can declare the class property in the root - * node of the EXML to register to the global as a class name. - * - * It will be fail to register and output a warning if the specified name already exists. You can get a definition - * of a class through egret.getDefinitionByName(className). - * - * @param url the path of an EXML file - * @param callBack method to invoke with an argument of the result when load and parse completed or failed. The argument will be - * undefined if load or parse failed. - * @param thisObject this object of callBack - * @param useCache use cached EXML - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 加载并解析一个外部的 EXML 文件为一个类定义。您可以在 EXML 文件的根节点上声明 class 属性作为要注册到全局的类名。 - * 若指定的类名已经存在,将会注册失败,并输出一个警告。注册成功后,您也可以通过 egret.getDefinitionByName(className) 方法获取这个 EXML 文件对应的类定义。 - * - * @param url 要加载的 EXML 文件路径 - * @param callBack 加载并解析完成后的回调函数,无论加载成功还是失败,此函数均会被回调。失败时将传入 undefined 作为回调函数参数。 - * @param thisObject 回调函数的 this 引用。 - * @param useCache 使用缓存的EXML - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function load(url: string, callBack?: (clazz: any, url: string) => void, thisObject?: any, useCache?: boolean): void; - /** - * @private - */ - function $loadAll(urls: string[], callBack?: (clazz: any[], url: string[]) => void, thisObject?: any, useCache?: boolean): void; - function update(url: string, clazz: any): void; - /** - * @private - * @param url - * @param text - */ - function $parseURLContentAsJs(url: string, text: string, className: string): void; - /** - * @private - */ - function $parseURLContent(url: string, text: string | any): any; -} -declare namespace eui.sys { - /** - * @private - * EUI 命名空间 - */ - let NS_S: string; - /** - * @private - * Wing命名空间 - */ - let NS_W: string; - /** - * @private - */ - class EXMLConfig { - /** - * @private - */ - $describe(instance: any): any; - /** - * @private - * 根据类的短名ID和命名空间获取完整类名(以"."分隔) - * @param id 类的短名ID - * @param ns 命名空间 - */ - getClassNameById(id: string, ns: string): string; - /** - * @private - * 根据ID获取对应的默认属性 - * @param id 类的短名ID - * @param ns 命名空间 - * @return 默认属性名 - */ - getDefaultPropById(id: string, ns: string): string; - /** - * @private - * 获取指定属性的类型,返回基本数据类型:"boolean","string","number","any"。 - * @param property 属性名 - * @param className 要查询的完整类名 - */ - getPropertyType(property: string, className: string): string; - } -} -declare namespace eui { -} -declare namespace eui { -} -declare namespace eui { - /** - * The BasicLayout class arranges the layout elements according to their individual settings, - * independent of each-other. BasicLayout, also called absolute layout, requires that you - * explicitly position each container child. - * You can use the x and y properties of the child, - * or constraints to position each child. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/BasicLayoutExample.ts - * @language en_US - */ - /** - * BasicLayout 类根据其各个设置彼此独立地排列布局元素。 - * BasicLayout(也称为绝对布局)要求显式定位每个容器子代。 - * 可以使用子代的 xy 属性,或使用约束来定位每个子代。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/BasicLayoutExample.ts - * @language zh_CN - */ - class BasicLayout extends LayoutBase { - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * BasicLayout does not support virtual layout, setting this property is invalid. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * BasicLayout不支持虚拟布局,设置这个属性无效。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - useVirtualLayout: boolean; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - measure(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - } -} -declare namespace eui.sys { - /** - * @private - * 一个工具方法,使用BasicLayout规则测量目标对象。 - */ - function measure(target: eui.Group | eui.Component): void; - /** - * @private - * 一个工具方法,使用BasicLayout规则布局目标对象。 - */ - function updateDisplayList(target: eui.Group | eui.Component, unscaledWidth: number, unscaledHeight: number): egret.Point; -} -declare namespace eui { - /** - * The ColumnAlign class defines the possible values for the - * columnAlign property of the TileLayout class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/ColumnAlignExample.ts - * @language en_US - */ - /** - * ColumnAlign 类为 TileLayout 类的 columnAlign 属性定义可能的值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/ColumnAlignExample.ts - * @language zh_CN - */ - class ColumnAlign { - /** - * Do not justify the rows. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 不将行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static LEFT: string; - /** - * Justify the rows by increasing the vertical gap. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 通过增大水平间隙将行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY_USING_GAP: string; - /** - * Justify the rows by increasing the row height. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 通过增大行高度将行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY_USING_WIDTH: string; - } -} -declare namespace eui { - /** - * The HorizontalLayout class arranges the layout elements in a horizontal sequence, - * left to right, with optional gaps between the elements and optional padding - * around the elements. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/HorizontalLayoutExample.ts - * @language en_US - */ - /** - * HorizontalLayout 类按水平顺序从左到右排列布局元素,在元素和围绕元素的可选填充之间带有可选间隙。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/HorizontalLayoutExample.ts - * @language zh_CN - */ - class HorizontalLayout extends LinearLayoutBase { - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected measureReal(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected measureVirtual(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayListReal(width: number, height: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayListVirtual(width: number, height: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getStartPosition(index: number): number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getElementSize(index: number): number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getElementTotalSize(): number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - elementAdded(index: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getIndexInView(): boolean; - } -} -declare namespace eui { - /** - * The JustifyAlign class defines the possible values for the - * horizontalAlignverticalAlign property of - * Layout class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/JustifyAlignExample.ts - * @language en_US - */ - /** - * JustifyAlign 定义布局类中 horizontalAlign 与 verticalAlign 属性需要的两端对齐常量值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/JustifyAlignExample.ts - * @language zh_CN - */ - class JustifyAlign { - /** - * Justify the children with respect to the container. - * This uniformly sizes all children to be the same size as the - * container. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对齐子代。这会将所有子代的大小统一调整为与容器相同的尺寸。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY: string; - /** - * Content justify the children width/height respect to the container. - * This uniformly sizes all children to be the content width/height of the container. - * The content width/height of the container is the size of the largest child. - * If all children are smaller than the width/height of the container, then - * all the children will be sized to the width/height of the container. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子代进行内容对齐。这会将所有子代的大小统一调整为容器的内容宽度/高度。 - * 容器的内容宽度/高度是最大子代的大小。如果所有子代都小于容器的宽度/高度,则会将所有子代的大小调整为容器的宽度/高度。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static CONTENT_JUSTIFY: string; - } -} -declare namespace eui { - /** - * The RowAlign class defines the possible values for the - * rowAlign property of the TileLayout class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/RowAlignExample.ts - * @language en_US - */ - /** - * RowAlign 类为 TileLayout 类的 rowAlign 属性定义可能的值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/RowAlignExample.ts - * @language zh_CN - */ - class RowAlign { - /** - * Do not justify the rows. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 不进行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static TOP: string; - /** - * Justify the rows by increasing the vertical gap. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 通过增大垂直间隙将行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY_USING_GAP: string; - /** - * Justify the rows by increasing the row height. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 通过增大行高度将行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY_USING_HEIGHT: string; - } -} -declare namespace eui { - /** - * The TileLayout class arranges layout elements in columns and rows - * of equally-sized cells. - * The TileLayout class uses a number of properties that control orientation, - * count, size, gap and justification of the columns and the rows - * as well as element alignment within the cells. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/TileLayoutExample.ts - * @language en_US - */ - /** - * TileLayout 类在单元格大小相等的列和行中排列布局元素。 - * TileLayout 类使用许多属性来控制列和行的方向、计数、大小、间隙和两端对齐以及单元格内的元素对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/TileLayoutExample.ts - * @language zh_CN - */ - class TileLayout extends LayoutBase { - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - * 标记horizontalGap被显式指定过 - */ - private explicitHorizontalGap; - /** - * @private - */ - private _horizontalGap; - /** - * Horizontal space between columns, in pixels. - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 列之间的水平空间(以像素为单位)。 - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - horizontalGap: number; - /** - * @private - * 标记verticalGap被显式指定过 - */ - private explicitVerticalGap; - /** - * @private - */ - private _verticalGap; - /** - * Vertical space between rows, in pixels. - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 行之间的垂直空间(以像素为单位)。 - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - verticalGap: number; - /** - * @private - */ - private _columnCount; - /** - * Contain the actual column count. - * - * @default -1 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 实际列计数。 - * - * @default -1 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - readonly columnCount: number; - /** - * @private - */ - private _requestedColumnCount; - /** - * Number of columns to be displayed. - *

      Set to 0 to allow the TileLayout to determine - * the column count automatically.

      - *

      If the orientation property is set to TileOrientation.ROWS, - * then setting this property has no effect - * In this case, the rowCount is explicitly set, and the - * container width is explicitly set.

      - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要显示的列数。 - *

      设置为 0 会允许 TileLayout 自动确定列计数。

      - *

      如果将 orientation 属性设置为 TileOrientation.ROWS, - * 则设置此属性不会产生任何效果。这种情况下,会显式设置 code>rowCount,并显式设置容器宽度。

      - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - requestedColumnCount: number; - /** - * @private - */ - private _rowCount; - /** - * The row count. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 行计数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - readonly rowCount: number; - /** - * @private - */ - private _requestedRowCount; - /** - * Number of rows to be displayed. - *

      Set to 0 to remove explicit override and allow the TileLayout to determine - * the row count automatically.

      - *

      If the orientation property is set to - * TileOrientation.COLUMNS, setting this property has no effect. - * in this case, columnCount is explicitly set, and the - * container height is explicitly set.

      - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要显示的行数。 - * 设置为 -1 会删除显式覆盖并允许 TileLayout 自动确定行计数。 - * 如果将 orientation 属性设置为 TileOrientation.COLUMNS, - * 则设置此属性不会产生任何效果。这种情况下,会显式设置 columnCount,并显式设置容器高度。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - requestedRowCount: number; - /** - * @private - * 外部显式指定的列宽 - */ - private explicitColumnWidth; - /** - * @private - */ - private _columnWidth; - /** - * Contain the actual column width, in pixels. - *

      If not explicitly set, the column width is - * determined from the width of the widest element.

      - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 包含实际列宽(以像素为单位)。 - *

      若未显式设置,则从根据最宽的元素的宽度确定列宽度。

      - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - columnWidth: number; - /** - * @private - * 外部显式指定的行高 - */ - private explicitRowHeight; - /** - * @private - */ - private _rowHeight; - /** - * The row height, in pixels. - *

      If not explicitly set, the row height is - * determined from the maximum of elements' height.

      - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 行高(以像素为单位)。 - *

      如果未显式设置,则从元素的高度的最大值确定行高度。

      - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - rowHeight: number; - /** - * @private - */ - private _paddingLeft; - /** - * @copy eui.LinearLayoutBase#paddingLeft - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - paddingLeft: number; - /** - * @private - */ - private _paddingRight; - /** - * @copy eui.LinearLayoutBase#paddingRight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - paddingRight: number; - /** - * @private - */ - private _paddingTop; - /** - * @copy eui.LinearLayoutBase#paddingTop - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - paddingTop: number; - /** - * @private - */ - private _paddingBottom; - /** - * @copy eui.LinearLayoutBase#paddingBottom - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - paddingBottom: number; - /** - * @private - */ - private _horizontalAlign; - /** - * Specifies how to align the elements within the cells in the horizontal direction. - * Supported values are - * HorizontalAlign.LEFT、HorizontalAlign.CENTER、 - * HorizontalAlign.RIGHT、JustifyAlign.JUSTIFY。 - * - * @default JustifyAlign.JUSTIFY - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指定如何在水平方向上对齐单元格内的元素。支持的值有 - * HorizontalAlign.LEFT、HorizontalAlign.CENTER、 - * HorizontalAlign.RIGHT、JustifyAlign.JUSTIFY。 - * - * @default JustifyAlign.JUSTIFY - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - horizontalAlign: string; - /** - * @private - */ - private _verticalAlign; - /** - * 指定如何在垂直方向上对齐单元格内的元素。 - * 支持的值有 VerticalAlign.TOP、VerticalAlign.MIDDLE、 - * VerticalAlign.BOTTOM、JustifyAlign.JUSTIFY。 - * 默认值:JustifyAlign.JUSTIFY。 - * - * @default eui.JustifyAlign.JUSTIFY - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * Specifies how to align the elements within the cells in the vertical direction. - * Supported values are - * VerticalAlign.TOP、VerticalAlign.MIDDLE、 - * VerticalAlign.BOTTOM、JustifyAlign.JUSTIFY。 - * - * @default eui.JustifyAlign.JUSTIFY - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - verticalAlign: string; - /** - * @private - */ - private _columnAlign; - /** - * Specifies how to justify the fully visible columns to the container width. - * - *

      When set to ColumnAlign.LEFT it turns column justification off. - * There may be partially visible columns or whitespace between the last column and - * the right edge of the container. This is the default value.

      - * - *

      When set to ColumnAlign.JUSTIFY_USING_GAP the horizontalGap - * actual value increases so that - * the last fully visible column right edge aligns with the container's right edge. - * In case there is only a single fully visible column, the horizontalGap actual value - * increases so that it pushes any partially visible column beyond the right edge - * of the container. - * Note that explicitly setting the horizontalGap property does not turn off - * justification. It only determines the initial gap value. - * Justification may increases it.

      - * - *

      When set to ColumnAlign.JUSTIFY_USING_WIDTH the columnWidth - * actual value increases so that - * the last fully visible column right edge aligns with the container's right edge. - * Note that explicitly setting the columnWidth property does not turn off justification. - * It only determines the initial column width value. - * Justification may increases it.

      - * - * @default ColumnAlign.LEFT - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指定如何将完全可见列与容器宽度对齐。 - * - *

      设置为 ColumnAlign.LEFT 时,它会关闭列两端对齐。 - * 在容器的最后一列和右边缘之间可能存在部分可见的列或空白。这是默认值。

      - * - *

      设置为 ColumnAlign.JUSTIFY_USING_GAP 时,horizontalGap 的实际值将增大, - * 这样最后一个完全可见列右边缘会与容器的右边缘对齐。仅存在一个完全可见列时, - * horizontalGap 的实际值将增大,这样它会将任何部分可见列推到容器的右边缘之外。 - * 请注意显式设置 horizontalGap 属性不会关闭两端对齐。它仅确定初始间隙值。两端对齐可能会增大它。

      - * - *

      设置为 ColumnAlign.JUSTIFY_USING_WIDTH 时,columnWidth 的实际值将增大, - * 这样最后一个完全可见列右边缘会与容器的右边缘对齐。请注意显式设置 columnWidth 属性不会关闭两端对齐。 - * 它仅确定初始列宽度值。两端对齐可能会增大它。

      - * - * @default ColumnAlign.LEFT - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - columnAlign: string; - /** - * @private - */ - private _rowAlign; - /** - * Specifies how to justify the fully visible rows to the container height. - * - *

      When set to RowAlign.TOP it turns column justification off. - * There might be partially visible rows or whitespace between the last row and - * the bottom edge of the container. This is the default value.

      - * - *

      When set to RowAlign.JUSTIFY_USING_GAP the verticalGap - * actual value increases so that - * the last fully visible row bottom edge aligns with the container's bottom edge. - * In case there is only a single fully visible row, the value of verticalGap - * increases so that it pushes any partially visible row beyond the bottom edge - * of the container. Note that explicitly setting the verticalGap does not turn off - * justification, but just determines the initial gap value. - * Justification can then increases it.

      - * - *

      When set to RowAlign.JUSTIFY_USING_HEIGHT the rowHeight - * actual value increases so that - * the last fully visible row bottom edge aligns with the container's bottom edge. Note that - * explicitly setting the rowHeight does not turn off justification, but - * determines the initial row height value. - * Justification can then increase it.

      - * - * @default RowAlign.TOP - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指定如何将完全可见行与容器高度对齐。 - * - *

      设置为 RowAlign.TOP 时,它会关闭列两端对齐。 - * 在容器的最后一行和底边缘之间可能存在部分可见的行或空白。这是默认值。

      - * - *

      设置为 RowAlign.JUSTIFY_USING_GAP 时,verticalGap 的实际值会增大, - * 这样最后一个完全可见行底边缘会与容器的底边缘对齐。仅存在一个完全可见行时,verticalGap 的值会增大, - * 这样它会将任何部分可见行推到容器的底边缘之外。请注意,显式设置 verticalGap - * 不会关闭两端对齐,而只是确定初始间隙值。两端对齐接着可以增大它。

      - * - *

      设置为 RowAlign.JUSTIFY_USING_HEIGHT 时,rowHeight 的实际值会增大, - * 这样最后一个完全可见行底边缘会与容器的底边缘对齐。请注意,显式设置 rowHeight - * 不会关闭两端对齐,而只是确定初始行高度值。两端对齐接着可以增大它。

      - * - * @default RowAlign.TOP - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - rowAlign: string; - /** - * @private - */ - private _orientation; - /** - * Specifies whether elements are arranged row by row or - * column by column. - * - * @default TileOrientation.ROWS - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指定是逐行还是逐列排列元素。 - * - * @default TileOrientation.ROWS - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - orientation: string; - /** - * @private - * 标记目标容器的尺寸和显示列表失效 - */ - private invalidateTargetLayout(); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - measure(): void; - /** - * @private - * 计算行和列的尺寸及数量 - */ - private calculateRowAndColumn(explicitWidth, explicitHeight); - /** - * @private - * 缓存的最大子对象宽度 - */ - private maxElementWidth; - /** - * @private - * 缓存的最大子对象高度 - */ - private maxElementHeight; - /** - * @private - * 更新最大子对象尺寸 - */ - private updateMaxElementSize(); - /** - * @private - * 更新虚拟布局的最大子对象尺寸 - */ - private doUpdateMaxElementSize(startIndex, endIndex); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - clearVirtualLayoutCache(): void; - /** - * @private - * 当前视图中的第一个元素索引 - */ - private startIndex; - /** - * @private - * 当前视图中的最后一个元素的索引 - */ - private endIndex; - /** - * @private - * 视图的第一个和最后一个元素的索引值已经计算好的标志 - */ - private indexInViewCalculated; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - scrollPositionChanged(): void; - /** - * @private - * 获取视图中第一个和最后一个元素的索引,返回是否发生改变 - */ - private getIndexInView(); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - updateDisplayList(width: number, height: number): void; - /** - * @private - * 为单个元素布局 - */ - private sizeAndPositionElement(element, cellX, cellY, cellWidth, cellHeight); - /** - * @private - * 为两端对齐调整间隔或格子尺寸 - */ - private adjustForJustify(width, height); - } -} -declare namespace eui { - /** - * The TileOrientation class defines the possible values for the - * orientation property of the TileLayout class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/TileOrientationExample.ts - * @language en_US - */ - /** - * TileOrientation 类为 TileLayout 类的 orientation 属性定义可能的值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/TileOrientationExample.ts - * @language zh_CN - */ - class TileOrientation { - /** - * Arranges elements row by row. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 逐行排列元素。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static ROWS: string; - /** - * Arranges elements column by column. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 逐列排列元素。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - static COLUMNS: string; - } -} -declare namespace eui { - /** - * The VerticalLayout class arranges the layout elements in a vertical sequence, - * top to bottom, with optional gaps between the elements and optional padding - * around the sequence of elements. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/VerticalLayoutExample.ts - * @language en_US - */ - /** - * VerticalLayout 类按垂直顺序从上向下排列布局元素,在元素和围绕元素顺序的可选填充之间带有可选间隙。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/VerticalLayoutExample.ts - * @language zh_CN - */ - class VerticalLayout extends LinearLayoutBase { - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected measureReal(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected measureVirtual(): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayListReal(width: number, height: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayListVirtual(width: number, height: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getStartPosition(index: number): number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getElementSize(index: number): number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getElementTotalSize(): number; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - elementAdded(index: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected getIndexInView(): boolean; - } -} -declare namespace eui { - /** - * An ICollectionView is a view onto a collection of data. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * - * ICollection是一个列表的集合类数据源对象的查看接口。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - interface ICollection extends egret.IEventDispatcher { - /** - * The number of items in this view. - * 0 means no items, while -1 means that the length is unknown. - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此集合中的项目数。0 表示不包含项目。 - * @readOnly - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - length: number; - /** - * Gets the item at the specified index. - * @param index The index in the list from which to retrieve the item. - * @return The item at that index, or null if there is none. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取指定索引处的项目。 - * @param index 要得到的项的指定位置。 - * @return 在索引位置的项,如果没有该项则返回null。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - getItemAt(index: number): any; - /** - * Returns the index of the item if it is in the list。-1 otherwise. - * @param item The item to find. - * @return The index of the item, or -1 if the item is not in the list. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果项目位于列表中,返回该项目的索引。否则返回-1。 - * @param item 要查找的项。 - * @return 项的索引,如果该项没有在列表中将返回-1. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - getItemIndex(item: any): number; - } -} -declare namespace eui { - /** - * The HScrollBar (horizontal scrollbar) control lets you control - * the portion of data that is displayed when there is too much data - * to fit horizontally in a display area. - * - *

      Although you can use the HScrollBar control as a stand-alone control, - * you usually combine it as part of another group of components to - * provide scrolling functionality.

      - * - * @includeExample extension/eui/components/HScrollBarExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * HScrollBar(水平 ScrollBar)控件可以在因数据太多而不能在显示区域中以水平方向完全显示时控制显示的数据部分。 - *

      虽然 HScrollBar 控件可以单独使用,但通常将它与其他组件一起使用来提供滚动功能。

      - * - * @includeExample extension/eui/components/HScrollBarExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class HScrollBar extends ScrollBarBase { - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - protected onPropertyChanged(event: eui.PropertyEvent): void; - } -} -declare namespace eui.sys { - /** - * @private - */ - const enum AddPosition { - /** - * @private - * 添加父级容器的底层 - */ - FIRST = 0, - /** - * @private - * 添加在父级容器的顶层 - */ - LAST = 1, - /** - * @private - * 添加在相对对象之前 - */ - BEFORE = 2, - /** - * @private - * 添加在相对对象之后 - */ - AFTER = 3, - } -} -declare namespace eui { - /** - * The operation of adding a state to view. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 视图添加状态显示元素操作 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class AddItems implements IOverride { - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个AddItems实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(target: string, propertyName: string, position: number, relativeTo: string); - /** - * The name of the property that is being added. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要添加到的属性 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - propertyName: string; - /** - * The position to be added. Valid values: "first","last","before","after" - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 添加的位置,有效值为: "first","last","before","after" - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - position: number; - /** - * an instance name of relative visual element. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 相对的显示元素的实例名 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - relativeTo: string; - /** - * The target instance name. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 目标实例名 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - target: string; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - apply(host: any, parent: egret.DisplayObjectContainer): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - remove(host: any, parent: egret.DisplayObjectContainer): void; - } -} -declare namespace eui { - /** - * The IOverride interface is used for view state overrides. - * All entries in the State class overrides - * property array must implement this interface. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * IOverride 接口定义视图状态的覆盖操作。State 类 overrides 属性数组中的所有条目均必须实现此接口。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - interface IOverride { - /** - * Applies the override. Retains the original value, so that it can - * restore the value later in the remove() method.

      - * - * This method is called automatically when the state is entered. - * It should not be called directly. - * - * @param host A component that contains view states. - * @param parent The parent that a sub element be added. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 应用覆盖。将保留原始值,以便以后可以在 remove() 方法中恢复该值。

      - * - * 该方法是当进入状态的时候自动调用的,请不要直接调用此方法。 - * @param host 含有视图状态的组件。 - * @param parent 子项添加到的父级容器。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - apply(host: any, parent: egret.DisplayObjectContainer): void; - /** - * Removes the override. The value remembered in the apply() - * method is restored.

      - * - * This method is called automatically when the state is entered. - * It should not be called directly. - * @param host A component that contains view states. - * @param parent The parent that a sub element be added. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 删除覆盖。在 apply() 方法中记住的值将被恢复。 - * @param host 含有视图状态的组件。 - * @param parent 子项添加到的父级容器。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - remove(host: any, parent: egret.DisplayObjectContainer): void; - } -} -declare namespace eui { - /** - * The SetProperty class specifies a property value that is in effect only - * during the parent view state. - * You use this class in the overrides property of the State class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * SetProperty 类指定只在父视图状态期间有效的属性值。可以在 State 类的 overrides 属性中使用该类。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class SetProperty implements IOverride { - /** - * Constructor. - * - * @param target The object whose property is being set. - * By default, EUI uses the immediate parent of the State object. - * @param name The property to set. - * @param value The value of the property in the view state. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个SetProperty实例。 - * - * @param target 要设置其属性的对象。默认情况下,EUI 使用 State 对象的直接父级。 - * @param name 要设置的属性。 - * @param value 视图状态中的属性值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(target: string, name: string, value: any); - /** - * he name of the property to change. - * You must set this property, either in - * the SetProperty constructor or by setting - * the property value directly. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要更改的属性的名称。 - * 这个属性必须设置,在 SetProperty 构造函数中设置或通过直接设置该属性值设置。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * The object containing the property to be changed. - * If the property value is null, EUI uses the - * immediate parent of the State object. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 包含要更改的属性的对象。如果属性值为 null,则 EUI 将使用 State 对象的直接父级。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - target: string; - /** - * The new value for the property. - * - * @default undefined - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 属性的新值。 - * - * @default undefined - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - value: any; - /** - * @private - * 旧的属性值 - */ - private oldValue; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - apply(host: Skin, parent: egret.DisplayObjectContainer): void; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - remove(host: Skin, parent: egret.DisplayObjectContainer): void; - /** - * @private - * 设置属性值 - */ - private setPropertyValue(obj, name, value, valueForType); - /** - * @private - * 转成Boolean值 - */ - private toBoolean(value); - } -} -declare namespace eui { - /** - * The SetProperty class specifies a property value that is in effect only - * during the parent view state. - * You use this class in the overrides property of the State class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * SetProperty 类指定只在父视图状态期间有效的属性值。可以在 State 类的 overrides 属性中使用该类。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - class SetStateProperty implements IOverride { - /** - * Constructor. - * - * @param target The object whose property is being set. - * By default, EUI uses the immediate parent of the State object. - * @param name The property to set. - * @param value The value of the property in the view state. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个SetProperty实例。 - * - * @param target 要设置其属性的对象。默认情况下,EUI 使用 State 对象的直接父级。 - * @param name 要设置的属性。 - * @param value 视图状态中的属性值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - constructor(host: any, templates: any[], chainIndex: number[], target: any, prop: string); - /** - * 皮肤对象 - * @private - */ - private host; - /** - * @private - * 绑定的模板列表 - */ - templates: any[]; - /** - * @private - * chainIndex是一个索引列表,每个索引指向templates中的一个值,该值是代表属性链。 - */ - chainIndex: number[]; - /** - * 要绑定的对象 - * @private - */ - private target; - /** - * 要绑定对象的属性 - * @private - */ - private prop; - /** - * 上一次的数据 - * @private - */ - private oldValue; - /** - * @inheritDoc - * - * @version Egret 3.0 - * @version eui 1.0 - * @platform Web,Native - */ - apply(host: Skin, parent: egret.DisplayObjectContainer): void; - /** - * @inheritDoc - * - * @version Egret 3.0 - * @version eui 1.0 - * @platform Web,Native - */ - remove(host: Skin, parent: egret.DisplayObjectContainer): void; - /** - * @private - * 设置属性值 - */ - private setPropertyValue(obj, name, value, valueForType); - /** - * @private - * 转成Boolean值 - */ - private toBoolean(value); - } -} -declare namespace eui.sys { - /** - * @private - */ - class MatrixUtil { - /** - * @private - */ - static fitBounds(width: number, height: number, matrix: egret.Matrix, explicitWidth: number, explicitHeight: number, preferredWidth: number, preferredHeight: number, minWidth: number, minHeight: number, maxWidth: number, maxHeight: number): egret.Point; - } -} diff --git a/demo/libs/modules/eui/eui.js b/demo/libs/modules/eui/eui.js deleted file mode 100644 index a67df0fa..00000000 --- a/demo/libs/modules/eui/eui.js +++ /dev/null @@ -1,25655 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var sys; - (function (sys) { - /** - * @private - * 失效验证管理器 - */ - var Validator = (function (_super) { - __extends(Validator, _super); - /** - * @private - * 创建一个Validator对象 - */ - function Validator() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.targetLevel = Number.POSITIVE_INFINITY; - /** - * @private - */ - _this.invalidatePropertiesFlag = false; - /** - * @private - */ - _this.invalidateClientPropertiesFlag = false; - /** - * @private - */ - _this.invalidatePropertiesQueue = new DepthQueue(); - /** - * @private - */ - _this.invalidateSizeFlag = false; - /** - * @private - */ - _this.invalidateClientSizeFlag = false; - /** - * @private - */ - _this.invalidateSizeQueue = new DepthQueue(); - /** - * @private - */ - _this.invalidateDisplayListFlag = false; - /** - * @private - */ - _this.invalidateDisplayListQueue = new DepthQueue(); - /** - * @private - */ - _this.eventDisplay = new egret.Bitmap(); - /** - * @private - * 是否已经添加了事件监听 - */ - _this.listenersAttached = false; - return _this; - } - /** - * @private - * 标记组件属性失效 - */ - Validator.prototype.invalidateProperties = function (client) { - if (!this.invalidatePropertiesFlag) { - this.invalidatePropertiesFlag = true; - if (!this.listenersAttached) - this.attachListeners(); - } - if (this.targetLevel <= client.$nestLevel) - this.invalidateClientPropertiesFlag = true; - this.invalidatePropertiesQueue.insert(client); - }; - /** - * @private - * 验证失效的属性 - */ - Validator.prototype.validateProperties = function () { - var queue = this.invalidatePropertiesQueue; - var client = queue.shift(); - while (client) { - if (client.$stage) { - client.validateProperties(); - } - client = queue.shift(); - } - if (queue.isEmpty()) - this.invalidatePropertiesFlag = false; - }; - /** - * @private - * 标记需要重新测量尺寸 - */ - Validator.prototype.invalidateSize = function (client) { - if (!this.invalidateSizeFlag) { - this.invalidateSizeFlag = true; - if (!this.listenersAttached) - this.attachListeners(); - } - if (this.targetLevel <= client.$nestLevel) - this.invalidateClientSizeFlag = true; - this.invalidateSizeQueue.insert(client); - }; - /** - * @private - * 测量尺寸 - */ - Validator.prototype.validateSize = function () { - var queue = this.invalidateSizeQueue; - var client = queue.pop(); - while (client) { - if (client.$stage) { - client.validateSize(); - } - client = queue.pop(); - } - if (queue.isEmpty()) - this.invalidateSizeFlag = false; - }; - /** - * @private - * 标记需要重新布局 - */ - Validator.prototype.invalidateDisplayList = function (client) { - if (!this.invalidateDisplayListFlag) { - this.invalidateDisplayListFlag = true; - if (!this.listenersAttached) - this.attachListeners(); - } - this.invalidateDisplayListQueue.insert(client); - }; - /** - * @private - * 重新布局 - */ - Validator.prototype.validateDisplayList = function () { - var queue = this.invalidateDisplayListQueue; - var client = queue.shift(); - while (client) { - if (client.$stage) { - client.validateDisplayList(); - } - client = queue.shift(); - } - if (queue.isEmpty()) - this.invalidateDisplayListFlag = false; - }; - /** - * @private - * 添加事件监听 - */ - Validator.prototype.attachListeners = function () { - this.eventDisplay.addEventListener(egret.Event.ENTER_FRAME, this.doPhasedInstantiationCallBack, this); - this.eventDisplay.addEventListener(egret.Event.RENDER, this.doPhasedInstantiationCallBack, this); - egret.sys.$invalidateRenderFlag = true; - this.listenersAttached = true; - }; - /** - * @private - * 执行属性应用 - */ - Validator.prototype.doPhasedInstantiationCallBack = function (event) { - this.eventDisplay.removeEventListener(egret.Event.ENTER_FRAME, this.doPhasedInstantiationCallBack, this); - this.eventDisplay.removeEventListener(egret.Event.RENDER, this.doPhasedInstantiationCallBack, this); - this.doPhasedInstantiation(); - }; - /** - * @private - * - */ - Validator.prototype.doPhasedInstantiation = function () { - if (this.invalidatePropertiesFlag) { - this.validateProperties(); - } - if (this.invalidateSizeFlag) { - this.validateSize(); - } - if (this.invalidateDisplayListFlag) { - this.validateDisplayList(); - } - if (this.invalidatePropertiesFlag || - this.invalidateSizeFlag || - this.invalidateDisplayListFlag) { - this.attachListeners(); - } - else { - this.listenersAttached = false; - } - }; - /** - * @private - * 使大于等于指定组件层级的元素立即应用属性 - * @param target 要立即应用属性的组件 - */ - Validator.prototype.validateClient = function (target) { - var obj; - var done = false; - var oldTargetLevel = this.targetLevel; - if (this.targetLevel === Number.POSITIVE_INFINITY) - this.targetLevel = target.$nestLevel; - var propertiesQueue = this.invalidatePropertiesQueue; - var sizeQueue = this.invalidateSizeQueue; - var displayListQueue = this.invalidateDisplayListQueue; - while (!done) { - done = true; - obj = propertiesQueue.removeSmallestChild(target); - while (obj) { - if (obj.$stage) { - obj.validateProperties(); - } - obj = propertiesQueue.removeSmallestChild(target); - } - if (propertiesQueue.isEmpty()) { - this.invalidatePropertiesFlag = false; - } - this.invalidateClientPropertiesFlag = false; - obj = sizeQueue.removeLargestChild(target); - while (obj) { - if (obj.$stage) { - obj.validateSize(); - } - if (this.invalidateClientPropertiesFlag) { - obj = (propertiesQueue.removeSmallestChild(target)); - if (obj) { - propertiesQueue.insert(obj); - done = false; - break; - } - } - obj = sizeQueue.removeLargestChild(target); - } - if (sizeQueue.isEmpty()) { - this.invalidateSizeFlag = false; - } - this.invalidateClientPropertiesFlag = false; - this.invalidateClientSizeFlag = false; - obj = displayListQueue.removeSmallestChild(target); - while (obj) { - if (obj.$stage) { - obj.validateDisplayList(); - } - if (this.invalidateClientPropertiesFlag) { - obj = propertiesQueue.removeSmallestChild(target); - if (obj) { - propertiesQueue.insert(obj); - done = false; - break; - } - } - if (this.invalidateClientSizeFlag) { - obj = sizeQueue.removeLargestChild(target); - if (obj) { - sizeQueue.insert(obj); - done = false; - break; - } - } - obj = displayListQueue.removeSmallestChild(target); - } - if (displayListQueue.isEmpty()) { - this.invalidateDisplayListFlag = false; - } - } - if (oldTargetLevel === Number.POSITIVE_INFINITY) { - this.targetLevel = Number.POSITIVE_INFINITY; - } - }; - return Validator; - }(egret.EventDispatcher)); - sys.Validator = Validator; - __reflect(Validator.prototype, "eui.sys.Validator"); - /** - * @private - * 显示列表嵌套深度排序队列 - */ - var DepthQueue = (function () { - function DepthQueue() { - /** - * 深度队列 - */ - this.depthBins = {}; - /** - * 最小深度 - */ - this.minDepth = 0; - /** - * 最大深度 - */ - this.maxDepth = -1; - } - /** - * 插入一个元素 - */ - DepthQueue.prototype.insert = function (client) { - var depth = client.$nestLevel; - if (this.maxDepth < this.minDepth) { - this.minDepth = this.maxDepth = depth; - } - else { - if (depth < this.minDepth) - this.minDepth = depth; - if (depth > this.maxDepth) - this.maxDepth = depth; - } - var bin = this.depthBins[depth]; - if (!bin) { - bin = this.depthBins[depth] = new DepthBin(); - } - bin.insert(client); - }; - /** - * 从队列尾弹出深度最大的一个对象 - */ - DepthQueue.prototype.pop = function () { - var client; - var minDepth = this.minDepth; - if (minDepth <= this.maxDepth) { - var bin = this.depthBins[this.maxDepth]; - while (!bin || bin.length === 0) { - this.maxDepth--; - if (this.maxDepth < minDepth) - return null; - bin = this.depthBins[this.maxDepth]; - } - client = bin.pop(); - while (!bin || bin.length == 0) { - this.maxDepth--; - if (this.maxDepth < minDepth) - break; - bin = this.depthBins[this.maxDepth]; - } - } - return client; - }; - /** - * 从队列首弹出深度最小的一个对象 - */ - DepthQueue.prototype.shift = function () { - var client; - var maxDepth = this.maxDepth; - if (this.minDepth <= maxDepth) { - var bin = this.depthBins[this.minDepth]; - while (!bin || bin.length === 0) { - this.minDepth++; - if (this.minDepth > maxDepth) - return null; - bin = this.depthBins[this.minDepth]; - } - client = bin.pop(); - while (!bin || bin.length == 0) { - this.minDepth++; - if (this.minDepth > maxDepth) - break; - bin = this.depthBins[this.minDepth]; - } - } - return client; - }; - /** - * 移除大于等于指定组件层级的元素中最大的元素 - */ - DepthQueue.prototype.removeLargestChild = function (client) { - var hashCode = client.$hashCode; - var nestLevel = client.$nestLevel; - var max = this.maxDepth; - var min = nestLevel; - while (min <= max) { - var bin = this.depthBins[max]; - if (bin && bin.length > 0) { - if (max === nestLevel) { - if (bin.map[hashCode]) { - bin.remove(client); - return client; - } - } - else if (egret.is(client, "egret.DisplayObjectContainer")) { - var items = bin.items; - var length_1 = bin.length; - for (var i = 0; i < length_1; i++) { - var value = items[i]; - if (client.contains(value)) { - bin.remove(value); - return value; - } - } - } - else { - break; - } - max--; - } - else { - if (max == this.maxDepth) { - this.maxDepth--; - } - max--; - if (max < min) - break; - } - } - return null; - }; - /** - * 移除大于等于指定组件层级的元素中最小的元素 - */ - DepthQueue.prototype.removeSmallestChild = function (client) { - var nestLevel = client.$nestLevel; - var min = nestLevel; - var max = this.maxDepth; - var hashCode = client.$hashCode; - while (min <= max) { - var bin = this.depthBins[min]; - if (bin && bin.length > 0) { - if (min === nestLevel) { - if (bin.map[hashCode]) { - bin.remove(client); - return client; - } - } - else if (egret.is(client, "egret.DisplayObjectContainer")) { - var items = bin.items; - var length_2 = bin.length; - for (var i = 0; i < length_2; i++) { - var value = items[i]; - if (client.contains(value)) { - bin.remove(value); - return value; - } - } - } - else { - break; - } - min++; - } - else { - if (min == this.minDepth) - this.minDepth++; - min++; - if (min > max) - break; - } - } - return null; - }; - /** - * 队列是否为空 - */ - DepthQueue.prototype.isEmpty = function () { - return this.minDepth > this.maxDepth; - }; - return DepthQueue; - }()); - __reflect(DepthQueue.prototype, "DepthQueue"); - /** - * @private - * 列表项 - */ - var DepthBin = (function () { - function DepthBin() { - this.map = {}; - this.items = []; - this.length = 0; - } - DepthBin.prototype.insert = function (client) { - var hashCode = client.$hashCode; - if (this.map[hashCode]) { - return; - } - this.map[hashCode] = true; - this.length++; - this.items.push(client); - }; - DepthBin.prototype.pop = function () { - var client = this.items.pop(); //使用pop会比shift有更高的性能,避免索引整体重置。 - if (client) { - this.length--; - if (this.length === 0) { - this.map = {}; //清空所有key防止内存泄露 - } - else { - this.map[client.$hashCode] = false; - } - } - return client; - }; - DepthBin.prototype.remove = function (client) { - var index = this.items.indexOf(client); - if (index >= 0) { - this.items.splice(index, 1); - this.length--; - if (this.length === 0) { - this.map = {}; //清空所有key防止内存泄露 - } - else { - this.map[client.$hashCode] = false; - } - } - }; - return DepthBin; - }()); - __reflect(DepthBin.prototype, "DepthBin"); - })(sys = eui.sys || (eui.sys = {})); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * Register a property for a class definition in running, - * so that the EUI can get type of property accurate when parsing a EXML. - * This need not be called directly in most of time. Only when you have a custom UI - * component need to be described in EXML, you may invoke this method explicitly. - * - * Contains no following: - * When the property is the basic data type(boolean, number, string or Array), you only need set a correct initial value - * for he custom property then the EXML parser can get the correct property type in running. - * - * If you can not set the correct initial value (such as null), the EXML parser will treat this property as - * string. If there is no inital value, EUI will throw an error. But you can invoked this method to register - * a property in this case. - * - * - * @param classDefinition The class definition need to be registered. - * @param property The property need to be registered. Note that the property - * name cannot start with "_" or "$". - * @param type The type need to be registered, - * such as “boolean","number","string","Array","egret.Rectangle" and so on. - * @param asDefault Whether register this property as a default property of component. - * One component can register only on default property. And the default property can be spare in an EXML. - * - * @example: - *
      -     *      
      -     *          
      -     *          
      -     *          
      -     *      
      -     * 
      - * Cuz viewport is the default property of Scroller. So you can write as follow: - *
      -     *      
      -     *          
      -     *      
      -     * 
      - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 为一个类定义注册运行时属性类型,以便运行时的EXML文件解析过程能获取准确的属性类型。大多数情况下,您都不需要手动调用此方法显式注册属性类型。 - * 仅当您有一个自定义的 UI 组件,需要在EXML中用标签描述时可能需要显式注册,但以下情况除外: - * 当属性类型为基本数据类型:boolean,number,string,Array这四种其中之一时,您只需要为自定义的属性赋值上正确的初始值, - * 运行时EXML解析器就能通过初始值自动分析出正确的属性类型。 - * 若您无法为属性赋值上正确的初始值时(有初始值,比如null),运行时EXML解析器会把此属性当做string来处理,若完全没有初始值,将会报错找不到节点属性, - * 这种情况下可以手动调用此方法显式注册属性类型。 - * - * @param classDefinition 要注册的类定义。 - * @param property 要注册的属性,注意属性名不能以 _ 或 $ 符开头。 - * @param type 要注册的类型,例如:“boolean","number","string","Array","egret.Rectangle" - * @param asDefault 是否将此属性注册为组件的默认属性,一个组件只可以设置一个默认属性。注册了组件默认属性后,在EXML中可以使用省略属性节点的写法, - * @example: - *
      -     * 
      -     *     
      -     *         
      -     *     
      -     * 
      -     * 
      - * 因为 viewport 已经注册为 Scroller 的默认属性,上面的例子可以等效为: - *
      -     * 
      -     *     
      -     * 
      -     * 
      - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function registerProperty(classDefinition, property, type, asDefault) { - if (true) { - if (!classDefinition) { - egret.$error(1003, "classDefinition"); - } - if (!classDefinition.prototype) { - egret.$error(1012, "classDefinition"); - } - if (!property) { - egret.$error(1003, "property"); - } - if (!type) { - egret.$error(1003, "type"); - } - } - var prototype = classDefinition.prototype; - prototype.__meta__ = prototype.__meta__ || {}; - prototype.__meta__[property] = type; - if (asDefault) { - prototype.__defaultProperty__ = property; - } - } - eui.registerProperty = registerProperty; -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The State class defines a view state, a particular view of a component. - * - * For example, a product thumbnail could have two view states; - * a base view state with minimal information, and a rich view state with - * additional information. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * State 类定义视图状态,即组件的特定视图。 - * - * 例如,产品缩略图可以有两个视图状态,包含最少信息的基本视图状态和包含附加信息的丰富视图状态。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var State = (function (_super) { - __extends(State, _super); - /** - * Constructor. - * - * @param name The name of the view state. - * State names must be unique for a given component. - * This property must be set. - * @param overrides The overrides for this view state, as an Array of objects that implement - * the IOverride interface. These overrides are applied in order when the - * state is entered, and removed in reverse order when the state is exited. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个State实例。 - * - * @param name 视图状态的名称。给定组件的状态名称必须唯一。必须设置此属性。 - * @param overrides 该视图状态的覆盖,表现为实现 IOverride 接口的对象的数组。 - * 这些覆盖在进入状态时按顺序应用,在退出状态时按相反的顺序删除。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function State(name, overrides) { - if (overrides === void 0) { overrides = []; } - var _this = _super.call(this) || this; - _this.name = name; - _this.overrides = overrides; - return _this; - } - /** - * Initialize this state and all of its overrides. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 初始化视图状态 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - State.prototype.initialize = function (host, stage) { - var overrides = this.overrides; - var length = overrides.length; - for (var i = 0; i < length; i++) { - var addItems = overrides[i]; - if (addItems instanceof eui.AddItems) { - var target = host[addItems.target]; - if (target && target instanceof eui.Image && !target.$parent) { - stage.addChild(target); - stage.removeChild(target); - } - } - } - }; - return State; - }(egret.HashObject)); - eui.State = State; - __reflect(State.prototype, "eui.State"); -})(eui || (eui = {})); -(function (eui) { - var sys; - (function (sys) { - /** - * @private - */ - var StateClient = (function () { - function StateClient() { - } - Object.defineProperty(StateClient.prototype, "states", { - /** - * @private - * 为此组件定义的视图状态。 - */ - get: function () { - return this.$stateValues.states; - }, - set: function (value) { - if (!value) - value = []; - var values = this.$stateValues; - values.states = value; - var statesMap = {}; - var length = value.length; - for (var i = 0; i < length; i++) { - var state = value[i]; - statesMap[state.name] = state; - } - values.statesMap = statesMap; - if (values.parent) { - this.commitCurrentState(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(StateClient.prototype, "currentState", { - /** - * @private - * 组件的当前视图状态。将其设置为 "" 或 null 可将组件重置回其基本状态。 - */ - get: function () { - return this.$stateValues.currentState; - }, - set: function (value) { - var values = this.$stateValues; - values.explicitState = value; - values.currentState = value; - this.commitCurrentState(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 应用当前的视图状态。子类覆盖此方法在视图状态发生改变时执行相应更新操作。 - */ - StateClient.prototype.commitCurrentState = function () { - var values = this.$stateValues; - if (!values.parent) { - return; - } - var destination = values.statesMap[values.currentState]; - if (!destination) { - if (values.states.length > 0) { - values.currentState = values.states[0].name; - } - else { - return; - } - } - if (values.oldState == values.currentState) { - return; - } - var parent = values.parent; - var state = values.statesMap[values.oldState]; - if (state) { - var overrides = state.overrides; - var length_3 = overrides.length; - for (var i = 0; i < length_3; i++) { - overrides[i].remove(this, parent); - } - } - values.oldState = values.currentState; - state = values.statesMap[values.currentState]; - if (state) { - var overrides = state.overrides; - var length_4 = overrides.length; - for (var i = 0; i < length_4; i++) { - overrides[i].apply(this, parent); - } - } - }; - /** - * @private - * 返回是否含有指定名称的视图状态 - * @param stateName 要检查的视图状态名称 - */ - StateClient.prototype.hasState = function (stateName) { - return !!this.$stateValues.statesMap[stateName]; - }; - /** - * @private - * 初始化所有视图状态 - */ - StateClient.prototype.initializeStates = function (stage) { - this.$stateValues.intialized = true; - var states = this.states; - var length = states.length; - for (var i = 0; i < length; i++) { - states[i].initialize(this, stage); - } - }; - return StateClient; - }()); - sys.StateClient = StateClient; - __reflect(StateClient.prototype, "eui.sys.StateClient"); - /** - * @private - */ - var StateValues = (function () { - function StateValues() { - /** - * @private - */ - this.intialized = false; - /** - * @private - */ - this.statesMap = {}; - /** - * @private - */ - this.states = []; - /** - * @private - */ - this.oldState = null; - /** - * @private - */ - this.explicitState = null; - /** - * @private - */ - this.currentState = null; - /** - * @private - */ - this.parent = null; - /** - * @private - */ - this.stateIsDirty = false; - } - return StateValues; - }()); - sys.StateValues = StateValues; - __reflect(StateValues.prototype, "eui.sys.StateValues"); - })(sys = eui.sys || (eui.sys = {})); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -var eui; -(function (eui) { - function getAssets(source, callback, thisObject) { - var adapter = egret.getImplementation("eui.IAssetAdapter"); - if (!adapter) { - adapter = new eui.DefaultAssetAdapter(); - } - adapter.getAsset(source, function (content) { - callback.call(thisObject, content); - }, this); - } - eui.getAssets = getAssets; - function getTheme(source, callback) { - var adapter = egret.getImplementation("eui.IThemeAdapter"); - if (!adapter) { - adapter = new eui.DefaultThemeAdapter(); - } - adapter.getTheme(source, function (data) { - callback(data); - }, function (e) { console.log(e); }, this); - } - eui.getTheme = getTheme; -})(eui || (eui = {})); -(function (eui) { - var sys; - (function (sys) { - var UIComponentClass = "eui.UIComponent"; - function isDeltaIdentity(m) { - return (m.a === 1 && m.b === 0 && m.c === 0 && m.d === 1); - } - var validator = new sys.Validator(); - /** - * @private - * EUI 显示对象基类模板。仅作为 UIComponent 的默认实现,为egret.sys.implemenetUIComponenet()方法提供代码模板。 - * 注意:在此类里不允许直接使用super关键字访问父类方法。一律使用this.$super属性访问。 - */ - var UIComponentImpl = (function (_super) { - __extends(UIComponentImpl, _super); - /** - * @private - * 构造函数 - */ - function UIComponentImpl() { - var _this = _super.call(this) || this; - _this.initializeUIValues(); - return _this; - } - /** - * @private - * UIComponentImpl 定义的所有变量请不要添加任何初始值,必须统一在此处初始化。 - */ - UIComponentImpl.prototype.initializeUIValues = function () { - this.$UIComponent = { - 0: NaN, - 1: NaN, - 2: NaN, - 3: NaN, - 4: NaN, - 5: NaN, - 6: NaN, - 7: NaN, - 8: NaN, - 9: NaN, - 10: 0, - 11: 0, - 12: 0, - 13: 100000, - 14: 0, - 15: 100000, - 16: 0, - 17: 0, - 18: NaN, - 19: NaN, - 20: 0, - 21: 0, - 22: 0, - 23: 0, - 24: true, - 25: true, - 26: true, - 27: false, - 28: false, - 29: false, - }; - this.$includeInLayout = true; - //if egret - this.$touchEnabled = true; - //endif*/ - }; - /** - * @private - * 子类覆盖此方法可以执行一些初始化子项操作。此方法仅在组件第一次添加到舞台时回调一次。 - * 请务必调用super.createChildren()以完成父类组件的初始化 - */ - UIComponentImpl.prototype.createChildren = function () { - }; - /** - * @private - * 子项创建完成,此方法在createChildren()之后执行。 - */ - UIComponentImpl.prototype.childrenCreated = function () { - }; - /** - * @private - * 提交属性,子类在调用完invalidateProperties()方法后,应覆盖此方法以应用属性 - */ - UIComponentImpl.prototype.commitProperties = function () { - var values = this.$UIComponent; - if (values[22 /* oldWidth */] != values[10 /* width */] || values[23 /* oldHeight */] != values[11 /* height */]) { - this.dispatchEventWith(egret.Event.RESIZE); - values[22 /* oldWidth */] = values[10 /* width */]; - values[23 /* oldHeight */] = values[11 /* height */]; - } - if (values[20 /* oldX */] != this.$getX() || values[21 /* oldY */] != this.$getY()) { - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.MOVE); - values[20 /* oldX */] = this.$getX(); - values[21 /* oldY */] = this.$getY(); - } - }; - /** - * @private - * 测量组件尺寸 - */ - UIComponentImpl.prototype.measure = function () { - }; - /** - * @private - * 更新显示列表 - */ - UIComponentImpl.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - }; - Object.defineProperty(UIComponentImpl.prototype, "includeInLayout", { - /** - * @private - * 指定此组件是否包含在父容器的布局中。若为false,则父级容器在测量和布局阶段都忽略此组件。默认值为true。 - * 注意,visible属性与此属性不同,设置visible为false,父级容器仍会对其布局。 - */ - get: function () { - return this.$includeInLayout; - }, - set: function (value) { - value = !!value; - if (this.$includeInLayout === value) - return; - this.$includeInLayout = true; - this.invalidateParentLayout(); - this.$includeInLayout = value; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param stage - * @param nestLevel - */ - UIComponentImpl.prototype.$onAddToStage = function (stage, nestLevel) { - this.$super.$onAddToStage.call(this, stage, nestLevel); - this.checkInvalidateFlag(); - var values = this.$UIComponent; - if (!values[29 /* initialized */]) { - values[29 /* initialized */] = true; - this.createChildren(); - this.childrenCreated(); - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CREATION_COMPLETE); - } - }; - /** - * @private - * 检查属性失效标记并应用 - */ - UIComponentImpl.prototype.checkInvalidateFlag = function (event) { - var values = this.$UIComponent; - if (values[24 /* invalidatePropertiesFlag */]) { - validator.invalidateProperties(this); - } - if (values[25 /* invalidateSizeFlag */]) { - validator.invalidateSize(this); - } - if (values[26 /* invalidateDisplayListFlag */]) { - validator.invalidateDisplayList(this); - } - }; - Object.defineProperty(UIComponentImpl.prototype, "left", { - /** - * @private - * 距父级容器离左边距离 - */ - get: function () { - return this.$UIComponent[0 /* left */]; - }, - set: function (value) { - if (!value || typeof value == "number") { - value = +value; - } - else { - value = value.toString().trim(); - } - var values = this.$UIComponent; - if (values[0 /* left */] === value) - return; - values[0 /* left */] = value; - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "right", { - /** - * @private - * 距父级容器右边距离 - */ - get: function () { - return this.$UIComponent[1 /* right */]; - }, - set: function (value) { - if (!value || typeof value == "number") { - value = +value; - } - else { - value = value.toString().trim(); - } - var values = this.$UIComponent; - if (values[1 /* right */] === value) - return; - values[1 /* right */] = value; - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "top", { - /** - * @private - * 距父级容器顶部距离 - */ - get: function () { - return this.$UIComponent[2 /* top */]; - }, - set: function (value) { - if (!value || typeof value == "number") { - value = +value; - } - else { - value = value.toString().trim(); - } - var values = this.$UIComponent; - if (values[2 /* top */] === value) - return; - values[2 /* top */] = value; - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "bottom", { - /** - * @private - * 距父级容器底部距离 - */ - get: function () { - return this.$UIComponent[3 /* bottom */]; - }, - set: function (value) { - if (!value || typeof value == "number") { - value = +value; - } - else { - value = value.toString().trim(); - } - var values = this.$UIComponent; - if (values[3 /* bottom */] == value) - return; - values[3 /* bottom */] = value; - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "horizontalCenter", { - /** - * @private - * 在父级容器中距水平中心位置的距离 - */ - get: function () { - return this.$UIComponent[4 /* horizontalCenter */]; - }, - set: function (value) { - if (!value || typeof value == "number") { - value = +value; - } - else { - value = value.toString().trim(); - } - var values = this.$UIComponent; - if (values[4 /* horizontalCenter */] === value) - return; - values[4 /* horizontalCenter */] = value; - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "verticalCenter", { - /** - * @private - * 在父级容器中距竖直中心位置的距离 - */ - get: function () { - return this.$UIComponent[5 /* verticalCenter */]; - }, - set: function (value) { - if (!value || typeof value == "number") { - value = +value; - } - else { - value = value.toString().trim(); - } - var values = this.$UIComponent; - if (values[5 /* verticalCenter */] === value) - return; - values[5 /* verticalCenter */] = value; - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "percentWidth", { - /** - * @private - * 相对父级容器宽度的百分比 - */ - get: function () { - return this.$UIComponent[6 /* percentWidth */]; - }, - set: function (value) { - value = +value; - var values = this.$UIComponent; - if (values[6 /* percentWidth */] === value) - return; - values[6 /* percentWidth */] = value; - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "percentHeight", { - /** - * @private - * 相对父级容器高度的百分比 - */ - get: function () { - return this.$UIComponent[7 /* percentHeight */]; - }, - set: function (value) { - value = +value; - var values = this.$UIComponent; - if (values[7 /* percentHeight */] === value) - return; - values[7 /* percentHeight */] = value; - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "explicitWidth", { - /** - * @private - * 外部显式指定的宽度 - */ - get: function () { - return this.$UIComponent[8 /* explicitWidth */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "explicitHeight", { - /** - * @private - * 外部显式指定的高度 - */ - get: function () { - return this.$UIComponent[9 /* explicitHeight */]; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 组件宽度,默认值为egret.NaN,设置为NaN将使用组件的measure()方法自动计算尺寸 - */ - UIComponentImpl.prototype.$getWidth = function () { - this.validateSizeNow(); - return this.$UIComponent[10 /* width */]; - }; - /** - * @private - * - * @param value - */ - UIComponentImpl.prototype.$setWidth = function (value) { - value = +value; - var values = this.$UIComponent; - if (value < 0 || values[10 /* width */] === value && values[8 /* explicitWidth */] === value) - return false; - values[8 /* explicitWidth */] = value; - if (isNaN(value)) - this.invalidateSize(); - this.invalidateProperties(); - this.invalidateDisplayList(); - this.invalidateParentLayout(); - return true; - }; - /** - * @private - * 立即验证自身的尺寸。 - */ - UIComponentImpl.prototype.validateSizeNow = function () { - this.validateSize(true); - this.updateFinalSize(); - }; - /** - * @private - * 组件高度,默认值为NaN,设置为NaN将使用组件的measure()方法自动计算尺寸 - */ - UIComponentImpl.prototype.$getHeight = function () { - this.validateSizeNow(); - return this.$UIComponent[11 /* height */]; - }; - /** - * @private - * - * @param value - */ - UIComponentImpl.prototype.$setHeight = function (value) { - value = +value; - var values = this.$UIComponent; - if (value < 0 || values[11 /* height */] === value && values[9 /* explicitHeight */] === value) - return false; - values[9 /* explicitHeight */] = value; - if (isNaN(value)) - this.invalidateSize(); - this.invalidateProperties(); - this.invalidateDisplayList(); - this.invalidateParentLayout(); - return true; - }; - Object.defineProperty(UIComponentImpl.prototype, "minWidth", { - /** - * @private - * 组件的最小宽度,此属性设置为大于maxWidth的值时无效。同时影响测量和自动布局的尺寸。 - */ - get: function () { - return this.$UIComponent[12 /* minWidth */]; - }, - set: function (value) { - value = +value || 0; - var values = this.$UIComponent; - if (value < 0 || values[12 /* minWidth */] === value) { - return; - } - values[12 /* minWidth */] = value; - this.invalidateSize(); - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "maxWidth", { - /** - * @private - * 组件的最大高度。同时影响测量和自动布局的尺寸。 - */ - get: function () { - return this.$UIComponent[13 /* maxWidth */]; - }, - set: function (value) { - value = +value || 0; - var values = this.$UIComponent; - if (value < 0 || values[13 /* maxWidth */] === value) { - return; - } - values[13 /* maxWidth */] = value; - this.invalidateSize(); - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "minHeight", { - /** - * @private - * 组件的最小高度,此属性设置为大于maxHeight的值时无效。同时影响测量和自动布局的尺寸。 - */ - get: function () { - return this.$UIComponent[14 /* minHeight */]; - }, - set: function (value) { - value = +value || 0; - var values = this.$UIComponent; - if (value < 0 || values[14 /* minHeight */] === value) { - return; - } - values[14 /* minHeight */] = value; - this.invalidateSize(); - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIComponentImpl.prototype, "maxHeight", { - /** - * @private - * 组件的最大高度,同时影响测量和自动布局的尺寸。 - */ - get: function () { - return this.$UIComponent[15 /* maxHeight */]; - }, - set: function (value) { - value = +value || 0; - var values = this.$UIComponent; - if (value < 0 || values[15 /* maxHeight */] === value) { - return; - } - values[15 /* maxHeight */] = value; - this.invalidateSize(); - this.invalidateParentLayout(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 设置测量结果。 - * @param width 测量宽度 - * @param height 测量高度 - */ - UIComponentImpl.prototype.setMeasuredSize = function (width, height) { - var values = this.$UIComponent; - values[16 /* measuredWidth */] = Math.ceil(+width || 0); - values[17 /* measuredHeight */] = Math.ceil(+height || 0); - }; - /** - * @private - * 设置组件的宽高。此方法不同于直接设置width,height属性, - * 不会影响显式标记尺寸属性 - */ - UIComponentImpl.prototype.setActualSize = function (w, h) { - var change = false; - var values = this.$UIComponent; - if (values[10 /* width */] !== w) { - values[10 /* width */] = w; - change = true; - } - if (values[11 /* height */] !== h) { - values[11 /* height */] = h; - change = true; - } - if (change) { - this.invalidateDisplayList(); - this.dispatchEventWith(egret.Event.RESIZE); - } - }; - /** - * @private - */ - UIComponentImpl.prototype.$updateUseTransform = function () { - this.$super.$updateUseTransform.call(this); - this.invalidateParentLayout(); - }; - /** - * @private - */ - UIComponentImpl.prototype.$setMatrix = function (matrix, needUpdateProperties) { - if (needUpdateProperties === void 0) { needUpdateProperties = true; } - this.$super.$setMatrix.call(this, matrix, needUpdateProperties); - this.invalidateParentLayout(); - return true; - }; - /** - * @private - */ - UIComponentImpl.prototype.$setAnchorOffsetX = function (value) { - this.$super.$setAnchorOffsetX.call(this, value); - this.invalidateParentLayout(); - return true; - }; - /** - * @private - */ - UIComponentImpl.prototype.$setAnchorOffsetY = function (value) { - this.$super.$setAnchorOffsetY.call(this, value); - this.invalidateParentLayout(); - return true; - }; - /** - * @private - * - * @param value - * @returns - */ - UIComponentImpl.prototype.$setX = function (value) { - var change = this.$super.$setX.call(this, value); - if (change) { - this.invalidateParentLayout(); - this.invalidateProperties(); - } - return change; - }; - /** - * @private - * - * @param value - * @returns - */ - UIComponentImpl.prototype.$setY = function (value) { - var change = this.$super.$setY.call(this, value); - if (change) { - this.invalidateParentLayout(); - this.invalidateProperties(); - } - return change; - }; - /** - * @private - * 标记属性失效 - */ - UIComponentImpl.prototype.invalidateProperties = function () { - var values = this.$UIComponent; - if (!values[24 /* invalidatePropertiesFlag */]) { - values[24 /* invalidatePropertiesFlag */] = true; - if (this.$stage) - validator.invalidateProperties(this); - } - }; - /** - * @private - * 验证组件的属性 - */ - UIComponentImpl.prototype.validateProperties = function () { - var values = this.$UIComponent; - if (values[24 /* invalidatePropertiesFlag */]) { - this.commitProperties(); - values[24 /* invalidatePropertiesFlag */] = false; - } - }; - /** - * @private - * 标记提交过需要验证组件尺寸 - */ - UIComponentImpl.prototype.invalidateSize = function () { - var values = this.$UIComponent; - if (!values[25 /* invalidateSizeFlag */]) { - values[25 /* invalidateSizeFlag */] = true; - if (this.$stage) - validator.invalidateSize(this); - } - }; - /** - * @private - * 验证组件的尺寸 - */ - UIComponentImpl.prototype.validateSize = function (recursive) { - if (recursive) { - var children = this.$children; - if (children) { - var length_5 = children.length; - for (var i = 0; i < length_5; i++) { - var child = children[i]; - if (egret.is(child, UIComponentClass)) { - child.validateSize(true); - } - } - } - } - var values = this.$UIComponent; - if (values[25 /* invalidateSizeFlag */]) { - var changed = this.measureSizes(); - if (changed) { - this.invalidateDisplayList(); - this.invalidateParentLayout(); - } - values[25 /* invalidateSizeFlag */] = false; - } - }; - /** - * @private - * 测量组件尺寸,返回尺寸是否发生变化 - */ - UIComponentImpl.prototype.measureSizes = function () { - var changed = false; - var values = this.$UIComponent; - if (!values[25 /* invalidateSizeFlag */]) - return changed; - if (isNaN(values[8 /* explicitWidth */]) || isNaN(values[9 /* explicitHeight */])) { - this.measure(); - if (values[16 /* measuredWidth */] < values[12 /* minWidth */]) { - values[16 /* measuredWidth */] = values[12 /* minWidth */]; - } - if (values[16 /* measuredWidth */] > values[13 /* maxWidth */]) { - values[16 /* measuredWidth */] = values[13 /* maxWidth */]; - } - if (values[17 /* measuredHeight */] < values[14 /* minHeight */]) { - values[17 /* measuredHeight */] = values[14 /* minHeight */]; - } - if (values[17 /* measuredHeight */] > values[15 /* maxHeight */]) { - values[17 /* measuredHeight */] = values[15 /* maxHeight */]; - } - } - var preferredW = this.getPreferredUWidth(); - var preferredH = this.getPreferredUHeight(); - if (preferredW !== values[18 /* oldPreferWidth */] || - preferredH !== values[19 /* oldPreferHeight */]) { - values[18 /* oldPreferWidth */] = preferredW; - values[19 /* oldPreferHeight */] = preferredH; - changed = true; - } - return changed; - }; - /** - * @private - * 标记需要验证显示列表 - */ - UIComponentImpl.prototype.invalidateDisplayList = function () { - var values = this.$UIComponent; - if (!values[26 /* invalidateDisplayListFlag */]) { - values[26 /* invalidateDisplayListFlag */] = true; - if (this.$stage) - validator.invalidateDisplayList(this); - } - }; - /** - * @private - * 验证子项的位置和大小,并绘制其他可视内容 - */ - UIComponentImpl.prototype.validateDisplayList = function () { - var values = this.$UIComponent; - if (values[26 /* invalidateDisplayListFlag */]) { - this.updateFinalSize(); - this.updateDisplayList(values[10 /* width */], values[11 /* height */]); - values[26 /* invalidateDisplayListFlag */] = false; - } - }; - /** - * @private - * 更新最终的组件宽高 - */ - UIComponentImpl.prototype.updateFinalSize = function () { - var unscaledWidth = 0; - var unscaledHeight = 0; - var values = this.$UIComponent; - if (values[27 /* layoutWidthExplicitlySet */]) { - unscaledWidth = values[10 /* width */]; - } - else if (!isNaN(values[8 /* explicitWidth */])) { - unscaledWidth = values[8 /* explicitWidth */]; - } - else { - unscaledWidth = values[16 /* measuredWidth */]; - } - if (values[28 /* layoutHeightExplicitlySet */]) { - unscaledHeight = values[11 /* height */]; - } - else if (!isNaN(values[9 /* explicitHeight */])) { - unscaledHeight = values[9 /* explicitHeight */]; - } - else { - unscaledHeight = values[17 /* measuredHeight */]; - } - this.setActualSize(unscaledWidth, unscaledHeight); - }; - /** - * @private - * 立即应用组件及其子项的所有属性 - */ - UIComponentImpl.prototype.validateNow = function () { - if (this.$stage) - validator.validateClient(this); - }; - /** - * @private - * 标记父级容器的尺寸和显示列表为失效 - */ - UIComponentImpl.prototype.invalidateParentLayout = function () { - var parent = this.$parent; - if (!parent || !this.$includeInLayout || !egret.is(parent, UIComponentClass)) - return; - parent.invalidateSize(); - parent.invalidateDisplayList(); - }; - /** - * @private - * 设置组件的布局宽高 - */ - UIComponentImpl.prototype.setLayoutBoundsSize = function (layoutWidth, layoutHeight) { - layoutHeight = +layoutHeight; - layoutWidth = +layoutWidth; - if (layoutHeight < 0 || layoutWidth < 0) { - return; - } - var values = this.$UIComponent; - var maxWidth = values[13 /* maxWidth */]; - var maxHeight = values[15 /* maxHeight */]; - var minWidth = Math.min(values[12 /* minWidth */], maxWidth); - var minHeight = Math.min(values[14 /* minHeight */], maxHeight); - var width; - var height; - if (isNaN(layoutWidth)) { - values[27 /* layoutWidthExplicitlySet */] = false; - width = this.getPreferredUWidth(); - } - else { - values[27 /* layoutWidthExplicitlySet */] = true; - width = Math.max(minWidth, Math.min(maxWidth, layoutWidth)); - } - if (isNaN(layoutHeight)) { - values[28 /* layoutHeightExplicitlySet */] = false; - height = this.getPreferredUHeight(); - } - else { - values[28 /* layoutHeightExplicitlySet */] = true; - height = Math.max(minHeight, Math.min(maxHeight, layoutHeight)); - } - var matrix = this.getAnchorMatrix(); - if (isDeltaIdentity(matrix)) { - this.setActualSize(width, height); - return; - } - var fitSize = sys.MatrixUtil.fitBounds(layoutWidth, layoutHeight, matrix, values[8 /* explicitWidth */], values[9 /* explicitHeight */], this.getPreferredUWidth(), this.getPreferredUHeight(), minWidth, minHeight, maxWidth, maxHeight); - if (!fitSize) { - fitSize = egret.Point.create(minWidth, minHeight); - } - this.setActualSize(fitSize.x, fitSize.y); - egret.Point.release(fitSize); - }; - /** - * @private - * 设置组件的布局位置 - */ - UIComponentImpl.prototype.setLayoutBoundsPosition = function (x, y) { - var matrix = this.$getMatrix(); - if (!isDeltaIdentity(matrix) || this.anchorOffsetX != 0 || this.anchorOffsetY != 0) { - var bounds = egret.$TempRectangle; - this.getLayoutBounds(bounds); - x += this.$getX() - bounds.x; - y += this.$getY() - bounds.y; - } - var changed = this.$super.$setX.call(this, x); - if (this.$super.$setY.call(this, y) || changed) { - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.MOVE); - } - }; - /** - * @private - * 组件的布局尺寸,常用于父级的updateDisplayList()方法中 - * 按照:布局尺寸>外部显式设置尺寸>测量尺寸 的优先级顺序返回尺寸, - * 注意此方法返回值已经包含scale和rotation。 - */ - UIComponentImpl.prototype.getLayoutBounds = function (bounds) { - var values = this.$UIComponent; - var w; - if (values[27 /* layoutWidthExplicitlySet */]) { - w = values[10 /* width */]; - } - else if (!isNaN(values[8 /* explicitWidth */])) { - w = values[8 /* explicitWidth */]; - } - else { - w = values[16 /* measuredWidth */]; - } - var h; - if (values[28 /* layoutHeightExplicitlySet */]) { - h = values[11 /* height */]; - } - else if (!isNaN(values[9 /* explicitHeight */])) { - h = values[9 /* explicitHeight */]; - } - else { - h = values[17 /* measuredHeight */]; - } - this.applyMatrix(bounds, w, h); - }; - /** - * @private - * - * @returns - */ - UIComponentImpl.prototype.getPreferredUWidth = function () { - var values = this.$UIComponent; - return isNaN(values[8 /* explicitWidth */]) ? - values[16 /* measuredWidth */] : values[8 /* explicitWidth */]; - }; - /** - * @private - * - * @returns - */ - UIComponentImpl.prototype.getPreferredUHeight = function () { - var values = this.$UIComponent; - return isNaN(values[9 /* explicitHeight */]) ? - values[17 /* measuredHeight */] : values[9 /* explicitHeight */]; - }; - /** - * @private - * 获取组件的首选尺寸,常用于父级的measure()方法中 - * 按照:外部显式设置尺寸>测量尺寸 的优先级顺序返回尺寸, - * 注意此方法返回值已经包含scale和rotation。 - */ - UIComponentImpl.prototype.getPreferredBounds = function (bounds) { - var w = this.getPreferredUWidth(); - var h = this.getPreferredUHeight(); - this.applyMatrix(bounds, w, h); - }; - /** - * @private - */ - UIComponentImpl.prototype.applyMatrix = function (bounds, w, h) { - bounds.setTo(0, 0, w, h); - var matrix = this.getAnchorMatrix(); - if (isDeltaIdentity(matrix)) { - bounds.x += matrix.tx; - bounds.y += matrix.ty; - } - else { - matrix.$transformBounds(bounds); - } - }; - /** - * @private - */ - UIComponentImpl.prototype.getAnchorMatrix = function () { - var matrix = this.$getMatrix(); - var offsetX = this.anchorOffsetX; - var offsetY = this.anchorOffsetY; - if (offsetX != 0 || offsetY != 0) { - var tempM = egret.$TempMatrix; - matrix.$preMultiplyInto(tempM.setTo(1, 0, 0, 1, -offsetX, -offsetY), tempM); - return tempM; - } - return matrix; - }; - return UIComponentImpl; - }(egret.DisplayObject)); - sys.UIComponentImpl = UIComponentImpl; - __reflect(UIComponentImpl.prototype, "eui.sys.UIComponentImpl", ["eui.UIComponent", "egret.DisplayObject"]); - /** - * 检查一个函数的方法体是否为空。 - */ - function isEmptyFunction(prototype, key) { - if (typeof prototype[key] != "function") { - return false; - } - var body = prototype[key].toString(); - var index = body.indexOf("{"); - var lastIndex = body.lastIndexOf("}"); - body = body.substring(index + 1, lastIndex); - return body.trim() == ""; - } - /** - * @private - * 拷贝模板类的方法体和属性到目标类上。 - * @param target 目标类 - * @param template 模板类 - */ - function mixin(target, template) { - for (var property in template) { - if (property != "prototype" && template.hasOwnProperty(property)) { - target[property] = template[property]; - } - } - var prototype = target.prototype; - var protoBase = template.prototype; - var keys = Object.keys(protoBase); - var length = keys.length; - for (var i = 0; i < length; i++) { - var key = keys[i]; - if (key == "__meta__") { - continue; - } - if (!prototype.hasOwnProperty(key) || isEmptyFunction(prototype, key)) { - var value = Object.getOwnPropertyDescriptor(protoBase, key); - Object.defineProperty(prototype, key, value); - } - } - } - sys.mixin = mixin; - /** - * @private - * 自定义类实现UIComponent的步骤: - * 1.在自定义类的构造函数里调用:this.initializeUIValues(); - * 2.拷贝UIComponent接口定义的所有内容(包括注释掉的protected函数)到自定义类,将所有子类需要覆盖的方法都声明为空方法体。 - * 3.在定义类结尾的外部调用sys.implementUIComponent(),并传入自定义类。 - * 4.若覆盖了某个UIComponent的方法,需要手动调用UIComponentImpl.prototype["方法名"].call(this); - * @param descendant 自定义的UIComponent子类 - * @param base 自定义子类继承的父类 - */ - function implementUIComponent(descendant, base, isContainer) { - mixin(descendant, UIComponentImpl); - var prototype = descendant.prototype; - prototype.$super = base.prototype; - eui.registerProperty(descendant, "left", "Percentage"); - eui.registerProperty(descendant, "right", "Percentage"); - eui.registerProperty(descendant, "top", "Percentage"); - eui.registerProperty(descendant, "bottom", "Percentage"); - eui.registerProperty(descendant, "horizontalCenter", "Percentage"); - eui.registerProperty(descendant, "verticalCenter", "Percentage"); - if (isContainer) { - prototype.$childAdded = function (child, index) { - this.invalidateSize(); - this.invalidateDisplayList(); - }; - prototype.$childRemoved = function (child, index) { - this.invalidateSize(); - this.invalidateDisplayList(); - }; - } - if (true) { - Object.defineProperty(prototype, "preferredWidth", { - get: function () { - var bounds = egret.$TempRectangle; - this.getPreferredBounds(bounds); - return bounds.width; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "preferredHeight", { - get: function () { - var bounds = egret.$TempRectangle; - this.getPreferredBounds(bounds); - return bounds.height; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "preferredX", { - get: function () { - var bounds = egret.$TempRectangle; - this.getPreferredBounds(bounds); - return bounds.x; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "preferredY", { - get: function () { - var bounds = egret.$TempRectangle; - this.getPreferredBounds(bounds); - return bounds.y; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "layoutBoundsX", { - get: function () { - var bounds = egret.$TempRectangle; - this.getLayoutBounds(bounds); - return bounds.x; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "layoutBoundsY", { - get: function () { - var bounds = egret.$TempRectangle; - this.getLayoutBounds(bounds); - return bounds.y; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "layoutBoundsWidth", { - get: function () { - var bounds = egret.$TempRectangle; - this.getLayoutBounds(bounds); - return bounds.width; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "layoutBoundsHeight", { - get: function () { - var bounds = egret.$TempRectangle; - this.getLayoutBounds(bounds); - return bounds.height; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "measuredWidth", { - get: function () { - return this.$UIComponent[16 /* measuredWidth */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "measuredHeight", { - get: function () { - return this.$UIComponent[17 /* measuredHeight */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "layoutWidthExplicitlySet", { - get: function () { - return this.$UIComponent[27 /* layoutWidthExplicitlySet */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "layoutHeightExplicitlySet", { - get: function () { - return this.$UIComponent[28 /* layoutHeightExplicitlySet */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "invalidatePropertiesFlag", { - get: function () { - return this.$UIComponent[24 /* invalidatePropertiesFlag */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "invalidateSizeFlag", { - get: function () { - return this.$UIComponent[25 /* invalidateSizeFlag */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(prototype, "invalidateDisplayListFlag", { - get: function () { - return this.$UIComponent[26 /* invalidateDisplayListFlag */]; - }, - enumerable: true, - configurable: true - }); - } - } - sys.implementUIComponent = implementUIComponent; - })(sys = eui.sys || (eui.sys = {})); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -/// -/// -var eui; -(function (eui) { - /** - * The Group class is defines the base class for layout component. - * If the contents of the sub items are too large to scroll to show, you can wrap a Scroller component outside the - * group (Give the instance of Group to viewport property of Scroller component). - * The scroller component can adds a scrolling touch operation for the Group. - * - * @see http://edn.egret.com/cn/article/index/id/608 Simple container - * @defaultProperty elementsContent - * @includeExample extension/eui/components/GroupExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * Group 是自动布局的容器基类。如果包含的子项内容太大需要滚动显示,可以在在 Group 外部包裹一层 Scroller 组件 - * (将 Group 实例赋值给 Scroller 组件的 viewport 属性)。Scroller 会为 Group 添加滚动的触摸操作功能,并显示垂直或水平的滚动条。 - * - * @see http://edn.egret.com/cn/article/index/id/608 简单容器 - * @defaultProperty elementsContent - * @includeExample extension/eui/components/GroupExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var Group = (function (_super) { - __extends(Group, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function Group() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$layout = null; - /** - * @private - */ - _this.$stateValues = new eui.sys.StateValues(); - _this.initializeUIValues(); - _this.$Group = { - 0: 0, - 1: 0, - 2: 0, - 3: 0, - 4: false, - 5: false, - }; - _this.$stateValues.parent = _this; - return _this; - } - Object.defineProperty(Group.prototype, "elementsContent", { - /** - * This property is Usually invoked in resolving an EXML for adding multiple children quickly. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此属性通常在 EXML 的解析器中调用,便于快速添加多个子项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - set: function (value) { - if (value) { - var length_6 = value.length; - for (var i = 0; i < length_6; i++) { - this.addChild(value[i]); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Group.prototype, "layout", { - /** - * The layout object for this container. - * This object is responsible for the measurement and layout of - * the UIcomponent in the container. - * - * @default eui.BasicLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此容器的布局对象。 - * - * s@default eui.BasicLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$layout; - }, - set: function (value) { - this.$setLayout(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - Group.prototype.$setLayout = function (value) { - if (this.$layout == value) - return false; - if (this.$layout) { - this.$layout.target = null; - } - this.$layout = value; - if (value) { - value.target = this; - } - this.invalidateSize(); - this.invalidateDisplayList(); - return true; - }; - Object.defineProperty(Group.prototype, "contentWidth", { - /** - * @copy eui.IViewport#contentWidth - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - return this.$Group[0 /* contentWidth */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Group.prototype, "contentHeight", { - /** - * @copy eui.IViewport#contentHeight - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - return this.$Group[1 /* contentHeight */]; - }, - enumerable: true, - configurable: true - }); - /** - * - * Sets the contentWidth and contentHeight - * properties. - * - * This method is intended for layout class developers who should - * call it from updateDisplayList() methods. - * - * @param width The new value of contentWidth. - * @param height The new value of contentHeight. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * - * 设置 contentWidthcontentHeight 属性。 - * 此方法由布局来调用,开发者应该在布局类的 updateDisplayList() 方法中对其进行调用。 - * - * @param width contentWidth 的新值。 - * @param height contentHeight 的新值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Group.prototype.setContentSize = function (width, height) { - width = Math.ceil(+width || 0); - height = Math.ceil(+height || 0); - var values = this.$Group; - var wChange = (values[0 /* contentWidth */] !== width); - var hChange = (values[1 /* contentHeight */] !== height); - if (!wChange && !hChange) { - return; - } - values[0 /* contentWidth */] = width; - values[1 /* contentHeight */] = height; - if (wChange) { - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "contentWidth"); - } - if (hChange) { - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "contentHeight"); - } - }; - Object.defineProperty(Group.prototype, "scrollEnabled", { - /** - * @copy eui.IViewport#scrollEnabled - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - return this.$Group[4 /* scrollEnabled */]; - }, - set: function (value) { - value = !!value; - var values = this.$Group; - if (value === values[4 /* scrollEnabled */]) - return; - values[4 /* scrollEnabled */] = value; - this.updateScrollRect(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Group.prototype, "scrollH", { - /** - * @copy eui.IViewport#scrollH - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - return this.$Group[2 /* scrollH */]; - }, - set: function (value) { - value = +value || 0; - var values = this.$Group; - if (value === values[2 /* scrollH */]) - return; - values[2 /* scrollH */] = value; - if (this.updateScrollRect() && this.$layout) { - this.$layout.scrollPositionChanged(); - } - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "scrollH"); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Group.prototype, "scrollV", { - /** - * @copy eui.IViewport#scrollV - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - return this.$Group[3 /* scrollV */]; - }, - set: function (value) { - value = +value || 0; - var values = this.$Group; - if (value == values[3 /* scrollV */]) - return; - values[3 /* scrollV */] = value; - if (this.updateScrollRect() && this.$layout) { - this.$layout.scrollPositionChanged(); - } - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "scrollV"); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - Group.prototype.updateScrollRect = function () { - var values = this.$Group; - var hasClip = values[4 /* scrollEnabled */]; - if (hasClip) { - var uiValues = this.$UIComponent; - this.scrollRect = egret.$TempRectangle.setTo(values[2 /* scrollH */], values[3 /* scrollV */], uiValues[10 /* width */], uiValues[11 /* height */]); - } - else if (this.$scrollRect) { - this.scrollRect = null; - } - return hasClip; - }; - Object.defineProperty(Group.prototype, "numElements", { - /** - * The number of layout element in this container. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 布局元素子项的数量。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$children.length; - }, - enumerable: true, - configurable: true - }); - /** - * Returns the layout element at the specified index. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个布局元素子项。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Group.prototype.getElementAt = function (index) { - return this.$children[index]; - }; - Group.prototype.getVirtualElementAt = function (index) { - return this.getElementAt(index); - }; - /** - * Set the index range of the sub Visual element in container which support virtual layout. - * This method is invalid in container which do not support virtual layout. - * This method is usually invoked before layout. Override this method to release the invisible elements. - * - * @param startIndex the start index of sub visual elements(include) - * @param endIndex the end index of sub visual elements(include) - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在支持虚拟布局的容器中,设置容器内可见的子元素索引范围。此方法在不支持虚拟布局的容器中无效。 - * 通常在即将重新布局子项之前会被调用一次,容器覆盖此方法提前释放已经不可见的子元素。 - * - * @param startIndex 可视元素起始索引(包括) - * @param endIndex 可视元素结束索引(包括) - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Group.prototype.setVirtualElementIndicesInView = function (startIndex, endIndex) { - }; - Object.defineProperty(Group.prototype, "touchThrough", { - /** - * When true, this property - * ensures that the entire bounds of the Group respond to - * touch events such as begin. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触摸组件的背景透明区域是否可以穿透。设置为true表示可以穿透,反之透明区域也会响应触摸事件。默认 false。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$Group[5 /* touchThrough */]; - }, - set: function (value) { - this.$Group[5 /* touchThrough */] = !!value; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - Group.prototype.$hitTest = function (stageX, stageY) { - var target = _super.prototype.$hitTest.call(this, stageX, stageY); - if (target || this.$Group[5 /* touchThrough */]) { - return target; - } - //Bug: 当 group.sacleX or scaleY ==0 的时候,随便点击那里都点击成功 - //虽然 super.$hitTest里面检测过一次 宽高大小,但是没有直接退出这个函数,所以要再判断一次;(width,height可以不判断) - if (!this.$visible || !this.touchEnabled || this.scaleX === 0 || this.scaleY === 0 || this.width === 0 || this.height === 0) { - return null; - } - var point = this.globalToLocal(stageX, stageY, egret.$TempPoint); - var values = this.$UIComponent; - var bounds = egret.$TempRectangle.setTo(0, 0, values[10 /* width */], values[11 /* height */]); - var scrollRect = this.$scrollRect; - if (scrollRect) { - bounds.x = scrollRect.x; - bounds.y = scrollRect.y; - } - if (bounds.contains(point.x, point.y)) { - return this; - } - return null; - }; - /** - * @copy eui.Component#invalidateState() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.invalidateState = function () { - var values = this.$stateValues; - if (values.stateIsDirty) { - return; - } - values.stateIsDirty = true; - this.invalidateProperties(); - }; - /** - * @copy eui.Component#getCurrentState() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.getCurrentState = function () { - return ""; - }; - /** - * @copy eui.Component#createChildren() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.createChildren = function () { - if (!this.$layout) { - this.$setLayout(new eui.BasicLayout()); - } - this.initializeStates(this.$stage); - }; - /** - * @copy eui.Component#childrenCreated() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.childrenCreated = function () { - }; - /** - * @copy eui.Component#commitProperties() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.commitProperties = function () { - eui.sys.UIComponentImpl.prototype["commitProperties"].call(this); - var values = this.$stateValues; - if (values.stateIsDirty) { - values.stateIsDirty = false; - if (!values.explicitState) { - values.currentState = this.getCurrentState(); - this.commitCurrentState(); - } - } - }; - /** - * @copy eui.Component#measure() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.measure = function () { - if (!this.$layout) { - this.setMeasuredSize(0, 0); - return; - } - this.$layout.measure(); - }; - /** - * @copy eui.Component#updateDisplayList() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - if (this.$layout) { - this.$layout.updateDisplayList(unscaledWidth, unscaledHeight); - } - this.updateScrollRect(); - }; - /** - * @copy eui.Component#invalidateParentLayout() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.invalidateParentLayout = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.setMeasuredSize = function (width, height) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.invalidateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.validateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.invalidateSize = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.validateSize = function (recursive) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.invalidateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.validateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.validateNow = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.setLayoutBoundsSize = function (layoutWidth, layoutHeight) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.setLayoutBoundsPosition = function (x, y) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.getLayoutBounds = function (bounds) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Group.prototype.getPreferredBounds = function (bounds) { - }; - return Group; - }(egret.DisplayObjectContainer)); - eui.Group = Group; - __reflect(Group.prototype, "eui.Group", ["eui.IViewport", "eui.UIComponent", "egret.DisplayObject"]); - eui.sys.implementUIComponent(Group, egret.DisplayObjectContainer, true); - eui.sys.mixin(Group, eui.sys.StateClient); - eui.registerProperty(Group, "elementsContent", "Array", true); - eui.registerProperty(Group, "states", "State[]"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var key = "__bindables__"; - /** - * Register a property of an instance is can be bound. - * This method is ususally invoked by Watcher class. - * - * @param instance the instance to be registered. - * @param property the property of specified instance to be registered. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 标记实例的一个属性是可绑定的,此方法通常由 Watcher 类调用。 - * - * @param instance 要标记的实例 - * @param property 可绑定的属性。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function registerBindable(instance, property) { - if (true) { - if (!instance) { - egret.$error(1003, "instance"); - } - if (!property) { - egret.$error(1003, "property"); - } - } - if (instance.hasOwnProperty(key)) { - instance[key].push(property); - } - else { - var list = [property]; - if (instance[key]) { - list = instance[key].concat(list); - } - instance[key] = list; - } - } - eui.registerBindable = registerBindable; -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -/// -var eui; -(function (eui) { - /** - * The Component class defines the base class for skinnable components. - * The skins used by a Component class are typically child classes of - * the Skin class.

      - * - * Associate a skin class with a component class by setting the skinName property of the - * component class. - * @event egret.Event.COMPLETE Dispatch when skinName property is set the path of external EXML file and the EXML file is resolved. - * - * @includeExample extension/eui/components/ComponentExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * Component 类定义可设置外观的组件的基类。Component 类所使用的外观通常是 Skin 类的子类。

      - * 通过设置 component 类的 skinName 属性,将 skin 类与 component 类相关联。 - * @event egret.Event.COMPLETE 当设置skinName为外部exml文件路径时,加载并完成EXML解析后调度。 - * - * @includeExample extension/eui/components/ComponentExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var Component = (function (_super) { - __extends(Component, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function Component() { - var _this = _super.call(this) || this; - _this.initializeUIValues(); - _this.$Component = { - 0: null, - 1: null, - 2: "", - 3: true, - 4: false, - 5: false, - 6: true, - 7: true, - 8: null //skin - }; - //if egret - _this.$touchEnabled = true; - return _this; - //endif*/ - } - Object.defineProperty(Component.prototype, "hostComponentKey", { - /** - * A identifier of host component which can determine only one component names. - * Usually used for quering a default skin name in theme. - * @default null - * @see eui.Theme#getSkinName() - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 主机组件标识符。用于唯一确定一个组件的名称。通常用于在主题中查询默认皮肤名。 - * - * @default null - * @see eui.Theme#getSkinName() - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$Component[0 /* hostComponentKey */]; - }, - set: function (value) { - this.$Component[0 /* hostComponentKey */] = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Component.prototype, "skinName", { - /** - * Identifier of skin. Valid values: class definition of skin, - * class name of skin, instance of skin, EXML or external EXML file path. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤标识符。有效值可为:皮肤类定义,皮肤类名,皮肤实例,EXML文件内容,或外部EXML文件路径, - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$Component[1 /* skinName */]; - }, - set: function (value) { - var values = this.$Component; - values[5 /* skinNameExplicitlySet */] = true; - if (values[1 /* skinName */] == value) - return; - if (value) { - values[1 /* skinName */] = value; - } - else { - var theme = egret.getImplementation("eui.Theme"); - if (theme) { - var skinName = theme.getSkinName(this); - if (skinName) { - values[1 /* skinName */] = skinName; - } - } - } - this.$parseSkinName(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 解析skinName - */ - Component.prototype.$parseSkinName = function () { - var skinName = this.skinName; - var skin; - if (skinName) { - if (skinName.prototype) { - skin = new skinName(); - } - else if (typeof (skinName) == "string") { - var clazz = void 0; - var text = skinName.trim(); - if (text.charAt(0) == "<") { - clazz = EXML.parse(text); - } - else { - clazz = egret.getDefinitionByName(skinName); - if (!clazz && text.toLowerCase().indexOf(".exml") != -1) { - EXML.load(skinName, this.onExmlLoaded, this, true); - return; - } - } - if (clazz) { - skin = new clazz(); - } - } - else { - skin = skinName; - } - } - this.setSkin(skin); - }; - /** - * @private - * @param clazz - * @param url - */ - Component.prototype.onExmlLoaded = function (clazz, url) { - if (this.skinName != url) { - return; - } - var skin = new clazz(); - this.setSkin(skin); - }; - Object.defineProperty(Component.prototype, "skin", { - /** - * The instance of the skin class for this component instance. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤对象实例。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$Component[8 /* skin */]; - }, - enumerable: true, - configurable: true - }); - /** - * Setter for the skin instance. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置皮肤实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.setSkin = function (skin) { - if (skin && !(skin instanceof eui.Skin)) { - skin = null; - true && egret.$error(2202); - } - var values = this.$Component; - var oldSkin = values[8 /* skin */]; - if (oldSkin) { - var skinParts = oldSkin.skinParts; - var length_7 = skinParts.length; - for (var i = 0; i < length_7; i++) { - var partName = skinParts[i]; - if (this[partName]) { - this.setSkinPart(partName, null); - } - } - var children = oldSkin.$elementsContent; - if (children) { - length_7 = children.length; - for (var i = 0; i < length_7; i++) { - var child = children[i]; - if (child.$parent == this) { - this.removeChild(child); - } - } - } - oldSkin.hostComponent = null; - } - values[8 /* skin */] = skin; - if (skin) { - var skinParts = skin.skinParts; - var length_8 = skinParts.length; - for (var i = 0; i < length_8; i++) { - var partName = skinParts[i]; - var instance = skin[partName]; - if (instance) { - this.setSkinPart(partName, instance); - } - } - var children = skin.$elementsContent; - if (children) { - for (var i = children.length - 1; i >= 0; i--) { - this.addChildAt(children[i], 0); - } - } - skin.hostComponent = this; - } - this.invalidateSize(); - this.invalidateDisplayList(); - this.dispatchEventWith(egret.Event.COMPLETE); - }; - /** - * Find the skin parts in the skin class and assign them to the properties of the component. - * You do not call this method directly. This method will be invoked automatically when using a EXML as skin. - * The ID for a tag in an EXML will be passed in as partName, and the instance of the tag will be - * passed in as instance. - * @param partName name of a skin part - * @param instance instance of a skin part - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 关联一个对象到逻辑组件的指定皮肤部件上。通常您不需要手动调用此方法,当使用EXML文件作为组件皮肤,此方法将会被自动调用。 - * 在运行时,EXML文件内声明的id名称将作为此方法的partName参数,而id所对应的节点对象,将作为此方法的instance参数被依次传入。 - * @param partName 皮肤部件名称 - * @param instance 皮肤部件实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.setSkinPart = function (partName, instance) { - var oldInstance = this[partName]; - if (oldInstance) { - this.partRemoved(partName, oldInstance); - } - this[partName] = instance; - if (instance) { - this.partAdded(partName, instance); - } - }; - /** - * Called when a skin part is added. - * You do not call this method directly. - * EUI calls it automatically when it calls the setSkinPart() method.

      - * - * Override this function to attach behavior to the part, such as add event listener or - * assign property values cached. - * @param partName name of a skin part to add. - * @param instance instance of a skin part to add. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 添加皮肤部件时调用。 - * 您无需直接调用此方法。 - * EUI 会在调用 setSkinPart()方法时自动调用此方法。

      - * - * 子类覆盖此方法,以在皮肤部件第一次附加时对其执行一些初始化操作,例如添加事件监听,赋值缓存的属性值等。 - * @param partName 要附加的皮肤部件名称。 - * @param instance 要附加的皮肤部件实例。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.partAdded = function (partName, instance) { - }; - /** - * Called when an instance of a skin part is being removed. - * You do not call this method directly. - * EUI calls it automatically when it calls the setSkinPart() method.

      - * - * Override this function to clean behavior of the part, such as remove event listener or - * disconnect the cache reference - * @param partName name of a skin part to remove. - * @param instance instance of a skin part to remove. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 正删除外观部件的实例时调用。 - * 您无需直接调用此方法。 - * EUI 会在调用 setSkinPart()方法时自动调用此方法。

      - * - * 子类覆盖此方法,以在皮肤部件从逻辑组件卸载时对其执行一些清理操作,例如移除事件监听,断开缓存的引用等。 - * @param partName 要卸载的皮肤部件名称 - * @param instance 要卸载的皮肤部件实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.partRemoved = function (partName, instance) { - }; - /** - * @private - * - * @param value - */ - Component.prototype.$setTouchChildren = function (value) { - value = !!value; - var values = this.$Component; - values[6 /* explicitTouchChildren */] = value; - if (values[3 /* enabled */]) { - values[6 /* explicitTouchChildren */] = value; - return _super.prototype.$setTouchChildren.call(this, value); - } - else { - return true; - } - }; - /** - * @private - * - * @param value - */ - Component.prototype.$setTouchEnabled = function (value) { - value = !!value; - var values = this.$Component; - values[7 /* explicitTouchEnabled */] = value; - if (values[3 /* enabled */]) { - _super.prototype.$setTouchEnabled.call(this, value); - } - }; - Object.defineProperty(Component.prototype, "enabled", { - /** - * Whether the component can accept user interaction. - * After setting the enabled property to false, components will disabled touch event - * (set touchEnabled and touchChildren to false) and set state of skin to "disabled". - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件是否可以接受用户交互。 - * 将 enabled 属性设置为 false 后, - * 组件会自动禁用触摸事件(将 touchEnabled 和 touchChildren 同时设置为 false), - * 部分组件可能还会将皮肤的视图状态设置为"disabled",使其所有子项的颜色变暗。 - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$Component[3 /* enabled */]; - }, - set: function (value) { - value = !!value; - this.$setEnabled(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - Component.prototype.$setEnabled = function (value) { - var values = this.$Component; - if (value === values[3 /* enabled */]) { - return false; - } - values[3 /* enabled */] = value; - if (value) { - this.$touchEnabled = values[7 /* explicitTouchEnabled */]; - this.$touchChildren = values[6 /* explicitTouchChildren */]; - } - else { - this.$touchEnabled = false; - this.$touchChildren = false; - } - this.invalidateState(); - return true; - }; - Object.defineProperty(Component.prototype, "currentState", { - //========================皮肤视图状态=====================start======================= - /** - * The current view state of the component. When you use this property to set a component's state, - * EUI will explicit update state of skin and ignore the return of getCurrentState(). - * - * Set to "" or null to reset the component back to its base state. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件的当前视图状态。显式设置此属性, - * 将采用显式设置的值去更新皮肤状态,而忽略组件内部 getCurrentState() 方法返回的值。 - * - * 将其设置为 "" 或 null 可将取消组件外部显式设置的视图状态名称,从而采用内部 getCurrentState() 方法返回的状态。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - var values = this.$Component; - return values[2 /* explicitState */] ? - values[2 /* explicitState */] : this.getCurrentState(); - }, - set: function (value) { - var values = this.$Component; - if (value == values[2 /* explicitState */]) { - return; - } - values[2 /* explicitState */] = value; - this.invalidateState(); - }, - enumerable: true, - configurable: true - }); - /** - * Marks the component so that the new state of the skin is set during a later screen update. - * A subclass of SkinnableComponent must override getCurrentState() to return a value. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 标记组件当前的视图状态失效,调用此方法后,子类应该覆盖 getCurrentState() 方法来返回当前的视图状态名称。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.invalidateState = function () { - var values = this.$Component; - if (values[4 /* stateIsDirty */]) - return; - values[4 /* stateIsDirty */] = true; - this.invalidateProperties(); - }; - /** - * Returns the name of the state to be applied to the skin.

      - * A subclass of SkinnableComponent must override this method to return a value. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 返回组件当前的皮肤状态名称,子类覆盖此方法定义各种状态名 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.getCurrentState = function () { - return ""; - }; - /** - * Create child objects of the component. This is an advanced method that you might override - * when creating a subclass of Component. This method will be called once it be added to stage. - * You must invoke super.createChildren() to complete initialization of the parent class - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 子类覆盖此方法可以执行一些初始化子项操作。此方法仅在组件第一次添加到舞台时回调一次。 - * 请务必调用super.createChildren()以完成父类组件的初始化 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.createChildren = function () { - var values = this.$Component; - if (!values[1 /* skinName */]) { - var theme = egret.getImplementation("eui.Theme"); - if (theme) { - var skinName = theme.getSkinName(this); - if (skinName) { - values[1 /* skinName */] = skinName; - this.$parseSkinName(); - } - } - } - }; - /** - * Performs any final processing after child objects are created. - * This is an advanced method that you might override - * when creating a subclass of Component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建子对象后执行任何最终处理。此方法在创建 Component 的子类时覆盖。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.childrenCreated = function () { - }; - /** - * Processes the properties set on the component. - * You can override this method when creating a subclass of Component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 提交属性,子类在调用完invalidateProperties()方法后,应覆盖此方法以应用属性 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.commitProperties = function () { - eui.sys.UIComponentImpl.prototype["commitProperties"].call(this); - var values = this.$Component; - if (values[4 /* stateIsDirty */]) { - values[4 /* stateIsDirty */] = false; - if (values[8 /* skin */]) { - values[8 /* skin */].currentState = this.currentState; - } - } - }; - /** - * Calculates the default size. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 测量组件尺寸 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.measure = function () { - eui.sys.measure(this); - var skin = this.$Component[8 /* skin */]; - if (!skin) { - return; - } - var values = this.$UIComponent; - if (!isNaN(skin.width)) { - values[16 /* measuredWidth */] = skin.width; - } - else { - if (values[16 /* measuredWidth */] < skin.minWidth) { - values[16 /* measuredWidth */] = skin.minWidth; - } - if (values[16 /* measuredWidth */] > skin.maxWidth) { - values[16 /* measuredWidth */] = skin.maxWidth; - } - } - if (!isNaN(skin.height)) { - values[17 /* measuredHeight */] = skin.height; - } - else { - if (values[17 /* measuredHeight */] < skin.minHeight) { - values[17 /* measuredHeight */] = skin.minHeight; - } - if (values[17 /* measuredHeight */] > skin.maxHeight) { - values[17 /* measuredHeight */] = skin.maxHeight; - } - } - }; - /** - * Draws the object and/or sizes and positions its children. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 更新显示列表 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - eui.sys.updateDisplayList(this, unscaledWidth, unscaledHeight); - }; - /** - * Method to invalidate parent size and display list if - * this object affects its layout (includeInLayout is true). - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此对象影响其布局时(includeInLayout 为 true),使父代大小和显示列表失效的方法。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Component.prototype.invalidateParentLayout = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.setMeasuredSize = function (width, height) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.invalidateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.validateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.invalidateSize = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.validateSize = function (recursive) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.invalidateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.validateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.validateNow = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.setLayoutBoundsSize = function (layoutWidth, layoutHeight) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.setLayoutBoundsPosition = function (x, y) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.getLayoutBounds = function (bounds) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Component.prototype.getPreferredBounds = function (bounds) { - }; - return Component; - }(egret.DisplayObjectContainer)); - eui.Component = Component; - __reflect(Component.prototype, "eui.Component", ["eui.UIComponent", "egret.DisplayObject"]); - eui.registerProperty(Component, "skinName", "Class"); - eui.sys.implementUIComponent(Component, egret.DisplayObjectContainer, true); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The DataGroup class is the base container class for data items. - * The DataGroup class converts data items to visual elements for display. - * While this container can hold visual elements, it is often used only - * to hold data items as children. - * - * @see eui.Group - * @see http://edn.egret.com/cn/article/index/id/527 Data container - * @see http://edn.egret.com/cn/article/index/id/528 Array collection - * @defaultProperty dataProvider - * @includeExample extension/eui/components/DataGroupExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * DataGroup 类将数据项目转换为可视元素以进行显示。 - * 尽管此容器可以包含可视元素,但它通常仅用于包含作为子项的数据项目。 - * - * @see eui.Group - * @see http://edn.egret.com/cn/article/index/id/527 数据容器 - * @see http://edn.egret.com/cn/article/index/id/528 数组集合 - * @defaultProperty dataProvider - * @includeExample extension/eui/components/DataGroupExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var DataGroup = (function (_super) { - __extends(DataGroup, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function DataGroup() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$dataProviderChanged = false; - /** - * @private - */ - _this.$dataProvider = null; - /** - * @private - * 索引到项呈示器的转换数组 - */ - _this.$indexToRenderer = []; - _this.$DataGroup = { - 0: true, - 1: false, - 2: {}, - 3: {}, - 4: false, - 5: false, - 6: null, - 7: null, - 8: false, - 9: null, - 10: false, - 11: false, - 12: null, - 13: null, - 14: false, - }; - return _this; - } - Object.defineProperty(DataGroup.prototype, "useVirtualLayout", { - /** - * @copy eui.LayoutBase#useVirtualLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - return this.$layout ? this.$layout.$useVirtualLayout : - this.$DataGroup[0 /* useVirtualLayout */]; - }, - set: function (value) { - value = !!value; - var values = this.$DataGroup; - if (value === values[0 /* useVirtualLayout */]) - return; - values[0 /* useVirtualLayout */] = value; - if (this.$layout) - this.$layout.useVirtualLayout = value; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - DataGroup.prototype.$setLayout = function (value) { - if (value == this.$layout) - return false; - if (this.$layout) { - this.$layout.setTypicalSize(0, 0); - this.$layout.removeEventListener("useVirtualLayoutChanged", this.onUseVirtualLayoutChanged, this); - } - if (this.$layout && value && (this.$layout.$useVirtualLayout != value.$useVirtualLayout)) - this.onUseVirtualLayoutChanged(); - var result = _super.prototype.$setLayout.call(this, value); - if (value) { - var rect = this.$DataGroup[9 /* typicalLayoutRect */]; - if (rect) { - value.setTypicalSize(rect.width, rect.height); - } - value.useVirtualLayout = this.$DataGroup[0 /* useVirtualLayout */]; - value.addEventListener("useVirtualLayoutChanged", this.onUseVirtualLayoutChanged, this); - } - return result; - }; - /** - * @private - * 是否使用虚拟布局标记改变 - */ - DataGroup.prototype.onUseVirtualLayoutChanged = function (event) { - var values = this.$DataGroup; - values[1 /* useVirtualLayoutChanged */] = true; - values[10 /* cleanFreeRenderer */] = true; - this.removeDataProviderListener(); - this.invalidateProperties(); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - DataGroup.prototype.setVirtualElementIndicesInView = function (startIndex, endIndex) { - if (!this.$layout || !this.$layout.$useVirtualLayout) { - return; - } - var indexToRenderer = this.$indexToRenderer; - var keys = Object.keys(indexToRenderer); - var length = keys.length; - for (var i = 0; i < length; i++) { - var index = +keys[i]; - if (index < startIndex || index > endIndex) { - this.freeRendererByIndex(index); - } - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - DataGroup.prototype.getElementAt = function (index) { - return this.$indexToRenderer[index]; - }; - /** - * @inheritDoc - * - * @version Egret 2.5.2 - * @version eui 1.0 - * @platform Web,Native - */ - DataGroup.prototype.getVirtualElementAt = function (index) { - index = +index | 0; - if (index < 0 || index >= this.$dataProvider.length) - return null; - var renderer = this.$indexToRenderer[index]; - if (!renderer) { - var item = this.$dataProvider.getItemAt(index); - renderer = this.createVirtualRenderer(item); - this.$indexToRenderer[index] = renderer; - this.updateRenderer(renderer, index, item); - var values = this.$DataGroup; - if (values[4 /* createNewRendererFlag */]) { - renderer.validateNow(); - values[4 /* createNewRendererFlag */] = false; - this.rendererAdded(renderer, index, item); - } - } - return renderer; - }; - /** - * @private - * 释放指定索引处的项呈示器 - */ - DataGroup.prototype.freeRendererByIndex = function (index) { - var renderer = this.$indexToRenderer[index]; - if (renderer) { - delete this.$indexToRenderer[index]; - this.doFreeRenderer(renderer); - } - }; - /** - * @private - * - * @param renderer - */ - DataGroup.prototype.doFreeRenderer = function (renderer) { - var values = this.$DataGroup; - var rendererClass = values[2 /* rendererToClassMap */][renderer.$hashCode]; - var hashCode = rendererClass.$hashCode; - if (!values[3 /* freeRenderers */][hashCode]) { - values[3 /* freeRenderers */][hashCode] = []; - } - values[3 /* freeRenderers */][hashCode].push(renderer); - renderer.visible = false; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - DataGroup.prototype.invalidateSize = function () { - if (!this.$DataGroup[4 /* createNewRendererFlag */]) { - _super.prototype.invalidateSize.call(this); - } - }; - /** - * @private - * 为指定索引创建虚拟的项呈示器 - */ - DataGroup.prototype.createVirtualRenderer = function (item) { - var renderer; - var rendererClass = this.itemToRendererClass(item); - var hashCode = rendererClass.$hashCode; - var values = this.$DataGroup; - var freeRenderers = values[3 /* freeRenderers */]; - if (freeRenderers[hashCode] && freeRenderers[hashCode].length > 0) { - renderer = freeRenderers[hashCode].pop(); - renderer.visible = true; - this.invalidateDisplayList(); - return renderer; - } - values[4 /* createNewRendererFlag */] = true; - return this.createOneRenderer(rendererClass); - }; - /** - * @private - * 根据rendererClass创建一个Renderer,并添加到显示列表 - */ - DataGroup.prototype.createOneRenderer = function (rendererClass) { - var renderer = (new rendererClass()); - var values = this.$DataGroup; - values[2 /* rendererToClassMap */][renderer.$hashCode] = rendererClass; - if (!egret.is(renderer, "eui.IItemRenderer")) { - return null; - } - if (values[13 /* itemRendererSkinName */]) { - this.setItemRenderSkinName(renderer, values[13 /* itemRendererSkinName */]); - } - this.addChild(renderer); - return renderer; - }; - /** - * @private - * 设置项呈示器的默认皮肤 - */ - DataGroup.prototype.setItemRenderSkinName = function (renderer, skinName) { - if (renderer && renderer instanceof eui.Component) { - var comp = renderer; - if (!comp.$Component[5 /* skinNameExplicitlySet */]) { - comp.skinName = skinName; - comp.$Component[5 /* skinNameExplicitlySet */] = false; - } - } - }; - Object.defineProperty(DataGroup.prototype, "dataProvider", { - /** - * The data provider for this DataGroup. - * It must be an ICollection, such as ArrayCollection - * - * @see eui.ICollection - * @see eui.ArrayCollection - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 列表数据源,请使用实现了ICollection接口的数据类型,例如 ArrayCollection - * - * @see eui.ICollection - * @see eui.ArrayCollection - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$dataProvider; - }, - set: function (value) { - this.$setDataProvider(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - DataGroup.prototype.$setDataProvider = function (value) { - if (this.$dataProvider == value || (value && !value.getItemAt)) - return false; - this.removeDataProviderListener(); - this.$dataProvider = value; - this.$dataProviderChanged = true; - this.$DataGroup[10 /* cleanFreeRenderer */] = true; - this.invalidateProperties(); - this.invalidateSize(); - this.invalidateDisplayList(); - return true; - }; - /** - * @private - * 移除数据源监听 - */ - DataGroup.prototype.removeDataProviderListener = function () { - if (this.$dataProvider) - this.$dataProvider.removeEventListener(eui.CollectionEvent.COLLECTION_CHANGE, this.onCollectionChange, this); - }; - /** - * Called when contents within the dataProvider changes. We will catch certain - * events and update our children based on that. - * - * @param event 事件eui.CollectionEvent的对象。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据源改变事件处理。 - * - * @param event 事件eui.CollectionEvent的对象。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - DataGroup.prototype.onCollectionChange = function (event) { - switch (event.kind) { - case eui.CollectionEventKind.ADD: - this.itemAddedHandler(event.items, event.location); - break; - case eui.CollectionEventKind.REMOVE: - this.itemRemovedHandler(event.items, event.location); - break; - case eui.CollectionEventKind.UPDATE: - case eui.CollectionEventKind.REPLACE: - this.itemUpdatedHandler(event.items[0], event.location); - break; - case eui.CollectionEventKind.RESET: - case eui.CollectionEventKind.REFRESH: { - if (this.$layout && this.$layout.$useVirtualLayout) { - var indexToRenderer = this.$indexToRenderer; - var keys = Object.keys(indexToRenderer); - var length_9 = keys.length; - for (var i = length_9 - 1; i >= 0; i--) { - var index = +keys[i]; - this.freeRendererByIndex(index); - } - } - this.$dataProviderChanged = true; - this.invalidateProperties(); - break; - } - default: { - egret.$warn(2204, event.kind); - break; - } - } - this.invalidateSize(); - this.invalidateDisplayList(); - }; - /** - * @private - * 数据源添加项目事件处理 - */ - DataGroup.prototype.itemAddedHandler = function (items, index) { - var length = items.length; - for (var i = 0; i < length; i++) { - this.itemAdded(items[i], index + i); - } - this.resetRenderersIndices(); - }; - /** - * @private - * 数据源移除项目事件处理 - */ - DataGroup.prototype.itemRemovedHandler = function (items, location) { - var length = items.length; - for (var i = length - 1; i >= 0; i--) { - this.itemRemoved(items[i], location + i); - } - this.resetRenderersIndices(); - }; - /** - * Adds the item for the specified dataProvider item to this DataGroup. - * - * This method is called as needed by the DataGroup implementation, - * it should not be called directly. - * - * @param item The item that was added, the value of dataProvider[index]. - * @param index The index where the dataProvider item was added. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 添加一个指定的数据到数据源。 - * - * 这个方法不应该由开发者直接调用,而用于本类自动内调用。 - * - * @param item 添加的数据项。 - * @param index 被添加到的索引。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - DataGroup.prototype.itemAdded = function (item, index) { - if (this.$layout) - this.$layout.elementAdded(index); - if (this.$layout && this.$layout.$useVirtualLayout) { - this.$indexToRenderer.splice(index, 0, null); - return; - } - var renderer = this.createVirtualRenderer(item); - this.$indexToRenderer.splice(index, 0, renderer); - if (renderer) { - this.updateRenderer(renderer, index, item); - var values = this.$DataGroup; - if (values[4 /* createNewRendererFlag */]) { - values[4 /* createNewRendererFlag */] = false; - this.rendererAdded(renderer, index, item); - } - } - }; - /** - * Removes the itemRenderer for the specified dataProvider item from this DataGroup. - * - * This method is called as needed by the DataGroup implementation, - * it should not be called directly. - * - * @param item The item that is being removed. - * @param index The index of the item that is being removed. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 删除数据源中指定的项。 - * - * 这个方法不应该由开发者直接调用,而用于本类自动内调用。 - * - * @param item 移除的数据项。 - * @param index 被移除的索引。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - DataGroup.prototype.itemRemoved = function (item, index) { - if (this.$layout) - this.$layout.elementRemoved(index); - var oldRenderer = this.$indexToRenderer[index]; - if (this.$indexToRenderer.length > index) - this.$indexToRenderer.splice(index, 1); - if (oldRenderer) { - if (this.$layout && this.$layout.$useVirtualLayout) { - this.doFreeRenderer(oldRenderer); - } - else { - this.rendererRemoved(oldRenderer, index, item); - this.removeChild(oldRenderer); - } - } - }; - /** - * @private - * 更新当前所有项的索引 - */ - DataGroup.prototype.resetRenderersIndices = function () { - var indexToRenderer = this.$indexToRenderer; - if (indexToRenderer.length == 0) - return; - if (this.$layout && this.$layout.$useVirtualLayout) { - var keys = Object.keys(indexToRenderer); - var length_10 = keys.length; - for (var i = 0; i < length_10; i++) { - var index = +keys[i]; - this.resetRendererItemIndex(index); - } - } - else { - var indexToRendererLength = indexToRenderer.length; - for (var index = 0; index < indexToRendererLength; index++) { - this.resetRendererItemIndex(index); - } - } - }; - /** - * @private - * 数据源更新或替换项目事件处理 - */ - DataGroup.prototype.itemUpdatedHandler = function (item, location) { - if (this.$DataGroup[11 /* renderersBeingUpdated */]) { - return; //防止无限循环 - } - var renderer = this.$indexToRenderer[location]; - if (renderer) - this.updateRenderer(renderer, location, item); - }; - /** - * @private - * 调整指定项呈示器的索引值 - */ - DataGroup.prototype.resetRendererItemIndex = function (index) { - var renderer = this.$indexToRenderer[index]; - if (renderer) - renderer.itemIndex = index; - }; - Object.defineProperty(DataGroup.prototype, "itemRenderer", { - /** - * The item renderer to use for data items. - * The class must implement the IItemRenderer interface. - * If defined, the itemRendererFunction property - * takes precedence over this property. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 用于数据项目的项呈示器。您应该直接为此属性赋值自定义类的类定义,而不是一个实例。注意:该类必须实现 IItemRenderer 接口。
      - * rendererClass获取顺序:itemRendererFunction > itemRenderer > 默认ItemRenerer。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$DataGroup[6 /* itemRenderer */]; - }, - set: function (value) { - var values = this.$DataGroup; - if (values[6 /* itemRenderer */] == value) - return; - values[6 /* itemRenderer */] = value; - values[5 /* itemRendererChanged */] = true; - values[8 /* typicalItemChanged */] = true; - values[10 /* cleanFreeRenderer */] = true; - this.removeDataProviderListener(); - this.invalidateProperties(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DataGroup.prototype, "itemRendererSkinName", { - /** - * The skinName property of the itemRenderer.This property will be passed to itemRenderer.skinName as default value,if you - * did not set it explicitly.
      - * Note: This property is invalid if the itemRenderer is not a subclass of the Component class. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 条目渲染器的可选皮肤标识符。在实例化itemRenderer时,若其内部没有设置过skinName,则将此属性的值赋值给它的skinName。 - * 注意:若 itemRenderer 不是 Component 的子类,则此属性无效。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$DataGroup[13 /* itemRendererSkinName */]; - }, - set: function (value) { - var values = this.$DataGroup; - if (values[13 /* itemRendererSkinName */] == value) - return; - values[13 /* itemRendererSkinName */] = value; - if (this.$UIComponent[29 /* initialized */]) { - values[14 /* itemRendererSkinNameChange */] = true; - this.invalidateProperties(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DataGroup.prototype, "itemRendererFunction", { - /** - * Function that returns an item renderer for a - * specific item. - * - * If defined, this property - * takes precedence over the itemRenderer property. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 为某个特定数据项返回一个项呈示器类定义的函数。 - * rendererClass获取顺序:itemRendererFunction > itemRenderer > 默认ItemRenerer。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$DataGroup[7 /* itemRendererFunction */]; - }, - set: function (value) { - var values = this.$DataGroup; - if (values[7 /* itemRendererFunction */] == value) - return; - values[7 /* itemRendererFunction */] = value; - values[5 /* itemRendererChanged */] = true; - values[8 /* typicalItemChanged */] = true; - this.removeDataProviderListener(); - this.invalidateProperties(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 为特定的数据项返回项呈示器的工厂实例 - */ - DataGroup.prototype.itemToRendererClass = function (item) { - var rendererClass; - var values = this.$DataGroup; - if (values[7 /* itemRendererFunction */]) { - rendererClass = values[7 /* itemRendererFunction */](item); - } - if (!rendererClass) { - rendererClass = values[6 /* itemRenderer */]; - } - if (!rendererClass) { - rendererClass = eui.ItemRenderer; - } - if (!rendererClass.$hashCode) { - rendererClass.$hashCode = egret.$hashCount++; - } - return rendererClass; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - DataGroup.prototype.createChildren = function () { - if (!this.$layout) { - var layout = new eui.VerticalLayout(); - layout.gap = 0; - layout.horizontalAlign = eui.JustifyAlign.CONTENT_JUSTIFY; - this.$setLayout(layout); - } - _super.prototype.createChildren.call(this); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - DataGroup.prototype.commitProperties = function () { - var values = this.$DataGroup; - if (values[5 /* itemRendererChanged */] || this.$dataProviderChanged || values[1 /* useVirtualLayoutChanged */]) { - this.removeAllRenderers(); - if (this.$layout) - this.$layout.clearVirtualLayoutCache(); - this.setTypicalLayoutRect(null); - values[1 /* useVirtualLayoutChanged */] = false; - values[5 /* itemRendererChanged */] = false; - if (this.$dataProvider) - this.$dataProvider.addEventListener(eui.CollectionEvent.COLLECTION_CHANGE, this.onCollectionChange, this); - if (this.$layout && this.$layout.$useVirtualLayout) { - this.invalidateSize(); - this.invalidateDisplayList(); - } - else { - this.createRenderers(); - } - if (this.$dataProviderChanged) { - this.$dataProviderChanged = false; - this.scrollV = this.scrollH = 0; - } - } - _super.prototype.commitProperties.call(this); - if (values[8 /* typicalItemChanged */]) { - values[8 /* typicalItemChanged */] = false; - if (this.$dataProvider && this.$dataProvider.length > 0) { - values[12 /* typicalItem */] = this.$dataProvider.getItemAt(0); - this.measureRendererSize(); - } - } - if (values[14 /* itemRendererSkinNameChange */]) { - values[14 /* itemRendererSkinNameChange */] = false; - var skinName = values[13 /* itemRendererSkinName */]; - var indexToRenderer = this.$indexToRenderer; - var keys = Object.keys(indexToRenderer); - var length_11 = keys.length; - for (var i = 0; i < length_11; i++) { - var index = keys[i]; - this.setItemRenderSkinName(indexToRenderer[index], skinName); - } - var freeRenderers = values[3 /* freeRenderers */]; - keys = Object.keys(freeRenderers); - length_11 = keys.length; - for (var i = 0; i < length_11; i++) { - var hashCode = keys[i]; - var list = freeRenderers[hashCode]; - var length_12 = list.length; - for (var i_1 = 0; i_1 < length_12; i_1++) { - this.setItemRenderSkinName(list[i_1], skinName); - } - } - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - DataGroup.prototype.measure = function () { - if (this.$layout && this.$layout.$useVirtualLayout) { - this.ensureTypicalLayoutElement(); - } - _super.prototype.measure.call(this); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - DataGroup.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - var useVirtualLayout = (this.$layout && this.$layout.$useVirtualLayout); - if (useVirtualLayout) { - this.ensureTypicalLayoutElement(); - } - _super.prototype.updateDisplayList.call(this, unscaledWidth, unscaledHeight); - var values = this.$DataGroup; - if (useVirtualLayout) { - //检查索引 0 处的项测量大小是否发生改变,若改变就重新计算 typicalLayoutRect - var rect = values[9 /* typicalLayoutRect */]; - if (rect) { - var renderer = this.$indexToRenderer[0]; - if (renderer) { - var bounds = egret.$TempRectangle; - renderer.getPreferredBounds(bounds); - if (bounds.width != rect.width || bounds.height != rect.height) { - values[9 /* typicalLayoutRect */] = null; - } - } - } - } - }; - /** - * @private - * 确保测量过默认条目大小。 - */ - DataGroup.prototype.ensureTypicalLayoutElement = function () { - if (this.$DataGroup[9 /* typicalLayoutRect */]) - return; - if (this.$dataProvider && this.$dataProvider.length > 0) { - this.$DataGroup[12 /* typicalItem */] = this.$dataProvider.getItemAt(0); - this.measureRendererSize(); - } - }; - /** - * @private - * 测量项呈示器默认尺寸 - */ - DataGroup.prototype.measureRendererSize = function () { - var values = this.$DataGroup; - if (values[12 /* typicalItem */] == undefined) { - this.setTypicalLayoutRect(null); - return; - } - var typicalRenderer = this.createVirtualRenderer(values[12 /* typicalItem */]); - if (!typicalRenderer) { - this.setTypicalLayoutRect(null); - return; - } - this.updateRenderer(typicalRenderer, 0, values[12 /* typicalItem */]); - typicalRenderer.validateNow(); - var bounds = egret.$TempRectangle; - typicalRenderer.getPreferredBounds(bounds); - var rect = new egret.Rectangle(0, 0, bounds.width, bounds.height); - if (this.$layout && this.$layout.$useVirtualLayout) { - if (values[4 /* createNewRendererFlag */]) { - this.rendererAdded(typicalRenderer, 0, values[12 /* typicalItem */]); - } - this.doFreeRenderer(typicalRenderer); - } - else { - this.removeChild(typicalRenderer); - } - this.setTypicalLayoutRect(rect); - values[4 /* createNewRendererFlag */] = false; - }; - /** - * @private - * 设置项目默认大小 - */ - DataGroup.prototype.setTypicalLayoutRect = function (rect) { - this.$DataGroup[9 /* typicalLayoutRect */] = rect; - if (this.$layout) { - if (rect) { - this.$layout.setTypicalSize(rect.width, rect.height); - } - else { - this.$layout.setTypicalSize(0, 0); - } - } - }; - /** - * @private - * 移除所有项呈示器 - */ - DataGroup.prototype.removeAllRenderers = function () { - var indexToRenderer = this.$indexToRenderer; - var keys = Object.keys(indexToRenderer); - var length = keys.length; - for (var i = 0; i < length; i++) { - var index = keys[i]; - var renderer = indexToRenderer[index]; - if (renderer) { - this.rendererRemoved(renderer, renderer.itemIndex, renderer.data); - this.removeChild(renderer); - } - } - this.$indexToRenderer = []; - var values = this.$DataGroup; - if (values[10 /* cleanFreeRenderer */]) { - var freeRenderers = values[3 /* freeRenderers */]; - var keys_1 = Object.keys(freeRenderers); - var length_13 = keys_1.length; - for (var i = 0; i < length_13; i++) { - var hashCode = keys_1[i]; - var list = freeRenderers[hashCode]; - var length_14 = list.length; - for (var i_2 = 0; i_2 < length_14; i_2++) { - var renderer = list[i_2]; - this.rendererRemoved(renderer, renderer.itemIndex, renderer.data); - this.removeChild(renderer); - } - } - values[3 /* freeRenderers */] = {}; - values[2 /* rendererToClassMap */] = {}; - values[10 /* cleanFreeRenderer */] = false; - } - }; - /** - * @private - * 为数据项创建项呈示器 - */ - DataGroup.prototype.createRenderers = function () { - if (!this.$dataProvider) - return; - var index = 0; - var length = this.$dataProvider.length; - for (var i = 0; i < length; i++) { - var item = this.$dataProvider.getItemAt(i); - var rendererClass = this.itemToRendererClass(item); - var renderer = this.createOneRenderer(rendererClass); - if (!renderer) - continue; - this.$indexToRenderer[index] = renderer; - this.updateRenderer(renderer, index, item); - this.rendererAdded(renderer, index, item); - index++; - } - }; - /** - * Updates the renderer for reuse. - * This method first prepares the item - * renderer for reuse by cleaning out any stale properties - * as well as updating it with new properties.

      - * - * The last thing this method should do is set the data property - * of the item renderer. - * - * @param renderer The item renderer. - * @param itemIndex The index of the data in the data provider. - * @param data The data object this item renderer is representing. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此方法首先会准备项呈示器以重用,方法是清除任何旧属性,同时使用新属性进行更新。

      - * - * 最后,此方法应对项呈示器设置 data 属性。 - * - * @param renderer 项呈示器。 - * @param itemIndex 数据提供程序中的数据索引。 - * @param data 此项呈示器正在表示的数据对象。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - DataGroup.prototype.updateRenderer = function (renderer, itemIndex, data) { - var values = this.$DataGroup; - values[11 /* renderersBeingUpdated */] = true; - renderer.itemIndex = itemIndex; - if (renderer.parent == this) { - this.setChildIndex(renderer, itemIndex); - } - renderer.data = data; - values[11 /* renderersBeingUpdated */] = false; - return renderer; - }; - Object.defineProperty(DataGroup.prototype, "numElements", { - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - if (!this.$dataProvider) - return 0; - return this.$dataProvider.length; - }, - enumerable: true, - configurable: true - }); - /** - * Adds the itemRenderer for the specified dataProvider item to this DataGroup. - * - * This method is called as needed by the DataGroup implementation, - * it should not be called directly. - * - * @param renderer The renderer that was added. - * @param index The index where the dataProvider item was added. - * @param item The item that was added, the value of dataProvider[index]. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 项呈示器被添加. - * - * 这个方法不能直接调用,它是由该类自身自动调用的。 - * - * @param renderer 添加的项呈示器 - * @param index 项呈示器的索引 - * @param item 项呈示器对应的数据 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - DataGroup.prototype.rendererAdded = function (renderer, index, item) { - }; - /** - * Removes the itemRenderer for the specified dataProvider item from this DataGroup. - * - * This method is called as needed by the DataGroup implementation, - * it should not be called directly. - * - * @param renderer The renderer that is being removed. - * @param index The index of the item that is being removed. - * @param item The item that is being removed. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 项呈示器被移除。 - * 这个方法不能直接调用,它是由该类自身自动调用的。 - * - * @param renderer 移除的项呈示器 - * @param index 项呈示器的索引 - * @param item 项呈示器对应的数据 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - DataGroup.prototype.rendererRemoved = function (renderer, index, item) { - }; - return DataGroup; - }(eui.Group)); - eui.DataGroup = DataGroup; - __reflect(DataGroup.prototype, "eui.DataGroup"); - eui.registerProperty(DataGroup, "itemRenderer", "Class"); - eui.registerProperty(DataGroup, "itemRendererSkinName", "Class"); - eui.registerProperty(DataGroup, "dataProvider", "eui.ICollection", true); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The Button component is a commonly used rectangular button. - * The Button component looks like it can be pressed. - * The default skin has a text label and a icon display object. - * - * @event egret.TouchEvent.TOUCH_CANCEL canceled the touch - * - * @state up Button up state - * @state down Button down state - * @state disabled Button disabled state - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ButtonExample.ts - * @language en_US - */ - /** - * Button 组件是常用的矩形按钮。Button 组件看起来可以按压。默认外观具有一个文本标签和图标显示对象。 - * - * @event egret.TouchEvent.TOUCH_CANCEL 取消触摸事件 - * - * @state up 按钮弹起状态 - * @state down 按钮按下状态 - * @state disabled 按钮禁用状态 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ButtonExample.ts - * @language zh_CN - */ - var Button = (function (_super) { - __extends(Button, _super); - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个按钮实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function Button() { - var _this = _super.call(this) || this; - /** - * [SkinPart] A skin part that defines the label of the button. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart] 按钮上的文本标签。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.labelDisplay = null; - /** - * @private - */ - _this._label = ""; - /** - * [SkinPart] A skin part that defines an optional icon for the button. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart] 按钮上的图标显示对象。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.iconDisplay = null; - /** - * @private - */ - _this._icon = null; - /** - * @private - * 指示第一次分派 TouchEvent.TOUCH_BEGIN 时,触摸点是否在按钮上。 - */ - _this.touchCaptured = false; - _this.touchChildren = false; - _this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.onTouchBegin, _this); - return _this; - } - Object.defineProperty(Button.prototype, "label", { - /** - * Text to appear on the Button control. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要在按钮上显示的文本。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._label; - }, - set: function (value) { - this._label = value; - if (this.labelDisplay) { - this.labelDisplay.text = value; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Button.prototype, "icon", { - /** - * Icon to appear on the Button control. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要在按钮上显示的图标数据 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._icon; - }, - set: function (value) { - this._icon = value; - if (this.iconDisplay) { - this.iconDisplay.source = value; - } - }, - enumerable: true, - configurable: true - }); - /** - * This method handles the touchCancle events - * @param The egret.TouchEvent object. - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 解除触碰事件处理。 - * @param event 事件 egret.TouchEvent 的对象。 - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Button.prototype.onTouchCancle = function (event) { - var stage = event.$currentTarget; - stage.removeEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchCancle, this); - stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onStageTouchEnd, this); - this.touchCaptured = false; - this.invalidateState(); - }; - /** - * This method handles the touch events - * @param The egret.TouchEvent object. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触碰事件处理。 - * @param event 事件 egret.TouchEvent 的对象。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Button.prototype.onTouchBegin = function (event) { - this.$stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchCancle, this); - this.$stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onStageTouchEnd, this); - this.touchCaptured = true; - this.invalidateState(); - event.updateAfterEvent(); - }; - /** - * @private - * 舞台上触摸弹起事件 - */ - Button.prototype.onStageTouchEnd = function (event) { - var stage = event.$currentTarget; - stage.removeEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchCancle, this); - stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onStageTouchEnd, this); - if (this.contains(event.target)) { - this.buttonReleased(); - } - this.touchCaptured = false; - this.invalidateState(); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Button.prototype.getCurrentState = function () { - if (!this.enabled) - return "disabled"; - if (this.touchCaptured) - return "down"; - return "up"; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Button.prototype.partAdded = function (partName, instance) { - if (instance === this.labelDisplay) { - this.labelDisplay.text = this._label; - } - else if (instance == this.iconDisplay) { - this.iconDisplay.source = this._icon; - } - }; - /** - * This method is called when handling a egret.TouchEvent.TOUCH_END event - * when the user touches on the button. It is only called when the button - * is the target and when touchCaptured is true. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当在用户单击按钮之后处理 egret.TouchEvent.TOUCH_END 事件时,将调用此方法。 - * 仅当以按钮为目标,并且 touchCapturedtrue 时,才会调用此方法。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Button.prototype.buttonReleased = function () { - }; - return Button; - }(eui.Component)); - eui.Button = Button; - __reflect(Button.prototype, "eui.Button"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The Range class holds a value and an allowed range for that - * value, defined by minimum and maximum properties. - * - * The value property - * is always constrained to be between the current minimum and - * maximum, and the minimum, - * and maximum are always constrained - * to be in the proper numerical order, such that - * (minimum <= value <= maximum) is true. - * - * If the value of the snapInterval property is not 0, - * then the value property is also constrained to be a multiple of - * snapInterval. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/supportClasses/RangeExample.ts - * @language en_US - */ - /** - * 范围选取组件,该组件包含一个值和这个值所允许的最大最小约束范围。 - * - * value属性的值永远被限制于当前的minimum和 - * maximum之间,并且minimummaximum永远按照固定的顺序排列, - * 即(minimum <= value <= maximum) 为真。 - * - * 如果snapInterval属性的值不是0,那么value的值也会被snapInterval所约束。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/supportClasses/RangeExample.ts - * @language zh_CN - */ - var Range = (function (_super) { - __extends(Range, _super); - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Range 实例。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function Range() { - var _this = _super.call(this) || this; - _this.$Range = { - 0: 100, - 1: false, - 2: 0, - 3: false, - 4: 0, - 5: 0, - 6: false, - 7: 1, - 8: false, - 9: false, - }; - return _this; - } - Object.defineProperty(Range.prototype, "maximum", { - /** - * The maximum valid value.

      - * - * Changes to the value property are constrained - * by commitProperties() to be less than or equal to - * maximum with the nearestValidValue() method. - * - * @default 100 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 最大有效值。

      - * - * 规定value属性的值不能够超过的最大值。该修正过程 - * 将在nearestValidValue()方法中进行。 - * - * @default 100 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$Range[0 /* maximum */]; - }, - set: function (value) { - value = +value || 0; - var values = this.$Range; - if (value === values[0 /* maximum */]) - return; - values[0 /* maximum */] = value; - values[1 /* maxChanged */] = true; - this.invalidateProperties(); - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Range.prototype, "minimum", { - /** - * The minimum valid value.

      - * - * Changes to the value property are constrained - * by commitProperties() to be greater than or equal to - * minimum with the nearestValidValue() method. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 最小有效值

      - * - * 规定value属性的值不能够低于的最小值。该修正过程 - * 将在nearestValidValue()方法中进行。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$Range[2 /* minimum */]; - }, - set: function (value) { - value = +value || 0; - var values = this.$Range; - if (value === values[2 /* minimum */]) - return; - values[2 /* minimum */] = value; - values[3 /* minChanged */] = true; - this.invalidateProperties(); - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Range.prototype, "value", { - /** - * The current value for this range.

      - * - * Changes to the value property are constrained - * by commitProperties() to be greater than or equal to - * the minimum property, less than or equal to the maximum property, and a - * multiple of snapInterval with the nearestValidValue() - * method. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此范围的当前值。

      - * - * 改变的value属性将在commitProperties()方法中被minimum属性 - * 和minimum属性所限制。此修正过程将在nearestValidValue()方法中进行。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - var values = this.$Range; - return values[6 /* valueChanged */] ? - values[5 /* changedValue */] : values[4 /* value */]; - }, - set: function (newValue) { - newValue = +newValue || 0; - this.$setValue(newValue); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param newValue - */ - Range.prototype.$setValue = function (newValue) { - if (newValue === this.value) - return false; - var values = this.$Range; - values[5 /* changedValue */] = newValue; - values[6 /* valueChanged */] = true; - this.invalidateProperties(); - return true; - }; - Object.defineProperty(Range.prototype, "snapInterval", { - /** - * The snapInterval property controls the valid values of the value property. - * - * If nonzero, valid values are the sum of the minimum and integer multiples - * of this property, for all sums that are less than or equal to the maximum.

      - * - * For example, if minimum is 10, maximum is 20, and this property is 3, then the - * valid values of this Range are 10, 13, 16, 19, and 20.

      - * - * If the value of this property is zero, then valid values are only constrained - * to be between minimum and maximum inclusive. - * - * @default 1 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * snapInterval 属性定义 value 属性的有效值。 - * 如果为非零,则有效值为 minimum 与此属性的整数倍数之和,且小于或等于 maximum。

      - * - * 例如,如果 minimum 为 10,maximum 为 20,而此属性为 3,则可能的有效值为 10、13、16、19 和 20.

      - * - * 如果此属性的值为零,则仅会将有效值约束到介于 minimum 和 maximum 之间(包括两者)。 - * - * @default 1 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$Range[7 /* snapInterval */]; - }, - set: function (value) { - var values = this.$Range; - values[9 /* explicitSnapInterval */] = true; - value = +value || 0; - if (value === values[7 /* snapInterval */]) - return; - if (isNaN(value)) { - values[7 /* snapInterval */] = 1; - values[9 /* explicitSnapInterval */] = false; - } - else { - values[7 /* snapInterval */] = value; - } - values[8 /* snapIntervalChanged */] = true; - this.invalidateProperties(); - }, - enumerable: true, - configurable: true - }); - /** - * Processes the properties set on the component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 处理对组件设置的属性 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Range.prototype.commitProperties = function () { - _super.prototype.commitProperties.call(this); - var values = this.$Range; - if (values[2 /* minimum */] > values[0 /* maximum */]) { - if (!values[1 /* maxChanged */]) - values[2 /* minimum */] = values[0 /* maximum */]; - else - values[0 /* maximum */] = values[2 /* minimum */]; - } - if (values[6 /* valueChanged */] || values[1 /* maxChanged */] || - values[3 /* minChanged */] || values[8 /* snapIntervalChanged */]) { - var currentValue = values[6 /* valueChanged */] ? - values[5 /* changedValue */] : values[4 /* value */]; - values[6 /* valueChanged */] = false; - values[1 /* maxChanged */] = false; - values[3 /* minChanged */] = false; - values[8 /* snapIntervalChanged */] = false; - this.setValue(this.nearestValidValue(currentValue, values[7 /* snapInterval */])); - } - }; - /** - * @private - * 修正size到最接近snapInterval的整数倍 - */ - Range.prototype.nearestValidSize = function (size) { - var interval = this.snapInterval; - if (interval == 0) - return size; - var validSize = Math.round(size / interval) * interval; - return (Math.abs(validSize) < interval) ? interval : validSize; - }; - /** - * Returns the sum of the minimum with an integer multiple of interval that's - * closest to value, unless value is closer to the maximum limit, - * in which case the maximum is returned.

      - * - * If interval is equal to 0, the value is clipped to the minimum and maximum - * limits.

      - * - * The valid values for a range are defined by the sum of the minimum property - * with multiples of the interval and also defined to be less than or equal to the - * maximum property. - * The maximum need not be a multiple of snapInterval.

      - * - * For example, if minimum is equal to 1, maximum is equal to 6, - * and snapInterval is equal to 2, the valid - * values for the Range are 1, 3, 5, 6. - * - * Similarly, if minimum is equal to 2, maximum is equal to 9, - * and snapInterval is equal to 1.5, the valid - * values for the Range are 2, 3.5, 5, 6.5, 8, and 9. - * - * @param value The input value. - * @param interval The value of snapInterval or an integer multiple of snapInterval. - * @return The valid value that's closest to the input. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 minimum 与最接近 valueinterval 的整数倍数之和, - * 除非 value 接近最大值限制的时候会返回 maximum。

      - * - * 如果 interval 等于 0,则会将该值剪裁到限制的最小值和最大值。

      - * - * 范围的有效值由 minimum 属性与 interval 的倍数之和决定, - * 与此同时也要小于等于 maximum 属性。 - * 最大值不能是 snapInterval 属性的倍数。

      - * - * 例如,如果 minimum 等于 1,maximum 等于 6,且 snapInterval 等于 3, - * 则 Range 的有效值有 1、2、5、6。 - * - * 类似地,如果 minimum 等于 2,maximum 等于 9, - * 且 snapInterval 等于 1.5,则 Range 的有效值有 2、3.5、5、6.5、8 和 9。 - * - * - * @param value 输入值。 - * @param interval snapInterval 的值,或 snapInterval 的整数倍数。 - * @return 最近接输入值的有效值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Range.prototype.nearestValidValue = function (value, interval) { - var values = this.$Range; - if (interval == 0) - return Math.max(values[2 /* minimum */], Math.min(values[0 /* maximum */], value)); - var maxValue = values[0 /* maximum */] - values[2 /* minimum */]; - var scale = 1; - value -= values[2 /* minimum */]; - if (interval != Math.round(interval)) { - var parts = ((1 + interval).toString()).split("."); - scale = Math.pow(10, parts[1].length); - maxValue *= scale; - value = Math.round(value * scale); - interval = Math.round(interval * scale); - } - var lower = Math.max(0, Math.floor(value / interval) * interval); - var upper = Math.min(maxValue, Math.floor((value + interval) / interval) * interval); - var validValue = ((value - lower) >= ((upper - lower) / 2)) ? upper : lower; - return (validValue / scale) + values[2 /* minimum */]; - }; - /** - * Sets the current value for the value property.

      - * - * This method assumes that the caller has already used the nearestValidValue() method - * to constrain the value parameter - * - * @param value The new value of the value property. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置当前值。

      - * - * 此方法假定调用者已经使用了 nearestValidValue() 方法来约束 value 参数。 - * - * @param value value属性的新值 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Range.prototype.setValue = function (value) { - var values = this.$Range; - if (values[4 /* value */] === value) - return; - if (values[0 /* maximum */] > values[2 /* minimum */]) - values[4 /* value */] = Math.min(values[0 /* maximum */], Math.max(values[2 /* minimum */], value)); - else - values[4 /* value */] = value; - values[6 /* valueChanged */] = false; - this.invalidateDisplayList(); - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "value"); - }; - /** - * Draws the object and/or sizes and positions its children. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制对象和/或设置其子项的大小和位置 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Range.prototype.updateDisplayList = function (w, h) { - _super.prototype.updateDisplayList.call(this, w, h); - this.updateSkinDisplayList(); - }; - /** - * Update size and visible of skin parts.

      - * Subclasses override this method to update skin parts display based on minimum, maximum - * and value properties. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 更新皮肤部件(通常为滑块)的大小和可见性。

      - * 子类覆盖此方法以基于 minimum、maximum 和 value 属性更新滑块的大小、位置和可见性。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Range.prototype.updateSkinDisplayList = function () { - }; - return Range; - }(eui.Component)); - eui.Range = Range; - __reflect(Range.prototype, "eui.Range"); - eui.registerBindable(Range.prototype, "value"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The LayoutBase class defines the base class for all Spark layouts. - * To create a custom layout that works with the Spark containers, - * you must extend LayoutBase or one of its subclasses. - * - *

      Subclasses must implement the updateDisplayList() - * method, which positions and sizes the target GroupBase's elements, and - * the measure() method, which calculates the default - * size of the target.

      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 容器布局基类。若要创建使用 Group 容器的自定义布局,必须扩展 LayoutBase 或其子类之一。 - * - *

      子类必须实现 updateDisplayList() 方法 - * (定位 target Group 的子项并调整这些子项的大小)和 measure() 方法 - * (计算 target 的默认大小)。

      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var LayoutBase = (function (_super) { - __extends(LayoutBase, _super); - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function LayoutBase() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.$target = null; - /** - * @private - */ - _this.$useVirtualLayout = false; - /** - * @private - */ - _this.$typicalWidth = 71; - /** - * @private - */ - _this.$typicalHeight = 22; - return _this; - } - Object.defineProperty(LayoutBase.prototype, "target", { - /** - * The Group container whose elements are measured, sized and positioned - * by this layout. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此布局将测量其元素、调整其元素的大小并定位其元素的 Group 容器。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$target; - }, - set: function (value) { - if (this.$target === value) - return; - this.$target = value; - this.clearVirtualLayoutCache(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(LayoutBase.prototype, "useVirtualLayout", { - /** - * To configure a container to use virtual layout, set the useVirtualLayout property - * to true for the layout associated with the container. - * Only DataGroup with layout set to VerticalLayout, - * HorizontalLayout, or TileLayout supports virtual layout. - * Layout subclasses that do not support virtualization must prevent changing - * this property. - * - * @default false - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 若要配置容器使用虚拟布局,请为与容器关联的布局的 useVirtualLayout 属性设置为 true。 - * 只有布局设置为 VerticalLayout、HorizontalLayout 或 TileLayout 的 DataGroup 才支持虚拟布局。 - * 不支持虚拟化的布局子类必须禁止更改此属性。 - * - * @default false - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$useVirtualLayout; - }, - set: function (value) { - value = !!value; - if (this.$useVirtualLayout == value) - return; - this.$useVirtualLayout = value; - this.dispatchEventWith("useVirtualLayoutChanged"); - if (this.$useVirtualLayout && !value) - this.clearVirtualLayoutCache(); - if (this.target) - this.target.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - /** - * Set this size of a typical element - * - * @param width the height of element - * @param height the width of element - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置一个典型元素的大小 - * - * @param width 元素的宽 - * @param height 元素的高 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LayoutBase.prototype.setTypicalSize = function (width, height) { - width = +width || 71; - height = +height || 22; - if (width !== this.$typicalWidth || height !== this.$typicalHeight) { - this.$typicalWidth = width; - this.$typicalHeight = height; - if (this.$target) { - this.$target.invalidateSize(); - } - } - }; - /** - * Called when the verticalScrollPosition or - * horizontalScrollPosition properties change. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * verticalScrollPositionhorizontalScrollPosition - * 属性更改时调用。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LayoutBase.prototype.scrollPositionChanged = function () { - }; - /** - * When useVirtualLayout is true, - * this method can be used by the layout target - * to clear cached layout information when the target changes. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果 useVirtualLayouttrue, - * 则当布局目标改变时,布局目标可以使用此方法来清除已缓存布局信息。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LayoutBase.prototype.clearVirtualLayoutCache = function () { - }; - /** - * Called by the target after a layout element - * has been added and before the target's size and display list are - * validated. - * Layouts that cache per element state, like virtual layouts, can - * override this method to update their cache. - * - * @param index The index of the element that was added. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在已添加布局元素之后且在验证目标的大小和显示列表之前,由目标调用。 - * 按元素状态缓存的布局(比如虚拟布局)可以覆盖此方法以更新其缓存。 - * - * @param index 发生改变的子项索引 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LayoutBase.prototype.elementAdded = function (index) { - }; - /** - * This method must is called by the target after a layout element - * has been removed and before the target's size and display list are - * validated. - * Layouts that cache per element state, like virtual layouts, can - * override this method to update their cache. - * - * @param index The index of the element that was added. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * - * 必须在已删除布局元素之后且在验证目标的大小和显示列表之前,由目标调用此方法。 - * 按元素状态缓存的布局(比如虚拟布局)可以覆盖此方法以更新其缓存。 - * - * @param index 发生改变的子项索引 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LayoutBase.prototype.elementRemoved = function (index) { - }; - /** - * Return the indices of the element visible within this Group. - * - * @return The indices of the visible element. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此 Group 中可见的元素的索引。 - * - * @return 可见的元素的索引。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LayoutBase.prototype.getElementIndicesInView = function () { - return null; - }; - /** - * Measures the target's default size based on its content. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 基于目标的内容测量其默认大小 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LayoutBase.prototype.measure = function () { - }; - /** - * Sizes and positions the target's elements. - * - * @param unscaledWidth Specifies the width of the target, in pixels, - * in the targets's coordinates. - * - * @param unscaledHeight Specifies the height of the component, in pixels, - * in the target's coordinates. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 调整目标的元素的大小并定位这些元素。 - * - * @param unscaledWidth 指定目标在目标坐标中的宽度(以像素为单位)。 - * @param unscaledHeight 指定组件在目标坐标中的高度(以像素为单位)。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LayoutBase.prototype.updateDisplayList = function (width, height) { - }; - return LayoutBase; - }(egret.EventDispatcher)); - eui.LayoutBase = LayoutBase; - __reflect(LayoutBase.prototype, "eui.LayoutBase"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The ListBase class is the base class for list component. - * It can display items of list as vertical or horizontal such as SELECT of HTML. - * @event egret.Event.CHANGE Dispatched after the selection has changed. - * This event is dispatched when the user interacts with the control. - * @event egret.Event.CHANGING Dispatched when the selection is going to change. - * Calling the preventDefault() method - * on the event prevents the selection from changing.

      - * This event is dispatched when the user interacts with the control. - * - * @event eui.ItemTapEvent.ITEM_TAP dispatched when the user tap an item in the control. - * @event egret.TouchEvent.TOUCH_CANCEL canceled the touch - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * ListBase 是列表控件基类。可显示垂直或水平的项目列表。其功能与 HTML 中的 SELECT 表单元素的功能相似。 - * @event egret.Event.CHANGE 选中的索引已经发生改变,注意:此事件仅在索引改变是由用户触摸操作引起时才抛出。 - * @event egret.Event.CHANGING 选中的索引即将发生改变,可以通过调用事件对象的 preventDefault() 方法来阻止改变。

      - * 注意:此事件仅在索引改变是由用户触摸操作引起时才抛出。 - * - * @event eui.ItemTapEvent.ITEM_TAP 项呈示器单击事件。 - * @event egret.TouchEvent.TOUCH_CANCEL 取消触摸事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var ListBase = (function (_super) { - __extends(ListBase, _super); - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function ListBase() { - var _this = _super.call(this) || this; - _this.$ListBase = { - 0: false, - 1: false, - 2: -2, - 3: -1, - 4: false, - 5: undefined, - 6: false, - 7: null, - 8: false //touchCancle - }; - return _this; - } - Object.defineProperty(ListBase.prototype, "requireSelection", { - /** - * If true, a data item must always be selected in the control. - * If the value is true, the selectedIndex property - * is always set to a value between 0 and (dataProvider.length - 1). - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果为 true,则控件中必须含有选中的数据项目。 - * 如果该值为 true,则始终将 selectedIndex 属性设置为 0 和 (dataProvider.length - 1) 之间的一个值。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$ListBase[0 /* requireSelection */]; - }, - set: function (value) { - value = !!value; - var values = this.$ListBase; - if (value === values[0 /* requireSelection */]) { - return; - } - values[0 /* requireSelection */] = value; - if (value) { - values[1 /* requireSelectionChanged */] = true; - this.invalidateProperties(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ListBase.prototype, "selectedIndex", { - /** - * he 0-based index of the selected item, or -1 if no item is selected. - * Setting the selectedIndex property deselects the currently selected - * item and selects the data item at the specified index.

      - * - * The value is always between -1 and (dataProvider.length - 1). - * If items at a lower index than selectedIndex are - * removed from the component, the selected index is adjusted downward - * accordingly.

      - * - * If the selected item is removed, the selected index is set to:

      - * - *

        - *
      • -1 if requireSelection == false or there are no remaining items.
      • - *
      • 0 if requireSelection == true and there is at least one item.
      • - *

      - * - * When the user changes the selectedIndex property by interacting with the control, - * the control dispatches the change and changing events. - * When you change the value of the selectedIndex property programmatically, - * it does not dispatches the change and changing events.

      - * - * @default -1 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 选中项目的基于 0 的索引。 - * 或者如果未选中项目,则为-1。设置 selectedIndex 属性会取消选择当前选定的项目并选择指定索引位置的数据项目。

      - * - * 这个值会之中在-1到(dataProvider.length - 1)之间。如果从该组件中删除一个低于 - * selectedIndex的值,则selectedIndex也会相应的调节选定的索引。

      - * - * 如果删除的项为当前选中项,则该值会变为:

      - * - *

        - *
      • -1: 如果 requireSelection == false 或者已经没有剩余项目。
      • - *
      • 0: 如果 requireSelection == true 并且当前至少还有一个剩余项目。
      • - *

      - * 当用户通过与控件交互来更改 selectedIndex 属性时,此控件将分派 change 和 changing 事件。 - * 当以编程方式更改 selectedIndex 属性的值时,此控件不分派 change 和 changing 事件。 - * - * @default -1 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$getSelectedIndex(); - }, - set: function (value) { - value = +value | 0; - this.setSelectedIndex(value, false); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @returns - */ - ListBase.prototype.$getSelectedIndex = function () { - var values = this.$ListBase; - if (values[2 /* proposedSelectedIndex */] != ListBase.NO_PROPOSED_SELECTION) - return values[2 /* proposedSelectedIndex */]; - return values[3 /* selectedIndex */]; - }; - /** - * Used internally to specify whether the selectedIndex changed programmatically or due to - * user interaction. - * @param value the new index need to select. - * @param dispatchChangeEvent if true, the component will dispatch a "change" event if the - * value has changed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 由程序或者用户设置选中项。 - * @param value 索引值。 - * @param dispatchChangeEvent 当索引值发生改变,且该参数为true的时候,组件派发出一个“change”事件。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.setSelectedIndex = function (value, dispatchChangeEvent) { - if (value == this.selectedIndex) { - return; - } - var values = this.$ListBase; - if (dispatchChangeEvent) - values[4 /* dispatchChangeAfterSelection */] = - (values[4 /* dispatchChangeAfterSelection */] || dispatchChangeEvent); - values[2 /* proposedSelectedIndex */] = value; - this.invalidateProperties(); - }; - Object.defineProperty(ListBase.prototype, "selectedItem", { - /** - * The item that is currently selected. - * Setting this property deselects the currently selected - * item and selects the newly specified item.

      - * - * Setting selectedItem to an item that is not - * in this component results in no selection, - * and selectedItem being set to undefined.

      - * - * If the selected item is removed, the selected item is set to:

      - *

        - *
      • undefined if requireSelection == false - * or there are no remaining items.
      • - *
      • The first item if requireSelection = true - * and there is at least one item.
      • - *

      - * - * When the user changes the selectedItem property by interacting with the control, - * the control dispatches the change and changing events. - * When you change the value of the selectedIndex property programmatically, - * it does not dispatches the change and changing events.

      - * - * @default undefined - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当前已选中的项目。设置此属性会取消选中当前选定的项目并选择新指定的项目。

      - * - * 如果设置的selectedItem不在当前列表里那么selectedItem将被设置 - * 为undefined

      - * - * 如果选择项目被移除,那选择项会被设置为:

      - *

        - *
      • undefined: 如果 requireSelection == false - * 或者已经没有剩余项。
      • - *
      • 第一项: 当 requireSelection == true - * 并且列表中还至少存有一项.
      • - *

      - * - * 当用户通过与控件交互来更改 selectedItem 属性时,此控件将分派 change 和 changing 事件。 - * 当以编程方式更改 selectedItem 属性的值时,此控件不分派 change 和 changing 事件。

      - * - * @default undefined - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - var values = this.$ListBase; - if (values[5 /* pendingSelectedItem */] !== undefined) - return values[5 /* pendingSelectedItem */]; - var selectedIndex = this.$getSelectedIndex(); - if (selectedIndex == ListBase.NO_SELECTION || this.$dataProvider == null) - return undefined; - return this.$dataProvider.length > selectedIndex ? this.$dataProvider.getItemAt(selectedIndex) : undefined; - }, - set: function (value) { - this.setSelectedItem(value, false); - }, - enumerable: true, - configurable: true - }); - /** - * Used internally to specify whether the selectedItem changed programmatically or due to - * user interaction. - * @param value the new item need to select. - * @param dispatchChangeEvent if true, the component will dispatch a "change" event if the - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 由程序或用户设置选中项数据源。 - * @param value 要选中的项。 - * @param dispatchChangeEvent 当索引值发生改变,且该参数为true的时候,组件派发出一个“change”事件。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.setSelectedItem = function (value, dispatchChangeEvent) { - if (dispatchChangeEvent === void 0) { dispatchChangeEvent = false; } - if (this.selectedItem === value) - return; - var values = this.$ListBase; - if (dispatchChangeEvent) - values[4 /* dispatchChangeAfterSelection */] = - (values[4 /* dispatchChangeAfterSelection */] || dispatchChangeEvent); - values[5 /* pendingSelectedItem */] = value; - this.invalidateProperties(); - }; - /** - * Processes the properties set on the component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 处理对组件设置的属性 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.commitProperties = function () { - var dataProviderChanged = this.$dataProviderChanged; - _super.prototype.commitProperties.call(this); - var values = this.$ListBase; - var selectedIndex = this.$getSelectedIndex(); - var dataProvider = this.$dataProvider; - if (dataProviderChanged) { - if (selectedIndex >= 0 && dataProvider && selectedIndex < dataProvider.length) - this.itemSelected(selectedIndex, true); - else if (this.requireSelection) - values[2 /* proposedSelectedIndex */] = 0; - else - this.setSelectedIndex(-1, false); - } - if (values[1 /* requireSelectionChanged */]) { - values[1 /* requireSelectionChanged */] = false; - if (values[0 /* requireSelection */] && - selectedIndex == ListBase.NO_SELECTION && - dataProvider && - dataProvider.length > 0) { - values[2 /* proposedSelectedIndex */] = 0; - } - } - if (values[5 /* pendingSelectedItem */] !== undefined) { - if (dataProvider) - values[2 /* proposedSelectedIndex */] = - dataProvider.getItemIndex(values[5 /* pendingSelectedItem */]); - else - values[2 /* proposedSelectedIndex */] = ListBase.NO_SELECTION; - values[5 /* pendingSelectedItem */] = undefined; - } - var changedSelection = false; - if (values[2 /* proposedSelectedIndex */] != ListBase.NO_PROPOSED_SELECTION) - changedSelection = this.commitSelection(); - if (values[6 /* selectedIndexAdjusted */]) { - values[6 /* selectedIndexAdjusted */] = false; - if (!changedSelection) { - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "selectedIndex"); - } - } - }; - /** - * Updates an item renderer for use or reuse. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 更新项呈示器,以备使用或重用 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.updateRenderer = function (renderer, itemIndex, data) { - this.itemSelected(itemIndex, this.$isItemIndexSelected(itemIndex)); - return _super.prototype.updateRenderer.call(this, renderer, itemIndex, data); - }; - /** - * Called when an item is selected or deselected. - * Subclasses must override this method to display the selection. - * @param index The item index that was selected. - * @param selected true if the item is selected, - * and false if it is deselected. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 选中或取消选中项目时调用。子类必须覆盖此方法才可设置选中项。 - * @param index 已选中的项目索引。 - * @param selected true为选中,false取消选中 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.itemSelected = function (index, selected) { - var renderer = this.$indexToRenderer[index]; - if (renderer) { - renderer.selected = selected; - } - }; - /** - * @private - * 返回指定索引是否等于当前选中索引 - */ - ListBase.prototype.$isItemIndexSelected = function (index) { - return index == this.selectedIndex; - }; - /** - * The selection validation and commitment workhorse method. - * Called to commit the pending selected index. This method dispatches - * the "changing" event, and if the event is not cancelled, - * commits the selection change and then dispatches the "change" - * event. - * @param dispatchChangedEvents if dispatch a "changed" event. - * @return true if the selection was committed, or false if the selection - * was cancelled. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 提交选中项属性。该方法会派发一个“changing”事件,如果该事件没有被阻止, - * 该方法将会提交选择项病根据参数派发“change”事件。 - * @param dispatchChangedEvents 是否派发一个“changed”事件。 - * @return true 表示提交成功, false表示被取消 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.commitSelection = function (dispatchChangedEvents) { - if (dispatchChangedEvents === void 0) { dispatchChangedEvents = true; } - var dataProvider = this.$dataProvider; - var values = this.$ListBase; - var maxIndex = dataProvider ? dataProvider.length - 1 : -1; - var oldSelectedIndex = values[3 /* selectedIndex */]; - var tmpProposedIndex = values[2 /* proposedSelectedIndex */]; - if (tmpProposedIndex < ListBase.NO_SELECTION) - tmpProposedIndex = ListBase.NO_SELECTION; - if (tmpProposedIndex > maxIndex) - tmpProposedIndex = maxIndex; - if (values[0 /* requireSelection */] && tmpProposedIndex == ListBase.NO_SELECTION && - dataProvider && dataProvider.length > 0) { - values[2 /* proposedSelectedIndex */] = ListBase.NO_PROPOSED_SELECTION; - values[4 /* dispatchChangeAfterSelection */] = false; - return false; - } - if (values[4 /* dispatchChangeAfterSelection */]) { - var result = this.dispatchEventWith(egret.Event.CHANGING, false, true, true); - if (!result) { - this.itemSelected(values[2 /* proposedSelectedIndex */], false); - values[2 /* proposedSelectedIndex */] = ListBase.NO_PROPOSED_SELECTION; - values[4 /* dispatchChangeAfterSelection */] = false; - return false; - } - } - values[3 /* selectedIndex */] = tmpProposedIndex; - values[2 /* proposedSelectedIndex */] = ListBase.NO_PROPOSED_SELECTION; - if (oldSelectedIndex != ListBase.NO_SELECTION) - this.itemSelected(oldSelectedIndex, false); - if (values[3 /* selectedIndex */] != ListBase.NO_SELECTION) - this.itemSelected(values[3 /* selectedIndex */], true); - //子类若需要自身抛出Change事件,而不是在此处抛出,可以设置dispatchChangedEvents为false - if (dispatchChangedEvents) { - if (values[4 /* dispatchChangeAfterSelection */]) { - this.dispatchEventWith(egret.Event.CHANGE); - values[4 /* dispatchChangeAfterSelection */] = false; - } - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "selectedIndex"); - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "selectedItem"); - } - return true; - }; - /** - * Adjusts the selected index to account for items being added to or - * removed from this component. - * It does not dispatch a change event because the change did not - * occur as a direct result of user-interaction. Moreover, - * it does not dispatch a changing event - * or allow the cancellation of the selection. - * It also does not call the itemSelected() method, - * since the same item is selected; - * @param newIndex The new index. - * @param add true if an item was added to the component, - * and false if an item was removed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 仅调整选中索引值而不更新选中项,即在提交属性阶段itemSelected方法不会被调用,也不会触发changing和change事件。 - * @param newIndex 新索引。 - * @param add 如果已将项目添加到组件,则为true;如果已删除项目,则为false。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.adjustSelection = function (newIndex, add) { - if (add === void 0) { add = false; } - var values = this.$ListBase; - if (values[2 /* proposedSelectedIndex */] != ListBase.NO_PROPOSED_SELECTION) - values[2 /* proposedSelectedIndex */] = newIndex; - else - values[3 /* selectedIndex */] = newIndex; - values[6 /* selectedIndexAdjusted */] = true; - this.invalidateProperties(); - }; - /** - * Called when an item has been added to this component. Selection - * and caret related properties are adjusted accordingly. - * @param item The item being added. - * @param index The index of the item being added. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据项添加 - * @param item 被添加的项。 - * @param index 被添加的项的索引。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.itemAdded = function (item, index) { - _super.prototype.itemAdded.call(this, item, index); - var selectedIndex = this.$getSelectedIndex(); - if (selectedIndex == ListBase.NO_SELECTION) { - if (this.$ListBase[0 /* requireSelection */]) - this.adjustSelection(index, true); - } - else if (index <= selectedIndex) { - this.adjustSelection(selectedIndex + 1, true); - } - }; - /** - * Called when an item has been removed from this component. - * Selection and caret related properties are adjusted - * accordingly. - * @param item The item being removed. - * @param index The index of the item being removed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据项移除 - * @param item 被移除的项。 - * @param index 被移除的项的索引。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.itemRemoved = function (item, index) { - _super.prototype.itemRemoved.call(this, item, index); - if (this.selectedIndex == ListBase.NO_SELECTION) - return; - var selectedIndex = this.$getSelectedIndex(); - if (index == selectedIndex) { - if (this.requireSelection && this.$dataProvider && this.$dataProvider.length > 0) { - if (index == 0) { - this.$ListBase[2 /* proposedSelectedIndex */] = 0; - this.invalidateProperties(); - } - else - this.setSelectedIndex(0, false); - } - else - this.adjustSelection(-1, false); - } - else if (index < selectedIndex) { - this.adjustSelection(selectedIndex - 1, false); - } - }; - /** - * Event Listener of source data changed. - * @param The egret.gui.CollectionEvent object. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据源改变事件处理。 - * @param event 事件 egret.gui.CollectionEvent 的对象。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.onCollectionChange = function (event) { - _super.prototype.onCollectionChange.call(this, event); - if (event.kind == eui.CollectionEventKind.RESET) { - if (this.$dataProvider.length == 0) { - this.setSelectedIndex(ListBase.NO_SELECTION, false); - } - } - else if (event.kind == eui.CollectionEventKind.REFRESH) { - this.dataProviderRefreshed(); - } - }; - /** - * Default response to dataProvider refresh events: clear the selection and caret. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据源刷新时触发。此方法不从组件外部调用,仅用于编写自定义组件时,子类覆盖父类的此方法,以便在数据源发生改变时,自动执行一些额外的根据数据刷新视图的操作。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.dataProviderRefreshed = function () { - this.setSelectedIndex(ListBase.NO_SELECTION, false); - }; - /** - * Called when an item has been added to this component. - * @param renderer the renderer being added. - * @param index the index of renderer - * @param item the data of renderer - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 项呈示器被添加 - * @param renderer 添加的项呈示器 - * @param index 项呈示器的索引 - * @param item 项呈示器对应的数据 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.rendererAdded = function (renderer, index, item) { - renderer.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onRendererTouchBegin, this); - renderer.addEventListener(egret.TouchEvent.TOUCH_END, this.onRendererTouchEnd, this); - renderer.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onRendererTouchCancle, this); - }; - /** - * Called when an item has been removed to this component. - * @param renderer the renderer being removed. - * @param index the index of renderer. - * @param item the data of renderer. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 项呈示器被移除 - * @param renderer 移除的项呈示器 - * @param index 项呈示器的索引 - * @param item 项呈示器对应的数据 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.rendererRemoved = function (renderer, index, item) { - renderer.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onRendererTouchBegin, this); - renderer.removeEventListener(egret.TouchEvent.TOUCH_END, this.onRendererTouchEnd, this); - renderer.removeEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onRendererTouchCancle, this); - }; - /** - * Handles egret.TouchEvent.TOUCH_BEGIN events from any of the - * item renderers. This method handles egret.TouchEvent.TOUCH_END. - * @param event The egret.TouchEvent object. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 侦听项呈示器egret.TouchEvent.TOUCH_BEGIN事件的方法。同时会添加对舞台egret.TouchEvent.TOUCH_END - * 事件的侦听。 - * @param event 事件egret.TouchEvent的对象。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.onRendererTouchBegin = function (event) { - if (!this.$stage) { - return; - } - var values = this.$ListBase; - if (event.$isDefaultPrevented) - return; - values[8 /* touchCancle */] = false; - values[7 /* touchDownItemRenderer */] = (event.$currentTarget); - this.$stage.addEventListener(egret.TouchEvent.TOUCH_END, this.stage_touchEndHandler, this); - }; - /** - * Handles egret.TouchEvent.TOUCH_CANCEL events from any of the - * item renderers. This method will cancel the handles egret.TouchEvent.TOUCH_END and egret.TouchEvent.TOUCH_TAP. - * @param event The egret.TouchEvent object. - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 侦听项呈示器egret.TouchEvent.TOUCH_CANCEL事件的方法。触发时会取消对舞台egret.TouchEvent.TOUCH_END - * 和egret.TouchEvent.TOUCH_TAP事件的侦听。 - * @param event 事件egret.TouchEvent的对象。 - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.onRendererTouchCancle = function (event) { - var values = this.$ListBase; - values[7 /* touchDownItemRenderer */] = null; - values[8 /* touchCancle */] = true; - if (this.$stage) { - this.$stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.stage_touchEndHandler, this); - } - }; - /** - * Handles egret.TouchEvent.TOUCH_END events and dispatch ItemTapEvent.ITEM_TAP event. - * @param event The egret.TouchEvent object. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触摸在项呈示器上结束,抛出ItemTapEvent.ITEM_TAP事件。 - * @param event 事件egret.TouchEvent的对象。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.prototype.onRendererTouchEnd = function (event) { - var values = this.$ListBase; - var itemRenderer = (event.$currentTarget); - var touchDownItemRenderer = values[7 /* touchDownItemRenderer */]; - if (itemRenderer != touchDownItemRenderer) - return; - if (!values[8 /* touchCancle */]) { - this.setSelectedIndex(itemRenderer.itemIndex, true); - eui.ItemTapEvent.dispatchItemTapEvent(this, eui.ItemTapEvent.ITEM_TAP, itemRenderer); - } - values[8 /* touchCancle */] = false; - }; - /** - * @private - * 触摸在舞台上结束 - */ - ListBase.prototype.stage_touchEndHandler = function (event) { - var stage = event.$currentTarget; - stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.stage_touchEndHandler, this); - this.$ListBase[7 /* touchDownItemRenderer */] = null; - }; - /** - * Static constant representing the value "no selection". - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 未选中任何项时的索引值 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.NO_SELECTION = -1; - /** - * Static constant representing no proposed selection. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 未设置缓存选中项的值 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ListBase.NO_PROPOSED_SELECTION = -2; - return ListBase; - }(eui.DataGroup)); - eui.ListBase = ListBase; - __reflect(ListBase.prototype, "eui.ListBase"); - eui.registerBindable(ListBase.prototype, "selectedIndex"); - eui.registerBindable(ListBase.prototype, "selectedItem"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The ScrollBarBase class helps to position - * the portion of data that is displayed when there is too much data - * to fit in a display area. - * The ScrollBarBase class displays a pair of viewport and a thumb. - * viewport is a instance that implements IViewport. - * - * @see eui.IViewport - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * ScrollBarBase 滚动条基类,该类帮助在因数据太多而不能在显示区域完全显示时定位显示的数据部分。 - * ScrollBarBase 类显示视区的一部分和一个指示滑块。 - * 视区是一个IViewport接口实现的实例。 - * - * @see eui.IViewport - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var ScrollBarBase = (function (_super) { - __extends(ScrollBarBase, _super); - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个ScrollBarBase实例。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function ScrollBarBase() { - var _this = _super.call(this) || this; - /** - * [SkinPart] Thumb display object. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart]滑块显示对象。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.thumb = null; - /** - * @private - */ - _this.$viewport = null; - /** - * Whether the scrollbar can be autohide. - * @version Egret 3.0.2 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 是否自动隐藏 scrollbar - * @version Egret 3.0.2 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.autoVisibility = true; - return _this; - } - Object.defineProperty(ScrollBarBase.prototype, "viewport", { - /** - * The viewport controlled by this scrollbar. - * - * If a viewport is specified, then changes to its actual size, content - * size, and scroll position cause the corresponding ScrollBarBase methods to - * run: - *

        - *
      • onViewportResize()
      • - *
      • onPropertyChanged()
      • - *

      - * - * The VScrollBar and HScrollBar classes override these methods to keep their properties in - * sync with the viewport. - * - * @default null - * @see eui.VScrollBar - * @see eui.HScrollBar - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 由该滚动条控制的视区。 - * - * 如果指定了视区,则对其实际大小、内容大小和滚动位置的更改会导致运行相对应的 ScrollBarBase 方法: - *

        - *
      • onViewportResize()
      • - *
      • onPropertyChanged()
      • - *

      - * - * VScrollBar 和 HScrollBar 类需要重写这些方法以保证属性与视区的同步。 - * - * @default null - * @see eui.VScrollBar - * @see eui.HScrollBar - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$viewport; - }, - set: function (value) { - if (value == this.$viewport) { - return; - } - var viewport = this.$viewport; - if (viewport) { - viewport.removeEventListener(eui.PropertyEvent.PROPERTY_CHANGE, this.onPropertyChanged, this); - viewport.removeEventListener(egret.Event.RESIZE, this.onViewportResize, this); - } - this.$viewport = value; - if (value) { - value.addEventListener(eui.PropertyEvent.PROPERTY_CHANGE, this.onPropertyChanged, this); - value.addEventListener(egret.Event.RESIZE, this.onViewportResize, this); - } - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param event - */ - ScrollBarBase.prototype.onViewportResize = function (event) { - this.invalidateDisplayList(); - }; - /** - * Properties of viewport changed. - * @param event - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 视区属性发生改变。 - * @param event - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ScrollBarBase.prototype.onPropertyChanged = function (event) { - }; - return ScrollBarBase; - }(eui.Component)); - eui.ScrollBarBase = ScrollBarBase; - __reflect(ScrollBarBase.prototype, "eui.ScrollBarBase"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The SliderBase class lets users select a value by moving a slider thumb between - * the end points of the slider track. - * The current value of the slider is determined by the relative location of - * the thumb between the end points of the slider, - * corresponding to the slider's minimum and maximum values. - * The SliderBase class is a base class for HSlider and VSlider. - * - * @event eui.UIEvent.CHANGE_START Dispatched when the scroll position is going to change - * @event eui.UIEvent.CHANGE_END Dispatched when the scroll position changed complete - * @event egret.Event.CHANGE Dispatched when the scroll position is changing - * - * @see eui.HSlider - * @see eui.VSlider - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 滑块控件基类,通过使用 SliderBase 类,用户可以在滑块轨道的端点之间移动滑块来选择值。 - * 滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。 - * SliderBase 类是 HSlider 和 VSlider 的基类。 - * - * @event eui.UIEvent.CHANGE_START 滚动位置改变开始 - * @event eui.UIEvent.CHANGE_END 滚动位置改变结束 - * @event egret.Event.CHANGE 滚动位置改变的时候 - * - * @see eui.HSlider - * @see eui.VSlider - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var SliderBase = (function (_super) { - __extends(SliderBase, _super); - /** - * Constructor - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 SliderBase 实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function SliderBase() { - var _this = _super.call(this) || this; - /** - * [SkinPart] Highlight of track. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart] 轨道高亮显示对象。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.trackHighlight = null; - /** - * [SkinPart] Thumb display object. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart]滑块显示对象。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.thumb = null; - /** - * [SkinPart] Track display object. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * [SkinPart]轨道显示对象。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.track = null; - _this.$SliderBase = { - 0: 0, - 1: 0, - 2: 0, - 3: 0, - 4: null, - 5: null, - 6: 300, - 7: 0, - 8: 0, - 9: true, - }; - _this.maximum = 10; - _this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.onTouchBegin, _this); - return _this; - } - Object.defineProperty(SliderBase.prototype, "slideDuration", { - /** - * Duration in milliseconds for the sliding animation when you tap on the track to move a thumb. - * - * @default 300 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在轨道上单击以移动滑块时,滑动动画持续的时间(以毫秒为单位)。设置为0将不执行缓动。 - * - * @default 300 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$SliderBase[6 /* slideDuration */]; - }, - set: function (value) { - this.$SliderBase[6 /* slideDuration */] = +value || 0; - }, - enumerable: true, - configurable: true - }); - /** - * Converts a track-relative x,y pixel location into a value between - * the minimum and maximum, inclusive. - * - * @param x The x coordinate of the location relative to the track's origin. - * @param y The y coordinate of the location relative to the track's origin. - * @return A value between the minimum and maximum, inclusive. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 将相对于轨道的 x,y 像素位置转换为介于最小值和最大值(包括两者)之间的一个值。 - * - * @param x 相对于轨道原点的位置的x坐标。 - * @param y 相对于轨道原点的位置的y坐标。 - * @return 介于最小值和最大值(包括两者)之间的一个值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - SliderBase.prototype.pointToValue = function (x, y) { - return this.minimum; - }; - Object.defineProperty(SliderBase.prototype, "liveDragging", { - /** - * Specifies whether live dragging is enabled for the slider. If true, sets the value - * and values properties and dispatches the change event continuously as - * the user moves the thumb. - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果为 true,则将在沿着轨道拖动滑块时,而不是在释放滑块按钮时,提交此滑块的值。 - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$SliderBase[9 /* liveDragging */]; - }, - set: function (value) { - this.$SliderBase[9 /* liveDragging */] = !!value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SliderBase.prototype, "pendingValue", { - /** - * The value the slider will have when the touch is end. - * This property is updated when the slider thumb moves, even if liveDragging is false.

      - * If the liveDragging style is false, then the slider's value is only set - * when the touch is end. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触摸结束时滑块将具有的值。 - * 无论 liveDragging 是否为 true,在滑块拖动期间始终更新此属性。 - * 而 value 属性在当 liveDragging 为 false 时,只在触摸释放时更新一次。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$SliderBase[7 /* pendingValue */]; - }, - set: function (value) { - value = +value || 0; - var values = this.$SliderBase; - if (value === values[7 /* pendingValue */]) - return; - values[7 /* pendingValue */] = value; - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - SliderBase.prototype.setValue = function (value) { - this.$SliderBase[7 /* pendingValue */] = value; - _super.prototype.setValue.call(this, value); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - SliderBase.prototype.partAdded = function (partName, instance) { - _super.prototype.partAdded.call(this, partName, instance); - if (instance == this.thumb) { - this.thumb.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onThumbTouchBegin, this); - this.thumb.addEventListener(egret.Event.RESIZE, this.onTrackOrThumbResize, this); - } - else if (instance == this.track) { - this.track.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTrackTouchBegin, this); - this.track.addEventListener(egret.Event.RESIZE, this.onTrackOrThumbResize, this); - } - else if (instance === this.trackHighlight) { - this.trackHighlight.touchEnabled = false; - if (egret.is(this.trackHighlight, "egret.DisplayObjectContainer")) { - this.trackHighlight.touchChildren = false; - } - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - SliderBase.prototype.partRemoved = function (partName, instance) { - _super.prototype.partRemoved.call(this, partName, instance); - if (instance == this.thumb) { - this.thumb.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onThumbTouchBegin, this); - this.thumb.removeEventListener(egret.Event.RESIZE, this.onTrackOrThumbResize, this); - } - else if (instance == this.track) { - this.track.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTrackTouchBegin, this); - this.track.removeEventListener(egret.Event.RESIZE, this.onTrackOrThumbResize, this); - } - }; - /** - * @private - * 滑块或轨道尺寸改变事件 - */ - SliderBase.prototype.onTrackOrThumbResize = function (event) { - this.updateSkinDisplayList(); - }; - /** - * Handle touch-begin events on the scroll thumb. Records the touch begin point in clickOffset. - * - * @param The egret.TouchEvent object. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 滑块触摸开始事件,记录触碰开始的坐标偏移量。 - * - * @param event 事件 egret.TouchEvent 的对象. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - SliderBase.prototype.onThumbTouchBegin = function (event) { - var values = this.$SliderBase; - if (values[5 /* animation */] && values[5 /* animation */].isPlaying) - this.stopAnimation(); - var stage = this.$stage; - stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.onStageTouchMove, this); - stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onStageTouchEnd, this); - var clickOffset = this.thumb.globalToLocal(event.stageX, event.stageY, egret.$TempPoint); - values[0 /* clickOffsetX */] = clickOffset.x; - values[1 /* clickOffsetY */] = clickOffset.y; - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CHANGE_START); - }; - /** - * @private - * 舞台上触摸移动事件 - */ - SliderBase.prototype.onStageTouchMove = function (event) { - var values = this.$SliderBase; - values[2 /* moveStageX */] = event.$stageX; - values[3 /* moveStageY */] = event.$stageY; - var track = this.track; - if (!track) - return; - var p = track.globalToLocal(values[2 /* moveStageX */], values[3 /* moveStageY */], egret.$TempPoint); - var newValue = this.pointToValue(p.x - values[0 /* clickOffsetX */], p.y - values[1 /* clickOffsetY */]); - newValue = this.nearestValidValue(newValue, this.snapInterval); - this.updateWhenTouchMove(newValue); - event.updateAfterEvent(); - }; - /** - * Capture touch-move events anywhere on or off the stage. - * @param newValue new value - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 监听舞台的触碰移动事件。 - * @param newValue 新的值 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - SliderBase.prototype.updateWhenTouchMove = function (newValue) { - if (newValue != this.$SliderBase[7 /* pendingValue */]) { - if (this.liveDragging) { - this.setValue(newValue); - this.dispatchEventWith(egret.Event.CHANGE); - } - else { - this.pendingValue = newValue; - } - } - }; - /** - * Handle touch-end events anywhere on or off the stage. - * - * @param The egret.Event object. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触摸结束事件 - * - * @param event 事件 egret.Event 的对象。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - SliderBase.prototype.onStageTouchEnd = function (event) { - var stage = event.$currentTarget; - stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onStageTouchMove, this); - stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onStageTouchEnd, this); - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CHANGE_END); - var values = this.$SliderBase; - if (!this.liveDragging && this.value != values[7 /* pendingValue */]) { - this.setValue(values[7 /* pendingValue */]); - this.dispatchEventWith(egret.Event.CHANGE); - } - }; - /** - * @private - * 当在组件上按下时记录被按下的子显示对象 - */ - SliderBase.prototype.onTouchBegin = function (event) { - this.$stage.addEventListener(egret.TouchEvent.TOUCH_END, this.stageTouchEndHandler, this); - this.$SliderBase[4 /* touchDownTarget */] = (event.$target); - }; - /** - * @private - * 当结束时,若不是在 touchDownTarget 上弹起,而是另外的子显示对象上弹起时,额外抛出一个触摸单击事件。 - */ - SliderBase.prototype.stageTouchEndHandler = function (event) { - var target = event.$target; - var values = this.$SliderBase; - event.$currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END, this.stageTouchEndHandler, this); - if (values[4 /* touchDownTarget */] != target && this.contains((target))) { - egret.TouchEvent.dispatchTouchEvent(this, egret.TouchEvent.TOUCH_TAP, true, true, event.$stageX, event.$stageY, event.touchPointID); - } - values[4 /* touchDownTarget */] = null; - }; - /** - * @private - * 动画播放更新数值 - */ - SliderBase.prototype.$animationUpdateHandler = function (animation) { - this.pendingValue = animation.currentValue; - }; - /** - * @private - * 动画播放完毕 - */ - SliderBase.prototype.animationEndHandler = function (animation) { - this.setValue(this.$SliderBase[8 /* slideToValue */]); - this.dispatchEventWith(egret.Event.CHANGE); - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CHANGE_END); - }; - /** - * @private - * 停止播放动画 - */ - SliderBase.prototype.stopAnimation = function () { - this.$SliderBase[5 /* animation */].stop(); - this.setValue(this.nearestValidValue(this.pendingValue, this.snapInterval)); - this.dispatchEventWith(egret.Event.CHANGE); - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CHANGE_END); - }; - /** - * Handle touch-begin events for the slider track. We - * calculate the value based on the new position and then - * move the thumb to the correct location as well as - * commit the value. - * @param The egret.TouchEvent object. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 轨道的触碰开始事件。我们会在这里根据新的坐标位置计算value,然后移动滑块到当前位置。 - * - * @param event 事件 egret.TouchEvent 的对象. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - SliderBase.prototype.onTrackTouchBegin = function (event) { - var thumbW = this.thumb ? this.thumb.width : 0; - var thumbH = this.thumb ? this.thumb.height : 0; - var offsetX = event.$stageX - (thumbW / 2); - var offsetY = event.$stageY - (thumbH / 2); - var p = this.track.globalToLocal(offsetX, offsetY, egret.$TempPoint); - var rangeValues = this.$Range; - var newValue = this.pointToValue(p.x, p.y); - newValue = this.nearestValidValue(newValue, rangeValues[7 /* snapInterval */]); - var values = this.$SliderBase; - if (newValue != values[7 /* pendingValue */]) { - if (values[6 /* slideDuration */] != 0) { - if (!values[5 /* animation */]) { - values[5 /* animation */] = new eui.sys.Animation(this.$animationUpdateHandler, this); - values[5 /* animation */].endFunction = this.animationEndHandler; - } - var animation = values[5 /* animation */]; - if (animation.isPlaying) - this.stopAnimation(); - values[8 /* slideToValue */] = newValue; - animation.duration = values[6 /* slideDuration */] * - (Math.abs(values[7 /* pendingValue */] - values[8 /* slideToValue */]) / (rangeValues[0 /* maximum */] - rangeValues[2 /* minimum */])); - animation.from = values[7 /* pendingValue */]; - animation.to = values[8 /* slideToValue */]; - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CHANGE_START); - animation.play(); - } - else { - this.setValue(newValue); - this.dispatchEventWith(egret.Event.CHANGE); - } - } - }; - return SliderBase; - }(eui.Range)); - eui.SliderBase = SliderBase; - __reflect(SliderBase.prototype, "eui.SliderBase"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var sys; - (function (sys) { - var exmlParserPool = []; - var parsedClasses = {}; - var innerClassCount = 1; - var HOST_COMPONENT = "hostComponent"; - var SKIN_CLASS = "eui.Skin"; - var DECLARATIONS = "Declarations"; - var RECTANGLE = "egret.Rectangle"; - var TYPE_CLASS = "Class"; - var TYPE_ARRAY = "Array"; - var TYPE_PERCENTAGE = "Percentage"; - var TYPE_STATE = "State[]"; - var SKIN_NAME = "skinName"; - var ELEMENTS_CONTENT = "elementsContent"; - var basicTypes = [TYPE_ARRAY, "boolean", "string", "number"]; - var wingKeys = ["id", "locked", "includeIn", "excludeFrom"]; - var htmlEntities = [["<", "<"], [">", ">"], ["&", "&"], ["\"", """], ["'", "'"]]; - var jsKeyWords = ["null", "NaN", "undefined", "true", "false"]; - /** - * @private - */ - var EXMLParser = (function () { - /** - * @private - */ - function EXMLParser() { - /** - * @private - * 延迟赋值字典 - */ - this.delayAssignmentDic = {}; - if (true) { - this.repeatedIdMap = {}; - this.getRepeatedIds = getRepeatedIds; - this.getIds = getIds; - this.checkDeclarations = checkDeclarations; - } - } - /** - * @private - * 将已有javascript代码注册 - * @param codeText 执行的javascript代码 - * @param classStr 类名 - */ - EXMLParser.prototype.$parseCode = function (codeText, classStr) { - //传入的是编译后的js字符串 - var className = classStr ? classStr : "$exmlClass" + innerClassCount++; - var geval = eval; - var clazz = geval(codeText); - var hasClass = true; - if (hasClass && clazz) { - egret.registerClass(clazz, className); - var paths = className.split("."); - var length_15 = paths.length; - var definition = __global; - for (var i = 0; i < length_15 - 1; i++) { - var path = paths[i]; - definition = definition[path] || (definition[path] = {}); - } - if (definition[paths[length_15 - 1]]) { - if (true && !parsedClasses[className]) { - egret.$warn(2101, className, codeText); - } - } - else { - if (true) { - parsedClasses[className] = true; - } - definition[paths[length_15 - 1]] = clazz; - } - } - return clazz; - }; - /** - * @private - * 编译指定的XML对象为JavaScript代码。 - * @param xmlData 要编译的EXML文件内容 - * - */ - EXMLParser.prototype.parse = function (text) { - if (true) { - if (!text) { - egret.$error(1003, "text"); - } - } - var xmlData = null; - if (true) { - try { - xmlData = egret.XML.parse(text); - } - catch (e) { - egret.$error(2002, text + "\n" + e.message); - } - } - else { - xmlData = egret.XML.parse(text); - } - var hasClass = false; - var className = ""; - if (xmlData.attributes["class"]) { - className = xmlData.attributes["class"]; - delete xmlData.attributes["class"]; - hasClass = !!className; - } - else { - className = "$exmlClass" + innerClassCount++; - } - var exClass = this.parseClass(xmlData, className); - var code = exClass.toCode(); - var clazz = null; - var geval = eval; - if (true) { - try { - clazz = geval(code); - } - catch (e) { - egret.log(code); - return null; - } - } - else { - clazz = geval(code); - } - if (hasClass && clazz) { - egret.registerClass(clazz, className); - var paths = className.split("."); - var length_16 = paths.length; - var definition = __global; - for (var i = 0; i < length_16 - 1; i++) { - var path = paths[i]; - definition = definition[path] || (definition[path] = {}); - } - if (definition[paths[length_16 - 1]]) { - if (true && !parsedClasses[className]) { - egret.$warn(2101, className, toXMLString(xmlData)); - } - } - else { - if (true) { - parsedClasses[className] = true; - } - definition[paths[length_16 - 1]] = clazz; - } - } - return clazz; - }; - /** - * @private - * 编译指定的XML对象为CpClass对象。 - */ - EXMLParser.prototype.parseClass = function (xmlData, className) { - if (!sys.exmlConfig) { - sys.exmlConfig = new sys.EXMLConfig(); - } - this.currentXML = xmlData; - this.currentClassName = className; - this.delayAssignmentDic = {}; - this.idDic = {}; - this.stateCode = []; - this.stateNames = []; - this.skinParts = []; - this.bindings = []; - this.declarations = null; - this.currentClass = new sys.EXClass(); - this.stateIds = []; - var index = className.lastIndexOf("."); - if (index != -1) { - this.currentClass.className = className.substring(index + 1); - } - else { - this.currentClass.className = className; - } - this.startCompile(); - var clazz = this.currentClass; - this.currentClass = null; - return clazz; - }; - /** - * @private - * 开始编译 - */ - EXMLParser.prototype.startCompile = function () { - if (true) { - var result = this.getRepeatedIds(this.currentXML); - if (result.length > 0) { - egret.$error(2004, this.currentClassName, result.join("\n")); - } - } - var superClass = this.getClassNameOfNode(this.currentXML); - this.isSkinClass = (superClass == SKIN_CLASS); - this.currentClass.superClass = superClass; - this.getStateNames(); - var children = this.currentXML.children; - if (children) { - var length_17 = children.length; - for (var i = 0; i < length_17; i++) { - var node = children[i]; - if (node.nodeType === 1 && node.namespace == sys.NS_W && - node.localName == DECLARATIONS) { - this.declarations = node; - break; - } - } - } - if (true) { - var list = []; - this.checkDeclarations(this.declarations, list); - if (list.length > 0) { - egret.$error(2020, this.currentClassName, list.join("\n")); - } - } - if (!this.currentXML.namespace) { - if (true) { - egret.$error(2017, this.currentClassName, toXMLString(this.currentXML)); - } - return; - } - this.addIds(this.currentXML.children); - this.createConstructFunc(); - }; - /** - * @private - * 添加必须的id - */ - EXMLParser.prototype.addIds = function (items) { - if (!items) { - return; - } - var length = items.length; - for (var i = 0; i < length; i++) { - var node = items[i]; - if (node.nodeType != 1) { - continue; - } - if (!node.namespace) { - if (true) { - egret.$error(2017, this.currentClassName, toXMLString(node)); - } - continue; - } - if (this.isInnerClass(node)) { - continue; - } - this.addIds(node.children); - if (node.namespace == sys.NS_W || !node.localName) { - } - else if (this.isProperty(node)) { - var prop = node.localName; - var index = prop.indexOf("."); - var children = node.children; - if (index == -1 || !children || children.length == 0) { - continue; - } - var firstChild = children[0]; - this.stateIds.push(firstChild.attributes.id); - } - else if (node.nodeType === 1) { - var id = node.attributes["id"]; - if (id) { - var e = new RegExp("^[a-zA-Z_$]{1}[a-z0-9A-Z_$]*"); - if (id.match(e) == null) { - egret.$warn(2022, id); - } - if (id.match(new RegExp(/ /g)) != null) { - egret.$warn(2022, id); - } - if (this.skinParts.indexOf(id) == -1) { - this.skinParts.push(id); - } - this.createVarForNode(node); - if (this.isStateNode(node)) - this.stateIds.push(id); - } - else { - this.createIdForNode(node); - if (this.isStateNode(node)) - this.stateIds.push(node.attributes.id); - } - } - } - }; - /** - * @private - * 是否为内部类。 - */ - EXMLParser.prototype.isInnerClass = function (node) { - if (node.hasOwnProperty("isInnerClass")) { - return node["isInnerClass"]; - } - var result = (node.localName == "Skin" && node.namespace == sys.NS_S); - if (!result) { - if (this.isProperty(node)) { - result = false; - } - else { - var prop = void 0; - var parent_1 = node.parent; - if (this.isProperty(parent_1)) { - prop = parent_1.localName; - var index = prop.indexOf("."); - if (index != -1) { - var stateName = prop.substring(index + 1); - prop = prop.substring(0, index); - } - parent_1 = parent_1.parent; - } - else { - prop = sys.exmlConfig.getDefaultPropById(parent_1.localName, parent_1.namespace); - } - var className = sys.exmlConfig.getClassNameById(parent_1.localName, parent_1.namespace); - result = (sys.exmlConfig.getPropertyType(prop, className) == TYPE_CLASS); - } - } - node["isInnerClass"] = result; - return result; - }; - /** - * @private - * 检测指定节点的属性是否含有视图状态 - */ - EXMLParser.prototype.containsState = function (node) { - var attributes = node.attributes; - if (attributes["includeIn"] || attributes["excludeFrom"]) { - return true; - } - var keys = Object.keys(attributes); - var length = keys.length; - for (var i = 0; i < length; i++) { - var name_1 = keys[i]; - if (name_1.indexOf(".") != -1) { - return true; - } - } - return false; - }; - /** - * @private - * 为指定节点创建id属性 - */ - EXMLParser.prototype.createIdForNode = function (node) { - var idName = this.getNodeId(node); - if (!this.idDic[idName]) - this.idDic[idName] = 1; - else - this.idDic[idName]++; - idName += this.idDic[idName]; - node.attributes.id = idName; - }; - /** - * @private - * 获取节点ID - */ - EXMLParser.prototype.getNodeId = function (node) { - if (node.attributes["id"]) - return node.attributes.id; - return "_" + node.localName; - }; - /** - * @private - * 为指定节点创建变量 - */ - EXMLParser.prototype.createVarForNode = function (node) { - var moduleName = this.getClassNameOfNode(node); - if (moduleName == "") - return; - if (!this.currentClass.getVariableByName(node.attributes.id)) - this.currentClass.addVariable(new sys.EXVariable(node.attributes.id)); - }; - /** - * @private - * 为指定节点创建初始化函数,返回函数名引用 - */ - EXMLParser.prototype.createFuncForNode = function (node) { - var className = node.localName; - var isBasicType = this.isBasicTypeData(className); - if (isBasicType) - return this.createBasicTypeForNode(node); - var moduleName = this.getClassNameOfNode(node); - var func = new sys.EXFunction(); - var tailName = "_i"; - var id = node.attributes.id; - func.name = id + tailName; - this.currentClass.addFunction(func); - var cb = new sys.EXCodeBlock(); - func.codeBlock = cb; - var varName = "t"; - if (className == "Object") { - cb.addVar(varName, "{}"); - } - else { - cb.addVar(varName, "new " + moduleName + "()"); - } - var containsId = !!this.currentClass.getVariableByName(id); - if (containsId) { - cb.addAssignment("this." + id, varName); - } - this.addAttributesToCodeBlock(cb, varName, node); - this.initlizeChildNode(node, cb, varName); - var delayAssignments = this.delayAssignmentDic[id]; - if (delayAssignments) { - var length_18 = delayAssignments.length; - for (var i = 0; i < length_18; i++) { - var codeBlock = delayAssignments[i]; - cb.concat(codeBlock); - } - } - cb.addReturn(varName); - return "this." + func.name + "()"; - }; - /** - * @private - * 检查目标类名是否是基本数据类型 - */ - EXMLParser.prototype.isBasicTypeData = function (className) { - return basicTypes.indexOf(className) != -1; - }; - /** - * @private - * 为指定基本数据类型节点实例化,返回实例化后的值。 - */ - EXMLParser.prototype.createBasicTypeForNode = function (node) { - var className = node.localName; - var returnValue = ""; - var varItem = this.currentClass.getVariableByName(node.attributes.id); - var children = node.children; - var text = ""; - if (children && children.length > 0) { - var firstChild = children[0]; - if (firstChild.nodeType == 3) { - text = firstChild.text.trim(); - } - } - switch (className) { - case TYPE_ARRAY: - var values = []; - if (children) { - var length_19 = children.length; - for (var i = 0; i < length_19; i++) { - var child = children[i]; - if (child.nodeType == 1) { - values.push(this.createFuncForNode(child)); - } - } - } - returnValue = "[" + values.join(",") + "]"; - break; - case "boolean": - returnValue = (text == "false" || !text) ? "false" : "true"; - break; - case "number": - returnValue = text; - if (returnValue.indexOf("%") != -1) - returnValue = returnValue.substring(0, returnValue.length - 1); - break; - case "string": - returnValue = this.formatString(text); - break; - } - if (varItem) - varItem.defaultValue = returnValue; - return returnValue; - }; - /** - * @private - * 将节点属性赋值语句添加到代码块 - */ - EXMLParser.prototype.addAttributesToCodeBlock = function (cb, varName, node) { - var key; - var value; - var attributes = node.attributes; - var keyList = Object.keys(attributes); - keyList.sort(); //排序一下防止出现随机顺序 - var length = keyList.length; - for (var i = 0; i < length; i++) { - key = keyList[i]; - if (!this.isNormalKey(key)) { - continue; - } - value = attributes[key]; - key = this.formatKey(key, value); - value = this.formatValue(key, value, node); - if (!value) { - continue; - } - if (this.currentClass.getVariableByName(value)) { - var THIS = "this."; - var id = attributes.id; - var codeLine = THIS + id + " = t;"; - if (!this.currentClass.getVariableByName(id)) - this.createVarForNode(node); - if (!cb.containsCodeLine(codeLine)) { - cb.addCodeLineAt(codeLine, 1); - } - var delayCb = new sys.EXCodeBlock(); - if (varName == "this") { - delayCb.addAssignment(varName, THIS + value, key); - } - else { - delayCb.startIf(THIS + id); - delayCb.addAssignment(THIS + id, THIS + value, key); - delayCb.endBlock(); - } - if (!this.delayAssignmentDic[value]) { - this.delayAssignmentDic[value] = []; - } - this.delayAssignmentDic[value].push(delayCb); - value = THIS + value; - } - cb.addAssignment(varName, value, key); - } - }; - /** - * @private - * 初始化子项 - */ - EXMLParser.prototype.initlizeChildNode = function (node, cb, varName) { - var children = node.children; - if (!children || children.length == 0) - return; - var className = sys.exmlConfig.getClassNameById(node.localName, node.namespace); - var directChild = []; - var length = children.length; - var propList = []; - var errorInfo; - for (var i = 0; i < length; i++) { - var child = children[i]; - if (child.nodeType != 1 || child.namespace == sys.NS_W) { - continue; - } - if (this.isInnerClass(child)) { - if (child.localName == "Skin") { - var innerClassName = this.parseInnerClass(child); - var type = sys.exmlConfig.getPropertyType(SKIN_NAME, className); - if (type) { - cb.addAssignment(varName, innerClassName, SKIN_NAME); - } - else { - egret.$error(2005, this.currentClassName, SKIN_NAME, getPropertyStr(child)); - } - } - continue; - } - var prop = child.localName; - if (this.isProperty(child)) { - if (!this.isNormalKey(prop)) { - continue; - } - var type = sys.exmlConfig.getPropertyType(child.localName, className); - if (!type) { - if (true) { - egret.$error(2005, this.currentClassName, child.localName, getPropertyStr(child)); - } - continue; - } - if (!child.children || child.children.length == 0) { - if (true) { - egret.$warn(2102, this.currentClassName, getPropertyStr(child)); - } - continue; - } - if (true) { - errorInfo = getPropertyStr(child); - } - this.addChildrenToProp(child.children, type, prop, cb, varName, errorInfo, propList, node); - } - else { - directChild.push(child); - } - } - if (directChild.length == 0) - return; - var defaultProp = sys.exmlConfig.getDefaultPropById(node.localName, node.namespace); - var defaultType = sys.exmlConfig.getPropertyType(defaultProp, className); - if (true) { - errorInfo = getPropertyStr(directChild[0]); - } - if (!defaultProp || !defaultType) { - if (true) { - egret.$error(2012, this.currentClassName, errorInfo); - } - return; - } - this.addChildrenToProp(directChild, defaultType, defaultProp, cb, varName, errorInfo, propList, node); - }; - /** - * @private - * 解析内部类节点,并返回类名。 - */ - EXMLParser.prototype.parseInnerClass = function (node) { - var parser = exmlParserPool.pop(); - if (!parser) { - parser = new EXMLParser(); - } - var innerClassName = this.currentClass.className + "$" + node.localName + innerClassCount++; - var innerClass = parser.parseClass(node, innerClassName); - this.currentClass.addInnerClass(innerClass); - exmlParserPool.push(parser); - return innerClassName; - }; - /** - * @private - * 添加多个子节点到指定的属性 - */ - EXMLParser.prototype.addChildrenToProp = function (children, type, prop, cb, varName, errorInfo, propList, node) { - var childFunc = ""; - var childLength = children.length; - if (childLength > 1) { - if (type != TYPE_ARRAY) { - if (true) { - egret.$error(2011, this.currentClassName, prop, errorInfo); - } - return; - } - var values = []; - for (var j = 0; j < childLength; j++) { - var item = children[j]; - if (item.nodeType != 1) { - continue; - } - childFunc = this.createFuncForNode(item); - var childClassName = this.getClassNameOfNode(item); - if (!this.isStateNode(item)) - values.push(childFunc); - } - childFunc = "[" + values.join(",") + "]"; - } - else { - var firstChild = children[0]; - if (type == TYPE_ARRAY) { - if (firstChild.localName == TYPE_ARRAY) { - var values = []; - if (firstChild.children) { - var len = firstChild.children.length; - for (var k = 0; k < len; k++) { - var item = firstChild.children[k]; - if (item.nodeType != 1) { - continue; - } - childFunc = this.createFuncForNode(item); - var childClassName = this.getClassNameOfNode(item); - if (!this.isStateNode(item)) - values.push(childFunc); - } - } - childFunc = "[" + values.join(",") + "]"; - } - else { - childFunc = this.createFuncForNode(firstChild); - var childClassName = this.getClassNameOfNode(firstChild); - if (!this.isStateNode(firstChild)) - childFunc = "[" + childFunc + "]"; - else - childFunc = "[]"; - } - } - else if (firstChild.nodeType == 1) { - if (type == TYPE_CLASS) { - if (childLength > 1) { - if (true) { - egret.$error(2011, this.currentClassName, prop, errorInfo); - } - return; - } - childFunc = this.parseInnerClass(children[0]); - } - else { - var targetClass = this.getClassNameOfNode(firstChild); - childFunc = this.createFuncForNode(firstChild); - } - } - else { - childFunc = this.formatValue(prop, firstChild.text, node); - } - } - if (childFunc != "") { - if (childFunc.indexOf("()") == -1) - prop = this.formatKey(prop, childFunc); - if (propList.indexOf(prop) == -1) { - propList.push(prop); - } - else if (true) { - egret.$warn(2103, this.currentClassName, prop, errorInfo); - } - cb.addAssignment(varName, childFunc, prop); - } - }; - /** - * @private - * 指定节点是否是属性节点 - */ - EXMLParser.prototype.isProperty = function (node) { - if (node.hasOwnProperty("isProperty")) { - return node["isProperty"]; - } - var result; - var name = node.localName; - if (!name || node.nodeType !== 1 || !node.parent || this.isBasicTypeData(name)) { - result = false; - } - else { - var parent_2 = node.parent; - var index = name.indexOf("."); - if (index != -1) { - name = name.substr(0, index); - } - var className = sys.exmlConfig.getClassNameById(parent_2.localName, parent_2.namespace); - result = !!sys.exmlConfig.getPropertyType(name, className); - } - node["isProperty"] = result; - return result; - }; - /** - * @private - * 是否是普通赋值的key - */ - EXMLParser.prototype.isNormalKey = function (key) { - if (!key || key.indexOf(".") != -1 - || key.indexOf(":") != -1 || wingKeys.indexOf(key) != -1) - return false; - return true; - }; - /** - * @private - * 格式化key - */ - EXMLParser.prototype.formatKey = function (key, value) { - if (value.indexOf("%") != -1) { - if (key == "height") - key = "percentHeight"; - else if (key == "width") - key = "percentWidth"; - } - return key; - }; - /** - * @private - * 格式化值 - */ - EXMLParser.prototype.formatValue = function (key, value, node) { - if (!value) { - value = ""; - } - var stringValue = value; //除了字符串,其他类型都去除两端多余空格。 - value = value.trim(); - var className = this.getClassNameOfNode(node); - var type = sys.exmlConfig.getPropertyType(key, className); - if (true && !type) { - egret.$error(2005, this.currentClassName, key, toXMLString(node)); - } - var bindingValue = this.formatBinding(key, value, node); - if (bindingValue) { - this.checkIdForState(node); - var target = "this"; - if (node !== this.currentXML) { - target += "." + node.attributes["id"]; - } - this.bindings.push(new sys.EXBinding(target, key, bindingValue.templates, bindingValue.chainIndex)); - value = ""; - } - else if (type == RECTANGLE) { - if (true) { - var rect = value.split(","); - if (rect.length != 4 || isNaN(parseInt(rect[0])) || isNaN(parseInt(rect[1])) || - isNaN(parseInt(rect[2])) || isNaN(parseInt(rect[3]))) { - egret.$error(2016, this.currentClassName, toXMLString(node)); - } - } - value = "new " + RECTANGLE + "(" + value + ")"; - } - else if (type == TYPE_PERCENTAGE) { - if (value.indexOf("%") != -1) { - value = this.formatString(value); - ; - } - } - else { - var orgValue = value; - switch (type) { - case TYPE_CLASS: - if (key == SKIN_NAME) { - value = this.formatString(stringValue); - } - break; - case "number": - if (value.indexOf("#") == 0) { - if (true && isNaN(value.substring(1))) { - egret.$warn(2021, this.currentClassName, key, value); - } - value = "0x" + value.substring(1); - } - else if (value.indexOf("%") != -1) { - if (true && isNaN(value.substr(0, value.length - 1))) { - egret.$warn(2021, this.currentClassName, key, value); - } - value = (parseFloat(value.substr(0, value.length - 1))).toString(); - } - else if (true && isNaN(value)) { - egret.$warn(2021, this.currentClassName, key, value); - } - break; - case "boolean": - value = (value == "false" || !value) ? "false" : "true"; - break; - case "string": - case "any": - value = this.formatString(stringValue); - break; - default: - if (true) { - egret.$error(2008, this.currentClassName, "string", key + ":" + type, toXMLString(node)); - } - break; - } - } - return value; - }; - /** - * @private - * 格式化字符串 - */ - EXMLParser.prototype.formatString = function (value) { - value = this.unescapeHTMLEntity(value); - value = value.split("\n").join("\\n"); - value = value.split("\r").join("\\n"); - value = value.split("\"").join("\\\""); - value = "\"" + value + "\""; - return value; - }; - EXMLParser.prototype.formatBinding = function (key, value, node) { - if (!value) { - return null; - } - value = value.trim(); - if (value.charAt(0) != "{" || value.charAt(value.length - 1) != "}") { - return null; - } - value = value.substring(1, value.length - 1).trim(); - var templates = value.indexOf("+") == -1 ? [value] : this.parseTemplates(value); - var chainIndex = []; - var length = templates.length; - for (var i = 0; i < length; i++) { - var item = templates[i].trim(); - if (!item) { - templates.splice(i, 1); - i--; - length--; - continue; - } - var first = item.charAt(0); - if (first == "'" || first == "\"" || first >= "0" && first <= "9" || first == "-") { - continue; - } - if (item.indexOf(".") == -1 && jsKeyWords.indexOf(item) != -1) { - continue; - } - if (item.indexOf("this.") == 0) { - item = item.substring(5); - } - var firstKey = item.split(".")[0]; - if (firstKey != HOST_COMPONENT && this.skinParts.indexOf(firstKey) == -1) { - item = HOST_COMPONENT + "." + item; - } - templates[i] = "\"" + item + "\""; - chainIndex.push(i); - } - return { templates: templates, chainIndex: chainIndex }; - }; - EXMLParser.prototype.parseTemplates = function (value) { - //仅仅是表达式相加 如:{a.b+c.d} - if (value.indexOf("'") == -1) { - return value.split("+"); - } - //包含文本的需要提取文本并对文本进行处理 - var isSingleQuoteLeak = false; //是否缺失单引号 - var trimText = ""; - value = value.split("\\\'").join("\v0\v"); - while (value.length > 0) { - //'成对出现 这是第一个 - var index = value.indexOf("'"); - if (index == -1) { - trimText += value; - break; - } - trimText += value.substring(0, index + 1); - value = value.substring(index + 1); - //'成对出现 这是第二个 - index = value.indexOf("'"); - if (index == -1) { - index = value.length - 1; - isSingleQuoteLeak = true; - } - var quote = value.substring(0, index + 1); - trimText += quote.split("+").join("\v1\v"); - value = value.substring(index + 1); - } - value = trimText.split("\v0\v").join("\\\'"); - //补全缺失的单引号 - if (isSingleQuoteLeak) { - value += "'"; - } - var templates = value.split("+"); - var length = templates.length; - for (var i = 0; i < length; i++) { - templates[i] = templates[i].split("\v1\v").join("+"); - } - return templates; - }; - /** - * @private - /** - * 转换HTML实体字符为普通字符 - */ - EXMLParser.prototype.unescapeHTMLEntity = function (str) { - if (!str) - return ""; - var length = htmlEntities.length; - for (var i = 0; i < length; i++) { - var arr = htmlEntities[i]; - var key = arr[0]; - var value = arr[1]; - str = str.split(value).join(key); - } - return str; - }; - /** - * @private - * 创建构造函数 - */ - EXMLParser.prototype.createConstructFunc = function () { - var cb = new sys.EXCodeBlock; - cb.addEmptyLine(); - var varName = "this"; - this.addAttributesToCodeBlock(cb, varName, this.currentXML); - if (this.declarations) { - var children = this.declarations.children; - if (children && children.length > 0) { - var length_20 = children.length; - for (var i = 0; i < length_20; i++) { - var decl = children[i]; - if (decl.nodeType != 1) { - continue; - } - var funcName = this.createFuncForNode(decl); - if (funcName) { - cb.addCodeLine(funcName + ";"); - } - } - } - } - this.initlizeChildNode(this.currentXML, cb, varName); - var id; - var length; - var stateIds = this.stateIds; - if (stateIds.length > 0) { - length = stateIds.length; - for (var i = 0; i < length; i++) { - id = stateIds[i]; - cb.addCodeLine("this." + id + "_i();"); - } - cb.addEmptyLine(); - } - var skinParts = this.skinParts; - var skinPartStr = "[]"; - length = skinParts.length; - if (length > 0) { - for (var i = 0; i < length; i++) { - skinParts[i] = "\"" + skinParts[i] + "\""; - } - skinPartStr = "[" + skinParts.join(",") + "]"; - } - var skinPartFunc = new sys.EXFunction(); - skinPartFunc.name = "skinParts"; - skinPartFunc.isGet = true; - var skinPartCB = new sys.EXCodeBlock(); - skinPartCB.addReturn(skinPartStr); - skinPartFunc.codeBlock = skinPartCB; - this.currentClass.addFunction(skinPartFunc); - this.currentXML.attributes.id = ""; - //生成视图状态代码 - this.createStates(this.currentXML); - var states; - var node = this.currentXML; - var nodeClassName = this.getClassNameOfNode(node); - var attributes = node.attributes; - var keys = Object.keys(attributes); - var keysLength = keys.length; - for (var m = 0; m < keysLength; m++) { - var itemName = keys[m]; - var value = attributes[itemName]; - var index = itemName.indexOf("."); - if (index != -1) { - var key = itemName.substring(0, index); - key = this.formatKey(key, value); - var itemValue = this.formatValue(key, value, node); - if (!itemValue) { - continue; - } - var stateName = itemName.substr(index + 1); - states = this.getStateByName(stateName, node); - var stateLength = states.length; - if (stateLength > 0) { - for (var i = 0; i < stateLength; i++) { - var state = states[i]; - state.addOverride(new sys.EXSetProperty("", key, itemValue)); - } - } - } - } - //打印视图状态初始化代码 - var stateCode = this.stateCode; - length = stateCode.length; - if (length > 0) { - var indentStr = " "; - cb.addCodeLine("this.states = ["); - var first = true; - for (var i = 0; i < length; i++) { - var state = stateCode[i]; - if (first) - first = false; - else - cb.addCodeLine(indentStr + ","); - var codes = state.toCode().split("\n"); - var codeIndex = 0; - while (codeIndex < codes.length) { - var code = codes[codeIndex]; - if (code) - cb.addCodeLine(indentStr + code); - codeIndex++; - } - } - cb.addCodeLine("];"); - } - //生成绑定代码 - var bindings = this.bindings; - length = bindings.length; - if (length > 0) { - cb.addEmptyLine(); - for (var i = 0; i < length; i++) { - var binding = bindings[i]; - cb.addCodeLine(binding.toCode()); - } - } - this.currentClass.constructCode = cb; - }; - /** - * @private - * 是否含有includeIn和excludeFrom属性 - */ - EXMLParser.prototype.isStateNode = function (node) { - var attributes = node.attributes; - return attributes.hasOwnProperty("includeIn") || attributes.hasOwnProperty("excludeFrom"); - }; - /** - * @private - * 获取视图状态名称列表 - */ - EXMLParser.prototype.getStateNames = function () { - var root = this.currentXML; - var className = sys.exmlConfig.getClassNameById(root.localName, root.namespace); - var type = sys.exmlConfig.getPropertyType("states", className); - if (type != TYPE_STATE) { - return; - } - var statesValue = root.attributes["states"]; - if (statesValue) { - delete root.attributes["states"]; - } - var stateNames = this.stateNames; - var stateChildren; - var children = root.children; - var item; - if (children) { - var length_21 = children.length; - for (var i = 0; i < length_21; i++) { - item = children[i]; - if (item.nodeType == 1 && - item.localName == "states") { - item.namespace = sys.NS_W; - stateChildren = item.children; - break; - } - } - } - if (!stateChildren && !statesValue) { - return; - } - if (true) { - if (stateChildren && stateChildren.length == 0) { - egret.$warn(2102, this.currentClassName, getPropertyStr(item)); - } - if (stateChildren && statesValue) { - egret.$warn(2103, this.currentClassName, "states", getPropertyStr(item)); - } - } - if (statesValue) { - var states = statesValue.split(","); - var length_22 = states.length; - for (var i = 0; i < length_22; i++) { - var stateName = states[i].trim(); - if (!stateName) { - continue; - } - if (stateNames.indexOf(stateName) == -1) { - stateNames.push(stateName); - } - this.stateCode.push(new sys.EXState(stateName)); - } - return; - } - var length = stateChildren.length; - for (var i = 0; i < length; i++) { - var state = stateChildren[i]; - if (state.nodeType != 1) { - continue; - } - var stateGroups = []; - var attributes = state.attributes; - if (attributes["stateGroups"]) { - var groups = attributes.stateGroups.split(","); - var len = groups.length; - for (var j = 0; j < len; j++) { - var group = groups[j].trim(); - if (group) { - if (stateNames.indexOf(group) == -1) { - stateNames.push(group); - } - stateGroups.push(group); - } - } - } - var stateName = attributes.name; - if (stateNames.indexOf(stateName) == -1) { - stateNames.push(stateName); - } - this.stateCode.push(new sys.EXState(stateName, stateGroups)); - } - }; - /** - * @private - * 解析视图状态代码 - */ - EXMLParser.prototype.createStates = function (parentNode) { - var items = parentNode.children; - if (!items) { - return; - } - var length = items.length; - for (var i = 0; i < length; i++) { - var node = items[i]; - if (node.nodeType != 1 || this.isInnerClass(node)) { - continue; - } - this.createStates(node); - if (node.namespace == sys.NS_W || !node.localName) { - continue; - } - if (this.isProperty(node)) { - var prop = node.localName; - var index = prop.indexOf("."); - var children = node.children; - if (index == -1 || !children || children.length == 0) { - continue; - } - var stateName = prop.substring(index + 1); - prop = prop.substring(0, index); - var className = this.getClassNameOfNode(parentNode); - var type = sys.exmlConfig.getPropertyType(prop, className); - if (true) { - if (type == TYPE_ARRAY) { - egret.$error(2013, this.currentClassName, getPropertyStr(node)); - } - if (children.length > 1) { - egret.$error(2011, this.currentClassName, prop, getPropertyStr(node)); - } - } - var firstChild = children[0]; - var value = void 0; - if (firstChild.nodeType == 1) { - this.createFuncForNode(firstChild); - this.checkIdForState(firstChild); - value = "this." + firstChild.attributes.id; - } - else { - value = this.formatValue(prop, firstChild.text, parentNode); - } - var states = this.getStateByName(stateName, node); - var l = states.length; - if (l > 0) { - for (var j = 0; j < l; j++) { - var state = states[j]; - state.addOverride(new sys.EXSetProperty(parentNode.attributes.id, prop, value)); - } - } - } - else if (this.containsState(node)) { - var attributes = node.attributes; - var id = attributes.id; - var nodeClassName = this.getClassNameOfNode(node); - this.checkIdForState(node); - var stateName = void 0; - var states = void 0; - var state = void 0; - if (this.isStateNode(node)) { - var propertyName = ""; - var parent_3 = node.parent; - if (parent_3.localName == TYPE_ARRAY) - parent_3 = parent_3.parent; - if (parent_3 && parent_3.parent) { - if (this.isProperty(parent_3)) - parent_3 = parent_3.parent; - } - if (parent_3 && parent_3 != this.currentXML) { - propertyName = parent_3.attributes.id; - this.checkIdForState(parent_3); - } - var positionObj = this.findNearNodeId(node); - var stateNames = []; - if (attributes.includeIn) { - stateNames = attributes.includeIn.split(","); - } - else { - var excludeNames = attributes.excludeFrom.split(","); - var stateLength = excludeNames.length; - for (var j = 0; j < stateLength; j++) { - var name_2 = excludeNames[j]; - this.getStateByName(name_2, node); //检查exlcudeFrom是否含有未定义的视图状态名 - } - stateLength = this.stateCode.length; - for (var j = 0; j < stateLength; j++) { - state = this.stateCode[j]; - if (excludeNames.indexOf(state.name) == -1) { - stateNames.push(state.name); - } - } - } - var len = stateNames.length; - for (var k = 0; k < len; k++) { - stateName = stateNames[k]; - states = this.getStateByName(stateName, node); - if (states.length > 0) { - var l = states.length; - for (var j = 0; j < l; j++) { - state = states[j]; - state.addOverride(new sys.EXAddItems(id, propertyName, positionObj.position, positionObj.relativeTo)); - } - } - } - } - var names = Object.keys(attributes); - var namesLength = names.length; - for (var m = 0; m < namesLength; m++) { - var name_3 = names[m]; - var value = attributes[name_3]; - var index = name_3.indexOf("."); - if (index != -1) { - var key = name_3.substring(0, index); - key = this.formatKey(key, value); - var bindingValue = this.formatBinding(key, value, node); - if (!bindingValue) { - value = this.formatValue(key, value, node); - if (!value) { - continue; - } - } - stateName = name_3.substr(index + 1); - states = this.getStateByName(stateName, node); - var l = states.length; - if (l > 0) { - for (var j = 0; j < l; j++) { - state = states[j]; - if (bindingValue) { - state.addOverride(new sys.EXSetStateProperty(id, key, bindingValue.templates, bindingValue.chainIndex)); - } - else { - state.addOverride(new sys.EXSetProperty(id, key, value)); - } - } - } - } - } - } - } - }; - /** - * @private - * 检查指定的ID是否创建了类成员变量,若没创建则为其创建。 - */ - EXMLParser.prototype.checkIdForState = function (node) { - if (!node || this.currentClass.getVariableByName(node.attributes.id)) { - return; - } - this.createVarForNode(node); - var id = node.attributes.id; - var funcName = id + "_i"; - var func = this.currentClass.getFuncByName(funcName); - if (!func) - return; - var codeLine = "this." + id + " = t;"; - var cb = func.codeBlock; - if (!cb) - return; - if (!cb.containsCodeLine(codeLine)) { - cb.addCodeLineAt(codeLine, 1); - } - }; - /** - * @private - * 通过视图状态名称获取对应的视图状态 - */ - EXMLParser.prototype.getStateByName = function (name, node) { - var states = []; - var stateCode = this.stateCode; - var length = stateCode.length; - for (var i = 0; i < length; i++) { - var state = stateCode[i]; - if (state.name == name) { - if (states.indexOf(state) == -1) - states.push(state); - } - else if (state.stateGroups.length > 0) { - var found = false; - var len = state.stateGroups.length; - for (var j = 0; j < len; j++) { - var g = state.stateGroups[j]; - if (g == name) { - found = true; - break; - } - } - if (found) { - if (states.indexOf(state) == -1) - states.push(state); - } - } - } - if (true && states.length == 0) { - egret.$error(2006, this.currentClassName, name, toXMLString(node)); - } - return states; - }; - /** - * @private - * 寻找节点的临近节点ID和位置 - */ - EXMLParser.prototype.findNearNodeId = function (node) { - var parentNode = node.parent; - var targetId = ""; - var position; - var index = -1; - var preItem; - var afterItem; - var found = false; - var children = parentNode.children; - var length = children.length; - for (var i = 0; i < length; i++) { - var item = children[i]; - if (this.isProperty(item)) - continue; - if (item == node) { - found = true; - index = i; - } - else { - if (found && !afterItem && !this.isStateNode(item)) { - afterItem = item; - } - } - if (!found && !this.isStateNode(item)) - preItem = item; - } - if (index == 0) { - position = 0 /* FIRST */; - return { position: position, relativeTo: targetId }; - } - if (index == length - 1) { - position = 1 /* LAST */; - return { position: position, relativeTo: targetId }; - } - if (afterItem) { - position = 2 /* BEFORE */; - targetId = afterItem.attributes.id; - if (targetId) { - this.checkIdForState(afterItem); - return { position: position, relativeTo: targetId }; - } - } - return { position: 1 /* LAST */, relativeTo: targetId }; - }; - /** - * @private - * 获取节点的完整类名,包括模块名 - */ - EXMLParser.prototype.getClassNameOfNode = function (node) { - var className = sys.exmlConfig.getClassNameById(node.localName, node.namespace); - if (true && !className) { - egret.$error(2003, this.currentClassName, toXMLString(node)); - } - return className; - }; - return EXMLParser; - }()); - sys.EXMLParser = EXMLParser; - __reflect(EXMLParser.prototype, "eui.sys.EXMLParser"); - if (true) { - /** - * 获取重复的ID名 - */ - function getRepeatedIds(xml) { - var result = []; - this.repeatedIdMap = {}; - this.getIds(xml, result); - return result; - } - function getIds(xml, result) { - if (xml.namespace != sys.NS_W && xml.attributes.id) { - var id = xml.attributes.id; - if (this.repeatedIdMap[id]) { - result.push(toXMLString(xml)); - } - else { - this.repeatedIdMap[id] = true; - } - } - var children = xml.children; - if (children) { - var length_23 = children.length; - for (var i = 0; i < length_23; i++) { - var node = children[i]; - if (node.nodeType !== 1 || this.isInnerClass(node)) { - continue; - } - this.getIds(node, result); - } - } - } - function toXMLString(node) { - if (!node) { - return ""; - } - var str = " at <" + node.name; - var attributes = node.attributes; - var keys = Object.keys(attributes); - var length = keys.length; - for (var i = 0; i < length; i++) { - var key = keys[i]; - var value = attributes[key]; - if (key == "id" && value.substring(0, 2) == "__") { - continue; - } - str += " " + key + "=\"" + value + "\""; - } - if (node.children.length == 0) { - str += "/>"; - } - else { - str += ">"; - } - return str; - } - /** - * 清理声明节点里的状态标志 - */ - function checkDeclarations(declarations, list) { - if (!declarations) { - return; - } - var children = declarations.children; - if (children) { - var length_24 = children.length; - for (var i = 0; i < length_24; i++) { - var node = children[i]; - if (node.nodeType != 1) { - continue; - } - if (node.attributes.includeIn) { - list.push(toXMLString(node)); - } - if (node.attributes.excludeFrom) { - list.push(toXMLString(node)); - } - checkDeclarations(node, list); - } - } - } - function getPropertyStr(child) { - var parentStr = toXMLString(child.parent); - var childStr = toXMLString(child).substring(5); - return parentStr + "\n \t" + childStr; - } - } - })(sys = eui.sys || (eui.sys = {})); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The ToggleButton component defines a toggle button. - * Clicking the button toggles it between the up and an down states. - * If you click the button while it is in the up state, - * it toggles to the down state. You must click the button again - * to toggle it back to the up state. - *

      You can get or set this state programmatically - * by using the selected property.

      - * - * @event egret.Event.CHANGE Dispatched when the selected property - * changes for the ToggleButton control. - * This event is dispatched only when the - * user interacts with the control by touching. - * - * @state up Button up state - * @state down Button down state - * @state disabled Button disabled state - * @state upAndSelected Up state when the button is selected - * @state downAndSelected Down state when the button is selected - * @state disabledAndSelected Disabled state when the button is selected - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ToggleButtonExample.ts - * @language en_US - */ - /** - * ToggleButton 组件定义切换按钮。单击该按钮会在弹起状态和按下状态之间进行切换。 - * 如果在按钮处于弹起状态时单击该按钮,则它会切换到按下状态。必须再次单击该按钮才可将其切换回弹起状态。 - *

      可以使用 selected 属性以编程方式获取或设置此状态。

      - * - * @event egret.Event.CHANGE ToggleButtonBase 控件的 selected 属性更改时分派。 - * 仅当用户通过触摸与控件交互时,才分派此事件。 - * - * @state up 按钮弹起状态 - * @state down 按钮按下状态 - * @state disabled 按钮禁用状态 - * @state upAndSelected 按钮选择时的弹起状态 - * @state downAndSelected 按钮选择时的按下状态 - * @state disabledAndSelected 按钮选择时的禁用状态 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ToggleButtonExample.ts - * @language zh_CN - */ - var ToggleButton = (function (_super) { - __extends(ToggleButton, _super); - function ToggleButton() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.$selected = false; - /** - * @private - * 是否根据触摸事件自动变换选中状态,默认true。仅框架内使用。 - */ - _this.$autoSelected = true; - return _this; - } - Object.defineProperty(ToggleButton.prototype, "selected", { - /** - * Contains true if the button is in the down state, - * and false if it is in the up state. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 按钮处于按下状态时为 true,而按钮处于弹起状态时为 false。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$selected; - }, - set: function (value) { - this.$setSelected(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - ToggleButton.prototype.$setSelected = function (value) { - value = !!value; - if (value === this.$selected) - return false; - this.$selected = value; - this.invalidateState(); - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "selected"); - return true; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ToggleButton.prototype.getCurrentState = function () { - var state = _super.prototype.getCurrentState.call(this); - if (!this.$selected) { - return state; - } - else { - var selectedState = state + "AndSelected"; - var skin = this.skin; - if (skin && skin.hasState(selectedState)) { - return selectedState; - } - return state == "disabled" ? "disabled" : "down"; - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ToggleButton.prototype.buttonReleased = function () { - if (!this.$autoSelected) - return; - this.selected = !this.$selected; - this.dispatchEventWith(egret.Event.CHANGE); - }; - return ToggleButton; - }(eui.Button)); - eui.ToggleButton = ToggleButton; - __reflect(ToggleButton.prototype, "eui.ToggleButton"); - eui.registerBindable(ToggleButton.prototype, "selected"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * Linear layout base class, usually as the parent class of - * HorizontalLayout and VerticalLayout. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 线性布局基类,通常作为 HorizontalLayoutVerticalLayout 的父类。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var LinearLayoutBase = (function (_super) { - __extends(LinearLayoutBase, _super); - function LinearLayoutBase() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.$horizontalAlign = "left"; - /** - * @private - */ - _this.$verticalAlign = "top"; - /** - * @private - */ - _this.$gap = 6; - /** - * @private - */ - _this.$paddingLeft = 0; - /** - * @private - */ - _this.$paddingRight = 0; - /** - * @private - */ - _this.$paddingTop = 0; - /** - * @private - */ - _this.$paddingBottom = 0; - /** - * An Array of the virtual layout elements size cache. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 虚拟布局使用的尺寸缓存。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.elementSizeTable = []; - /** - * The first element index in the view of the virtual layout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 虚拟布局使用的当前视图中的第一个元素索引 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.startIndex = -1; - /** - * The last element index in the view of the virtual layout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 虚拟布局使用的当前视图中的最后一个元素的索引 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.endIndex = -1; - /** - * A Flag of the first element and the end element has been calculated. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 视图的第一个和最后一个元素的索引值已经计算好的标志 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.indexInViewCalculated = false; - /** - * The maximum size of elements - * - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 子元素最大的尺寸 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.maxElementSize = 0; - return _this; - } - Object.defineProperty(LinearLayoutBase.prototype, "horizontalAlign", { - /** - * The horizontal alignment of layout elements. - *

      The egret.HorizontalAlign and eui.JustifyAlign class - * defines the possible values for this property.

      - * - * @default "left" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 布局元素的水平对齐策略。 - *

      egret.HorizontalAlign 和 - * eui.JustifyAlign类定义此属性的可能值。

      - * - * @default "left" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$horizontalAlign; - }, - set: function (value) { - if (this.$horizontalAlign == value) - return; - this.$horizontalAlign = value; - if (this.$target) - this.$target.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(LinearLayoutBase.prototype, "verticalAlign", { - /** - * The vertical alignment of layout elements. - *

      The egret.VerticalAlign and eui.JustifyAlign class - * defines the possible values for this property.

      - * - * @default "top" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 布局元素的垂直对齐策略。请使用 VerticalAlign 定义的常量。 - *

      egret.VerticalAlign 和 - * eui.JustifyAlign类定义此属性的可能值。

      - * - * @default "top" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$verticalAlign; - }, - set: function (value) { - if (this.$verticalAlign == value) - return; - this.$verticalAlign = value; - if (this.$target) - this.$target.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(LinearLayoutBase.prototype, "gap", { - /** - * The space between layout elements, in pixels. - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 布局元素之间的间隔(以像素为单位)。 - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$gap; - }, - set: function (value) { - value = +value || 0; - if (this.$gap === value) - return; - this.$gap = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(LinearLayoutBase.prototype, "paddingLeft", { - /** - * Number of pixels between the container's left edge - * and the left edge of the first layout element. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 容器的左边缘与第一个布局元素的左边缘之间的像素数。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$paddingLeft; - }, - set: function (value) { - value = +value || 0; - if (this.$paddingLeft === value) - return; - this.$paddingLeft = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(LinearLayoutBase.prototype, "paddingRight", { - /** - * Number of pixels between the container's right edge - * and the right edge of the last layout element. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 容器的右边缘与最后一个布局元素的右边缘之间的像素数。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$paddingRight; - }, - set: function (value) { - value = +value || 0; - if (this.$paddingRight === value) - return; - this.$paddingRight = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(LinearLayoutBase.prototype, "paddingTop", { - /** - * The minimum number of pixels between the container's top edge and - * the top of all the container's layout elements. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 容器的顶边缘与所有容器的布局元素的顶边缘之间的最少像素数。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$paddingTop; - }, - set: function (value) { - value = +value || 0; - if (this.$paddingTop === value) - return; - this.$paddingTop = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(LinearLayoutBase.prototype, "paddingBottom", { - /** - * The minimum number of pixels between the container's bottom edge and - * the bottom of all the container's layout elements. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 容器的底边缘与所有容器的布局元素的底边缘之间的最少像素数。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$paddingBottom; - }, - set: function (value) { - value = +value || 0; - if (this.$paddingBottom === value) - return; - this.$paddingBottom = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - /** - * Convenience function for subclasses that invalidates the - * target's size and displayList so that both layout's measure() - * and updateDisplayList methods get called. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 失效目标容器的尺寸和显示列表的简便方法,调用目标容器的 - * measure()updateDisplayList方法 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LinearLayoutBase.prototype.invalidateTargetLayout = function () { - var target = this.$target; - if (target) { - target.invalidateSize(); - target.invalidateDisplayList(); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - LinearLayoutBase.prototype.measure = function () { - if (!this.$target) - return; - if (this.$useVirtualLayout) { - this.measureVirtual(); - } - else { - this.measureReal(); - } - }; - /** - * Compute exact values for measuredWidth and measuredHeight. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 计算目标容器 measuredWidth 和 measuredHeight 的精确值 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LinearLayoutBase.prototype.measureReal = function () { - }; - /** - * Compute potentially approximate values for measuredWidth and measuredHeight. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 计算目标容器 measuredWidth 和 measuredHeight 的近似值 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LinearLayoutBase.prototype.measureVirtual = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - LinearLayoutBase.prototype.updateDisplayList = function (width, height) { - var target = this.$target; - if (!target) - return; - if (target.numElements == 0) { - target.setContentSize(Math.ceil(this.$paddingLeft + this.$paddingRight), Math.ceil(this.$paddingTop + this.$paddingBottom)); - return; - } - if (this.$useVirtualLayout) { - this.updateDisplayListVirtual(width, height); - } - else { - this.updateDisplayListReal(width, height); - } - }; - /** - * Gets the starting position of the specified index element - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取指定索引元素的起始位置 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LinearLayoutBase.prototype.getStartPosition = function (index) { - return 0; - }; - /** - * Gets the size of the specified index element - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取指定索引元素的尺寸 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LinearLayoutBase.prototype.getElementSize = function (index) { - return 0; - }; - /** - * Gets the sum of the size of cached elements - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取缓存的子对象尺寸总和 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LinearLayoutBase.prototype.getElementTotalSize = function () { - return 0; - }; - /** - * @inheritDoc - * - * @param index - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - LinearLayoutBase.prototype.elementRemoved = function (index) { - if (!this.$useVirtualLayout) - return; - _super.prototype.elementRemoved.call(this, index); - this.elementSizeTable.splice(index, 1); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - LinearLayoutBase.prototype.clearVirtualLayoutCache = function () { - if (!this.$useVirtualLayout) - return; - this.elementSizeTable = []; - this.maxElementSize = 0; - }; - /** - * The binary search to find the specified index position of the display object - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 折半查找法寻找指定位置的显示对象索引 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LinearLayoutBase.prototype.findIndexAt = function (x, i0, i1) { - var index = ((i0 + i1) * 0.5) | 0; - var elementX = this.getStartPosition(index); - var elementWidth = this.getElementSize(index); - if ((x >= elementX) && (x < elementX + elementWidth + this.$gap)) - return index; - else if (i0 == i1) - return -1; - else if (x < elementX) - return this.findIndexAt(x, i0, Math.max(i0, index - 1)); - else - return this.findIndexAt(x, Math.min(index + 1, i1), i1); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - LinearLayoutBase.prototype.scrollPositionChanged = function () { - _super.prototype.scrollPositionChanged.call(this); - if (this.$useVirtualLayout) { - var changed = this.getIndexInView(); - if (changed) { - this.indexInViewCalculated = true; - this.target.invalidateDisplayList(); - } - } - }; - /** - * Get the index of the first and last element in the view, - * and to return whether or not to change. - * - * @return has the index changed - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 获取视图中第一个和最后一个元素的索引,返回是否发生改变。 - * - * @return 索引是否已改变 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LinearLayoutBase.prototype.getIndexInView = function () { - return false; - }; - /** - * Update the layout of the virtualized elements - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 更新虚拟布局的显示列表 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LinearLayoutBase.prototype.updateDisplayListVirtual = function (width, height) { - }; - /** - * Update the layout of the reality elements - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 更新真实布局的显示列表 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LinearLayoutBase.prototype.updateDisplayListReal = function (width, height) { - }; - /** - * Allocate blank area for each variable size element. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 为每个可变尺寸的子项分配空白区域。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - LinearLayoutBase.prototype.flexChildrenProportionally = function (spaceForChildren, spaceToDistribute, totalPercent, childInfoArray) { - var numElements = childInfoArray.length; - var done; - do { - done = true; - var unused = spaceToDistribute - - (spaceForChildren * totalPercent / 100); - if (unused > 0) - spaceToDistribute -= unused; - else - unused = 0; - var spacePerPercent = spaceToDistribute / totalPercent; - for (var i = 0; i < numElements; i++) { - var childInfo = childInfoArray[i]; - var size = childInfo.percent * spacePerPercent; - if (size < childInfo.min) { - var min = childInfo.min; - childInfo.size = min; - childInfoArray[i] = childInfoArray[--numElements]; - childInfoArray[numElements] = childInfo; - totalPercent -= childInfo.percent; - if (unused >= min) { - unused -= min; - } - else { - spaceToDistribute -= min - unused; - unused = 0; - } - done = false; - break; - } - else if (size > childInfo.max) { - var max = childInfo.max; - childInfo.size = max; - childInfoArray[i] = childInfoArray[--numElements]; - childInfoArray[numElements] = childInfo; - totalPercent -= childInfo.percent; - if (unused >= max) { - unused -= max; - } - else { - spaceToDistribute -= max - unused; - unused = 0; - } - done = false; - break; - } - else { - childInfo.size = size; - } - } - } while (!done); - }; - return LinearLayoutBase; - }(eui.LayoutBase)); - eui.LinearLayoutBase = LinearLayoutBase; - __reflect(LinearLayoutBase.prototype, "eui.LinearLayoutBase"); -})(eui || (eui = {})); -(function (eui) { - var sys; - (function (sys) { - /** - * @private - */ - var ChildInfo = (function () { - function ChildInfo() { - /** - * @private - */ - this.layoutElement = null; - /** - * @private - */ - this.size = 0; - /** - * @private - */ - this.percent = NaN; - /** - * @private - */ - this.min = NaN; - /** - * @private - */ - this.max = NaN; - } - return ChildInfo; - }()); - sys.ChildInfo = ChildInfo; - __reflect(ChildInfo.prototype, "eui.sys.ChildInfo"); - })(sys = eui.sys || (eui.sys = {})); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The HSlider (horizontal slider) control lets users select a value - * by moving a slider thumb between the end points of the slider track. - * The current value of the slider is determined by the relative location of the thumb between - * the end points of the slider, corresponding to the slider's minimum and maximum values. - * - * @includeExample extension/eui/components/HSliderExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 使用 HSlider(水平滑块)控件,用户可通过在滑块轨道的端点之间移动滑块来选择值。 - * 滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。 - * - * @includeExample extension/eui/components/HSliderExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var HSlider = (function (_super) { - __extends(HSlider, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function HSlider() { - return _super.call(this) || this; - } - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HSlider.prototype.pointToValue = function (x, y) { - if (!this.thumb || !this.track) - return 0; - var values = this.$Range; - var range = values[0 /* maximum */] - values[2 /* minimum */]; - var thumbRange = this.getThumbRange(); - return values[2 /* minimum */] + (thumbRange != 0 ? (x / thumbRange) * range : 0); - }; - /** - * @private - * - * @returns - */ - HSlider.prototype.getThumbRange = function () { - var bounds = egret.$TempRectangle; - this.track.getLayoutBounds(bounds); - var thumbRange = bounds.width; - this.thumb.getLayoutBounds(bounds); - return thumbRange - bounds.width; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HSlider.prototype.updateSkinDisplayList = function () { - if (!this.thumb || !this.track) - return; - var values = this.$Range; - var thumbRange = this.getThumbRange(); - var range = values[0 /* maximum */] - values[2 /* minimum */]; - var thumbPosTrackX = (range > 0) ? ((this.pendingValue - values[2 /* minimum */]) / range) * thumbRange : 0; - var thumbPos = this.track.localToGlobal(thumbPosTrackX, 0, egret.$TempPoint); - var thumbPosX = thumbPos.x; - var thumbPosY = thumbPos.y; - var thumbPosParentX = this.thumb.$parent.globalToLocal(thumbPosX, thumbPosY, egret.$TempPoint).x; - var bounds = egret.$TempRectangle; - this.thumb.getLayoutBounds(bounds); - this.thumb.setLayoutBoundsPosition(Math.round(thumbPosParentX), bounds.y); - if (this.trackHighlight && this.trackHighlight.$parent) { - var trackHighlightX = this.trackHighlight.$parent.globalToLocal(thumbPosX, thumbPosY, egret.$TempPoint).x - thumbPosTrackX; - this.trackHighlight.x = Math.round(trackHighlightX); - this.trackHighlight.width = Math.round(thumbPosTrackX); - } - }; - return HSlider; - }(eui.SliderBase)); - eui.HSlider = HSlider; - __reflect(HSlider.prototype, "eui.HSlider"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var loaderPool = []; - var callBackMap = {}; - var loaderMap = {}; - /** - * Default instance of interface IAssetAdapter. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/supportClasses/DefaultAssetAdapterExample.ts - * @language en_US - */ - /** - * 默认的IAssetAdapter接口实现。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/supportClasses/DefaultAssetAdapterExample.ts - * @language zh_CN - */ - var DefaultAssetAdapter = (function () { - function DefaultAssetAdapter() { - } - /** - * resolve asset. - * @param source the identifier of new asset need to be resolved - * @param callBack callback function when resolving complete - * example:callBack(content:any,source:string):void; - * @param thisObject this object of callback method - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 解析素材 - * @param source 待解析的新素材标识符 - * @param callBack 解析完成回调函数,示例:callBack(content:any,source:string):void; - * @param thisObject callBack的 this 引用 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - DefaultAssetAdapter.prototype.getAsset = function (source, callBack, thisObject) { - var list = callBackMap[source]; - if (list) { - list.push([callBack, thisObject]); - return; - } - var loader = loaderPool.pop(); - if (!loader) { - loader = new egret.ImageLoader(); - } - callBackMap[source] = [[callBack, thisObject]]; - loaderMap[loader.$hashCode] = source; - loader.addEventListener(egret.Event.COMPLETE, this.onLoadFinish, this); - loader.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onLoadFinish, this); - loader.load(source); - }; - /** - * @private - * - * @param event - */ - DefaultAssetAdapter.prototype.onLoadFinish = function (event) { - var loader = event.currentTarget; - loader.removeEventListener(egret.Event.COMPLETE, this.onLoadFinish, this); - loader.removeEventListener(egret.IOErrorEvent.IO_ERROR, this.onLoadFinish, this); - var data; - if (event.$type == egret.Event.COMPLETE) { - data = new egret.Texture(); - data._setBitmapData(loader.data); - loader.data = null; - } - loaderPool.push(loader); - var source = loaderMap[loader.$hashCode]; - delete loaderMap[loader.$hashCode]; - var list = callBackMap[source]; - delete callBackMap[source]; - var length = list.length; - for (var i = 0; i < length; i++) { - var arr = list[i]; - arr[0].call(arr[1], data, source); - } - }; - return DefaultAssetAdapter; - }()); - eui.DefaultAssetAdapter = DefaultAssetAdapter; - __reflect(DefaultAssetAdapter.prototype, "eui.DefaultAssetAdapter", ["eui.IAssetAdapter"]); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -var eui; -(function (eui) { - /** - * The Image control lets you show JPEG, PNG, and GIF files - * at runtime. Image inherit Bitmap,so you can set the bitmapData property - * to show the data. you can also set the source property, Image will auto load - * and show the url image or the bitmapData. - * - * @event egret.Event.COMPLETE Dispatched when the image loaded complete. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ImageExample.ts - * @language en_US - */ - /** - * Image 控件允许您在运行时显示 JPEG、PNG 等图片文件文件。Image 继承至 Bitmap,因此您可以直接对其 bitmapData 属性, - * 赋值从外部加载得到的位图数据以显示对应图片。同时,Image 还提供了更加方便的 source 属性,source 属性可以接受一个网络图片url作为值, - * 赋值为url后,它内部会自动去加载并显示图片。并且您同样也可以直接把 BitmapData 对象赋值给 source 属性以显示图片。 - * - * @event egret.Event.COMPLETE 当图片加载完成后调度 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ImageExample.ts - * @language zh_CN - */ - var Image = (function (_super) { - __extends(Image, _super); - /** - * Constructor. - * - * @param source The source used for the bitmap fill. the value can be - * a string or an instance of egret.Texture - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @param source 用于位图填充的源。可以是一个字符串或者 egret.Texture 对象 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function Image(source) { - var _this = _super.call(this) || this; - //endif*/ - /** - * @private - */ - _this.sourceChanged = false; - /** - * @private - */ - _this._source = null; - _this.initializeUIValues(); - if (source) { - _this.source = source; - } - return _this; - } - Object.defineProperty(Image.prototype, "scale9Grid", { - /** - * Represent a Rectangle Area that the 9 scale area of Image. - * Notice: This property is valid only when fillMode - * is BitmapFillMode.SCALE. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形区域,它定义素材对象的九个缩放区域。 - * 注意:此属性仅在fillModeBitmapFillMode.SCALE时有效。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$scale9Grid; - }, - set: function (value) { - this.$setScale9Grid(value); - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Image.prototype, "fillMode", { - /** - * Determines how the bitmap fills in the dimensions. - *

      When set to BitmapFillMode.CLIP, the bitmap - * ends at the edge of the region.

      - *

      When set to BitmapFillMode.REPEAT, the bitmap - * repeats to fill the region.

      - *

      When set to BitmapFillMode.SCALE, the bitmap - * stretches to fill the region.

      - * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 确定位图填充尺寸的方式。 - *

      设置为 BitmapFillMode.CLIP时,位图将在边缘处被截断。

      - *

      设置为 BitmapFillMode.REPEAT时,位图将重复以填充区域。

      - *

      设置为 BitmapFillMode.SCALE时,位图将拉伸以填充区域。

      - * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$fillMode; - }, - set: function (value) { - if (value == this.$fillMode) { - return; - } - _super.prototype.$setFillMode.call(this, value); - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - //if egret - Image.prototype.$setFillMode = function (value) { - var result = _super.prototype.$setFillMode.call(this, value); - this.invalidateDisplayList(); - return result; - }; - Object.defineProperty(Image.prototype, "source", { - /** - * The source used for the bitmap fill. the value can be - * a string or an instance of egret.Texture - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 用于位图填充的源。可以是一个字符串或者 egret.Texture 对象 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._source; - }, - set: function (value) { - if (value == this._source) { - return; - } - this._source = value; - if (this.$stage) { - this.parseSource(); - } - else { - this.sourceChanged = true; - this.invalidateProperties(); - } - }, - enumerable: true, - configurable: true - }); - Image.prototype.$setTexture = function (value) { - if (value == this.$texture) { - return false; - } - var result = _super.prototype.$setTexture.call(this, value); - this.sourceChanged = false; - this.invalidateSize(); - this.invalidateDisplayList(); - return result; - }; - /** - * @private - * 解析source - */ - Image.prototype.parseSource = function () { - this.sourceChanged = false; - var source = this._source; - if (source && typeof source == "string") { - eui.getAssets(this._source, function (data) { - if (source !== this._source) - return; - if (!egret.is(data, "egret.Texture")) { - return; - } - this.$setTexture(data); - if (data) { - this.dispatchEventWith(egret.Event.COMPLETE); - } - else if (true) { - egret.$warn(2301, source); - } - }, this); - } - else { - this.$setTexture(source); - } - }; - Image.prototype.$measureContentBounds = function (bounds) { - var image = this.$texture; - if (image) { - var uiValues = this.$UIComponent; - var width = uiValues[10 /* width */]; - var height = uiValues[11 /* height */]; - if (isNaN(width) || isNaN(height)) { - bounds.setEmpty(); - return; - } - if (this.$fillMode == "clip") { - if (width > image.$getTextureWidth()) { - width = image.$getTextureWidth(); - } - if (height > image.$getTextureHeight()) { - height = image.$getTextureHeight(); - } - } - bounds.setTo(0, 0, width, height); - } - else { - bounds.setEmpty(); - } - }; - /** - * @copy eui.UIComponent#createChildren - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.createChildren = function () { - if (this.sourceChanged) { - this.parseSource(); - } - }; - /** - * @private - * 设置组件的宽高。此方法不同于直接设置width,height属性, - * 不会影响显式标记尺寸属性 - */ - Image.prototype.setActualSize = function (w, h) { - eui.sys.UIComponentImpl.prototype["setActualSize"].call(this, w, h); - _super.prototype.$setWidth.call(this, w); - _super.prototype.$setHeight.call(this, h); - }; - /** - * @copy eui.UIComponent#childrenCreated - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.childrenCreated = function () { - }; - /** - * @copy eui.UIComponent#commitProperties - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.commitProperties = function () { - eui.sys.UIComponentImpl.prototype["commitProperties"].call(this); - if (this.sourceChanged) { - this.parseSource(); - } - }; - /** - * @copy eui.UIComponent#measure - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.measure = function () { - var texture = this.$texture; - if (texture) { - this.setMeasuredSize(texture.$getTextureWidth(), texture.$getTextureHeight()); - } - else { - this.setMeasuredSize(0, 0); - } - }; - /** - * @copy eui.UIComponent#updateDisplayList - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - this.$renderDirty = true; - }; - /** - * @copy eui.UIComponent#invalidateParentLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.invalidateParentLayout = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.setMeasuredSize = function (width, height) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.invalidateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.validateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.invalidateSize = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.validateSize = function (recursive) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.invalidateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.validateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.validateNow = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.setLayoutBoundsSize = function (layoutWidth, layoutHeight) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.setLayoutBoundsPosition = function (x, y) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.getLayoutBounds = function (bounds) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Image.prototype.getPreferredBounds = function (bounds) { - }; - return Image; - }(egret.Bitmap)); - eui.Image = Image; - __reflect(Image.prototype, "eui.Image", ["eui.UIComponent", "egret.DisplayObject"]); - eui.sys.implementUIComponent(Image, egret.Bitmap); - eui.registerProperty(Image, "scale9Grid", "egret.Rectangle"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -var eui; -(function (eui) { - /** - * The ItemRenderer class is the base class for item renderers. - * - * @state up Up state - * @state down Down state - * @state upAndSelected Up state when the button is selected - * @state downAndSelected Down state when the button is selected - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ItemRendererExample.ts - * @language en_US - */ - /** - * ItemRenderer 类是项呈示器的基类。 - * - * @state up 弹起状态 - * @state down 按下状态 - * @state upAndSelected 选择时的弹起状态 - * @state downAndSelected 选择时的按下状态 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ItemRendererExample.ts - * @language zh_CN - */ - var ItemRenderer = (function (_super) { - __extends(ItemRenderer, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function ItemRenderer() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this._data = null; - /** - * @private - */ - _this._selected = false; - /** - * The index of the item in the data provider - * of the host component of the item renderer. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 项呈示器的数据提供程序中的项目索引。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.itemIndex = -1; - /** - * @private - * 指示第一次分派 TouchEvent.TOUCH_BEGIN 时,触摸点是否在按钮上。 - */ - _this.touchCaptured = false; - _this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.onTouchBegin, _this); - return _this; - } - Object.defineProperty(ItemRenderer.prototype, "data", { - /** - * The data to render or edit. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要呈示或编辑的数据。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._data; - }, - set: function (value) { - this._data = value; - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "data"); - this.dataChanged(); - }, - enumerable: true, - configurable: true - }); - /** - * Update the view when the data property changes. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当数据改变时,更新视图。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ItemRenderer.prototype.dataChanged = function () { - }; - Object.defineProperty(ItemRenderer.prototype, "selected", { - /** - * Contains true if the item renderer - * can show itself as selected. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果项呈示器可以将其自身显示为已选中,则为 true。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._selected; - }, - set: function (value) { - if (this._selected == value) - return; - this._selected = value; - this.invalidateState(); - }, - enumerable: true, - configurable: true - }); - /** - * Dispatched when an event of some kind occurred that canceled the touch. - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 由于某个事件取消了触摸时触发 - * @version Egret 3.0.1 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ItemRenderer.prototype.onTouchCancle = function (event) { - this.touchCaptured = false; - var stage = event.$currentTarget; - stage.removeEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchCancle, this); - stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onStageTouchEnd, this); - this.invalidateState(); - }; - /** - * Handles TouchEvent.TOUCH_BEGIN events - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触碰开始时触发事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ItemRenderer.prototype.onTouchBegin = function (event) { - if (!this.$stage) { - return; - } - this.$stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchCancle, this); - this.$stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onStageTouchEnd, this); - this.touchCaptured = true; - this.invalidateState(); - event.updateAfterEvent(); - }; - /** - * @private - * 舞台上触摸弹起事件 - */ - ItemRenderer.prototype.onStageTouchEnd = function (event) { - var stage = event.$currentTarget; - stage.removeEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchCancle, this); - stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onStageTouchEnd, this); - this.touchCaptured = false; - this.invalidateState(); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ItemRenderer.prototype.getCurrentState = function () { - var state = "up"; - if (!this.enabled) { - state = "disabled"; - } - if (this.touchCaptured) { - state = "down"; - } - if (this._selected) { - var selectedState = state + "AndSelected"; - var skin = this.skin; - if (skin && skin.hasState(selectedState)) { - return selectedState; - } - return state == "disabled" ? "disabled" : "down"; - } - return state; - }; - return ItemRenderer; - }(eui.Component)); - eui.ItemRenderer = ItemRenderer; - __reflect(ItemRenderer.prototype, "eui.ItemRenderer", ["eui.IItemRenderer"]); - eui.registerBindable(ItemRenderer.prototype, "data"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var UIImpl = eui.sys.UIComponentImpl; - /** - * Label is an UIComponent that can render one or more lines of text. - * The text to be displayed is determined by the text property. - * The formatting of the text is specified by the styles, - * such as fontFamily and size. - * - *

      Because Label is fast and lightweight, it is especially suitable - * for use cases that involve rendering many small pieces of non-interactive - * text, such as item renderers and labels in Button skins.

      - * - *

      In Label, three character sequences are recognized - * as explicit line breaks: CR ("\r"), LF ("\n"), - * and CR+LF ("\r\n").

      - * - *

      If you don't specify any kind of width for a Label, - * then the longest line, as determined by these explicit line breaks, - * determines the width of the Label.

      - * - *

      If you do specify some kind of width, then the specified text is - * word-wrapped at the right edge of the component's bounds. - * If the text extends below the bottom of the component, - * it is clipped.

      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/LabelExample.ts - * @language en_US - */ - /** - * Label 是可以呈示一行或多行统一格式文本的UI组件。要显示的文本由 text 属性确定。文本格式由样式属性指定,例如 fontFamily 和 size。 - * 因为 Label 运行速度快且占用内存少,所以它特别适合用于显示多个小型非交互式文本的情况,例如,项呈示器和 Button 外观中的标签。 - * 在 Label 中,将以下三个字符序列识别为显式换行符:CR(“\r”)、LF(“\n”)和 CR+LF(“\r\n”)。 - * 如果没有为 Label 指定宽度,则由这些显式换行符确定的最长行确定 Label 的宽度。 - * 如果指定了宽度,则指定文本将在组件边界的右边缘换行,如果文本扩展到低于组件底部,则将被剪切。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/LabelExample.ts - * @language zh_CN - */ - var Label = (function (_super) { - __extends(Label, _super); - /** - * Constructor. - * - * @param text The text displayed by this text component. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @param text 此文本组件所显示的文本。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function Label(text) { - var _this = _super.call(this) || this; - /** - * style中属性是否允许被赋值,当主动赋值过属性之后将不允许被赋值 - */ - _this.$styleSetMap = { - "fontFamily": true, - "size": true, - "bold": true, - "italic": true, - "textAlign": true, - "verticalAlign": true, - "lineSpacing": true, - "textColor": true, - "wordWrap": true, - "displayAsPassword": true, - "strokeColor": true, - "stroke": true, - "maxChars": true, - "multiline": true, - "border": true, - "borderColor": true, - "background": true, - "backgroundColor": true - }; - _this.$revertStyle = {}; - _this.$style = null; - _this.$changeFromStyle = false; - /** - * @private - */ - _this._widthConstraint = NaN; - _this.initializeUIValues(); - _this.text = text; - return _this; - } - Object.defineProperty(Label.prototype, "style", { - /** - * The style of text. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 文本样式。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$style; - }, - set: function (value) { - this.$setStyle(value); - }, - enumerable: true, - configurable: true - }); - Label.prototype.$setStyle = function (value) { - if (this.$style == value) { - return; - } - this.$style = value; - var theme = egret.getImplementation("eui.Theme"); - if (theme) { - this.$changeFromStyle = true; - for (var key in this.$revertStyle) { - this[key] = this.$revertStyle[key]; - } - this.$revertStyle = {}; - if (value == null) { - this.$changeFromStyle = false; - return; - } - var styleList = value.split(","); - for (var i = 0; i < styleList.length; i++) { - var config = theme.$getStyleConfig(styleList[i]); - if (config) { - for (var key in config) { - if (this.$styleSetMap[key]) { - var revertValue = this[key]; - this[key] = config[key]; - this.$revertStyle[key] = revertValue; - } - } - } - } - this.$changeFromStyle = false; - } - }; - Label.prototype.$setFontFamily = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["fontFamily"]; - this.$styleSetMap["fontFamily"] = false; - } - return _super.prototype.$setFontFamily.call(this, value); - }; - Label.prototype.$setSize = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["size"]; - this.$styleSetMap["size"] = false; - } - return _super.prototype.$setSize.call(this, value); - }; - Label.prototype.$setBold = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["bold"]; - this.$styleSetMap["bold"] = false; - } - return _super.prototype.$setBold.call(this, value); - }; - Label.prototype.$setItalic = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["italic"]; - this.$styleSetMap["italic"] = false; - } - return _super.prototype.$setItalic.call(this, value); - }; - Label.prototype.$setTextAlign = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["textAlign"]; - this.$styleSetMap["textAlign"] = false; - } - return _super.prototype.$setTextAlign.call(this, value); - }; - Label.prototype.$setVerticalAlign = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["verticalAlign"]; - this.$styleSetMap["verticalAlign"] = false; - } - return _super.prototype.$setVerticalAlign.call(this, value); - }; - Label.prototype.$setLineSpacing = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["lineSpacing"]; - this.$styleSetMap["lineSpacing"] = false; - } - return _super.prototype.$setLineSpacing.call(this, value); - }; - Label.prototype.$setTextColor = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["textColor"]; - this.$styleSetMap["textColor"] = false; - } - return _super.prototype.$setTextColor.call(this, value); - }; - Label.prototype.$setWordWrap = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["wordWrap"]; - this.$styleSetMap["wordWrap"] = false; - } - _super.prototype.$setWordWrap.call(this, value); - }; - Label.prototype.$setDisplayAsPassword = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["displayAsPassword"]; - this.$styleSetMap["displayAsPassword"] = false; - } - return _super.prototype.$setDisplayAsPassword.call(this, value); - }; - Label.prototype.$setStrokeColor = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["strokeColor"]; - this.$styleSetMap["strokeColor"] = false; - } - return _super.prototype.$setStrokeColor.call(this, value); - }; - Label.prototype.$setStroke = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["stroke"]; - this.$styleSetMap["stroke"] = false; - } - return _super.prototype.$setStroke.call(this, value); - }; - Label.prototype.$setMaxChars = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["maxChars"]; - this.$styleSetMap["maxChars"] = false; - } - return _super.prototype.$setMaxChars.call(this, value); - }; - Label.prototype.$setMultiline = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["multiline"]; - this.$styleSetMap["multiline"] = false; - } - return _super.prototype.$setMultiline.call(this, value); - }; - Label.prototype.$setBorder = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["border"]; - this.$styleSetMap["border"] = false; - } - _super.prototype.$setBorder.call(this, value); - }; - Label.prototype.$setBorderColor = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["borderColor"]; - this.$styleSetMap["borderColor"] = false; - } - _super.prototype.$setBorderColor.call(this, value); - }; - Label.prototype.$setBackground = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["background"]; - this.$styleSetMap["background"] = false; - } - _super.prototype.$setBackground.call(this, value); - }; - Label.prototype.$setBackgroundColor = function (value) { - if (!this.$changeFromStyle) { - delete this.$revertStyle["backgroundColor"]; - this.$styleSetMap["backgroundColor"] = false; - } - _super.prototype.$setBackgroundColor.call(this, value); - }; - /** - * @private - * - */ - Label.prototype.$invalidateTextField = function () { - _super.prototype.$invalidateTextField.call(this); - this.invalidateSize(); - }; - /** - * @private - * - * @param value - */ - Label.prototype.$setWidth = function (value) { - var result1 = _super.prototype.$setWidth.call(this, value); - var result2 = UIImpl.prototype.$setWidth.call(this, value); - return result1 && result2; - }; - /** - * @private - * - * @param value - */ - Label.prototype.$setHeight = function (value) { - var result1 = _super.prototype.$setHeight.call(this, value); - var result2 = UIImpl.prototype.$setHeight.call(this, value); - return result1 && result2; - }; - /** - * @private - * - * @param value - */ - Label.prototype.$setText = function (value) { - var result = _super.prototype.$setText.call(this, value); - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "text"); - return result; - }; - /** - * @copy eui.UIComponent#createChildren - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.createChildren = function () { - }; - /** - * @copy eui.UIComponent#childrenCreated - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.childrenCreated = function () { - }; - /** - * @copy eui.UIComponent#commitProperties - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.commitProperties = function () { - }; - /** - * @copy eui.UIComponent#measure - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.measure = function () { - var values = this.$UIComponent; - var textValues = this.$TextField; - var oldWidth = textValues[3 /* textFieldWidth */]; - var availableWidth = NaN; - if (!isNaN(this._widthConstraint)) { - availableWidth = this._widthConstraint; - this._widthConstraint = NaN; - } - else if (!isNaN(values[8 /* explicitWidth */])) { - availableWidth = values[8 /* explicitWidth */]; - } - else if (values[13 /* maxWidth */] != 100000) { - availableWidth = values[13 /* maxWidth */]; - } - _super.prototype.$setWidth.call(this, availableWidth); - this.setMeasuredSize(this.textWidth, this.textHeight); - _super.prototype.$setWidth.call(this, oldWidth); - }; - /** - * @copy eui.UIComponent#updateDisplayList - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - _super.prototype.$setWidth.call(this, unscaledWidth); - _super.prototype.$setHeight.call(this, unscaledHeight); - }; - /** - * @copy eui.UIComponent#invalidateParentLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.invalidateParentLayout = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.setMeasuredSize = function (width, height) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.invalidateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.validateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.invalidateSize = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.validateSize = function (recursive) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.invalidateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.validateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.validateNow = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.setLayoutBoundsSize = function (layoutWidth, layoutHeight) { - UIImpl.prototype.setLayoutBoundsSize.call(this, layoutWidth, layoutHeight); - if (isNaN(layoutWidth) || layoutWidth === this._widthConstraint || layoutWidth == 0) { - this._widthConstraint = layoutWidth; - return; - } - this._widthConstraint = layoutWidth; - var values = this.$UIComponent; - if (!isNaN(values[9 /* explicitHeight */])) { - return; - } - if (layoutWidth == values[16 /* measuredWidth */]) { - return; - } - this.invalidateSize(); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.setLayoutBoundsPosition = function (x, y) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.getLayoutBounds = function (bounds) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Label.prototype.getPreferredBounds = function (bounds) { - }; - return Label; - }(egret.TextField)); - eui.Label = Label; - __reflect(Label.prototype, "eui.Label", ["eui.UIComponent", "egret.DisplayObject", "eui.IDisplayText"]); - eui.sys.implementUIComponent(Label, egret.TextField); - eui.registerBindable(Label.prototype, "text"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The List control displays a vertical or horizontal list of items. - * The user can select one or more items from the list, depending - * on the value of the allowMultipleSelection property. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ListExample.ts - * @language en_US - */ - /** - * List 控件可显示垂直或水平的项目列表。用户可以根据 allowMultipleSelection 属性的值从列表中选择一个或多个项目。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ListExample.ts - * @language zh_CN - */ - var List = (function (_super) { - __extends(List, _super); - function List() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * whether are allowed to multiple selection. - * If true tap an unselected item will be selected, - * and tap the item again will cancel selection. - * - * @default false - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 是否允许同时选中多项,设置为 true 时,触摸按下未选中的项呈示器,将会设置该项选中,再次按下将会取消选中。 - * 可以设置多项为选中状态。 - * - * @default false - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.allowMultipleSelection = false; - /** - * @private - */ - _this._selectedIndices = []; - /** - * @private - * 是否是有效的索引 - */ - _this.isValidIndex = function (item, index, v) { - return _this.$dataProvider && (item >= 0) && (item < _this.$dataProvider.length) && item % 1 == 0; - }; - return _this; - } - Object.defineProperty(List.prototype, "selectedIndices", { - /** - * An Array of numbers representing the indices of the currently selected - * item or items. - * - * @default [] - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当前选中的一个或多个项目的索引列表。 - * - * @default [] - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - if (this._proposedSelectedIndices) - return this._proposedSelectedIndices; - return this._selectedIndices; - }, - set: function (value) { - this.setSelectedIndices(value, false); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(List.prototype, "selectedIndex", { - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - if (this._proposedSelectedIndices) { - if (this._proposedSelectedIndices.length > 0) - return this._proposedSelectedIndices[0]; - return -1; - } - return this.$getSelectedIndex(); - }, - set: function (value) { - this.setSelectedIndex(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(List.prototype, "selectedItems", { - /** - * An Array representing the currently selected data items. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 表示当前选定数据项的列表 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - var result = []; - var list = this.selectedIndices; - if (list) { - var count = list.length; - for (var i = 0; i < count; i++) { - result[i] = this.$dataProvider.getItemAt(list[i]); - } - } - return result; - }, - set: function (value) { - var indices = []; - if (value) { - var count = value.length; - for (var i = 0; i < count; i++) { - var index = this.$dataProvider.getItemIndex(value[i]); - if (index != -1) { - indices.splice(0, 0, index); - } - if (index == -1) { - indices = []; - break; - } - } - } - this.setSelectedIndices(indices, false); - }, - enumerable: true, - configurable: true - }); - /** - * Specify whether the selectedIndices changed programmatically or due to - * user interaction. - * - * @param value An array of numbers representing the indices of the selected - * @param dispatchChangeEvent whether dispatched a change event. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置多个选中项。 - * - * @param value 选中项索引的数组 - * @param dispatchChangeEvent 是否派发changed事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - List.prototype.setSelectedIndices = function (value, dispatchChangeEvent) { - var values = this.$ListBase; - if (dispatchChangeEvent) - values[4 /* dispatchChangeAfterSelection */] = - (values[4 /* dispatchChangeAfterSelection */] || dispatchChangeEvent); - if (value) - this._proposedSelectedIndices = value; - else - this._proposedSelectedIndices = []; - this.invalidateProperties(); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - List.prototype.commitProperties = function () { - _super.prototype.commitProperties.call(this); - if (this._proposedSelectedIndices) { - this.commitSelection(); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - List.prototype.commitSelection = function (dispatchChangedEvents) { - if (dispatchChangedEvents === void 0) { dispatchChangedEvents = true; } - var values = this.$ListBase; - var oldSelectedIndex = values[3 /* selectedIndex */]; - if (this._proposedSelectedIndices) { - this._proposedSelectedIndices = this._proposedSelectedIndices.filter(this.isValidIndex); - if (!this.allowMultipleSelection && this._proposedSelectedIndices.length > 0) { - var temp = []; - temp.push(this._proposedSelectedIndices[0]); - this._proposedSelectedIndices = temp; - } - if (this._proposedSelectedIndices.length > 0) { - values[2 /* proposedSelectedIndex */] = this._proposedSelectedIndices[0]; - } - else { - values[2 /* proposedSelectedIndex */] = -1; - } - } - var retVal = _super.prototype.commitSelection.call(this, false); - if (!retVal) { - this._proposedSelectedIndices = null; - return false; - } - var selectedIndex = this.$getSelectedIndex(); - if (selectedIndex > eui.ListBase.NO_SELECTION) { - if (this._proposedSelectedIndices) { - if (this._proposedSelectedIndices.indexOf(selectedIndex) == -1) - this._proposedSelectedIndices.push(selectedIndex); - } - else { - this._proposedSelectedIndices = [selectedIndex]; - } - } - if (this._proposedSelectedIndices) { - if (this._proposedSelectedIndices.indexOf(oldSelectedIndex) != -1) - this.itemSelected(oldSelectedIndex, true); - this.commitMultipleSelection(); - } - if (dispatchChangedEvents && retVal) { - if (values[4 /* dispatchChangeAfterSelection */]) { - this.dispatchEventWith(egret.Event.CHANGE); - values[4 /* dispatchChangeAfterSelection */] = false; - } - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "selectedIndex"); - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "selectedItem"); - } - return retVal; - }; - /** - * Given a new selection interval, figure out which - * items are newly added/removed from the selection interval and update - * selection properties and view accordingly. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 从给定的选择区间中找出新增或者移除的项,并更新属性。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - List.prototype.commitMultipleSelection = function () { - var removedItems = []; - var addedItems = []; - var i; - var count; - var selectedIndices = this._selectedIndices; - var proposedSelectedIndices = this._proposedSelectedIndices; - if (selectedIndices.length > 0 && proposedSelectedIndices.length > 0) { - count = proposedSelectedIndices.length; - for (i = 0; i < count; i++) { - if (selectedIndices.indexOf(proposedSelectedIndices[i]) == -1) - addedItems.push(proposedSelectedIndices[i]); - } - count = selectedIndices.length; - for (i = 0; i < count; i++) { - if (proposedSelectedIndices.indexOf(selectedIndices[i]) == -1) - removedItems.push(selectedIndices[i]); - } - } - else if (selectedIndices.length > 0) { - removedItems = selectedIndices; - } - else if (proposedSelectedIndices.length > 0) { - addedItems = proposedSelectedIndices; - } - this._selectedIndices = proposedSelectedIndices; - if (removedItems.length > 0) { - count = removedItems.length; - for (i = 0; i < count; i++) { - this.itemSelected(removedItems[i], false); - } - } - if (addedItems.length > 0) { - count = addedItems.length; - for (i = 0; i < count; i++) { - this.itemSelected(addedItems[i], true); - } - } - this._proposedSelectedIndices = null; - }; - /** - * @private - * - * @param index - * @returns - */ - List.prototype.$isItemIndexSelected = function (index) { - if (this.allowMultipleSelection) - return this._selectedIndices.indexOf(index) != -1; - return _super.prototype.$isItemIndexSelected.call(this, index); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - List.prototype.dataProviderRefreshed = function () { - if (this.allowMultipleSelection) { - return; - } - _super.prototype.dataProviderRefreshed.call(this); - }; - /** - * @private - * 计算当前的选中项列表 - */ - List.prototype.calculateSelectedIndices = function (index) { - var interval = []; - var selectedIndices = this._selectedIndices; - var length = selectedIndices.length; - if (length > 0) { - if (length == 1 && (selectedIndices[0] == index)) { - if (!this.$ListBase[0 /* requireSelection */]) { - return interval; - } - interval.splice(0, 0, selectedIndices[0]); - return interval; - } - else { - var found = false; - for (var i = 0; i < length; i++) { - if (selectedIndices[i] == index) { - found = true; - } - else if (selectedIndices[i] != index) { - interval.splice(0, 0, selectedIndices[i]); - } - } - if (!found) { - interval.splice(0, 0, index); - } - return interval; - } - } - else { - interval.splice(0, 0, index); - return interval; - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - List.prototype.onRendererTouchEnd = function (event) { - if (this.allowMultipleSelection) { - var itemRenderer = (event.currentTarget); - var touchDownItemRenderer = this.$ListBase[7 /* touchDownItemRenderer */]; - if (itemRenderer != touchDownItemRenderer) - return; - this.setSelectedIndices(this.calculateSelectedIndices(itemRenderer.itemIndex), true); - eui.ItemTapEvent.dispatchItemTapEvent(this, eui.ItemTapEvent.ITEM_TAP, itemRenderer); - } - else { - _super.prototype.onRendererTouchEnd.call(this, event); - } - }; - return List; - }(eui.ListBase)); - eui.List = List; - __reflect(List.prototype, "eui.List"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The Panel class defines a container that includes a title bar, - * a closeButton, a moveArea, and a content area for its children. - * - * @event eui.UIEvent.CLOSING Dispatched when the close button is taped - * you can use event.preventDefault() to prevent close. - * - * @defaultProperty elementsContent - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/PanelExample.ts - * @language en_US - */ - /** - * Panel 类定义一个容器,该容器为其子代提供标题栏、关闭按钮、可移动区域和内容区域。 - * - * @event eui.UIEvent.CLOSING 面板即将关闭事件,在关闭按钮被点击后抛出, - * 监听此事件并调用event.preventDefault()能够阻止面板被关闭。 - * - * @defaultProperty elementsContent - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/PanelExample.ts - * @language zh_CN - */ - var Panel = (function (_super) { - __extends(Panel, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function Panel() { - var _this = _super.call(this) || this; - /** - * The skin part that defines the appearance of the close button. - * When taped, the close button dispatches a closing event. - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭按钮 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.closeButton = null; - /** - * The area where the user must drag to move the window. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 可移动区域 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.moveArea = null; - /** - * The skin part that defines the appearance of the - * title text in the container. - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 标题显示对象 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.titleDisplay = null; - /** - * @private - */ - _this._title = ""; - /** - * @private - * 触摸按下时的偏移量 - */ - _this.offsetPointX = 0; - /** - * @private - */ - _this.offsetPointY = 0; - _this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.onWindowTouchBegin, _this, false, 100); - return _this; - } - /** - * @private - * 在窗体上按下时前置窗口 - */ - Panel.prototype.onWindowTouchBegin = function (event) { - this.$parent.addChild(this); - }; - Object.defineProperty(Panel.prototype, "elementsContent", { - /** - * write-only property,This property is Usually invoked in resolving an EXML for adding multiple children quickly. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 只写属性,此属性通常在 EXML 的解析器中调用,便于快速添加多个子项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - set: function (value) { - if (value) { - var length_25 = value.length; - for (var i = 0; i < length_25; i++) { - this.addChild(value[i]); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Panel.prototype, "title", { - /** - * Title or caption displayed in the title bar. - * - * @default "" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 标题栏中显示的标题。 - * - * @default "" - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._title; - }, - set: function (value) { - this._title = value; - if (this.titleDisplay) - this.titleDisplay.text = this.title; - }, - enumerable: true, - configurable: true - }); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Panel.prototype.partAdded = function (partName, instance) { - _super.prototype.partAdded.call(this, partName, instance); - if (instance == this.titleDisplay) { - this.titleDisplay.text = this._title; - } - else if (instance == this.moveArea) { - this.moveArea.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this); - } - else if (instance == this.closeButton) { - this.closeButton.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onCloseButtonClick, this); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Panel.prototype.partRemoved = function (partName, instance) { - _super.prototype.partRemoved.call(this, partName, instance); - if (instance == this.moveArea) { - this.moveArea.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this); - } - else if (instance == this.closeButton) { - this.closeButton.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onCloseButtonClick, this); - } - }; - /** - * Dispatch the "closing" event when the closeButton is clicked. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当 closeButton 被点击时派发 “closing” 事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Panel.prototype.onCloseButtonClick = function (event) { - if (eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CLOSING, true, true)) { - this.close(); - } - }; - /** - * Close the panel and remove from the parent container. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭面板,从父级容器移除自身。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Panel.prototype.close = function () { - if (!this.$parent) { - return; - } - this.$parent.removeChild(this); - }; - /** - * Called when the user starts dragging a Panel. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在可移动区域按下 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Panel.prototype.onTouchBegin = function (event) { - this.$includeInLayout = false; - this.offsetPointX = this.x - event.$stageX; - this.offsetPointY = this.y - event.$stageY; - this.$stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouchMove, this); - this.$stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this); - }; - /** - * Called when the user drags a Panel. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触摸拖拽时的移动事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Panel.prototype.onTouchMove = function (event) { - this.x = event.$stageX + this.offsetPointX; - this.y = event.$stageY + this.offsetPointY; - }; - /** - * Called when the user releases the Panel. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在舞台上弹起事件 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Panel.prototype.onTouchEnd = function (event) { - var stage = event.$currentTarget; - stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouchMove, this); - stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this); - }; - return Panel; - }(eui.Component)); - eui.Panel = Panel; - __reflect(Panel.prototype, "eui.Panel"); - eui.registerProperty(Panel, "elementsContent", "Array", true); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The ProgressBar control provides a visual representation of the progress of a task over time. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ProgressBarExample.ts - * @language en_US - */ - /** - * ProgressBar 控件为随时间而变的任务进度提供了形象化的表示。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ProgressBarExample.ts - * @language zh_CN - */ - var ProgressBar = (function (_super) { - __extends(ProgressBar, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function ProgressBar() { - var _this = _super.call(this) || this; - /** - * this hightlight component of the progressbar. - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 进度高亮显示对象。 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.thumb = null; - /** - * the label of the progressbar. - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 进度条文本 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.labelDisplay = null; - /** - * @private - */ - _this._labelFunction = null; - /** - * @private - */ - _this._slideDuration = 500; - /** - * @private - */ - _this._direction = eui.Direction.LTR; - /** - * @private - * 动画播放结束时要到达的value。 - */ - _this.slideToValue = 0; - /** - * @private - */ - _this.animationValue = 0; - /** - * @private - */ - _this.thumbInitX = 0; - /** - * @private - */ - _this.thumbInitY = 0; - _this.animation = new eui.sys.Animation(_this.animationUpdateHandler, _this); - return _this; - } - Object.defineProperty(ProgressBar.prototype, "labelFunction", { - /** - * a text format callback function。example: - * labelFunction(value:Number,maximum:Number):String; - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 进度条文本格式化回调函数。示例: - * labelFunction(value:Number,maximum:Number):String; - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._labelFunction; - }, - set: function (value) { - if (this._labelFunction == value) - return; - this._labelFunction = value; - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - /** - * Convert the current value to display text - * - * @param value the current value - * @param maximum the maximum value - * - * @return a converted text - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 将当前value转换成文本 - * - * @param value 当前值 - * @param maximum 最大值 - * - * @return 转换后的文本 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ProgressBar.prototype.valueToLabel = function (value, maximum) { - if (this.labelFunction != null) { - return this._labelFunction(value, maximum); - } - return value + " / " + maximum; - }; - Object.defineProperty(ProgressBar.prototype, "slideDuration", { - /** - * Duration in milliseconds for a sliding animation - * when the value changing. If the vlaue is 0, no animation will be done. - * - * @default 500 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * value改变时更新视图的缓动动画时间(毫秒为单位)。设置为0则不执行缓动。 - * - * @default 500 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._slideDuration; - }, - set: function (value) { - value = +value | 0; - if (this._slideDuration === value) - return; - this._slideDuration = value; - if (this.animation.isPlaying) { - this.animation.stop(); - this.setValue(this.slideToValue); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ProgressBar.prototype, "direction", { - /** - * Direction in which the fill of the ProgressBar expands toward completion. - * you should use the Direction class constants to set the property. - * - * @default Direction.LTR - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * ProgressBar 填充在逐步完成过程中扩展的方向。使用 Direction 类定义的常量。 - * - * @default Direction.LTR - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._direction; - }, - set: function (value) { - if (this._direction == value) - return; - if (this.thumb) - this.thumb.x = this.thumbInitX; - if (this.thumb) - this.thumb.y = this.thumbInitY; - this._direction = value; - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param newValue - */ - ProgressBar.prototype.$setValue = function (newValue) { - if (this.value === newValue) - return false; - var values = this.$Range; - var result = _super.prototype.$setValue.call(this, newValue); - if (this._slideDuration > 0 && this.$stage) { - this.validateProperties(); //最大值最小值发生改变时要立即应用,防止当前起始值不正确。 - var animation = this.animation; - if (animation.isPlaying) { - this.animationValue = this.slideToValue; - this.invalidateDisplayList(); - animation.stop(); - } - this.slideToValue = this.nearestValidValue(newValue, values[7 /* snapInterval */]); - if (this.slideToValue === this.animationValue) - return result; - var duration = this._slideDuration * - (Math.abs(this.animationValue - this.slideToValue) / (values[0 /* maximum */] - values[2 /* minimum */])); - animation.duration = duration === Infinity ? 0 : duration; - animation.from = this.animationValue; - animation.to = this.slideToValue; - animation.play(); - } - else { - this.animationValue = this.value; - } - return result; - }; - /** - * @private - * 动画播放更新数值 - */ - ProgressBar.prototype.animationUpdateHandler = function (animation) { - var values = this.$Range; - var value = this.nearestValidValue(animation.currentValue, values[7 /* snapInterval */]); - this.animationValue = Math.min(values[0 /* maximum */], Math.max(values[2 /* minimum */], value)); - this.invalidateDisplayList(); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ProgressBar.prototype.partAdded = function (partName, instance) { - _super.prototype.partAdded.call(this, partName, instance); - if (instance === this.thumb) { - if (this.thumb.x) - this.thumbInitX = this.thumb.x; - if (this.thumb.y) - this.thumbInitY = this.thumb.y; - this.thumb.addEventListener(egret.Event.RESIZE, this.onThumbResize, this); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ProgressBar.prototype.partRemoved = function (partName, instance) { - _super.prototype.partRemoved.call(this, partName, instance); - if (instance === this.thumb) { - this.thumb.removeEventListener(egret.Event.RESIZE, this.onThumbResize, this); - } - }; - /** - * @private - * thumb的位置或尺寸发生改变 - */ - ProgressBar.prototype.onThumbResize = function (event) { - this.updateSkinDisplayList(); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ProgressBar.prototype.updateSkinDisplayList = function () { - var currentValue = this.animation.isPlaying ? this.animationValue : this.value; - var maxValue = this.maximum; - var thumb = this.thumb; - if (thumb) { - var thumbWidth = thumb.width; - var thumbHeight = thumb.height; - var clipWidth = Math.round((currentValue / maxValue) * thumbWidth); - if (clipWidth < 0 || clipWidth === Infinity) - clipWidth = 0; - var clipHeight = Math.round((currentValue / maxValue) * thumbHeight); - if (clipHeight < 0 || clipHeight === Infinity) - clipHeight = 0; - var rect = thumb.$scrollRect; - if (!rect) { - rect = egret.$TempRectangle; - } - rect.setTo(0, 0, thumbWidth, thumbHeight); - var thumbPosX = thumb.x - rect.x; - var thumbPosY = thumb.y - rect.y; - switch (this._direction) { - case eui.Direction.LTR: - rect.width = clipWidth; - thumb.x = thumbPosX; - break; - case eui.Direction.RTL: - rect.width = clipWidth; - rect.x = thumbWidth - clipWidth; - thumb.x = rect.x; - break; - case eui.Direction.TTB: - rect.height = clipHeight; - thumb.y = thumbPosY; - break; - case eui.Direction.BTT: - rect.height = clipHeight; - rect.y = thumbHeight - clipHeight; - thumb.y = rect.y; - break; - } - thumb.scrollRect = rect; - } - if (this.labelDisplay) { - this.labelDisplay.text = this.valueToLabel(currentValue, maxValue); - } - }; - return ProgressBar; - }(eui.Range)); - eui.ProgressBar = ProgressBar; - __reflect(ProgressBar.prototype, "eui.ProgressBar"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * @private - * 存储根据groupName自动创建的RadioButtonGroup列表 - */ - var automaticRadioButtonGroups = {}; - /** - * The RadioButton component allows the user make a single choice - * within a set of mutually exclusive choices. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/RadioButtonExample.ts - * @language en_US - */ - /** - * RadioButton 组件使用户可在一组互相排斥的选择中做出一种选择 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/RadioButtonExample.ts - * @language zh_CN - */ - var RadioButton = (function (_super) { - __extends(RadioButton, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function RadioButton() { - var _this = _super.call(this) || this; - /** - * @private - * 在RadioButtonGroup中的索引 - */ - _this.$indexNumber = 0; - /** - * @private - * 所属的RadioButtonGroup - */ - _this.$radioButtonGroup = null; - /** - * @private - */ - _this._group = null; - /** - * @private - */ - _this.groupChanged = false; - /** - * @private - */ - _this._groupName = "radioGroup"; - /** - * @private - */ - _this._value = null; - _this.groupName = "radioGroup"; - return _this; - } - Object.defineProperty(RadioButton.prototype, "enabled", { - /** - * The RadioButton component is enabled if the - * RadioButtonGroup is enabled and the RadioButton itself is enabled. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果 RadioButtonGroup 启用且 RadioButton 本身也启用,则 RadioButton 组件启用。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - if (!this.$Component[3 /* enabled */]) { - return false; - } - return !this.$radioButtonGroup || - this.$radioButtonGroup.$enabled; - }, - set: function (value) { - this.$setEnabled(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RadioButton.prototype, "group", { - /** - * The RadioButtonGroup component to which this RadioButton belongs. - * If this property is not set, - * a unique RadioButtonGroup is created automatically based on the groupName property. - * - * @see eui.RadioButton#groupName - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此 RadioButton 所属的 RadioButtonGroup 组件。 - * 若不设置此属性,则根据groupName属性自动创建一个唯一的RadioButtonGroup。 - * - * @see eui.RadioButton#groupName - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - if (!this._group && this._groupName) { - var g = automaticRadioButtonGroups[this._groupName]; - if (!g) { - g = new eui.RadioButtonGroup(); - g.$name = this._groupName; - automaticRadioButtonGroups[this._groupName] = g; - } - this._group = g; - } - return this._group; - }, - set: function (value) { - if (this._group == value) - return; - if (this.$radioButtonGroup) - this.$radioButtonGroup.$removeInstance(this, false); - this._group = value; - this._groupName = value ? this.group.$name : "radioGroup"; - this.groupChanged = true; - this.invalidateProperties(); - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RadioButton.prototype, "groupName", { - /** - * Specifies the name of the group to which this RadioButton component belongs - * - * @default “radioGroup” - * - * @see eui.RadioButton#group - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * RadioButton 组件所属的组的名称 - * - * @default “radioGroup” - * - * @see eui.RadioButton#group - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._groupName; - }, - set: function (value) { - if (!value || value == "") - return; - this._groupName = value; - if (this.$radioButtonGroup) - this.$radioButtonGroup.$removeInstance(this, false); - this._group = null; - this.groupChanged = true; - this.invalidateProperties(); - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - RadioButton.prototype.$setSelected = function (value) { - var result = _super.prototype.$setSelected.call(this, value); - this.invalidateDisplayList(); - return result; - }; - Object.defineProperty(RadioButton.prototype, "value", { - /** - * Optional user-defined value - * that is associated with a RadioButton component. - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 与 RadioButton 组件关联的可选用户定义值。 - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._value; - }, - set: function (value) { - if (this._value == value) - return; - this._value = value; - if (this.$selected && this.group) { - eui.PropertyEvent.dispatchPropertyEvent(this.group, eui.PropertyEvent.PROPERTY_CHANGE, "selectedValue"); - } - }, - enumerable: true, - configurable: true - }); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - RadioButton.prototype.commitProperties = function () { - if (this.groupChanged) { - this.addToGroup(); - this.groupChanged = false; - } - _super.prototype.commitProperties.call(this); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - RadioButton.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - _super.prototype.updateDisplayList.call(this, unscaledWidth, unscaledHeight); - if (this.group) { - if (this.$selected) - this._group.$setSelection(this, false); - else if (this.group.selection == this) - this._group.$setSelection(null, false); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - RadioButton.prototype.buttonReleased = function () { - if (!this.enabled || this.selected) - return; - if (!this.$radioButtonGroup) - this.addToGroup(); - _super.prototype.buttonReleased.call(this); - this.group.$setSelection(this, true); - }; - /** - * @private - * 添此单选按钮加到组 - */ - RadioButton.prototype.addToGroup = function () { - var g = this.group; - if (g) - g.$addInstance(this); - return g; - }; - return RadioButton; - }(eui.ToggleButton)); - eui.RadioButton = RadioButton; - __reflect(RadioButton.prototype, "eui.RadioButton"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var groupCount = 0; - /** - * @private - * 显示列表深度排序 - */ - function breadthOrderCompare(a, b) { - var aParent = a.parent; - var bParent = b.parent; - if (!aParent || !bParent) - return 0; - var aNestLevel = a.$nestLevel; - var bNestLevel = b.$nestLevel; - var aIndex = 0; - var bIndex = 0; - if (aParent == bParent) { - aIndex = aParent.getChildIndex(a); - bIndex = bParent.getChildIndex(b); - } - if (aNestLevel > bNestLevel || aIndex > bIndex) - return 1; - if (aNestLevel < bNestLevel || bIndex > aIndex) - return -1; - if (a == b) - return 0; - return breadthOrderCompare(aParent, bParent); - } - /** - * The RadioButtonGroup component defines a group of RadioButton components - * that act as a single mutually exclusive component; therefore, - * a user can select only one RadioButton component at a time. - * - * @event egret.Event.CHANGE Dispatched when the value of the selected RadioButton component in - * this group changes. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/RadioButtonGroupExample.ts - * @language en_US - */ - /** - * RadioButtonGroup 组件定义一组 RadioButton 组件,这些组件相互排斥;因此,用户每次只能选择一个 RadioButton 组件 - * - * @event egret.Event.CHANGE 此组中所选 RadioButton 组件的值更改时分派。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/RadioButtonGroupExample.ts - * @language zh_CN - */ - var RadioButtonGroup = (function (_super) { - __extends(RadioButtonGroup, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function RadioButtonGroup() { - var _this = _super.call(this) || this; - /** - * @private - * 组名 - */ - _this.$name = null; - /** - * @private - * 单选按钮列表 - */ - _this.radioButtons = []; - /** - * @private - */ - _this.$enabled = true; - /** - * @private - */ - _this._selectedValue = null; - /** - * @private - */ - _this._selection = null; - _this.$name = "_radioButtonGroup" + groupCount++; - return _this; - } - /** - * Returns the RadioButton component at the specified index. - * - * @param index The 0-based index of the RadioButton in the - * RadioButtonGroup. - * - * @return The specified RadioButton component if index is between - * 0 and numRadioButtons - 1. Returns - * null if the index is invalid. - * - * @see eui.RadioButtonGroup#numRadioButtons - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 返回指定索引处的 RadioButton 组件。 - * - * @param index RadioButtonGroup 中的 RadioButton 的从零开始的索引。 - * - * @return 当索引位于 0 和 numRadioButtons 之间时,指定的 RadioButton 组件为 1。 - * 如果索引无效,则返回 null。 - * - * @see eui.RadioButtonGroup#numRadioButtons - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - RadioButtonGroup.prototype.getRadioButtonAt = function (index) { - return this.radioButtons[index]; - }; - Object.defineProperty(RadioButtonGroup.prototype, "enabled", { - /** - * Determines whether selection is allowed. Note that the value returned - * only reflects the value that was explicitly set on the - * RadioButtonGroup and does not reflect any values explicitly - * set on the individual RadioButtons. - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 确定是否允许选择。请注意,返回的值仅反映对 RadioButtonGroup 显式设置的值, - * 而不反映对各个 RadioButton 显式设置的任何值。 - * - * @default true - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$enabled; - }, - set: function (value) { - value = !!value; - if (this.$enabled === value) - return; - this.$enabled = value; - var buttons = this.radioButtons; - var length = buttons.length; - for (var i = 0; i < length; i++) - buttons[i].invalidateState(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RadioButtonGroup.prototype, "numRadioButtons", { - /** - * The number of RadioButtons that belong to this RadioButtonGroup. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 属于此 RadioButtonGroup 的 RadioButton 数。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.radioButtons.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RadioButtonGroup.prototype, "selectedValue", { - /** - * The value property of the selected - * RadioButton component in the group, if it has been set, - * otherwise, the label property of the selected RadioButton. - * If no RadioButton is selected, this property is null. - * - *

      If you set selectedValue, selects the - * first RadioButton component whose value or - * label property matches this value.

      - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组中所选 RadioButton 组件的 value 属性(如果未设置), - * 否则为所选 RadioButton 组件的 label 属性。 - * 如果未选择任何 RadioButton,则此属性为 null。 - * - *

      如果设置了 selectedValue,则会选择 valuelabel 属性 - * 与此值匹配的第一个 RadioButton 组件。

      - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - if (this.selection) { - return this.selection.value != null ? - this.selection.value : - this.selection.label; - } - return null; - }, - set: function (value) { - this._selectedValue = value; - if (value == null) { - this.$setSelection(null, false); - return; - } - var n = this.numRadioButtons; - for (var i = 0; i < n; i++) { - var radioButton = this.radioButtons[i]; - if (radioButton.value == value || - radioButton.label == value) { - this.changeSelection(i, false); - this._selectedValue = null; - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "selectedValue"); - break; - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RadioButtonGroup.prototype, "selection", { - /** - * Contains a reference to the currently selected - * RadioButton component in the group.This property is valid only - * when the target RadioButton is displayed on the display list - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当前被选中的单选按钮引用。此属性仅当目标RadioButton在显示列表时有效。 - * - * @default null - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._selection; - }, - set: function (value) { - if (this._selection == value) - return; - this.$setSelection(value, false); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 添加单选按钮到组内 - */ - RadioButtonGroup.prototype.$addInstance = function (instance) { - instance.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.removedHandler, this); - var buttons = this.radioButtons; - buttons.push(instance); - buttons.sort(breadthOrderCompare); - var length = buttons.length; - for (var i = 0; i < length; i++) { - buttons[i].$indexNumber = i; - } - if (this._selectedValue) - this.selectedValue = this._selectedValue; - if (instance.selected == true) - this.selection = instance; - instance.$radioButtonGroup = this; - instance.invalidateState(); - }; - /** - * @private - * 从组里移除单选按钮 - */ - RadioButtonGroup.prototype.$removeInstance = function (instance, addListener) { - if (instance) { - var foundInstance = false; - var buttons = this.radioButtons; - var length_26 = buttons.length; - for (var i = 0; i < length_26; i++) { - var rb = buttons[i]; - if (foundInstance) { - rb.$indexNumber = rb.$indexNumber - 1; - } - else if (rb == instance) { - if (addListener) - instance.addEventListener(egret.Event.ADDED_TO_STAGE, this.addedHandler, this); - if (instance == this._selection) - this._selection = null; - instance.$radioButtonGroup = null; - instance.invalidateState(); - this.radioButtons.splice(i, 1); - foundInstance = true; - i--; - length_26--; - } - } - } - }; - /** - * @private - * 设置选中的单选按钮 - */ - RadioButtonGroup.prototype.$setSelection = function (value, fireChange) { - if (this._selection == value) - return false; - if (!value) { - if (this._selection) { - this._selection.selected = false; - this._selection = null; - if (fireChange) - this.dispatchEventWith(egret.Event.CHANGE); - } - } - else { - var n = this.numRadioButtons; - for (var i = 0; i < n; i++) { - if (value == this.getRadioButtonAt(i)) { - this.changeSelection(i, fireChange); - break; - } - } - } - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "selectedValue"); - return true; - }; - /** - * @private - * 改变选中项 - */ - RadioButtonGroup.prototype.changeSelection = function (index, fireChange) { - var rb = this.getRadioButtonAt(index); - if (rb && rb != this._selection) { - if (this._selection) - this._selection.selected = false; - this._selection = rb; - this._selection.selected = true; - if (fireChange) - this.dispatchEventWith(egret.Event.CHANGE); - } - }; - /** - * @private - * 单选按钮添加到显示列表 - */ - RadioButtonGroup.prototype.addedHandler = function (event) { - var rb = event.target; - if (rb == event.currentTarget) { - rb.removeEventListener(egret.Event.ADDED_TO_STAGE, this.addedHandler, this); - this.$addInstance(rb); - } - }; - /** - * @private - * 单选按钮从显示列表移除 - */ - RadioButtonGroup.prototype.removedHandler = function (event) { - var rb = event.target; - if (rb == event.currentTarget) { - rb.removeEventListener(egret.Event.REMOVED_FROM_STAGE, this.removedHandler, this); - this.$removeInstance(rb, true); - } - }; - return RadioButtonGroup; - }(egret.EventDispatcher)); - eui.RadioButtonGroup = RadioButtonGroup; - __reflect(RadioButtonGroup.prototype, "eui.RadioButtonGroup"); - eui.registerBindable(RadioButtonGroup.prototype, "selectedValue"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The Rect component is a rectangular shape. It can be touched. - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * Rect 组件矩形绘图元素。此组件可响应鼠标事件。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var Rect = (function (_super) { - __extends(Rect, _super); - function Rect(width, height, fillColor) { - var _this = _super.call(this) || this; - _this.$fillColor = 0x000000; - _this.$fillAlpha = 1; - _this.$strokeColor = 0x444444; - _this.$strokeAlpha = 1; - _this.$strokeWeight = 0; - _this.$ellipseWidth = 0; - _this.$ellipseHeight = 0; - _this.touchChildren = false; - _this.$graphics = new egret.Graphics(); - _this.$graphics.$setTarget(_this); - _this.width = width; - _this.height = height; - _this.fillColor = fillColor; - return _this; - } - Rect.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(8 /* GRAPHICS */); - }; - Object.defineProperty(Rect.prototype, "graphics", { - get: function () { - return this.$graphics; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - Rect.prototype.$measureContentBounds = function (bounds) { - if (this.$graphics) { - bounds.setTo(0, 0, this.width, this.height); - } - }; - Object.defineProperty(Rect.prototype, "fillColor", { - /** - * Fill color - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 填充颜色 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$fillColor; - }, - set: function (value) { - if (value == undefined || this.$fillColor == value) - return; - this.$fillColor = value; - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rect.prototype, "fillAlpha", { - /** - * Fill alpha - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 填充透明度,默认值为1。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$fillAlpha; - }, - set: function (value) { - if (this.$fillAlpha == value) - return; - this.$fillAlpha = value; - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rect.prototype, "strokeColor", { - /** - * The line's color inside the rect border. Caution: when the strokeWeight is 0, a line is not drawn - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 边框颜色,注意:当 strokeWeight 为 0 时,不显示边框。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$strokeColor; - }, - set: function (value) { - if (this.$strokeColor == value) - return; - this.$strokeColor = value; - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rect.prototype, "strokeAlpha", { - /** - * The line's alpha inside the rect border. Caution: when the strokeWeight is 0, a line is not drawn - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 边框透明度,注意:当 strokeWeight 为0时,不显示边框。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$strokeAlpha; - }, - set: function (value) { - if (this.$strokeAlpha == value) - return; - this.$strokeAlpha = value; - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rect.prototype, "strokeWeight", { - /** - * The line's thickness inside the rect border. Caution: when the strokeWeight is 0, a line is not drawn - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 边框粗细(像素),注意:当 strokeWeight 为 0 时,不显示边框。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$strokeWeight; - }, - set: function (value) { - if (this.$strokeWeight == value) - return; - this.$strokeWeight = value; - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rect.prototype, "ellipseWidth", { - /** - * Width used to draw an ellipse with rounded corners (in pixels). - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 用于绘制圆角的椭圆的宽度(以像素为单位) - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$ellipseWidth; - }, - set: function (value) { - if (this.$ellipseWidth == value) - return; - this.$ellipseWidth = value; - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rect.prototype, "ellipseHeight", { - /** - * Height used to draw an ellipse with rounded corners (in pixels). If no value is specified, the default value matches the value of the ellipseWidth parameter. - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 用于绘制圆角的椭圆的高度 (以像素为单位)。如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$ellipseHeight; - }, - set: function (value) { - if (this.$ellipseHeight == value) - return; - this.$ellipseHeight = value; - this.invalidateDisplayList(); - }, - enumerable: true, - configurable: true - }); - /** - * @copy eui.UIComponent#updateDisplayList - * - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - */ - Rect.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - var g = this.graphics; - g.clear(); - if (this.$strokeWeight > 0) { - g.beginFill(this.$fillColor, 0); - g.lineStyle(this.$strokeWeight, this.$strokeColor, this.$strokeAlpha, true, "normal", "square", "miter"); - if (this.$ellipseWidth == 0 && this.$ellipseHeight == 0) { - g.drawRect(this.$strokeWeight / 2, this.$strokeWeight / 2, unscaledWidth - this.$strokeWeight, unscaledHeight - this.$strokeWeight); - } - else { - g.drawRoundRect(this.$strokeWeight / 2, this.$strokeWeight / 2, unscaledWidth - this.$strokeWeight, unscaledHeight - this.$strokeWeight, this.$ellipseWidth, this.$ellipseHeight); - } - g.endFill(); - } - g.beginFill(this.$fillColor, this.$fillAlpha); - g.lineStyle(this.$strokeWeight, this.$strokeColor, 0, true, "normal", "square", "miter"); - if (this.$ellipseWidth == 0 && this.$ellipseHeight == 0) { - g.drawRect(this.$strokeWeight, this.$strokeWeight, unscaledWidth - this.$strokeWeight * 2, unscaledHeight - this.$strokeWeight * 2); - } - else { - g.drawRoundRect(this.$strokeWeight, this.$strokeWeight, unscaledWidth - this.$strokeWeight * 2, unscaledHeight - this.$strokeWeight * 2, this.$ellipseWidth, this.$ellipseHeight); - } - g.endFill(); - }; - /** - * @private - */ - Rect.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - if (this.$graphics) { - this.$graphics.$onRemoveFromStage(); - } - }; - return Rect; - }(eui.Component)); - eui.Rect = Rect; - __reflect(Rect.prototype, "eui.Rect"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var scrollerThrowEvent; - /** - * The Scroller component displays a single scrollable component, - * called a viewport, and horizontal and vertical scroll bars. - * The viewport must implement the IViewport interface. - *

      The Group components implement the IViewport interface - * and can be used as the children of the Scroller control, - * as the following example shows:

      - *
      -     *       
      -     *           
      -     *               
      -     *           
      -     *       
      -     * 
      - *

      The size of the Image control is set larger than that of its parent Group container. - * By default, the child extends past the boundaries of the parent container. - * Rather than allow the child to extend past the boundaries of the parent container, - * the Scroller specifies to clip the child to the boundaries and display scroll bars.

      - * - * @event eui.UIEvent.CHANGE_START Dispatched when the scroll position is going to change - * @event eui.UIEvent.CHANGE_END Dispatched when the scroll position changed complete - * @event egret.Event.CHANGE Dispatched when the scroll position is changing - * @event egret.TouchEvent.TOUCH_CANCEL canceled the touch - * - * @defaultProperty viewport - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ScrollerExample.ts - * @language en_US - */ - /** - * Scroller 组件显示一个称为视域的单个可滚动组件,以及水平滚动条和垂直滚动条。该视域必须实现 IViewport 接口。 - *

      Group 组件实现 IViewport 接口,且可以用作 Scroller 控件的子代,如下例所示:

      - *
      -     *       
      -     *           
      -     *               
      -     *           
      -     *       
      -     * 
      - * Image 控件的大小比其父 Group 容器设置得大。默认情况下,子代超过父容器的边界。 - * Scroller 会指定将子代剪切到边界并显示滚动条,而不是让子代超过父容器的边界。 - * - * @event eui.UIEvent.CHANGE_START 滚动位置改变开始 - * @event eui.UIEvent.CHANGE_END 滚动位置改变结束 - * @event egret.Event.CHANGE 滚动位置改变的时候 - * @event egret.TouchEvent.TOUCH_CANCEL 取消触摸事件 - * - * @defaultProperty viewport - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ScrollerExample.ts - * @language zh_CN - */ - var Scroller = (function (_super) { - __extends(Scroller, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function Scroller() { - var _this = _super.call(this) || this; - _this.$bounces = true; - /** - * the horizontal scroll bar - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 水平滚动条 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.horizontalScrollBar = null; - /** - * the vertical scroll bar - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直滚动条 - * - * @skinPart - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.verticalScrollBar = null; - var touchScrollH = new eui.sys.TouchScroll(_this.horizontalUpdateHandler, _this.horizontalEndHandler, _this); - var touchScrollV = new eui.sys.TouchScroll(_this.verticalUpdateHandler, _this.verticalEndHanlder, _this); - _this.$Scroller = { - 0: "auto", - 1: "auto", - 2: null, - 3: 0, - 4: 0, - 5: false, - 6: false, - 7: false, - 8: touchScrollH, - 9: touchScrollV, - 10: null, - 11: false, - 12: false //touchCancle - }; - return _this; - } - Object.defineProperty(Scroller.prototype, "bounces", { - /** - * Whether to enable rebound, rebound When enabled, ScrollView contents allowed to continue to drag the border after arriving at the end user drag operation, and then bounce back boundary position - * @default true - * @version Egret 2.5.6 - * @language en_US - */ - /** - * 是否启用回弹,当启用回弹后,ScrollView中内容在到达边界后允许继续拖动,在用户拖动操作结束后,再反弹回边界位置 - * @default true - * @version Egret 2.5.6 - * @language zh_CN - */ - get: function () { - return this.$bounces; - }, - set: function (value) { - this.$bounces = !!value; - var touchScrollH = this.$Scroller[8 /* touchScrollH */]; - if (touchScrollH) { - touchScrollH.$bounces = this.$bounces; - } - var touchScrollV = this.$Scroller[9 /* touchScrollV */]; - if (touchScrollV) { - touchScrollV.$bounces = this.$bounces; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Scroller.prototype, "throwSpeed", { - get: function () { - return this.$Scroller[8 /* touchScrollH */].$scrollFactor; - }, - /** - * Adjust the speed to get out of the slide end.When equal to 0,the scroll animation will not be play. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 调节滑动结束时滚出的速度。等于0时,没有滚动动画 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - set: function (val) { - val = +val; - if (val < 0) - val = 0; - this.$Scroller[8 /* touchScrollH */].$scrollFactor = val; - this.$Scroller[9 /* touchScrollV */].$scrollFactor = val; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - Scroller.prototype.$getThrowInfo = function (currentPos, toPos) { - if (!scrollerThrowEvent) { - scrollerThrowEvent = new eui.ScrollerThrowEvent(eui.ScrollerThrowEvent.THROW, false, false, currentPos, toPos); - } - else { - scrollerThrowEvent.currentPos = currentPos; - scrollerThrowEvent.toPos = toPos; - } - return scrollerThrowEvent; - }; - Object.defineProperty(Scroller.prototype, "scrollPolicyV", { - /** - * Indicates under what conditions the scroller can be moved and the vertical scroll bar is displayed. - *

      ScrollPolicy.ON - the scroller can be moved, and the scroll bar is displayed when it's move.

      - *

      ScrollPolicy.OFF - the scroller can not be moved, the scroll bar is never displayed.

      - *

      ScrollPolicy.AUTO - the scroller can not be moved when - * the viewport's contentHeight is larger than its height. the scroll bar is displayed when it's move. - * - * @default ScrollPolicy.AUTO - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示在哪些条件可以滚动并且显示垂直滑动条。 - *

      ScrollPolicy.ON - 可以滚动,滚动时显示滚动条。

      - *

      ScrollPolicy.OFF - 不可以滚动并且不显示滚动条。

      - *

      ScrollPolicy.AUTO - 当视域的 contentHeight 大于其自身的高度时可以滚动,滚动时显示滚动条。

      - * - * @default ScrollPolicy.AUTO - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$Scroller[0 /* scrollPolicyV */]; - }, - set: function (value) { - var values = this.$Scroller; - if (values[0 /* scrollPolicyV */] == value) { - return; - } - values[0 /* scrollPolicyV */] = value; - this.checkScrollPolicy(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Scroller.prototype, "scrollPolicyH", { - /** - * Indicates under what conditions the scroller can be moved and the horizontal scroll bar is displayed. - *

      ScrollPolicy.ON - the scroller can be moved, and the scroll bar is displayed when it's move.

      - *

      ScrollPolicy.OFF - the scroller can not be moved, the scroll bar is never displayed.

      - *

      ScrollPolicy.AUTO - the can not be moved when - * the viewport's contentWidth is larger than its width. the scroll bar is displayed when it's move. - * - * @default ScrollPolicy.AUTO - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示在哪些条件下可以滚动并且显示水平滑动条。 - *

      ScrollPolicy.ON - 可以滚动,滚动时显示滚动条。

      - *

      ScrollPolicy.OFF - 不可以滚动并且不显示滚动条。

      - *

      ScrollPolicy.AUTO - 当视域的 contentWidth 大于其自身的宽度时可以滚动,滚动时显示滚动条。

      - * - * @default ScrollPolicy.AUTO - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$Scroller[1 /* scrollPolicyH */]; - }, - set: function (value) { - var values = this.$Scroller; - if (values[1 /* scrollPolicyH */] == value) { - return; - } - values[1 /* scrollPolicyH */] = value; - this.checkScrollPolicy(); - }, - enumerable: true, - configurable: true - }); - /** - * Stop the scroller animation - * @version Egret 3.0.2 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 停止滚动的动画 - * - * @version Egret 3.0.2 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Scroller.prototype.stopAnimation = function () { - var values = this.$Scroller; - var scrollV = values[9 /* touchScrollV */]; - var scrollH = values[8 /* touchScrollH */]; - if (scrollV.animation.isPlaying) { - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CHANGE_END); - } - else if (scrollH.animation.isPlaying) { - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CHANGE_END); - } - scrollV.stop(); - scrollH.stop(); - var verticalBar = this.verticalScrollBar; - var horizontalBar = this.horizontalScrollBar; - if (verticalBar && verticalBar.autoVisibility) { - verticalBar.visible = false; - } - if (horizontalBar && horizontalBar.autoVisibility) { - horizontalBar.visible = false; - } - }; - Object.defineProperty(Scroller.prototype, "viewport", { - /** - * The viewport component to be scrolled. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要滚动的视域组件。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$Scroller[10 /* viewport */]; - }, - set: function (value) { - var values = this.$Scroller; - if (value == values[10 /* viewport */]) - return; - this.uninstallViewport(); - values[10 /* viewport */] = value; - values[11 /* viewprotRemovedEvent */] = false; - this.installViewport(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 安装并初始化视域组件 - */ - Scroller.prototype.installViewport = function () { - var viewport = this.viewport; - if (viewport) { - this.addChildAt(viewport, 0); - viewport.scrollEnabled = true; - viewport.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBeginCapture, this, true); - viewport.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEndCapture, this, true); - viewport.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTapCapture, this, true); - viewport.addEventListener(egret.Event.REMOVED, this.onViewPortRemove, this); - } - if (this.horizontalScrollBar) { - this.horizontalScrollBar.viewport = viewport; - } - if (this.verticalScrollBar) { - this.verticalScrollBar.viewport = viewport; - } - }; - /** - * @private - * 卸载视域组件 - */ - Scroller.prototype.uninstallViewport = function () { - if (this.horizontalScrollBar) { - this.horizontalScrollBar.viewport = null; - } - if (this.verticalScrollBar) { - this.verticalScrollBar.viewport = null; - } - var viewport = this.viewport; - if (viewport) { - viewport.scrollEnabled = false; - viewport.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBeginCapture, this, true); - viewport.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEndCapture, this, true); - viewport.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouchTapCapture, this, true); - viewport.removeEventListener(egret.Event.REMOVED, this.onViewPortRemove, this); - if (this.$Scroller[11 /* viewprotRemovedEvent */] == false) { - this.removeChild(viewport); - } - } - }; - Scroller.prototype.onViewPortRemove = function (event) { - if (event.target == this.viewport) { - this.$Scroller[11 /* viewprotRemovedEvent */] = true; - this.viewport = null; - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Scroller.prototype.setSkin = function (skin) { - _super.prototype.setSkin.call(this, skin); - var viewport = this.viewport; - if (viewport) { - this.addChildAt(viewport, 0); - } - }; - /** - * @private - * @param event - */ - Scroller.prototype.onTouchBeginCapture = function (event) { - if (!this.$stage) { - return; - } - this.$Scroller[12 /* touchCancle */] = false; - var canScroll = this.checkScrollPolicy(); - if (!canScroll) { - return; - } - this.onTouchBegin(event); - }; - /** - * @private - * @param event - */ - Scroller.prototype.onTouchEndCapture = function (event) { - if (this.$Scroller[12 /* touchCancle */]) { - event.$bubbles = false; - this.dispatchBubbleEvent(event); - event.$bubbles = true; - event.stopPropagation(); - this.onTouchEnd(event); - } - }; - /** - * @private - * @param event - */ - Scroller.prototype.onTouchTapCapture = function (event) { - if (this.$Scroller[12 /* touchCancle */]) { - event.$bubbles = false; - this.dispatchBubbleEvent(event); - event.$bubbles = true; - event.stopPropagation(); - } - }; - /** - * @private - * 检查当前滚动策略,若有一个方向可以滚动,返回true。 - */ - Scroller.prototype.checkScrollPolicy = function () { - var values = this.$Scroller; - var viewport = values[10 /* viewport */]; - if (!viewport) { - return false; - } - var hCanScroll; - var uiValues = viewport.$UIComponent; - switch (values[1 /* scrollPolicyH */]) { - case "auto": - if (viewport.contentWidth > uiValues[10 /* width */] || viewport.scrollH !== 0) { - hCanScroll = true; - } - else { - hCanScroll = false; - } - break; - case "on": - hCanScroll = true; - break; - case "off": - hCanScroll = false; - break; - } - values[6 /* horizontalCanScroll */] = hCanScroll; - var vCanScroll; - switch (values[0 /* scrollPolicyV */]) { - case "auto": - if (viewport.contentHeight > uiValues[11 /* height */] || viewport.scrollV !== 0) { - vCanScroll = true; - } - else { - vCanScroll = false; - } - break; - case "on": - vCanScroll = true; - break; - case "off": - vCanScroll = false; - break; - } - values[7 /* verticalCanScroll */] = vCanScroll; - return hCanScroll || vCanScroll; - }; - /** - * @private - * - * @param event - */ - Scroller.prototype.onTouchBegin = function (event) { - if (event.isDefaultPrevented()) { - return; - } - if (!this.checkScrollPolicy()) { - return; - } - this.downTarget = event.target; - var values = this.$Scroller; - this.stopAnimation(); - values[3 /* touchStartX */] = event.$stageX; - values[4 /* touchStartY */] = event.$stageY; - if (values[6 /* horizontalCanScroll */]) { - values[8 /* touchScrollH */].start(event.$stageX); - } - if (values[7 /* verticalCanScroll */]) { - values[9 /* touchScrollV */].start(event.$stageY); - } - var stage = this.$stage; - this.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouchMove, this); - stage.addEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this, true); - this.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchCancel, this); - this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.onRemoveListeners, this); - this.tempStage = stage; - }; - /** - * @private - * - * @param event - */ - Scroller.prototype.onTouchMove = function (event) { - if (event.isDefaultPrevented()) { - return; - } - var values = this.$Scroller; - if (!values[5 /* touchMoved */]) { - var outX = void 0; - if (Math.abs(values[3 /* touchStartX */] - event.$stageX) < Scroller.scrollThreshold) { - outX = false; - } - else { - outX = true; - } - var outY = void 0; - if (Math.abs(values[4 /* touchStartY */] - event.$stageY) < Scroller.scrollThreshold) { - outY = false; - } - else { - outY = true; - } - if (!outX && !outY) { - return; - } - if (!outY && outX && values[1 /* scrollPolicyH */] == 'off') { - return; - } - if (!outX && outY && values[0 /* scrollPolicyV */] == 'off') { - return; - } - values[12 /* touchCancle */] = true; - values[5 /* touchMoved */] = true; - this.dispatchCancelEvent(event); - var horizontalBar = this.horizontalScrollBar; - var verticalBar = this.verticalScrollBar; - if (horizontalBar && horizontalBar.autoVisibility && values[6 /* horizontalCanScroll */]) { - horizontalBar.visible = true; - } - if (verticalBar && verticalBar.autoVisibility && values[7 /* verticalCanScroll */]) { - verticalBar.visible = true; - } - if (values[2 /* autoHideTimer */]) { - values[2 /* autoHideTimer */].reset(); - } - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CHANGE_START); - this.$stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouchMove, this); - } - event.preventDefault(); - var viewport = values[10 /* viewport */]; - var uiValues = viewport.$UIComponent; - if (values[6 /* horizontalCanScroll */]) { - values[8 /* touchScrollH */].update(event.$stageX, viewport.contentWidth - uiValues[10 /* width */], viewport.scrollH); - } - if (values[7 /* verticalCanScroll */]) { - values[9 /* touchScrollV */].update(event.$stageY, viewport.contentHeight - uiValues[11 /* height */], viewport.scrollV); - } - }; - /** - * @private - * @param event - */ - Scroller.prototype.onTouchCancel = function (event) { - if (!this.$Scroller[5 /* touchMoved */]) { - this.onRemoveListeners(); - } - }; - /** - * @private - * @param event - */ - Scroller.prototype.dispatchBubbleEvent = function (event) { - var viewport = this.$Scroller[10 /* viewport */]; - if (!viewport) { - return; - } - var cancelEvent = egret.Event.create(egret.TouchEvent, event.type, event.bubbles, event.cancelable); - cancelEvent.$initTo(event.$stageX, event.$stageY, event.touchPointID); - var target = this.downTarget; - cancelEvent.$setTarget(target); - var list = this.$getPropagationList(target); - var length = list.length; - var targetIndex = list.length * 0.5; - var startIndex = -1; - for (var i = 0; i < length; i++) { - if (list[i] === viewport) { - startIndex = i; - break; - } - } - list.splice(0, list.length - startIndex + 1); - targetIndex = 0; - this.$dispatchPropagationEvent(cancelEvent, list, targetIndex); - egret.Event.release(cancelEvent); - }; - /** - * @private - * @param event - */ - Scroller.prototype.dispatchCancelEvent = function (event) { - var viewport = this.$Scroller[10 /* viewport */]; - if (!viewport) { - return; - } - var cancelEvent = egret.Event.create(egret.TouchEvent, egret.TouchEvent.TOUCH_CANCEL, event.bubbles, event.cancelable); - cancelEvent.$initTo(event.$stageX, event.$stageY, event.touchPointID); - var target = this.downTarget; - cancelEvent.$setTarget(target); - var list = this.$getPropagationList(target); - var length = list.length; - var targetIndex = list.length * 0.5; - var startIndex = -1; - for (var i = 0; i < length; i++) { - if (list[i] === viewport) { - startIndex = i; - break; - } - } - list.splice(0, startIndex + 1 - 2); - list.splice(list.length - 1 - startIndex + 2, startIndex + 1 - 2); - targetIndex -= startIndex + 1; - this.$dispatchPropagationEvent(cancelEvent, list, targetIndex); - egret.Event.release(cancelEvent); - }; - /** - * @private - * @param event - */ - Scroller.prototype.onTouchEnd = function (event) { - var values = this.$Scroller; - values[5 /* touchMoved */] = false; - this.onRemoveListeners(); - var viewport = values[10 /* viewport */]; - var uiValues = viewport.$UIComponent; - if (values[8 /* touchScrollH */].isStarted()) { - values[8 /* touchScrollH */].finish(viewport.scrollH, viewport.contentWidth - uiValues[10 /* width */]); - } - if (values[9 /* touchScrollV */].isStarted()) { - values[9 /* touchScrollV */].finish(viewport.scrollV, viewport.contentHeight - uiValues[11 /* height */]); - } - }; - /** - * @private - */ - Scroller.prototype.onRemoveListeners = function () { - var stage = this.tempStage || this.$stage; - this.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouchMove, this); - stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.onTouchEnd, this, true); - stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.onTouchMove, this); - this.removeEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchCancel, this); - this.removeEventListener(egret.Event.REMOVED_FROM_STAGE, this.onRemoveListeners, this); - }; - /** - * @private - * - * @param scrollPos - */ - Scroller.prototype.horizontalUpdateHandler = function (scrollPos) { - var viewport = this.$Scroller[10 /* viewport */]; - if (viewport) { - viewport.scrollH = scrollPos; - } - this.dispatchEventWith(egret.Event.CHANGE); - }; - /** - * @private - * - * @param scrollPos - */ - Scroller.prototype.verticalUpdateHandler = function (scrollPos) { - var viewport = this.$Scroller[10 /* viewport */]; - if (viewport) { - viewport.scrollV = scrollPos; - } - this.dispatchEventWith(egret.Event.CHANGE); - }; - /** - * @private - * - */ - Scroller.prototype.horizontalEndHandler = function () { - if (!this.$Scroller[9 /* touchScrollV */].isPlaying()) { - this.onChangeEnd(); - } - }; - /** - * @private - * - */ - Scroller.prototype.verticalEndHanlder = function () { - if (!this.$Scroller[8 /* touchScrollH */].isPlaying()) { - this.onChangeEnd(); - } - }; - /** - * @private - * - */ - Scroller.prototype.onChangeEnd = function () { - var values = this.$Scroller; - var horizontalBar = this.horizontalScrollBar; - var verticalBar = this.verticalScrollBar; - if (horizontalBar && horizontalBar.visible || verticalBar && verticalBar.visible) { - if (!values[2 /* autoHideTimer */]) { - values[2 /* autoHideTimer */] = new egret.Timer(200, 1); - values[2 /* autoHideTimer */].addEventListener(egret.TimerEvent.TIMER_COMPLETE, this.onAutoHideTimer, this); - } - values[2 /* autoHideTimer */].reset(); - values[2 /* autoHideTimer */].start(); - } - eui.UIEvent.dispatchUIEvent(this, eui.UIEvent.CHANGE_END); - }; - /** - * @private - * - * @param event - */ - Scroller.prototype.onAutoHideTimer = function (event) { - var horizontalBar = this.horizontalScrollBar; - var verticalBar = this.verticalScrollBar; - if (horizontalBar && horizontalBar.autoVisibility) { - horizontalBar.visible = false; - } - if (verticalBar && verticalBar.autoVisibility) { - verticalBar.visible = false; - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Scroller.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - _super.prototype.updateDisplayList.call(this, unscaledWidth, unscaledHeight); - var viewport = this.viewport; - if (viewport) { - //必须先调用setLayoutBoundsSize(),因为尺寸改变会影响布局位置。 - viewport.setLayoutBoundsSize(unscaledWidth, unscaledHeight); - viewport.setLayoutBoundsPosition(0, 0); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - Scroller.prototype.partAdded = function (partName, instance) { - _super.prototype.partAdded.call(this, partName, instance); - if (instance == this.horizontalScrollBar) { - this.horizontalScrollBar.touchChildren = false; - this.horizontalScrollBar.touchEnabled = false; - this.horizontalScrollBar.viewport = this.viewport; - if (this.horizontalScrollBar.autoVisibility) { - this.horizontalScrollBar.visible = false; - } - } - else if (instance == this.verticalScrollBar) { - this.verticalScrollBar.touchChildren = false; - this.verticalScrollBar.touchEnabled = false; - this.verticalScrollBar.viewport = this.viewport; - if (this.verticalScrollBar.autoVisibility) { - this.verticalScrollBar.visible = false; - } - } - }; - /** - * The threshold value(in pixels) trigger the rolling. - * when the touch points deviate from the initial touch point than this value will trigger the rolling. - * - * @default 5 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 开始触发滚动的阈值(以像素为单位),当触摸点偏离初始触摸点的距离超过这个值时才会触发滚动。 - * - * @default 5 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Scroller.scrollThreshold = 5; - return Scroller; - }(eui.Component)); - eui.Scroller = Scroller; - __reflect(Scroller.prototype, "eui.Scroller"); - eui.registerProperty(Scroller, "viewport", "eui.IViewport", true); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The Skin class defines the base class for all skins. - * You typically don't need to manually create the instance of this class. - * It can be created by resolving a EXML.

      - * - * @example You typically write the skin classes in EXML, as the followiong example shows:

      - *

      -     *      
      -     *      
      -     *          
      -     *              
      -     *          
      -     *          
      -     *      
      -     * 
      - * - * @defaultProperty elementsContent - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/SkinExample.ts - * @language en_US - */ - /** - * 皮肤基类。通常情况下,您不需要手动创建这个类的实例,而是通过解析EXML文件后自动生成。

      - * - * @example 通常您可以按照如下方式写EXML代码:

      - *

      -     *      
      -     *      
      -     *          
      -     *              
      -     *          
      -     *          
      -     *      
      -     * 
      - * - * @defaultProperty elementsContent - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/SkinExample.ts - * @language zh_CN - */ - var Skin = (function (_super) { - __extends(Skin, _super); - function Skin() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * The maximum recommended width of the component to be considered. - * This property can only affect measure result of host component. - * - * @default 100000 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤的最大宽度。仅影响主机组件的测量结果。 - * - * @default 100000 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.maxWidth = 100000; - /** - * The minimum recommended width of the component to be considered. - * This property can only affect measure result of host component. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤的最小宽度,此属性设置为大于maxWidth的值时无效。仅影响主机组件的测量结果。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.minWidth = 0; - /** - * The maximum recommended height of the component to be considered. - * This property can only affect measure result of host component. - * - * @default 100000 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤的最大高度。仅影响主机组件的测量结果。 - * - * @default 100000 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.maxHeight = 100000; - /** - * The minimum recommended height of the component to be considered. - * This property can only affect measure result of host component. - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤的最小高度,此属性设置为大于maxHeight的值时无效。仅影响主机组件的测量结果。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.minHeight = 0; - /** - * Number that specifies the explicit width of the skin. - * This property can only affect measure result of host component. - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤显式设置宽度,设置为 NaN 表示不显式设置。仅影响主机组件的测量结果。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.width = NaN; - /** - * Number that specifies the explicit height of the skin. - * This property can only affect measure result of host component. - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 皮肤显式设置高度,设置为 NaN 表示不显式设置。仅影响主机组件的测量结果。 - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.height = NaN; - /** - * @private - */ - _this.$elementsContent = []; - /** - * @private - */ - _this._hostComponent = null; - /** - * @private - */ - _this.$stateValues = new eui.sys.StateValues(); - return _this; - } - Object.defineProperty(Skin.prototype, "elementsContent", { - set: function (value) { - this.$elementsContent = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Skin.prototype, "hostComponent", { - /** - * The host component which the skin will be attached. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此皮肤附加到的主机组件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._hostComponent; - }, - set: function (value) { - if (this._hostComponent == value) - return; - if (this._hostComponent) { - this._hostComponent.removeEventListener(egret.Event.ADDED_TO_STAGE, this.onAddedToStage, this); - } - this._hostComponent = value; - var values = this.$stateValues; - values.parent = value; - if (value) { - this.commitCurrentState(); - if (!this.$stateValues.intialized) { - if (value.$stage) { - this.initializeStates(value.$stage); - } - else { - value.once(egret.Event.ADDED_TO_STAGE, this.onAddedToStage, this); - } - } - } - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "hostComponent"); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param event - */ - Skin.prototype.onAddedToStage = function (event) { - this.initializeStates(this._hostComponent.$stage); - }; - return Skin; - }(egret.EventDispatcher)); - eui.Skin = Skin; - __reflect(Skin.prototype, "eui.Skin"); - eui.sys.mixin(Skin, eui.sys.StateClient); - eui.registerProperty(Skin, "elementsContent", "Array", true); - eui.registerProperty(Skin, "states", "State[]"); - eui.registerBindable(Skin.prototype, "hostComponent"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The TabBar class displays a set of identical tabs. - * One tab can be selected at a time, and the first tab is selected by default. - *

      The set of tabs is defined by the dataProvider property. - * The appearance of each tab is defined by the ItemRenderer class.

      - *

      You can use the TabBar control to set the active child of a ViewStack container, - * as the following example shows:

      - *
      -     *       
      -     *       
      -     *          
      -     *          
      -     *          
      -     *       
      -     * 
      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TabBarExample.ts - * @language en_US - */ - /** - * TabBar 类显示一组相同的选项卡。一次可以选择一个选项卡,且默认情况下选择第一个选项卡。 - *

      该组选项卡由 dataProvider 属性定义。 - * 每个选项卡的外观由 ItemRenderer 定义。

      - *

      可以使用 TabBar 控件设置 ViewStack 容器的活动子代,如下例所示:

      - *
      -     *       
      -     *       
      -     *          
      -     *          
      -     *          
      -     *       
      -     * 
      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TabBarExample.ts - * @language zh_CN - */ - var TabBar = (function (_super) { - __extends(TabBar, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function TabBar() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.indexBeingUpdated = false; - _this.requireSelection = true; - _this.useVirtualLayout = false; - return _this; - } - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - TabBar.prototype.createChildren = function () { - if (!this.$layout) { - var layout = new eui.HorizontalLayout(); - layout.gap = 0; - layout.horizontalAlign = eui.JustifyAlign.JUSTIFY; - layout.verticalAlign = eui.JustifyAlign.CONTENT_JUSTIFY; - this.$setLayout(layout); - } - _super.prototype.createChildren.call(this); - }; - /** - * @private - * - * @param value - */ - TabBar.prototype.$setDataProvider = function (value) { - var dp = this.$dataProvider; - if (dp && dp instanceof eui.ViewStack) { - dp.removeEventListener(eui.PropertyEvent.PROPERTY_CHANGE, this.onViewStackIndexChange, this); - this.removeEventListener(egret.Event.CHANGE, this.onIndexChanged, this); - } - if (value && value instanceof eui.ViewStack) { - value.addEventListener(eui.PropertyEvent.PROPERTY_CHANGE, this.onViewStackIndexChange, this); - this.addEventListener(egret.Event.CHANGE, this.onIndexChanged, this); - } - return _super.prototype.$setDataProvider.call(this, value); - }; - /** - * @private - * 触摸点击的选中项改变 - */ - TabBar.prototype.onIndexChanged = function (event) { - this.indexBeingUpdated = true; - (this.$dataProvider).selectedIndex = this.selectedIndex; - this.indexBeingUpdated = false; - }; - /** - * @private - * ViewStack选中项发生改变 - */ - TabBar.prototype.onViewStackIndexChange = function (event) { - if (event.property == "selectedIndex" && !this.indexBeingUpdated) { - this.setSelectedIndex((this.$dataProvider).selectedIndex, false); - } - }; - return TabBar; - }(eui.ListBase)); - eui.TabBar = TabBar; - __reflect(TabBar.prototype, "eui.TabBar"); -})(eui || (eui = {})); -var eui; -(function (eui) { - var FocusEvent = egret.FocusEvent; - /** - * - */ - /** - * The TextInput is a textfield input component, the user can input and edit the text. - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TextInputExample.ts - * @language en_US - */ - /** - * TextInput 是一个文本输入控件,供用户输入和编辑统一格式文本 - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TextInputExample.ts - * @language zh_CN - */ - var TextInput = (function (_super) { - __extends(TextInput, _super); - function TextInput() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.isFocus = false; - _this.$TextInput = { - 0: null, - 1: null, - 2: null, - 3: null, - 4: null, - 5: null, - 6: "", - 7: null, - 8: egret.TextFieldInputType.TEXT //inputType - }; - return _this; - } - Object.defineProperty(TextInput.prototype, "prompt", { - /** - * @copy eui.EditableText#prompt - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - if (this.promptDisplay) { - return this.promptDisplay.text; - } - return this.$TextInput[0 /* prompt */]; - }, - /** - * @copy eui.EditableText#prompt - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - set: function (value) { - this.$TextInput[0 /* prompt */] = value; - if (this.promptDisplay) { - this.promptDisplay.text = value; - } - this.invalidateProperties(); - this.invalidateState(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextInput.prototype, "displayAsPassword", { - /** - * @copy egret.TextField#displayAsPassword - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - if (this.textDisplay) { - return this.textDisplay.displayAsPassword; - } - var v = this.$TextInput[1 /* displayAsPassword */]; - return v ? v : false; - }, - /** - * @copy egret.TextField#displayAsPassword - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - set: function (value) { - this.$TextInput[1 /* displayAsPassword */] = value; - if (this.textDisplay) { - this.textDisplay.displayAsPassword = value; - } - this.invalidateProperties(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextInput.prototype, "inputType", { - /** - * @copy egret.TextField#inputType - * - * @version Egret 3.1.6 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - if (this.textDisplay) { - return this.textDisplay.inputType; - } - return this.$TextInput[8 /* inputType */]; - }, - /** - * @copy egret.TextField#inputType - * - * @version Egret 3.1.6 - * @version eui 1.0 - * @platform Web,Native - */ - set: function (value) { - this.$TextInput[8 /* inputType */] = value; - if (this.textDisplay) { - this.textDisplay.inputType = value; - } - this.invalidateProperties(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextInput.prototype, "textColor", { - /** - * @copy egret.TextField#textColor - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - if (this.textDisplay) { - return this.textDisplay.textColor; - } - return this.$TextInput[2 /* textColor */]; - }, - /** - * @copy egret.TextField#textColor - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - set: function (value) { - this.$TextInput[2 /* textColor */] = value; - if (this.textDisplay) { - this.textDisplay.textColor = value; - } - this.invalidateProperties(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextInput.prototype, "maxChars", { - /** - * @copy egret.TextField#maxChars - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - if (this.textDisplay) { - return this.textDisplay.maxChars; - } - var v = this.$TextInput[3 /* maxChars */]; - return v ? v : 0; - }, - /** - * @copy egret.TextField#maxChars - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - set: function (value) { - this.$TextInput[3 /* maxChars */] = value; - if (this.textDisplay) { - this.textDisplay.maxChars = value; - } - this.invalidateProperties(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextInput.prototype, "maxWidth", { - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - if (this.textDisplay) { - return this.textDisplay.maxWidth; - } - var v = this.$TextInput[4 /* maxWidth */]; - return v ? v : 100000; - }, - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - set: function (value) { - this.$TextInput[4 /* maxWidth */] = value; - if (this.textDisplay) { - this.textDisplay.maxWidth = value; - } - this.invalidateProperties(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextInput.prototype, "maxHeight", { - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - if (this.textDisplay) { - //return this.textDisplay.maxHeight; - } - var v = this.$TextInput[5 /* maxHeight */]; - return v ? v : 100000; - }, - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - set: function (value) { - this.$TextInput[5 /* maxHeight */] = value; - if (this.textDisplay) { - this.textDisplay.maxHeight = value; - } - this.invalidateProperties(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextInput.prototype, "text", { - /** - * @copy egret.TextField#text - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - if (this.textDisplay) { - return this.textDisplay.text; - } - return this.$TextInput[6 /* text */]; - }, - /** - * @copy egret.TextField#text - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - set: function (value) { - this.$TextInput[6 /* text */] = value; - if (this.textDisplay) { - this.textDisplay.text = value; - } - this.invalidateProperties(); - this.invalidateState(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextInput.prototype, "restrict", { - /** - * @copy egret.TextField#restrict - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - if (this.textDisplay) { - return this.textDisplay.restrict; - } - return this.$TextInput[7 /* restrict */]; - }, - /** - * @copy egret.TextField#restrict - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - set: function (value) { - this.$TextInput[7 /* restrict */] = value; - if (this.textDisplay) { - this.textDisplay.restrict = value; - } - this.invalidateProperties(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 焦点移入 - */ - TextInput.prototype.focusInHandler = function (event) { - this.isFocus = true; - this.invalidateState(); - }; - /** - * @private - * 焦点移出 - */ - TextInput.prototype.focusOutHandler = function (event) { - this.isFocus = false; - this.invalidateState(); - }; - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - TextInput.prototype.getCurrentState = function () { - var skin = this.skin; - if (this.prompt && !this.isFocus && !this.text) { - if (this.enabled && skin.hasState("normalWithPrompt")) { - return "normalWithPrompt"; - } - else if (!this.enabled && skin.hasState("disabledWithPrompt")) { - return "disabledWithPrompt"; - } - } - else { - if (this.enabled) { - return "normal"; - } - else { - return "disabled"; - } - } - }; - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - TextInput.prototype.partAdded = function (partName, instance) { - _super.prototype.partAdded.call(this, partName, instance); - var values = this.$TextInput; - if (instance == this.textDisplay) { - this.textDisplayAdded(); - if (this.textDisplay instanceof eui.EditableText) { - this.textDisplay.addEventListener(FocusEvent.FOCUS_IN, this.focusInHandler, this); - this.textDisplay.addEventListener(FocusEvent.FOCUS_OUT, this.focusOutHandler, this); - } - } - else if (instance == this.promptDisplay) { - if (values[0 /* prompt */]) { - this.promptDisplay.text = values[0 /* prompt */]; - } - } - }; - /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - TextInput.prototype.partRemoved = function (partName, instance) { - _super.prototype.partRemoved.call(this, partName, instance); - if (instance == this.textDisplay) { - this.textDisplayRemoved(); - if (this.textDisplay instanceof eui.EditableText) { - this.textDisplay.removeEventListener(FocusEvent.FOCUS_IN, this.focusInHandler, this); - this.textDisplay.removeEventListener(FocusEvent.FOCUS_OUT, this.focusOutHandler, this); - } - } - else if (instance == this.promptDisplay) { - this.$TextInput[0 /* prompt */] = this.promptDisplay.text; - } - }; - /** - * @private - */ - TextInput.prototype.textDisplayAdded = function () { - var values = this.$TextInput; - if (values[1 /* displayAsPassword */]) { - this.textDisplay.displayAsPassword = values[1 /* displayAsPassword */]; - } - if (values[2 /* textColor */]) { - this.textDisplay.textColor = values[2 /* textColor */]; - } - if (values[3 /* maxChars */]) { - this.textDisplay.maxChars = values[3 /* maxChars */]; - } - if (values[4 /* maxWidth */]) { - this.textDisplay.maxWidth = values[4 /* maxWidth */]; - } - if (values[5 /* maxHeight */]) { - this.textDisplay.maxHeight = values[5 /* maxHeight */]; - } - if (values[6 /* text */]) { - this.textDisplay.text = values[6 /* text */]; - } - if (values[7 /* restrict */]) { - this.textDisplay.restrict = values[7 /* restrict */]; - } - if (values[8 /* inputType */]) { - this.textDisplay.inputType = values[8 /* inputType */]; - } - }; - /** - * @private - */ - TextInput.prototype.textDisplayRemoved = function () { - var values = this.$TextInput; - values[1 /* displayAsPassword */] = this.textDisplay.displayAsPassword; - values[2 /* textColor */] = this.textDisplay.textColor; - values[3 /* maxChars */] = this.textDisplay.maxChars; - values[4 /* maxWidth */] = this.textDisplay.maxWidth; - values[5 /* maxHeight */] = this.textDisplay.maxHeight; - values[6 /* text */] = this.textDisplay.text; - values[7 /* restrict */] = this.textDisplay.restrict; - values[8 /* inputType */] = this.textDisplay.inputType; - }; - return TextInput; - }(eui.Component)); - eui.TextInput = TextInput; - __reflect(TextInput.prototype, "eui.TextInput"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The CheckBox component consists of an optional label and a small box - * that can contain a check mark or not.

      - * - * When a user clicks a CheckBox component or its associated text, - * the CheckBox component sets its selected property - * to true for checked, and to false for unchecked. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/CheckboxExample.ts - * @language en_US - */ - /** - * CheckBox 组件包含一个可选标签和一个小方框,该方框内可以包含/不包含复选标记。

      - * 用户单击 CheckBox 组件或其关联文本时,CheckBox 组件会将其 selected 属性设置为 true(表示选中)或 false(表示取消选中)。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/CheckboxExample.ts - * @language zh_CN - */ - var CheckBox = (function (_super) { - __extends(CheckBox, _super); - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个CheckBox - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function CheckBox() { - return _super.call(this) || this; - } - return CheckBox; - }(eui.ToggleButton)); - eui.CheckBox = CheckBox; - __reflect(CheckBox.prototype, "eui.CheckBox"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The ToggleSwitch control defines an on-off control. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ToggleSwitchExample.ts - * @language en_US - */ - /** - * ToggleSwitch 表示一个开关组件。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ToggleSwitchExample.ts - * @language zh_CN - */ - var ToggleSwitch = (function (_super) { - __extends(ToggleSwitch, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function ToggleSwitch() { - return _super.call(this) || this; - } - return ToggleSwitch; - }(eui.ToggleButton)); - eui.ToggleSwitch = ToggleSwitch; - __reflect(ToggleSwitch.prototype, "eui.ToggleSwitch"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The UILayer class is the subclass of the Group class.It not only has the standard function of the Group class,but also - * can keep its size the same to the stage size (Stage.stageWidth,Stage.stageHeight).Its size will changes as the stage size changes. - * like any normal container class,you can create multiple instance of the UILayer class,but it is usually used as the root of the UI display list. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * UILayer 是 Group 的子类,它除了具有容器的所有标准功能,还能够自动保持自身尺寸始终与舞台尺寸相同(Stage.stageWidth,Stage.stageHeight)。 - * 当舞台尺寸发生改变时,它会跟随舞台尺寸改变。UILayer 跟普通容器一样,允许创建多个实例,但通常都将它作为UI显示列表的根节点使用。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var UILayer = (function (_super) { - __extends(UILayer, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function UILayer() { - var _this = _super.call(this) || this; - _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _this); - _this.addEventListener(egret.Event.REMOVED_FROM_STAGE, _this.onRemoveFromStage, _this); - return _this; - } - /** - * @private - * 添加到舞台 - */ - UILayer.prototype.onAddToStage = function (event) { - this.$stage.addEventListener(egret.Event.RESIZE, this.onResize, this); - this.onResize(); - }; - /** - * @private - * 从舞台移除 - */ - UILayer.prototype.onRemoveFromStage = function (event) { - this.$stage.removeEventListener(egret.Event.RESIZE, this.onResize, this); - }; - /** - * @private - * 舞台尺寸改变 - */ - UILayer.prototype.onResize = function (event) { - var stage = this.$stage; - this.$setWidth(stage.$stageWidth); - this.$setHeight(stage.$stageHeight); - }; - return UILayer; - }(eui.Group)); - eui.UILayer = UILayer; - __reflect(UILayer.prototype, "eui.UILayer"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The VScrollBar (vertical scrollbar) control lets you control - * the portion of data that is displayed when there is too much data - * to fit vertically in a display area. - * - *

      Although you can use the VScrollBar control as a stand-alone control, - * you usually combine it as part of another group of components to - * provide scrolling functionality.

      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VScrollBarExample.ts - * @language en_US - */ - /** - * VScrollBar(垂直 ScrollBar)控件可以在因数据太多而不能在显示区域中以垂直方向完全显示时控制显示的数据部分。 - *

      虽然 VScrollBar 控件可以单独使用,但通常将它与其他组件一起使用来提供滚动功能。

      - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VScrollBarExample.ts - * @language zh_CN - */ - var VScrollBar = (function (_super) { - __extends(VScrollBar, _super); - function VScrollBar() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VScrollBar.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - _super.prototype.updateDisplayList.call(this, unscaledWidth, unscaledHeight); - var thumb = this.thumb; - var viewport = this.$viewport; - if (!thumb || !viewport) { - return; - } - var bounds = egret.$TempRectangle; - thumb.getPreferredBounds(bounds); - var thumbHeight = bounds.height; - var thumbX = bounds.x; - var vsp = viewport.scrollV; - var contentHeight = viewport.contentHeight; - var height = viewport.height; - if (vsp <= 0) { - var scaleHeight = thumbHeight * (1 - (-vsp) / (height * 0.5)); - scaleHeight = Math.max(5, Math.round(scaleHeight)); - thumb.setLayoutBoundsSize(NaN, scaleHeight); - thumb.setLayoutBoundsPosition(thumbX, 0); - } - else if (vsp >= contentHeight - height) { - var scaleHeight = thumbHeight * (1 - (vsp - contentHeight + height) / (height * 0.5)); - scaleHeight = Math.max(5, Math.round(scaleHeight)); - thumb.setLayoutBoundsSize(NaN, scaleHeight); - thumb.setLayoutBoundsPosition(thumbX, unscaledHeight - scaleHeight); - } - else { - var thumbY = (unscaledHeight - thumbHeight) * vsp / (contentHeight - height); - thumb.setLayoutBoundsSize(NaN, NaN); - thumb.setLayoutBoundsPosition(thumbX, thumbY); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VScrollBar.prototype.onPropertyChanged = function (event) { - switch (event.property) { - case "scrollV": - case "contentHeight": - this.invalidateDisplayList(); - break; - } - }; - return VScrollBar; - }(eui.ScrollBarBase)); - eui.VScrollBar = VScrollBar; - __reflect(VScrollBar.prototype, "eui.VScrollBar"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The VSlider (vertical slider) control lets users select a value - * by moving a slider thumb between the end points of the slider track. - * The current value of the slider is determined by the relative location of the thumb between - * the end points of the slider, corresponding to the slider's minimum and maximum values. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VSliderExample.ts - * @language en_US - */ - /** - * 使用 VSlider(垂直滑块)控件,用户可通过在滑块轨道的端点之间移动滑块来选择值。 - * 滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VSliderExample.ts - * @language zh_CN - */ - var VSlider = (function (_super) { - __extends(VSlider, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function VSlider() { - return _super.call(this) || this; - } - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VSlider.prototype.pointToValue = function (x, y) { - if (!this.thumb || !this.track) - return 0; - var values = this.$Range; - var range = values[0 /* maximum */] - values[2 /* minimum */]; - var thumbRange = this.getThumbRange(); - return values[2 /* minimum */] + ((thumbRange != 0) ? ((thumbRange - y) / thumbRange) * range : 0); - }; - /** - * @private - * - * @returns - */ - VSlider.prototype.getThumbRange = function () { - var bounds = egret.$TempRectangle; - this.track.getLayoutBounds(bounds); - var thumbRange = bounds.height; - this.thumb.getLayoutBounds(bounds); - return thumbRange - bounds.height; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VSlider.prototype.updateSkinDisplayList = function () { - if (!this.thumb || !this.track) - return; - var values = this.$Range; - var thumbRange = this.getThumbRange(); - var range = values[0 /* maximum */] - values[2 /* minimum */]; - var thumbPosTrackY = (range > 0) ? thumbRange - (((this.pendingValue - values[2 /* minimum */]) / range) * thumbRange) : 0; - var thumbPos = this.track.localToGlobal(0, thumbPosTrackY, egret.$TempPoint); - var thumbPosX = thumbPos.x; - var thumbPosY = thumbPos.y; - var thumbPosParentY = this.thumb.$parent.globalToLocal(thumbPosX, thumbPosY, egret.$TempPoint).y; - var bounds = egret.$TempRectangle; - var thumbHeight = bounds.height; - this.thumb.getLayoutBounds(bounds); - this.thumb.setLayoutBoundsPosition(bounds.x, Math.round(thumbPosParentY)); - if (this.trackHighlight) { - var trackHighlightY = this.trackHighlight.$parent.globalToLocal(thumbPosX, thumbPosY, egret.$TempPoint).y; - this.trackHighlight.y = Math.round(trackHighlightY + thumbHeight); - this.trackHighlight.height = Math.round(thumbRange - trackHighlightY); - } - }; - return VSlider; - }(eui.SliderBase)); - eui.VSlider = VSlider; - __reflect(VSlider.prototype, "eui.VSlider"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * An ViewStack navigator container consists of a collection of child - * containers stacked on top of each other, where only one child - * at a time is visible. - * When a different child container is selected, it seems to replace - * the old one because it appears in the same location. - * However, the old child container still exists; it is just invisible. - * - * @event eui.CollectionEvent.COLLECTION_CHANGE Dispatched when the ICollection has been updated in some way. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ViewStackExample.ts - * @language en_US - */ - /** - * ViewStack 导航器容器由一组彼此上下堆叠的子容器组成,其中一次只可以显示一个子容器。 - * 选择另一个子容器后,它将显示在原来子容器的位置处,所以看起来好像此子容器替换了原来的子容器。 - * 但是,原来的子容器仍然存在,只不过它现在处于不可见状态。 - * - * @event eui.CollectionEvent.COLLECTION_CHANGE 以某种方式更新 ICollection 后分派。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ViewStackExample.ts - * @language zh_CN - */ - var ViewStack = (function (_super) { - __extends(ViewStack, _super); - /** - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function ViewStack() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this._selectedChild = null; - /** - * @private - * 在属性提交前缓存选中项索引 - */ - _this.proposedSelectedIndex = eui.ListBase.NO_PROPOSED_SELECTION; - /** - * @private - */ - _this._selectedIndex = -1; - return _this; - } - Object.defineProperty(ViewStack.prototype, "layout", { - /** - * The layout object for this container. - * This object is responsible for the measurement and layout of - * the visual elements in the container. - * - * @default eui.BasicLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 此容器的 layout 对象。此对象负责容器中可视元素的测量和布局。 - * - * @default eui.BasicLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$layout; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ViewStack.prototype, "selectedChild", { - /** - * A reference to the currently visible child container. - * The default is a reference to the first child. - * If there are no children, this property is null. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 对当前可见子容器的引用。默认设置为对第一个子容器的引用。如果没有子项,则此属性为 null。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - var index = this.selectedIndex; - if (index >= 0 && index < this.numChildren) - return this.getChildAt(index); - return null; - }, - set: function (value) { - var index = this.getChildIndex(value); - if (index >= 0 && index < this.numChildren) - this.setSelectedIndex(index); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ViewStack.prototype, "selectedIndex", { - /** - * The zero-based index of the currently visible child container. - * Child indexes are in the range 0, 1, 2, ..., n - 1, - * where n is the number of children. - * The default value is 0, corresponding to the first child. - * If there are no children, the value of this property is -1. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当前可见子容器的从零开始的索引。子索引的范围是 0、1、2、...、n - 1,其中 n 是子项的数目。 - * 默认值是 0,对应于第一个子项。如果不存在子容器,则此属性的值为 -1。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.proposedSelectedIndex != eui.ListBase.NO_PROPOSED_SELECTION ? this.proposedSelectedIndex : this._selectedIndex; - }, - set: function (value) { - value = +value | 0; - this.setSelectedIndex(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 设置选中项索引 - */ - ViewStack.prototype.setSelectedIndex = function (value) { - if (value == this.selectedIndex) { - return; - } - this.proposedSelectedIndex = value; - this.invalidateProperties(); - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "selectedIndex"); - }; - /** - * @private - * 一个子项被添加到容器内,此方法不仅在操作addChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - ViewStack.prototype.$childAdded = function (child, index) { - _super.prototype.$childAdded.call(this, child, index); - this.showOrHide(child, false); - var selectedIndex = this.selectedIndex; - if (selectedIndex == -1) { - this.setSelectedIndex(index); - } - else if (index <= this.selectedIndex && this.$stage) { - this.setSelectedIndex(selectedIndex + 1); - } - eui.CollectionEvent.dispatchCollectionEvent(this, eui.CollectionEvent.COLLECTION_CHANGE, eui.CollectionEventKind.ADD, index, -1, [child.name]); - }; - /** - * @private - * 一个子项从容器内移除,此方法不仅在操作removeChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - ViewStack.prototype.$childRemoved = function (child, index) { - _super.prototype.$childRemoved.call(this, child, index); - this.showOrHide(child, true); - var selectedIndex = this.selectedIndex; - if (index == selectedIndex) { - if (this.numChildren > 0) { - if (index == 0) { - this.proposedSelectedIndex = 0; - this.invalidateProperties(); - } - else - this.setSelectedIndex(0); - } - else - this.setSelectedIndex(-1); - } - else if (index < selectedIndex) { - this.setSelectedIndex(selectedIndex - 1); - } - eui.CollectionEvent.dispatchCollectionEvent(this, eui.CollectionEvent.COLLECTION_CHANGE, eui.CollectionEventKind.REMOVE, index, -1, [child.name]); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ViewStack.prototype.commitProperties = function () { - _super.prototype.commitProperties.call(this); - if (this.proposedSelectedIndex != eui.ListBase.NO_PROPOSED_SELECTION) { - this.commitSelection(this.proposedSelectedIndex); - this.proposedSelectedIndex = eui.ListBase.NO_PROPOSED_SELECTION; - } - }; - /** - * @private - * - * @param newIndex - */ - ViewStack.prototype.commitSelection = function (newIndex) { - if (newIndex >= 0 && newIndex < this.numChildren) { - this._selectedIndex = newIndex; - if (this._selectedChild) { - this.showOrHide(this._selectedChild, false); - } - this._selectedChild = this.getElementAt(this._selectedIndex); - this.showOrHide(this._selectedChild, true); - } - else { - this._selectedChild = null; - this._selectedIndex = -1; - } - this.invalidateSize(); - this.invalidateDisplayList(); - }; - /** - * @private - * - * @param child - * @param visible - */ - ViewStack.prototype.showOrHide = function (child, visible) { - if (egret.is(child, "eui.UIComponent")) { - child.includeInLayout = visible; - } - child.visible = visible; - }; - Object.defineProperty(ViewStack.prototype, "length", { - /** - * number of children - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 子项数量 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$children.length; - }, - enumerable: true, - configurable: true - }); - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ViewStack.prototype.getItemAt = function (index) { - var element = this.$children[index]; - return element ? element.name : ""; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ViewStack.prototype.getItemIndex = function (item) { - var list = this.$children; - var length = list.length; - for (var i = 0; i < length; i++) { - if (list[i].name == item) { - return i; - } - } - return -1; - }; - return ViewStack; - }(eui.Group)); - eui.ViewStack = ViewStack; - __reflect(ViewStack.prototype, "eui.ViewStack", ["eui.ICollection", "egret.IEventDispatcher"]); - eui.registerBindable(ViewStack.prototype, "selectedIndex"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var sys; - (function (sys) { - /** - * @private - * - * @param fraction - * @returns - */ - function sineInOut(fraction) { - return -0.5 * (Math.cos(Math.PI * fraction) - 1); - } - /** - * @private - * 数值缓动工具类 - */ - var Animation = (function () { - /** - * @private - */ - function Animation(updateFunction, thisObject) { - /** - * @private - * 此动画的缓动行为。设置为null意味着不使用缓动,默认值为 sineInOut - */ - this.easerFunction = sineInOut; - /** - * @private - * 是否正在播放动画,不包括延迟等待和暂停的阶段 - */ - this.isPlaying = false; - /** - * @private - * 动画持续时间,单位毫秒,默认值500 - */ - this.duration = 500; - /** - * @private - * 动画到当前时间对应的值。 - */ - this.currentValue = 0; - /** - * @private - * 起始值 - */ - this.from = 0; - /** - * @private - * 终点值。 - */ - this.to = 0; - /** - * @private - * 动画启动时刻 - */ - this.startTime = 0; - /** - * @private - * 动画播放结束时的回调函数 - */ - this.endFunction = null; - this.updateFunction = updateFunction; - this.thisObject = thisObject; - } - /** - * @private - * 开始正向播放动画,无论何时调用都重新从零时刻开始,若设置了延迟会首先进行等待。 - */ - Animation.prototype.play = function () { - this.stop(); - this.start(); - }; - /** - * @private - * 开始播放动画 - */ - Animation.prototype.start = function () { - this.isPlaying = false; - this.currentValue = 0; - this.startTime = egret.getTimer(); - this.doInterval(this.startTime); - egret.startTick(this.doInterval, this); - }; - /** - * @private - * 停止播放动画 - */ - Animation.prototype.stop = function () { - this.isPlaying = false; - this.startTime = 0; - egret.stopTick(this.doInterval, this); - }; - /** - * @private - * 计算当前值并返回动画是否结束 - */ - Animation.prototype.doInterval = function (currentTime) { - var runningTime = currentTime - this.startTime; - if (!this.isPlaying) { - this.isPlaying = true; - } - var duration = this.duration; - var fraction = duration == 0 ? 1 : Math.min(runningTime, duration) / duration; - if (this.easerFunction) { - fraction = this.easerFunction(fraction); - } - this.currentValue = this.from + (this.to - this.from) * fraction; - if (this.updateFunction) - this.updateFunction.call(this.thisObject, this); - var isEnded = runningTime >= duration; - if (isEnded) { - this.stop(); - } - if (isEnded && this.endFunction) { - this.endFunction.call(this.thisObject, this); - } - return true; - }; - return Animation; - }()); - sys.Animation = Animation; - __reflect(Animation.prototype, "eui.sys.Animation"); - })(sys = eui.sys || (eui.sys = {})); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * Default instance of interface IThemeAdapter. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 默认的IThemeAdapter接口实现。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var DefaultThemeAdapter = (function () { - function DefaultThemeAdapter() { - } - /** - * 解析主题 - * @param url 待解析的主题url - * @param compFunc 解析完成回调函数,示例:compFunc(e:egret.Event):void; - * @param errorFunc 解析失败回调函数,示例:errorFunc():void; - * @param thisObject 回调的this引用 - */ - DefaultThemeAdapter.prototype.getTheme = function (url, compFunc, errorFunc, thisObject) { - function onGet(event) { - var loader = (event.target); - compFunc.call(thisObject, loader.response); - } - function onError(event) { - errorFunc.call(thisObject); - } - var loader = new egret.HttpRequest(); - loader.addEventListener(egret.Event.COMPLETE, onGet, thisObject); - loader.addEventListener(egret.IOErrorEvent.IO_ERROR, onError, thisObject); - loader.responseType = egret.HttpResponseType.TEXT; - loader.open(url); - loader.send(); - }; - return DefaultThemeAdapter; - }()); - eui.DefaultThemeAdapter = DefaultThemeAdapter; - __reflect(DefaultThemeAdapter.prototype, "eui.DefaultThemeAdapter", ["eui.IThemeAdapter"]); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * @private - */ - var listeners = "__listeners__"; - /** - * @private - */ - var bindables = "__bindables__"; - /** - * @private - */ - var bindableCount = 0; - /** - * @private - * - * @param host - * @param property - * @returns - */ - function getPropertyDescriptor(host, property) { - var data = Object.getOwnPropertyDescriptor(host, property); - if (data) { - return data; - } - var prototype = Object.getPrototypeOf(host); - if (prototype) { - return getPropertyDescriptor(prototype, property); - } - return null; - } - function notifyListener(host, property) { - var list = host[listeners]; - var length = list.length; - for (var i = 0; i < length; i += 2) { - var listener = list[i]; - var target = list[i + 1]; - listener.call(target, property); - } - } - /** - * The Watcher class defines utility method that you can use with bindable properties. - * These methods let you define an event handler that is executed whenever a bindable property is updated. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/binding/WatcherExample.ts - * @language en_US - */ - /** - * Watcher 类能够监视可绑定属性的改变,您可以定义一个事件处理函数作为 Watcher 的回调方法,在每次可绑定属性的值改变时都执行此函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/binding/WatcherExample.ts - * @language zh_CN - */ - var Watcher = (function () { - /** - * Constructor. - * Not for public use. This method is called only from the watch() method. - * See the watch() method for parameter usage. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数,非公开。只能从 watch() 方法中调用此方法。有关参数用法,请参阅 watch() 方法。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function Watcher(property, handler, thisObject, next) { - /** - * @private - */ - this.isExecuting = false; - this.property = property; - this.handler = handler; - this.next = next; - this.thisObject = thisObject; - } - /** - * Creates and starts a Watcher instance. - * The Watcher can only watch the property of a Object which host is instance of egret.IEventDispatcher. - * @param host The object that hosts the property or property chain to be watched. - * You can use the use the reset() method to change the value of the host argument - * after creating the Watcher instance. - * The host maintains a list of handlers to invoke when prop changes. - * @param chain A value specifying the property or chain to be watched. - * For example, to watch the property host.a.b.c, - * call the method as: watch(host, ["a","b","c"], ...). - * @param handler An event handler function called when the value of the watched property - * (or any property in a watched chain) is modified. - * @param thisObject this object of which binding with handler - * @returns he ChangeWatcher instance, if at least one property name has been specified to - * the chain argument; null otherwise. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建并启动 Watcher 实例。注意:Watcher 只能监视 host 为 egret.IEventDispatcher 对象的属性改变。若属性链中某个属性所对应的实例不是 egret.IEventDispatcher, - * 则属性链中在它之后的属性改变将无法检测到。 - * @param host 用于承载要监视的属性或属性链的对象。 - * 创建Watcher实例后,您可以利用reset()方法更改host参数的值。 - * 当prop改变的时候,会使得host对应的一系列handlers被触发。 - * @param chain 用于指定要监视的属性链的值。例如,要监视属性 host.a.b.c,需按以下形式调用此方法:watch¬(host, ["a","b","c"], ...)。 - * @param handler 在监视的目标属性链中任何属性的值发生改变时调用的事件处理函数。 - * @param thisObject handler 方法绑定的this对象 - * @returns 如果已为 chain 参数至少指定了一个属性名称,则返回 Watcher 实例;否则返回 null。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Watcher.watch = function (host, chain, handler, thisObject) { - if (true) { - if (!chain) { - egret.$error(1003, "chain"); - } - } - if (chain.length > 0) { - var property = chain.shift(); - var next = Watcher.watch(null, chain, handler, thisObject); - var watcher = new Watcher(property, handler, thisObject, next); - watcher.reset(host); - return watcher; - } - else { - return null; - } - }; - /** - * @private - * 检查属性是否可以绑定。若还未绑定,尝试添加绑定事件。若是只读或只写属性,返回false。 - */ - Watcher.checkBindable = function (host, property) { - var list = host[bindables]; - if (list && list.indexOf(property) != -1) { - return true; - } - var isEventDispatcher = egret.is(host, "egret.IEventDispatcher"); - if (!isEventDispatcher && !host[listeners]) { - host[listeners] = []; - } - var data = getPropertyDescriptor(host, property); - if (data && data.set && data.get) { - var orgSet_1 = data.set; - data.set = function (value) { - if (this[property] != value) { - orgSet_1.call(this, value); - if (isEventDispatcher) { - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, property); - } - else { - notifyListener(this, property); - } - } - }; - } - else if (!data || (!data.get && !data.set)) { - bindableCount++; - var newProp_1 = "_" + bindableCount + property; - host[newProp_1] = data ? data.value : null; - data = { enumerable: true, configurable: true }; - data.get = function () { - return this[newProp_1]; - }; - data.set = function (value) { - if (this[newProp_1] != value) { - this[newProp_1] = value; - if (isEventDispatcher) { - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, property); - } - else { - notifyListener(this, property); - } - } - }; - } - else { - return false; - } - Object.defineProperty(host, property, data); - eui.registerBindable(host, property); - }; - /** - * Detaches this Watcher instance, and its handler function, from the current host. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 从当前宿主中断开此 Watcher 实例及其处理函数。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Watcher.prototype.unwatch = function () { - this.reset(null); - this.handler = null; - if (this.next) { - this.next.handler = null; - } - }; - /** - * Retrieves the current value of the watched property or property chain, or null if the host object is null. - * @example - *
      -         * watch(obj, ["a","b","c"], ...).getValue() === obj.a.b.c
      -         * 
      - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 检索观察的属性或属性链的当前值,当宿主对象为空时此值为空。 - * @example - *
      -         * watch(obj, ["a","b","c"], ...).getValue() === obj.a.b.c
      -         * 
      - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Watcher.prototype.getValue = function () { - if (this.next) { - return this.next.getValue(); - } - return this.getHostPropertyValue(); - }; - /** - * Sets the handler function.s - * @param handler The handler function. This argument must not be null. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 设置处理函数。 - * @param handler 处理函数,此参数必须为非空。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Watcher.prototype.setHandler = function (handler, thisObject) { - this.handler = handler; - this.thisObject = thisObject; - if (this.next) { - this.next.setHandler(handler, thisObject); - } - }; - /** - * Resets this ChangeWatcher instance to use a new host object. - * You can call this method to reuse a watcher instance on a different host. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 重置此 Watcher 实例使用新的宿主对象。 - * 您可以通过该方法实现一个Watcher实例用于不同的宿主。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Watcher.prototype.reset = function (newHost) { - var oldHost = this.host; - if (oldHost) { - if (egret.is(oldHost, "egret.IEventDispatcher")) { - oldHost.removeEventListener(eui.PropertyEvent.PROPERTY_CHANGE, this.wrapHandler, this); - } - else { - var list = oldHost[listeners]; - var index = list.indexOf(this); - list.splice(index - 1, 2); - } - } - this.host = newHost; - if (newHost) { - Watcher.checkBindable(newHost, this.property); - if (egret.is(newHost, "egret.IEventDispatcher")) { - newHost.addEventListener(eui.PropertyEvent.PROPERTY_CHANGE, this.wrapHandler, this, false, 100); - } - else { - var list = newHost[listeners]; - list.push(this.onPropertyChange); - list.push(this); - } - } - if (this.next) - this.next.reset(this.getHostPropertyValue()); - }; - /** - * @private - * - * @returns - */ - Watcher.prototype.getHostPropertyValue = function () { - return this.host ? this.host[this.property] : null; - }; - /** - * @private - */ - Watcher.prototype.wrapHandler = function (event) { - this.onPropertyChange(event.property); - }; - /** - * @private - */ - Watcher.prototype.onPropertyChange = function (property) { - if (property == this.property && !this.isExecuting) { - try { - this.isExecuting = true; - if (this.next) - this.next.reset(this.getHostPropertyValue()); - this.handler.call(this.thisObject, this.getValue()); - } - finally { - this.isExecuting = false; - } - } - }; - return Watcher; - }()); - eui.Watcher = Watcher; - __reflect(Watcher.prototype, "eui.Watcher"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - function joinValues(templates) { - var first = templates[0]; - var value = first instanceof eui.Watcher ? first.getValue() : first; - var length = templates.length; - for (var i = 1; i < length; i++) { - var item = templates[i]; - if (item instanceof eui.Watcher) { - item = item.getValue(); - } - value += item; - } - return value; - } - /** - * The Binding class defines utility methods for performing data binding. - * You can use the methods defined in this class to configure data bindings. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/binding/BindingExample.ts - * @language en_US - */ - /** - * 绑定工具类,用于执行数据绑定用的方法集。您可以使用此类中定义的方法来配置数据绑定。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/binding/BindingExample.ts - * @language zh_CN - */ - var Binding = (function () { - function Binding() { - } - /** - * Binds a property, prop on the target Object, to a bindable property or peoperty chain. - * @param host The object that hosts the property or property chain to be watched. - * The host maintains a list of targets to update theirs prop when chain changes. - * @param chain A value specifying the property or chain to be watched. For example, when watch the property host.a.b.c, - * you need call the method like this: indProperty(host, ["a","b","c"], ...) - * @param target The Object defining the property to be bound to chain. - * @param prop The name of the public property defined in the site Object to be bound. - * @returns A ChangeWatcher instance, if at least one property name has been specified - * to the chain argument; null otherwise. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 绑定一个对象的属性值到要监视的对象属性上。 - * @param host 用于承载要监视的属性或属性链的对象。 - * 当 hostchain所对应的值发生改变时,target上的prop属性将被自动更新。 - * @param chain 用于指定要监视的属性链的值。例如,要监视属性 host.a.b.c,需按以下形式调用此方法:bindProperty(host, ["a","b","c"], ...)。 - * @param target 本次绑定要更新的目标对象。 - * @param prop 本次绑定要更新的目标属性名称。 - * @returns 如果已为 chain 参数至少指定了一个属性名称,则返回 Watcher 实例;否则返回 null。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Binding.bindProperty = function (host, chain, target, prop) { - var watcher = eui.Watcher.watch(host, chain, null, null); - if (watcher) { - var assign = function (value) { - target[prop] = value; - }; - watcher.setHandler(assign, null); - assign(watcher.getValue()); - } - return watcher; - }; - /** - * Binds a callback, handler on the target Object, to a bindable property or peoperty chain. - * Callback method to invoke with an argument of the current value of chain when that value changes. - * @param host The object that hosts the property or property chain to be watched. - * @param chain A value specifying the property or chain to be watched. For example, when watch the property host.a.b.c, - * you need call the method like this: indProperty(host, ["a","b","c"], ...) - * @param handler method to invoke with an argument of the current value of chain when that value changes. - * @param thisObject this object of binding method - * @returns A ChangeWatcher instance, if at least one property name has been specified to the chain argument; null otherwise. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 绑定一个回调函数到要监视的对象属性上。当 host上 chain 所对应的值发生改变时,handler 方法将被自动调用。 - * @param host 用于承载要监视的属性或属性链的对象。 - * @param chain 用于指定要监视的属性链的值。例如,要监视属性 host.a.b.c,需按以下形式调用此方法:bindSetter(host, ["a","b","c"], ...)。 - * @param handler 在监视的目标属性链中任何属性的值发生改变时调用的事件处理函数。 - * @param thisObject handler 方法绑定的this对象 - * @returns 如果已为 chain 参数至少指定了一个属性名称,则返回 Watcher 实例;否则返回 null。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Binding.bindHandler = function (host, chain, handler, thisObject) { - var watcher = eui.Watcher.watch(host, chain, handler, thisObject); - if (watcher) { - handler.call(thisObject, watcher.getValue()); - } - return watcher; - }; - Binding.$bindProperties = function (host, templates, chainIndex, target, prop) { - if (templates.length == 1 && chainIndex.length == 1) { - return Binding.bindProperty(host, templates[0].split("."), target, prop); - } - var assign = function () { - target[prop] = joinValues(templates); - }; - var length = chainIndex.length; - var watcher; - for (var i = 0; i < length; i++) { - var index = chainIndex[i]; - var chain = templates[index].split("."); - watcher = eui.Watcher.watch(host, chain, null, null); - if (watcher) { - templates[index] = watcher; - watcher.setHandler(assign, null); - } - } - assign(); - return watcher; - }; - return Binding; - }()); - eui.Binding = Binding; - __reflect(Binding.prototype, "eui.Binding"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -/// -var eui; -(function (eui) { - /** - * The ArrayCollection class is a wrapper class that exposes an any[] as a collection that can be - * accessed and manipulated using the methods and properties of the ICollection interfaces. - * ArrayCollection can notify the view to update item when data source changed. - * - * @event eui.CollectionEvent.COLLECTION_CHANGE Dispatched when the ArrayCollection has been updated in some way. - * - * @defaultProperty source - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/collections/ArrayCollectionExample.ts - * @language en_US - */ - /** - * ArrayCollection 类是数组的集合类数据结构包装器,可使用ICollection接口的方法和属性对其进行访问和处理。 - * 使用这种数据结构包装普通数组,能在数据源发生改变的时候主动通知视图刷新变更数据项。 - * - * @event eui.CollectionEvent.COLLECTION_CHANGE 当 ArrayCollection 更新的的时候会派发此事件。 - * - * @defaultProperty source - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/collections/ArrayCollectionExample.ts - * @language zh_CN - */ - var ArrayCollection = (function (_super) { - __extends(ArrayCollection, _super); - /** - * Constructor.

      - * Creates a new ArrayCollection using the specified source array. - * If no array is specified an empty array will be used. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。

      - * 用指定的原始数组创建一个 ArrayCollection 实例。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function ArrayCollection(source) { - var _this = _super.call(this) || this; - if (source) { - _this._source = source; - } - else { - _this._source = []; - } - return _this; - } - Object.defineProperty(ArrayCollection.prototype, "source", { - /** - * The source of data in the ArrayCollection. - * The ArrayCollection object does not represent any changes that you make - * directly to the source array. Always use the ICollection methods to view the collection. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 数据源 - * 通常情况下请不要直接调用Array的方法操作数据源,否则对应的视图无法收到数据改变的通知。通常都是通过ICollection的接口方法来查看数据。 - * 若对数据源进行了修改,请手动调用refresh()方法刷新数据。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._source; - }, - set: function (value) { - if (!value) - value = []; - this._source = value; - this.dispatchCoEvent(eui.CollectionEventKind.RESET); - }, - enumerable: true, - configurable: true - }); - /** - * Applies the sort and filter to the view. - * The ArrayCollection does not detect source data changes automatically, - * so you must call the refresh() - * method to update the view after changing the source data. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在对数据源进行排序或过滤操作后可以手动调用此方法刷新所有数据,以更新视图。 - * ArrayCollection 不会自动检原始数据进行了改变,所以你必须调用refresh()方法去更新显示。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ArrayCollection.prototype.refresh = function () { - this.dispatchCoEvent(eui.CollectionEventKind.REFRESH); - }; - Object.defineProperty(ArrayCollection.prototype, "length", { - //-------------------------------------------------------------------------- - // - // ICollection接口实现方法 - // - //-------------------------------------------------------------------------- - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - return this._source.length; - }, - enumerable: true, - configurable: true - }); - /** - * Adds the specified item to the end of the list. - * Equivalent to addItemAt(item, length). - * @param item The item to add. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 向列表末尾添加指定项目。等效于 addItemAt(item, length)。 - * @param item 要被添加的项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ArrayCollection.prototype.addItem = function (item) { - this._source.push(item); - this.dispatchCoEvent(eui.CollectionEventKind.ADD, this._source.length - 1, -1, [item]); - }; - /** - * Adds the item at the specified index. - * The index of any item greater than the index of the added item is increased by one. - * If the the specified index is less than zero or greater than the length - * of the list, a Error which code is 1007 is thrown. - * @param item The item to place at the index. - * @param index The index at which to place the item. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 在指定的索引处添加项目。 - * 任何大于已添加项目的索引的项目索引都会增加 1。 - * 如果指定的索引比0小或者比最大长度要大。则会抛出1007异常。 - * @param item 要添加的项 - * @param index 要添加的指定索引位置 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ArrayCollection.prototype.addItemAt = function (item, index) { - if (index < 0 || index > this._source.length) { - true && egret.$error(1007); - } - this._source.splice(index, 0, item); - this.dispatchCoEvent(eui.CollectionEventKind.ADD, index, -1, [item]); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ArrayCollection.prototype.getItemAt = function (index) { - return this._source[index]; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ArrayCollection.prototype.getItemIndex = function (item) { - var length = this._source.length; - for (var i = 0; i < length; i++) { - if (this._source[i] === item) { - return i; - } - } - return -1; - }; - /** - * Notifies the view that an item has been updated. - * @param item The item within the view that was updated. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 通知视图,某个项目的属性已更新。 - * @param item 视图中需要被更新的项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ArrayCollection.prototype.itemUpdated = function (item) { - var index = this.getItemIndex(item); - if (index != -1) { - this.dispatchCoEvent(eui.CollectionEventKind.UPDATE, index, -1, [item]); - } - }; - /** - * Removes all items from the list. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 删除列表中的所有项目。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ArrayCollection.prototype.removeAll = function () { - var items = this._source.concat(); - this._source = []; - this.dispatchCoEvent(eui.CollectionEventKind.REMOVE, 0, -1, items); - }; - /** - * Removes the item at the specified index and returns it. - * Any items that were after this index are now one index earlier. - * @param index The index from which to remove the item. - * @return The item that was removed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 删除指定索引处的项目并返回该项目。原先位于此索引之后的所有项目的索引现在都向前移动一个位置。 - * @param index 要被移除的项的索引。 - * @return 被移除的项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ArrayCollection.prototype.removeItemAt = function (index) { - if (index < 0 || index >= this._source.length) { - true && egret.$error(1007); - return; - } - var item = this._source.splice(index, 1)[0]; - this.dispatchCoEvent(eui.CollectionEventKind.REMOVE, index, -1, [item]); - return item; - }; - /** - * Replaces the item at the specified index. - * @param item The new item to be placed at the specified index. - * @param index The index at which to place the item. - * @return The item that was replaced, or null if none. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 替换在指定索引处的项目,并返回该项目。 - * @param item 要在指定索引放置的新的项。 - * @param index 要被替换的项的索引位置。 - * @return 被替换的项目,如果没有该项则返回null 。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ArrayCollection.prototype.replaceItemAt = function (item, index) { - if (index < 0 || index >= this._source.length) { - true && egret.$error(1007); - return; - } - var oldItem = this._source.splice(index, 1, item)[0]; - this.dispatchCoEvent(eui.CollectionEventKind.REPLACE, index, -1, [item], [oldItem]); - return oldItem; - }; - /** - * Replaces all items with a new source data, this method can not reset the scroller position of view. - * @param newSource new source data. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 用新数据源替换原始数据源,此方法与直接设置source不同,它不会导致目标视图重置滚动位置。 - * @param newSource 新数据。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ArrayCollection.prototype.replaceAll = function (newSource) { - if (!newSource) - newSource = []; - var newLength = newSource.length; - var oldLength = this._source.length; - for (var i = newLength; i < oldLength; i++) { - this.removeItemAt(newLength); - } - for (var i = 0; i < newLength; i++) { - if (i >= oldLength) - this.addItemAt(newSource[i], i); - else - this.replaceItemAt(newSource[i], i); - } - this._source = newSource; - }; - /** - * @private - * 抛出事件 - */ - ArrayCollection.prototype.dispatchCoEvent = function (kind, location, oldLocation, items, oldItems) { - eui.CollectionEvent.dispatchCollectionEvent(this, eui.CollectionEvent.COLLECTION_CHANGE, kind, location, oldLocation, items, oldItems); - }; - return ArrayCollection; - }(egret.EventDispatcher)); - eui.ArrayCollection = ArrayCollection; - __reflect(ArrayCollection.prototype, "eui.ArrayCollection", ["eui.ICollection", "egret.IEventDispatcher"]); - eui.registerProperty(ArrayCollection, "source", "Array", true); -})(eui || (eui = {})); -var eui; -(function (eui) { - var UIImpl = eui.sys.UIComponentImpl; - /** - * Editable text for displaying, - * scrolling, selecting, and editing text. - * @includeExample extension/eui/components/EditablTextExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 可编辑文本,用于显示、滚动、选择和编辑文本。 - * @includeExample extension/eui/components/EditablTextExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var EditableText = (function (_super) { - __extends(EditableText, _super); - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function EditableText() { - var _this = _super.call(this) || this; - /** - * @private - */ - _this._widthConstraint = NaN; - /** - * @private - */ - _this.$isShowPrompt = false; - /** - * @private - */ - _this.$promptColor = 0x666666; - /** - * @private - */ - _this.$isFocusIn = false; - /** - * @private - */ - _this.$isTouchCancle = false; - _this.initializeUIValues(); - _this.type = egret.TextFieldType.INPUT; - _this.$EditableText = { - 0: null, - 1: 0xffffff, - 2: false //asPassword - }; - return _this; - } - /** - * @private - * - */ - EditableText.prototype.$invalidateTextField = function () { - _super.prototype.$invalidateTextField.call(this); - this.invalidateSize(); - }; - /** - * @private - * - * @param value - */ - EditableText.prototype.$setWidth = function (value) { - var result1 = _super.prototype.$setWidth.call(this, value); - var result2 = UIImpl.prototype.$setWidth.call(this, value); - return result1 && result2; - }; - /** - * @private - * - * @param value - */ - EditableText.prototype.$setHeight = function (value) { - var result1 = _super.prototype.$setHeight.call(this, value); - var result2 = UIImpl.prototype.$setHeight.call(this, value); - return result1 && result2; - }; - /** - * @private - * - * @param value - */ - EditableText.prototype.$getText = function () { - var value = _super.prototype.$getText.call(this); - if (value == this.$EditableText[0 /* promptText */]) { - value = ""; - } - return value; - }; - /** - * @private - * - * @param value - */ - EditableText.prototype.$setText = function (value) { - var promptText = this.$EditableText[0 /* promptText */]; - if (promptText != value || promptText == null) { - this.$isShowPrompt = false; - this.textColor = this.$EditableText[1 /* textColorUser */]; - this.displayAsPassword = this.$EditableText[2 /* asPassword */]; - } - if (!this.$isFocusIn) { - if (value == "" || value == null) { - value = promptText; - this.$isShowPrompt = true; - _super.prototype.$setTextColor.call(this, this.$promptColor); - _super.prototype.$setDisplayAsPassword.call(this, false); - } - } - var result = _super.prototype.$setText.call(this, value); - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "text"); - return result; - }; - /** - * @private - * - * @param stage - * @param nestLevel - */ - EditableText.prototype.$onAddToStage = function (stage, nestLevel) { - eui.sys.UIComponentImpl.prototype["$onAddToStage"].call(this, stage, nestLevel); - this.addEventListener(egret.FocusEvent.FOCUS_IN, this.onfocusIn, this); - this.addEventListener(egret.FocusEvent.FOCUS_OUT, this.onfocusOut, this); - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this); - this.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchCancle, this); - }; - /** - * @private - * - */ - EditableText.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - this.removeEventListener(egret.FocusEvent.FOCUS_IN, this.onfocusIn, this); - this.removeEventListener(egret.FocusEvent.FOCUS_OUT, this.onfocusOut, this); - this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchBegin, this); - this.removeEventListener(egret.TouchEvent.TOUCH_CANCEL, this.onTouchCancle, this); - }; - Object.defineProperty(EditableText.prototype, "prompt", { - /** - * When the property of the text is empty, it will show the defalut string. - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 当text属性为空字符串时要显示的文本内容。 - * 先创建文本控件时将显示提示文本。控件获得焦点时或控件的 text 属性为非空字符串时,提示文本将消失。 - * 控件失去焦点时提示文本将重新显示,但仅当未输入文本时(如果文本字段的值为空字符串)。

      - * 对于文本控件,如果用户输入文本,但随后又将其删除,则控件失去焦点后,提示文本将重新显示。 - * 您还可以通过编程方式将文本控件的 text 属性设置为空字符串使提示文本重新显示。 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this.$EditableText[0 /* promptText */]; - }, - set: function (value) { - var values = this.$EditableText; - var promptText = values[0 /* promptText */]; - if (promptText == value) - return; - values[0 /* promptText */] = value; - var text = this.text; - if (!text || text == promptText) { - this.showPromptText(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EditableText.prototype, "promptColor", { - get: function () { - return this.$promptColor; - }, - /** - * The color of the defalut string. - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本的颜色 - * @version Egret 2.5.5 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - set: function (value) { - value = +value | 0; - if (this.$promptColor != value) { - this.$promptColor = value; - var text = this.text; - if (!text || text == this.$EditableText[0 /* promptText */]) { - this.showPromptText(); - } - } - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - EditableText.prototype.onfocusOut = function () { - this.$isFocusIn = false; - if (!this.text) { - this.showPromptText(); - } - }; - /** - * @private - */ - EditableText.prototype.onTouchBegin = function () { - this.$isTouchCancle = false; - }; - /** - * @private - */ - EditableText.prototype.onTouchCancle = function () { - this.$isTouchCancle = true; - }; - /** - * @private - */ - EditableText.prototype.onfocusIn = function () { - if (!egret.Capabilities.isMobile && this.$isTouchCancle) { - this.inputUtils.stageText.$hide(); - return; - } - this.$isFocusIn = true; - this.$isShowPrompt = false; - this.displayAsPassword = this.$EditableText[2 /* asPassword */]; - var values = this.$EditableText; - var text = this.text; - if (!text || text == values[0 /* promptText */]) { - this.textColor = values[1 /* textColorUser */]; - this.text = ""; - } - }; - /** - * @private - */ - EditableText.prototype.showPromptText = function () { - var values = this.$EditableText; - this.$isShowPrompt = true; - _super.prototype.$setTextColor.call(this, this.$promptColor); - _super.prototype.$setDisplayAsPassword.call(this, false); - this.text = values[0 /* promptText */]; - }; - /** - * @private - */ - EditableText.prototype.$setTextColor = function (value) { - value = +value | 0; - this.$EditableText[1 /* textColorUser */] = value; - if (!this.$isShowPrompt) { - _super.prototype.$setTextColor.call(this, value); - } - return true; - }; - /** - * @private - */ - EditableText.prototype.$setDisplayAsPassword = function (value) { - this.$EditableText[2 /* asPassword */] = value; - if (!this.$isShowPrompt) { - _super.prototype.$setDisplayAsPassword.call(this, value); - } - return true; - }; - /** - * @copy eui.Component#createChildren() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.createChildren = function () { - this.onfocusOut(); - }; - /** - * @copy eui.Component#childrenCreated() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.childrenCreated = function () { - }; - /** - * @copy eui.Component#commitProperties() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.commitProperties = function () { - }; - /** - * @copy eui.Component#measure() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.measure = function () { - var values = this.$UIComponent; - var textValues = this.$TextField; - var oldWidth = textValues[3 /* textFieldWidth */]; - var availableWidth = NaN; - if (!isNaN(this._widthConstraint)) { - availableWidth = this._widthConstraint; - this._widthConstraint = NaN; - } - else if (!isNaN(values[8 /* explicitWidth */])) { - availableWidth = values[8 /* explicitWidth */]; - } - else if (values[13 /* maxWidth */] != 100000) { - availableWidth = values[13 /* maxWidth */]; - } - _super.prototype.$setWidth.call(this, availableWidth); - this.setMeasuredSize(this.textWidth, this.textHeight); - _super.prototype.$setWidth.call(this, oldWidth); - }; - /** - * @copy eui.Component#updateDisplayList() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - _super.prototype.$setWidth.call(this, unscaledWidth); - _super.prototype.$setHeight.call(this, unscaledHeight); - }; - /** - * @copy eui.Component#invalidateParentLayout() - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.invalidateParentLayout = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.setMeasuredSize = function (width, height) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.invalidateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.validateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.invalidateSize = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.validateSize = function (recursive) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.invalidateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.validateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.validateNow = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.setLayoutBoundsSize = function (layoutWidth, layoutHeight) { - UIImpl.prototype.setLayoutBoundsSize.call(this, layoutWidth, layoutHeight); - if (isNaN(layoutWidth) || layoutWidth === this._widthConstraint || layoutWidth == 0) { - return; - } - var values = this.$UIComponent; - if (!isNaN(values[9 /* explicitHeight */])) { - return; - } - if (layoutWidth == values[16 /* measuredWidth */]) { - return; - } - this._widthConstraint = layoutWidth; - this.invalidateSize(); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.setLayoutBoundsPosition = function (x, y) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.getLayoutBounds = function (bounds) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - EditableText.prototype.getPreferredBounds = function (bounds) { - }; - return EditableText; - }(egret.TextField)); - eui.EditableText = EditableText; - __reflect(EditableText.prototype, "eui.EditableText", ["eui.UIComponent", "egret.DisplayObject", "eui.IDisplayText"]); - eui.sys.implementUIComponent(EditableText, egret.TextField); - eui.registerBindable(EditableText.prototype, "text"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var sys; - (function (sys) { - /** - * @private - * 需要记录的历史速度的最大次数。 - */ - var MAX_VELOCITY_COUNT = 4; - /** - * @private - * 记录的历史速度的权重列表。 - */ - var VELOCITY_WEIGHTS = [1, 1.33, 1.66, 2]; - /** - * @private - * 当前速度所占的权重。 - */ - var CURRENT_VELOCITY_WEIGHT = 2.33; - /** - * @private - * 最小的改变速度,解决浮点数精度问题。 - */ - var MINIMUM_VELOCITY = 0.02; - /** - * @private - * 当容器自动滚动时要应用的摩擦系数 - */ - var FRICTION = 0.998; - /** - * @private - * 当容器自动滚动时并且滚动位置超出容器范围时要额外应用的摩擦系数 - */ - var EXTRA_FRICTION = 0.95; - /** - * @private - * 摩擦系数的自然对数 - */ - var FRICTION_LOG = Math.log(FRICTION); - /** - * @private - * - * @param ratio - * @returns - */ - function easeOut(ratio) { - var invRatio = ratio - 1.0; - return invRatio * invRatio * invRatio + 1; - } - /** - * @private - * 一个工具类,用于容器的滚屏拖动操作,计算在一段时间持续滚动后释放,应该继续滚动到的值和缓动时间。 - * 使用此工具类,您需要创建一个 ScrollThrown 实例,并在滚动发生时调用start()方法,然后在触摸移动过程中调用update()更新当前舞台坐标。 - * 内部将会启动一个计时器定时根据当前位置计算出速度值,并缓存下来最后4个值。当停止滚动时,再调用finish()方法, - * 将立即停止记录位移,并将计算出的最终结果存储到 Thrown.scrollTo 和 Thrown.duration 属性上。 - */ - var TouchScroll = (function () { - /** - * @private - * 创建一个 TouchScroll 实例 - * @param updateFunction 滚动位置更新回调函数 - */ - function TouchScroll(updateFunction, endFunction, target) { - /** - * @private - * 当前容器滚动外界可调节的系列 - */ - this.$scrollFactor = 1.0; - /** - * @private - */ - this.previousTime = 0; - /** - * @private - */ - this.velocity = 0; - /** - * @private - */ - this.previousVelocity = []; - /** - * @private - */ - this.currentPosition = 0; - /** - * @private - */ - this.previousPosition = 0; - /** - * @private - */ - this.currentScrollPos = 0; - /** - * @private - */ - this.maxScrollPos = 0; - /** - * @private - * 触摸按下时的偏移量 - */ - this.offsetPoint = 0; - this.$bounces = true; - this.started = true; - if (true && !updateFunction) { - egret.$error(1003, "updateFunction"); - } - this.updateFunction = updateFunction; - this.endFunction = endFunction; - this.target = target; - this.animation = new sys.Animation(this.onScrollingUpdate, this); - this.animation.endFunction = this.finishScrolling; - this.animation.easerFunction = easeOut; - } - /** - * @private - * 正在播放缓动动画的标志。 - */ - TouchScroll.prototype.isPlaying = function () { - return this.animation.isPlaying; - }; - /** - * @private - * 如果正在执行缓动滚屏,停止缓动。 - */ - TouchScroll.prototype.stop = function () { - this.animation.stop(); - egret.stopTick(this.onTick, this); - this.started = false; - }; - /** - * @private - * true表示已经调用过start方法。 - */ - TouchScroll.prototype.isStarted = function () { - return this.started; - }; - /** - * @private - * 开始记录位移变化。注意:当使用完毕后,必须调用 finish() 方法结束记录,否则该对象将无法被回收。 - * @param touchPoint 起始触摸位置,以像素为单位,通常是stageX或stageY。 - */ - TouchScroll.prototype.start = function (touchPoint) { - this.started = true; - this.velocity = 0; - this.previousVelocity.length = 0; - this.previousTime = egret.getTimer(); - this.previousPosition = this.currentPosition = touchPoint; - this.offsetPoint = touchPoint; - egret.startTick(this.onTick, this); - }; - /** - * @private - * 更新当前移动到的位置 - * @param touchPoint 当前触摸位置,以像素为单位,通常是stageX或stageY。 - */ - TouchScroll.prototype.update = function (touchPoint, maxScrollValue, scrollValue) { - maxScrollValue = Math.max(maxScrollValue, 0); - this.currentPosition = touchPoint; - this.maxScrollPos = maxScrollValue; - var disMove = this.offsetPoint - touchPoint; - var scrollPos = disMove + scrollValue; - this.offsetPoint = touchPoint; - if (scrollPos < 0) { - if (!this.$bounces) { - scrollPos = 0; - } - else { - scrollPos -= disMove * 0.5; - } - } - if (scrollPos > maxScrollValue) { - if (!this.$bounces) { - scrollPos = maxScrollValue; - } - else { - scrollPos -= disMove * 0.5; - } - } - this.currentScrollPos = scrollPos; - this.updateFunction.call(this.target, scrollPos); - }; - /** - * @private - * 停止记录位移变化,并计算出目标值和继续缓动的时间。 - * @param currentScrollPos 容器当前的滚动值。 - * @param maxScrollPos 容器可以滚动的最大值。当目标值不在 0~maxValue之间时,将会应用更大的摩擦力,从而影响缓动时间的长度。 - */ - TouchScroll.prototype.finish = function (currentScrollPos, maxScrollPos) { - egret.stopTick(this.onTick, this); - this.started = false; - var sum = this.velocity * CURRENT_VELOCITY_WEIGHT; - var previousVelocityX = this.previousVelocity; - var length = previousVelocityX.length; - var totalWeight = CURRENT_VELOCITY_WEIGHT; - for (var i = 0; i < length; i++) { - var weight = VELOCITY_WEIGHTS[i]; - sum += previousVelocityX[0] * weight; - totalWeight += weight; - } - var pixelsPerMS = sum / totalWeight; - var absPixelsPerMS = Math.abs(pixelsPerMS); - var duration = 0; - var posTo = 0; - if (absPixelsPerMS > MINIMUM_VELOCITY) { - posTo = currentScrollPos + (pixelsPerMS - MINIMUM_VELOCITY) / FRICTION_LOG * 2 * this.$scrollFactor; - if (posTo < 0 || posTo > maxScrollPos) { - posTo = currentScrollPos; - while (Math.abs(pixelsPerMS) > MINIMUM_VELOCITY) { - posTo -= pixelsPerMS; - if (posTo < 0 || posTo > maxScrollPos) { - pixelsPerMS *= FRICTION * EXTRA_FRICTION; - } - else { - pixelsPerMS *= FRICTION; - } - duration++; - } - } - else { - duration = Math.log(MINIMUM_VELOCITY / absPixelsPerMS) / FRICTION_LOG; - } - } - else { - posTo = currentScrollPos; - } - if (this.target["$getThrowInfo"]) { - var event_1 = this.target["$getThrowInfo"](currentScrollPos, posTo); - posTo = event_1.toPos; - } - if (duration > 0) { - //如果取消了回弹,保证动画之后不会超出边界 - if (!this.$bounces) { - if (posTo < 0) { - posTo = 0; - } - else if (posTo > maxScrollPos) { - posTo = maxScrollPos; - } - } - this.throwTo(posTo, duration); - } - else { - this.finishScrolling(); - } - }; - /** - * @private - * - * @param timeStamp - * @returns - */ - TouchScroll.prototype.onTick = function (timeStamp) { - var timeOffset = timeStamp - this.previousTime; - if (timeOffset > 10) { - var previousVelocity = this.previousVelocity; - if (previousVelocity.length >= MAX_VELOCITY_COUNT) { - previousVelocity.shift(); - } - this.velocity = (this.currentPosition - this.previousPosition) / timeOffset; - previousVelocity.push(this.velocity); - this.previousTime = timeStamp; - this.previousPosition = this.currentPosition; - } - return true; - }; - /** - * @private - * - * @param animation - */ - TouchScroll.prototype.finishScrolling = function (animation) { - var hsp = this.currentScrollPos; - var maxHsp = this.maxScrollPos; - var hspTo = hsp; - if (hsp < 0) { - hspTo = 0; - } - if (hsp > maxHsp) { - hspTo = maxHsp; - } - this.throwTo(hspTo, 300); - }; - /** - * @private - * 缓动到水平滚动位置 - */ - TouchScroll.prototype.throwTo = function (hspTo, duration) { - if (duration === void 0) { duration = 500; } - var hsp = this.currentScrollPos; - if (hsp == hspTo) { - this.endFunction.call(this.target); - return; - } - var animation = this.animation; - animation.duration = duration; - animation.from = hsp; - animation.to = hspTo; - animation.play(); - }; - /** - * @private - * 更新水平滚动位置 - */ - TouchScroll.prototype.onScrollingUpdate = function (animation) { - this.currentScrollPos = animation.currentValue; - this.updateFunction.call(this.target, animation.currentValue); - }; - return TouchScroll; - }()); - sys.TouchScroll = TouchScroll; - __reflect(TouchScroll.prototype, "eui.sys.TouchScroll"); - })(sys = eui.sys || (eui.sys = {})); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * Defines values for setting the direction property - * of the ProgressBar class. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/DirectionExample.ts - * @language en_US - */ - /** - * 定义进度条等控件增长方向的常量 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/DirectionExample.ts - * @language zh_CN - */ - var Direction = (function () { - function Direction() { - } - /** - * Specifies left-to-right direction. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 水平从左到右增长 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Direction.LTR = "ltr"; - /** - * Specifies right-to-left direction. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 水平从右到左增长 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Direction.RTL = "rtl"; - /** - * Specifies top-to-bottom direction. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 竖直从上到下增长 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Direction.TTB = "ttb"; - /** - * Specifies bottom-to-top direction. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 竖直从下到上增长 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Direction.BTT = "btt"; - return Direction; - }()); - eui.Direction = Direction; - __reflect(Direction.prototype, "eui.Direction"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * Values for the horizontalCanScroll and - * verticalCanScroll properties of the Scroller classes. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/ScrollPolicyExample.ts - * @language en_US - */ - /** - * 滚动条显示策略常量。 - * Scroller 类的 horizontalCanScrollverticalCanScroll 属性的值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/ScrollPolicyExample.ts - * @language zh_CN - */ - var ScrollPolicy = (function () { - function ScrollPolicy() { - } - /** - * Show the scrollbar if the children exceed the owner's dimension. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 如果子项超出父级的尺寸,则允许滚动,反之不允许滚动。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ScrollPolicy.AUTO = "auto"; - /** - * Never show the scrollbar. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 从不允许滚动。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ScrollPolicy.OFF = "off"; - /** - * Always show the scrollbar. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 总是允许滚动。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ScrollPolicy.ON = "on"; - return ScrollPolicy; - }()); - eui.ScrollPolicy = ScrollPolicy; - __reflect(ScrollPolicy.prototype, "eui.ScrollPolicy"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * Note: The skin name values in the skin theme are used as default values,which can not be changed while running. - * You can change the skin of a component with the skinName property. - * @event egret.Event.COMPLETE Dispatch when EXML used in this theme is loaded and parsed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/ThemeExample.ts - * @language en_US - */ - /** - * 皮肤主题。注意:皮肤主题是一次性设置的默认值,并不能运行时切换所有组件默认皮肤。切换单个皮肤您可以自行对Component.skinName赋值来修改。 - * @event egret.Event.COMPLETE 当主题关联的EXML加载解析完成时派发 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/core/ThemeExample.ts - * @language zh_CN - */ - var Theme = (function (_super) { - __extends(Theme, _super); - /** - * Create an instance of Theme - * @param configURL the external theme path. if null, you need to register the default skin name with - * mapSkin() manually. - * @param stage current stage. - * If null, you need to register with egret.registerImplementation("eui.Theme",theme) - * manually. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个主题实例 - * @param configURL 要加载并解析的外部主题配置文件路径。若传入 null,将不进行配置文件加载, - * 之后需要在外部以代码方式手动调用 mapSkin() 方法完成每条默认皮肤名的注册。 - * @param stage 当前舞台引用。 - * 若传入null,需要在外部手动调用 egret.registerImplementation("eui.Theme",theme) 来完成主题的注册。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function Theme(configURL, stage) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this.delayList = []; - /** - * @private - */ - _this.skinMap = {}; - /** - * @private - * styles 配置信息 - */ - _this.$styles = {}; - _this.initialized = !configURL; - if (stage) { - egret.registerImplementation("eui.Theme", _this); - } - _this.$configURL = configURL; - _this.load(configURL); - return _this; - } - /** - * @private - * - * @param url - */ - Theme.prototype.load = function (url) { - var _this = this; - eui.getTheme(url, function (data) { return _this.onConfigLoaded(data); }); - }; - /** - * @private - * - * @param str - */ - Theme.prototype.onConfigLoaded = function (str) { - var data; - if (typeof str == "string") { - try { - data = JSON.parse(str); - } - catch (e) { - egret.$error(3000); - } - } - else { - data = str; - } - if (data && data.skins) { - var skinMap = this.skinMap; - var skins = data.skins; - var keys = Object.keys(skins); - var length_27 = keys.length; - for (var i = 0; i < length_27; i++) { - var key = keys[i]; - if (!skinMap[key]) { - this.mapSkin(key, skins[key]); - } - } - } - if (data.styles) { - this.$styles = data.styles; - } - var paths = data.paths; - for (var path in paths) { - EXML.update(path, paths[path]); - } - //commonjs|commonjs2 - if (!data.exmls || data.exmls.length == 0) { - this.onLoaded(); - } - else if (data.exmls[0]['gjs']) { - data.exmls.forEach(function (exml) { return EXML.$parseURLContentAsJs(exml.path, exml.gjs, exml.className); }); - this.onLoaded(); - } - else if (data.exmls[0]['content']) { - data.exmls.forEach(function (exml) { return EXML.$parseURLContent(exml.path, exml.content); }); - this.onLoaded(); - } - else { - EXML.$loadAll(data.exmls, this.onLoaded, this, true); - } - }; - Theme.prototype.onLoaded = function (classes, urls) { - this.initialized = true; - this.handleDelayList(); - this.dispatchEventWith(egret.Event.COMPLETE); - }; - /** - * @private - * - */ - Theme.prototype.handleDelayList = function () { - var list = this.delayList; - var length = list.length; - for (var i = 0; i < length; i++) { - var client = list[i]; - if (!client.$Component[5 /* skinNameExplicitlySet */]) { - var skinName = this.getSkinName(client); - if (skinName) { - client.$Component[1 /* skinName */] = skinName; - client.$parseSkinName(); - } - } - } - list.length = 0; - }; - /** - * According to the host component to get the default skin name. - * Search rules are as follows: - *

    • 1. Use the hostComponentKey of client to search.
    • - *
    • 2. Use the class name of client to search.
    • - *
    • 3. Use the parent class name of client to search.
    • - *
    • 4. Repeat step 3 until find the skin name or the parent is eui.Component.
    • - * @param client the component need to get the default skin. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 根据主机组件,获取对应的默认皮肤名。查询规则如下: - *
    • 1.使用client的hostComponentKey作为键查询默认皮肤名。
    • - *
    • 2.使用client的类名作为键查询默认皮肤名。
    • - *
    • 3.使用client的父类名作为键查询默认皮肤名。
    • - *
    • 4.不断重复3直到查询到皮肤名或父类为eui.Component时停止。
    • - * @param client 要获取默认皮肤的组件。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Theme.prototype.getSkinName = function (client) { - if (!this.initialized) { - if (this.delayList.indexOf(client) == -1) { - this.delayList.push(client); - } - return ""; - } - var skinMap = this.skinMap; - var skinName = skinMap[client.hostComponentKey]; - if (!skinName) { - skinName = this.findSkinName(client); - } - return skinName; - }; - /** - * @private - */ - Theme.prototype.findSkinName = function (prototype) { - if (!prototype) { - return ""; - } - var key = prototype["__class__"]; - if (key === void 0) { - return ""; - } - var skinName = this.skinMap[key]; - if (skinName || key == "eui.Component") { - return skinName; - } - return this.findSkinName(Object.getPrototypeOf(prototype)); - }; - /** - * Map a default skin for the specified host component. - * @param hostComponentKey the name of host component, such as "eui.Button". - * @param skinName the name of skin, such as "app.MyButtonSkin". - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 为指定的主机组件映射一个默认皮肤。 - * @param hostComponentKey 主机组件名称,例如:“eui.Button”。 - * @param skinName 皮肤名称 例如:"app.MyButtonSkin"。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - Theme.prototype.mapSkin = function (hostComponentKey, skinName) { - if (true) { - if (!hostComponentKey) { - egret.$error(1003, "hostComponentKey"); - } - if (!skinName) { - egret.$error(1003, "skinName"); - } - } - this.skinMap[hostComponentKey] = skinName; - }; - Theme.prototype.$getStyleConfig = function (style) { - return this.$styles[style]; - }; - return Theme; - }(egret.EventDispatcher)); - eui.Theme = Theme; - __reflect(Theme.prototype, "eui.Theme"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The eui.CollectionEvent class represents an event that is - * dispatched when the associated collection changes. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/CollectionEventExample.ts - * @language en_US - */ - /** - * 集合类型数据改变事件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/CollectionEventExample.ts - * @language zh_CN - */ - var CollectionEvent = (function (_super) { - __extends(CollectionEvent, _super); - /** - * Constructor. - * - * @param type The event type; indicates the action that triggered the event. - * @param bubbles Specifies whether the event can bubble - * up the display list hierarchy. - * @param cancelable Specifies whether the behavior - * associated with the event can be prevented. - * @param kind Indicates the kind of event that occured. - * The parameter value can be one of the values in the CollectionEventKind - * class, or null, which indicates that the kind is unknown. - * @param location When the kind is - * CollectionEventKind.ADD, - * CollectionEventKind.REMOVE, - * CollectionEventKind.REPLACE,or - * CollectionEventKind.UPDATE - * this value indicates at what location the item(s) specified - * in the items property can be found - * within the target collection. - * @param oldLocation this value indicates - * the old location within the target collection - * of the item(s) specified in the items property. - * @param items Array of objects with information about the items - * affected by the event. - * @param oldItems When the kine is CollectionEventKind.REPLACE the value represents - * a list of items before replaced. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 CollectionEvent 实例 - * - * @param type 事件类型;指示触发事件的动作。 - * @param bubbles 指定该事件是否可以在显示列表层次结构得到冒泡处理。 - * @param cancelable 指定是否可以防止与事件相关联的行为。 - * @param kind 指示发生的事件类型。此属性值可以是 CollectionEventKind 类中的一个值,也可以是 null,用于指示类型未知。 - * @param location 如果 kind 值为 CollectionEventKind.ADD, - * CollectionEventKind.REMOVE, - * CollectionEventKind.REPLACE,或 - * CollectionEventKind.UPDATE - * 则此属性为 items 属性中指定的项目集合中零号元素的的索引。 - * @param oldLocation 此值指示 items 属性中指定的项目在目标集合中的原位置。 - * @param items 受事件影响的项目的列表。 - * @param oldItems 仅当kind的值为CollectionEventKind.REPLACE时,表示替换前的项目列表。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function CollectionEvent(type, bubbles, cancelable, kind, location, oldLocation, items, oldItems) { - var _this = _super.call(this, type, bubbles, cancelable) || this; - _this.$initTo(kind, location, oldLocation, items, oldItems); - return _this; - } - /** - * @private - * - * @param kind - * @param location - * @param oldLocation - * @param items - * @param oldItems - */ - CollectionEvent.prototype.$initTo = function (kind, location, oldLocation, items, oldItems) { - this.kind = kind; - this.location = +location | 0; - this.oldLocation = +oldLocation | 0; - this.items = items || []; - this.oldItems = oldItems || []; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - CollectionEvent.prototype.clean = function () { - _super.prototype.clean.call(this); - this.items = this.oldItems = null; - }; - /** - * Dispatch an event with specified EventDispatcher. The dispatched event will be cached in the object pool, - * for the next cycle of reuse. - * - * @param target the target of event dispatcher. - * @param eventType The event type; indicates the action that triggered the event. - * @param kind Indicates the kind of event that occured. - * The parameter value can be one of the values in the CollectionEventKind - * class, or null, which indicates that the kind is unknown. - * @param location When the kind is - * CollectionEventKind.ADD, - * CollectionEventKind.REMOVE, - * CollectionEventKind.REPLACE,or - * CollectionEventKind.UPDATE - * this value indicates at what location the item(s) specified - * in the items property can be found - * within the target collection. - * @param oldLocation this value indicates - * the old location within the target collection - * of the item(s) specified in the items property. - * @param items Array of objects with information about the items - * affected by the event. - * @param oldItems When the kine is CollectionEventKind.REPLACE the value represents - * a list of items before replaced. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * - * @param target 事件派发目标。 - * @param eventType 事件类型;指示触发事件的动作。 - * @param kind 指示发生的事件类型。此属性值可以是 CollectionEventKind 类中的一个值,也可以是 null,用于指示类型未知。 - * @param location 如果 kind 值为 CollectionEventKind.ADD, - * CollectionEventKind.REMOVE, - * CollectionEventKind.REPLACE,或 - * CollectionEventKind.UPDATE - * 则此属性为 items 属性中指定的项目集合中零号元素的的索引。 - * @param oldLocation 此值指示 items 属性中指定的项目在目标集合中的原位置。 - * @param items 受事件影响的项目的列表。 - * @param oldItems 仅当kind的值为CollectionEventKind.REPLACE时,表示替换前的项目列表。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - CollectionEvent.dispatchCollectionEvent = function (target, eventType, kind, location, oldLocation, items, oldItems) { - if (!target.hasEventListener(eventType)) { - return true; - } - var event = egret.Event.create(CollectionEvent, eventType); - event.$initTo(kind, location, oldLocation, items, oldItems); - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Dispatched when a collection has changed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 集合类数据发生改变 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - CollectionEvent.COLLECTION_CHANGE = "collectionChange"; - return CollectionEvent; - }(egret.Event)); - eui.CollectionEvent = CollectionEvent; - __reflect(CollectionEvent.prototype, "eui.CollectionEvent"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The CollectionEventKind class contains constants for the valid values - * of the CollectionEvent class kind property. - * These constants indicate the kind of change that was made to the collection. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 定义 CollectionEventkind 属性的有效值的常量。 - * 这些常量指示对集合进行的更改类型。 - - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var CollectionEventKind = (function () { - function CollectionEventKind() { - } - /** - * Indicates that the collection added an item or items. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示集合添加了一个或多个项目。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - CollectionEventKind.ADD = "add"; - /** - * Indicates that the collection applied a sort, a filter, or both. - * This change can potentially be easier to handle than a RESET. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示集合应用了排序或/和筛选。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - CollectionEventKind.REFRESH = "refresh"; - /** - * Indicates that the collection removed an item or items. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示集合删除了一个或多个项目。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - CollectionEventKind.REMOVE = "remove"; - /** - * Indicates that the item at the position identified by the - * CollectionEvent location property has been replaced. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示已替换由 CollectionEvent.location 属性确定的位置处的项目。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - CollectionEventKind.REPLACE = "replace"; - /** - * Indicates that the collection has changed so drastically that - * a reset is required. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示集合已彻底更改,需要进行重置。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - CollectionEventKind.RESET = "reset"; - /** - * Indicates that one or more items were updated within the collection. - * The affected item(s) - * are stored in the CollectionEvent.items property. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指示集合中一个或多个项目进行了更新。受影响的项目将存储在 CollectionEvent.items 属性中。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - CollectionEventKind.UPDATE = "update"; - return CollectionEventKind; - }()); - eui.CollectionEventKind = CollectionEventKind; - __reflect(CollectionEventKind.prototype, "eui.CollectionEventKind"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * Represents events that are dispatched when a item has been touched. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/ItemTapEventExample.ts - * @language en_US - */ - /** - * 列表项触碰事件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/ItemTapEventExample.ts - * @language zh_CN - */ - var ItemTapEvent = (function (_super) { - __extends(ItemTapEvent, _super); - function ItemTapEvent() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * The item in the data provider of the associated item. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触发触摸事件的项呈示器数据源项。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.item = null; - /** - * The item renderer in the list of the associated item. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触发触摸事件的项呈示器。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.itemRenderer = null; - /** - * The index of the associated navigation item. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 触发触摸事件的项索引 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - _this.itemIndex = -1; - return _this; - } - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - ItemTapEvent.prototype.clean = function () { - _super.prototype.clean.call(this); - this.item = this.itemRenderer = null; - }; - /** - * Dispatch an event with specified EventDispatcher. The dispatched event will be cached in the object pool, - * for the next cycle of reuse. - * - * @param target the target of event dispatcher. - * @param eventType The event type; indicates the action that triggered the event. - * @param itemRenderer The item renderer in the list of the associated item. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 EventDispatcher 对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * - * @param target 事件派发目标 - * @param eventType 事件类型;指示触发事件的动作。 - * @param itemRenderer 触发触摸事件的项呈示器。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ItemTapEvent.dispatchItemTapEvent = function (target, eventType, itemRenderer) { - if (!target.hasEventListener(eventType)) { - return true; - } - var event = egret.Event.create(ItemTapEvent, eventType); - event.item = itemRenderer.data; - event.itemIndex = itemRenderer.itemIndex; - event.itemRenderer = itemRenderer; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * The type of the event object for an itemTap event. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * itemTap 事件的对象类型。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ItemTapEvent.ITEM_TAP = "itemTap"; - return ItemTapEvent; - }(egret.Event)); - eui.ItemTapEvent = ItemTapEvent; - __reflect(ItemTapEvent.prototype, "eui.ItemTapEvent"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The PropertyChangeEvent class represents the event object - * passed to the event listener when one of the properties of - * an object has changed, and provides information about the change. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/PropertyEventExample.ts - * @language en_US - */ - /** - * 对象的一个属性发生更改时传递到事件侦听器的事件。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/PropertyEventExample.ts - * @language zh_CN - */ - var PropertyEvent = (function (_super) { - __extends(PropertyEvent, _super); - /** - * Constructor. - * - * @param type The event type; indicates the action that triggered the event. - * @param bubbles Specifies whether the event can bubble - * up the display list hierarchy. - * @param cancelable Specifies whether the behavior - * associated with the event can be prevented. - * @param property Name of the property that changed. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个属性改变事件。 - * - * @param type 事件类型;指示触发事件的动作。 - * @param bubbles 指定该事件是否可以在显示列表层次结构得到冒泡处理。 - * @param cancelable 指定是否可以防止与事件相关联的行为。 - * @param property 发生改变的属性名称。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function PropertyEvent(type, bubbles, cancelable, property) { - var _this = _super.call(this, type, bubbles, cancelable) || this; - _this.property = property; - return _this; - } - /** - * Dispatch an event with specified EventDispatcher. The dispatched event will be cached in the object pool, - * for the next cycle of reuse. - * - * @param target the target of event dispatcher. - * @param eventType The event type; indicates the action that triggered the event. - * @param property Name of the property that changed. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 EventDispatcher 对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * - * @param target 事件派发目标 - * @param eventType 事件类型;指示触发事件的动作。 - * @param property 发生改变的属性名称。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - PropertyEvent.dispatchPropertyEvent = function (target, eventType, property) { - if (!target.hasEventListener(eventType)) { - return true; - } - var event = egret.Event.create(PropertyEvent, eventType); - event.property = property; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Dispatch when a property changed. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 属性改变。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - PropertyEvent.PROPERTY_CHANGE = "propertyChange"; - return PropertyEvent; - }(egret.Event)); - eui.PropertyEvent = PropertyEvent; - __reflect(PropertyEvent.prototype, "eui.PropertyEvent"); -})(eui || (eui = {})); -var eui; -(function (eui) { - /** - * @private - */ - var ScrollerThrowEvent = (function (_super) { - __extends(ScrollerThrowEvent, _super); - /** - * 动画信息,可调节或修改 - */ - //public tween; - function ScrollerThrowEvent(type, bubbles, cancelable, currentPos, toPos) { - var _this = _super.call(this, type, bubbles, cancelable) || this; - currentPos = +currentPos; - toPos = +toPos; - _this.currentPos = currentPos; - _this.toPos = toPos; - return _this; - } - ScrollerThrowEvent.THROW = "throw"; - return ScrollerThrowEvent; - }(egret.Event)); - eui.ScrollerThrowEvent = ScrollerThrowEvent; - __reflect(ScrollerThrowEvent.prototype, "eui.ScrollerThrowEvent"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The UIEvent class represents the event object passed to - * the event listener for many UI events. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/UIEventExample.ts - * @language en_US - */ - /** - * UI事件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/events/UIEventExample.ts - * @language zh_CN - */ - var UIEvent = (function (_super) { - __extends(UIEvent, _super); - /** - * Constructor. - * - * @param type The event type; indicates the action that triggered the event. - * @param bubbles Specifies whether the event can bubble - * up the display list hierarchy. - * @param cancelable Specifies whether the behavior - * associated with the event can be prevented. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 UIEvent 实例 - * - * @param type 事件类型;指示触发事件的动作。 - * @param bubbles 指定该事件是否可以在显示列表层次结构得到冒泡处理。 - * @param cancelable 指定是否可以防止与事件相关联的行为。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function UIEvent(type, bubbles, cancelable) { - return _super.call(this, type, bubbles, cancelable) || this; - } - /** - * Dispatch an event with specified EventDispatcher. The dispatched event will be cached in the object pool, - * for the next cycle of reuse. - * - * @param target the target of event dispatcher. - * @param eventType The event type; indicates the action that triggered the event. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * - * @param target 事件派发目标。 - * @param eventType 事件类型;指示触发事件的动作。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - UIEvent.dispatchUIEvent = function (target, eventType, bubbles, cancelable) { - if (!target.hasEventListener(eventType)) { - return true; - } - var event = egret.Event.create(UIEvent, eventType, bubbles, cancelable); - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * creation complete of component. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 组件创建完成 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - UIEvent.CREATION_COMPLETE = "creationComplete"; - /** - * the ending of change. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 改变结束 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - UIEvent.CHANGE_END = "changeEnd"; - /** - * The beginning of change. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 改变开始 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - UIEvent.CHANGE_START = "changeStart"; - /** - * Before close the panel. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 即将关闭面板事件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - UIEvent.CLOSING = "closing"; - /** - * The coordinates of the UI components changed in it's parent. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * UI组件在父级容器中的坐标发生改变事件 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - UIEvent.MOVE = "move"; - return UIEvent; - }(egret.Event)); - eui.UIEvent = UIEvent; - __reflect(UIEvent.prototype, "eui.UIEvent"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var sys; - (function (sys) { - var STATE = "eui.State"; - var ADD_ITEMS = "eui.AddItems"; - var SET_PROPERTY = "eui.SetProperty"; - var SET_STATEPROPERTY = "eui.SetStateProperty"; - var BINDING_PROPERTIES = "eui.Binding.$bindProperties"; - /** - * @private - * 代码生成工具基类 - */ - var CodeBase = (function () { - function CodeBase() { - /** - * @private - */ - this.indent = 0; - } - /** - * @private - * - * @returns - */ - CodeBase.prototype.toCode = function () { - return ""; - }; - /** - * @private - * 获取缩进字符串 - */ - CodeBase.prototype.getIndent = function (indent) { - if (indent === void 0) - indent = this.indent; - var str = ""; - for (var i = 0; i < indent; i++) { - str += " "; - } - return str; - }; - return CodeBase; - }()); - sys.CodeBase = CodeBase; - __reflect(CodeBase.prototype, "eui.sys.CodeBase"); - /** - * @private - */ - var EXClass = (function (_super) { - __extends(EXClass, _super); - function EXClass() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - * 类名,不包括模块名 - */ - _this.className = ""; - /** - * @private - * 父类类名,包括完整模块名 - */ - _this.superClass = ""; - /** - * @private - * 内部类区块 - */ - _this.innerClassBlock = []; - /** - * @private - * 变量定义区块 - */ - _this.variableBlock = []; - /** - * @private - * 函数定义区块 - */ - _this.functionBlock = []; - return _this; - } - /** - * @private - * 添加一个内部类 - */ - EXClass.prototype.addInnerClass = function (clazz) { - if (this.innerClassBlock.indexOf(clazz) == -1) { - this.innerClassBlock.push(clazz); - } - }; - /** - * @private - * 添加变量 - */ - EXClass.prototype.addVariable = function (variableItem) { - if (this.variableBlock.indexOf(variableItem) == -1) { - this.variableBlock.push(variableItem); - } - }; - /** - * @private - * 根据变量名获取变量定义 - */ - EXClass.prototype.getVariableByName = function (name) { - var list = this.variableBlock; - var length = list.length; - for (var i = 0; i < length; i++) { - var item = list[i]; - if (item.name == name) { - return item; - } - } - return null; - }; - /** - * @private - * 添加函数 - */ - EXClass.prototype.addFunction = function (functionItem) { - if (this.functionBlock.indexOf(functionItem) == -1) { - this.functionBlock.push(functionItem); - } - }; - /** - * @private - * 根据函数名返回函数定义块 - */ - EXClass.prototype.getFuncByName = function (name) { - var list = this.functionBlock; - var length = list.length; - for (var i = 0; i < length; i++) { - var item = list[i]; - if (item.name == name) { - return item; - } - } - return null; - }; - /** - * @private - * - * @returns - */ - EXClass.prototype.toCode = function () { - var indent = this.indent; - var indentStr = this.getIndent(indent); - var indent1Str = this.getIndent(indent + 1); - var indent2Str = this.getIndent(indent + 2); - //打印类起始块 - var returnStr = indentStr + "(function ("; - if (this.superClass) { - returnStr += "_super) {\n" + indent1Str + "__extends(" + this.className + ", _super);\n"; - } - else { - returnStr += ") {\n"; - } - //打印内部类列表 - var innerClasses = this.innerClassBlock; - var length = innerClasses.length; - for (var i = 0; i < length; i++) { - var clazz = innerClasses[i]; - clazz.indent = indent + 1; - returnStr += indent1Str + "var " + clazz.className + " = " + clazz.toCode() + "\n\n"; - } - returnStr += indent1Str + "function " + this.className + "() {\n"; - if (this.superClass) { - returnStr += indent2Str + "_super.call(this);\n"; - } - //打印变量列表 - var variables = this.variableBlock; - length = variables.length; - for (var i = 0; i < length; i++) { - var variable = variables[i]; - if (variable.defaultValue) { - returnStr += indent2Str + variable.toCode() + "\n"; - } - } - //打印构造函数 - if (this.constructCode) { - var codes = this.constructCode.toCode().split("\n"); - length = codes.length; - for (var i = 0; i < length; i++) { - var code = codes[i]; - returnStr += indent2Str + code + "\n"; - } - } - returnStr += indent1Str + "}\n"; - returnStr += indent1Str + "var _proto = " + this.className + ".prototype;\n\n"; - //打印函数列表 - var functions = this.functionBlock; - length = functions.length; - for (var i = 0; i < length; i++) { - var functionItem = functions[i]; - functionItem.indent = indent + 1; - returnStr += functionItem.toCode() + "\n"; - } - //打印类结尾 - returnStr += indent1Str + "return " + this.className + ";\n" + indentStr; - if (this.superClass) { - returnStr += "})(" + this.superClass + ");"; - } - else { - returnStr += "})();"; - } - return returnStr; - }; - return EXClass; - }(CodeBase)); - sys.EXClass = EXClass; - __reflect(EXClass.prototype, "eui.sys.EXClass"); - /** - * @private - */ - var EXCodeBlock = (function (_super) { - __extends(EXCodeBlock, _super); - function EXCodeBlock() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.lines = []; - return _this; - } - /** - * @private - * 添加变量声明语句 - * @param name 变量名 - * @param value 变量初始值 - */ - EXCodeBlock.prototype.addVar = function (name, value) { - var valueStr = value ? " = " + value : ""; - this.addCodeLine("var " + name + valueStr + ";"); - }; - /** - * @private - * 添加赋值语句 - * @param target 要赋值的目标 - * @param value 值 - * @param prop 目标的属性(用“.”访问),不填则是对目标赋值 - */ - EXCodeBlock.prototype.addAssignment = function (target, value, prop) { - var propStr = prop ? "." + prop : ""; - this.addCodeLine(target + propStr + " = " + value + ";"); - }; - /** - * @private - * 添加返回值语句 - */ - EXCodeBlock.prototype.addReturn = function (data) { - this.addCodeLine("return " + data + ";"); - }; - /** - * @private - * 添加一条空行 - */ - EXCodeBlock.prototype.addEmptyLine = function () { - this.addCodeLine(""); - }; - /** - * @private - * 开始添加if语句块,自动调用startBlock(); - */ - EXCodeBlock.prototype.startIf = function (expression) { - this.addCodeLine("if(" + expression + ")"); - this.startBlock(); - }; - /** - * @private - * 开始else语句块,自动调用startBlock(); - */ - EXCodeBlock.prototype.startElse = function () { - this.addCodeLine("else"); - this.startBlock(); - }; - /** - * @private - * 开始else if语句块,自动调用startBlock(); - */ - EXCodeBlock.prototype.startElseIf = function (expression) { - this.addCodeLine("else if(" + expression + ")"); - this.startBlock(); - }; - /** - * @private - * 添加一个左大括号,开始新的语句块 - */ - EXCodeBlock.prototype.startBlock = function () { - this.addCodeLine("{"); - this.indent++; - }; - /** - * @private - * 添加一个右大括号,结束当前的语句块 - */ - EXCodeBlock.prototype.endBlock = function () { - this.indent--; - this.addCodeLine("}"); - }; - /** - * @private - * 添加执行函数语句块 - * @param functionName 要执行的函数名称 - * @param args 函数参数列表 - */ - EXCodeBlock.prototype.doFunction = function (functionName, args) { - var argsStr = args.join(","); - this.addCodeLine(functionName + "(" + argsStr + ")"); - }; - /** - * @private - * 添加一行代码 - */ - EXCodeBlock.prototype.addCodeLine = function (code) { - this.lines.push(this.getIndent() + code); - }; - /** - * @private - * 添加一行代码到指定行 - */ - EXCodeBlock.prototype.addCodeLineAt = function (code, index) { - this.lines.splice(index, 0, this.getIndent() + code); - }; - /** - * @private - * 是否存在某行代码内容 - */ - EXCodeBlock.prototype.containsCodeLine = function (code) { - return this.lines.indexOf(code) != -1; - }; - /** - * @private - * 在结尾追加另一个代码块的内容 - */ - EXCodeBlock.prototype.concat = function (cb) { - this.lines = this.lines.concat(cb.lines); - }; - /** - * @private - * - * @returns - */ - EXCodeBlock.prototype.toCode = function () { - return this.lines.join("\n"); - }; - return EXCodeBlock; - }(CodeBase)); - sys.EXCodeBlock = EXCodeBlock; - __reflect(EXCodeBlock.prototype, "eui.sys.EXCodeBlock"); - /** - * @private - */ - var EXFunction = (function (_super) { - __extends(EXFunction, _super); - function EXFunction() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - * 代码块 - */ - _this.codeBlock = null; - /** - * @private - */ - _this.isGet = false; - /** - * @private - * 函数名 - */ - _this.name = ""; - return _this; - } - /** - * @private - * - * @returns - */ - EXFunction.prototype.toCode = function () { - var indentStr = this.getIndent(); - var indent1Str = this.getIndent(this.indent + 1); - var codeIndent; - var returnStr = indentStr; - if (this.isGet) { - codeIndent = this.getIndent(this.indent + 2); - returnStr += 'Object.defineProperty(_proto, "skinParts", {\n'; - returnStr += indent1Str + "get: function () {\n"; - } - else { - codeIndent = indent1Str; - returnStr += "_proto." + this.name + " = function () {\n"; - } - if (this.codeBlock) { - var lines = this.codeBlock.toCode().split("\n"); - var length_28 = lines.length; - for (var i = 0; i < length_28; i++) { - var line = lines[i]; - returnStr += codeIndent + line + "\n"; - } - } - if (this.isGet) { - returnStr += indent1Str + "},\n" + indent1Str + "enumerable: true,\n" + - indent1Str + "configurable: true\n" + indentStr + "});"; - } - else { - returnStr += indentStr + "};"; - } - return returnStr; - }; - return EXFunction; - }(CodeBase)); - sys.EXFunction = EXFunction; - __reflect(EXFunction.prototype, "eui.sys.EXFunction"); - /** - * @private - */ - var EXVariable = (function (_super) { - __extends(EXVariable, _super); - /** - * @private - */ - function EXVariable(name, defaultValue) { - var _this = _super.call(this) || this; - _this.indent = 2; - _this.name = name; - _this.defaultValue = defaultValue; - return _this; - } - /** - * @private - * - * @returns - */ - EXVariable.prototype.toCode = function () { - if (!this.defaultValue) { - return ""; - } - return "this." + this.name + " = " + this.defaultValue + ";"; - }; - return EXVariable; - }(CodeBase)); - sys.EXVariable = EXVariable; - __reflect(EXVariable.prototype, "eui.sys.EXVariable"); - /** - * @private - */ - var EXState = (function (_super) { - __extends(EXState, _super); - /** - * @private - */ - function EXState(name, stateGroups) { - var _this = _super.call(this) || this; - /** - * @private - * 视图状态名称 - */ - _this.name = ""; - /** - * @private - */ - _this.stateGroups = []; - /** - * @private - */ - _this.addItems = []; - /** - * @private - */ - _this.setProperty = []; - _this.name = name; - if (stateGroups) - _this.stateGroups = stateGroups; - return _this; - } - /** - * @private - * 添加一个覆盖 - */ - EXState.prototype.addOverride = function (item) { - if (item instanceof EXAddItems) - this.addItems.push(item); - else - this.setProperty.push(item); - }; - /** - * @private - * - * @returns - */ - EXState.prototype.toCode = function () { - var indentStr = this.getIndent(1); - var returnStr = "new " + STATE + " (\"" + this.name + "\",\n" + indentStr + "[\n"; - var index = 0; - var isFirst = true; - var overrides = this.addItems.concat(this.setProperty); - while (index < overrides.length) { - if (isFirst) - isFirst = false; - else - returnStr += ",\n"; - var item = overrides[index]; - var codes = item.toCode().split("\n"); - var length_29 = codes.length; - for (var i = 0; i < length_29; i++) { - var code = codes[i]; - codes[i] = indentStr + indentStr + code; - } - returnStr += codes.join("\n"); - index++; - } - returnStr += "\n" + indentStr + "])"; - return returnStr; - }; - return EXState; - }(CodeBase)); - sys.EXState = EXState; - __reflect(EXState.prototype, "eui.sys.EXState"); - /** - * @private - */ - var EXAddItems = (function (_super) { - __extends(EXAddItems, _super); - /** - * @private - */ - function EXAddItems(target, property, position, relativeTo) { - var _this = _super.call(this) || this; - _this.target = target; - _this.property = property; - _this.position = position; - _this.relativeTo = relativeTo; - return _this; - } - /** - * @private - * - * @returns - */ - EXAddItems.prototype.toCode = function () { - var returnStr = "new " + ADD_ITEMS + "(\"" + this.target + "\",\"" + this.property + "\"," + this.position + ",\"" + this.relativeTo + "\")"; - return returnStr; - }; - return EXAddItems; - }(CodeBase)); - sys.EXAddItems = EXAddItems; - __reflect(EXAddItems.prototype, "eui.sys.EXAddItems"); - /** - * @private - */ - var EXSetProperty = (function (_super) { - __extends(EXSetProperty, _super); - /** - * @private - */ - function EXSetProperty(target, name, value) { - var _this = _super.call(this) || this; - _this.target = target; - _this.name = name; - _this.value = value; - return _this; - } - /** - * @private - * - * @returns - */ - EXSetProperty.prototype.toCode = function () { - return "new " + SET_PROPERTY + "(\"" + this.target + "\",\"" + this.name + "\"," + this.value + ")"; - }; - return EXSetProperty; - }(CodeBase)); - sys.EXSetProperty = EXSetProperty; - __reflect(EXSetProperty.prototype, "eui.sys.EXSetProperty"); - /** - * @private - */ - var EXSetStateProperty = (function (_super) { - __extends(EXSetStateProperty, _super); - /** - * @private - */ - function EXSetStateProperty(target, property, templates, chainIndex) { - var _this = _super.call(this) || this; - if (target) { - target = "this." + target; - } - else { - target = "this"; - } - _this.target = target; - _this.property = property; - _this.templates = templates; - _this.chainIndex = chainIndex; - return _this; - } - /** - * @private - * - * @returns - */ - EXSetStateProperty.prototype.toCode = function () { - var expression = this.templates.join(","); - var chain = this.chainIndex.join(","); - return "new " + SET_STATEPROPERTY + "(this, [" + expression + "]," + "[" + chain + "]," + - this.target + ",\"" + this.property + "\")"; - }; - return EXSetStateProperty; - }(CodeBase)); - sys.EXSetStateProperty = EXSetStateProperty; - __reflect(EXSetStateProperty.prototype, "eui.sys.EXSetStateProperty"); - /** - * @private - */ - var EXBinding = (function (_super) { - __extends(EXBinding, _super); - /** - * @private - */ - function EXBinding(target, property, templates, chainIndex) { - var _this = _super.call(this) || this; - _this.target = target; - _this.property = property; - _this.templates = templates; - _this.chainIndex = chainIndex; - return _this; - } - /** - * @private - * - * @returns - */ - EXBinding.prototype.toCode = function () { - var expression = this.templates.join(","); - var chain = this.chainIndex.join(","); - return BINDING_PROPERTIES + "(this, [" + expression + "]," + "[" + chain + "]," + - this.target + ",\"" + this.property + "\")"; - }; - return EXBinding; - }(CodeBase)); - sys.EXBinding = EXBinding; - __reflect(EXBinding.prototype, "eui.sys.EXBinding"); - })(sys = eui.sys || (eui.sys = {})); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -var eui; -(function (eui) { - var UIImpl = eui.sys.UIComponentImpl; - /** - * BitmapLabel is one line or multiline uneditable BitmapText - * @version Egret 2.5.3 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapLabel 组件是一行或多行不可编辑的位图文本 - * @version Egret 2.5.3 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var BitmapLabel = (function (_super) { - __extends(BitmapLabel, _super); - function BitmapLabel(text) { - var _this = _super.call(this) || this; - _this.$createChildrenCalled = false; - _this.$fontChanged = false; - /** - * @private - */ - _this._widthConstraint = NaN; - /** - * @private - */ - _this._heightConstraint = NaN; - _this.initializeUIValues(); - _this.text = text; - return _this; - } - /** - * @private - */ - BitmapLabel.prototype.$invalidateContentBounds = function () { - _super.prototype.$invalidateContentBounds.call(this); - this.invalidateSize(); - }; - /** - * @private - * - * @param value - */ - BitmapLabel.prototype.$setWidth = function (value) { - var result1 = _super.prototype.$setWidth.call(this, value); - var result2 = UIImpl.prototype.$setWidth.call(this, value); - return result1 && result2; - }; - /** - * @private - * - * @param value - */ - BitmapLabel.prototype.$setHeight = function (value) { - var result1 = _super.prototype.$setHeight.call(this, value); - var result2 = UIImpl.prototype.$setHeight.call(this, value); - return result1 && result2; - }; - /** - * @private - * - * @param value - */ - BitmapLabel.prototype.$setText = function (value) { - var result = _super.prototype.$setText.call(this, value); - eui.PropertyEvent.dispatchPropertyEvent(this, eui.PropertyEvent.PROPERTY_CHANGE, "text"); - return result; - }; - BitmapLabel.prototype.$setFont = function (value) { - if (this.$fontForBitmapLabel == value) { - return false; - } - this.$fontForBitmapLabel = value; - if (this.$createChildrenCalled) { - this.$parseFont(); - } - else { - this.$fontChanged = true; - } - this.$fontStringChanged = true; - return true; - }; - /** - * 解析source - */ - BitmapLabel.prototype.$parseFont = function () { - this.$fontChanged = false; - var font = this.$fontForBitmapLabel; - if (typeof font == "string") { - eui.getAssets(font, function (bitmapFont) { - this.$setFontData(bitmapFont, font); - }, this); - } - else { - this.$setFontData(font); - } - }; - BitmapLabel.prototype.$setFontData = function (value, font) { - if (font && font != this.$fontForBitmapLabel) { - return; - } - if (value == this.$font) { - return false; - } - this.$font = value; - this.$invalidateContentBounds(); - return true; - }; - /** - * @copy eui.UIComponent#createChildren - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.createChildren = function () { - if (this.$fontChanged) { - this.$parseFont(); - } - this.$createChildrenCalled = true; - }; - /** - * @copy eui.UIComponent#childrenCreated - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.childrenCreated = function () { - }; - /** - * @copy eui.UIComponent#commitProperties - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.commitProperties = function () { - }; - /** - * @copy eui.UIComponent#measure - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.measure = function () { - var values = this.$UIComponent; - var oldWidth = this.$textFieldWidth; - var oldHeight = this.$textFieldHeight; - var availableWidth = NaN; - if (!isNaN(this._widthConstraint)) { - availableWidth = this._widthConstraint; - this._widthConstraint = NaN; - } - else if (!isNaN(values[8 /* explicitWidth */])) { - availableWidth = values[8 /* explicitWidth */]; - } - else if (values[13 /* maxWidth */] != 100000) { - availableWidth = values[13 /* maxWidth */]; - } - _super.prototype.$setWidth.call(this, availableWidth); - var availableHeight = NaN; - if (!isNaN(this._heightConstraint)) { - availableHeight = this._heightConstraint; - this._heightConstraint = NaN; - } - else if (!isNaN(values[9 /* explicitHeight */])) { - availableHeight = values[9 /* explicitHeight */]; - } - else if (values[15 /* maxHeight */] != 100000) { - availableHeight = values[15 /* maxHeight */]; - } - _super.prototype.$setHeight.call(this, availableHeight); - this.setMeasuredSize(this.textWidth, this.textHeight); - _super.prototype.$setWidth.call(this, oldWidth); - _super.prototype.$setHeight.call(this, oldHeight); - }; - /** - * @copy eui.UIComponent#updateDisplayList - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - _super.prototype.$setWidth.call(this, unscaledWidth); - _super.prototype.$setHeight.call(this, unscaledHeight); - }; - /** - * @copy eui.UIComponent#invalidateParentLayout - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.invalidateParentLayout = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.setMeasuredSize = function (width, height) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.invalidateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.validateProperties = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.invalidateSize = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.validateSize = function (recursive) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.invalidateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.validateDisplayList = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.validateNow = function () { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.setLayoutBoundsSize = function (layoutWidth, layoutHeight) { - UIImpl.prototype.setLayoutBoundsSize.call(this, layoutWidth, layoutHeight); - if (isNaN(layoutWidth) || layoutWidth === this._widthConstraint || layoutWidth == 0) { - return; - } - var values = this.$UIComponent; - if (!isNaN(values[9 /* explicitHeight */])) { - return; - } - if (layoutWidth == values[16 /* measuredWidth */]) { - return; - } - this._widthConstraint = layoutWidth; - this._heightConstraint = layoutHeight; - this.invalidateSize(); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.setLayoutBoundsPosition = function (x, y) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.getLayoutBounds = function (bounds) { - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BitmapLabel.prototype.getPreferredBounds = function (bounds) { - }; - return BitmapLabel; - }(egret.BitmapText)); - eui.BitmapLabel = BitmapLabel; - __reflect(BitmapLabel.prototype, "eui.BitmapLabel", ["eui.UIComponent", "egret.DisplayObject", "eui.IDisplayText"]); - eui.sys.implementUIComponent(BitmapLabel, egret.BitmapText); - eui.registerBindable(BitmapLabel.prototype, "text"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -/// -var EXML; -(function (EXML) { - var parser = new eui.sys.EXMLParser(); - var requestPool = []; - var callBackMap = {}; - var parsedClasses = {}; - var $prefixURL = ""; - Object.defineProperty(EXML, "prefixURL", { - get: function () { return $prefixURL; }, - set: function (value) { $prefixURL = value; }, - enumerable: true, - configurable: true - }); - /** - * Parsing a text of EXML file for a definition of class. You can declare the class property in the root - * node of the EXML to register to the global as a class name. - * - * It will be fail to register and output a warning if the specified name already exists. You can get a definition - * of a class through egret.getDefinitionByName(className). - * - * @param text the text of a EXML file. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 解析一个 EXML 文件的文本内容为一个类定义。您可以在 EXML 文件的根节点上声明 class 属性作为要注册到全局的类名。 - * 若指定的类名已经存在,将会注册失败,并输出一个警告。注册成功后,您也可以通过 egret.getDefinitionByName(className) 方法获取这个 EXML 文件对应的类定义。 - * - * @param text 要解析的 EXML 文件内容。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function parse(text) { - return parser.parse(text); - } - EXML.parse = parse; - /** - * Load and parse an external EXML file for a class definition. You can declare the class property in the root - * node of the EXML to register to the global as a class name. - * - * It will be fail to register and output a warning if the specified name already exists. You can get a definition - * of a class through egret.getDefinitionByName(className). - * - * @param url the path of an EXML file - * @param callBack method to invoke with an argument of the result when load and parse completed or failed. The argument will be - * undefined if load or parse failed. - * @param thisObject this object of callBack - * @param useCache use cached EXML - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 加载并解析一个外部的 EXML 文件为一个类定义。您可以在 EXML 文件的根节点上声明 class 属性作为要注册到全局的类名。 - * 若指定的类名已经存在,将会注册失败,并输出一个警告。注册成功后,您也可以通过 egret.getDefinitionByName(className) 方法获取这个 EXML 文件对应的类定义。 - * - * @param url 要加载的 EXML 文件路径 - * @param callBack 加载并解析完成后的回调函数,无论加载成功还是失败,此函数均会被回调。失败时将传入 undefined 作为回调函数参数。 - * @param thisObject 回调函数的 this 引用。 - * @param useCache 使用缓存的EXML - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function load(url, callBack, thisObject, useCache) { - if (useCache === void 0) { useCache = false; } - if (true) { - if (!url) { - egret.$error(1003, "url"); - } - } - if (useCache && (url in parsedClasses)) { - callBack && callBack.call(thisObject, parsedClasses[url], url); - return; - } - var list = callBackMap[url]; - if (list) { - list.push([callBack, thisObject]); - return; - } - callBackMap[url] = [[callBack, thisObject]]; - request(url, $parseURLContent); - } - EXML.load = load; - /** - * @private - */ - function $loadAll(urls, callBack, thisObject, useCache) { - if (useCache === void 0) { useCache = false; } - if (!urls || urls.length == 0) { - callBack && callBack.call(thisObject, [], urls); - return; - } - var exmlContents = []; - urls.forEach(function (url) { - var loaded = function (url, text) { - exmlContents[url] = text; - exmlContents.push(url); - if (exmlContents.length == urls.length) - onLoadAllFinished(urls, exmlContents, callBack, thisObject); - }; - if (useCache && (url in parsedClasses)) { - loaded(url, ""); - return; - } - request(url, loaded); - }); - } - EXML.$loadAll = $loadAll; - /** - * @private - */ - function onLoadAllFinished(urls, exmlContents, callBack, thisObject) { - var clazzes = []; - urls.forEach(function (url, i) { - if ((url in parsedClasses) && !exmlContents[url]) { - clazzes[i] = parsedClasses[url]; - return; - } - var text = exmlContents[url]; - var clazz = $parseURLContent(url, text); - clazzes[i] = clazz; - }); - callBack && callBack.call(thisObject, clazzes, urls); - } - function update(url, clazz) { - parsedClasses[url] = clazz; - var list = callBackMap[url]; - delete callBackMap[url]; - var length = list ? list.length : 0; - for (var i = 0; i < length; i++) { - var arr = list[i]; - if (arr[0] && arr[1]) - arr[0].call(arr[1], clazz, url); - } - } - EXML.update = update; - /** - * @private - * @param url - * @param text - */ - function $parseURLContentAsJs(url, text, className) { - var clazz = null; - if (text) { - clazz = parser.$parseCode(text, className); - update(url, clazz); - } - } - EXML.$parseURLContentAsJs = $parseURLContentAsJs; - /** - * @private - */ - function $parseURLContent(url, text) { - var clazz = null; - if (text && typeof (text) == "string") { - try { - clazz = parse(text); - } - catch (e) { - console.error(url + "\n" + e.message); - } - } - if (text && text["prototype"]) { - clazz = text; - } - if (url) { - if (clazz) { - parsedClasses[url] = clazz; - } - var list = callBackMap[url]; - delete callBackMap[url]; - var length_30 = list ? list.length : 0; - for (var i = 0; i < length_30; i++) { - var arr = list[i]; - if (arr[0] && arr[1]) - arr[0].call(arr[1], clazz, url); - } - } - return clazz; - } - EXML.$parseURLContent = $parseURLContent; - /** - * @private - */ - function request(url, callback) { - var openUrl = url; - if (url.indexOf("://") == -1) { - openUrl = $prefixURL + url; - } - var onConfigLoaded = function (str) { - if (!str) { - str = ""; - } - callback(url, str); - }; - eui.getTheme(openUrl, onConfigLoaded); - } -})(EXML || (EXML = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var sys; - (function (sys) { - /** - * @private - * EUI 命名空间 - */ - sys.NS_S = "http://ns.egret.com/eui"; - /** - * @private - * Wing命名空间 - */ - sys.NS_W = "http://ns.egret.com/wing"; - var coreClasses = ["Point", "Matrix", "Rectangle"]; - var basicTypes = ["Array", "boolean", "string", "number"]; - var MODULE_NAME = "eui."; - var hashCount = 0; - var properties = {}; - /** - * @private - */ - var EXMLConfig = (function () { - function EXMLConfig() { - } - /** - * @private - */ - EXMLConfig.prototype.$describe = function (instance) { - if (!instance) { - return null; - } - var prototype = Object.getPrototypeOf(instance); - if (!prototype) { - return null; - } - var info; - if (prototype.hasOwnProperty("__hashCode__")) { - info = properties[prototype.__hashCode__]; - if (info) { - return info; - } - } - var superProto = Object.getPrototypeOf(prototype); - if (!superProto) { - return null; - } - var superInstance = getInstanceOf(superProto.constructor); - var superInfo = this.$describe(superInstance); - if (superInfo) { - var factory = function () { - }; - factory.prototype = superInfo; - info = new factory(); - } - else { - info = {}; - } - if (true) { - info.__class__ = prototype.constructor.name; - } - var keys = Object.keys(prototype).concat(Object.keys(instance)); - var length = keys.length; - var meta = instance.__meta__; - for (var i = 0; i < length; i++) { - var key = keys[i]; - if (key == "constructor" || key.charAt(0) == "_" || key.charAt(0) == "$") { - continue; - } - var resultType = void 0; - if (meta && meta[key]) { - resultType = meta[key]; - } - else if (isArray(instance[key])) { - resultType = "Array"; - } - else { - resultType = typeof instance[key]; - if (resultType == "function") { - continue; - } - if (basicTypes.indexOf(resultType) == -1) { - resultType = "any"; - } - } - info[key] = resultType; - } - if (Object.getPrototypeOf(superProto)) { - prototype.__hashCode__ = hashCount++; - properties[prototype.__hashCode__] = info; - } - return info; - }; - /** - * @private - * 根据类的短名ID和命名空间获取完整类名(以"."分隔) - * @param id 类的短名ID - * @param ns 命名空间 - */ - EXMLConfig.prototype.getClassNameById = function (id, ns) { - if (ns == sys.NS_S) { - if (id == "Object") { - return id; - } - if (coreClasses.indexOf(id) != -1) { - return "egret." + id; - } - } - var name = ""; - if (basicTypes.indexOf(id) != -1) { - return id; - } - if (ns == sys.NS_W) { - } - else if (!ns || ns == sys.NS_S) { - name = MODULE_NAME + id; - } - else { - name = ns.substring(0, ns.length - 1) + id; - } - if (!getPrototypeOf(name)) { - name = ""; - } - return name; - }; - /** - * @private - * 根据ID获取对应的默认属性 - * @param id 类的短名ID - * @param ns 命名空间 - * @return 默认属性名 - */ - EXMLConfig.prototype.getDefaultPropById = function (id, ns) { - var className = this.getClassNameById(id, ns); - var prototype = getPrototypeOf(className); - var property; - if (prototype) { - property = prototype.__defaultProperty__; - } - return property ? property : ""; - }; - /** - * @private - * 获取指定属性的类型,返回基本数据类型:"boolean","string","number","any"。 - * @param property 属性名 - * @param className 要查询的完整类名 - */ - EXMLConfig.prototype.getPropertyType = function (property, className) { - if (className == "Object") { - return "any"; - } - var resultType = ""; - var prototype = getPrototypeOf(className); - if (prototype) { - if (!prototype.hasOwnProperty("__hashCode__")) { - var clazz = egret.getDefinitionByName(className); - var instance = getInstanceOf(clazz); - if (!instance) { - if (true) { - egret.$warn(2104, className); - } - return resultType; - } - this.$describe(instance); - } - var info = properties[prototype.__hashCode__]; - if (info) { - resultType = info[property]; - } - } - return resultType; - }; - return EXMLConfig; - }()); - sys.EXMLConfig = EXMLConfig; - __reflect(EXMLConfig.prototype, "eui.sys.EXMLConfig"); - /** - * @private - * 判断一个对象是数组 - */ - function isArray(o) { - return Object.prototype.toString.call(o) === '[object Array]'; - } - /** - * @private - * 获取一个类名对应的prototype引用 - */ - function getPrototypeOf(className) { - var clazz = egret.getDefinitionByName(className); - if (!clazz) { - return null; - } - return clazz.prototype; - } - /** - * @private - * 创建一个类名对应的实例 - */ - function getInstanceOf(clazz) { - if (!clazz) { - return null; - } - var instance; - if (true) { - try { - instance = new clazz(); - } - catch (e) { - egret.error(e); - return null; - } - } - else { - instance = new clazz(); - } - return instance; - } - })(sys = eui.sys || (eui.sys = {})); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present; Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms; with or without -// modification; are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice; this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice; this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES; INCLUDING; BUT NOT LIMITED TO; THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT; INDIRECT; -// INCIDENTAL; SPECIAL; EXEMPLARY; OR CONSEQUENTIAL DAMAGES (INCLUDING; BUT NOT -// LIMITED TO; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE; DATA; -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY; WHETHER IN CONTRACT; STRICT LIABILITY; OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE; -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - egret.$locale_strings = egret.$locale_strings || {}; - egret.$locale_strings["en_US"] = egret.$locale_strings["en_US"] || {}; - var locale_strings = egret.$locale_strings["en_US"]; - //2000-2999 - locale_strings[2001] = "EXML parsing error {0}: EXML file can't be found "; - locale_strings[2002] = "EXML parsing error : invalid XML file:\n{0}"; - locale_strings[2003] = "EXML parsing error {0}: the class definitions corresponding to nodes can't be found \n {1}"; - locale_strings[2004] = "EXML parsing error {0}: nodes cannot contain id property with the same name \n {1}"; - locale_strings[2005] = "EXML parsing error {0}: property with the name of '{1}' does not exist on the node, or the property does not have a default value: \n {2}"; - locale_strings[2006] = "EXML parsing error {0}: undefined view state name: '{1}' \n {2}"; - locale_strings[2007] = "EXML parsing error {0}: only UIComponent objects within the container can use the includeIn and excludeFrom properties\n {1}"; - locale_strings[2008] = "EXML parsing error {0}: fail to assign values of '{1}' class to property: '{2}' \n {3}"; - locale_strings[2009] = "EXML parsing error {0}: only one ID can be referenced in the node property value '{}' label; and complex expression is not allowed to use \n {1}"; - locale_strings[2010] = "EXML parsing error {0}: ID referenced by property: '{1}': '{2}' does not exist \n {3}"; - locale_strings[2011] = "EXML parsing error {0}: fail to assign more than one child nodes to the same property: '{1}' \n {2}"; - locale_strings[2012] = "EXML parsing error {0}: no default property exists on the node; and you must explicitly declare the property name that the child node is assigned to \n {1}"; - locale_strings[2013] = "EXML parsing error {0}: view state grammar is not allowed to use on property nodes of Array class \n {1} "; - locale_strings[2014] = "EXML parsing error {0}: assigning the skin class itself to the node property is not allowed \n {1}"; - locale_strings[2015] = "EXML parsing error {0}: class definition referenced by node: {1} does not exist \n {2}"; - locale_strings[2016] = "EXML parsing error {0}: format error of 'scale9Grid' property value on the node: {1}"; - locale_strings[2017] = "EXML parsing error {0}: namespace prefix missing on the node: {1}"; - locale_strings[2018] = "EXML parsing error {0}: format error of 'skinName' property value on the node: {1}"; - locale_strings[2019] = "EXML parsing error {0}: the container’s child item must be visible nodes: {1}"; - locale_strings[2020] = "EXML parsing error {0}: for child nodes in w: Declarations, the includeIn and excludeFrom properties are not allowed to use \n {1}"; - locale_strings[2021] = "Compile errors in {0}, the attribute name: {1}, the attribute value: {2}."; - locale_strings[2022] = "EXML parsing error: there contains illegal characters in the id `{0}`"; - locale_strings[2101] = "EXML parsing warnning : fail to register the class property : {0},there is already a class with the same name in the global,please try to rename the class name for the exml. \n {1}"; - locale_strings[2102] = "EXML parsing warnning {0}: no child node can be found on the property code \n {1}"; - locale_strings[2103] = "EXML parsing warnning {0}: the same property '{1}' on the node is assigned multiple times \n {2}"; - locale_strings[2104] = "EXML parsing warnning, Instantiate class {0} error,the parameters of its constructor method must be empty."; - locale_strings[2201] = "BasicLayout doesn't support virtualization."; - locale_strings[2202] = "parse skinName error,the parsing result of skinName must be a instance of eui.Skin."; - locale_strings[2203] = "Could not find the skin class '{0}'。"; - locale_strings[2204] = "Undefined event.kind type (CollectionEventKind) = '{0}'."; - locale_strings[2301] = "parse source failed,could not find asset from URL:{0} ."; -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present; Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms; with or without -// modification; are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice; this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice; this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES; INCLUDING; BUT NOT LIMITED TO; THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT; INDIRECT; -// INCIDENTAL; SPECIAL; EXEMPLARY; OR CONSEQUENTIAL DAMAGES (INCLUDING; BUT NOT -// LIMITED TO; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE; DATA; -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY; WHETHER IN CONTRACT; STRICT LIABILITY; OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE; -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - egret.$locale_strings = egret.$locale_strings || {}; - egret.$locale_strings["zh_CN"] = egret.$locale_strings["zh_CN"] || {}; - var locale_strings = egret.$locale_strings["zh_CN"]; - //2000-2999 - //EXML报错信息 - locale_strings[2001] = "EXML解析错误 {0}: 找不到EXML文件"; - locale_strings[2002] = "EXML解析错误: 不是有效的XML文件:\n{0}"; - locale_strings[2003] = "EXML解析错误 {0}: 无法找到节点所对应的类定义\n{1}"; - locale_strings[2004] = "EXML解析错误 {0}: 节点不能含有同名的id属性\n{1}"; - locale_strings[2005] = "EXML解析错误 {0}: 节点上不存在名为'{1}'的属性,或者该属性没有初始值:\n{2}"; - locale_strings[2006] = "EXML解析错误 {0}: 未定义的视图状态名称:'{1}'\n{2}"; - locale_strings[2007] = "EXML解析错误 {0}: 只有处于容器内的 UIComponent 对象可以使用includeIn和excludeFrom属性\n{1}"; - locale_strings[2008] = "EXML解析错误 {0}: 无法将'{1}'类型的值赋给属性:'{2}'\n{3}"; - locale_strings[2009] = "EXML解析错误 {0}: 在节点属性值的‘{}’标签内只能引用一个ID,不允许使用复杂表达式\n{1}"; - locale_strings[2010] = "EXML解析错误 {0}: 属性:'{1}'所引用的ID: '{2}'不存在\n{3}"; - locale_strings[2011] = "EXML解析错误 {0}: 无法将多个子节点赋值给同一个属性:'{1}'\n{2}"; - locale_strings[2012] = "EXML解析错误 {0}: 节点上不存在默认属性,必须显式声明子节点要赋值到的属性名\n{1}"; - locale_strings[2013] = "EXML解析错误 {0}: 类型为Array的属性节点上不允许使用视图状态语法\n{1}"; - locale_strings[2014] = "EXML解析错误 {0}: 不允许将皮肤类自身赋值给节点属性\n{1}"; - locale_strings[2015] = "EXML解析错误 {0}: 节点引用的类定义:{1}不存在\n{2}"; - locale_strings[2016] = "EXML解析错误 {0}: 节点上'scale9Grid'属性值的格式错误:{1}"; - locale_strings[2017] = "EXML解析错误 {0}: 节点上缺少命名空间前缀:{1}"; - locale_strings[2018] = "EXML解析错误 {0}: 节点上'skinName'属性值的格式错误:{1}"; - locale_strings[2019] = "EXML解析错误 {0}: 容器的子项必须是可视节点:{1}"; - locale_strings[2020] = "EXML解析错误 {0}: 在w:Declarations内的子节点,不允许使用includeIn和excludeFrom属性\n{1}"; - locale_strings[2021] = "{0} 中存在编译错误,属性名 : {1},属性值 : {2}"; - locale_strings[2022] = "EXML解析错误: id `{0}` 中含有非法字符"; - //EXML警告信息 - locale_strings[2101] = "EXML解析警告: 在EXML根节点上声明的 class 属性: {0} 注册失败,所对应的类已经存在,请尝试重命名要注册的类名。\n{1}"; - locale_strings[2102] = "EXML解析警告 {0}: 在属性节点上找不到任何子节点\n{1}"; - locale_strings[2103] = "EXML解析警告 {0}: 节点上的同一个属性'{1}'被多次赋值\n{2}"; - locale_strings[2104] = "EXML解析警告,无法直接实例化自定义组件:{0} ,在EXML中使用的自定义组件必须要能直接被实例化,否则可能导致后续EXML解析报错。"; - //EUI 报错与警告信息 - locale_strings[2201] = "BasicLayout 不支持虚拟化。"; - locale_strings[2202] = "皮肤解析出错,属性 skinName 的值必须要能够解析为一个 eui.Skin 的实例。"; - locale_strings[2203] = "找不到指定的皮肤类 '{0}'。"; - locale_strings[2204] = "未定义的event.kind类型(CollectionEventKind) = '{0}'."; - locale_strings[2301] = "素材解析失败,找不到URL:{0} 所对应的资源。"; -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The BasicLayout class arranges the layout elements according to their individual settings, - * independent of each-other. BasicLayout, also called absolute layout, requires that you - * explicitly position each container child. - * You can use the x and y properties of the child, - * or constraints to position each child. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/BasicLayoutExample.ts - * @language en_US - */ - /** - * BasicLayout 类根据其各个设置彼此独立地排列布局元素。 - * BasicLayout(也称为绝对布局)要求显式定位每个容器子代。 - * 可以使用子代的 xy 属性,或使用约束来定位每个子代。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/BasicLayoutExample.ts - * @language zh_CN - */ - var BasicLayout = (function (_super) { - __extends(BasicLayout, _super); - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function BasicLayout() { - return _super.call(this) || this; - } - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BasicLayout.prototype.measure = function () { - _super.prototype.measure.call(this); - eui.sys.measure(this.$target); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - BasicLayout.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - _super.prototype.updateDisplayList.call(this, unscaledWidth, unscaledHeight); - var target = this.$target; - var pos = eui.sys.updateDisplayList(target, unscaledWidth, unscaledHeight); - target.setContentSize(Math.ceil(pos.x), Math.ceil(pos.y)); - }; - return BasicLayout; - }(eui.LayoutBase)); - eui.BasicLayout = BasicLayout; - __reflect(BasicLayout.prototype, "eui.BasicLayout"); - if (true) { - Object.defineProperty(BasicLayout.prototype, "useVirtualLayout", { - /** - * 此布局不支持虚拟布局,设置这个属性无效 - */ - get: function () { - return this.$useVirtualLayout; - }, - set: function (value) { - egret.$error(2201); - }, - enumerable: true, - configurable: true - }); - } -})(eui || (eui = {})); -(function (eui) { - var sys; - (function (sys) { - var UIComponentClass = "eui.UIComponent"; - /** - * @private - * @param value 要格式化的相对值 - * @param total 在此值方向上的总长度 - */ - function formatRelative(value, total) { - if (!value || typeof value == "number") { - return value; - } - var str = value; - var index = str.indexOf("%"); - if (index == -1) { - return +str; - } - var percent = +str.substring(0, index); - return percent * 0.01 * total; - } - /** - * @private - * 一个工具方法,使用BasicLayout规则测量目标对象。 - */ - function measure(target) { - if (!target) { - return; - } - var width = 0; - var height = 0; - var bounds = egret.$TempRectangle; - var count = target.numChildren; - for (var i = 0; i < count; i++) { - var layoutElement = (target.getChildAt(i)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - var values = layoutElement.$UIComponent; - var hCenter = +values[4 /* horizontalCenter */]; - var vCenter = +values[5 /* verticalCenter */]; - var left = +values[0 /* left */]; - var right = +values[1 /* right */]; - var top_1 = +values[2 /* top */]; - var bottom = +values[3 /* bottom */]; - var extX = void 0; - var extY = void 0; - layoutElement.getPreferredBounds(bounds); - if (!isNaN(left) && !isNaN(right)) { - extX = left + right; - } - else if (!isNaN(hCenter)) { - extX = Math.abs(hCenter) * 2; - } - else if (!isNaN(left) || !isNaN(right)) { - extX = isNaN(left) ? 0 : left; - extX += isNaN(right) ? 0 : right; - } - else { - extX = bounds.x; - } - if (!isNaN(top_1) && !isNaN(bottom)) { - extY = top_1 + bottom; - } - else if (!isNaN(vCenter)) { - extY = Math.abs(vCenter) * 2; - } - else if (!isNaN(top_1) || !isNaN(bottom)) { - extY = isNaN(top_1) ? 0 : top_1; - extY += isNaN(bottom) ? 0 : bottom; - } - else { - extY = bounds.y; - } - var preferredWidth = bounds.width; - var preferredHeight = bounds.height; - width = Math.ceil(Math.max(width, extX + preferredWidth)); - height = Math.ceil(Math.max(height, extY + preferredHeight)); - } - target.setMeasuredSize(width, height); - } - sys.measure = measure; - /** - * @private - * 一个工具方法,使用BasicLayout规则布局目标对象。 - */ - function updateDisplayList(target, unscaledWidth, unscaledHeight) { - if (!target) - return; - var count = target.numChildren; - var maxX = 0; - var maxY = 0; - var bounds = egret.$TempRectangle; - for (var i = 0; i < count; i++) { - var layoutElement = (target.getChildAt(i)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - var values = layoutElement.$UIComponent; - var hCenter = formatRelative(values[4 /* horizontalCenter */], unscaledWidth * 0.5); - var vCenter = formatRelative(values[5 /* verticalCenter */], unscaledHeight * 0.5); - var left = formatRelative(values[0 /* left */], unscaledWidth); - var right = formatRelative(values[1 /* right */], unscaledWidth); - var top_2 = formatRelative(values[2 /* top */], unscaledHeight); - var bottom = formatRelative(values[3 /* bottom */], unscaledHeight); - var percentWidth = values[6 /* percentWidth */]; - var percentHeight = values[7 /* percentHeight */]; - var childWidth = NaN; - var childHeight = NaN; - if (!isNaN(left) && !isNaN(right)) { - childWidth = unscaledWidth - right - left; - } - else if (!isNaN(percentWidth)) { - childWidth = Math.round(unscaledWidth * Math.min(percentWidth * 0.01, 1)); - } - if (!isNaN(top_2) && !isNaN(bottom)) { - childHeight = unscaledHeight - bottom - top_2; - } - else if (!isNaN(percentHeight)) { - childHeight = Math.round(unscaledHeight * Math.min(percentHeight * 0.01, 1)); - } - layoutElement.setLayoutBoundsSize(childWidth, childHeight); - layoutElement.getLayoutBounds(bounds); - var elementWidth = bounds.width; - var elementHeight = bounds.height; - var childX = NaN; - var childY = NaN; - if (!isNaN(hCenter)) - childX = Math.round((unscaledWidth - elementWidth) / 2 + hCenter); - else if (!isNaN(left)) - childX = left; - else if (!isNaN(right)) - childX = unscaledWidth - elementWidth - right; - else - childX = bounds.x; - if (!isNaN(vCenter)) - childY = Math.round((unscaledHeight - elementHeight) / 2 + vCenter); - else if (!isNaN(top_2)) - childY = top_2; - else if (!isNaN(bottom)) - childY = unscaledHeight - elementHeight - bottom; - else - childY = bounds.y; - layoutElement.setLayoutBoundsPosition(childX, childY); - maxX = Math.max(maxX, childX + elementWidth); - maxY = Math.max(maxY, childY + elementHeight); - } - return egret.$TempPoint.setTo(maxX, maxY); - } - sys.updateDisplayList = updateDisplayList; - })(sys = eui.sys || (eui.sys = {})); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The ColumnAlign class defines the possible values for the - * columnAlign property of the TileLayout class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/ColumnAlignExample.ts - * @language en_US - */ - /** - * ColumnAlign 类为 TileLayout 类的 columnAlign 属性定义可能的值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/ColumnAlignExample.ts - * @language zh_CN - */ - var ColumnAlign = (function () { - function ColumnAlign() { - } - /** - * Do not justify the rows. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 不将行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ColumnAlign.LEFT = "left"; - /** - * Justify the rows by increasing the vertical gap. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 通过增大水平间隙将行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ColumnAlign.JUSTIFY_USING_GAP = "justifyUsingGap"; - /** - * Justify the rows by increasing the row height. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 通过增大行高度将行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - ColumnAlign.JUSTIFY_USING_WIDTH = "justifyUsingWidth"; - return ColumnAlign; - }()); - eui.ColumnAlign = ColumnAlign; - __reflect(ColumnAlign.prototype, "eui.ColumnAlign"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var UIComponentClass = "eui.UIComponent"; - /** - * The HorizontalLayout class arranges the layout elements in a horizontal sequence, - * left to right, with optional gaps between the elements and optional padding - * around the elements. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/HorizontalLayoutExample.ts - * @language en_US - */ - /** - * HorizontalLayout 类按水平顺序从左到右排列布局元素,在元素和围绕元素的可选填充之间带有可选间隙。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/HorizontalLayoutExample.ts - * @language zh_CN - */ - var HorizontalLayout = (function (_super) { - __extends(HorizontalLayout, _super); - function HorizontalLayout() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HorizontalLayout.prototype.measureReal = function () { - var target = this.$target; - var count = target.numElements; - var numElements = count; - var measuredWidth = 0; - var measuredHeight = 0; - var bounds = egret.$TempRectangle; - for (var i = 0; i < count; i++) { - var layoutElement = (target.getElementAt(i)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - numElements--; - continue; - } - layoutElement.getPreferredBounds(bounds); - measuredWidth += bounds.width; - measuredHeight = Math.max(measuredHeight, bounds.height); - } - measuredWidth += (numElements - 1) * this.$gap; - var hPadding = this.$paddingLeft + this.$paddingRight; - var vPadding = this.$paddingTop + this.$paddingBottom; - target.setMeasuredSize(measuredWidth + hPadding, measuredHeight + vPadding); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HorizontalLayout.prototype.measureVirtual = function () { - var target = this.$target; - var typicalWidth = this.$typicalWidth; - var measuredWidth = this.getElementTotalSize(); - var measuredHeight = Math.max(this.maxElementSize, this.$typicalHeight); - var bounds = egret.$TempRectangle; - var endIndex = this.endIndex; - var elementSizeTable = this.elementSizeTable; - for (var index = this.startIndex; index < endIndex; index++) { - var layoutElement = (target.getElementAt(index)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - layoutElement.getPreferredBounds(bounds); - measuredWidth += bounds.width; - measuredWidth -= isNaN(elementSizeTable[index]) ? typicalWidth : elementSizeTable[index]; - measuredHeight = Math.max(measuredHeight, bounds.height); - } - var hPadding = this.$paddingLeft + this.$paddingRight; - var vPadding = this.$paddingTop + this.$paddingBottom; - target.setMeasuredSize(measuredWidth + hPadding, measuredHeight + vPadding); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HorizontalLayout.prototype.updateDisplayListReal = function (width, height) { - var target = this.$target; - var paddingL = this.$paddingLeft; - var paddingR = this.$paddingRight; - var paddingT = this.$paddingTop; - var paddingB = this.$paddingBottom; - var gap = this.$gap; - var targetWidth = Math.max(0, width - paddingL - paddingR); - var targetHeight = Math.max(0, height - paddingT - paddingB); - var hJustify = this.$horizontalAlign == eui.JustifyAlign.JUSTIFY; - var vJustify = this.$verticalAlign == eui.JustifyAlign.JUSTIFY || this.$verticalAlign == eui.JustifyAlign.CONTENT_JUSTIFY; - var vAlign = 0; - if (!vJustify) { - if (this.$verticalAlign == egret.VerticalAlign.MIDDLE) { - vAlign = 0.5; - } - else if (this.$verticalAlign == egret.VerticalAlign.BOTTOM) { - vAlign = 1; - } - } - var count = target.numElements; - var numElements = count; - var x = paddingL; - var y = paddingT; - var i; - var layoutElement; - var totalPreferredWidth = 0; - var totalPercentWidth = 0; - var childInfoArray = []; - var childInfo; - var widthToDistribute = targetWidth; - var maxElementHeight = this.maxElementSize; - var bounds = egret.$TempRectangle; - for (i = 0; i < count; i++) { - var layoutElement_1 = (target.getElementAt(i)); - if (!egret.is(layoutElement_1, UIComponentClass) || !layoutElement_1.$includeInLayout) { - numElements--; - continue; - } - layoutElement_1.getPreferredBounds(bounds); - maxElementHeight = Math.max(maxElementHeight, bounds.height); - if (hJustify) { - totalPreferredWidth += bounds.width; - } - else { - var values = layoutElement_1.$UIComponent; - if (!isNaN(values[6 /* percentWidth */])) { - totalPercentWidth += values[6 /* percentWidth */]; - childInfo = new eui.sys.ChildInfo(); - childInfo.layoutElement = layoutElement_1; - childInfo.percent = values[6 /* percentWidth */]; - childInfo.min = values[12 /* minWidth */]; - childInfo.max = values[13 /* maxWidth */]; - childInfoArray.push(childInfo); - } - else { - widthToDistribute -= bounds.width; - } - } - } - widthToDistribute -= gap * (numElements - 1); - widthToDistribute = widthToDistribute > 0 ? widthToDistribute : 0; - var excessSpace = targetWidth - totalPreferredWidth - gap * (numElements - 1); - var averageWidth; - var largeChildrenCount = numElements; - var widthDic = {}; - if (hJustify) { - if (excessSpace < 0) { - averageWidth = widthToDistribute / numElements; - for (i = 0; i < count; i++) { - layoutElement = (target.getElementAt(i)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - layoutElement.getPreferredBounds(bounds); - if (bounds.width <= averageWidth) { - widthToDistribute -= bounds.width; - largeChildrenCount--; - continue; - } - } - widthToDistribute = widthToDistribute > 0 ? widthToDistribute : 0; - } - } - else { - if (totalPercentWidth > 0) { - this.flexChildrenProportionally(targetWidth, widthToDistribute, totalPercentWidth, childInfoArray); - var roundOff_1 = 0; - var length_31 = childInfoArray.length; - for (i = 0; i < length_31; i++) { - childInfo = childInfoArray[i]; - var childSize = Math.round(childInfo.size + roundOff_1); - roundOff_1 += childInfo.size - childSize; - widthDic[childInfo.layoutElement.$hashCode] = childSize; - widthToDistribute -= childSize; - } - widthToDistribute = widthToDistribute > 0 ? widthToDistribute : 0; - } - } - if (this.$horizontalAlign == egret.HorizontalAlign.CENTER) { - x = paddingL + widthToDistribute * 0.5; - } - else if (this.$horizontalAlign == egret.HorizontalAlign.RIGHT) { - x = paddingL + widthToDistribute; - } - var maxX = paddingL; - var maxY = paddingT; - var dx = 0; - var dy = 0; - var justifyHeight = Math.ceil(targetHeight); - if (this.$verticalAlign == eui.JustifyAlign.CONTENT_JUSTIFY) - justifyHeight = Math.ceil(Math.max(targetHeight, maxElementHeight)); - var roundOff = 0; - var layoutElementWidth; - var childWidth; - for (i = 0; i < count; i++) { - var exceesHeight = 0; - layoutElement = (target.getElementAt(i)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - layoutElement.getPreferredBounds(bounds); - layoutElementWidth = NaN; - if (hJustify) { - childWidth = NaN; - if (excessSpace > 0) { - childWidth = widthToDistribute * bounds.width / totalPreferredWidth; - } - else if (excessSpace < 0 && bounds.width > averageWidth) { - childWidth = widthToDistribute / largeChildrenCount; - } - if (!isNaN(childWidth)) { - layoutElementWidth = Math.round(childWidth + roundOff); - roundOff += childWidth - layoutElementWidth; - } - } - else { - layoutElementWidth = widthDic[layoutElement.$hashCode]; - } - if (vJustify) { - y = paddingT; - layoutElement.setLayoutBoundsSize(layoutElementWidth, justifyHeight); - layoutElement.getLayoutBounds(bounds); - } - else { - var layoutElementHeight = NaN; - var values = layoutElement.$UIComponent; - if (!isNaN(layoutElement.percentHeight)) { - var percent = Math.min(100, values[7 /* percentHeight */]); - layoutElementHeight = Math.round(targetHeight * percent * 0.01); - } - layoutElement.setLayoutBoundsSize(layoutElementWidth, layoutElementHeight); - layoutElement.getLayoutBounds(bounds); - exceesHeight = (targetHeight - bounds.height) * vAlign; - exceesHeight = exceesHeight > 0 ? exceesHeight : 0; - y = paddingT + exceesHeight; - } - layoutElement.setLayoutBoundsPosition(Math.round(x), Math.round(y)); - dx = Math.ceil(bounds.width); - dy = Math.ceil(bounds.height); - maxX = Math.max(maxX, x + dx); - maxY = Math.max(maxY, y + dy); - x += dx + gap; - } - this.maxElementSize = maxElementHeight; - target.setContentSize(maxX + paddingR, maxY + paddingB); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HorizontalLayout.prototype.updateDisplayListVirtual = function (width, height) { - var target = this.$target; - if (this.indexInViewCalculated) - this.indexInViewCalculated = false; - else - this.getIndexInView(); - var paddingR = this.$paddingRight; - var paddingT = this.$paddingTop; - var paddingB = this.$paddingBottom; - var gap = this.$gap; - var contentWidth; - var numElements = target.numElements; - if (this.startIndex == -1 || this.endIndex == -1) { - contentWidth = this.getStartPosition(numElements) - gap + paddingR; - target.setContentSize(contentWidth, target.contentHeight); - return; - } - var endIndex = this.endIndex; - target.setVirtualElementIndicesInView(this.startIndex, endIndex); - //获取垂直布局参数 - var justify = this.$verticalAlign == eui.JustifyAlign.JUSTIFY || this.$verticalAlign == eui.JustifyAlign.CONTENT_JUSTIFY; - var contentJustify = this.$verticalAlign == eui.JustifyAlign.CONTENT_JUSTIFY; - var vAlign = 0; - if (!justify) { - if (this.$verticalAlign == egret.VerticalAlign.MIDDLE) { - vAlign = 0.5; - } - else if (this.$verticalAlign == egret.VerticalAlign.BOTTOM) { - vAlign = 1; - } - } - var bounds = egret.$TempRectangle; - var targetHeight = Math.max(0, height - paddingT - paddingB); - var justifyHeight = Math.ceil(targetHeight); - var layoutElement; - var typicalHeight = this.$typicalHeight; - var typicalWidth = this.$typicalWidth; - var maxElementHeight = this.maxElementSize; - var oldMaxH = Math.max(typicalHeight, this.maxElementSize); - if (contentJustify) { - for (var index = this.startIndex; index <= endIndex; index++) { - layoutElement = (target.getVirtualElementAt(index)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - layoutElement.getPreferredBounds(bounds); - maxElementHeight = Math.max(maxElementHeight, bounds.height); - } - justifyHeight = Math.ceil(Math.max(targetHeight, maxElementHeight)); - } - var x = 0; - var y = 0; - var contentHeight = 0; - var oldElementSize; - var needInvalidateSize = false; - var elementSizeTable = this.elementSizeTable; - //对可见区域进行布局 - for (var i = this.startIndex; i <= endIndex; i++) { - var exceesHeight = 0; - layoutElement = (target.getVirtualElementAt(i)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - layoutElement.getPreferredBounds(bounds); - if (!contentJustify) { - maxElementHeight = Math.max(maxElementHeight, bounds.height); - } - if (justify) { - y = paddingT; - layoutElement.setLayoutBoundsSize(NaN, justifyHeight); - layoutElement.getLayoutBounds(bounds); - } - else { - layoutElement.getLayoutBounds(bounds); - exceesHeight = (targetHeight - bounds.height) * vAlign; - exceesHeight = exceesHeight > 0 ? exceesHeight : 0; - y = paddingT + exceesHeight; - } - contentHeight = Math.max(contentHeight, bounds.height); - if (!needInvalidateSize) { - oldElementSize = isNaN(elementSizeTable[i]) ? typicalWidth : elementSizeTable[i]; - if (oldElementSize != bounds.width) - needInvalidateSize = true; - } - elementSizeTable[i] = bounds.width; - x = this.getStartPosition(i); - layoutElement.setLayoutBoundsPosition(Math.round(x), Math.round(y)); - } - contentHeight += paddingT + paddingB; - contentWidth = this.getStartPosition(numElements) - gap + paddingR; - this.maxElementSize = maxElementHeight; - target.setContentSize(contentWidth, contentHeight); - if (needInvalidateSize || oldMaxH < this.maxElementSize) { - target.invalidateSize(); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HorizontalLayout.prototype.getStartPosition = function (index) { - if (!this.$useVirtualLayout) { - if (this.$target) { - var element = this.$target.getElementAt(index); - if (element) { - return element.x; - } - } - } - var typicalWidth = this.$typicalWidth; - var startPos = this.$paddingLeft; - var gap = this.$gap; - var elementSizeTable = this.elementSizeTable; - for (var i = 0; i < index; i++) { - var w = elementSizeTable[i]; - if (isNaN(w)) { - w = typicalWidth; - } - startPos += w + gap; - } - return startPos; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HorizontalLayout.prototype.getElementSize = function (index) { - if (this.$useVirtualLayout) { - var size = this.elementSizeTable[index]; - if (isNaN(size)) { - size = this.$typicalWidth; - } - return size; - } - if (this.$target) { - return this.$target.getElementAt(index).width; - } - return 0; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HorizontalLayout.prototype.getElementTotalSize = function () { - var typicalWidth = this.$typicalWidth; - var gap = this.$gap; - var totalSize = 0; - var length = this.$target.numElements; - var elementSizeTable = this.elementSizeTable; - for (var i = 0; i < length; i++) { - var w = elementSizeTable[i]; - if (isNaN(w)) { - w = typicalWidth; - } - totalSize += w + gap; - } - totalSize -= gap; - return totalSize; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HorizontalLayout.prototype.elementAdded = function (index) { - if (!this.useVirtualLayout) - return; - _super.prototype.elementAdded.call(this, index); - this.elementSizeTable.splice(index, 0, this.$typicalWidth); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HorizontalLayout.prototype.getIndexInView = function () { - var target = this.$target; - if (!target || target.numElements == 0) { - this.startIndex = this.endIndex = -1; - return false; - } - var values = target.$UIComponent; - if (values[10 /* width */] <= 0 || values[11 /* height */] <= 0) { - this.startIndex = this.endIndex = -1; - return false; - } - var numElements = target.numElements; - var contentWidth = this.getStartPosition(numElements - 1) + - this.elementSizeTable[numElements - 1] + this.$paddingRight; - var minVisibleX = target.scrollH; - if (minVisibleX > contentWidth - this.$paddingRight) { - this.startIndex = -1; - this.endIndex = -1; - return false; - } - var maxVisibleX = target.scrollH + values[10 /* width */]; - if (maxVisibleX < this.$paddingLeft) { - this.startIndex = -1; - this.endIndex = -1; - return false; - } - var oldStartIndex = this.startIndex; - var oldEndIndex = this.endIndex; - this.startIndex = this.findIndexAt(minVisibleX, 0, numElements - 1); - if (this.startIndex == -1) - this.startIndex = 0; - this.endIndex = this.findIndexAt(maxVisibleX, 0, numElements - 1); - if (this.endIndex == -1) - this.endIndex = numElements - 1; - return oldStartIndex != this.startIndex || oldEndIndex != this.endIndex; - }; - return HorizontalLayout; - }(eui.LinearLayoutBase)); - eui.HorizontalLayout = HorizontalLayout; - __reflect(HorizontalLayout.prototype, "eui.HorizontalLayout"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The JustifyAlign class defines the possible values for the - * horizontalAlignverticalAlign property of - * Layout class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/JustifyAlignExample.ts - * @language en_US - */ - /** - * JustifyAlign 定义布局类中 horizontalAlign 与 verticalAlign 属性需要的两端对齐常量值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/JustifyAlignExample.ts - * @language zh_CN - */ - var JustifyAlign = (function () { - function JustifyAlign() { - } - /** - * Justify the children with respect to the container. - * This uniformly sizes all children to be the same size as the - * container. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对齐子代。这会将所有子代的大小统一调整为与容器相同的尺寸。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - JustifyAlign.JUSTIFY = "justify"; - /** - * Content justify the children width/height respect to the container. - * This uniformly sizes all children to be the content width/height of the container. - * The content width/height of the container is the size of the largest child. - * If all children are smaller than the width/height of the container, then - * all the children will be sized to the width/height of the container. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子代进行内容对齐。这会将所有子代的大小统一调整为容器的内容宽度/高度。 - * 容器的内容宽度/高度是最大子代的大小。如果所有子代都小于容器的宽度/高度,则会将所有子代的大小调整为容器的宽度/高度。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - JustifyAlign.CONTENT_JUSTIFY = "contentJustify"; - return JustifyAlign; - }()); - eui.JustifyAlign = JustifyAlign; - __reflect(JustifyAlign.prototype, "eui.JustifyAlign"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The RowAlign class defines the possible values for the - * rowAlign property of the TileLayout class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/RowAlignExample.ts - * @language en_US - */ - /** - * RowAlign 类为 TileLayout 类的 rowAlign 属性定义可能的值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/RowAlignExample.ts - * @language zh_CN - */ - var RowAlign = (function () { - function RowAlign() { - } - /** - * Do not justify the rows. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 不进行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - RowAlign.TOP = "top"; - /** - * Justify the rows by increasing the vertical gap. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 通过增大垂直间隙将行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - RowAlign.JUSTIFY_USING_GAP = "justifyUsingGap"; - /** - * Justify the rows by increasing the row height. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 通过增大行高度将行两端对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - RowAlign.JUSTIFY_USING_HEIGHT = "justifyUsingHeight"; - return RowAlign; - }()); - eui.RowAlign = RowAlign; - __reflect(RowAlign.prototype, "eui.RowAlign"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var UIComponentClass = "eui.UIComponent"; - /** - * The TileLayout class arranges layout elements in columns and rows - * of equally-sized cells. - * The TileLayout class uses a number of properties that control orientation, - * count, size, gap and justification of the columns and the rows - * as well as element alignment within the cells. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/TileLayoutExample.ts - * @language en_US - */ - /** - * TileLayout 类在单元格大小相等的列和行中排列布局元素。 - * TileLayout 类使用许多属性来控制列和行的方向、计数、大小、间隙和两端对齐以及单元格内的元素对齐。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/TileLayoutExample.ts - * @language zh_CN - */ - var TileLayout = (function (_super) { - __extends(TileLayout, _super); - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function TileLayout() { - var _this = _super.call(this) || this; - /** - * @private - * 标记horizontalGap被显式指定过 - */ - _this.explicitHorizontalGap = NaN; - /** - * @private - */ - _this._horizontalGap = 6; - /** - * @private - * 标记verticalGap被显式指定过 - */ - _this.explicitVerticalGap = NaN; - /** - * @private - */ - _this._verticalGap = 6; - /** - * @private - */ - _this._columnCount = -1; - /** - * @private - */ - _this._requestedColumnCount = 0; - /** - * @private - */ - _this._rowCount = -1; - /** - * @private - */ - _this._requestedRowCount = 0; - /** - * @private - * 外部显式指定的列宽 - */ - _this.explicitColumnWidth = NaN; - /** - * @private - */ - _this._columnWidth = NaN; - /** - * @private - * 外部显式指定的行高 - */ - _this.explicitRowHeight = NaN; - /** - * @private - */ - _this._rowHeight = NaN; - /** - * @private - */ - _this._paddingLeft = 0; - /** - * @private - */ - _this._paddingRight = 0; - /** - * @private - */ - _this._paddingTop = 0; - /** - * @private - */ - _this._paddingBottom = 0; - /** - * @private - */ - _this._horizontalAlign = eui.JustifyAlign.JUSTIFY; - /** - * @private - */ - _this._verticalAlign = eui.JustifyAlign.JUSTIFY; - /** - * @private - */ - _this._columnAlign = eui.ColumnAlign.LEFT; - /** - * @private - */ - _this._rowAlign = eui.RowAlign.TOP; - /** - * @private - */ - _this._orientation = eui.TileOrientation.ROWS; - /** - * @private - * 缓存的最大子对象宽度 - */ - _this.maxElementWidth = 0; - /** - * @private - * 缓存的最大子对象高度 - */ - _this.maxElementHeight = 0; - /** - * @private - * 当前视图中的第一个元素索引 - */ - _this.startIndex = -1; - /** - * @private - * 当前视图中的最后一个元素的索引 - */ - _this.endIndex = -1; - /** - * @private - * 视图的第一个和最后一个元素的索引值已经计算好的标志 - */ - _this.indexInViewCalculated = false; - return _this; - } - Object.defineProperty(TileLayout.prototype, "horizontalGap", { - /** - * Horizontal space between columns, in pixels. - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 列之间的水平空间(以像素为单位)。 - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._horizontalGap; - }, - set: function (value) { - value = +value; - if (value === this._horizontalGap) - return; - this.explicitHorizontalGap = value; - this._horizontalGap = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "verticalGap", { - /** - * Vertical space between rows, in pixels. - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 行之间的垂直空间(以像素为单位)。 - * - * @default 6 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._verticalGap; - }, - set: function (value) { - value = +value; - if (value === this._verticalGap) - return; - this.explicitVerticalGap = value; - this._verticalGap = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "columnCount", { - /** - * Contain the actual column count. - * - * @default -1 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 实际列计数。 - * - * @default -1 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._columnCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "requestedColumnCount", { - /** - * Number of columns to be displayed. - *

      Set to 0 to allow the TileLayout to determine - * the column count automatically.

      - *

      If the orientation property is set to TileOrientation.ROWS, - * then setting this property has no effect - * In this case, the rowCount is explicitly set, and the - * container width is explicitly set.

      - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要显示的列数。 - *

      设置为 0 会允许 TileLayout 自动确定列计数。

      - *

      如果将 orientation 属性设置为 TileOrientation.ROWS, - * 则设置此属性不会产生任何效果。这种情况下,会显式设置 code>rowCount,并显式设置容器宽度。

      - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._requestedColumnCount; - }, - set: function (value) { - value = +value || 0; - if (this._requestedColumnCount === value) - return; - this._requestedColumnCount = value; - this._columnCount = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "rowCount", { - /** - * The row count. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 行计数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._rowCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "requestedRowCount", { - /** - * Number of rows to be displayed. - *

      Set to 0 to remove explicit override and allow the TileLayout to determine - * the row count automatically.

      - *

      If the orientation property is set to - * TileOrientation.COLUMNS, setting this property has no effect. - * in this case, columnCount is explicitly set, and the - * container height is explicitly set.

      - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 要显示的行数。 - * 设置为 -1 会删除显式覆盖并允许 TileLayout 自动确定行计数。 - * 如果将 orientation 属性设置为 TileOrientation.COLUMNS, - * 则设置此属性不会产生任何效果。这种情况下,会显式设置 columnCount,并显式设置容器高度。 - * - * @default 0 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._requestedRowCount; - }, - set: function (value) { - value = +value || 0; - if (this._requestedRowCount == value) - return; - this._requestedRowCount = value; - this._rowCount = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "columnWidth", { - /** - * Contain the actual column width, in pixels. - *

      If not explicitly set, the column width is - * determined from the width of the widest element.

      - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 包含实际列宽(以像素为单位)。 - *

      若未显式设置,则从根据最宽的元素的宽度确定列宽度。

      - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._columnWidth; - }, - set: function (value) { - value = +value; - if (value === this._columnWidth) - return; - this.explicitColumnWidth = value; - this._columnWidth = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "rowHeight", { - /** - * The row height, in pixels. - *

      If not explicitly set, the row height is - * determined from the maximum of elements' height.

      - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 行高(以像素为单位)。 - *

      如果未显式设置,则从元素的高度的最大值确定行高度。

      - * - * @default NaN - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._rowHeight; - }, - set: function (value) { - value = +value; - if (value === this._rowHeight) - return; - this.explicitRowHeight = value; - this._rowHeight = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "paddingLeft", { - /** - * @copy eui.LinearLayoutBase#paddingLeft - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - return this._paddingLeft; - }, - set: function (value) { - value = +value || 0; - if (this._paddingLeft == value) - return; - this._paddingLeft = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "paddingRight", { - /** - * @copy eui.LinearLayoutBase#paddingRight - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - return this._paddingRight; - }, - set: function (value) { - value = +value || 0; - if (this._paddingRight === value) - return; - this._paddingRight = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "paddingTop", { - /** - * @copy eui.LinearLayoutBase#paddingTop - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - return this._paddingTop; - }, - set: function (value) { - value = +value || 0; - if (this._paddingTop == value) - return; - this._paddingTop = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "paddingBottom", { - /** - * @copy eui.LinearLayoutBase#paddingBottom - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - get: function () { - return this._paddingBottom; - }, - set: function (value) { - value = +value || 0; - if (this._paddingBottom === value) - return; - this._paddingBottom = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "horizontalAlign", { - /** - * Specifies how to align the elements within the cells in the horizontal direction. - * Supported values are - * HorizontalAlign.LEFT、HorizontalAlign.CENTER、 - * HorizontalAlign.RIGHT、JustifyAlign.JUSTIFY。 - * - * @default JustifyAlign.JUSTIFY - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指定如何在水平方向上对齐单元格内的元素。支持的值有 - * HorizontalAlign.LEFT、HorizontalAlign.CENTER、 - * HorizontalAlign.RIGHT、JustifyAlign.JUSTIFY。 - * - * @default JustifyAlign.JUSTIFY - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._horizontalAlign; - }, - set: function (value) { - if (this._horizontalAlign == value) - return; - this._horizontalAlign = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "verticalAlign", { - /** - * 指定如何在垂直方向上对齐单元格内的元素。 - * 支持的值有 VerticalAlign.TOP、VerticalAlign.MIDDLE、 - * VerticalAlign.BOTTOM、JustifyAlign.JUSTIFY。 - * 默认值:JustifyAlign.JUSTIFY。 - * - * @default eui.JustifyAlign.JUSTIFY - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * Specifies how to align the elements within the cells in the vertical direction. - * Supported values are - * VerticalAlign.TOP、VerticalAlign.MIDDLE、 - * VerticalAlign.BOTTOM、JustifyAlign.JUSTIFY。 - * - * @default eui.JustifyAlign.JUSTIFY - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._verticalAlign; - }, - set: function (value) { - if (this._verticalAlign == value) - return; - this._verticalAlign = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "columnAlign", { - /** - * Specifies how to justify the fully visible columns to the container width. - * - *

      When set to ColumnAlign.LEFT it turns column justification off. - * There may be partially visible columns or whitespace between the last column and - * the right edge of the container. This is the default value.

      - * - *

      When set to ColumnAlign.JUSTIFY_USING_GAP the horizontalGap - * actual value increases so that - * the last fully visible column right edge aligns with the container's right edge. - * In case there is only a single fully visible column, the horizontalGap actual value - * increases so that it pushes any partially visible column beyond the right edge - * of the container. - * Note that explicitly setting the horizontalGap property does not turn off - * justification. It only determines the initial gap value. - * Justification may increases it.

      - * - *

      When set to ColumnAlign.JUSTIFY_USING_WIDTH the columnWidth - * actual value increases so that - * the last fully visible column right edge aligns with the container's right edge. - * Note that explicitly setting the columnWidth property does not turn off justification. - * It only determines the initial column width value. - * Justification may increases it.

      - * - * @default ColumnAlign.LEFT - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指定如何将完全可见列与容器宽度对齐。 - * - *

      设置为 ColumnAlign.LEFT 时,它会关闭列两端对齐。 - * 在容器的最后一列和右边缘之间可能存在部分可见的列或空白。这是默认值。

      - * - *

      设置为 ColumnAlign.JUSTIFY_USING_GAP 时,horizontalGap 的实际值将增大, - * 这样最后一个完全可见列右边缘会与容器的右边缘对齐。仅存在一个完全可见列时, - * horizontalGap 的实际值将增大,这样它会将任何部分可见列推到容器的右边缘之外。 - * 请注意显式设置 horizontalGap 属性不会关闭两端对齐。它仅确定初始间隙值。两端对齐可能会增大它。

      - * - *

      设置为 ColumnAlign.JUSTIFY_USING_WIDTH 时,columnWidth 的实际值将增大, - * 这样最后一个完全可见列右边缘会与容器的右边缘对齐。请注意显式设置 columnWidth 属性不会关闭两端对齐。 - * 它仅确定初始列宽度值。两端对齐可能会增大它。

      - * - * @default ColumnAlign.LEFT - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._columnAlign; - }, - set: function (value) { - if (this._columnAlign == value) - return; - this._columnAlign = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "rowAlign", { - /** - * Specifies how to justify the fully visible rows to the container height. - * - *

      When set to RowAlign.TOP it turns column justification off. - * There might be partially visible rows or whitespace between the last row and - * the bottom edge of the container. This is the default value.

      - * - *

      When set to RowAlign.JUSTIFY_USING_GAP the verticalGap - * actual value increases so that - * the last fully visible row bottom edge aligns with the container's bottom edge. - * In case there is only a single fully visible row, the value of verticalGap - * increases so that it pushes any partially visible row beyond the bottom edge - * of the container. Note that explicitly setting the verticalGap does not turn off - * justification, but just determines the initial gap value. - * Justification can then increases it.

      - * - *

      When set to RowAlign.JUSTIFY_USING_HEIGHT the rowHeight - * actual value increases so that - * the last fully visible row bottom edge aligns with the container's bottom edge. Note that - * explicitly setting the rowHeight does not turn off justification, but - * determines the initial row height value. - * Justification can then increase it.

      - * - * @default RowAlign.TOP - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指定如何将完全可见行与容器高度对齐。 - * - *

      设置为 RowAlign.TOP 时,它会关闭列两端对齐。 - * 在容器的最后一行和底边缘之间可能存在部分可见的行或空白。这是默认值。

      - * - *

      设置为 RowAlign.JUSTIFY_USING_GAP 时,verticalGap 的实际值会增大, - * 这样最后一个完全可见行底边缘会与容器的底边缘对齐。仅存在一个完全可见行时,verticalGap 的值会增大, - * 这样它会将任何部分可见行推到容器的底边缘之外。请注意,显式设置 verticalGap - * 不会关闭两端对齐,而只是确定初始间隙值。两端对齐接着可以增大它。

      - * - *

      设置为 RowAlign.JUSTIFY_USING_HEIGHT 时,rowHeight 的实际值会增大, - * 这样最后一个完全可见行底边缘会与容器的底边缘对齐。请注意,显式设置 rowHeight - * 不会关闭两端对齐,而只是确定初始行高度值。两端对齐接着可以增大它。

      - * - * @default RowAlign.TOP - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._rowAlign; - }, - set: function (value) { - if (this._rowAlign == value) - return; - this._rowAlign = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TileLayout.prototype, "orientation", { - /** - * Specifies whether elements are arranged row by row or - * column by column. - * - * @default TileOrientation.ROWS - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 指定是逐行还是逐列排列元素。 - * - * @default TileOrientation.ROWS - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._orientation; - }, - set: function (value) { - if (this._orientation == value) - return; - this._orientation = value; - this.invalidateTargetLayout(); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * 标记目标容器的尺寸和显示列表失效 - */ - TileLayout.prototype.invalidateTargetLayout = function () { - var target = this.$target; - if (target) { - target.invalidateSize(); - target.invalidateDisplayList(); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - TileLayout.prototype.measure = function () { - var target = this.$target; - if (!target) - return; - var savedColumnCount = this._columnCount; - var savedRowCount = this._rowCount; - var savedColumnWidth = this._columnWidth; - var savedRowHeight = this._rowHeight; - var measuredWidth = 0; - var measuredHeight = 0; - var values = target.$UIComponent; - this.calculateRowAndColumn(values[8 /* explicitWidth */], values[9 /* explicitHeight */]); - var columnCount = this._requestedColumnCount > 0 ? this._requestedColumnCount : this._columnCount; - var rowCount = this._requestedRowCount > 0 ? this._requestedRowCount : this._rowCount; - var horizontalGap = isNaN(this._horizontalGap) ? 0 : this._horizontalGap; - var verticalGap = isNaN(this._verticalGap) ? 0 : this._verticalGap; - if (columnCount > 0) { - measuredWidth = columnCount * (this._columnWidth + horizontalGap) - horizontalGap; - } - if (rowCount > 0) { - measuredHeight = rowCount * (this._rowHeight + verticalGap) - verticalGap; - } - var hPadding = this._paddingLeft + this._paddingRight; - var vPadding = this._paddingTop + this._paddingBottom; - target.setMeasuredSize(measuredWidth + hPadding, measuredHeight + vPadding); - this._columnCount = savedColumnCount; - this._rowCount = savedRowCount; - this._columnWidth = savedColumnWidth; - this._rowHeight = savedRowHeight; - }; - /** - * @private - * 计算行和列的尺寸及数量 - */ - TileLayout.prototype.calculateRowAndColumn = function (explicitWidth, explicitHeight) { - var target = this.$target; - var horizontalGap = isNaN(this._horizontalGap) ? 0 : this._horizontalGap; - var verticalGap = isNaN(this._verticalGap) ? 0 : this._verticalGap; - this._rowCount = this._columnCount = -1; - var numElements = target.numElements; - var count = numElements; - for (var index = 0; index < count; index++) { - var layoutElement = (target.getElementAt(index)); - if (layoutElement && (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout)) { - numElements--; - continue; - } - } - if (numElements == 0) { - this._rowCount = this._columnCount = 0; - return; - } - if (isNaN(this.explicitColumnWidth) || isNaN(this.explicitRowHeight)) - this.updateMaxElementSize(); - if (isNaN(this.explicitColumnWidth)) { - this._columnWidth = this.maxElementWidth; - } - else { - this._columnWidth = this.explicitColumnWidth; - } - if (isNaN(this.explicitRowHeight)) { - this._rowHeight = this.maxElementHeight; - } - else { - this._rowHeight = this.explicitRowHeight; - } - var itemWidth = this._columnWidth + horizontalGap; - //防止出现除数为零的情况 - if (itemWidth <= 0) - itemWidth = 1; - var itemHeight = this._rowHeight + verticalGap; - if (itemHeight <= 0) - itemHeight = 1; - var orientedByColumns = (this._orientation == eui.TileOrientation.COLUMNS); - var widthHasSet = !isNaN(explicitWidth); - var heightHasSet = !isNaN(explicitHeight); - var paddingL = this._paddingLeft; - var paddingR = this._paddingRight; - var paddingT = this._paddingTop; - var paddingB = this._paddingBottom; - if (this._requestedColumnCount > 0 || this._requestedRowCount > 0) { - if (this._requestedRowCount > 0) - this._rowCount = Math.min(this._requestedRowCount, numElements); - if (this._requestedColumnCount > 0) - this._columnCount = Math.min(this._requestedColumnCount, numElements); - } - else if (!widthHasSet && !heightHasSet) { - var side = Math.sqrt(numElements * itemWidth * itemHeight); - if (orientedByColumns) { - this._rowCount = Math.max(1, Math.round(side / itemHeight)); - } - else { - this._columnCount = Math.max(1, Math.round(side / itemWidth)); - } - } - else if (widthHasSet && (!heightHasSet || !orientedByColumns)) { - var targetWidth = Math.max(0, explicitWidth - paddingL - paddingR); - this._columnCount = Math.floor((targetWidth + horizontalGap) / itemWidth); - this._columnCount = Math.max(1, Math.min(this._columnCount, numElements)); - } - else { - var targetHeight = Math.max(0, explicitHeight - paddingT - paddingB); - this._rowCount = Math.floor((targetHeight + verticalGap) / itemHeight); - this._rowCount = Math.max(1, Math.min(this._rowCount, numElements)); - } - if (this._rowCount == -1) - this._rowCount = Math.max(1, Math.ceil(numElements / this._columnCount)); - if (this._columnCount == -1) - this._columnCount = Math.max(1, Math.ceil(numElements / this._rowCount)); - if (this._requestedColumnCount > 0 && this._requestedRowCount > 0) { - if (this._orientation == eui.TileOrientation.ROWS) - this._rowCount = Math.max(1, Math.ceil(numElements / this._requestedColumnCount)); - else - this._columnCount = Math.max(1, Math.ceil(numElements / this._requestedRowCount)); - } - }; - /** - * @private - * 更新最大子对象尺寸 - */ - TileLayout.prototype.updateMaxElementSize = function () { - if (!this.$target) - return; - if (this.$useVirtualLayout) { - this.maxElementWidth = Math.max(this.maxElementWidth, this.$typicalWidth); - this.maxElementHeight = Math.max(this.maxElementHeight, this.$typicalHeight); - this.doUpdateMaxElementSize(this.startIndex, this.endIndex); - } - else { - this.doUpdateMaxElementSize(0, this.$target.numElements - 1); - } - }; - /** - * @private - * 更新虚拟布局的最大子对象尺寸 - */ - TileLayout.prototype.doUpdateMaxElementSize = function (startIndex, endIndex) { - var maxElementWidth = this.maxElementWidth; - var maxElementHeight = this.maxElementHeight; - var bounds = egret.$TempRectangle; - var target = this.$target; - if ((startIndex != -1) && (endIndex != -1)) { - for (var index = startIndex; index <= endIndex; index++) { - var elt = target.getVirtualElementAt(index); - if (!egret.is(elt, UIComponentClass) || !elt.$includeInLayout) { - continue; - } - elt.getPreferredBounds(bounds); - maxElementWidth = Math.max(maxElementWidth, bounds.width); - maxElementHeight = Math.max(maxElementHeight, bounds.height); - } - } - this.maxElementWidth = maxElementWidth; - this.maxElementHeight = maxElementHeight; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - TileLayout.prototype.clearVirtualLayoutCache = function () { - _super.prototype.clearVirtualLayoutCache.call(this); - this.maxElementWidth = 0; - this.maxElementHeight = 0; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - TileLayout.prototype.scrollPositionChanged = function () { - if (this.$useVirtualLayout) { - var changed = this.getIndexInView(); - if (changed) { - this.indexInViewCalculated = true; - this.$target.invalidateDisplayList(); - } - } - }; - /** - * @private - * 获取视图中第一个和最后一个元素的索引,返回是否发生改变 - */ - TileLayout.prototype.getIndexInView = function () { - if (!this.$target || this.$target.numElements == 0) { - this.startIndex = this.endIndex = -1; - return false; - } - var target = this.$target; - var numElements = target.numElements; - if (!this.$useVirtualLayout) { - this.startIndex = 0; - this.endIndex = numElements - 1; - return false; - } - var values = target.$UIComponent; - if (values[10 /* width */] == 0 || values[11 /* height */] == 0) { - this.startIndex = this.endIndex = -1; - return false; - } - var oldStartIndex = this.startIndex; - var oldEndIndex = this.endIndex; - var paddingL = this._paddingLeft; - var paddingT = this._paddingTop; - var horizontalGap = isNaN(this._horizontalGap) ? 0 : this._horizontalGap; - var verticalGap = isNaN(this._verticalGap) ? 0 : this._verticalGap; - if (this._orientation == eui.TileOrientation.COLUMNS) { - var itemWidth = this._columnWidth + horizontalGap; - if (itemWidth <= 0) { - this.startIndex = 0; - this.endIndex = numElements - 1; - return false; - } - var minVisibleX = target.scrollH; - var maxVisibleX = minVisibleX + values[10 /* width */]; - var startColumn = Math.floor((minVisibleX - paddingL) / itemWidth); - if (startColumn < 0) - startColumn = 0; - var endColumn = Math.ceil((maxVisibleX - paddingL) / itemWidth); - if (endColumn < 0) - endColumn = 0; - this.startIndex = Math.min(numElements - 1, Math.max(0, startColumn * this._rowCount)); - this.endIndex = Math.min(numElements - 1, Math.max(0, endColumn * this._rowCount - 1)); - } - else { - var itemHeight = this._rowHeight + verticalGap; - if (itemHeight <= 0) { - this.startIndex = 0; - this.endIndex = numElements - 1; - return false; - } - var minVisibleY = target.scrollV; - var maxVisibleY = minVisibleY + values[11 /* height */]; - var startRow = Math.floor((minVisibleY - paddingT) / itemHeight); - if (startRow < 0) - startRow = 0; - var endRow = Math.ceil((maxVisibleY - paddingT) / itemHeight); - if (endRow < 0) - endRow = 0; - this.startIndex = Math.min(numElements - 1, Math.max(0, startRow * this._columnCount)); - this.endIndex = Math.min(numElements - 1, Math.max(0, endRow * this._columnCount - 1)); - } - return this.startIndex != oldStartIndex || this.endIndex != oldEndIndex; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - TileLayout.prototype.updateDisplayList = function (width, height) { - _super.prototype.updateDisplayList.call(this, width, height); - if (!this.$target) - return; - var target = this.$target; - var paddingL = this._paddingLeft; - var paddingR = this._paddingRight; - var paddingT = this._paddingTop; - var paddingB = this._paddingBottom; - if (this.indexInViewCalculated) { - this.indexInViewCalculated = false; - } - else { - this.calculateRowAndColumn(width, height); - if (this._rowCount == 0 || this._columnCount == 0) { - target.setContentSize(paddingL + paddingR, paddingT + paddingB); - return; - } - this.adjustForJustify(width, height); - this.getIndexInView(); - } - if (this.$useVirtualLayout) { - this.calculateRowAndColumn(width, height); - this.adjustForJustify(width, height); - } - if (this.startIndex == -1 || this.endIndex == -1) { - target.setContentSize(0, 0); - return; - } - var endIndex = this.endIndex; - target.setVirtualElementIndicesInView(this.startIndex, endIndex); - var elt; - var x; - var y; - var columnIndex; - var rowIndex; - var orientedByColumns = (this._orientation == eui.TileOrientation.COLUMNS); - var index = this.startIndex; - var horizontalGap = isNaN(this._horizontalGap) ? 0 : this._horizontalGap; - var verticalGap = isNaN(this._verticalGap) ? 0 : this._verticalGap; - var rowCount = this._rowCount; - var columnCount = this._columnCount; - var columnWidth = this._columnWidth; - var rowHeight = this._rowHeight; - for (var i = this.startIndex; i <= endIndex; i++) { - if (this.$useVirtualLayout) { - elt = (this.target.getVirtualElementAt(i)); - } - else { - elt = (this.target.getElementAt(i)); - } - if (!egret.is(elt, UIComponentClass) || !elt.$includeInLayout) { - continue; - } - if (orientedByColumns) { - columnIndex = Math.ceil((index + 1) / rowCount) - 1; - rowIndex = Math.ceil((index + 1) % rowCount) - 1; - if (rowIndex == -1) - rowIndex = rowCount - 1; - } - else { - columnIndex = Math.ceil((index + 1) % columnCount) - 1; - if (columnIndex == -1) - columnIndex = columnCount - 1; - rowIndex = Math.ceil((index + 1) / columnCount) - 1; - } - switch (this._horizontalAlign) { - case egret.HorizontalAlign.RIGHT: - x = width - (columnIndex + 1) * (columnWidth + horizontalGap) + horizontalGap - paddingR; - break; - case egret.HorizontalAlign.LEFT: - x = columnIndex * (columnWidth + horizontalGap) + paddingL; - break; - default: - x = columnIndex * (columnWidth + horizontalGap) + paddingL; - } - switch (this._verticalAlign) { - case egret.VerticalAlign.TOP: - y = rowIndex * (rowHeight + verticalGap) + paddingT; - break; - case egret.VerticalAlign.BOTTOM: - y = height - (rowIndex + 1) * (rowHeight + verticalGap) + verticalGap - paddingB; - break; - default: - y = rowIndex * (rowHeight + verticalGap) + paddingT; - } - this.sizeAndPositionElement(elt, x, y, columnWidth, rowHeight); - index++; - } - var hPadding = paddingL + paddingR; - var vPadding = paddingT + paddingB; - var contentWidth = (columnWidth + horizontalGap) * columnCount - horizontalGap; - var contentHeight = (rowHeight + verticalGap) * rowCount - verticalGap; - target.setContentSize(contentWidth + hPadding, contentHeight + vPadding); - }; - /** - * @private - * 为单个元素布局 - */ - TileLayout.prototype.sizeAndPositionElement = function (element, cellX, cellY, cellWidth, cellHeight) { - var elementWidth = NaN; - var elementHeight = NaN; - var values = element.$UIComponent; - if (this._horizontalAlign == eui.JustifyAlign.JUSTIFY) - elementWidth = cellWidth; - else if (!isNaN(values[6 /* percentWidth */])) - elementWidth = cellWidth * values[6 /* percentWidth */] * 0.01; - if (this._verticalAlign == eui.JustifyAlign.JUSTIFY) - elementHeight = cellHeight; - else if (!isNaN(values[7 /* percentHeight */])) - elementHeight = cellHeight * values[7 /* percentHeight */] * 0.01; - element.setLayoutBoundsSize(Math.round(elementWidth), Math.round(elementHeight)); - var x = cellX; - var bounds = egret.$TempRectangle; - element.getLayoutBounds(bounds); - switch (this._horizontalAlign) { - case egret.HorizontalAlign.RIGHT: - x += cellWidth - bounds.width; - break; - case egret.HorizontalAlign.CENTER: - x = cellX + (cellWidth - bounds.width) / 2; - break; - } - var y = cellY; - switch (this._verticalAlign) { - case egret.VerticalAlign.BOTTOM: - y += cellHeight - bounds.height; - break; - case egret.VerticalAlign.MIDDLE: - y += (cellHeight - bounds.height) / 2; - break; - } - element.setLayoutBoundsPosition(Math.round(x), Math.round(y)); - }; - /** - * @private - * 为两端对齐调整间隔或格子尺寸 - */ - TileLayout.prototype.adjustForJustify = function (width, height) { - var paddingL = this._paddingLeft; - var paddingR = this._paddingRight; - var paddingT = this._paddingTop; - var paddingB = this._paddingBottom; - var targetWidth = Math.max(0, width - paddingL - paddingR); - var targetHeight = Math.max(0, height - paddingT - paddingB); - if (!isNaN(this.explicitVerticalGap)) - this._verticalGap = this.explicitVerticalGap; - if (!isNaN(this.explicitHorizontalGap)) - this._horizontalGap = this.explicitHorizontalGap; - this._verticalGap = isNaN(this._verticalGap) ? 0 : this._verticalGap; - this._horizontalGap = isNaN(this._horizontalGap) ? 0 : this._horizontalGap; - var offsetY = targetHeight - this._rowHeight * this._rowCount; - var offsetX = targetWidth - this._columnWidth * this._columnCount; - var gapCount; - if (offsetY > 0) { - if (this._rowAlign == eui.RowAlign.JUSTIFY_USING_GAP) { - gapCount = Math.max(1, this._rowCount - 1); - this._verticalGap = offsetY / gapCount; - } - else if (this._rowAlign == eui.RowAlign.JUSTIFY_USING_HEIGHT) { - if (this._rowCount > 0) { - this._rowHeight += (offsetY - (this._rowCount - 1) * this._verticalGap) / this._rowCount; - } - } - } - if (offsetX > 0) { - if (this._columnAlign == eui.ColumnAlign.JUSTIFY_USING_GAP) { - gapCount = Math.max(1, this._columnCount - 1); - this._horizontalGap = offsetX / gapCount; - } - else if (this._columnAlign == eui.ColumnAlign.JUSTIFY_USING_WIDTH) { - if (this._columnCount > 0) { - this._columnWidth += (offsetX - (this._columnCount - 1) * this._horizontalGap) / this._columnCount; - } - } - } - }; - return TileLayout; - }(eui.LayoutBase)); - eui.TileLayout = TileLayout; - __reflect(TileLayout.prototype, "eui.TileLayout"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The TileOrientation class defines the possible values for the - * orientation property of the TileLayout class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/TileOrientationExample.ts - * @language en_US - */ - /** - * TileOrientation 类为 TileLayout 类的 orientation 属性定义可能的值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/TileOrientationExample.ts - * @language zh_CN - */ - var TileOrientation = (function () { - function TileOrientation() { - } - /** - * Arranges elements row by row. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 逐行排列元素。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - TileOrientation.ROWS = "rows"; - /** - * Arranges elements column by column. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 逐列排列元素。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - TileOrientation.COLUMNS = "columns"; - return TileOrientation; - }()); - eui.TileOrientation = TileOrientation; - __reflect(TileOrientation.prototype, "eui.TileOrientation"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var UIComponentClass = "eui.UIComponent"; - /** - * The VerticalLayout class arranges the layout elements in a vertical sequence, - * top to bottom, with optional gaps between the elements and optional padding - * around the sequence of elements. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/VerticalLayoutExample.ts - * @language en_US - */ - /** - * VerticalLayout 类按垂直顺序从上向下排列布局元素,在元素和围绕元素顺序的可选填充之间带有可选间隙。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/layout/VerticalLayoutExample.ts - * @language zh_CN - */ - var VerticalLayout = (function (_super) { - __extends(VerticalLayout, _super); - function VerticalLayout() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VerticalLayout.prototype.measureReal = function () { - var target = this.$target; - var count = target.numElements; - var numElements = count; - var measuredWidth = 0; - var measuredHeight = 0; - var bounds = egret.$TempRectangle; - for (var i = 0; i < count; i++) { - var layoutElement = (target.getElementAt(i)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - numElements--; - continue; - } - layoutElement.getPreferredBounds(bounds); - measuredHeight += bounds.height; - measuredWidth = Math.max(measuredWidth, bounds.width); - } - measuredHeight += (numElements - 1) * this.$gap; - var hPadding = this.$paddingLeft + this.$paddingRight; - var vPadding = this.$paddingTop + this.$paddingBottom; - target.setMeasuredSize(measuredWidth + hPadding, measuredHeight + vPadding); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VerticalLayout.prototype.measureVirtual = function () { - var target = this.$target; - var typicalHeight = this.$typicalHeight; - var measuredHeight = this.getElementTotalSize(); - var measuredWidth = Math.max(this.maxElementSize, this.$typicalWidth); - var bounds = egret.$TempRectangle; - var endIndex = this.endIndex; - var elementSizeTable = this.elementSizeTable; - for (var index = this.startIndex; index < endIndex; index++) { - var layoutElement = (target.getElementAt(index)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - layoutElement.getPreferredBounds(bounds); - measuredHeight += bounds.height; - measuredHeight -= isNaN(elementSizeTable[index]) ? typicalHeight : elementSizeTable[index]; - measuredWidth = Math.max(measuredWidth, bounds.width); - } - var hPadding = this.$paddingLeft + this.$paddingRight; - var vPadding = this.$paddingTop + this.$paddingBottom; - target.setMeasuredSize(measuredWidth + hPadding, measuredHeight + vPadding); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VerticalLayout.prototype.updateDisplayListReal = function (width, height) { - var target = this.$target; - var paddingL = this.$paddingLeft; - var paddingR = this.$paddingRight; - var paddingT = this.$paddingTop; - var paddingB = this.$paddingBottom; - var gap = this.$gap; - var targetWidth = Math.max(0, width - paddingL - paddingR); - var targetHeight = Math.max(0, height - paddingT - paddingB); - var vJustify = this.$verticalAlign == eui.JustifyAlign.JUSTIFY; - var hJustify = this.$horizontalAlign == eui.JustifyAlign.JUSTIFY || this.$horizontalAlign == eui.JustifyAlign.CONTENT_JUSTIFY; - var hAlign = 0; - if (!hJustify) { - if (this.$horizontalAlign == egret.HorizontalAlign.CENTER) { - hAlign = 0.5; - } - else if (this.$horizontalAlign == egret.HorizontalAlign.RIGHT) { - hAlign = 1; - } - } - var count = target.numElements; - var numElements = count; - var x = paddingL; - var y = paddingT; - var i; - var layoutElement; - var totalPreferredHeight = 0; - var totalPercentHeight = 0; - var childInfoArray = []; - var childInfo; - var heightToDistribute = targetHeight; - var maxElementWidth = this.maxElementSize; - var bounds = egret.$TempRectangle; - for (i = 0; i < count; i++) { - var layoutElement_2 = (target.getElementAt(i)); - if (!egret.is(layoutElement_2, UIComponentClass) || !layoutElement_2.$includeInLayout) { - numElements--; - continue; - } - layoutElement_2.getPreferredBounds(bounds); - maxElementWidth = Math.max(maxElementWidth, bounds.width); - if (vJustify) { - totalPreferredHeight += bounds.height; - } - else { - var values = layoutElement_2.$UIComponent; - if (!isNaN(values[7 /* percentHeight */])) { - totalPercentHeight += values[7 /* percentHeight */]; - childInfo = new eui.sys.ChildInfo(); - childInfo.layoutElement = layoutElement_2; - childInfo.percent = values[7 /* percentHeight */]; - childInfo.min = values[14 /* minHeight */]; - childInfo.max = values[15 /* maxHeight */]; - childInfoArray.push(childInfo); - } - else { - heightToDistribute -= bounds.height; - } - } - } - heightToDistribute -= gap * (numElements - 1); - heightToDistribute = heightToDistribute > 0 ? heightToDistribute : 0; - var excessSpace = targetHeight - totalPreferredHeight - gap * (numElements - 1); - var averageHeight; - var largeChildrenCount = numElements; - var heightDic = {}; - if (vJustify) { - if (excessSpace < 0) { - averageHeight = heightToDistribute / numElements; - for (i = 0; i < count; i++) { - layoutElement = (target.getElementAt(i)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - layoutElement.getPreferredBounds(bounds); - if (bounds.height <= averageHeight) { - heightToDistribute -= bounds.height; - largeChildrenCount--; - continue; - } - } - heightToDistribute = heightToDistribute > 0 ? heightToDistribute : 0; - } - } - else { - if (totalPercentHeight > 0) { - this.flexChildrenProportionally(targetHeight, heightToDistribute, totalPercentHeight, childInfoArray); - var roundOff_2 = 0; - var length_32 = childInfoArray.length; - for (i = 0; i < length_32; i++) { - childInfo = childInfoArray[i]; - var childSize = Math.round(childInfo.size + roundOff_2); - roundOff_2 += childInfo.size - childSize; - heightDic[childInfo.layoutElement.$hashCode] = childSize; - heightToDistribute -= childSize; - } - heightToDistribute = heightToDistribute > 0 ? heightToDistribute : 0; - } - } - if (this.$verticalAlign == egret.VerticalAlign.MIDDLE) { - y = paddingT + heightToDistribute * 0.5; - } - else if (this.$verticalAlign == egret.VerticalAlign.BOTTOM) { - y = paddingT + heightToDistribute; - } - var maxX = paddingL; - var maxY = paddingT; - var dx = 0; - var dy = 0; - var justifyWidth = Math.ceil(targetWidth); - if (this.$horizontalAlign == eui.JustifyAlign.CONTENT_JUSTIFY) - justifyWidth = Math.ceil(Math.max(targetWidth, maxElementWidth)); - var roundOff = 0; - var layoutElementHeight; - var childHeight; - for (i = 0; i < count; i++) { - var exceesWidth = 0; - layoutElement = (target.getElementAt(i)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - layoutElement.getPreferredBounds(bounds); - layoutElementHeight = NaN; - if (vJustify) { - childHeight = NaN; - if (excessSpace > 0) { - childHeight = heightToDistribute * bounds.height / totalPreferredHeight; - } - else if (excessSpace < 0 && bounds.height > averageHeight) { - childHeight = heightToDistribute / largeChildrenCount; - } - if (!isNaN(childHeight)) { - layoutElementHeight = Math.round(childHeight + roundOff); - roundOff += childHeight - layoutElementHeight; - } - } - else { - layoutElementHeight = heightDic[layoutElement.$hashCode]; - } - if (hJustify) { - x = paddingL; - layoutElement.setLayoutBoundsSize(justifyWidth, layoutElementHeight); - layoutElement.getLayoutBounds(bounds); - } - else { - var layoutElementWidth = NaN; - var values = layoutElement.$UIComponent; - if (!isNaN(values[6 /* percentWidth */])) { - var percent = Math.min(100, values[6 /* percentWidth */]); - layoutElementWidth = Math.round(targetWidth * percent * 0.01); - } - layoutElement.setLayoutBoundsSize(layoutElementWidth, layoutElementHeight); - layoutElement.getLayoutBounds(bounds); - exceesWidth = (targetWidth - bounds.width) * hAlign; - exceesWidth = exceesWidth > 0 ? exceesWidth : 0; - x = paddingL + exceesWidth; - } - layoutElement.setLayoutBoundsPosition(Math.round(x), Math.round(y)); - dx = Math.ceil(bounds.width); - dy = Math.ceil(bounds.height); - maxX = Math.max(maxX, x + dx); - maxY = Math.max(maxY, y + dy); - y += dy + gap; - } - this.maxElementSize = maxElementWidth; - target.setContentSize(maxX + paddingR, maxY + paddingB); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VerticalLayout.prototype.updateDisplayListVirtual = function (width, height) { - var target = this.$target; - if (this.indexInViewCalculated) - this.indexInViewCalculated = false; - else - this.getIndexInView(); - var paddingB = this.$paddingBottom; - var paddingL = this.$paddingLeft; - var paddingR = this.$paddingRight; - var gap = this.$gap; - var contentHeight; - var numElements = target.numElements; - if (this.startIndex == -1 || this.endIndex == -1) { - contentHeight = this.getStartPosition(numElements) - gap + paddingB; - target.setContentSize(target.contentWidth, contentHeight); - return; - } - var endIndex = this.endIndex; - target.setVirtualElementIndicesInView(this.startIndex, endIndex); - //获取垂直布局参数 - var justify = this.$horizontalAlign == eui.JustifyAlign.JUSTIFY || this.$horizontalAlign == eui.JustifyAlign.CONTENT_JUSTIFY; - var contentJustify = this.$horizontalAlign == eui.JustifyAlign.CONTENT_JUSTIFY; - var hAlign = 0; - if (!justify) { - if (this.$horizontalAlign == egret.HorizontalAlign.CENTER) { - hAlign = 0.5; - } - else if (this.$horizontalAlign == egret.HorizontalAlign.RIGHT) { - hAlign = 1; - } - } - var bounds = egret.$TempRectangle; - var targetWidth = Math.max(0, width - paddingL - paddingR); - var justifyWidth = Math.ceil(targetWidth); - var layoutElement; - var typicalHeight = this.$typicalHeight; - var typicalWidth = this.$typicalWidth; - var maxElementWidth = this.maxElementSize; - var oldMaxW = Math.max(typicalWidth, this.maxElementSize); - if (contentJustify) { - for (var index = this.startIndex; index <= endIndex; index++) { - layoutElement = (target.getVirtualElementAt(index)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - layoutElement.getPreferredBounds(bounds); - maxElementWidth = Math.max(maxElementWidth, bounds.width); - } - justifyWidth = Math.ceil(Math.max(targetWidth, maxElementWidth)); - } - var x = 0; - var y = 0; - var contentWidth = 0; - var oldElementSize; - var needInvalidateSize = false; - var elementSizeTable = this.elementSizeTable; - //对可见区域进行布局 - for (var i = this.startIndex; i <= endIndex; i++) { - var exceesWidth = 0; - layoutElement = (target.getVirtualElementAt(i)); - if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { - continue; - } - layoutElement.getPreferredBounds(bounds); - if (!contentJustify) { - maxElementWidth = Math.max(maxElementWidth, bounds.width); - } - if (justify) { - x = paddingL; - layoutElement.setLayoutBoundsSize(justifyWidth, NaN); - layoutElement.getLayoutBounds(bounds); - } - else { - layoutElement.getLayoutBounds(bounds); - exceesWidth = (targetWidth - bounds.width) * hAlign; - exceesWidth = exceesWidth > 0 ? exceesWidth : 0; - x = paddingL + exceesWidth; - } - contentWidth = Math.max(contentWidth, bounds.width); - if (!needInvalidateSize) { - oldElementSize = isNaN(elementSizeTable[i]) ? typicalHeight : elementSizeTable[i]; - if (oldElementSize != bounds.height) - needInvalidateSize = true; - } - elementSizeTable[i] = bounds.height; - y = this.getStartPosition(i); - layoutElement.setLayoutBoundsPosition(Math.round(x), Math.round(y)); - } - contentWidth += paddingL + paddingR; - contentHeight = this.getStartPosition(numElements) - gap + paddingB; - this.maxElementSize = maxElementWidth; - target.setContentSize(contentWidth, contentHeight); - if (needInvalidateSize || oldMaxW < this.maxElementSize) { - target.invalidateSize(); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VerticalLayout.prototype.getStartPosition = function (index) { - if (!this.$useVirtualLayout) { - if (this.$target) { - var element = this.$target.getElementAt(index); - if (element) { - return element.y; - } - } - } - var typicalHeight = this.$typicalHeight; - var startPos = this.$paddingTop; - var gap = this.$gap; - var elementSizeTable = this.elementSizeTable; - for (var i = 0; i < index; i++) { - var h = elementSizeTable[i]; - if (isNaN(h)) { - h = typicalHeight; - } - startPos += h + gap; - } - return startPos; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VerticalLayout.prototype.getElementSize = function (index) { - if (this.$useVirtualLayout) { - var size = this.elementSizeTable[index]; - if (isNaN(size)) { - size = this.$typicalHeight; - } - return size; - } - if (this.$target) { - return this.$target.getElementAt(index).height; - } - return 0; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VerticalLayout.prototype.getElementTotalSize = function () { - var typicalHeight = this.$typicalHeight; - var gap = this.$gap; - var totalSize = 0; - var length = this.$target.numElements; - var elementSizeTable = this.elementSizeTable; - for (var i = 0; i < length; i++) { - var h = elementSizeTable[i]; - if (isNaN(h)) { - h = typicalHeight; - } - totalSize += h + gap; - } - totalSize -= gap; - return totalSize; - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VerticalLayout.prototype.elementAdded = function (index) { - if (!this.$useVirtualLayout) - return; - _super.prototype.elementAdded.call(this, index); - this.elementSizeTable.splice(index, 0, this.$typicalHeight); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - VerticalLayout.prototype.getIndexInView = function () { - var target = this.$target; - if (!target || target.numElements == 0) { - this.startIndex = this.endIndex = -1; - return false; - } - var values = target.$UIComponent; - if (values[10 /* width */] == 0 || values[11 /* height */] == 0) { - this.startIndex = this.endIndex = -1; - return false; - } - var numElements = target.numElements; - var contentHeight = this.getStartPosition(numElements - 1) + - this.elementSizeTable[numElements - 1] + this.$paddingBottom; - var minVisibleY = target.scrollV; - if (minVisibleY > contentHeight - this.$paddingBottom) { - this.startIndex = -1; - this.endIndex = -1; - return false; - } - var maxVisibleY = target.scrollV + values[11 /* height */]; - if (maxVisibleY < this.$paddingTop) { - this.startIndex = -1; - this.endIndex = -1; - return false; - } - var oldStartIndex = this.startIndex; - var oldEndIndex = this.endIndex; - this.startIndex = this.findIndexAt(minVisibleY, 0, numElements - 1); - if (this.startIndex == -1) - this.startIndex = 0; - this.endIndex = this.findIndexAt(maxVisibleY, 0, numElements - 1); - if (this.endIndex == -1) - this.endIndex = numElements - 1; - return oldStartIndex != this.startIndex || oldEndIndex != this.endIndex; - }; - return VerticalLayout; - }(eui.LinearLayoutBase)); - eui.VerticalLayout = VerticalLayout; - __reflect(VerticalLayout.prototype, "eui.VerticalLayout"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The HScrollBar (horizontal scrollbar) control lets you control - * the portion of data that is displayed when there is too much data - * to fit horizontally in a display area. - * - *

      Although you can use the HScrollBar control as a stand-alone control, - * you usually combine it as part of another group of components to - * provide scrolling functionality.

      - * - * @includeExample extension/eui/components/HScrollBarExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * HScrollBar(水平 ScrollBar)控件可以在因数据太多而不能在显示区域中以水平方向完全显示时控制显示的数据部分。 - *

      虽然 HScrollBar 控件可以单独使用,但通常将它与其他组件一起使用来提供滚动功能。

      - * - * @includeExample extension/eui/components/HScrollBarExample.ts - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var HScrollBar = (function (_super) { - __extends(HScrollBar, _super); - function HScrollBar() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HScrollBar.prototype.updateDisplayList = function (unscaledWidth, unscaledHeight) { - _super.prototype.updateDisplayList.call(this, unscaledWidth, unscaledHeight); - var thumb = this.thumb; - var viewport = this.$viewport; - if (!thumb || !viewport) { - return; - } - var bounds = egret.$TempRectangle; - thumb.getPreferredBounds(bounds); - var thumbWidth = bounds.width; - var thumbY = bounds.y; - var hsp = viewport.scrollH; - var contentWidth = viewport.contentWidth; - var width = viewport.width; - if (hsp <= 0) { - var scaleWidth = thumbWidth * (1 - (-hsp) / (width * 0.5)); - scaleWidth = Math.max(5, Math.round(scaleWidth)); - thumb.setLayoutBoundsSize(scaleWidth, NaN); - thumb.setLayoutBoundsPosition(0, thumbY); - } - else if (hsp >= contentWidth - width) { - var scaleWidth = thumbWidth * (1 - (hsp - contentWidth + width) / (width * 0.5)); - scaleWidth = Math.max(5, Math.round(scaleWidth)); - thumb.setLayoutBoundsSize(scaleWidth, NaN); - thumb.setLayoutBoundsPosition(unscaledWidth - scaleWidth, thumbY); - } - else { - var thumbX = (unscaledWidth - thumbWidth) * hsp / (contentWidth - width); - thumb.setLayoutBoundsSize(NaN, NaN); - thumb.setLayoutBoundsPosition(thumbX, thumbY); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - HScrollBar.prototype.onPropertyChanged = function (event) { - switch (event.property) { - case "scrollH": - case "contentWidth": - this.invalidateDisplayList(); - break; - } - }; - return HScrollBar; - }(eui.ScrollBarBase)); - eui.HScrollBar = HScrollBar; - __reflect(HScrollBar.prototype, "eui.HScrollBar"); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The operation of adding a state to view. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 视图添加状态显示元素操作 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var AddItems = (function () { - /** - * Constructor. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个AddItems实例 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function AddItems(target, propertyName, position, relativeTo) { - this.target = target; - this.propertyName = propertyName; - this.position = position; - this.relativeTo = relativeTo; - } - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - AddItems.prototype.apply = function (host, parent) { - var index; - var relative = host[this.relativeTo]; - var target = host[this.target]; - var container = this.propertyName ? host[this.propertyName] : parent; - if (!target || !container) - return; - switch (this.position) { - case 0 /* FIRST */: - index = 0; - break; - case 1 /* LAST */: - index = -1; - break; - case 2 /* BEFORE */: - index = container.getChildIndex(relative); - break; - case 3 /* AFTER */: - index = container.getChildIndex(relative) + 1; - break; - } - if (index == -1) { - index = container.numChildren; - } - if (egret.is(container, "eui.Component")) { - container.$Component[8 /* skin */].$elementsContent.push(target); - } - container.addChildAt(target, index); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - AddItems.prototype.remove = function (host, parent) { - var container = this.propertyName ? host[this.propertyName] : parent; - var target = host[this.target]; - if (!target || !container) - return; - if (target.$parent === container) { - container.removeChild(target); - } - if (egret.is(container, "eui.Component")) { - var arr = container.$Component[8 /* skin */].$elementsContent; - var idx = arr.indexOf(target); - if (idx > -1) { - arr.splice(idx, 1); - } - } - }; - return AddItems; - }()); - eui.AddItems = AddItems; - __reflect(AddItems.prototype, "eui.AddItems", ["eui.IOverride"]); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The SetProperty class specifies a property value that is in effect only - * during the parent view state. - * You use this class in the overrides property of the State class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * SetProperty 类指定只在父视图状态期间有效的属性值。可以在 State 类的 overrides 属性中使用该类。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var SetProperty = (function () { - /** - * Constructor. - * - * @param target The object whose property is being set. - * By default, EUI uses the immediate parent of the State object. - * @param name The property to set. - * @param value The value of the property in the view state. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个SetProperty实例。 - * - * @param target 要设置其属性的对象。默认情况下,EUI 使用 State 对象的直接父级。 - * @param name 要设置的属性。 - * @param value 视图状态中的属性值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function SetProperty(target, name, value) { - this.target = target; - this.name = name; - this.value = value; - } - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - SetProperty.prototype.apply = function (host, parent) { - var obj = this.target ? host[this.target] : host; - if (!obj) - return; - this.oldValue = obj[this.name]; - this.setPropertyValue(obj, this.name, this.value, this.oldValue); - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - SetProperty.prototype.remove = function (host, parent) { - var obj = this.target ? host[this.target] : host; - if (!obj) - return; - this.setPropertyValue(obj, this.name, this.oldValue, this.oldValue); - this.oldValue = null; - }; - /** - * @private - * 设置属性值 - */ - SetProperty.prototype.setPropertyValue = function (obj, name, value, valueForType) { - if (value === undefined || value === null) - obj[name] = value; - else if (typeof (valueForType) == "number") - obj[name] = +value; - else if (typeof (valueForType) == "boolean") - obj[name] = this.toBoolean(value); - else - obj[name] = value; - }; - /** - * @private - * 转成Boolean值 - */ - SetProperty.prototype.toBoolean = function (value) { - if (typeof (value) == "string") - return value.toLowerCase() == "true"; - return value != false; - }; - return SetProperty; - }()); - eui.SetProperty = SetProperty; - __reflect(SetProperty.prototype, "eui.SetProperty", ["eui.IOverride"]); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * The SetProperty class specifies a property value that is in effect only - * during the parent view state. - * You use this class in the overrides property of the State class. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * SetProperty 类指定只在父视图状态期间有效的属性值。可以在 State 类的 overrides 属性中使用该类。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - var SetStateProperty = (function () { - /** - * Constructor. - * - * @param target The object whose property is being set. - * By default, EUI uses the immediate parent of the State object. - * @param name The property to set. - * @param value The value of the property in the view state. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个SetProperty实例。 - * - * @param target 要设置其属性的对象。默认情况下,EUI 使用 State 对象的直接父级。 - * @param name 要设置的属性。 - * @param value 视图状态中的属性值。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @language zh_CN - */ - function SetStateProperty(host, templates, chainIndex, target, prop) { - this.host = host; - this.templates = templates; - this.chainIndex = chainIndex; - this.target = target; - this.prop = prop; - } - /** - * @inheritDoc - * - * @version Egret 3.0 - * @version eui 1.0 - * @platform Web,Native - */ - SetStateProperty.prototype.apply = function (host, parent) { - if (!this.target) { - return; - } - var nextOldValue = this.target[this.prop]; - if (this.oldValue) { - this.setPropertyValue(this.target, this.prop, this.oldValue, this.oldValue); - } - if (nextOldValue) { - this.oldValue = nextOldValue; - } - eui.Binding.$bindProperties(this.host, this.templates.concat(), this.chainIndex.concat(), this.target, this.prop); - }; - /** - * @inheritDoc - * - * @version Egret 3.0 - * @version eui 1.0 - * @platform Web,Native - */ - SetStateProperty.prototype.remove = function (host, parent) { - if (!this.target) { - return; - } - var oldValue = this.oldValue; - if (this.target[this.prop]) { - this.oldValue = this.target[this.prop]; - } - if (oldValue) { - this.setPropertyValue(this.target, this.prop, oldValue, oldValue); - } - }; - /** - * @private - * 设置属性值 - */ - SetStateProperty.prototype.setPropertyValue = function (obj, name, value, valueForType) { - if (value === undefined || value === null) - obj[name] = value; - else if (typeof (valueForType) == "number") - obj[name] = +value; - else if (typeof (valueForType) == "boolean") - obj[name] = this.toBoolean(value); - else - obj[name] = value; - }; - /** - * @private - * 转成Boolean值 - */ - SetStateProperty.prototype.toBoolean = function (value) { - if (typeof (value) == "string") - return value.toLowerCase() == "true"; - return value != false; - }; - return SetStateProperty; - }()); - eui.SetStateProperty = SetStateProperty; - __reflect(SetStateProperty.prototype, "eui.SetStateProperty", ["eui.IOverride"]); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var sys; - (function (sys) { - var SOLUTION_TOLERANCE = 0.1; - var MIN_MAX_TOLERANCE = 0.1; - /** - * @private - */ - var MatrixUtil = (function () { - function MatrixUtil() { - } - /** - * @private - */ - MatrixUtil.fitBounds = function (width, height, matrix, explicitWidth, explicitHeight, preferredWidth, preferredHeight, minWidth, minHeight, maxWidth, maxHeight) { - if (isNaN(width) && isNaN(height)) - return egret.Point.create(preferredWidth, preferredHeight); - var newMinWidth = (minWidth < MIN_MAX_TOLERANCE) ? 0 : minWidth - MIN_MAX_TOLERANCE; - var newMinHeight = (minHeight < MIN_MAX_TOLERANCE) ? 0 : minHeight - MIN_MAX_TOLERANCE; - var newMaxWidth = maxWidth + MIN_MAX_TOLERANCE; - var newMaxHeight = maxHeight + MIN_MAX_TOLERANCE; - var actualSize; - if (!isNaN(width) && !isNaN(height)) { - actualSize = calcUBoundsToFitTBounds(width, height, matrix, newMinWidth, newMinHeight, newMaxWidth, newMaxHeight); - if (!actualSize) { - var actualSize1 = void 0; - actualSize1 = fitTBoundsWidth(width, matrix, explicitWidth, explicitHeight, preferredWidth, preferredHeight, newMinWidth, newMinHeight, newMaxWidth, newMaxHeight); - if (actualSize1) { - var fitHeight = transformSize(actualSize1.x, actualSize1.y, matrix).height; - if (fitHeight - SOLUTION_TOLERANCE > height) { - egret.Point.release(actualSize1); - actualSize1 = null; - } - } - var actualSize2 = void 0; - actualSize2 = fitTBoundsHeight(height, matrix, explicitWidth, explicitHeight, preferredWidth, preferredHeight, newMinWidth, newMinHeight, newMaxWidth, newMaxHeight); - if (actualSize2) { - var fitWidth = transformSize(actualSize2.x, actualSize2.y, matrix).width; - if (fitWidth - SOLUTION_TOLERANCE > width) { - egret.Point.release(actualSize2); - actualSize2 = null; - } - } - if (actualSize1 && actualSize2) { - actualSize = ((actualSize1.x * actualSize1.y) > (actualSize2.x * actualSize2.y)) ? actualSize1 : actualSize2; - } - else if (actualSize1) { - actualSize = actualSize1; - } - else { - actualSize = actualSize2; - } - egret.Point.release(actualSize1); - egret.Point.release(actualSize2); - } - return actualSize; - } - else if (!isNaN(width)) { - return fitTBoundsWidth(width, matrix, explicitWidth, explicitHeight, preferredWidth, preferredHeight, newMinWidth, newMinHeight, newMaxWidth, newMaxHeight); - } - else { - return fitTBoundsHeight(height, matrix, explicitWidth, explicitHeight, preferredWidth, preferredHeight, newMinWidth, newMinHeight, newMaxWidth, newMaxHeight); - } - }; - return MatrixUtil; - }()); - sys.MatrixUtil = MatrixUtil; - __reflect(MatrixUtil.prototype, "eui.sys.MatrixUtil"); - /** - * @private - */ - function fitTBoundsWidth(width, matrix, explicitWidth, explicitHeight, preferredWidth, preferredHeight, minWidth, minHeight, maxWidth, maxHeight) { - var actualSize; - if (!isNaN(explicitWidth) && isNaN(explicitHeight)) { - actualSize = calcUBoundsToFitTBoundsWidth(width, matrix, explicitWidth, preferredHeight, explicitWidth, minHeight, explicitWidth, maxHeight); - if (actualSize) - return actualSize; - } - else if (isNaN(explicitWidth) && !isNaN(explicitHeight)) { - actualSize = calcUBoundsToFitTBoundsWidth(width, matrix, preferredWidth, explicitHeight, minWidth, explicitHeight, maxWidth, explicitHeight); - if (actualSize) - return actualSize; - } - actualSize = calcUBoundsToFitTBoundsWidth(width, matrix, preferredWidth, preferredHeight, minWidth, minHeight, maxWidth, maxHeight); - return actualSize; - } - /** - * @private - */ - function fitTBoundsHeight(height, matrix, explicitWidth, explicitHeight, preferredWidth, preferredHeight, minWidth, minHeight, maxWidth, maxHeight) { - var actualSize; - if (!isNaN(explicitWidth) && isNaN(explicitHeight)) { - actualSize = calcUBoundsToFitTBoundsHeight(height, matrix, explicitWidth, preferredHeight, explicitWidth, minHeight, explicitWidth, maxHeight); - if (actualSize) - return actualSize; - } - else if (isNaN(explicitWidth) && !isNaN(explicitHeight)) { - actualSize = calcUBoundsToFitTBoundsHeight(height, matrix, preferredWidth, explicitHeight, minWidth, explicitHeight, maxWidth, explicitHeight); - if (actualSize) - return actualSize; - } - actualSize = calcUBoundsToFitTBoundsHeight(height, matrix, preferredWidth, preferredHeight, minWidth, minHeight, maxWidth, maxHeight); - return actualSize; - } - /** - * @private - */ - function calcUBoundsToFitTBoundsHeight(h, matrix, preferredX, preferredY, minX, minY, maxX, maxY) { - var b = matrix.b; - var d = matrix.d; - if (-1.0e-9 < b && b < +1.0e-9) - b = 0; - if (-1.0e-9 < d && d < +1.0e-9) - d = 0; - if (b == 0 && d == 0) - return null; - if (b == 0 && d == 0) - return null; - if (b == 0) - return egret.Point.create(preferredX, h / Math.abs(d)); - else if (d == 0) - return egret.Point.create(h / Math.abs(b), preferredY); - var d1 = (b * d >= 0) ? d : -d; - var s; - var x; - var y; - if (d1 != 0 && preferredX > 0) { - var invD1 = 1 / d1; - preferredX = Math.max(minX, Math.min(maxX, preferredX)); - x = preferredX; - y = (h - b * x) * invD1; - if (minY <= y && y <= maxY && - b * x + d1 * y >= 0) { - s = egret.Point.create(x, y); - } - y = (-h - b * x) * invD1; - if (minY <= y && y <= maxY && - b * x + d1 * y < 0) { - if (!s || transformSize(s.x, s.y, matrix).width > transformSize(x, y, matrix).width) { - egret.Point.release(s); - s = egret.Point.create(x, y); - } - } - } - if (b != 0 && preferredY > 0) { - var invB = 1 / b; - preferredY = Math.max(minY, Math.min(maxY, preferredY)); - y = preferredY; - x = (h - d1 * y) * invB; - if (minX <= x && x <= maxX && - b * x + d1 * y >= 0) { - if (!s || transformSize(s.x, s.y, matrix).width > transformSize(x, y, matrix).width) - s = egret.Point.create(x, y); - } - x = (-h - d1 * y) * invB; - if (minX <= x && x <= maxX && - b * x + d1 * y < 0) { - if (!s || transformSize(s.x, s.y, matrix).width > transformSize(x, y, matrix).width) { - egret.Point.release(s); - s = egret.Point.create(x, y); - } - } - } - if (s) - return s; - var a = matrix.a; - var c = matrix.c; - var c1 = (a * c >= 0) ? c : -c; - return solveEquation(b, d1, h, minX, minY, maxX, maxY, a, c1); - } - /** - * @private - */ - function calcUBoundsToFitTBoundsWidth(w, matrix, preferredX, preferredY, minX, minY, maxX, maxY) { - var a = matrix.a; - var c = matrix.c; - if (-1.0e-9 < a && a < +1.0e-9) - a = 0; - if (-1.0e-9 < c && c < +1.0e-9) - c = 0; - if (a == 0 && c == 0) - return null; - if (a == 0) - return egret.Point.create(preferredX, w / Math.abs(c)); - else if (c == 0) - return egret.Point.create(w / Math.abs(a), preferredY); - var c1 = (a * c >= 0) ? c : -c; - var s; - var x; - var y; - if (c1 != 0 && preferredX > 0) { - var invC1 = 1 / c1; - preferredX = Math.max(minX, Math.min(maxX, preferredX)); - x = preferredX; - y = (w - a * x) * invC1; - if (minY <= y && y <= maxY && - a * x + c1 * y >= 0) { - s = egret.Point.create(x, y); - } - y = (-w - a * x) * invC1; - if (minY <= y && y <= maxY && - a * x + c1 * y < 0) { - if (!s || transformSize(s.x, s.y, matrix).height > transformSize(x, y, matrix).height) { - egret.Point.release(s); - s = egret.Point.create(x, y); - } - } - } - if (a != 0 && preferredY > 0) { - var invA = 1 / a; - preferredY = Math.max(minY, Math.min(maxY, preferredY)); - y = preferredY; - x = (w - c1 * y) * invA; - if (minX <= x && x <= maxX && - a * x + c1 * y >= 0) { - if (!s || transformSize(s.x, s.y, matrix).height > transformSize(x, y, matrix).height) { - egret.Point.release(s); - s = egret.Point.create(x, y); - } - } - x = (-w - c1 * y) * invA; - if (minX <= x && x <= maxX && - a * x + c1 * y < 0) { - if (!s || transformSize(s.x, s.y, matrix).height > transformSize(x, y, matrix).height) { - egret.Point.release(s); - s = egret.Point.create(x, y); - } - } - } - if (s) - return s; - var b = matrix.b; - var d = matrix.d; - var d1 = (b * d >= 0) ? d : -d; - return solveEquation(a, c1, w, minX, minY, maxX, maxY, b, d1); - } - /** - * @private - */ - function solveEquation(a, c, w, minX, minY, maxX, maxY, b, d) { - if (a == 0 || c == 0) - return null; - var x; - var y; - var A = (w - minX * a) / c; - var B = (w - maxX * a) / c; - var rangeMinY = Math.max(minY, Math.min(A, B)); - var rangeMaxY = Math.min(maxY, Math.max(A, B)); - var det = (b * c - a * d); - if (rangeMinY <= rangeMaxY) { - if (Math.abs(det) < 1.0e-9) { - y = w / (a + c); - } - else { - y = b * w / det; - } - y = Math.max(rangeMinY, Math.min(y, rangeMaxY)); - x = (w - c * y) / a; - return egret.Point.create(x, y); - } - A = -(minX * a + w) / c; - B = -(maxX * a + w) / c; - rangeMinY = Math.max(minY, Math.min(A, B)); - rangeMaxY = Math.min(maxY, Math.max(A, B)); - if (rangeMinY <= rangeMaxY) { - if (Math.abs(det) < 1.0e-9) { - y = -w / (a + c); - } - else { - y = -b * w / det; - } - y = Math.max(rangeMinY, Math.min(y, rangeMaxY)); - x = (-w - c * y) / a; - return egret.Point.create(x, y); - } - return null; - } - /** - * @private - */ - function calcUBoundsToFitTBounds(w, h, matrix, minX, minY, maxX, maxY) { - var a = matrix.a; - var b = matrix.b; - var c = matrix.c; - var d = matrix.d; - if (-1.0e-9 < a && a < +1.0e-9) - a = 0; - if (-1.0e-9 < b && b < +1.0e-9) - b = 0; - if (-1.0e-9 < c && c < +1.0e-9) - c = 0; - if (-1.0e-9 < d && d < +1.0e-9) - d = 0; - if (b == 0 && c == 0) { - if (a == 0 || d == 0) - return null; - return egret.Point.create(w / Math.abs(a), h / Math.abs(d)); - } - if (a == 0 && d == 0) { - if (b == 0 || c == 0) - return null; - return egret.Point.create(h / Math.abs(b), w / Math.abs(c)); - } - var c1 = (a * c >= 0) ? c : -c; - var d1 = (b * d >= 0) ? d : -d; - var det = a * d1 - b * c1; - if (Math.abs(det) < 1.0e-9) { - if (c1 == 0 || a == 0 || a == -c1) - return null; - if (Math.abs(a * h - b * w) > 1.0e-9) - return null; - return solveEquation(a, c1, w, minX, minX, maxX, maxY, b, d1); - } - var invDet = 1 / det; - w *= invDet; - h *= invDet; - var s; - s = solveSystem(a, c1, b, d1, w, h); - if (s && - minX <= s.x && s.x <= maxX && minY <= s.y && s.y <= maxY && - a * s.x + c1 * s.x >= 0 && - b * s.x + d1 * s.y >= 0) - return s; - s = solveSystem(a, c1, b, d1, w, -h); - if (s && - minX <= s.x && s.x <= maxX && minY <= s.y && s.y <= maxY && - a * s.x + c1 * s.x >= 0 && - b * s.x + d1 * s.y < 0) - return s; - s = solveSystem(a, c1, b, d1, -w, h); - if (s && - minX <= s.x && s.x <= maxX && minY <= s.y && s.y <= maxY && - a * s.x + c1 * s.x < 0 && - b * s.x + d1 * s.y >= 0) - return s; - s = solveSystem(a, c1, b, d1, -w, -h); - if (s && - minX <= s.x && s.x <= maxX && minY <= s.y && s.y <= maxY && - a * s.x + c1 * s.x < 0 && - b * s.x + d1 * s.y < 0) - return s; - egret.Point.release(s); - return null; - } - /** - * @private - */ - function transformSize(width, height, matrix) { - var bounds = egret.$TempRectangle.setTo(0, 0, width, height); - matrix.$transformBounds(bounds); - return bounds; - } - /** - * @private - */ - function solveSystem(a, c, b, d, mOverDet, nOverDet) { - return egret.Point.create(d * mOverDet - c * nOverDet, a * nOverDet - b * mOverDet); - } - })(sys = eui.sys || (eui.sys = {})); -})(eui || (eui = {})); diff --git a/demo/libs/modules/eui/eui.min.js b/demo/libs/modules/eui/eui.min.js deleted file mode 100644 index e140177b..00000000 --- a/demo/libs/modules/eui/eui.min.js +++ /dev/null @@ -1,7 +0,0 @@ -var __reflect=this&&this.__reflect||function(t,e,i){t.__class__=e,i?i.push(e):i=[e],t.__types__=t.__types__?i.concat(t.__types__):i},__extends=this&&this.__extends||function(t,e){function i(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);i.prototype=e.prototype,t.prototype=new i},eui;!function(t){var e;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.targetLevel=Number.POSITIVE_INFINITY,e.invalidatePropertiesFlag=!1,e.invalidateClientPropertiesFlag=!1,e.invalidatePropertiesQueue=new i,e.invalidateSizeFlag=!1,e.invalidateClientSizeFlag=!1,e.invalidateSizeQueue=new i,e.invalidateDisplayListFlag=!1,e.invalidateDisplayListQueue=new i,e.eventDisplay=new egret.Bitmap,e.listenersAttached=!1,e}return __extends(e,t),e.prototype.invalidateProperties=function(t){this.invalidatePropertiesFlag||(this.invalidatePropertiesFlag=!0,this.listenersAttached||this.attachListeners()),this.targetLevel<=t.$nestLevel&&(this.invalidateClientPropertiesFlag=!0),this.invalidatePropertiesQueue.insert(t)},e.prototype.validateProperties=function(){for(var t=this.invalidatePropertiesQueue,e=t.shift();e;)e.$stage&&e.validateProperties(),e=t.shift();t.isEmpty()&&(this.invalidatePropertiesFlag=!1)},e.prototype.invalidateSize=function(t){this.invalidateSizeFlag||(this.invalidateSizeFlag=!0,this.listenersAttached||this.attachListeners()),this.targetLevel<=t.$nestLevel&&(this.invalidateClientSizeFlag=!0),this.invalidateSizeQueue.insert(t)},e.prototype.validateSize=function(){for(var t=this.invalidateSizeQueue,e=t.pop();e;)e.$stage&&e.validateSize(),e=t.pop();t.isEmpty()&&(this.invalidateSizeFlag=!1)},e.prototype.invalidateDisplayList=function(t){this.invalidateDisplayListFlag||(this.invalidateDisplayListFlag=!0,this.listenersAttached||this.attachListeners()),this.invalidateDisplayListQueue.insert(t)},e.prototype.validateDisplayList=function(){for(var t=this.invalidateDisplayListQueue,e=t.shift();e;)e.$stage&&e.validateDisplayList(),e=t.shift();t.isEmpty()&&(this.invalidateDisplayListFlag=!1)},e.prototype.attachListeners=function(){this.eventDisplay.addEventListener(egret.Event.ENTER_FRAME,this.doPhasedInstantiationCallBack,this),this.eventDisplay.addEventListener(egret.Event.RENDER,this.doPhasedInstantiationCallBack,this),egret.sys.$invalidateRenderFlag=!0,this.listenersAttached=!0},e.prototype.doPhasedInstantiationCallBack=function(t){this.eventDisplay.removeEventListener(egret.Event.ENTER_FRAME,this.doPhasedInstantiationCallBack,this),this.eventDisplay.removeEventListener(egret.Event.RENDER,this.doPhasedInstantiationCallBack,this),this.doPhasedInstantiation()},e.prototype.doPhasedInstantiation=function(){this.invalidatePropertiesFlag&&this.validateProperties(),this.invalidateSizeFlag&&this.validateSize(),this.invalidateDisplayListFlag&&this.validateDisplayList(),this.invalidatePropertiesFlag||this.invalidateSizeFlag||this.invalidateDisplayListFlag?this.attachListeners():this.listenersAttached=!1},e.prototype.validateClient=function(t){var e,i=!1,n=this.targetLevel;this.targetLevel===Number.POSITIVE_INFINITY&&(this.targetLevel=t.$nestLevel);for(var r=this.invalidatePropertiesQueue,o=this.invalidateSizeQueue,s=this.invalidateDisplayListQueue;!i;){for(i=!0,e=r.removeSmallestChild(t);e;)e.$stage&&e.validateProperties(),e=r.removeSmallestChild(t);for(r.isEmpty()&&(this.invalidatePropertiesFlag=!1),this.invalidateClientPropertiesFlag=!1,e=o.removeLargestChild(t);e;){if(e.$stage&&e.validateSize(),this.invalidateClientPropertiesFlag&&(e=r.removeSmallestChild(t))){r.insert(e),i=!1;break}e=o.removeLargestChild(t)}for(o.isEmpty()&&(this.invalidateSizeFlag=!1),this.invalidateClientPropertiesFlag=!1,this.invalidateClientSizeFlag=!1,e=s.removeSmallestChild(t);e;){if(e.$stage&&e.validateDisplayList(),this.invalidateClientPropertiesFlag&&(e=r.removeSmallestChild(t))){r.insert(e),i=!1;break}if(this.invalidateClientSizeFlag&&(e=o.removeLargestChild(t))){o.insert(e),i=!1;break}e=s.removeSmallestChild(t)}s.isEmpty()&&(this.invalidateDisplayListFlag=!1)}n===Number.POSITIVE_INFINITY&&(this.targetLevel=Number.POSITIVE_INFINITY)},e}(egret.EventDispatcher);t.Validator=e,__reflect(e.prototype,"eui.sys.Validator");var i=function(){function t(){this.depthBins={},this.minDepth=0,this.maxDepth=-1}return t.prototype.insert=function(t){var e=t.$nestLevel;this.maxDepththis.maxDepth&&(this.maxDepth=e));var i=this.depthBins[e];i||(i=this.depthBins[e]=new n),i.insert(t)},t.prototype.pop=function(){var t,e=this.minDepth;if(e<=this.maxDepth){for(var i=this.depthBins[this.maxDepth];!i||0===i.length;){if(this.maxDepth--,this.maxDepthe)return null;i=this.depthBins[this.minDepth]}for(t=i.pop();!(i&&0!=i.length||(this.minDepth++,this.minDepth>e));)i=this.depthBins[this.minDepth]}return t},t.prototype.removeLargestChild=function(t){for(var e=t.$hashCode,i=t.$nestLevel,n=this.maxDepth,r=i;n>=r;){var o=this.depthBins[n];if(o&&o.length>0){if(n===i){if(o.map[e])return o.remove(t),t}else{if(!egret.is(t,"egret.DisplayObjectContainer"))break;for(var s=o.items,a=o.length,h=0;a>h;h++){var l=s[h];if(t.contains(l))return o.remove(l),l}}n--}else if(n==this.maxDepth&&this.maxDepth--,n--,r>n)break}return null},t.prototype.removeSmallestChild=function(t){for(var e=t.$nestLevel,i=e,n=this.maxDepth,r=t.$hashCode;n>=i;){var o=this.depthBins[i];if(o&&o.length>0){if(i===e){if(o.map[r])return o.remove(t),t}else{if(!egret.is(t,"egret.DisplayObjectContainer"))break;for(var s=o.items,a=o.length,h=0;a>h;h++){var l=s[h];if(t.contains(l))return o.remove(l),l}}i++}else if(i==this.minDepth&&this.minDepth++,i++,i>n)break}return null},t.prototype.isEmpty=function(){return this.minDepth>this.maxDepth},t}();__reflect(i.prototype,"DepthQueue");var n=function(){function t(){this.map={},this.items=[],this.length=0}return t.prototype.insert=function(t){var e=t.$hashCode;this.map[e]||(this.map[e]=!0,this.length++,this.items.push(t))},t.prototype.pop=function(){var t=this.items.pop();return t&&(this.length--,0===this.length?this.map={}:this.map[t.$hashCode]=!1),t},t.prototype.remove=function(t){var e=this.items.indexOf(t);e>=0&&(this.items.splice(e,1),this.length--,0===this.length?this.map={}:this.map[t.$hashCode]=!1)},t}();__reflect(n.prototype,"DepthBin")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){function e(t,e,i,n){var r=t.prototype;r.__meta__=r.__meta__||{},r.__meta__[e]=i,n&&(r.__defaultProperty__=e)}t.registerProperty=e}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(t,i){void 0===i&&(i=[]);var n=e.call(this)||this;return n.name=t,n.overrides=i,n}return __extends(i,e),i.prototype.initialize=function(e,i){for(var n=this.overrides,r=n.length,o=0;r>o;o++){var s=n[o];if(s instanceof t.AddItems){var a=e[s.target];a&&a instanceof t.Image&&!a.$parent&&(i.addChild(a),i.removeChild(a))}}},i}(egret.HashObject);t.State=e,__reflect(e.prototype,"eui.State")}(eui||(eui={})),function(t){var e;!function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"states",{get:function(){return this.$stateValues.states},set:function(t){t||(t=[]);var e=this.$stateValues;e.states=t;for(var i={},n=t.length,r=0;n>r;r++){var o=t[r];i[o.name]=o}e.statesMap=i,e.parent&&this.commitCurrentState()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentState",{get:function(){return this.$stateValues.currentState},set:function(t){var e=this.$stateValues;e.explicitState=t,e.currentState=t,this.commitCurrentState()},enumerable:!0,configurable:!0}),t.prototype.commitCurrentState=function(){var t=this.$stateValues;if(t.parent){var e=t.statesMap[t.currentState];if(!e){if(!(t.states.length>0))return;t.currentState=t.states[0].name}if(t.oldState!=t.currentState){var i=t.parent,n=t.statesMap[t.oldState];if(n)for(var r=n.overrides,o=r.length,s=0;o>s;s++)r[s].remove(this,i);if(t.oldState=t.currentState,n=t.statesMap[t.currentState])for(var r=n.overrides,a=r.length,s=0;a>s;s++)r[s].apply(this,i)}}},t.prototype.hasState=function(t){return!!this.$stateValues.statesMap[t]},t.prototype.initializeStates=function(t){this.$stateValues.intialized=!0;for(var e=this.states,i=e.length,n=0;i>n;n++)e[n].initialize(this,t)},t}();t.StateClient=e,__reflect(e.prototype,"eui.sys.StateClient");var i=function(){function t(){this.intialized=!1,this.statesMap={},this.states=[],this.oldState=null,this.explicitState=null,this.currentState=null,this.parent=null,this.stateIsDirty=!1}return t}();t.StateValues=i,__reflect(i.prototype,"eui.sys.StateValues")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){function e(e,i,n){var r=egret.getImplementation("eui.IAssetAdapter");r||(r=new t.DefaultAssetAdapter),r.getAsset(e,function(t){i.call(n,t)},this)}function i(e,i){var n=egret.getImplementation("eui.IThemeAdapter");n||(n=new t.DefaultThemeAdapter),n.getTheme(e,function(t){i(t)},function(t){console.log(t)},this)}t.getAssets=e,t.getTheme=i}(eui||(eui={})),function(t){var e;!function(e){function i(t){return 1===t.a&&0===t.b&&0===t.c&&1===t.d}function n(t,e){if("function"!=typeof t[e])return!1;var i=t[e].toString(),n=i.indexOf("{"),r=i.lastIndexOf("}");return i=i.substring(n+1,r),""==i.trim()}function r(t,e){for(var i in e)"prototype"!=i&&e.hasOwnProperty(i)&&(t[i]=e[i]);for(var r=t.prototype,o=e.prototype,s=Object.keys(o),a=s.length,h=0;a>h;h++){var l=s[h];if("__meta__"!=l&&(!r.hasOwnProperty(l)||n(r,l))){var u=Object.getOwnPropertyDescriptor(o,l);Object.defineProperty(r,l,u)}}}function o(e,i,n){r(e,h);var o=e.prototype;o.$super=i.prototype,t.registerProperty(e,"left","Percentage"),t.registerProperty(e,"right","Percentage"),t.registerProperty(e,"top","Percentage"),t.registerProperty(e,"bottom","Percentage"),t.registerProperty(e,"horizontalCenter","Percentage"),t.registerProperty(e,"verticalCenter","Percentage"),n&&(o.$childAdded=function(t,e){this.invalidateSize(),this.invalidateDisplayList()},o.$childRemoved=function(t,e){this.invalidateSize(),this.invalidateDisplayList()})}var s="eui.UIComponent",a=new e.Validator,h=function(n){function r(){var t=n.call(this)||this;return t.initializeUIValues(),t}return __extends(r,n),r.prototype.initializeUIValues=function(){this.$UIComponent={0:0/0,1:0/0,2:0/0,3:0/0,4:0/0,5:0/0,6:0/0,7:0/0,8:0/0,9:0/0,10:0,11:0,12:0,13:1e5,14:0,15:1e5,16:0,17:0,18:0/0,19:0/0,20:0,21:0,22:0,23:0,24:!0,25:!0,26:!0,27:!1,28:!1,29:!1},this.$includeInLayout=!0,this.$touchEnabled=!0},r.prototype.createChildren=function(){},r.prototype.childrenCreated=function(){},r.prototype.commitProperties=function(){var e=this.$UIComponent;(e[22]!=e[10]||e[23]!=e[11])&&(this.dispatchEventWith(egret.Event.RESIZE),e[22]=e[10],e[23]=e[11]),(e[20]!=this.$getX()||e[21]!=this.$getY())&&(t.UIEvent.dispatchUIEvent(this,t.UIEvent.MOVE),e[20]=this.$getX(),e[21]=this.$getY())},r.prototype.measure=function(){},r.prototype.updateDisplayList=function(t,e){},Object.defineProperty(r.prototype,"includeInLayout",{get:function(){return this.$includeInLayout},set:function(t){t=!!t,this.$includeInLayout!==t&&(this.$includeInLayout=!0,this.invalidateParentLayout(),this.$includeInLayout=t)},enumerable:!0,configurable:!0}),r.prototype.$onAddToStage=function(e,i){this.$super.$onAddToStage.call(this,e,i),this.checkInvalidateFlag();var n=this.$UIComponent;n[29]||(n[29]=!0,this.createChildren(),this.childrenCreated(),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CREATION_COMPLETE))},r.prototype.checkInvalidateFlag=function(t){var e=this.$UIComponent;e[24]&&a.invalidateProperties(this),e[25]&&a.invalidateSize(this),e[26]&&a.invalidateDisplayList(this)},Object.defineProperty(r.prototype,"left",{get:function(){return this.$UIComponent[0]},set:function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[0]!==t&&(e[0]=t,this.invalidateParentLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"right",{get:function(){return this.$UIComponent[1]},set:function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[1]!==t&&(e[1]=t,this.invalidateParentLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"top",{get:function(){return this.$UIComponent[2]},set:function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[2]!==t&&(e[2]=t,this.invalidateParentLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bottom",{get:function(){return this.$UIComponent[3]},set:function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[3]!=t&&(e[3]=t,this.invalidateParentLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"horizontalCenter",{get:function(){return this.$UIComponent[4]},set:function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[4]!==t&&(e[4]=t,this.invalidateParentLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"verticalCenter",{get:function(){return this.$UIComponent[5]},set:function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[5]!==t&&(e[5]=t,this.invalidateParentLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"percentWidth",{get:function(){return this.$UIComponent[6]},set:function(t){t=+t;var e=this.$UIComponent;e[6]!==t&&(e[6]=t,this.invalidateParentLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"percentHeight",{get:function(){return this.$UIComponent[7]},set:function(t){t=+t;var e=this.$UIComponent;e[7]!==t&&(e[7]=t,this.invalidateParentLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"explicitWidth",{get:function(){return this.$UIComponent[8]},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"explicitHeight",{get:function(){return this.$UIComponent[9]},enumerable:!0,configurable:!0}),r.prototype.$getWidth=function(){return this.validateSizeNow(),this.$UIComponent[10]},r.prototype.$setWidth=function(t){t=+t;var e=this.$UIComponent;return 0>t||e[10]===t&&e[8]===t?!1:(e[8]=t,isNaN(t)&&this.invalidateSize(),this.invalidateProperties(),this.invalidateDisplayList(),this.invalidateParentLayout(),!0)},r.prototype.validateSizeNow=function(){this.validateSize(!0),this.updateFinalSize()},r.prototype.$getHeight=function(){return this.validateSizeNow(),this.$UIComponent[11]},r.prototype.$setHeight=function(t){t=+t;var e=this.$UIComponent;return 0>t||e[11]===t&&e[9]===t?!1:(e[9]=t,isNaN(t)&&this.invalidateSize(),this.invalidateProperties(),this.invalidateDisplayList(),this.invalidateParentLayout(),!0)},Object.defineProperty(r.prototype,"minWidth",{get:function(){return this.$UIComponent[12]},set:function(t){t=+t||0;var e=this.$UIComponent;0>t||e[12]===t||(e[12]=t,this.invalidateSize(),this.invalidateParentLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"maxWidth",{get:function(){return this.$UIComponent[13]},set:function(t){t=+t||0;var e=this.$UIComponent;0>t||e[13]===t||(e[13]=t,this.invalidateSize(),this.invalidateParentLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"minHeight",{get:function(){return this.$UIComponent[14]},set:function(t){t=+t||0;var e=this.$UIComponent;0>t||e[14]===t||(e[14]=t,this.invalidateSize(),this.invalidateParentLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"maxHeight",{get:function(){return this.$UIComponent[15]},set:function(t){t=+t||0;var e=this.$UIComponent;0>t||e[15]===t||(e[15]=t,this.invalidateSize(),this.invalidateParentLayout())},enumerable:!0,configurable:!0}),r.prototype.setMeasuredSize=function(t,e){var i=this.$UIComponent;i[16]=Math.ceil(+t||0),i[17]=Math.ceil(+e||0)},r.prototype.setActualSize=function(t,e){var i=!1,n=this.$UIComponent;n[10]!==t&&(n[10]=t,i=!0),n[11]!==e&&(n[11]=e,i=!0),i&&(this.invalidateDisplayList(),this.dispatchEventWith(egret.Event.RESIZE))},r.prototype.$updateUseTransform=function(){this.$super.$updateUseTransform.call(this),this.invalidateParentLayout()},r.prototype.$setMatrix=function(t,e){return void 0===e&&(e=!0),this.$super.$setMatrix.call(this,t,e),this.invalidateParentLayout(),!0},r.prototype.$setAnchorOffsetX=function(t){return this.$super.$setAnchorOffsetX.call(this,t),this.invalidateParentLayout(),!0},r.prototype.$setAnchorOffsetY=function(t){return this.$super.$setAnchorOffsetY.call(this,t),this.invalidateParentLayout(),!0},r.prototype.$setX=function(t){var e=this.$super.$setX.call(this,t);return e&&(this.invalidateParentLayout(),this.invalidateProperties()),e},r.prototype.$setY=function(t){var e=this.$super.$setY.call(this,t);return e&&(this.invalidateParentLayout(),this.invalidateProperties()),e},r.prototype.invalidateProperties=function(){var t=this.$UIComponent;t[24]||(t[24]=!0,this.$stage&&a.invalidateProperties(this))},r.prototype.validateProperties=function(){var t=this.$UIComponent;t[24]&&(this.commitProperties(),t[24]=!1)},r.prototype.invalidateSize=function(){var t=this.$UIComponent;t[25]||(t[25]=!0,this.$stage&&a.invalidateSize(this))},r.prototype.validateSize=function(t){if(t){var e=this.$children;if(e)for(var i=e.length,n=0;i>n;n++){var r=e[n];egret.is(r,s)&&r.validateSize(!0)}}var o=this.$UIComponent;if(o[25]){var a=this.measureSizes();a&&(this.invalidateDisplayList(),this.invalidateParentLayout()),o[25]=!1}},r.prototype.measureSizes=function(){var t=!1,e=this.$UIComponent;if(!e[25])return t;(isNaN(e[8])||isNaN(e[9]))&&(this.measure(),e[16]e[13]&&(e[16]=e[13]),e[17]e[15]&&(e[17]=e[15]));var i=this.getPreferredUWidth(),n=this.getPreferredUHeight();return(i!==e[18]||n!==e[19])&&(e[18]=i,e[19]=n,t=!0),t},r.prototype.invalidateDisplayList=function(){var t=this.$UIComponent;t[26]||(t[26]=!0,this.$stage&&a.invalidateDisplayList(this))},r.prototype.validateDisplayList=function(){var t=this.$UIComponent;t[26]&&(this.updateFinalSize(),this.updateDisplayList(t[10],t[11]),t[26]=!1)},r.prototype.updateFinalSize=function(){var t=0,e=0,i=this.$UIComponent;t=i[27]?i[10]:isNaN(i[8])?i[16]:i[8],e=i[28]?i[11]:isNaN(i[9])?i[17]:i[9],this.setActualSize(t,e)},r.prototype.validateNow=function(){this.$stage&&a.validateClient(this)},r.prototype.invalidateParentLayout=function(){var t=this.$parent;t&&this.$includeInLayout&&egret.is(t,s)&&(t.invalidateSize(),t.invalidateDisplayList())},r.prototype.setLayoutBoundsSize=function(t,n){if(n=+n,t=+t,!(0>n||0>t)){var r,o,s=this.$UIComponent,a=s[13],h=s[15],l=Math.min(s[12],a),u=Math.min(s[14],h);isNaN(t)?(s[27]=!1,r=this.getPreferredUWidth()):(s[27]=!0,r=Math.max(l,Math.min(a,t))),isNaN(n)?(s[28]=!1,o=this.getPreferredUHeight()):(s[28]=!0,o=Math.max(u,Math.min(h,n)));var p=this.getAnchorMatrix();if(i(p))return void this.setActualSize(r,o);var c=e.MatrixUtil.fitBounds(t,n,p,s[8],s[9],this.getPreferredUWidth(),this.getPreferredUHeight(),l,u,a,h);c||(c=egret.Point.create(l,u)),this.setActualSize(c.x,c.y),egret.Point.release(c)}},r.prototype.setLayoutBoundsPosition=function(e,n){var r=this.$getMatrix();if(!i(r)||0!=this.anchorOffsetX||0!=this.anchorOffsetY){var o=egret.$TempRectangle;this.getLayoutBounds(o),e+=this.$getX()-o.x,n+=this.$getY()-o.y}var s=this.$super.$setX.call(this,e);(this.$super.$setY.call(this,n)||s)&&t.UIEvent.dispatchUIEvent(this,t.UIEvent.MOVE)},r.prototype.getLayoutBounds=function(t){var e,i=this.$UIComponent;e=i[27]?i[10]:isNaN(i[8])?i[16]:i[8];var n;n=i[28]?i[11]:isNaN(i[9])?i[17]:i[9],this.applyMatrix(t,e,n)},r.prototype.getPreferredUWidth=function(){var t=this.$UIComponent;return isNaN(t[8])?t[16]:t[8]},r.prototype.getPreferredUHeight=function(){var t=this.$UIComponent;return isNaN(t[9])?t[17]:t[9]},r.prototype.getPreferredBounds=function(t){var e=this.getPreferredUWidth(),i=this.getPreferredUHeight();this.applyMatrix(t,e,i)},r.prototype.applyMatrix=function(t,e,n){t.setTo(0,0,e,n);var r=this.getAnchorMatrix();i(r)?(t.x+=r.tx,t.y+=r.ty):r.$transformBounds(t)},r.prototype.getAnchorMatrix=function(){var t=this.$getMatrix(),e=this.anchorOffsetX,i=this.anchorOffsetY;if(0!=e||0!=i){var n=egret.$TempMatrix;return t.$preMultiplyInto(n.setTo(1,0,0,1,-e,-i),n),n}return t},r}(egret.DisplayObject);e.UIComponentImpl=h,__reflect(h.prototype,"eui.sys.UIComponentImpl",["eui.UIComponent","egret.DisplayObject"]),e.mixin=r,e.implementUIComponent=o}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.$layout=null,i.$stateValues=new t.sys.StateValues,i.initializeUIValues(),i.$Group={0:0,1:0,2:0,3:0,4:!1,5:!1},i.$stateValues.parent=i,i}return __extends(i,e),Object.defineProperty(i.prototype,"elementsContent",{set:function(t){if(t)for(var e=t.length,i=0;e>i;i++)this.addChild(t[i])},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"layout",{get:function(){return this.$layout},set:function(t){this.$setLayout(t)},enumerable:!0,configurable:!0}),i.prototype.$setLayout=function(t){return this.$layout==t?!1:(this.$layout&&(this.$layout.target=null),this.$layout=t,t&&(t.target=this),this.invalidateSize(),this.invalidateDisplayList(),!0)},Object.defineProperty(i.prototype,"contentWidth",{get:function(){return this.$Group[0]},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"contentHeight",{get:function(){return this.$Group[1]},enumerable:!0,configurable:!0}),i.prototype.setContentSize=function(e,i){e=Math.ceil(+e||0),i=Math.ceil(+i||0);var n=this.$Group,r=n[0]!==e,o=n[1]!==i;(r||o)&&(n[0]=e,n[1]=i,r&&t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"contentWidth"),o&&t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"contentHeight"))},Object.defineProperty(i.prototype,"scrollEnabled",{get:function(){return this.$Group[4]},set:function(t){t=!!t;var e=this.$Group;t!==e[4]&&(e[4]=t,this.updateScrollRect())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scrollH",{get:function(){return this.$Group[2]},set:function(e){e=+e||0;var i=this.$Group;e!==i[2]&&(i[2]=e,this.updateScrollRect()&&this.$layout&&this.$layout.scrollPositionChanged(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"scrollH"))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scrollV",{get:function(){return this.$Group[3]},set:function(e){e=+e||0;var i=this.$Group;e!=i[3]&&(i[3]=e,this.updateScrollRect()&&this.$layout&&this.$layout.scrollPositionChanged(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"scrollV"))},enumerable:!0,configurable:!0}),i.prototype.updateScrollRect=function(){var t=this.$Group,e=t[4];if(e){var i=this.$UIComponent;this.scrollRect=egret.$TempRectangle.setTo(t[2],t[3],i[10],i[11])}else this.$scrollRect&&(this.scrollRect=null);return e},Object.defineProperty(i.prototype,"numElements",{get:function(){return this.$children.length},enumerable:!0,configurable:!0}),i.prototype.getElementAt=function(t){return this.$children[t]},i.prototype.getVirtualElementAt=function(t){return this.getElementAt(t)},i.prototype.setVirtualElementIndicesInView=function(t,e){},Object.defineProperty(i.prototype,"touchThrough",{get:function(){return this.$Group[5]},set:function(t){this.$Group[5]=!!t},enumerable:!0,configurable:!0}),i.prototype.$hitTest=function(t,i){var n=e.prototype.$hitTest.call(this,t,i);if(n||this.$Group[5])return n;if(!this.$visible||!this.touchEnabled||0===this.scaleX||0===this.scaleY||0===this.width||0===this.height)return null;var r=this.globalToLocal(t,i,egret.$TempPoint),o=this.$UIComponent,s=egret.$TempRectangle.setTo(0,0,o[10],o[11]),a=this.$scrollRect;return a&&(s.x=a.x,s.y=a.y),s.contains(r.x,r.y)?this:null},i.prototype.invalidateState=function(){var t=this.$stateValues;t.stateIsDirty||(t.stateIsDirty=!0,this.invalidateProperties())},i.prototype.getCurrentState=function(){return""},i.prototype.createChildren=function(){this.$layout||this.$setLayout(new t.BasicLayout),this.initializeStates(this.$stage)},i.prototype.childrenCreated=function(){},i.prototype.commitProperties=function(){t.sys.UIComponentImpl.prototype.commitProperties.call(this);var e=this.$stateValues;e.stateIsDirty&&(e.stateIsDirty=!1,e.explicitState||(e.currentState=this.getCurrentState(),this.commitCurrentState()))},i.prototype.measure=function(){return this.$layout?void this.$layout.measure():void this.setMeasuredSize(0,0)},i.prototype.updateDisplayList=function(t,e){this.$layout&&this.$layout.updateDisplayList(t,e),this.updateScrollRect()},i.prototype.invalidateParentLayout=function(){},i.prototype.setMeasuredSize=function(t,e){},i.prototype.invalidateProperties=function(){},i.prototype.validateProperties=function(){},i.prototype.invalidateSize=function(){},i.prototype.validateSize=function(t){},i.prototype.invalidateDisplayList=function(){},i.prototype.validateDisplayList=function(){},i.prototype.validateNow=function(){},i.prototype.setLayoutBoundsSize=function(t,e){},i.prototype.setLayoutBoundsPosition=function(t,e){},i.prototype.getLayoutBounds=function(t){},i.prototype.getPreferredBounds=function(t){},i}(egret.DisplayObjectContainer);t.Group=e,__reflect(e.prototype,"eui.Group",["eui.IViewport","eui.UIComponent","egret.DisplayObject"]),t.sys.implementUIComponent(e,egret.DisplayObjectContainer,!0),t.sys.mixin(e,t.sys.StateClient),t.registerProperty(e,"elementsContent","Array",!0),t.registerProperty(e,"states","State[]")}(eui||(eui={}));var eui;!function(t){function e(t,e){if(t.hasOwnProperty(i))t[i].push(e);else{var n=[e];t[i]&&(n=t[i].concat(n)),t[i]=n}}var i="__bindables__";t.registerBindable=e}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.initializeUIValues(),t.$Component={0:null,1:null,2:"",3:!0,4:!1,5:!1,6:!0,7:!0,8:null},t.$touchEnabled=!0,t}return __extends(i,e),Object.defineProperty(i.prototype,"hostComponentKey",{get:function(){return this.$Component[0]},set:function(t){this.$Component[0]=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skinName",{get:function(){return this.$Component[1]},set:function(t){var e=this.$Component;if(e[5]=!0,e[1]!=t){if(t)e[1]=t;else{var i=egret.getImplementation("eui.Theme");if(i){var n=i.getSkinName(this);n&&(e[1]=n)}}this.$parseSkinName()}},enumerable:!0,configurable:!0}),i.prototype.$parseSkinName=function(){var t,e=this.skinName;if(e)if(e.prototype)t=new e;else if("string"==typeof e){var i=void 0,n=e.trim();if("<"==n.charAt(0))i=EXML.parse(n);else if(i=egret.getDefinitionByName(e),!i&&-1!=n.toLowerCase().indexOf(".exml"))return void EXML.load(e,this.onExmlLoaded,this,!0);i&&(t=new i)}else t=e;this.setSkin(t)},i.prototype.onExmlLoaded=function(t,e){if(this.skinName==e){var i=new t;this.setSkin(i)}},Object.defineProperty(i.prototype,"skin",{get:function(){return this.$Component[8]},enumerable:!0,configurable:!0}),i.prototype.setSkin=function(e){!e||e instanceof t.Skin||(e=null);var i=this.$Component,n=i[8];if(n){for(var r=n.skinParts,o=r.length,s=0;o>s;s++){var a=r[s];this[a]&&this.setSkinPart(a,null)}var h=n.$elementsContent;if(h){o=h.length;for(var s=0;o>s;s++){var l=h[s];l.$parent==this&&this.removeChild(l)}}n.hostComponent=null}if(i[8]=e,e){for(var r=e.skinParts,u=r.length,s=0;u>s;s++){var a=r[s],p=e[a];p&&this.setSkinPart(a,p)}var h=e.$elementsContent;if(h)for(var s=h.length-1;s>=0;s--)this.addChildAt(h[s],0);e.hostComponent=this}this.invalidateSize(),this.invalidateDisplayList(),this.dispatchEventWith(egret.Event.COMPLETE)},i.prototype.setSkinPart=function(t,e){var i=this[t];i&&this.partRemoved(t,i),this[t]=e,e&&this.partAdded(t,e)},i.prototype.partAdded=function(t,e){},i.prototype.partRemoved=function(t,e){},i.prototype.$setTouchChildren=function(t){t=!!t;var i=this.$Component;return i[6]=t,i[3]?(i[6]=t,e.prototype.$setTouchChildren.call(this,t)):!0},i.prototype.$setTouchEnabled=function(t){t=!!t;var i=this.$Component;i[7]=t,i[3]&&e.prototype.$setTouchEnabled.call(this,t)},Object.defineProperty(i.prototype,"enabled",{get:function(){return this.$Component[3]},set:function(t){t=!!t,this.$setEnabled(t)},enumerable:!0,configurable:!0}),i.prototype.$setEnabled=function(t){var e=this.$Component;return t===e[3]?!1:(e[3]=t,t?(this.$touchEnabled=e[7],this.$touchChildren=e[6]):(this.$touchEnabled=!1,this.$touchChildren=!1),this.invalidateState(),!0)},Object.defineProperty(i.prototype,"currentState",{get:function(){var t=this.$Component;return t[2]?t[2]:this.getCurrentState()},set:function(t){var e=this.$Component;t!=e[2]&&(e[2]=t,this.invalidateState())},enumerable:!0,configurable:!0}),i.prototype.invalidateState=function(){var t=this.$Component;t[4]||(t[4]=!0,this.invalidateProperties())},i.prototype.getCurrentState=function(){return""},i.prototype.createChildren=function(){var t=this.$Component;if(!t[1]){var e=egret.getImplementation("eui.Theme");if(e){var i=e.getSkinName(this);i&&(t[1]=i,this.$parseSkinName())}}},i.prototype.childrenCreated=function(){},i.prototype.commitProperties=function(){t.sys.UIComponentImpl.prototype.commitProperties.call(this);var e=this.$Component;e[4]&&(e[4]=!1,e[8]&&(e[8].currentState=this.currentState))},i.prototype.measure=function(){t.sys.measure(this);var e=this.$Component[8];if(e){var i=this.$UIComponent;isNaN(e.width)?(i[16]e.maxWidth&&(i[16]=e.maxWidth)):i[16]=e.width,isNaN(e.height)?(i[17]e.maxHeight&&(i[17]=e.maxHeight)):i[17]=e.height}},i.prototype.updateDisplayList=function(e,i){t.sys.updateDisplayList(this,e,i)},i.prototype.invalidateParentLayout=function(){},i.prototype.setMeasuredSize=function(t,e){},i.prototype.invalidateProperties=function(){},i.prototype.validateProperties=function(){},i.prototype.invalidateSize=function(){},i.prototype.validateSize=function(t){},i.prototype.invalidateDisplayList=function(){},i.prototype.validateDisplayList=function(){},i.prototype.validateNow=function(){},i.prototype.setLayoutBoundsSize=function(t,e){},i.prototype.setLayoutBoundsPosition=function(t,e){},i.prototype.getLayoutBounds=function(t){},i.prototype.getPreferredBounds=function(t){},i}(egret.DisplayObjectContainer);t.Component=e,__reflect(e.prototype,"eui.Component",["eui.UIComponent","egret.DisplayObject"]),t.registerProperty(e,"skinName","Class"),t.sys.implementUIComponent(e,egret.DisplayObjectContainer,!0)}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.$dataProviderChanged=!1,t.$dataProvider=null,t.$indexToRenderer=[],t.$DataGroup={0:!0,1:!1,2:{},3:{},4:!1,5:!1,6:null,7:null,8:!1,9:null,10:!1,11:!1,12:null,13:null,14:!1},t}return __extends(i,e),Object.defineProperty(i.prototype,"useVirtualLayout",{get:function(){return this.$layout?this.$layout.$useVirtualLayout:this.$DataGroup[0]},set:function(t){t=!!t;var e=this.$DataGroup;t!==e[0]&&(e[0]=t,this.$layout&&(this.$layout.useVirtualLayout=t))},enumerable:!0,configurable:!0}),i.prototype.$setLayout=function(t){if(t==this.$layout)return!1;this.$layout&&(this.$layout.setTypicalSize(0,0),this.$layout.removeEventListener("useVirtualLayoutChanged",this.onUseVirtualLayoutChanged,this)),this.$layout&&t&&this.$layout.$useVirtualLayout!=t.$useVirtualLayout&&this.onUseVirtualLayoutChanged();var i=e.prototype.$setLayout.call(this,t);if(t){var n=this.$DataGroup[9];n&&t.setTypicalSize(n.width,n.height),t.useVirtualLayout=this.$DataGroup[0],t.addEventListener("useVirtualLayoutChanged",this.onUseVirtualLayoutChanged,this)}return i},i.prototype.onUseVirtualLayoutChanged=function(t){var e=this.$DataGroup;e[1]=!0,e[10]=!0,this.removeDataProviderListener(),this.invalidateProperties()},i.prototype.setVirtualElementIndicesInView=function(t,e){if(this.$layout&&this.$layout.$useVirtualLayout)for(var i=this.$indexToRenderer,n=Object.keys(i),r=n.length,o=0;r>o;o++){var s=+n[o]; -(t>s||s>e)&&this.freeRendererByIndex(s)}},i.prototype.getElementAt=function(t){return this.$indexToRenderer[t]},i.prototype.getVirtualElementAt=function(t){if(t=0|+t,0>t||t>=this.$dataProvider.length)return null;var e=this.$indexToRenderer[t];if(!e){var i=this.$dataProvider.getItemAt(t);e=this.createVirtualRenderer(i),this.$indexToRenderer[t]=e,this.updateRenderer(e,t,i);var n=this.$DataGroup;n[4]&&(e.validateNow(),n[4]=!1,this.rendererAdded(e,t,i))}return e},i.prototype.freeRendererByIndex=function(t){var e=this.$indexToRenderer[t];e&&(delete this.$indexToRenderer[t],this.doFreeRenderer(e))},i.prototype.doFreeRenderer=function(t){var e=this.$DataGroup,i=e[2][t.$hashCode],n=i.$hashCode;e[3][n]||(e[3][n]=[]),e[3][n].push(t),t.visible=!1},i.prototype.invalidateSize=function(){this.$DataGroup[4]||e.prototype.invalidateSize.call(this)},i.prototype.createVirtualRenderer=function(t){var e,i=this.itemToRendererClass(t),n=i.$hashCode,r=this.$DataGroup,o=r[3];return o[n]&&o[n].length>0?(e=o[n].pop(),e.visible=!0,this.invalidateDisplayList(),e):(r[4]=!0,this.createOneRenderer(i))},i.prototype.createOneRenderer=function(t){var e=new t,i=this.$DataGroup;return i[2][e.$hashCode]=t,egret.is(e,"eui.IItemRenderer")?(i[13]&&this.setItemRenderSkinName(e,i[13]),this.addChild(e),e):null},i.prototype.setItemRenderSkinName=function(e,i){if(e&&e instanceof t.Component){var n=e;n.$Component[5]||(n.skinName=i,n.$Component[5]=!1)}},Object.defineProperty(i.prototype,"dataProvider",{get:function(){return this.$dataProvider},set:function(t){this.$setDataProvider(t)},enumerable:!0,configurable:!0}),i.prototype.$setDataProvider=function(t){return this.$dataProvider==t||t&&!t.getItemAt?!1:(this.removeDataProviderListener(),this.$dataProvider=t,this.$dataProviderChanged=!0,this.$DataGroup[10]=!0,this.invalidateProperties(),this.invalidateSize(),this.invalidateDisplayList(),!0)},i.prototype.removeDataProviderListener=function(){this.$dataProvider&&this.$dataProvider.removeEventListener(t.CollectionEvent.COLLECTION_CHANGE,this.onCollectionChange,this)},i.prototype.onCollectionChange=function(e){switch(e.kind){case t.CollectionEventKind.ADD:this.itemAddedHandler(e.items,e.location);break;case t.CollectionEventKind.REMOVE:this.itemRemovedHandler(e.items,e.location);break;case t.CollectionEventKind.UPDATE:case t.CollectionEventKind.REPLACE:this.itemUpdatedHandler(e.items[0],e.location);break;case t.CollectionEventKind.RESET:case t.CollectionEventKind.REFRESH:if(this.$layout&&this.$layout.$useVirtualLayout)for(var i=this.$indexToRenderer,n=Object.keys(i),r=n.length,o=r-1;o>=0;o--){var s=+n[o];this.freeRendererByIndex(s)}this.$dataProviderChanged=!0,this.invalidateProperties();break;default:egret.$warn(2204,e.kind)}this.invalidateSize(),this.invalidateDisplayList()},i.prototype.itemAddedHandler=function(t,e){for(var i=t.length,n=0;i>n;n++)this.itemAdded(t[n],e+n);this.resetRenderersIndices()},i.prototype.itemRemovedHandler=function(t,e){for(var i=t.length,n=i-1;n>=0;n--)this.itemRemoved(t[n],e+n);this.resetRenderersIndices()},i.prototype.itemAdded=function(t,e){if(this.$layout&&this.$layout.elementAdded(e),this.$layout&&this.$layout.$useVirtualLayout)return void this.$indexToRenderer.splice(e,0,null);var i=this.createVirtualRenderer(t);if(this.$indexToRenderer.splice(e,0,i),i){this.updateRenderer(i,e,t);var n=this.$DataGroup;n[4]&&(n[4]=!1,this.rendererAdded(i,e,t))}},i.prototype.itemRemoved=function(t,e){this.$layout&&this.$layout.elementRemoved(e);var i=this.$indexToRenderer[e];this.$indexToRenderer.length>e&&this.$indexToRenderer.splice(e,1),i&&(this.$layout&&this.$layout.$useVirtualLayout?this.doFreeRenderer(i):(this.rendererRemoved(i,e,t),this.removeChild(i)))},i.prototype.resetRenderersIndices=function(){var t=this.$indexToRenderer;if(0!=t.length)if(this.$layout&&this.$layout.$useVirtualLayout)for(var e=Object.keys(t),i=e.length,n=0;i>n;n++){var r=+e[n];this.resetRendererItemIndex(r)}else for(var o=t.length,r=0;o>r;r++)this.resetRendererItemIndex(r)},i.prototype.itemUpdatedHandler=function(t,e){if(!this.$DataGroup[11]){var i=this.$indexToRenderer[e];i&&this.updateRenderer(i,e,t)}},i.prototype.resetRendererItemIndex=function(t){var e=this.$indexToRenderer[t];e&&(e.itemIndex=t)},Object.defineProperty(i.prototype,"itemRenderer",{get:function(){return this.$DataGroup[6]},set:function(t){var e=this.$DataGroup;e[6]!=t&&(e[6]=t,e[5]=!0,e[8]=!0,e[10]=!0,this.removeDataProviderListener(),this.invalidateProperties())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"itemRendererSkinName",{get:function(){return this.$DataGroup[13]},set:function(t){var e=this.$DataGroup;e[13]!=t&&(e[13]=t,this.$UIComponent[29]&&(e[14]=!0,this.invalidateProperties()))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"itemRendererFunction",{get:function(){return this.$DataGroup[7]},set:function(t){var e=this.$DataGroup;e[7]!=t&&(e[7]=t,e[5]=!0,e[8]=!0,this.removeDataProviderListener(),this.invalidateProperties())},enumerable:!0,configurable:!0}),i.prototype.itemToRendererClass=function(e){var i,n=this.$DataGroup;return n[7]&&(i=n[7](e)),i||(i=n[6]),i||(i=t.ItemRenderer),i.$hashCode||(i.$hashCode=egret.$hashCount++),i},i.prototype.createChildren=function(){if(!this.$layout){var i=new t.VerticalLayout;i.gap=0,i.horizontalAlign=t.JustifyAlign.CONTENT_JUSTIFY,this.$setLayout(i)}e.prototype.createChildren.call(this)},i.prototype.commitProperties=function(){var i=this.$DataGroup;if((i[5]||this.$dataProviderChanged||i[1])&&(this.removeAllRenderers(),this.$layout&&this.$layout.clearVirtualLayoutCache(),this.setTypicalLayoutRect(null),i[1]=!1,i[5]=!1,this.$dataProvider&&this.$dataProvider.addEventListener(t.CollectionEvent.COLLECTION_CHANGE,this.onCollectionChange,this),this.$layout&&this.$layout.$useVirtualLayout?(this.invalidateSize(),this.invalidateDisplayList()):this.createRenderers(),this.$dataProviderChanged&&(this.$dataProviderChanged=!1,this.scrollV=this.scrollH=0)),e.prototype.commitProperties.call(this),i[8]&&(i[8]=!1,this.$dataProvider&&this.$dataProvider.length>0&&(i[12]=this.$dataProvider.getItemAt(0),this.measureRendererSize())),i[14]){i[14]=!1;for(var n=i[13],r=this.$indexToRenderer,o=Object.keys(r),s=o.length,a=0;s>a;a++){var h=o[a];this.setItemRenderSkinName(r[h],n)}var l=i[3];o=Object.keys(l),s=o.length;for(var a=0;s>a;a++)for(var u=o[a],p=l[u],c=p.length,d=0;c>d;d++)this.setItemRenderSkinName(p[d],n)}},i.prototype.measure=function(){this.$layout&&this.$layout.$useVirtualLayout&&this.ensureTypicalLayoutElement(),e.prototype.measure.call(this)},i.prototype.updateDisplayList=function(t,i){var n=this.$layout&&this.$layout.$useVirtualLayout;n&&this.ensureTypicalLayoutElement(),e.prototype.updateDisplayList.call(this,t,i);var r=this.$DataGroup;if(n){var o=r[9];if(o){var s=this.$indexToRenderer[0];if(s){var a=egret.$TempRectangle;s.getPreferredBounds(a),(a.width!=o.width||a.height!=o.height)&&(r[9]=null)}}}},i.prototype.ensureTypicalLayoutElement=function(){this.$DataGroup[9]||this.$dataProvider&&this.$dataProvider.length>0&&(this.$DataGroup[12]=this.$dataProvider.getItemAt(0),this.measureRendererSize())},i.prototype.measureRendererSize=function(){var t=this.$DataGroup;if(void 0==t[12])return void this.setTypicalLayoutRect(null);var e=this.createVirtualRenderer(t[12]);if(!e)return void this.setTypicalLayoutRect(null);this.updateRenderer(e,0,t[12]),e.validateNow();var i=egret.$TempRectangle;e.getPreferredBounds(i);var n=new egret.Rectangle(0,0,i.width,i.height);this.$layout&&this.$layout.$useVirtualLayout?(t[4]&&this.rendererAdded(e,0,t[12]),this.doFreeRenderer(e)):this.removeChild(e),this.setTypicalLayoutRect(n),t[4]=!1},i.prototype.setTypicalLayoutRect=function(t){this.$DataGroup[9]=t,this.$layout&&(t?this.$layout.setTypicalSize(t.width,t.height):this.$layout.setTypicalSize(0,0))},i.prototype.removeAllRenderers=function(){for(var t=this.$indexToRenderer,e=Object.keys(t),i=e.length,n=0;i>n;n++){var r=e[n],o=t[r];o&&(this.rendererRemoved(o,o.itemIndex,o.data),this.removeChild(o))}this.$indexToRenderer=[];var s=this.$DataGroup;if(s[10]){for(var a=s[3],h=Object.keys(a),l=h.length,n=0;l>n;n++)for(var u=h[n],p=a[u],c=p.length,d=0;c>d;d++){var o=p[d];this.rendererRemoved(o,o.itemIndex,o.data),this.removeChild(o)}s[3]={},s[2]={},s[10]=!1}},i.prototype.createRenderers=function(){if(this.$dataProvider)for(var t=0,e=this.$dataProvider.length,i=0;e>i;i++){var n=this.$dataProvider.getItemAt(i),r=this.itemToRendererClass(n),o=this.createOneRenderer(r);o&&(this.$indexToRenderer[t]=o,this.updateRenderer(o,t,n),this.rendererAdded(o,t,n),t++)}},i.prototype.updateRenderer=function(t,e,i){var n=this.$DataGroup;return n[11]=!0,t.itemIndex=e,t.parent==this&&this.setChildIndex(t,e),t.data=i,n[11]=!1,t},Object.defineProperty(i.prototype,"numElements",{get:function(){return this.$dataProvider?this.$dataProvider.length:0},enumerable:!0,configurable:!0}),i.prototype.rendererAdded=function(t,e,i){},i.prototype.rendererRemoved=function(t,e,i){},i}(t.Group);t.DataGroup=e,__reflect(e.prototype,"eui.DataGroup"),t.registerProperty(e,"itemRenderer","Class"),t.registerProperty(e,"itemRendererSkinName","Class"),t.registerProperty(e,"dataProvider","eui.ICollection",!0)}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.labelDisplay=null,e._label="",e.iconDisplay=null,e._icon=null,e.touchCaptured=!1,e.touchChildren=!1,e.addEventListener(egret.TouchEvent.TOUCH_BEGIN,e.onTouchBegin,e),e}return __extends(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return this._label},set:function(t){this._label=t,this.labelDisplay&&(this.labelDisplay.text=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"icon",{get:function(){return this._icon},set:function(t){this._icon=t,this.iconDisplay&&(this.iconDisplay.source=t)},enumerable:!0,configurable:!0}),e.prototype.onTouchCancle=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!1,this.invalidateState()},e.prototype.onTouchBegin=function(t){this.$stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!0,this.invalidateState(),t.updateAfterEvent()},e.prototype.onStageTouchEnd=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.contains(t.target)&&this.buttonReleased(),this.touchCaptured=!1,this.invalidateState()},e.prototype.getCurrentState=function(){return this.enabled?this.touchCaptured?"down":"up":"disabled"},e.prototype.partAdded=function(t,e){e===this.labelDisplay?this.labelDisplay.text=this._label:e==this.iconDisplay&&(this.iconDisplay.source=this._icon)},e.prototype.buttonReleased=function(){},e}(t.Component);t.Button=e,__reflect(e.prototype,"eui.Button")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.$Range={0:100,1:!1,2:0,3:!1,4:0,5:0,6:!1,7:1,8:!1,9:!1},t}return __extends(i,e),Object.defineProperty(i.prototype,"maximum",{get:function(){return this.$Range[0]},set:function(t){t=+t||0;var e=this.$Range;t!==e[0]&&(e[0]=t,e[1]=!0,this.invalidateProperties(),this.invalidateDisplayList())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"minimum",{get:function(){return this.$Range[2]},set:function(t){t=+t||0;var e=this.$Range;t!==e[2]&&(e[2]=t,e[3]=!0,this.invalidateProperties(),this.invalidateDisplayList())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"value",{get:function(){var t=this.$Range;return t[6]?t[5]:t[4]},set:function(t){t=+t||0,this.$setValue(t)},enumerable:!0,configurable:!0}),i.prototype.$setValue=function(t){if(t===this.value)return!1;var e=this.$Range;return e[5]=t,e[6]=!0,this.invalidateProperties(),!0},Object.defineProperty(i.prototype,"snapInterval",{get:function(){return this.$Range[7]},set:function(t){var e=this.$Range;e[9]=!0,t=+t||0,t!==e[7]&&(isNaN(t)?(e[7]=1,e[9]=!1):e[7]=t,e[8]=!0,this.invalidateProperties())},enumerable:!0,configurable:!0}),i.prototype.commitProperties=function(){e.prototype.commitProperties.call(this);var t=this.$Range;if(t[2]>t[0]&&(t[1]?t[0]=t[2]:t[2]=t[0]),t[6]||t[1]||t[3]||t[8]){var i=t[6]?t[5]:t[4];t[6]=!1,t[1]=!1,t[3]=!1,t[8]=!1,this.setValue(this.nearestValidValue(i,t[7]))}},i.prototype.nearestValidSize=function(t){var e=this.snapInterval;if(0==e)return t;var i=Math.round(t/e)*e;return Math.abs(i)=(a-s)/2?a:s;return h/r+i[2]},i.prototype.setValue=function(e){var i=this.$Range;i[4]!==e&&(i[0]>i[2]?i[4]=Math.min(i[0],Math.max(i[2],e)):i[4]=e,i[6]=!1,this.invalidateDisplayList(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"value"))},i.prototype.updateDisplayList=function(t,i){e.prototype.updateDisplayList.call(this,t,i),this.updateSkinDisplayList()},i.prototype.updateSkinDisplayList=function(){},i}(t.Component);t.Range=e,__reflect(e.prototype,"eui.Range"),t.registerBindable(e.prototype,"value")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.$target=null,e.$useVirtualLayout=!1,e.$typicalWidth=71,e.$typicalHeight=22,e}return __extends(e,t),Object.defineProperty(e.prototype,"target",{get:function(){return this.$target},set:function(t){this.$target!==t&&(this.$target=t,this.clearVirtualLayoutCache())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useVirtualLayout",{get:function(){return this.$useVirtualLayout},set:function(t){t=!!t,this.$useVirtualLayout!=t&&(this.$useVirtualLayout=t,this.dispatchEventWith("useVirtualLayoutChanged"),this.$useVirtualLayout&&!t&&this.clearVirtualLayoutCache(),this.target&&this.target.invalidateDisplayList())},enumerable:!0,configurable:!0}),e.prototype.setTypicalSize=function(t,e){t=+t||71,e=+e||22,(t!==this.$typicalWidth||e!==this.$typicalHeight)&&(this.$typicalWidth=t,this.$typicalHeight=e,this.$target&&this.$target.invalidateSize())},e.prototype.scrollPositionChanged=function(){},e.prototype.clearVirtualLayoutCache=function(){},e.prototype.elementAdded=function(t){},e.prototype.elementRemoved=function(t){},e.prototype.getElementIndicesInView=function(){return null},e.prototype.measure=function(){},e.prototype.updateDisplayList=function(t,e){},e}(egret.EventDispatcher);t.LayoutBase=e,__reflect(e.prototype,"eui.LayoutBase")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.$ListBase={0:!1,1:!1,2:-2,3:-1,4:!1,5:void 0,6:!1,7:null,8:!1},t}return __extends(i,e),Object.defineProperty(i.prototype,"requireSelection",{get:function(){return this.$ListBase[0]},set:function(t){t=!!t;var e=this.$ListBase;t!==e[0]&&(e[0]=t,t&&(e[1]=!0,this.invalidateProperties()))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectedIndex",{get:function(){return this.$getSelectedIndex()},set:function(t){t=0|+t,this.setSelectedIndex(t,!1)},enumerable:!0,configurable:!0}),i.prototype.$getSelectedIndex=function(){var t=this.$ListBase;return t[2]!=i.NO_PROPOSED_SELECTION?t[2]:t[3]},i.prototype.setSelectedIndex=function(t,e){if(t!=this.selectedIndex){var i=this.$ListBase;e&&(i[4]=i[4]||e),i[2]=t,this.invalidateProperties()}},Object.defineProperty(i.prototype,"selectedItem",{get:function(){var t=this.$ListBase;if(void 0!==t[5])return t[5];var e=this.$getSelectedIndex();if(e!=i.NO_SELECTION&&null!=this.$dataProvider)return this.$dataProvider.length>e?this.$dataProvider.getItemAt(e):void 0},set:function(t){this.setSelectedItem(t,!1)},enumerable:!0,configurable:!0}),i.prototype.setSelectedItem=function(t,e){if(void 0===e&&(e=!1),this.selectedItem!==t){var i=this.$ListBase;e&&(i[4]=i[4]||e),i[5]=t,this.invalidateProperties()}},i.prototype.commitProperties=function(){var n=this.$dataProviderChanged;e.prototype.commitProperties.call(this);var r=this.$ListBase,o=this.$getSelectedIndex(),s=this.$dataProvider;n&&(o>=0&&s&&o0&&(r[2]=0)),void 0!==r[5]&&(s?r[2]=s.getItemIndex(r[5]):r[2]=i.NO_SELECTION,r[5]=void 0);var a=!1;r[2]!=i.NO_PROPOSED_SELECTION&&(a=this.commitSelection()),r[6]&&(r[6]=!1,a||t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedIndex"))},i.prototype.updateRenderer=function(t,i,n){return this.itemSelected(i,this.$isItemIndexSelected(i)),e.prototype.updateRenderer.call(this,t,i,n)},i.prototype.itemSelected=function(t,e){var i=this.$indexToRenderer[t];i&&(i.selected=e)},i.prototype.$isItemIndexSelected=function(t){return t==this.selectedIndex},i.prototype.commitSelection=function(e){void 0===e&&(e=!0);var n=this.$dataProvider,r=this.$ListBase,o=n?n.length-1:-1,s=r[3],a=r[2];if(ao&&(a=o),r[0]&&a==i.NO_SELECTION&&n&&n.length>0)return r[2]=i.NO_PROPOSED_SELECTION,r[4]=!1,!1;if(r[4]){var h=this.dispatchEventWith(egret.Event.CHANGING,!1,!0,!0);if(!h)return this.itemSelected(r[2],!1),r[2]=i.NO_PROPOSED_SELECTION,r[4]=!1,!1}return r[3]=a,r[2]=i.NO_PROPOSED_SELECTION,s!=i.NO_SELECTION&&this.itemSelected(s,!1),r[3]!=i.NO_SELECTION&&this.itemSelected(r[3],!0),e&&(r[4]&&(this.dispatchEventWith(egret.Event.CHANGE),r[4]=!1),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedIndex"),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedItem")),!0},i.prototype.adjustSelection=function(t,e){void 0===e&&(e=!1);var n=this.$ListBase;n[2]!=i.NO_PROPOSED_SELECTION?n[2]=t:n[3]=t,n[6]=!0,this.invalidateProperties()},i.prototype.itemAdded=function(t,n){e.prototype.itemAdded.call(this,t,n);var r=this.$getSelectedIndex();r==i.NO_SELECTION?this.$ListBase[0]&&this.adjustSelection(n,!0):r>=n&&this.adjustSelection(r+1,!0)},i.prototype.itemRemoved=function(t,n){if(e.prototype.itemRemoved.call(this,t,n),this.selectedIndex!=i.NO_SELECTION){var r=this.$getSelectedIndex();n==r?this.requireSelection&&this.$dataProvider&&this.$dataProvider.length>0?0==n?(this.$ListBase[2]=0,this.invalidateProperties()):this.setSelectedIndex(0,!1):this.adjustSelection(-1,!1):r>n&&this.adjustSelection(r-1,!1)}},i.prototype.onCollectionChange=function(n){e.prototype.onCollectionChange.call(this,n),n.kind==t.CollectionEventKind.RESET?0==this.$dataProvider.length&&this.setSelectedIndex(i.NO_SELECTION,!1):n.kind==t.CollectionEventKind.REFRESH&&this.dataProviderRefreshed()},i.prototype.dataProviderRefreshed=function(){this.setSelectedIndex(i.NO_SELECTION,!1)},i.prototype.rendererAdded=function(t,e,i){t.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onRendererTouchBegin,this),t.addEventListener(egret.TouchEvent.TOUCH_END,this.onRendererTouchEnd,this),t.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onRendererTouchCancle,this)},i.prototype.rendererRemoved=function(t,e,i){t.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onRendererTouchBegin,this),t.removeEventListener(egret.TouchEvent.TOUCH_END,this.onRendererTouchEnd,this),t.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onRendererTouchCancle,this)},i.prototype.onRendererTouchBegin=function(t){if(this.$stage){var e=this.$ListBase;t.$isDefaultPrevented||(e[8]=!1,e[7]=t.$currentTarget,this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.stage_touchEndHandler,this))}},i.prototype.onRendererTouchCancle=function(t){var e=this.$ListBase;e[7]=null,e[8]=!0,this.$stage&&this.$stage.removeEventListener(egret.TouchEvent.TOUCH_END,this.stage_touchEndHandler,this)},i.prototype.onRendererTouchEnd=function(e){var i=this.$ListBase,n=e.$currentTarget,r=i[7];n==r&&(i[8]||(this.setSelectedIndex(n.itemIndex,!0),t.ItemTapEvent.dispatchItemTapEvent(this,t.ItemTapEvent.ITEM_TAP,n)),i[8]=!1)},i.prototype.stage_touchEndHandler=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_END,this.stage_touchEndHandler,this),this.$ListBase[7]=null},i.NO_SELECTION=-1,i.NO_PROPOSED_SELECTION=-2,i}(t.DataGroup);t.ListBase=e,__reflect(e.prototype,"eui.ListBase"),t.registerBindable(e.prototype,"selectedIndex"),t.registerBindable(e.prototype,"selectedItem")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.thumb=null,t.$viewport=null,t.autoVisibility=!0,t}return __extends(i,e),Object.defineProperty(i.prototype,"viewport",{get:function(){return this.$viewport},set:function(e){if(e!=this.$viewport){var i=this.$viewport;i&&(i.removeEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onPropertyChanged,this),i.removeEventListener(egret.Event.RESIZE,this.onViewportResize,this)),this.$viewport=e,e&&(e.addEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onPropertyChanged,this),e.addEventListener(egret.Event.RESIZE,this.onViewportResize,this)),this.invalidateDisplayList()}},enumerable:!0,configurable:!0}),i.prototype.onViewportResize=function(t){this.invalidateDisplayList()},i.prototype.onPropertyChanged=function(t){},i}(t.Component);t.ScrollBarBase=e,__reflect(e.prototype,"eui.ScrollBarBase")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.trackHighlight=null,t.thumb=null,t.track=null,t.$SliderBase={0:0,1:0,2:0,3:0,4:null,5:null,6:300,7:0,8:0,9:!0},t.maximum=10,t.addEventListener(egret.TouchEvent.TOUCH_BEGIN,t.onTouchBegin,t),t}return __extends(i,e),Object.defineProperty(i.prototype,"slideDuration",{get:function(){return this.$SliderBase[6]},set:function(t){this.$SliderBase[6]=+t||0},enumerable:!0,configurable:!0}),i.prototype.pointToValue=function(t,e){return this.minimum},Object.defineProperty(i.prototype,"liveDragging",{get:function(){return this.$SliderBase[9]},set:function(t){this.$SliderBase[9]=!!t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pendingValue",{get:function(){return this.$SliderBase[7]},set:function(t){t=+t||0;var e=this.$SliderBase;t!==e[7]&&(e[7]=t,this.invalidateDisplayList())},enumerable:!0,configurable:!0}),i.prototype.setValue=function(t){this.$SliderBase[7]=t,e.prototype.setValue.call(this,t)},i.prototype.partAdded=function(t,i){e.prototype.partAdded.call(this,t,i),i==this.thumb?(this.thumb.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onThumbTouchBegin,this),this.thumb.addEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this)):i==this.track?(this.track.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTrackTouchBegin,this),this.track.addEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this)):i===this.trackHighlight&&(this.trackHighlight.touchEnabled=!1,egret.is(this.trackHighlight,"egret.DisplayObjectContainer")&&(this.trackHighlight.touchChildren=!1))},i.prototype.partRemoved=function(t,i){e.prototype.partRemoved.call(this,t,i),i==this.thumb?(this.thumb.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onThumbTouchBegin,this),this.thumb.removeEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this)):i==this.track&&(this.track.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTrackTouchBegin,this),this.track.removeEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this))},i.prototype.onTrackOrThumbResize=function(t){this.updateSkinDisplayList()},i.prototype.onThumbTouchBegin=function(e){var i=this.$SliderBase;i[5]&&i[5].isPlaying&&this.stopAnimation();var n=this.$stage;n.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.onStageTouchMove,this),n.addEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this);var r=this.thumb.globalToLocal(e.stageX,e.stageY,egret.$TempPoint);i[0]=r.x,i[1]=r.y,t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_START)},i.prototype.onStageTouchMove=function(t){var e=this.$SliderBase;e[2]=t.$stageX,e[3]=t.$stageY;var i=this.track;if(i){var n=i.globalToLocal(e[2],e[3],egret.$TempPoint),r=this.pointToValue(n.x-e[0],n.y-e[1]);r=this.nearestValidValue(r,this.snapInterval),this.updateWhenTouchMove(r),t.updateAfterEvent()}},i.prototype.updateWhenTouchMove=function(t){t!=this.$SliderBase[7]&&(this.liveDragging?(this.setValue(t),this.dispatchEventWith(egret.Event.CHANGE)):this.pendingValue=t)},i.prototype.onStageTouchEnd=function(e){var i=e.$currentTarget;i.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onStageTouchMove,this),i.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END);var n=this.$SliderBase;this.liveDragging||this.value==n[7]||(this.setValue(n[7]),this.dispatchEventWith(egret.Event.CHANGE))},i.prototype.onTouchBegin=function(t){this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.stageTouchEndHandler,this),this.$SliderBase[4]=t.$target},i.prototype.stageTouchEndHandler=function(t){var e=t.$target,i=this.$SliderBase;t.$currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END,this.stageTouchEndHandler,this),i[4]!=e&&this.contains(e)&&egret.TouchEvent.dispatchTouchEvent(this,egret.TouchEvent.TOUCH_TAP,!0,!0,t.$stageX,t.$stageY,t.touchPointID),i[4]=null},i.prototype.$animationUpdateHandler=function(t){this.pendingValue=t.currentValue},i.prototype.animationEndHandler=function(e){this.setValue(this.$SliderBase[8]),this.dispatchEventWith(egret.Event.CHANGE),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END)},i.prototype.stopAnimation=function(){this.$SliderBase[5].stop(),this.setValue(this.nearestValidValue(this.pendingValue,this.snapInterval)),this.dispatchEventWith(egret.Event.CHANGE),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END)},i.prototype.onTrackTouchBegin=function(e){var i=this.thumb?this.thumb.width:0,n=this.thumb?this.thumb.height:0,r=e.$stageX-i/2,o=e.$stageY-n/2,s=this.track.globalToLocal(r,o,egret.$TempPoint),a=this.$Range,h=this.pointToValue(s.x,s.y);h=this.nearestValidValue(h,a[7]);var l=this.$SliderBase;if(h!=l[7])if(0!=l[6]){l[5]||(l[5]=new t.sys.Animation(this.$animationUpdateHandler,this),l[5].endFunction=this.animationEndHandler);var u=l[5];u.isPlaying&&this.stopAnimation(),l[8]=h,u.duration=l[6]*(Math.abs(l[7]-l[8])/(a[0]-a[2])),u.from=l[7],u.to=l[8],t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_START),u.play()}else this.setValue(h),this.dispatchEventWith(egret.Event.CHANGE)},i}(t.Range);t.SliderBase=e,__reflect(e.prototype,"eui.SliderBase")}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t){if(!t)return"";for(var e=" at <"+t.name,i=t.attributes,n=Object.keys(i),r=n.length,o=0;r>o;o++){var s=n[o],a=i[s];("id"!=s||"__"!=a.substring(0,2))&&(e+=" "+s+'="'+a+'"')}return e+=0==t.children.length?"/>":">"}function i(t){var i=e(t.parent),n=e(t).substring(5);return i+"\n "+n}var n=[],r=1,o="hostComponent",s="eui.Skin",a="Declarations",h="egret.Rectangle",l="Class",u="Array",p="Percentage",c="State[]",d="skinName",f=[u,"boolean","string","number"],g=["id","locked","includeIn","excludeFrom"],y=[["<","<"],[">",">"],["&","&"],['"',"""],["'","'"]],v=["null","NaN","undefined","true","false"],m=function(){function e(){this.delayAssignmentDic={}}return e.prototype.$parseCode=function(t,e){var i=e?e:"$exmlClass"+r++,n=eval,o=n(t),s=!0;if(s&&o){egret.registerClass(o,i);for(var a=i.split("."),h=a.length,l=__global,u=0;h-1>u;u++){var p=a[u];l=l[p]||(l[p]={})}l[a[h-1]]||(l[a[h-1]]=o)}return o},e.prototype.parse=function(t){var e=null;e=egret.XML.parse(t);var i=!1,n="";e.attributes["class"]?(n=e.attributes["class"],delete e.attributes["class"],i=!!n):n="$exmlClass"+r++;var o=this.parseClass(e,n),s=o.toCode(),a=null,h=eval;if(a=h(s),i&&a){egret.registerClass(a,n);for(var l=n.split("."),u=l.length,p=__global,c=0;u-1>c;c++){var d=l[c];p=p[d]||(p[d]={})}p[l[u-1]]||(p[l[u-1]]=a)}return a},e.prototype.parseClass=function(e,i){t.exmlConfig||(t.exmlConfig=new t.EXMLConfig),this.currentXML=e,this.currentClassName=i,this.delayAssignmentDic={},this.idDic={},this.stateCode=[],this.stateNames=[],this.skinParts=[],this.bindings=[],this.declarations=null,this.currentClass=new t.EXClass,this.stateIds=[];var n=i.lastIndexOf(".");-1!=n?this.currentClass.className=i.substring(n+1):this.currentClass.className=i,this.startCompile();var r=this.currentClass;return this.currentClass=null,r},e.prototype.startCompile=function(){var e=this.getClassNameOfNode(this.currentXML);this.isSkinClass=e==s,this.currentClass.superClass=e,this.getStateNames();var i=this.currentXML.children;if(i)for(var n=i.length,r=0;n>r;r++){var o=i[r];if(1===o.nodeType&&o.namespace==t.NS_W&&o.localName==a){this.declarations=o;break}}this.currentXML.namespace&&(this.addIds(this.currentXML.children),this.createConstructFunc())},e.prototype.addIds=function(e){if(e)for(var i=e.length,n=0;i>n;n++){var r=e[n];if(1==r.nodeType&&r.namespace&&!this.isInnerClass(r))if(this.addIds(r.children),r.namespace!=t.NS_W&&r.localName){if(this.isProperty(r)){var o=r.localName,s=o.indexOf("."),a=r.children;if(-1==s||!a||0==a.length)continue;var h=a[0];this.stateIds.push(h.attributes.id)}else if(1===r.nodeType){var l=r.attributes.id;if(l){var u=new RegExp("^[a-zA-Z_$]{1}[a-z0-9A-Z_$]*");null==l.match(u)&&egret.$warn(2022,l),null!=l.match(new RegExp(/ /g))&&egret.$warn(2022,l),-1==this.skinParts.indexOf(l)&&this.skinParts.push(l),this.createVarForNode(r),this.isStateNode(r)&&this.stateIds.push(l)}else this.createIdForNode(r),this.isStateNode(r)&&this.stateIds.push(r.attributes.id)}}else;}},e.prototype.isInnerClass=function(e){if(e.hasOwnProperty("isInnerClass"))return e.isInnerClass;var i="Skin"==e.localName&&e.namespace==t.NS_S;if(!i)if(this.isProperty(e))i=!1;else{var n=void 0,r=e.parent;if(this.isProperty(r)){n=r.localName;var o=n.indexOf(".");if(-1!=o){n.substring(o+1);n=n.substring(0,o)}r=r.parent}else n=t.exmlConfig.getDefaultPropById(r.localName,r.namespace);var s=t.exmlConfig.getClassNameById(r.localName,r.namespace);i=t.exmlConfig.getPropertyType(n,s)==l}return e.isInnerClass=i,i},e.prototype.containsState=function(t){var e=t.attributes;if(e.includeIn||e.excludeFrom)return!0;for(var i=Object.keys(e),n=i.length,r=0;n>r;r++){var o=i[r];if(-1!=o.indexOf("."))return!0}return!1},e.prototype.createIdForNode=function(t){var e=this.getNodeId(t);this.idDic[e]?this.idDic[e]++:this.idDic[e]=1,e+=this.idDic[e],t.attributes.id=e},e.prototype.getNodeId=function(t){return t.attributes.id?t.attributes.id:"_"+t.localName},e.prototype.createVarForNode=function(e){var i=this.getClassNameOfNode(e);""!=i&&(this.currentClass.getVariableByName(e.attributes.id)||this.currentClass.addVariable(new t.EXVariable(e.attributes.id)))},e.prototype.createFuncForNode=function(e){var i=e.localName,n=this.isBasicTypeData(i);if(n)return this.createBasicTypeForNode(e);var r=this.getClassNameOfNode(e),o=new t.EXFunction,s="_i",a=e.attributes.id;o.name=a+s,this.currentClass.addFunction(o);var h=new t.EXCodeBlock;o.codeBlock=h;var l="t";"Object"==i?h.addVar(l,"{}"):h.addVar(l,"new "+r+"()");var u=!!this.currentClass.getVariableByName(a);u&&h.addAssignment("this."+a,l),this.addAttributesToCodeBlock(h,l,e),this.initlizeChildNode(e,h,l);var p=this.delayAssignmentDic[a];if(p)for(var c=p.length,d=0;c>d;d++){var f=p[d];h.concat(f)}return h.addReturn(l),"this."+o.name+"()"},e.prototype.isBasicTypeData=function(t){return-1!=f.indexOf(t)},e.prototype.createBasicTypeForNode=function(t){var e=t.localName,i="",n=this.currentClass.getVariableByName(t.attributes.id),r=t.children,o="";if(r&&r.length>0){var s=r[0];3==s.nodeType&&(o=s.text.trim())}switch(e){case u:var a=[];if(r)for(var h=r.length,l=0;h>l;l++){var p=r[l];1==p.nodeType&&a.push(this.createFuncForNode(p))}i="["+a.join(",")+"]";break;case"boolean":i="false"!=o&&o?"true":"false"; -break;case"number":i=o,-1!=i.indexOf("%")&&(i=i.substring(0,i.length-1));break;case"string":i=this.formatString(o)}return n&&(n.defaultValue=i),i},e.prototype.addAttributesToCodeBlock=function(e,i,n){var r,o,s=n.attributes,a=Object.keys(s);a.sort();for(var h=a.length,l=0;h>l;l++)if(r=a[l],this.isNormalKey(r)&&(o=s[r],r=this.formatKey(r,o),o=this.formatValue(r,o,n))){if(this.currentClass.getVariableByName(o)){var u="this.",p=s.id,c=u+p+" = t;";this.currentClass.getVariableByName(p)||this.createVarForNode(n),e.containsCodeLine(c)||e.addCodeLineAt(c,1);var d=new t.EXCodeBlock;"this"==i?d.addAssignment(i,u+o,r):(d.startIf(u+p),d.addAssignment(u+p,u+o,r),d.endBlock()),this.delayAssignmentDic[o]||(this.delayAssignmentDic[o]=[]),this.delayAssignmentDic[o].push(d),o=u+o}e.addAssignment(i,o,r)}},e.prototype.initlizeChildNode=function(e,n,r){var o=e.children;if(o&&0!=o.length){for(var s,a=t.exmlConfig.getClassNameById(e.localName,e.namespace),h=[],l=o.length,u=[],p=0;l>p;p++){var c=o[p];if(1==c.nodeType&&c.namespace!=t.NS_W)if(this.isInnerClass(c)){if("Skin"==c.localName){var f=this.parseInnerClass(c),g=t.exmlConfig.getPropertyType(d,a);g?n.addAssignment(r,f,d):egret.$error(2005,this.currentClassName,d,i(c))}}else{var y=c.localName;if(this.isProperty(c)){if(!this.isNormalKey(y))continue;var g=t.exmlConfig.getPropertyType(c.localName,a);if(!g)continue;if(!c.children||0==c.children.length)continue;this.addChildrenToProp(c.children,g,y,n,r,s,u,e)}else h.push(c)}}if(0!=h.length){var v=t.exmlConfig.getDefaultPropById(e.localName,e.namespace),m=t.exmlConfig.getPropertyType(v,a);v&&m&&this.addChildrenToProp(h,m,v,n,r,s,u,e)}}},e.prototype.parseInnerClass=function(t){var i=n.pop();i||(i=new e);var o=this.currentClass.className+"$"+t.localName+r++,s=i.parseClass(t,o);return this.currentClass.addInnerClass(s),n.push(i),o},e.prototype.addChildrenToProp=function(t,e,i,n,r,o,s,a){var h="",p=t.length;if(p>1){if(e!=u)return;for(var c=[],d=0;p>d;d++){var f=t[d];if(1==f.nodeType){h=this.createFuncForNode(f);this.getClassNameOfNode(f);this.isStateNode(f)||c.push(h)}}h="["+c.join(",")+"]"}else{var g=t[0];if(e==u)if(g.localName==u){var c=[];if(g.children)for(var y=g.children.length,v=0;y>v;v++){var f=g.children[v];if(1==f.nodeType){h=this.createFuncForNode(f);this.getClassNameOfNode(f);this.isStateNode(f)||c.push(h)}}h="["+c.join(",")+"]"}else{h=this.createFuncForNode(g);this.getClassNameOfNode(g);h=this.isStateNode(g)?"[]":"["+h+"]"}else if(1==g.nodeType)if(e==l){if(p>1)return;h=this.parseInnerClass(t[0])}else{this.getClassNameOfNode(g);h=this.createFuncForNode(g)}else h=this.formatValue(i,g.text,a)}""!=h&&(-1==h.indexOf("()")&&(i=this.formatKey(i,h)),-1==s.indexOf(i)&&s.push(i),n.addAssignment(r,h,i))},e.prototype.isProperty=function(e){if(e.hasOwnProperty("isProperty"))return e.isProperty;var i,n=e.localName;if(n&&1===e.nodeType&&e.parent&&!this.isBasicTypeData(n)){var r=e.parent,o=n.indexOf(".");-1!=o&&(n=n.substr(0,o));var s=t.exmlConfig.getClassNameById(r.localName,r.namespace);i=!!t.exmlConfig.getPropertyType(n,s)}else i=!1;return e.isProperty=i,i},e.prototype.isNormalKey=function(t){return t&&-1==t.indexOf(".")&&-1==t.indexOf(":")&&-1==g.indexOf(t)?!0:!1},e.prototype.formatKey=function(t,e){return-1!=e.indexOf("%")&&("height"==t?t="percentHeight":"width"==t&&(t="percentWidth")),t},e.prototype.formatValue=function(e,i,n){i||(i="");var r=i;i=i.trim();var o=this.getClassNameOfNode(n),s=t.exmlConfig.getPropertyType(e,o),a=this.formatBinding(e,i,n);if(a){this.checkIdForState(n);var u="this";n!==this.currentXML&&(u+="."+n.attributes.id),this.bindings.push(new t.EXBinding(u,e,a.templates,a.chainIndex)),i=""}else if(s==h){i="new "+h+"("+i+")"}else if(s==p)-1!=i.indexOf("%")&&(i=this.formatString(i));else{switch(s){case l:e==d&&(i=this.formatString(r));break;case"number":0==i.indexOf("#")?i="0x"+i.substring(1):-1!=i.indexOf("%")&&(i=parseFloat(i.substr(0,i.length-1)).toString());break;case"boolean":i="false"!=i&&i?"true":"false";break;case"string":case"any":i=this.formatString(r)}}return i},e.prototype.formatString=function(t){return t=this.unescapeHTMLEntity(t),t=t.split("\n").join("\\n"),t=t.split("\r").join("\\n"),t=t.split('"').join('\\"'),t='"'+t+'"'},e.prototype.formatBinding=function(t,e,i){if(!e)return null;if(e=e.trim(),"{"!=e.charAt(0)||"}"!=e.charAt(e.length-1))return null;e=e.substring(1,e.length-1).trim();for(var n=-1==e.indexOf("+")?[e]:this.parseTemplates(e),r=[],s=n.length,a=0;s>a;a++){var h=n[a].trim();if(h){var l=h.charAt(0);if(!("'"==l||'"'==l||l>="0"&&"9">=l||"-"==l||-1==h.indexOf(".")&&-1!=v.indexOf(h))){0==h.indexOf("this.")&&(h=h.substring(5));var u=h.split(".")[0];u!=o&&-1==this.skinParts.indexOf(u)&&(h=o+"."+h),n[a]='"'+h+'"',r.push(a)}}else n.splice(a,1),a--,s--}return{templates:n,chainIndex:r}},e.prototype.parseTemplates=function(t){if(-1==t.indexOf("'"))return t.split("+");var e=!1,i="";for(t=t.split("\\'").join(" 0 ");t.length>0;){var n=t.indexOf("'");if(-1==n){i+=t;break}i+=t.substring(0,n+1),t=t.substring(n+1),n=t.indexOf("'"),-1==n&&(n=t.length-1,e=!0);var r=t.substring(0,n+1);i+=r.split("+").join(" 1 "),t=t.substring(n+1)}t=i.split(" 0 ").join("\\'"),e&&(t+="'");for(var o=t.split("+"),s=o.length,a=0;s>a;a++)o[a]=o[a].split(" 1 ").join("+");return o},e.prototype.unescapeHTMLEntity=function(t){if(!t)return"";for(var e=y.length,i=0;e>i;i++){var n=y[i],r=n[0],o=n[1];t=t.split(o).join(r)}return t},e.prototype.createConstructFunc=function(){var e=new t.EXCodeBlock;e.addEmptyLine();var i="this";if(this.addAttributesToCodeBlock(e,i,this.currentXML),this.declarations){var n=this.declarations.children;if(n&&n.length>0)for(var r=n.length,o=0;r>o;o++){var s=n[o];if(1==s.nodeType){var a=this.createFuncForNode(s);a&&e.addCodeLine(a+";")}}}this.initlizeChildNode(this.currentXML,e,i);var h,l,u=this.stateIds;if(u.length>0){l=u.length;for(var o=0;l>o;o++)h=u[o],e.addCodeLine("this."+h+"_i();");e.addEmptyLine()}var p=this.skinParts,c="[]";if(l=p.length,l>0){for(var o=0;l>o;o++)p[o]='"'+p[o]+'"';c="["+p.join(",")+"]"}var d=new t.EXFunction;d.name="skinParts",d.isGet=!0;var f=new t.EXCodeBlock;f.addReturn(c),d.codeBlock=f,this.currentClass.addFunction(d),this.currentXML.attributes.id="",this.createStates(this.currentXML);for(var g,y=this.currentXML,v=(this.getClassNameOfNode(y),y.attributes),m=Object.keys(v),$=m.length,E=0;$>E;E++){var C=m[E],_=v[C],b=C.indexOf(".");if(-1!=b){var T=C.substring(0,b);T=this.formatKey(T,_);var S=this.formatValue(T,_,y);if(!S)continue;var x=C.substr(b+1);g=this.getStateByName(x,y);var I=g.length;if(I>0)for(var o=0;I>o;o++){var P=g[o];P.addOverride(new t.EXSetProperty("",T,S))}}}var L=this.stateCode;if(l=L.length,l>0){var N=" ";e.addCodeLine("this.states = [");for(var O=!0,o=0;l>o;o++){var P=L[o];O?O=!1:e.addCodeLine(N+",");for(var A=P.toCode().split("\n"),B=0;B0){e.addEmptyLine();for(var o=0;l>o;o++){var M=R[o];e.addCodeLine(M.toCode())}}this.currentClass.constructCode=e},e.prototype.isStateNode=function(t){var e=t.attributes;return e.hasOwnProperty("includeIn")||e.hasOwnProperty("excludeFrom")},e.prototype.getStateNames=function(){var e=this.currentXML,i=t.exmlConfig.getClassNameById(e.localName,e.namespace),n=t.exmlConfig.getPropertyType("states",i);if(n==c){var r=e.attributes.states;r&&delete e.attributes.states;var o,s,a=this.stateNames,h=e.children;if(h)for(var l=h.length,u=0;l>u;u++)if(s=h[u],1==s.nodeType&&"states"==s.localName){s.namespace=t.NS_W,o=s.children;break}if(o||r)if(r)for(var p=r.split(","),d=p.length,u=0;d>u;u++){var f=p[u].trim();f&&(-1==a.indexOf(f)&&a.push(f),this.stateCode.push(new t.EXState(f)))}else for(var g=o.length,u=0;g>u;u++){var y=o[u];if(1==y.nodeType){var v=[],m=y.attributes;if(m.stateGroups)for(var $=m.stateGroups.split(","),E=$.length,C=0;E>C;C++){var _=$[C].trim();_&&(-1==a.indexOf(_)&&a.push(_),v.push(_))}var f=m.name;-1==a.indexOf(f)&&a.push(f),this.stateCode.push(new t.EXState(f,v))}}}},e.prototype.createStates=function(e){var i=e.children;if(i)for(var n=i.length,r=0;n>r;r++){var o=i[r];if(1==o.nodeType&&!this.isInnerClass(o)&&(this.createStates(o),o.namespace!=t.NS_W&&o.localName))if(this.isProperty(o)){var s=o.localName,a=s.indexOf("."),h=o.children;if(-1==a||!h||0==h.length)continue;var l=s.substring(a+1);s=s.substring(0,a);var p=this.getClassNameOfNode(e),c=(t.exmlConfig.getPropertyType(s,p),h[0]),d=void 0;1==c.nodeType?(this.createFuncForNode(c),this.checkIdForState(c),d="this."+c.attributes.id):d=this.formatValue(s,c.text,e);var f=this.getStateByName(l,o),g=f.length;if(g>0)for(var y=0;g>y;y++){var v=f[y];v.addOverride(new t.EXSetProperty(e.attributes.id,s,d))}}else if(this.containsState(o)){var m=o.attributes,$=m.id;this.getClassNameOfNode(o);this.checkIdForState(o);var l=void 0,f=void 0,v=void 0;if(this.isStateNode(o)){var E="",C=o.parent;C.localName==u&&(C=C.parent),C&&C.parent&&this.isProperty(C)&&(C=C.parent),C&&C!=this.currentXML&&(E=C.attributes.id,this.checkIdForState(C));var _=this.findNearNodeId(o),b=[];if(m.includeIn)b=m.includeIn.split(",");else{for(var T=m.excludeFrom.split(","),S=T.length,y=0;S>y;y++){var x=T[y];this.getStateByName(x,o)}S=this.stateCode.length;for(var y=0;S>y;y++)v=this.stateCode[y],-1==T.indexOf(v.name)&&b.push(v.name)}for(var I=b.length,P=0;I>P;P++)if(l=b[P],f=this.getStateByName(l,o),f.length>0)for(var g=f.length,y=0;g>y;y++)v=f[y],v.addOverride(new t.EXAddItems($,E,_.position,_.relativeTo))}for(var L=Object.keys(m),N=L.length,O=0;N>O;O++){var A=L[O],d=m[A],a=A.indexOf(".");if(-1!=a){var B=A.substring(0,a);B=this.formatKey(B,d);var D=this.formatBinding(B,d,o);if(!D&&(d=this.formatValue(B,d,o),!d))continue;l=A.substr(a+1),f=this.getStateByName(l,o);var g=f.length;if(g>0)for(var y=0;g>y;y++)v=f[y],D?v.addOverride(new t.EXSetStateProperty($,B,D.templates,D.chainIndex)):v.addOverride(new t.EXSetProperty($,B,d))}}}}},e.prototype.checkIdForState=function(t){if(t&&!this.currentClass.getVariableByName(t.attributes.id)){this.createVarForNode(t);var e=t.attributes.id,i=e+"_i",n=this.currentClass.getFuncByName(i);if(n){var r="this."+e+" = t;",o=n.codeBlock;o&&(o.containsCodeLine(r)||o.addCodeLineAt(r,1))}}},e.prototype.getStateByName=function(t,e){for(var i=[],n=this.stateCode,r=n.length,o=0;r>o;o++){var s=n[o];if(s.name==t)-1==i.indexOf(s)&&i.push(s);else if(s.stateGroups.length>0){for(var a=!1,h=s.stateGroups.length,l=0;h>l;l++){var u=s.stateGroups[l];if(u==t){a=!0;break}}a&&-1==i.indexOf(s)&&i.push(s)}}return i},e.prototype.findNearNodeId=function(t){for(var e,i,n,r=t.parent,o="",s=-1,a=!1,h=r.children,l=h.length,u=0;l>u;u++){var p=h[u];this.isProperty(p)||(p==t?(a=!0,s=u):!a||n||this.isStateNode(p)||(n=p),a||this.isStateNode(p)||(i=p))}return 0==s?(e=0,{position:e,relativeTo:o}):s==l-1?(e=1,{position:e,relativeTo:o}):n&&(e=2,o=n.attributes.id)?(this.checkIdForState(n),{position:e,relativeTo:o}):{position:1,relativeTo:o}},e.prototype.getClassNameOfNode=function(e){var i=t.exmlConfig.getClassNameById(e.localName,e.namespace);return i},e}();t.EXMLParser=m,__reflect(m.prototype,"eui.sys.EXMLParser")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.$selected=!1,t.$autoSelected=!0,t}return __extends(i,e),Object.defineProperty(i.prototype,"selected",{get:function(){return this.$selected},set:function(t){this.$setSelected(t)},enumerable:!0,configurable:!0}),i.prototype.$setSelected=function(e){return e=!!e,e===this.$selected?!1:(this.$selected=e,this.invalidateState(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selected"),!0)},i.prototype.getCurrentState=function(){var t=e.prototype.getCurrentState.call(this);if(this.$selected){var i=t+"AndSelected",n=this.skin;return n&&n.hasState(i)?i:"disabled"==t?"disabled":"down"}return t},i.prototype.buttonReleased=function(){this.$autoSelected&&(this.selected=!this.$selected,this.dispatchEventWith(egret.Event.CHANGE))},i}(t.Button);t.ToggleButton=e,__reflect(e.prototype,"eui.ToggleButton"),t.registerBindable(e.prototype,"selected")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.$horizontalAlign="left",e.$verticalAlign="top",e.$gap=6,e.$paddingLeft=0,e.$paddingRight=0,e.$paddingTop=0,e.$paddingBottom=0,e.elementSizeTable=[],e.startIndex=-1,e.endIndex=-1,e.indexInViewCalculated=!1,e.maxElementSize=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"horizontalAlign",{get:function(){return this.$horizontalAlign},set:function(t){this.$horizontalAlign!=t&&(this.$horizontalAlign=t,this.$target&&this.$target.invalidateDisplayList())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"verticalAlign",{get:function(){return this.$verticalAlign},set:function(t){this.$verticalAlign!=t&&(this.$verticalAlign=t,this.$target&&this.$target.invalidateDisplayList())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"gap",{get:function(){return this.$gap},set:function(t){t=+t||0,this.$gap!==t&&(this.$gap=t,this.invalidateTargetLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"paddingLeft",{get:function(){return this.$paddingLeft},set:function(t){t=+t||0,this.$paddingLeft!==t&&(this.$paddingLeft=t,this.invalidateTargetLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"paddingRight",{get:function(){return this.$paddingRight},set:function(t){t=+t||0,this.$paddingRight!==t&&(this.$paddingRight=t,this.invalidateTargetLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"paddingTop",{get:function(){return this.$paddingTop},set:function(t){t=+t||0,this.$paddingTop!==t&&(this.$paddingTop=t,this.invalidateTargetLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"paddingBottom",{get:function(){return this.$paddingBottom},set:function(t){t=+t||0,this.$paddingBottom!==t&&(this.$paddingBottom=t,this.invalidateTargetLayout())},enumerable:!0,configurable:!0}),e.prototype.invalidateTargetLayout=function(){var t=this.$target;t&&(t.invalidateSize(),t.invalidateDisplayList())},e.prototype.measure=function(){this.$target&&(this.$useVirtualLayout?this.measureVirtual():this.measureReal())},e.prototype.measureReal=function(){},e.prototype.measureVirtual=function(){},e.prototype.updateDisplayList=function(t,e){var i=this.$target;if(i)return 0==i.numElements?void i.setContentSize(Math.ceil(this.$paddingLeft+this.$paddingRight),Math.ceil(this.$paddingTop+this.$paddingBottom)):void(this.$useVirtualLayout?this.updateDisplayListVirtual(t,e):this.updateDisplayListReal(t,e))},e.prototype.getStartPosition=function(t){return 0},e.prototype.getElementSize=function(t){return 0},e.prototype.getElementTotalSize=function(){return 0},e.prototype.elementRemoved=function(e){this.$useVirtualLayout&&(t.prototype.elementRemoved.call(this,e),this.elementSizeTable.splice(e,1))},e.prototype.clearVirtualLayoutCache=function(){this.$useVirtualLayout&&(this.elementSizeTable=[],this.maxElementSize=0)},e.prototype.findIndexAt=function(t,e,i){var n=.5*(e+i)|0,r=this.getStartPosition(n),o=this.getElementSize(n);return t>=r&&tt?this.findIndexAt(t,e,Math.max(e,n-1)):this.findIndexAt(t,Math.min(n+1,i),i)},e.prototype.scrollPositionChanged=function(){if(t.prototype.scrollPositionChanged.call(this),this.$useVirtualLayout){var e=this.getIndexInView();e&&(this.indexInViewCalculated=!0,this.target.invalidateDisplayList())}},e.prototype.getIndexInView=function(){return!1},e.prototype.updateDisplayListVirtual=function(t,e){},e.prototype.updateDisplayListReal=function(t,e){},e.prototype.flexChildrenProportionally=function(t,e,i,n){var r,o=n.length;do{r=!0;var s=e-t*i/100;s>0?e-=s:s=0;for(var a=e/i,h=0;o>h;h++){var l=n[h],u=l.percent*a;if(u=p?s-=p:(e-=p-s,s=0),r=!1;break}if(u>l.max){var c=l.max;l.size=c,n[h]=n[--o],n[o]=l,i-=l.percent,s>=c?s-=c:(e-=c-s,s=0),r=!1;break}l.size=u}}while(!r)},e}(t.LayoutBase);t.LinearLayoutBase=e,__reflect(e.prototype,"eui.LinearLayoutBase")}(eui||(eui={})),function(t){var e;!function(t){var e=function(){function t(){this.layoutElement=null,this.size=0,this.percent=0/0,this.min=0/0,this.max=0/0}return t}();t.ChildInfo=e,__reflect(e.prototype,"eui.sys.ChildInfo")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){return t.call(this)||this}return __extends(e,t),e.prototype.pointToValue=function(t,e){if(!this.thumb||!this.track)return 0;var i=this.$Range,n=i[0]-i[2],r=this.getThumbRange();return i[2]+(0!=r?t/r*n:0)},e.prototype.getThumbRange=function(){var t=egret.$TempRectangle;this.track.getLayoutBounds(t);var e=t.width;return this.thumb.getLayoutBounds(t),e-t.width},e.prototype.updateSkinDisplayList=function(){if(this.thumb&&this.track){var t=this.$Range,e=this.getThumbRange(),i=t[0]-t[2],n=i>0?(this.pendingValue-t[2])/i*e:0,r=this.track.localToGlobal(n,0,egret.$TempPoint),o=r.x,s=r.y,a=this.thumb.$parent.globalToLocal(o,s,egret.$TempPoint).x,h=egret.$TempRectangle;if(this.thumb.getLayoutBounds(h),this.thumb.setLayoutBoundsPosition(Math.round(a),h.y),this.trackHighlight&&this.trackHighlight.$parent){var l=this.trackHighlight.$parent.globalToLocal(o,s,egret.$TempPoint).x-n;this.trackHighlight.x=Math.round(l),this.trackHighlight.width=Math.round(n)}}},e}(t.SliderBase);t.HSlider=e,__reflect(e.prototype,"eui.HSlider")}(eui||(eui={}));var eui;!function(t){var e=[],i={},n={},r=function(){function t(){}return t.prototype.getAsset=function(t,r,o){var s=i[t];if(s)return void s.push([r,o]);var a=e.pop();a||(a=new egret.ImageLoader),i[t]=[[r,o]],n[a.$hashCode]=t,a.addEventListener(egret.Event.COMPLETE,this.onLoadFinish,this),a.addEventListener(egret.IOErrorEvent.IO_ERROR,this.onLoadFinish,this),a.load(t)},t.prototype.onLoadFinish=function(t){var r=t.currentTarget;r.removeEventListener(egret.Event.COMPLETE,this.onLoadFinish,this),r.removeEventListener(egret.IOErrorEvent.IO_ERROR,this.onLoadFinish,this);var o;t.$type==egret.Event.COMPLETE&&(o=new egret.Texture,o._setBitmapData(r.data),r.data=null),e.push(r);var s=n[r.$hashCode];delete n[r.$hashCode];var a=i[s];delete i[s];for(var h=a.length,l=0;h>l;l++){var u=a[l];u[0].call(u[1],o,s)}},t}();t.DefaultAssetAdapter=r,__reflect(r.prototype,"eui.DefaultAssetAdapter",["eui.IAssetAdapter"])}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(t){var i=e.call(this)||this;return i.sourceChanged=!1,i._source=null,i.initializeUIValues(),t&&(i.source=t),i}return __extends(i,e),Object.defineProperty(i.prototype,"scale9Grid",{get:function(){return this.$scale9Grid},set:function(t){this.$setScale9Grid(t),this.invalidateDisplayList()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillMode",{get:function(){return this.$fillMode},set:function(t){t!=this.$fillMode&&(e.prototype.$setFillMode.call(this,t),this.invalidateDisplayList())},enumerable:!0,configurable:!0}),i.prototype.$setFillMode=function(t){var i=e.prototype.$setFillMode.call(this,t);return this.invalidateDisplayList(),i},Object.defineProperty(i.prototype,"source",{get:function(){return this._source},set:function(t){t!=this._source&&(this._source=t,this.$stage?this.parseSource():(this.sourceChanged=!0,this.invalidateProperties()))},enumerable:!0,configurable:!0}),i.prototype.$setTexture=function(t){if(t==this.$texture)return!1;var i=e.prototype.$setTexture.call(this,t);return this.sourceChanged=!1,this.invalidateSize(),this.invalidateDisplayList(),i},i.prototype.parseSource=function(){this.sourceChanged=!1;var e=this._source;e&&"string"==typeof e?t.getAssets(this._source,function(t){e===this._source&&egret.is(t,"egret.Texture")&&(this.$setTexture(t),t&&this.dispatchEventWith(egret.Event.COMPLETE))},this):this.$setTexture(e)},i.prototype.$measureContentBounds=function(t){var e=this.$texture;if(e){var i=this.$UIComponent,n=i[10],r=i[11];if(isNaN(n)||isNaN(r))return void t.setEmpty();"clip"==this.$fillMode&&(n>e.$getTextureWidth()&&(n=e.$getTextureWidth()),r>e.$getTextureHeight()&&(r=e.$getTextureHeight())),t.setTo(0,0,n,r)}else t.setEmpty()},i.prototype.createChildren=function(){this.sourceChanged&&this.parseSource()},i.prototype.setActualSize=function(i,n){t.sys.UIComponentImpl.prototype.setActualSize.call(this,i,n),e.prototype.$setWidth.call(this,i),e.prototype.$setHeight.call(this,n)},i.prototype.childrenCreated=function(){},i.prototype.commitProperties=function(){t.sys.UIComponentImpl.prototype.commitProperties.call(this),this.sourceChanged&&this.parseSource()},i.prototype.measure=function(){var t=this.$texture;t?this.setMeasuredSize(t.$getTextureWidth(),t.$getTextureHeight()):this.setMeasuredSize(0,0)},i.prototype.updateDisplayList=function(t,e){this.$renderDirty=!0},i.prototype.invalidateParentLayout=function(){},i.prototype.setMeasuredSize=function(t,e){},i.prototype.invalidateProperties=function(){},i.prototype.validateProperties=function(){},i.prototype.invalidateSize=function(){},i.prototype.validateSize=function(t){},i.prototype.invalidateDisplayList=function(){},i.prototype.validateDisplayList=function(){},i.prototype.validateNow=function(){},i.prototype.setLayoutBoundsSize=function(t,e){},i.prototype.setLayoutBoundsPosition=function(t,e){},i.prototype.getLayoutBounds=function(t){},i.prototype.getPreferredBounds=function(t){},i}(egret.Bitmap);t.Image=e,__reflect(e.prototype,"eui.Image",["eui.UIComponent","egret.DisplayObject"]),t.sys.implementUIComponent(e,egret.Bitmap),t.registerProperty(e,"scale9Grid","egret.Rectangle")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t._data=null,t._selected=!1,t.itemIndex=-1,t.touchCaptured=!1,t.addEventListener(egret.TouchEvent.TOUCH_BEGIN,t.onTouchBegin,t),t}return __extends(i,e),Object.defineProperty(i.prototype,"data",{get:function(){return this._data},set:function(e){this._data=e,t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"data"),this.dataChanged()},enumerable:!0,configurable:!0}),i.prototype.dataChanged=function(){},Object.defineProperty(i.prototype,"selected",{get:function(){return this._selected},set:function(t){this._selected!=t&&(this._selected=t,this.invalidateState())},enumerable:!0,configurable:!0}),i.prototype.onTouchCancle=function(t){this.touchCaptured=!1;var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.invalidateState()},i.prototype.onTouchBegin=function(t){this.$stage&&(this.$stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!0,this.invalidateState(),t.updateAfterEvent())},i.prototype.onStageTouchEnd=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!1,this.invalidateState()},i.prototype.getCurrentState=function(){var t="up";if(this.enabled||(t="disabled"),this.touchCaptured&&(t="down"),this._selected){var e=t+"AndSelected",i=this.skin;return i&&i.hasState(e)?e:"disabled"==t?"disabled":"down"}return t},i}(t.Component);t.ItemRenderer=e,__reflect(e.prototype,"eui.ItemRenderer",["eui.IItemRenderer"]),t.registerBindable(e.prototype,"data")}(eui||(eui={}));var eui;!function(t){var e=t.sys.UIComponentImpl,i=function(i){function n(t){var e=i.call(this)||this;return e.$styleSetMap={fontFamily:!0,size:!0,bold:!0,italic:!0,textAlign:!0,verticalAlign:!0,lineSpacing:!0,textColor:!0,wordWrap:!0,displayAsPassword:!0,strokeColor:!0,stroke:!0,maxChars:!0,multiline:!0,border:!0,borderColor:!0,background:!0,backgroundColor:!0},e.$revertStyle={},e.$style=null,e.$changeFromStyle=!1,e._widthConstraint=0/0,e.initializeUIValues(),e.text=t,e}return __extends(n,i),Object.defineProperty(n.prototype,"style",{get:function(){return this.$style},set:function(t){this.$setStyle(t)},enumerable:!0,configurable:!0}),n.prototype.$setStyle=function(t){if(this.$style!=t){this.$style=t;var e=egret.getImplementation("eui.Theme");if(e){this.$changeFromStyle=!0;for(var i in this.$revertStyle)this[i]=this.$revertStyle[i];if(this.$revertStyle={},null==t)return void(this.$changeFromStyle=!1);for(var n=t.split(","),r=0;r=0&&e0?this._proposedSelectedIndices[0]:-1:this.$getSelectedIndex()},set:function(t){this.setSelectedIndex(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectedItems",{get:function(){var t=[],e=this.selectedIndices;if(e)for(var i=e.length,n=0;i>n;n++)t[n]=this.$dataProvider.getItemAt(e[n]);return t},set:function(t){var e=[];if(t)for(var i=t.length,n=0;i>n;n++){var r=this.$dataProvider.getItemIndex(t[n]);if(-1!=r&&e.splice(0,0,r),-1==r){e=[];break}}this.setSelectedIndices(e,!1)},enumerable:!0,configurable:!0}),i.prototype.setSelectedIndices=function(t,e){var i=this.$ListBase;e&&(i[4]=i[4]||e),t?this._proposedSelectedIndices=t:this._proposedSelectedIndices=[],this.invalidateProperties()},i.prototype.commitProperties=function(){e.prototype.commitProperties.call(this),this._proposedSelectedIndices&&this.commitSelection()},i.prototype.commitSelection=function(i){void 0===i&&(i=!0);var n=this.$ListBase,r=n[3];if(this._proposedSelectedIndices){if(this._proposedSelectedIndices=this._proposedSelectedIndices.filter(this.isValidIndex),!this.allowMultipleSelection&&this._proposedSelectedIndices.length>0){var o=[];o.push(this._proposedSelectedIndices[0]),this._proposedSelectedIndices=o}this._proposedSelectedIndices.length>0?n[2]=this._proposedSelectedIndices[0]:n[2]=-1}var s=e.prototype.commitSelection.call(this,!1);if(!s)return this._proposedSelectedIndices=null,!1;var a=this.$getSelectedIndex();return a>t.ListBase.NO_SELECTION&&(this._proposedSelectedIndices?-1==this._proposedSelectedIndices.indexOf(a)&&this._proposedSelectedIndices.push(a):this._proposedSelectedIndices=[a]),this._proposedSelectedIndices&&(-1!=this._proposedSelectedIndices.indexOf(r)&&this.itemSelected(r,!0),this.commitMultipleSelection()),i&&s&&(n[4]&&(this.dispatchEventWith(egret.Event.CHANGE),n[4]=!1),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedIndex"),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedItem")),s -},i.prototype.commitMultipleSelection=function(){var t,e,i=[],n=[],r=this._selectedIndices,o=this._proposedSelectedIndices;if(r.length>0&&o.length>0){for(e=o.length,t=0;e>t;t++)-1==r.indexOf(o[t])&&n.push(o[t]);for(e=r.length,t=0;e>t;t++)-1==o.indexOf(r[t])&&i.push(r[t])}else r.length>0?i=r:o.length>0&&(n=o);if(this._selectedIndices=o,i.length>0)for(e=i.length,t=0;e>t;t++)this.itemSelected(i[t],!1);if(n.length>0)for(e=n.length,t=0;e>t;t++)this.itemSelected(n[t],!0);this._proposedSelectedIndices=null},i.prototype.$isItemIndexSelected=function(t){return this.allowMultipleSelection?-1!=this._selectedIndices.indexOf(t):e.prototype.$isItemIndexSelected.call(this,t)},i.prototype.dataProviderRefreshed=function(){this.allowMultipleSelection||e.prototype.dataProviderRefreshed.call(this)},i.prototype.calculateSelectedIndices=function(t){var e=[],i=this._selectedIndices,n=i.length;if(n>0){if(1==n&&i[0]==t)return this.$ListBase[0]?(e.splice(0,0,i[0]),e):e;for(var r=!1,o=0;n>o;o++)i[o]==t?r=!0:i[o]!=t&&e.splice(0,0,i[o]);return r||e.splice(0,0,t),e}return e.splice(0,0,t),e},i.prototype.onRendererTouchEnd=function(i){if(this.allowMultipleSelection){var n=i.currentTarget,r=this.$ListBase[7];if(n!=r)return;this.setSelectedIndices(this.calculateSelectedIndices(n.itemIndex),!0),t.ItemTapEvent.dispatchItemTapEvent(this,t.ItemTapEvent.ITEM_TAP,n)}else e.prototype.onRendererTouchEnd.call(this,i)},i}(t.ListBase);t.List=e,__reflect(e.prototype,"eui.List")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.closeButton=null,t.moveArea=null,t.titleDisplay=null,t._title="",t.offsetPointX=0,t.offsetPointY=0,t.addEventListener(egret.TouchEvent.TOUCH_BEGIN,t.onWindowTouchBegin,t,!1,100),t}return __extends(i,e),i.prototype.onWindowTouchBegin=function(t){this.$parent.addChild(this)},Object.defineProperty(i.prototype,"elementsContent",{set:function(t){if(t)for(var e=t.length,i=0;e>i;i++)this.addChild(t[i])},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(t){this._title=t,this.titleDisplay&&(this.titleDisplay.text=this.title)},enumerable:!0,configurable:!0}),i.prototype.partAdded=function(t,i){e.prototype.partAdded.call(this,t,i),i==this.titleDisplay?this.titleDisplay.text=this._title:i==this.moveArea?this.moveArea.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this):i==this.closeButton&&this.closeButton.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onCloseButtonClick,this)},i.prototype.partRemoved=function(t,i){e.prototype.partRemoved.call(this,t,i),i==this.moveArea?this.moveArea.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this):i==this.closeButton&&this.closeButton.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onCloseButtonClick,this)},i.prototype.onCloseButtonClick=function(e){t.UIEvent.dispatchUIEvent(this,t.UIEvent.CLOSING,!0,!0)&&this.close()},i.prototype.close=function(){this.$parent&&this.$parent.removeChild(this)},i.prototype.onTouchBegin=function(t){this.$includeInLayout=!1,this.offsetPointX=this.x-t.$stageX,this.offsetPointY=this.y-t.$stageY,this.$stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this)},i.prototype.onTouchMove=function(t){this.x=t.$stageX+this.offsetPointX,this.y=t.$stageY+this.offsetPointY},i.prototype.onTouchEnd=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this)},i}(t.Component);t.Panel=e,__reflect(e.prototype,"eui.Panel"),t.registerProperty(e,"elementsContent","Array",!0)}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.thumb=null,i.labelDisplay=null,i._labelFunction=null,i._slideDuration=500,i._direction=t.Direction.LTR,i.slideToValue=0,i.animationValue=0,i.thumbInitX=0,i.thumbInitY=0,i.animation=new t.sys.Animation(i.animationUpdateHandler,i),i}return __extends(i,e),Object.defineProperty(i.prototype,"labelFunction",{get:function(){return this._labelFunction},set:function(t){this._labelFunction!=t&&(this._labelFunction=t,this.invalidateDisplayList())},enumerable:!0,configurable:!0}),i.prototype.valueToLabel=function(t,e){return null!=this.labelFunction?this._labelFunction(t,e):t+" / "+e},Object.defineProperty(i.prototype,"slideDuration",{get:function(){return this._slideDuration},set:function(t){t=0|+t,this._slideDuration!==t&&(this._slideDuration=t,this.animation.isPlaying&&(this.animation.stop(),this.setValue(this.slideToValue)))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(t){this._direction!=t&&(this.thumb&&(this.thumb.x=this.thumbInitX),this.thumb&&(this.thumb.y=this.thumbInitY),this._direction=t,this.invalidateDisplayList())},enumerable:!0,configurable:!0}),i.prototype.$setValue=function(t){if(this.value===t)return!1;var i=this.$Range,n=e.prototype.$setValue.call(this,t);if(this._slideDuration>0&&this.$stage){this.validateProperties();var r=this.animation;if(r.isPlaying&&(this.animationValue=this.slideToValue,this.invalidateDisplayList(),r.stop()),this.slideToValue=this.nearestValidValue(t,i[7]),this.slideToValue===this.animationValue)return n;var o=this._slideDuration*(Math.abs(this.animationValue-this.slideToValue)/(i[0]-i[2]));r.duration=o===1/0?0:o,r.from=this.animationValue,r.to=this.slideToValue,r.play()}else this.animationValue=this.value;return n},i.prototype.animationUpdateHandler=function(t){var e=this.$Range,i=this.nearestValidValue(t.currentValue,e[7]);this.animationValue=Math.min(e[0],Math.max(e[2],i)),this.invalidateDisplayList()},i.prototype.partAdded=function(t,i){e.prototype.partAdded.call(this,t,i),i===this.thumb&&(this.thumb.x&&(this.thumbInitX=this.thumb.x),this.thumb.y&&(this.thumbInitY=this.thumb.y),this.thumb.addEventListener(egret.Event.RESIZE,this.onThumbResize,this))},i.prototype.partRemoved=function(t,i){e.prototype.partRemoved.call(this,t,i),i===this.thumb&&this.thumb.removeEventListener(egret.Event.RESIZE,this.onThumbResize,this)},i.prototype.onThumbResize=function(t){this.updateSkinDisplayList()},i.prototype.updateSkinDisplayList=function(){var e=this.animation.isPlaying?this.animationValue:this.value,i=this.maximum,n=this.thumb;if(n){var r=n.width,o=n.height,s=Math.round(e/i*r);(0>s||s===1/0)&&(s=0);var a=Math.round(e/i*o);(0>a||a===1/0)&&(a=0);var h=n.$scrollRect;h||(h=egret.$TempRectangle),h.setTo(0,0,r,o);var l=n.x-h.x,u=n.y-h.y;switch(this._direction){case t.Direction.LTR:h.width=s,n.x=l;break;case t.Direction.RTL:h.width=s,h.x=r-s,n.x=h.x;break;case t.Direction.TTB:h.height=a,n.y=u;break;case t.Direction.BTT:h.height=a,h.y=o-a,n.y=h.y}n.scrollRect=h}this.labelDisplay&&(this.labelDisplay.text=this.valueToLabel(e,i))},i}(t.Range);t.ProgressBar=e,__reflect(e.prototype,"eui.ProgressBar")}(eui||(eui={}));var eui;!function(t){var e={},i=function(i){function n(){var t=i.call(this)||this;return t.$indexNumber=0,t.$radioButtonGroup=null,t._group=null,t.groupChanged=!1,t._groupName="radioGroup",t._value=null,t.groupName="radioGroup",t}return __extends(n,i),Object.defineProperty(n.prototype,"enabled",{get:function(){return this.$Component[3]?!this.$radioButtonGroup||this.$radioButtonGroup.$enabled:!1},set:function(t){this.$setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"group",{get:function(){if(!this._group&&this._groupName){var i=e[this._groupName];i||(i=new t.RadioButtonGroup,i.$name=this._groupName,e[this._groupName]=i),this._group=i}return this._group},set:function(t){this._group!=t&&(this.$radioButtonGroup&&this.$radioButtonGroup.$removeInstance(this,!1),this._group=t,this._groupName=t?this.group.$name:"radioGroup",this.groupChanged=!0,this.invalidateProperties(),this.invalidateDisplayList())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"groupName",{get:function(){return this._groupName},set:function(t){t&&""!=t&&(this._groupName=t,this.$radioButtonGroup&&this.$radioButtonGroup.$removeInstance(this,!1),this._group=null,this.groupChanged=!0,this.invalidateProperties(),this.invalidateDisplayList())},enumerable:!0,configurable:!0}),n.prototype.$setSelected=function(t){var e=i.prototype.$setSelected.call(this,t);return this.invalidateDisplayList(),e},Object.defineProperty(n.prototype,"value",{get:function(){return this._value},set:function(e){this._value!=e&&(this._value=e,this.$selected&&this.group&&t.PropertyEvent.dispatchPropertyEvent(this.group,t.PropertyEvent.PROPERTY_CHANGE,"selectedValue"))},enumerable:!0,configurable:!0}),n.prototype.commitProperties=function(){this.groupChanged&&(this.addToGroup(),this.groupChanged=!1),i.prototype.commitProperties.call(this)},n.prototype.updateDisplayList=function(t,e){i.prototype.updateDisplayList.call(this,t,e),this.group&&(this.$selected?this._group.$setSelection(this,!1):this.group.selection==this&&this._group.$setSelection(null,!1))},n.prototype.buttonReleased=function(){this.enabled&&!this.selected&&(this.$radioButtonGroup||this.addToGroup(),i.prototype.buttonReleased.call(this),this.group.$setSelection(this,!0))},n.prototype.addToGroup=function(){var t=this.group;return t&&t.$addInstance(this),t},n}(t.ToggleButton);t.RadioButton=i,__reflect(i.prototype,"eui.RadioButton")}(eui||(eui={}));var eui;!function(t){function e(t,i){var n=t.parent,r=i.parent;if(!n||!r)return 0;var o=t.$nestLevel,s=i.$nestLevel,a=0,h=0;return n==r&&(a=n.getChildIndex(t),h=r.getChildIndex(i)),o>s||a>h?1:s>o||h>a?-1:t==i?0:e(n,r)}var i=0,n=function(n){function r(){var t=n.call(this)||this;return t.$name=null,t.radioButtons=[],t.$enabled=!0,t._selectedValue=null,t._selection=null,t.$name="_radioButtonGroup"+i++,t}return __extends(r,n),r.prototype.getRadioButtonAt=function(t){return this.radioButtons[t]},Object.defineProperty(r.prototype,"enabled",{get:function(){return this.$enabled},set:function(t){if(t=!!t,this.$enabled!==t){this.$enabled=t;for(var e=this.radioButtons,i=e.length,n=0;i>n;n++)e[n].invalidateState()}},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"numRadioButtons",{get:function(){return this.radioButtons.length},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"selectedValue",{get:function(){return this.selection?null!=this.selection.value?this.selection.value:this.selection.label:null},set:function(e){if(this._selectedValue=e,null==e)return void this.$setSelection(null,!1);for(var i=this.numRadioButtons,n=0;i>n;n++){var r=this.radioButtons[n];if(r.value==e||r.label==e){this.changeSelection(n,!1),this._selectedValue=null,t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedValue");break}}},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"selection",{get:function(){return this._selection},set:function(t){this._selection!=t&&this.$setSelection(t,!1)},enumerable:!0,configurable:!0}),r.prototype.$addInstance=function(t){t.addEventListener(egret.Event.REMOVED_FROM_STAGE,this.removedHandler,this);var i=this.radioButtons;i.push(t),i.sort(e);for(var n=i.length,r=0;n>r;r++)i[r].$indexNumber=r;this._selectedValue&&(this.selectedValue=this._selectedValue),1==t.selected&&(this.selection=t),t.$radioButtonGroup=this,t.invalidateState()},r.prototype.$removeInstance=function(t,e){if(t)for(var i=!1,n=this.radioButtons,r=n.length,o=0;r>o;o++){var s=n[o];i?s.$indexNumber=s.$indexNumber-1:s==t&&(e&&t.addEventListener(egret.Event.ADDED_TO_STAGE,this.addedHandler,this),t==this._selection&&(this._selection=null),t.$radioButtonGroup=null,t.invalidateState(),this.radioButtons.splice(o,1),i=!0,o--,r--)}},r.prototype.$setSelection=function(e,i){if(this._selection==e)return!1;if(e){for(var n=this.numRadioButtons,r=0;n>r;r++)if(e==this.getRadioButtonAt(r)){this.changeSelection(r,i);break}}else this._selection&&(this._selection.selected=!1,this._selection=null,i&&this.dispatchEventWith(egret.Event.CHANGE));return t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedValue"),!0},r.prototype.changeSelection=function(t,e){var i=this.getRadioButtonAt(t);i&&i!=this._selection&&(this._selection&&(this._selection.selected=!1),this._selection=i,this._selection.selected=!0,e&&this.dispatchEventWith(egret.Event.CHANGE))},r.prototype.addedHandler=function(t){var e=t.target;e==t.currentTarget&&(e.removeEventListener(egret.Event.ADDED_TO_STAGE,this.addedHandler,this),this.$addInstance(e))},r.prototype.removedHandler=function(t){var e=t.target;e==t.currentTarget&&(e.removeEventListener(egret.Event.REMOVED_FROM_STAGE,this.removedHandler,this),this.$removeInstance(e,!0))},r}(egret.EventDispatcher);t.RadioButtonGroup=n,__reflect(n.prototype,"eui.RadioButtonGroup"),t.registerBindable(n.prototype,"selectedValue")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n){var r=t.call(this)||this;return r.$fillColor=0,r.$fillAlpha=1,r.$strokeColor=4473924,r.$strokeAlpha=1,r.$strokeWeight=0,r.$ellipseWidth=0,r.$ellipseHeight=0,r.touchChildren=!1,r.$graphics=new egret.Graphics,r.$graphics.$setTarget(r),r.width=e,r.height=i,r.fillColor=n,r}return __extends(e,t),e.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(8)},Object.defineProperty(e.prototype,"graphics",{get:function(){return this.$graphics},enumerable:!0,configurable:!0}),e.prototype.$measureContentBounds=function(t){this.$graphics&&t.setTo(0,0,this.width,this.height)},Object.defineProperty(e.prototype,"fillColor",{get:function(){return this.$fillColor},set:function(t){void 0!=t&&this.$fillColor!=t&&(this.$fillColor=t,this.invalidateDisplayList())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fillAlpha",{get:function(){return this.$fillAlpha},set:function(t){this.$fillAlpha!=t&&(this.$fillAlpha=t,this.invalidateDisplayList())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"strokeColor",{get:function(){return this.$strokeColor},set:function(t){this.$strokeColor!=t&&(this.$strokeColor=t,this.invalidateDisplayList())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"strokeAlpha",{get:function(){return this.$strokeAlpha},set:function(t){this.$strokeAlpha!=t&&(this.$strokeAlpha=t,this.invalidateDisplayList())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"strokeWeight",{get:function(){return this.$strokeWeight},set:function(t){this.$strokeWeight!=t&&(this.$strokeWeight=t,this.invalidateDisplayList())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ellipseWidth",{get:function(){return this.$ellipseWidth},set:function(t){this.$ellipseWidth!=t&&(this.$ellipseWidth=t,this.invalidateDisplayList())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ellipseHeight",{get:function(){return this.$ellipseHeight},set:function(t){this.$ellipseHeight!=t&&(this.$ellipseHeight=t,this.invalidateDisplayList())},enumerable:!0,configurable:!0}),e.prototype.updateDisplayList=function(t,e){var i=this.graphics;i.clear(),this.$strokeWeight>0&&(i.beginFill(this.$fillColor,0),i.lineStyle(this.$strokeWeight,this.$strokeColor,this.$strokeAlpha,!0,"normal","square","miter"),0==this.$ellipseWidth&&0==this.$ellipseHeight?i.drawRect(this.$strokeWeight/2,this.$strokeWeight/2,t-this.$strokeWeight,e-this.$strokeWeight):i.drawRoundRect(this.$strokeWeight/2,this.$strokeWeight/2,t-this.$strokeWeight,e-this.$strokeWeight,this.$ellipseWidth,this.$ellipseHeight),i.endFill()),i.beginFill(this.$fillColor,this.$fillAlpha),i.lineStyle(this.$strokeWeight,this.$strokeColor,0,!0,"normal","square","miter"),0==this.$ellipseWidth&&0==this.$ellipseHeight?i.drawRect(this.$strokeWeight,this.$strokeWeight,t-2*this.$strokeWeight,e-2*this.$strokeWeight):i.drawRoundRect(this.$strokeWeight,this.$strokeWeight,t-2*this.$strokeWeight,e-2*this.$strokeWeight,this.$ellipseWidth,this.$ellipseHeight),i.endFill()},e.prototype.$onRemoveFromStage=function(){t.prototype.$onRemoveFromStage.call(this),this.$graphics&&this.$graphics.$onRemoveFromStage()},e}(t.Component);t.Rect=e,__reflect(e.prototype,"eui.Rect")}(eui||(eui={}));var eui;!function(t){var e,i=function(i){function n(){var e=i.call(this)||this;e.$bounces=!0,e.horizontalScrollBar=null,e.verticalScrollBar=null;var n=new t.sys.TouchScroll(e.horizontalUpdateHandler,e.horizontalEndHandler,e),r=new t.sys.TouchScroll(e.verticalUpdateHandler,e.verticalEndHanlder,e);return e.$Scroller={0:"auto",1:"auto",2:null,3:0,4:0,5:!1,6:!1,7:!1,8:n,9:r,10:null,11:!1,12:!1},e}return __extends(n,i),Object.defineProperty(n.prototype,"bounces",{get:function(){return this.$bounces},set:function(t){this.$bounces=!!t;var e=this.$Scroller[8];e&&(e.$bounces=this.$bounces);var i=this.$Scroller[9];i&&(i.$bounces=this.$bounces)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"throwSpeed",{get:function(){return this.$Scroller[8].$scrollFactor},set:function(t){t=+t,0>t&&(t=0),this.$Scroller[8].$scrollFactor=t,this.$Scroller[9].$scrollFactor=t},enumerable:!0,configurable:!0}),n.prototype.$getThrowInfo=function(i,n){return e?(e.currentPos=i,e.toPos=n):e=new t.ScrollerThrowEvent(t.ScrollerThrowEvent.THROW,!1,!1,i,n),e},Object.defineProperty(n.prototype,"scrollPolicyV",{get:function(){return this.$Scroller[0]},set:function(t){var e=this.$Scroller;e[0]!=t&&(e[0]=t,this.checkScrollPolicy())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scrollPolicyH",{get:function(){return this.$Scroller[1]},set:function(t){var e=this.$Scroller;e[1]!=t&&(e[1]=t,this.checkScrollPolicy())},enumerable:!0,configurable:!0}),n.prototype.stopAnimation=function(){var e=this.$Scroller,i=e[9],n=e[8];i.animation.isPlaying?t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END):n.animation.isPlaying&&t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END),i.stop(),n.stop();var r=this.verticalScrollBar,o=this.horizontalScrollBar;r&&r.autoVisibility&&(r.visible=!1),o&&o.autoVisibility&&(o.visible=!1)},Object.defineProperty(n.prototype,"viewport",{get:function(){return this.$Scroller[10]},set:function(t){var e=this.$Scroller;t!=e[10]&&(this.uninstallViewport(),e[10]=t,e[11]=!1,this.installViewport())},enumerable:!0,configurable:!0}),n.prototype.installViewport=function(){var t=this.viewport;t&&(this.addChildAt(t,0),t.scrollEnabled=!0,t.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBeginCapture,this,!0),t.addEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEndCapture,this,!0),t.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onTouchTapCapture,this,!0),t.addEventListener(egret.Event.REMOVED,this.onViewPortRemove,this)),this.horizontalScrollBar&&(this.horizontalScrollBar.viewport=t),this.verticalScrollBar&&(this.verticalScrollBar.viewport=t)},n.prototype.uninstallViewport=function(){this.horizontalScrollBar&&(this.horizontalScrollBar.viewport=null),this.verticalScrollBar&&(this.verticalScrollBar.viewport=null);var t=this.viewport;t&&(t.scrollEnabled=!1,t.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBeginCapture,this,!0),t.removeEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEndCapture,this,!0),t.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onTouchTapCapture,this,!0),t.removeEventListener(egret.Event.REMOVED,this.onViewPortRemove,this),0==this.$Scroller[11]&&this.removeChild(t))},n.prototype.onViewPortRemove=function(t){t.target==this.viewport&&(this.$Scroller[11]=!0,this.viewport=null)},n.prototype.setSkin=function(t){i.prototype.setSkin.call(this,t);var e=this.viewport;e&&this.addChildAt(e,0)},n.prototype.onTouchBeginCapture=function(t){if(this.$stage){this.$Scroller[12]=!1;var e=this.checkScrollPolicy();e&&this.onTouchBegin(t)}},n.prototype.onTouchEndCapture=function(t){this.$Scroller[12]&&(t.$bubbles=!1,this.dispatchBubbleEvent(t),t.$bubbles=!0,t.stopPropagation(),this.onTouchEnd(t))},n.prototype.onTouchTapCapture=function(t){this.$Scroller[12]&&(t.$bubbles=!1,this.dispatchBubbleEvent(t),t.$bubbles=!0,t.stopPropagation())},n.prototype.checkScrollPolicy=function(){var t=this.$Scroller,e=t[10];if(!e)return!1;var i,n=e.$UIComponent;switch(t[1]){case"auto":i=e.contentWidth>n[10]||0!==e.scrollH?!0:!1;break;case"on":i=!0;break;case"off":i=!1}t[6]=i;var r;switch(t[0]){case"auto":r=e.contentHeight>n[11]||0!==e.scrollV?!0:!1;break;case"on":r=!0;break;case"off":r=!1}return t[7]=r,i||r},n.prototype.onTouchBegin=function(t){if(!t.isDefaultPrevented()&&this.checkScrollPolicy()){this.downTarget=t.target;var e=this.$Scroller;this.stopAnimation(),e[3]=t.$stageX,e[4]=t.$stageY,e[6]&&e[8].start(t.$stageX),e[7]&&e[9].start(t.$stageY);var i=this.$stage;this.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),i.addEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this,!0),this.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancel,this),this.addEventListener(egret.Event.REMOVED_FROM_STAGE,this.onRemoveListeners,this),this.tempStage=i}},n.prototype.onTouchMove=function(e){if(!e.isDefaultPrevented()){var i=this.$Scroller;if(!i[5]){var r=void 0;r=Math.abs(i[3]-e.$stageX)h;h++)if(r[h]===e){a=h;break}r.splice(0,r.length-a+1),s=0,this.$dispatchPropagationEvent(i,r,s),egret.Event.release(i)}},n.prototype.dispatchCancelEvent=function(t){var e=this.$Scroller[10];if(e){var i=egret.Event.create(egret.TouchEvent,egret.TouchEvent.TOUCH_CANCEL,t.bubbles,t.cancelable);i.$initTo(t.$stageX,t.$stageY,t.touchPointID);var n=this.downTarget;i.$setTarget(n);for(var r=this.$getPropagationList(n),o=r.length,s=.5*r.length,a=-1,h=0;o>h;h++)if(r[h]===e){a=h;break}r.splice(0,a+1-2),r.splice(r.length-1-a+2,a+1-2),s-=a+1,this.$dispatchPropagationEvent(i,r,s),egret.Event.release(i)}},n.prototype.onTouchEnd=function(t){var e=this.$Scroller;e[5]=!1,this.onRemoveListeners();var i=e[10],n=i.$UIComponent;e[8].isStarted()&&e[8].finish(i.scrollH,i.contentWidth-n[10]),e[9].isStarted()&&e[9].finish(i.scrollV,i.contentHeight-n[11])},n.prototype.onRemoveListeners=function(){var t=this.tempStage||this.$stage;this.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),t.removeEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this,!0),t.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),this.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancel,this),this.removeEventListener(egret.Event.REMOVED_FROM_STAGE,this.onRemoveListeners,this)},n.prototype.horizontalUpdateHandler=function(t){var e=this.$Scroller[10];e&&(e.scrollH=t),this.dispatchEventWith(egret.Event.CHANGE)},n.prototype.verticalUpdateHandler=function(t){var e=this.$Scroller[10];e&&(e.scrollV=t),this.dispatchEventWith(egret.Event.CHANGE)},n.prototype.horizontalEndHandler=function(){this.$Scroller[9].isPlaying()||this.onChangeEnd()},n.prototype.verticalEndHanlder=function(){this.$Scroller[8].isPlaying()||this.onChangeEnd()},n.prototype.onChangeEnd=function(){var e=this.$Scroller,i=this.horizontalScrollBar,n=this.verticalScrollBar;(i&&i.visible||n&&n.visible)&&(e[2]||(e[2]=new egret.Timer(200,1),e[2].addEventListener(egret.TimerEvent.TIMER_COMPLETE,this.onAutoHideTimer,this)),e[2].reset(),e[2].start()),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END)},n.prototype.onAutoHideTimer=function(t){var e=this.horizontalScrollBar,i=this.verticalScrollBar;e&&e.autoVisibility&&(e.visible=!1),i&&i.autoVisibility&&(i.visible=!1)},n.prototype.updateDisplayList=function(t,e){i.prototype.updateDisplayList.call(this,t,e);var n=this.viewport;n&&(n.setLayoutBoundsSize(t,e),n.setLayoutBoundsPosition(0,0))},n.prototype.partAdded=function(t,e){i.prototype.partAdded.call(this,t,e),e==this.horizontalScrollBar?(this.horizontalScrollBar.touchChildren=!1,this.horizontalScrollBar.touchEnabled=!1,this.horizontalScrollBar.viewport=this.viewport,this.horizontalScrollBar.autoVisibility&&(this.horizontalScrollBar.visible=!1)):e==this.verticalScrollBar&&(this.verticalScrollBar.touchChildren=!1,this.verticalScrollBar.touchEnabled=!1,this.verticalScrollBar.viewport=this.viewport,this.verticalScrollBar.autoVisibility&&(this.verticalScrollBar.visible=!1))},n.scrollThreshold=5,n}(t.Component);t.Scroller=i,__reflect(i.prototype,"eui.Scroller"),t.registerProperty(i,"viewport","eui.IViewport",!0)}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.maxWidth=1e5,i.minWidth=0,i.maxHeight=1e5,i.minHeight=0,i.width=0/0,i.height=0/0,i.$elementsContent=[],i._hostComponent=null,i.$stateValues=new t.sys.StateValues,i}return __extends(i,e),Object.defineProperty(i.prototype,"elementsContent",{set:function(t){this.$elementsContent=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hostComponent",{get:function(){return this._hostComponent},set:function(e){if(this._hostComponent!=e){this._hostComponent&&this._hostComponent.removeEventListener(egret.Event.ADDED_TO_STAGE,this.onAddedToStage,this),this._hostComponent=e;var i=this.$stateValues;i.parent=e,e&&(this.commitCurrentState(),this.$stateValues.intialized||(e.$stage?this.initializeStates(e.$stage):e.once(egret.Event.ADDED_TO_STAGE,this.onAddedToStage,this))),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"hostComponent")}},enumerable:!0,configurable:!0}),i.prototype.onAddedToStage=function(t){this.initializeStates(this._hostComponent.$stage)},i}(egret.EventDispatcher);t.Skin=e,__reflect(e.prototype,"eui.Skin"),t.sys.mixin(e,t.sys.StateClient),t.registerProperty(e,"elementsContent","Array",!0),t.registerProperty(e,"states","State[]"),t.registerBindable(e.prototype,"hostComponent")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.indexBeingUpdated=!1,t.requireSelection=!0,t.useVirtualLayout=!1,t}return __extends(i,e),i.prototype.createChildren=function(){if(!this.$layout){var i=new t.HorizontalLayout;i.gap=0,i.horizontalAlign=t.JustifyAlign.JUSTIFY,i.verticalAlign=t.JustifyAlign.CONTENT_JUSTIFY,this.$setLayout(i)}e.prototype.createChildren.call(this)},i.prototype.$setDataProvider=function(i){var n=this.$dataProvider;return n&&n instanceof t.ViewStack&&(n.removeEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onViewStackIndexChange,this),this.removeEventListener(egret.Event.CHANGE,this.onIndexChanged,this)),i&&i instanceof t.ViewStack&&(i.addEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onViewStackIndexChange,this),this.addEventListener(egret.Event.CHANGE,this.onIndexChanged,this)),e.prototype.$setDataProvider.call(this,i)},i.prototype.onIndexChanged=function(t){this.indexBeingUpdated=!0,this.$dataProvider.selectedIndex=this.selectedIndex,this.indexBeingUpdated=!1},i.prototype.onViewStackIndexChange=function(t){"selectedIndex"!=t.property||this.indexBeingUpdated||this.setSelectedIndex(this.$dataProvider.selectedIndex,!1)},i}(t.ListBase);t.TabBar=e,__reflect(e.prototype,"eui.TabBar")}(eui||(eui={}));var eui;!function(t){var e=egret.FocusEvent,i=function(i){function n(){var t=i.call(this)||this;return t.isFocus=!1,t.$TextInput={0:null,1:null,2:null,3:null,4:null,5:null,6:"",7:null,8:egret.TextFieldInputType.TEXT},t}return __extends(n,i),Object.defineProperty(n.prototype,"prompt",{get:function(){return this.promptDisplay?this.promptDisplay.text:this.$TextInput[0]},set:function(t){this.$TextInput[0]=t,this.promptDisplay&&(this.promptDisplay.text=t),this.invalidateProperties(),this.invalidateState()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"displayAsPassword",{get:function(){if(this.textDisplay)return this.textDisplay.displayAsPassword;var t=this.$TextInput[1];return t?t:!1},set:function(t){this.$TextInput[1]=t,this.textDisplay&&(this.textDisplay.displayAsPassword=t),this.invalidateProperties()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"inputType",{get:function(){return this.textDisplay?this.textDisplay.inputType:this.$TextInput[8]},set:function(t){this.$TextInput[8]=t,this.textDisplay&&(this.textDisplay.inputType=t),this.invalidateProperties()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"textColor",{get:function(){return this.textDisplay?this.textDisplay.textColor:this.$TextInput[2]},set:function(t){this.$TextInput[2]=t,this.textDisplay&&(this.textDisplay.textColor=t),this.invalidateProperties()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxChars",{get:function(){if(this.textDisplay)return this.textDisplay.maxChars;var t=this.$TextInput[3];return t?t:0},set:function(t){this.$TextInput[3]=t,this.textDisplay&&(this.textDisplay.maxChars=t),this.invalidateProperties()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxWidth",{get:function(){if(this.textDisplay)return this.textDisplay.maxWidth;var t=this.$TextInput[4];return t?t:1e5},set:function(t){this.$TextInput[4]=t,this.textDisplay&&(this.textDisplay.maxWidth=t),this.invalidateProperties()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxHeight",{get:function(){this.textDisplay;var t=this.$TextInput[5];return t?t:1e5},set:function(t){this.$TextInput[5]=t,this.textDisplay&&(this.textDisplay.maxHeight=t),this.invalidateProperties()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"text",{get:function(){return this.textDisplay?this.textDisplay.text:this.$TextInput[6]},set:function(t){this.$TextInput[6]=t,this.textDisplay&&(this.textDisplay.text=t),this.invalidateProperties(),this.invalidateState()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"restrict",{get:function(){return this.textDisplay?this.textDisplay.restrict:this.$TextInput[7]},set:function(t){this.$TextInput[7]=t,this.textDisplay&&(this.textDisplay.restrict=t),this.invalidateProperties()},enumerable:!0,configurable:!0}),n.prototype.focusInHandler=function(t){this.isFocus=!0,this.invalidateState()},n.prototype.focusOutHandler=function(t){this.isFocus=!1,this.invalidateState()},n.prototype.getCurrentState=function(){var t=this.skin;return!this.prompt||this.isFocus||this.text?this.enabled?"normal":"disabled":this.enabled&&t.hasState("normalWithPrompt")?"normalWithPrompt":!this.enabled&&t.hasState("disabledWithPrompt")?"disabledWithPrompt":void 0},n.prototype.partAdded=function(n,r){i.prototype.partAdded.call(this,n,r);var o=this.$TextInput;r==this.textDisplay?(this.textDisplayAdded(),this.textDisplay instanceof t.EditableText&&(this.textDisplay.addEventListener(e.FOCUS_IN,this.focusInHandler,this),this.textDisplay.addEventListener(e.FOCUS_OUT,this.focusOutHandler,this))):r==this.promptDisplay&&o[0]&&(this.promptDisplay.text=o[0])},n.prototype.partRemoved=function(n,r){i.prototype.partRemoved.call(this,n,r),r==this.textDisplay?(this.textDisplayRemoved(),this.textDisplay instanceof t.EditableText&&(this.textDisplay.removeEventListener(e.FOCUS_IN,this.focusInHandler,this),this.textDisplay.removeEventListener(e.FOCUS_OUT,this.focusOutHandler,this))):r==this.promptDisplay&&(this.$TextInput[0]=this.promptDisplay.text) -},n.prototype.textDisplayAdded=function(){var t=this.$TextInput;t[1]&&(this.textDisplay.displayAsPassword=t[1]),t[2]&&(this.textDisplay.textColor=t[2]),t[3]&&(this.textDisplay.maxChars=t[3]),t[4]&&(this.textDisplay.maxWidth=t[4]),t[5]&&(this.textDisplay.maxHeight=t[5]),t[6]&&(this.textDisplay.text=t[6]),t[7]&&(this.textDisplay.restrict=t[7]),t[8]&&(this.textDisplay.inputType=t[8])},n.prototype.textDisplayRemoved=function(){var t=this.$TextInput;t[1]=this.textDisplay.displayAsPassword,t[2]=this.textDisplay.textColor,t[3]=this.textDisplay.maxChars,t[4]=this.textDisplay.maxWidth,t[5]=this.textDisplay.maxHeight,t[6]=this.textDisplay.text,t[7]=this.textDisplay.restrict,t[8]=this.textDisplay.inputType},n}(t.Component);t.TextInput=i,__reflect(i.prototype,"eui.TextInput")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){return t.call(this)||this}return __extends(e,t),e}(t.ToggleButton);t.CheckBox=e,__reflect(e.prototype,"eui.CheckBox")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){return t.call(this)||this}return __extends(e,t),e}(t.ToggleButton);t.ToggleSwitch=e,__reflect(e.prototype,"eui.ToggleSwitch")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.addEventListener(egret.Event.ADDED_TO_STAGE,e.onAddToStage,e),e.addEventListener(egret.Event.REMOVED_FROM_STAGE,e.onRemoveFromStage,e),e}return __extends(e,t),e.prototype.onAddToStage=function(t){this.$stage.addEventListener(egret.Event.RESIZE,this.onResize,this),this.onResize()},e.prototype.onRemoveFromStage=function(t){this.$stage.removeEventListener(egret.Event.RESIZE,this.onResize,this)},e.prototype.onResize=function(t){var e=this.$stage;this.$setWidth(e.$stageWidth),this.$setHeight(e.$stageHeight)},e}(t.Group);t.UILayer=e,__reflect(e.prototype,"eui.UILayer")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.updateDisplayList=function(e,i){t.prototype.updateDisplayList.call(this,e,i);var n=this.thumb,r=this.$viewport;if(n&&r){var o=egret.$TempRectangle;n.getPreferredBounds(o);var s=o.height,a=o.x,h=r.scrollV,l=r.contentHeight,u=r.height;if(0>=h){var p=s*(1- -h/(.5*u));p=Math.max(5,Math.round(p)),n.setLayoutBoundsSize(0/0,p),n.setLayoutBoundsPosition(a,0)}else if(h>=l-u){var p=s*(1-(h-l+u)/(.5*u));p=Math.max(5,Math.round(p)),n.setLayoutBoundsSize(0/0,p),n.setLayoutBoundsPosition(a,i-p)}else{var c=(i-s)*h/(l-u);n.setLayoutBoundsSize(0/0,0/0),n.setLayoutBoundsPosition(a,c)}}},e.prototype.onPropertyChanged=function(t){switch(t.property){case"scrollV":case"contentHeight":this.invalidateDisplayList()}},e}(t.ScrollBarBase);t.VScrollBar=e,__reflect(e.prototype,"eui.VScrollBar")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){return t.call(this)||this}return __extends(e,t),e.prototype.pointToValue=function(t,e){if(!this.thumb||!this.track)return 0;var i=this.$Range,n=i[0]-i[2],r=this.getThumbRange();return i[2]+(0!=r?(r-e)/r*n:0)},e.prototype.getThumbRange=function(){var t=egret.$TempRectangle;this.track.getLayoutBounds(t);var e=t.height;return this.thumb.getLayoutBounds(t),e-t.height},e.prototype.updateSkinDisplayList=function(){if(this.thumb&&this.track){var t=this.$Range,e=this.getThumbRange(),i=t[0]-t[2],n=i>0?e-(this.pendingValue-t[2])/i*e:0,r=this.track.localToGlobal(0,n,egret.$TempPoint),o=r.x,s=r.y,a=this.thumb.$parent.globalToLocal(o,s,egret.$TempPoint).y,h=egret.$TempRectangle,l=h.height;if(this.thumb.getLayoutBounds(h),this.thumb.setLayoutBoundsPosition(h.x,Math.round(a)),this.trackHighlight){var u=this.trackHighlight.$parent.globalToLocal(o,s,egret.$TempPoint).y;this.trackHighlight.y=Math.round(u+l),this.trackHighlight.height=Math.round(e-u)}}},e}(t.SliderBase);t.VSlider=e,__reflect(e.prototype,"eui.VSlider")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var i=e.call(this)||this;return i._selectedChild=null,i.proposedSelectedIndex=t.ListBase.NO_PROPOSED_SELECTION,i._selectedIndex=-1,i}return __extends(i,e),Object.defineProperty(i.prototype,"layout",{get:function(){return this.$layout},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectedChild",{get:function(){var t=this.selectedIndex;return t>=0&&t=0&&e0?0==n?(this.proposedSelectedIndex=0,this.invalidateProperties()):this.setSelectedIndex(0):this.setSelectedIndex(-1):r>n&&this.setSelectedIndex(r-1),t.CollectionEvent.dispatchCollectionEvent(this,t.CollectionEvent.COLLECTION_CHANGE,t.CollectionEventKind.REMOVE,n,-1,[i.name])},i.prototype.commitProperties=function(){e.prototype.commitProperties.call(this),this.proposedSelectedIndex!=t.ListBase.NO_PROPOSED_SELECTION&&(this.commitSelection(this.proposedSelectedIndex),this.proposedSelectedIndex=t.ListBase.NO_PROPOSED_SELECTION)},i.prototype.commitSelection=function(t){t>=0&&tn;n++)if(e[n].name==t)return n;return-1},i}(t.Group);t.ViewStack=e,__reflect(e.prototype,"eui.ViewStack",["eui.ICollection","egret.IEventDispatcher"]),t.registerBindable(e.prototype,"selectedIndex")}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t){return-.5*(Math.cos(Math.PI*t)-1)}var i=function(){function t(t,i){this.easerFunction=e,this.isPlaying=!1,this.duration=500,this.currentValue=0,this.from=0,this.to=0,this.startTime=0,this.endFunction=null,this.updateFunction=t,this.thisObject=i}return t.prototype.play=function(){this.stop(),this.start()},t.prototype.start=function(){this.isPlaying=!1,this.currentValue=0,this.startTime=egret.getTimer(),this.doInterval(this.startTime),egret.startTick(this.doInterval,this)},t.prototype.stop=function(){this.isPlaying=!1,this.startTime=0,egret.stopTick(this.doInterval,this)},t.prototype.doInterval=function(t){var e=t-this.startTime;this.isPlaying||(this.isPlaying=!0);var i=this.duration,n=0==i?1:Math.min(e,i)/i;this.easerFunction&&(n=this.easerFunction(n)),this.currentValue=this.from+(this.to-this.from)*n,this.updateFunction&&this.updateFunction.call(this.thisObject,this);var r=e>=i;return r&&this.stop(),r&&this.endFunction&&this.endFunction.call(this.thisObject,this),!0},t}();t.Animation=i,__reflect(i.prototype,"eui.sys.Animation")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}return t.prototype.getTheme=function(t,e,i,n){function r(t){var i=t.target;e.call(n,i.response)}function o(t){i.call(n)}var s=new egret.HttpRequest;s.addEventListener(egret.Event.COMPLETE,r,n),s.addEventListener(egret.IOErrorEvent.IO_ERROR,o,n),s.responseType=egret.HttpResponseType.TEXT,s.open(t),s.send()},t}();t.DefaultThemeAdapter=e,__reflect(e.prototype,"eui.DefaultThemeAdapter",["eui.IThemeAdapter"])}(eui||(eui={}));var eui;!function(t){function e(t,i){var n=Object.getOwnPropertyDescriptor(t,i);if(n)return n;var r=Object.getPrototypeOf(t);return r?e(r,i):null}function i(t,e){for(var i=t[n],r=i.length,o=0;r>o;o+=2){var s=i[o],a=i[o+1];s.call(a,e)}}var n="__listeners__",r="__bindables__",o=0,s=function(){function s(t,e,i,n){this.isExecuting=!1,this.property=t,this.handler=e,this.next=n,this.thisObject=i}return s.watch=function(t,e,i,n){if(e.length>0){var r=e.shift(),o=s.watch(null,e,i,n),a=new s(r,i,n,o);return a.reset(t),a}return null},s.checkBindable=function(s,a){var h=s[r];if(h&&-1!=h.indexOf(a))return!0;var l=egret.is(s,"egret.IEventDispatcher");l||s[n]||(s[n]=[]);var u=e(s,a);if(u&&u.set&&u.get){var p=u.set;u.set=function(e){this[a]!=e&&(p.call(this,e),l?t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,a):i(this,a))}}else{if(u&&(u.get||u.set))return!1;o++;var c="_"+o+a;s[c]=u?u.value:null,u={enumerable:!0,configurable:!0},u.get=function(){return this[c]},u.set=function(e){this[c]!=e&&(this[c]=e,l?t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,a):i(this,a))}}Object.defineProperty(s,a,u),t.registerBindable(s,a)},s.prototype.unwatch=function(){this.reset(null),this.handler=null,this.next&&(this.next.handler=null)},s.prototype.getValue=function(){return this.next?this.next.getValue():this.getHostPropertyValue()},s.prototype.setHandler=function(t,e){this.handler=t,this.thisObject=e,this.next&&this.next.setHandler(t,e)},s.prototype.reset=function(e){var i=this.host;if(i)if(egret.is(i,"egret.IEventDispatcher"))i.removeEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.wrapHandler,this);else{var r=i[n],o=r.indexOf(this);r.splice(o-1,2)}if(this.host=e,e)if(s.checkBindable(e,this.property),egret.is(e,"egret.IEventDispatcher"))e.addEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.wrapHandler,this,!1,100);else{var r=e[n];r.push(this.onPropertyChange),r.push(this)}this.next&&this.next.reset(this.getHostPropertyValue())},s.prototype.getHostPropertyValue=function(){return this.host?this.host[this.property]:null},s.prototype.wrapHandler=function(t){this.onPropertyChange(t.property)},s.prototype.onPropertyChange=function(t){if(t==this.property&&!this.isExecuting)try{this.isExecuting=!0,this.next&&this.next.reset(this.getHostPropertyValue()),this.handler.call(this.thisObject,this.getValue())}finally{this.isExecuting=!1}},s}();t.Watcher=s,__reflect(s.prototype,"eui.Watcher")}(eui||(eui={}));var eui;!function(t){function e(e){for(var i=e[0],n=i instanceof t.Watcher?i.getValue():i,r=e.length,o=1;r>o;o++){var s=e[o];s instanceof t.Watcher&&(s=s.getValue()),n+=s}return n}var i=function(){function i(){}return i.bindProperty=function(e,i,n,r){var o=t.Watcher.watch(e,i,null,null);if(o){var s=function(t){n[r]=t};o.setHandler(s,null),s(o.getValue())}return o},i.bindHandler=function(e,i,n,r){var o=t.Watcher.watch(e,i,n,r);return o&&n.call(r,o.getValue()),o},i.$bindProperties=function(n,r,o,s,a){if(1==r.length&&1==o.length)return i.bindProperty(n,r[0].split("."),s,a);for(var h,l=function(){s[a]=e(r)},u=o.length,p=0;u>p;p++){var c=o[p],d=r[c].split(".");h=t.Watcher.watch(n,d,null,null),h&&(r[c]=h,h.setHandler(l,null))}return l(),h},i}();t.Binding=i,__reflect(i.prototype,"eui.Binding")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(t){var i=e.call(this)||this;return t?i._source=t:i._source=[],i}return __extends(i,e),Object.defineProperty(i.prototype,"source",{get:function(){return this._source},set:function(e){e||(e=[]),this._source=e,this.dispatchCoEvent(t.CollectionEventKind.RESET)},enumerable:!0,configurable:!0}),i.prototype.refresh=function(){this.dispatchCoEvent(t.CollectionEventKind.REFRESH)},Object.defineProperty(i.prototype,"length",{get:function(){return this._source.length},enumerable:!0,configurable:!0}),i.prototype.addItem=function(e){this._source.push(e),this.dispatchCoEvent(t.CollectionEventKind.ADD,this._source.length-1,-1,[e])},i.prototype.addItemAt=function(e,i){0>i||i>this._source.length,this._source.splice(i,0,e),this.dispatchCoEvent(t.CollectionEventKind.ADD,i,-1,[e])},i.prototype.getItemAt=function(t){return this._source[t]},i.prototype.getItemIndex=function(t){for(var e=this._source.length,i=0;e>i;i++)if(this._source[i]===t)return i;return-1},i.prototype.itemUpdated=function(e){var i=this.getItemIndex(e);-1!=i&&this.dispatchCoEvent(t.CollectionEventKind.UPDATE,i,-1,[e])},i.prototype.removeAll=function(){var e=this._source.concat();this._source=[],this.dispatchCoEvent(t.CollectionEventKind.REMOVE,0,-1,e)},i.prototype.removeItemAt=function(e){if(!(0>e||e>=this._source.length)){var i=this._source.splice(e,1)[0];return this.dispatchCoEvent(t.CollectionEventKind.REMOVE,e,-1,[i]),i}},i.prototype.replaceItemAt=function(e,i){if(!(0>i||i>=this._source.length)){var n=this._source.splice(i,1,e)[0];return this.dispatchCoEvent(t.CollectionEventKind.REPLACE,i,-1,[e],[n]),n}},i.prototype.replaceAll=function(t){t||(t=[]);for(var e=t.length,i=this._source.length,n=e;i>n;n++)this.removeItemAt(e);for(var n=0;e>n;n++)n>=i?this.addItemAt(t[n],n):this.replaceItemAt(t[n],n);this._source=t},i.prototype.dispatchCoEvent=function(e,i,n,r,o){t.CollectionEvent.dispatchCollectionEvent(this,t.CollectionEvent.COLLECTION_CHANGE,e,i,n,r,o)},i}(egret.EventDispatcher);t.ArrayCollection=e,__reflect(e.prototype,"eui.ArrayCollection",["eui.ICollection","egret.IEventDispatcher"]),t.registerProperty(e,"source","Array",!0)}(eui||(eui={}));var eui;!function(t){var e=t.sys.UIComponentImpl,i=function(i){function n(){var t=i.call(this)||this;return t._widthConstraint=0/0,t.$isShowPrompt=!1,t.$promptColor=6710886,t.$isFocusIn=!1,t.$isTouchCancle=!1,t.initializeUIValues(),t.type=egret.TextFieldType.INPUT,t.$EditableText={0:null,1:16777215,2:!1},t}return __extends(n,i),n.prototype.$invalidateTextField=function(){i.prototype.$invalidateTextField.call(this),this.invalidateSize()},n.prototype.$setWidth=function(t){var n=i.prototype.$setWidth.call(this,t),r=e.prototype.$setWidth.call(this,t);return n&&r},n.prototype.$setHeight=function(t){var n=i.prototype.$setHeight.call(this,t),r=e.prototype.$setHeight.call(this,t);return n&&r},n.prototype.$getText=function(){var t=i.prototype.$getText.call(this);return t==this.$EditableText[0]&&(t=""),t},n.prototype.$setText=function(e){var n=this.$EditableText[0];(n!=e||null==n)&&(this.$isShowPrompt=!1,this.textColor=this.$EditableText[1],this.displayAsPassword=this.$EditableText[2]),this.$isFocusIn||(""==e||null==e)&&(e=n,this.$isShowPrompt=!0,i.prototype.$setTextColor.call(this,this.$promptColor),i.prototype.$setDisplayAsPassword.call(this,!1));var r=i.prototype.$setText.call(this,e);return t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"text"),r},n.prototype.$onAddToStage=function(e,i){t.sys.UIComponentImpl.prototype.$onAddToStage.call(this,e,i),this.addEventListener(egret.FocusEvent.FOCUS_IN,this.onfocusIn,this),this.addEventListener(egret.FocusEvent.FOCUS_OUT,this.onfocusOut,this),this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this),this.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this)},n.prototype.$onRemoveFromStage=function(){i.prototype.$onRemoveFromStage.call(this),this.removeEventListener(egret.FocusEvent.FOCUS_IN,this.onfocusIn,this),this.removeEventListener(egret.FocusEvent.FOCUS_OUT,this.onfocusOut,this),this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this),this.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this)},Object.defineProperty(n.prototype,"prompt",{get:function(){return this.$EditableText[0]},set:function(t){var e=this.$EditableText,i=e[0];if(i!=t){e[0]=t;var n=this.text;n&&n!=i||this.showPromptText()}},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"promptColor",{get:function(){return this.$promptColor},set:function(t){if(t=0|+t,this.$promptColor!=t){this.$promptColor=t;var e=this.text;e&&e!=this.$EditableText[0]||this.showPromptText()}},enumerable:!0,configurable:!0}),n.prototype.onfocusOut=function(){this.$isFocusIn=!1,this.text||this.showPromptText()},n.prototype.onTouchBegin=function(){this.$isTouchCancle=!1},n.prototype.onTouchCancle=function(){this.$isTouchCancle=!0},n.prototype.onfocusIn=function(){if(!egret.Capabilities.isMobile&&this.$isTouchCancle)return void this.inputUtils.stageText.$hide();this.$isFocusIn=!0,this.$isShowPrompt=!1,this.displayAsPassword=this.$EditableText[2];var t=this.$EditableText,e=this.text;e&&e!=t[0]||(this.textColor=t[1],this.text="")},n.prototype.showPromptText=function(){var t=this.$EditableText;this.$isShowPrompt=!0,i.prototype.$setTextColor.call(this,this.$promptColor),i.prototype.$setDisplayAsPassword.call(this,!1),this.text=t[0]},n.prototype.$setTextColor=function(t){return t=0|+t,this.$EditableText[1]=t,this.$isShowPrompt||i.prototype.$setTextColor.call(this,t),!0},n.prototype.$setDisplayAsPassword=function(t){return this.$EditableText[2]=t,this.$isShowPrompt||i.prototype.$setDisplayAsPassword.call(this,t),!0},n.prototype.createChildren=function(){this.onfocusOut()},n.prototype.childrenCreated=function(){},n.prototype.commitProperties=function(){},n.prototype.measure=function(){var t=this.$UIComponent,e=this.$TextField,n=e[3],r=0/0;isNaN(this._widthConstraint)?isNaN(t[8])?1e5!=t[13]&&(r=t[13]):r=t[8]:(r=this._widthConstraint,this._widthConstraint=0/0),i.prototype.$setWidth.call(this,r),this.setMeasuredSize(this.textWidth,this.textHeight),i.prototype.$setWidth.call(this,n)},n.prototype.updateDisplayList=function(t,e){i.prototype.$setWidth.call(this,t),i.prototype.$setHeight.call(this,e)},n.prototype.invalidateParentLayout=function(){},n.prototype.setMeasuredSize=function(t,e){},n.prototype.invalidateProperties=function(){},n.prototype.validateProperties=function(){},n.prototype.invalidateSize=function(){},n.prototype.validateSize=function(t){},n.prototype.invalidateDisplayList=function(){},n.prototype.validateDisplayList=function(){},n.prototype.validateNow=function(){},n.prototype.setLayoutBoundsSize=function(t,i){if(e.prototype.setLayoutBoundsSize.call(this,t,i),!isNaN(t)&&t!==this._widthConstraint&&0!=t){var n=this.$UIComponent;isNaN(n[9])&&t!=n[16]&&(this._widthConstraint=t,this.invalidateSize())}},n.prototype.setLayoutBoundsPosition=function(t,e){},n.prototype.getLayoutBounds=function(t){},n.prototype.getPreferredBounds=function(t){},n}(egret.TextField);t.EditableText=i,__reflect(i.prototype,"eui.EditableText",["eui.UIComponent","egret.DisplayObject","eui.IDisplayText"]),t.sys.implementUIComponent(i,egret.TextField),t.registerBindable(i.prototype,"text")}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t){var e=t-1;return e*e*e+1}var i=4,n=[1,1.33,1.66,2],r=2.33,o=.02,s=.998,a=.95,h=Math.log(s),l=function(){function l(i,n,r){this.$scrollFactor=1,this.previousTime=0,this.velocity=0,this.previousVelocity=[],this.currentPosition=0,this.previousPosition=0,this.currentScrollPos=0,this.maxScrollPos=0,this.offsetPoint=0,this.$bounces=!0,this.started=!0,this.updateFunction=i,this.endFunction=n,this.target=r,this.animation=new t.Animation(this.onScrollingUpdate,this),this.animation.endFunction=this.finishScrolling,this.animation.easerFunction=e}return l.prototype.isPlaying=function(){return this.animation.isPlaying},l.prototype.stop=function(){this.animation.stop(),egret.stopTick(this.onTick,this),this.started=!1},l.prototype.isStarted=function(){return this.started},l.prototype.start=function(t){this.started=!0,this.velocity=0,this.previousVelocity.length=0,this.previousTime=egret.getTimer(),this.previousPosition=this.currentPosition=t,this.offsetPoint=t,egret.startTick(this.onTick,this)},l.prototype.update=function(t,e,i){e=Math.max(e,0),this.currentPosition=t,this.maxScrollPos=e;var n=this.offsetPoint-t,r=n+i;this.offsetPoint=t,0>r&&(this.$bounces?r-=.5*n:r=0),r>e&&(this.$bounces?r-=.5*n:r=e),this.currentScrollPos=r,this.updateFunction.call(this.target,r)},l.prototype.finish=function(t,e){egret.stopTick(this.onTick,this),this.started=!1;for(var i=this.velocity*r,l=this.previousVelocity,u=l.length,p=r,c=0;u>c;c++){var d=n[c];i+=l[0]*d,p+=d}var f=i/p,g=Math.abs(f),y=0,v=0;if(g>o)if(v=t+(f-o)/h*2*this.$scrollFactor,0>v||v>e)for(v=t;Math.abs(f)>o;)v-=f,f*=0>v||v>e?s*a:s,y++;else y=Math.log(o/g)/h;else v=t;if(this.target.$getThrowInfo){var m=this.target.$getThrowInfo(t,v);v=m.toPos}y>0?(this.$bounces||(0>v?v=0:v>e&&(v=e)),this.throwTo(v,y)):this.finishScrolling()},l.prototype.onTick=function(t){var e=t-this.previousTime;if(e>10){var n=this.previousVelocity;n.length>=i&&n.shift(),this.velocity=(this.currentPosition-this.previousPosition)/e,n.push(this.velocity),this.previousTime=t,this.previousPosition=this.currentPosition}return!0},l.prototype.finishScrolling=function(t){var e=this.currentScrollPos,i=this.maxScrollPos,n=e;0>e&&(n=0),e>i&&(n=i),this.throwTo(n,300)},l.prototype.throwTo=function(t,e){void 0===e&&(e=500);var i=this.currentScrollPos;if(i==t)return void this.endFunction.call(this.target);var n=this.animation;n.duration=e,n.from=i,n.to=t,n.play()},l.prototype.onScrollingUpdate=function(t){this.currentScrollPos=t.currentValue,this.updateFunction.call(this.target,t.currentValue)},l}();t.TouchScroll=l,__reflect(l.prototype,"eui.sys.TouchScroll")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}return t.LTR="ltr",t.RTL="rtl",t.TTB="ttb",t.BTT="btt",t}();t.Direction=e,__reflect(e.prototype,"eui.Direction")}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}return t.AUTO="auto",t.OFF="off",t.ON="on",t}();t.ScrollPolicy=e,__reflect(e.prototype,"eui.ScrollPolicy")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(t,i){var n=e.call(this)||this;return n.delayList=[],n.skinMap={},n.$styles={},n.initialized=!t,i&&egret.registerImplementation("eui.Theme",n),n.$configURL=t,n.load(t),n}return __extends(i,e),i.prototype.load=function(e){var i=this;t.getTheme(e,function(t){return i.onConfigLoaded(t)})},i.prototype.onConfigLoaded=function(t){var e;if("string"==typeof t)try{e=JSON.parse(t)}catch(i){egret.$error(3e3)}else e=t;if(e&&e.skins)for(var n=this.skinMap,r=e.skins,o=Object.keys(r),s=o.length,a=0;s>a;a++){var h=o[a];n[h]||this.mapSkin(h,r[h])}e.styles&&(this.$styles=e.styles);var l=e.paths;for(var u in l)EXML.update(u,l[u]);e.exmls&&0!=e.exmls.length?e.exmls[0].gjs?(e.exmls.forEach(function(t){return EXML.$parseURLContentAsJs(t.path,t.gjs,t.className)}),this.onLoaded()):e.exmls[0].content?(e.exmls.forEach(function(t){return EXML.$parseURLContent(t.path,t.content)}),this.onLoaded()):EXML.$loadAll(e.exmls,this.onLoaded,this,!0):this.onLoaded()},i.prototype.onLoaded=function(t,e){this.initialized=!0,this.handleDelayList(),this.dispatchEventWith(egret.Event.COMPLETE)},i.prototype.handleDelayList=function(){for(var t=this.delayList,e=t.length,i=0;e>i;i++){var n=t[i];if(!n.$Component[5]){var r=this.getSkinName(n);r&&(n.$Component[1]=r,n.$parseSkinName())}}t.length=0},i.prototype.getSkinName=function(t){if(!this.initialized)return-1==this.delayList.indexOf(t)&&this.delayList.push(t),"";var e=this.skinMap,i=e[t.hostComponentKey];return i||(i=this.findSkinName(t)),i},i.prototype.findSkinName=function(t){if(!t)return"";var e=t.__class__;if(void 0===e)return"";var i=this.skinMap[e];return i||"eui.Component"==e?i:this.findSkinName(Object.getPrototypeOf(t))},i.prototype.mapSkin=function(t,e){this.skinMap[t]=e},i.prototype.$getStyleConfig=function(t){return this.$styles[t]},i}(egret.EventDispatcher);t.Theme=e,__reflect(e.prototype,"eui.Theme")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n,r,o,s,a,h){var l=t.call(this,e,i,n)||this;return l.$initTo(r,o,s,a,h),l}return __extends(e,t),e.prototype.$initTo=function(t,e,i,n,r){this.kind=t,this.location=0|+e,this.oldLocation=0|+i,this.items=n||[],this.oldItems=r||[]},e.prototype.clean=function(){t.prototype.clean.call(this),this.items=this.oldItems=null},e.dispatchCollectionEvent=function(t,i,n,r,o,s,a){if(!t.hasEventListener(i))return!0;var h=egret.Event.create(e,i);h.$initTo(n,r,o,s,a);var l=t.dispatchEvent(h);return egret.Event.release(h),l},e.COLLECTION_CHANGE="collectionChange",e}(egret.Event);t.CollectionEvent=e,__reflect(e.prototype,"eui.CollectionEvent")}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}return t.ADD="add",t.REFRESH="refresh",t.REMOVE="remove",t.REPLACE="replace",t.RESET="reset",t.UPDATE="update",t}();t.CollectionEventKind=e,__reflect(e.prototype,"eui.CollectionEventKind")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.item=null,e.itemRenderer=null,e.itemIndex=-1,e}return __extends(e,t),e.prototype.clean=function(){t.prototype.clean.call(this),this.item=this.itemRenderer=null},e.dispatchItemTapEvent=function(t,i,n){if(!t.hasEventListener(i))return!0;var r=egret.Event.create(e,i);r.item=n.data,r.itemIndex=n.itemIndex,r.itemRenderer=n;var o=t.dispatchEvent(r);return egret.Event.release(r),o},e.ITEM_TAP="itemTap",e}(egret.Event);t.ItemTapEvent=e,__reflect(e.prototype,"eui.ItemTapEvent")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n,r){var o=t.call(this,e,i,n)||this;return o.property=r,o}return __extends(e,t),e.dispatchPropertyEvent=function(t,i,n){if(!t.hasEventListener(i))return!0;var r=egret.Event.create(e,i);r.property=n;var o=t.dispatchEvent(r);return egret.Event.release(r),o},e.PROPERTY_CHANGE="propertyChange",e}(egret.Event);t.PropertyEvent=e,__reflect(e.prototype,"eui.PropertyEvent")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n,r,o){var s=t.call(this,e,i,n)||this;return r=+r,o=+o,s.currentPos=r,s.toPos=o,s}return __extends(e,t),e.THROW="throw",e}(egret.Event);t.ScrollerThrowEvent=e,__reflect(e.prototype,"eui.ScrollerThrowEvent")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n){return t.call(this,e,i,n)||this}return __extends(e,t),e.dispatchUIEvent=function(t,i,n,r){if(!t.hasEventListener(i))return!0;var o=egret.Event.create(e,i,n,r),s=t.dispatchEvent(o);return egret.Event.release(o),s},e.CREATION_COMPLETE="creationComplete",e.CHANGE_END="changeEnd",e.CHANGE_START="changeStart",e.CLOSING="closing",e.MOVE="move",e}(egret.Event);t.UIEvent=e,__reflect(e.prototype,"eui.UIEvent")}(eui||(eui={}));var eui;!function(t){var e;!function(t){var e="eui.State",i="eui.AddItems",n="eui.SetProperty",r="eui.SetStateProperty",o="eui.Binding.$bindProperties",s=function(){function t(){this.indent=0}return t.prototype.toCode=function(){return""},t.prototype.getIndent=function(t){void 0===t&&(t=this.indent);for(var e="",i=0;t>i;i++)e+=" ";return e},t}();t.CodeBase=s,__reflect(s.prototype,"eui.sys.CodeBase");var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.className="",e.superClass="",e.innerClassBlock=[],e.variableBlock=[],e.functionBlock=[],e}return __extends(e,t),e.prototype.addInnerClass=function(t){-1==this.innerClassBlock.indexOf(t)&&this.innerClassBlock.push(t)},e.prototype.addVariable=function(t){-1==this.variableBlock.indexOf(t)&&this.variableBlock.push(t)},e.prototype.getVariableByName=function(t){for(var e=this.variableBlock,i=e.length,n=0;i>n;n++){var r=e[n];if(r.name==t)return r}return null},e.prototype.addFunction=function(t){-1==this.functionBlock.indexOf(t)&&this.functionBlock.push(t)},e.prototype.getFuncByName=function(t){for(var e=this.functionBlock,i=e.length,n=0;i>n;n++){var r=e[n];if(r.name==t)return r}return null},e.prototype.toCode=function(){var t=this.indent,e=this.getIndent(t),i=this.getIndent(t+1),n=this.getIndent(t+2),r=e+"(function (";r+=this.superClass?"_super) {\n"+i+"__extends("+this.className+", _super);\n":") {\n";for(var o=this.innerClassBlock,s=o.length,a=0;s>a;a++){var h=o[a];h.indent=t+1,r+=i+"var "+h.className+" = "+h.toCode()+"\n\n"}r+=i+"function "+this.className+"() {\n",this.superClass&&(r+=n+"_super.call(this);\n");var l=this.variableBlock;s=l.length;for(var a=0;s>a;a++){var u=l[a];u.defaultValue&&(r+=n+u.toCode()+"\n")}if(this.constructCode){var p=this.constructCode.toCode().split("\n");s=p.length;for(var a=0;s>a;a++){var c=p[a];r+=n+c+"\n"}}r+=i+"}\n",r+=i+"var _proto = "+this.className+".prototype;\n\n";var d=this.functionBlock;s=d.length;for(var a=0;s>a;a++){var f=d[a];f.indent=t+1,r+=f.toCode()+"\n"}return r+=i+"return "+this.className+";\n"+e,r+=this.superClass?"})("+this.superClass+");":"})();"},e}(s);t.EXClass=a,__reflect(a.prototype,"eui.sys.EXClass");var h=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.lines=[],e}return __extends(e,t),e.prototype.addVar=function(t,e){var i=e?" = "+e:"";this.addCodeLine("var "+t+i+";")},e.prototype.addAssignment=function(t,e,i){var n=i?"."+i:"";this.addCodeLine(t+n+" = "+e+";")},e.prototype.addReturn=function(t){this.addCodeLine("return "+t+";")},e.prototype.addEmptyLine=function(){this.addCodeLine("")},e.prototype.startIf=function(t){this.addCodeLine("if("+t+")"),this.startBlock()},e.prototype.startElse=function(){this.addCodeLine("else"),this.startBlock()},e.prototype.startElseIf=function(t){this.addCodeLine("else if("+t+")"),this.startBlock()},e.prototype.startBlock=function(){this.addCodeLine("{"),this.indent++},e.prototype.endBlock=function(){this.indent--,this.addCodeLine("}")},e.prototype.doFunction=function(t,e){var i=e.join(",");this.addCodeLine(t+"("+i+")")},e.prototype.addCodeLine=function(t){this.lines.push(this.getIndent()+t)},e.prototype.addCodeLineAt=function(t,e){this.lines.splice(e,0,this.getIndent()+t)},e.prototype.containsCodeLine=function(t){return-1!=this.lines.indexOf(t)},e.prototype.concat=function(t){this.lines=this.lines.concat(t.lines)},e.prototype.toCode=function(){return this.lines.join("\n")},e}(s);t.EXCodeBlock=h,__reflect(h.prototype,"eui.sys.EXCodeBlock");var l=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.codeBlock=null,e.isGet=!1,e.name="",e}return __extends(e,t),e.prototype.toCode=function(){var t,e=this.getIndent(),i=this.getIndent(this.indent+1),n=e;if(this.isGet?(t=this.getIndent(this.indent+2),n+='Object.defineProperty(_proto, "skinParts", {\n',n+=i+"get: function () {\n"):(t=i,n+="_proto."+this.name+" = function () {\n"),this.codeBlock)for(var r=this.codeBlock.toCode().split("\n"),o=r.length,s=0;o>s;s++){var a=r[s];n+=t+a+"\n"}return n+=this.isGet?i+"},\n"+i+"enumerable: true,\n"+i+"configurable: true\n"+e+"});":e+"};"},e}(s);t.EXFunction=l,__reflect(l.prototype,"eui.sys.EXFunction");var u=function(t){function e(e,i){var n=t.call(this)||this;return n.indent=2,n.name=e,n.defaultValue=i,n}return __extends(e,t),e.prototype.toCode=function(){return this.defaultValue?"this."+this.name+" = "+this.defaultValue+";":""},e}(s);t.EXVariable=u,__reflect(u.prototype,"eui.sys.EXVariable");var p=function(t){function i(e,i){var n=t.call(this)||this;return n.name="",n.stateGroups=[],n.addItems=[],n.setProperty=[],n.name=e,i&&(n.stateGroups=i),n}return __extends(i,t),i.prototype.addOverride=function(t){t instanceof c?this.addItems.push(t):this.setProperty.push(t)},i.prototype.toCode=function(){for(var t=this.getIndent(1),i="new "+e+' ("'+this.name+'",\n'+t+"[\n",n=0,r=!0,o=this.addItems.concat(this.setProperty);nl;l++){var u=a[l];a[l]=t+t+u}i+=a.join("\n"),n++}return i+="\n"+t+"])"},i}(s);t.EXState=p,__reflect(p.prototype,"eui.sys.EXState");var c=function(t){function e(e,i,n,r){var o=t.call(this)||this; -return o.target=e,o.property=i,o.position=n,o.relativeTo=r,o}return __extends(e,t),e.prototype.toCode=function(){var t="new "+i+'("'+this.target+'","'+this.property+'",'+this.position+',"'+this.relativeTo+'")';return t},e}(s);t.EXAddItems=c,__reflect(c.prototype,"eui.sys.EXAddItems");var d=function(t){function e(e,i,n){var r=t.call(this)||this;return r.target=e,r.name=i,r.value=n,r}return __extends(e,t),e.prototype.toCode=function(){return"new "+n+'("'+this.target+'","'+this.name+'",'+this.value+")"},e}(s);t.EXSetProperty=d,__reflect(d.prototype,"eui.sys.EXSetProperty");var f=function(t){function e(e,i,n,r){var o=t.call(this)||this;return e=e?"this."+e:"this",o.target=e,o.property=i,o.templates=n,o.chainIndex=r,o}return __extends(e,t),e.prototype.toCode=function(){var t=this.templates.join(","),e=this.chainIndex.join(",");return"new "+r+"(this, ["+t+"],["+e+"],"+this.target+',"'+this.property+'")'},e}(s);t.EXSetStateProperty=f,__reflect(f.prototype,"eui.sys.EXSetStateProperty");var g=function(t){function e(e,i,n,r){var o=t.call(this)||this;return o.target=e,o.property=i,o.templates=n,o.chainIndex=r,o}return __extends(e,t),e.prototype.toCode=function(){var t=this.templates.join(","),e=this.chainIndex.join(",");return o+"(this, ["+t+"],["+e+"],"+this.target+',"'+this.property+'")'},e}(s);t.EXBinding=g,__reflect(g.prototype,"eui.sys.EXBinding")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=t.sys.UIComponentImpl,i=function(i){function n(t){var e=i.call(this)||this;return e.$createChildrenCalled=!1,e.$fontChanged=!1,e._widthConstraint=0/0,e._heightConstraint=0/0,e.initializeUIValues(),e.text=t,e}return __extends(n,i),n.prototype.$invalidateContentBounds=function(){i.prototype.$invalidateContentBounds.call(this),this.invalidateSize()},n.prototype.$setWidth=function(t){var n=i.prototype.$setWidth.call(this,t),r=e.prototype.$setWidth.call(this,t);return n&&r},n.prototype.$setHeight=function(t){var n=i.prototype.$setHeight.call(this,t),r=e.prototype.$setHeight.call(this,t);return n&&r},n.prototype.$setText=function(e){var n=i.prototype.$setText.call(this,e);return t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"text"),n},n.prototype.$setFont=function(t){return this.$fontForBitmapLabel==t?!1:(this.$fontForBitmapLabel=t,this.$createChildrenCalled?this.$parseFont():this.$fontChanged=!0,this.$fontStringChanged=!0,!0)},n.prototype.$parseFont=function(){this.$fontChanged=!1;var e=this.$fontForBitmapLabel;"string"==typeof e?t.getAssets(e,function(t){this.$setFontData(t,e)},this):this.$setFontData(e)},n.prototype.$setFontData=function(t,e){return e&&e!=this.$fontForBitmapLabel?void 0:t==this.$font?!1:(this.$font=t,this.$invalidateContentBounds(),!0)},n.prototype.createChildren=function(){this.$fontChanged&&this.$parseFont(),this.$createChildrenCalled=!0},n.prototype.childrenCreated=function(){},n.prototype.commitProperties=function(){},n.prototype.measure=function(){var t=this.$UIComponent,e=this.$textFieldWidth,n=this.$textFieldHeight,r=0/0;isNaN(this._widthConstraint)?isNaN(t[8])?1e5!=t[13]&&(r=t[13]):r=t[8]:(r=this._widthConstraint,this._widthConstraint=0/0),i.prototype.$setWidth.call(this,r);var o=0/0;isNaN(this._heightConstraint)?isNaN(t[9])?1e5!=t[15]&&(o=t[15]):o=t[9]:(o=this._heightConstraint,this._heightConstraint=0/0),i.prototype.$setHeight.call(this,o),this.setMeasuredSize(this.textWidth,this.textHeight),i.prototype.$setWidth.call(this,e),i.prototype.$setHeight.call(this,n)},n.prototype.updateDisplayList=function(t,e){i.prototype.$setWidth.call(this,t),i.prototype.$setHeight.call(this,e)},n.prototype.invalidateParentLayout=function(){},n.prototype.setMeasuredSize=function(t,e){},n.prototype.invalidateProperties=function(){},n.prototype.validateProperties=function(){},n.prototype.invalidateSize=function(){},n.prototype.validateSize=function(t){},n.prototype.invalidateDisplayList=function(){},n.prototype.validateDisplayList=function(){},n.prototype.validateNow=function(){},n.prototype.setLayoutBoundsSize=function(t,i){if(e.prototype.setLayoutBoundsSize.call(this,t,i),!isNaN(t)&&t!==this._widthConstraint&&0!=t){var n=this.$UIComponent;isNaN(n[9])&&t!=n[16]&&(this._widthConstraint=t,this._heightConstraint=i,this.invalidateSize())}},n.prototype.setLayoutBoundsPosition=function(t,e){},n.prototype.getLayoutBounds=function(t){},n.prototype.getPreferredBounds=function(t){},n}(egret.BitmapText);t.BitmapLabel=i,__reflect(i.prototype,"eui.BitmapLabel",["eui.UIComponent","egret.DisplayObject","eui.IDisplayText"]),t.sys.implementUIComponent(i,egret.BitmapText),t.registerBindable(i.prototype,"text")}(eui||(eui={}));var EXML;!function(t){function e(t){return l.parse(t)}function i(t,e,i,n){if(void 0===n&&(n=!1),n&&t in p)return void(e&&e.call(i,p[t],t));var r=u[t];return r?void r.push([e,i]):(u[t]=[[e,i]],void h(t,a))}function n(t,e,i,n){if(void 0===n&&(n=!1),!t||0==t.length)return void(e&&e.call(i,[],t));var o=[];t.forEach(function(s){var a=function(n,s){o[n]=s,o.push(n),o.length==t.length&&r(t,o,e,i)};return n&&s in p?void a(s,""):void h(s,a)})}function r(t,e,i,n){var r=[];t.forEach(function(t,i){if(t in p&&!e[t])return void(r[i]=p[t]);var n=e[t],o=a(t,n);r[i]=o}),i&&i.call(n,r,t)}function o(t,e){p[t]=e;var i=u[t];delete u[t];for(var n=i?i.length:0,r=0;n>r;r++){var o=i[r];o[0]&&o[1]&&o[0].call(o[1],e,t)}}function s(t,e,i){var n=null;e&&(n=l.$parseCode(e,i),o(t,n))}function a(t,i){var n=null;if(i&&"string"==typeof i)try{n=e(i)}catch(r){console.error(t+"\n"+r.message)}if(i&&i.prototype&&(n=i),t){n&&(p[t]=n);var o=u[t];delete u[t];for(var s=o?o.length:0,a=0;s>a;a++){var h=o[a];h[0]&&h[1]&&h[0].call(h[1],n,t)}}return n}function h(t,e){var i=t;-1==t.indexOf("://")&&(i=c+t);var n=function(i){i||(i=""),e(t,i)};eui.getTheme(i,n)}var l=new eui.sys.EXMLParser,u={},p={},c="";Object.defineProperty(t,"prefixURL",{get:function(){return c},set:function(t){c=t},enumerable:!0,configurable:!0}),t.parse=e,t.load=i,t.$loadAll=n,t.update=o,t.$parseURLContentAsJs=s,t.$parseURLContent=a}(EXML||(EXML={}));var eui;!function(t){var e;!function(t){function e(t){return"[object Array]"===Object.prototype.toString.call(t)}function i(t){var e=egret.getDefinitionByName(t);return e?e.prototype:null}function n(t){if(!t)return null;var e;return e=new t}t.NS_S="http://ns.egret.com/eui",t.NS_W="http://ns.egret.com/wing";var r=["Point","Matrix","Rectangle"],o=["Array","boolean","string","number"],s="eui.",a=0,h={},l=function(){function l(){}return l.prototype.$describe=function(t){if(!t)return null;var i=Object.getPrototypeOf(t);if(!i)return null;var r;if(i.hasOwnProperty("__hashCode__")&&(r=h[i.__hashCode__]))return r;var s=Object.getPrototypeOf(i);if(!s)return null;var l=n(s.constructor),u=this.$describe(l);if(u){var p=function(){};p.prototype=u,r=new p}else r={};for(var c=Object.keys(i).concat(Object.keys(t)),d=c.length,f=t.__meta__,g=0;d>g;g++){var y=c[g];if("constructor"!=y&&"_"!=y.charAt(0)&&"$"!=y.charAt(0)){var v=void 0;if(f&&f[y])v=f[y];else if(e(t[y]))v="Array";else{if(v=typeof t[y],"function"==v)continue;-1==o.indexOf(v)&&(v="any")}r[y]=v}}return Object.getPrototypeOf(s)&&(i.__hashCode__=a++,h[i.__hashCode__]=r),r},l.prototype.getClassNameById=function(e,n){if(n==t.NS_S){if("Object"==e)return e;if(-1!=r.indexOf(e))return"egret."+e}var a="";return-1!=o.indexOf(e)?e:(n==t.NS_W||(a=n&&n!=t.NS_S?n.substring(0,n.length-1)+e:s+e),i(a)||(a=""),a)},l.prototype.getDefaultPropById=function(t,e){var n,r=this.getClassNameById(t,e),o=i(r);return o&&(n=o.__defaultProperty__),n?n:""},l.prototype.getPropertyType=function(t,e){if("Object"==e)return"any";var r="",o=i(e);if(o){if(!o.hasOwnProperty("__hashCode__")){var s=egret.getDefinitionByName(e),a=n(s);if(!a)return r;this.$describe(a)}var l=h[o.__hashCode__];l&&(r=l[t])}return r},l}();t.EXMLConfig=l,__reflect(l.prototype,"eui.sys.EXMLConfig")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){egret.$locale_strings=egret.$locale_strings||{},egret.$locale_strings.en_US=egret.$locale_strings.en_US||{};var e=egret.$locale_strings.en_US;e[2001]="EXML parsing error {0}: EXML file can't be found ",e[2002]="EXML parsing error : invalid XML file:\n{0}",e[2003]="EXML parsing error {0}: the class definitions corresponding to nodes can't be found \n {1}",e[2004]="EXML parsing error {0}: nodes cannot contain id property with the same name \n {1}",e[2005]="EXML parsing error {0}: property with the name of '{1}' does not exist on the node, or the property does not have a default value: \n {2}",e[2006]="EXML parsing error {0}: undefined view state name: '{1}' \n {2}",e[2007]="EXML parsing error {0}: only UIComponent objects within the container can use the includeIn and excludeFrom properties\n {1}",e[2008]="EXML parsing error {0}: fail to assign values of '{1}' class to property: '{2}' \n {3}",e[2009]="EXML parsing error {0}: only one ID can be referenced in the node property value '{}' label; and complex expression is not allowed to use \n {1}",e[2010]="EXML parsing error {0}: ID referenced by property: '{1}': '{2}' does not exist \n {3}",e[2011]="EXML parsing error {0}: fail to assign more than one child nodes to the same property: '{1}' \n {2}",e[2012]="EXML parsing error {0}: no default property exists on the node; and you must explicitly declare the property name that the child node is assigned to \n {1}",e[2013]="EXML parsing error {0}: view state grammar is not allowed to use on property nodes of Array class \n {1} ",e[2014]="EXML parsing error {0}: assigning the skin class itself to the node property is not allowed \n {1}",e[2015]="EXML parsing error {0}: class definition referenced by node: {1} does not exist \n {2}",e[2016]="EXML parsing error {0}: format error of 'scale9Grid' property value on the node: {1}",e[2017]="EXML parsing error {0}: namespace prefix missing on the node: {1}",e[2018]="EXML parsing error {0}: format error of 'skinName' property value on the node: {1}",e[2019]="EXML parsing error {0}: the container’s child item must be visible nodes: {1}",e[2020]="EXML parsing error {0}: for child nodes in w: Declarations, the includeIn and excludeFrom properties are not allowed to use \n {1}",e[2021]="Compile errors in {0}, the attribute name: {1}, the attribute value: {2}.",e[2022]="EXML parsing error: there contains illegal characters in the id `{0}`",e[2101]="EXML parsing warnning : fail to register the class property : {0},there is already a class with the same name in the global,please try to rename the class name for the exml. \n {1}",e[2102]="EXML parsing warnning {0}: no child node can be found on the property code \n {1}",e[2103]="EXML parsing warnning {0}: the same property '{1}' on the node is assigned multiple times \n {2}",e[2104]="EXML parsing warnning, Instantiate class {0} error,the parameters of its constructor method must be empty.",e[2201]="BasicLayout doesn't support virtualization.",e[2202]="parse skinName error,the parsing result of skinName must be a instance of eui.Skin.",e[2203]="Could not find the skin class '{0}'。",e[2204]="Undefined event.kind type (CollectionEventKind) = '{0}'.",e[2301]="parse source failed,could not find asset from URL:{0} ."}(eui||(eui={}));var eui;!function(t){egret.$locale_strings=egret.$locale_strings||{},egret.$locale_strings.zh_CN=egret.$locale_strings.zh_CN||{};var e=egret.$locale_strings.zh_CN;e[2001]="EXML解析错误 {0}: 找不到EXML文件",e[2002]="EXML解析错误: 不是有效的XML文件:\n{0}",e[2003]="EXML解析错误 {0}: 无法找到节点所对应的类定义\n{1}",e[2004]="EXML解析错误 {0}: 节点不能含有同名的id属性\n{1}",e[2005]="EXML解析错误 {0}: 节点上不存在名为'{1}'的属性,或者该属性没有初始值:\n{2}",e[2006]="EXML解析错误 {0}: 未定义的视图状态名称:'{1}'\n{2}",e[2007]="EXML解析错误 {0}: 只有处于容器内的 UIComponent 对象可以使用includeIn和excludeFrom属性\n{1}",e[2008]="EXML解析错误 {0}: 无法将'{1}'类型的值赋给属性:'{2}'\n{3}",e[2009]="EXML解析错误 {0}: 在节点属性值的‘{}’标签内只能引用一个ID,不允许使用复杂表达式\n{1}",e[2010]="EXML解析错误 {0}: 属性:'{1}'所引用的ID: '{2}'不存在\n{3}",e[2011]="EXML解析错误 {0}: 无法将多个子节点赋值给同一个属性:'{1}'\n{2}",e[2012]="EXML解析错误 {0}: 节点上不存在默认属性,必须显式声明子节点要赋值到的属性名\n{1}",e[2013]="EXML解析错误 {0}: 类型为Array的属性节点上不允许使用视图状态语法\n{1}",e[2014]="EXML解析错误 {0}: 不允许将皮肤类自身赋值给节点属性\n{1}",e[2015]="EXML解析错误 {0}: 节点引用的类定义:{1}不存在\n{2}",e[2016]="EXML解析错误 {0}: 节点上'scale9Grid'属性值的格式错误:{1}",e[2017]="EXML解析错误 {0}: 节点上缺少命名空间前缀:{1}",e[2018]="EXML解析错误 {0}: 节点上'skinName'属性值的格式错误:{1}",e[2019]="EXML解析错误 {0}: 容器的子项必须是可视节点:{1}",e[2020]="EXML解析错误 {0}: 在w:Declarations内的子节点,不允许使用includeIn和excludeFrom属性\n{1}",e[2021]="{0} 中存在编译错误,属性名 : {1},属性值 : {2}",e[2022]="EXML解析错误: id `{0}` 中含有非法字符",e[2101]="EXML解析警告: 在EXML根节点上声明的 class 属性: {0} 注册失败,所对应的类已经存在,请尝试重命名要注册的类名。\n{1}",e[2102]="EXML解析警告 {0}: 在属性节点上找不到任何子节点\n{1}",e[2103]="EXML解析警告 {0}: 节点上的同一个属性'{1}'被多次赋值\n{2}",e[2104]="EXML解析警告,无法直接实例化自定义组件:{0} ,在EXML中使用的自定义组件必须要能直接被实例化,否则可能导致后续EXML解析报错。",e[2201]="BasicLayout 不支持虚拟化。",e[2202]="皮肤解析出错,属性 skinName 的值必须要能够解析为一个 eui.Skin 的实例。",e[2203]="找不到指定的皮肤类 '{0}'。",e[2204]="未定义的event.kind类型(CollectionEventKind) = '{0}'.",e[2301]="素材解析失败,找不到URL:{0} 所对应的资源。"}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){return e.call(this)||this}return __extends(i,e),i.prototype.measure=function(){e.prototype.measure.call(this),t.sys.measure(this.$target)},i.prototype.updateDisplayList=function(i,n){e.prototype.updateDisplayList.call(this,i,n);var r=this.$target,o=t.sys.updateDisplayList(r,i,n);r.setContentSize(Math.ceil(o.x),Math.ceil(o.y))},i}(t.LayoutBase);t.BasicLayout=e,__reflect(e.prototype,"eui.BasicLayout")}(eui||(eui={})),function(t){var e;!function(t){function e(t,e){if(!t||"number"==typeof t)return t;var i=t,n=i.indexOf("%");if(-1==n)return+i;var r=+i.substring(0,n);return.01*r*e}function i(t){if(t){for(var e=0,i=0,n=egret.$TempRectangle,o=t.numChildren,s=0;o>s;s++){var a=t.getChildAt(s);if(egret.is(a,r)&&a.$includeInLayout){var h=a.$UIComponent,l=+h[4],u=+h[5],p=+h[0],c=+h[1],d=+h[2],f=+h[3],g=void 0,y=void 0;a.getPreferredBounds(n),isNaN(p)||isNaN(c)?isNaN(l)?isNaN(p)&&isNaN(c)?g=n.x:(g=isNaN(p)?0:p,g+=isNaN(c)?0:c):g=2*Math.abs(l):g=p+c,isNaN(d)||isNaN(f)?isNaN(u)?isNaN(d)&&isNaN(f)?y=n.y:(y=isNaN(d)?0:d,y+=isNaN(f)?0:f):y=2*Math.abs(u):y=d+f;var v=n.width,m=n.height;e=Math.ceil(Math.max(e,g+v)),i=Math.ceil(Math.max(i,y+m))}}t.setMeasuredSize(e,i)}}function n(t,i,n){if(t){for(var o=t.numChildren,s=0,a=0,h=egret.$TempRectangle,l=0;o>l;l++){var u=t.getChildAt(l);if(egret.is(u,r)&&u.$includeInLayout){var p=u.$UIComponent,c=e(p[4],.5*i),d=e(p[5],.5*n),f=e(p[0],i),g=e(p[1],i),y=e(p[2],n),v=e(p[3],n),m=p[6],$=p[7],E=0/0,C=0/0;isNaN(f)||isNaN(g)?isNaN(m)||(E=Math.round(i*Math.min(.01*m,1))):E=i-g-f,isNaN(y)||isNaN(v)?isNaN($)||(C=Math.round(n*Math.min(.01*$,1))):C=n-v-y,u.setLayoutBoundsSize(E,C),u.getLayoutBounds(h);var _=h.width,b=h.height,T=0/0,S=0/0;T=isNaN(c)?isNaN(f)?isNaN(g)?h.x:i-_-g:f:Math.round((i-_)/2+c),S=isNaN(d)?isNaN(y)?isNaN(v)?h.y:n-b-v:y:Math.round((n-b)/2+d),u.setLayoutBoundsPosition(T,S),s=Math.max(s,T+_),a=Math.max(a,S+b)}}return egret.$TempPoint.setTo(s,a)}}var r="eui.UIComponent";t.measure=i,t.updateDisplayList=n}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}return t.LEFT="left",t.JUSTIFY_USING_GAP="justifyUsingGap",t.JUSTIFY_USING_WIDTH="justifyUsingWidth",t}();t.ColumnAlign=e,__reflect(e.prototype,"eui.ColumnAlign")}(eui||(eui={}));var eui;!function(t){var e="eui.UIComponent",i=function(i){function n(){return null!==i&&i.apply(this,arguments)||this}return __extends(n,i),n.prototype.measureReal=function(){for(var t=this.$target,i=t.numElements,n=i,r=0,o=0,s=egret.$TempRectangle,a=0;i>a;a++){var h=t.getElementAt(a);egret.is(h,e)&&h.$includeInLayout?(h.getPreferredBounds(s),r+=s.width,o=Math.max(o,s.height)):n--}r+=(n-1)*this.$gap;var l=this.$paddingLeft+this.$paddingRight,u=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(r+l,o+u)},n.prototype.measureVirtual=function(){for(var t=this.$target,i=this.$typicalWidth,n=this.getElementTotalSize(),r=Math.max(this.maxElementSize,this.$typicalHeight),o=egret.$TempRectangle,s=this.endIndex,a=this.elementSizeTable,h=this.startIndex;s>h;h++){var l=t.getElementAt(h);egret.is(l,e)&&l.$includeInLayout&&(l.getPreferredBounds(o),n+=o.width,n-=isNaN(a[h])?i:a[h],r=Math.max(r,o.height))}var u=this.$paddingLeft+this.$paddingRight,p=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(n+u,r+p)},n.prototype.updateDisplayListReal=function(i,n){var r=this.$target,o=this.$paddingLeft,s=this.$paddingRight,a=this.$paddingTop,h=this.$paddingBottom,l=this.$gap,u=Math.max(0,i-o-s),p=Math.max(0,n-a-h),c=this.$horizontalAlign==t.JustifyAlign.JUSTIFY,d=this.$verticalAlign==t.JustifyAlign.JUSTIFY||this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY,f=0;d||(this.$verticalAlign==egret.VerticalAlign.MIDDLE?f=.5:this.$verticalAlign==egret.VerticalAlign.BOTTOM&&(f=1));var g,y,v,m=r.numElements,$=m,E=o,C=a,_=0,b=0,T=[],S=u,x=this.maxElementSize,I=egret.$TempRectangle;for(g=0;m>g;g++){var P=r.getElementAt(g);if(egret.is(P,e)&&P.$includeInLayout)if(P.getPreferredBounds(I),x=Math.max(x,I.height),c)_+=I.width;else{var L=P.$UIComponent;isNaN(L[6])?S-=I.width:(b+=L[6],v=new t.sys.ChildInfo,v.layoutElement=P,v.percent=L[6],v.min=L[12],v.max=L[13],T.push(v))}else $--}S-=l*($-1),S=S>0?S:0;var N,O=u-_-l*($-1),A=$,B={};if(c){if(0>O){for(N=S/$,g=0;m>g;g++)y=r.getElementAt(g),egret.is(y,e)&&y.$includeInLayout&&(y.getPreferredBounds(I),I.width<=N&&(S-=I.width,A--));S=S>0?S:0}}else if(b>0){this.flexChildrenProportionally(u,S,b,T);var D=0,R=T.length;for(g=0;R>g;g++){v=T[g];var M=Math.round(v.size+D);D+=v.size-M,B[v.layoutElement.$hashCode]=M,S-=M}S=S>0?S:0}this.$horizontalAlign==egret.HorizontalAlign.CENTER?E=o+.5*S:this.$horizontalAlign==egret.HorizontalAlign.RIGHT&&(E=o+S);var w=o,V=a,H=0,z=0,U=Math.ceil(p);this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY&&(U=Math.ceil(Math.max(p,x)));var k,F,G=0;for(g=0;m>g;g++){var j=0;if(y=r.getElementAt(g),egret.is(y,e)&&y.$includeInLayout){if(y.getPreferredBounds(I),k=0/0,c?(F=0/0,O>0?F=S*I.width/_:0>O&&I.width>N&&(F=S/A),isNaN(F)||(k=Math.round(F+G),G+=F-k)):k=B[y.$hashCode],d)C=a,y.setLayoutBoundsSize(k,U),y.getLayoutBounds(I);else{var W=0/0,L=y.$UIComponent;if(!isNaN(y.percentHeight)){var X=Math.min(100,L[7]);W=Math.round(p*X*.01)}y.setLayoutBoundsSize(k,W),y.getLayoutBounds(I),j=(p-I.height)*f,j=j>0?j:0,C=a+j}y.setLayoutBoundsPosition(Math.round(E),Math.round(C)),H=Math.ceil(I.width),z=Math.ceil(I.height),w=Math.max(w,E+H),V=Math.max(V,C+z),E+=H+l}}this.maxElementSize=x,r.setContentSize(w+s,V+h)},n.prototype.updateDisplayListVirtual=function(i,n){var r=this.$target;this.indexInViewCalculated?this.indexInViewCalculated=!1:this.getIndexInView();var o,s=this.$paddingRight,a=this.$paddingTop,h=this.$paddingBottom,l=this.$gap,u=r.numElements;if(-1==this.startIndex||-1==this.endIndex)return o=this.getStartPosition(u)-l+s,void r.setContentSize(o,r.contentHeight);var p=this.endIndex;r.setVirtualElementIndicesInView(this.startIndex,p);var c=this.$verticalAlign==t.JustifyAlign.JUSTIFY||this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY,d=this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY,f=0;c||(this.$verticalAlign==egret.VerticalAlign.MIDDLE?f=.5:this.$verticalAlign==egret.VerticalAlign.BOTTOM&&(f=1));var g,y=egret.$TempRectangle,v=Math.max(0,n-a-h),m=Math.ceil(v),$=this.$typicalHeight,E=this.$typicalWidth,C=this.maxElementSize,_=Math.max($,this.maxElementSize);if(d){for(var b=this.startIndex;p>=b;b++)g=r.getVirtualElementAt(b),egret.is(g,e)&&g.$includeInLayout&&(g.getPreferredBounds(y),C=Math.max(C,y.height));m=Math.ceil(Math.max(v,C))}for(var T,S=0,x=0,I=0,P=!1,L=this.elementSizeTable,N=this.startIndex;p>=N;N++){var O=0;g=r.getVirtualElementAt(N),egret.is(g,e)&&g.$includeInLayout&&(g.getPreferredBounds(y),d||(C=Math.max(C,y.height)),c?(x=a,g.setLayoutBoundsSize(0/0,m),g.getLayoutBounds(y)):(g.getLayoutBounds(y),O=(v-y.height)*f,O=O>0?O:0,x=a+O),I=Math.max(I,y.height),P||(T=isNaN(L[N])?E:L[N],T!=y.width&&(P=!0)),L[N]=y.width,S=this.getStartPosition(N),g.setLayoutBoundsPosition(Math.round(S),Math.round(x)))}I+=a+h,o=this.getStartPosition(u)-l+s,this.maxElementSize=C,r.setContentSize(o,I),(P||_s;s++){var a=o[s];isNaN(a)&&(a=i),n+=a+r}return n},n.prototype.getElementSize=function(t){if(this.$useVirtualLayout){var e=this.elementSizeTable[t];return isNaN(e)&&(e=this.$typicalWidth),e}return this.$target?this.$target.getElementAt(t).width:0},n.prototype.getElementTotalSize=function(){for(var t=this.$typicalWidth,e=this.$gap,i=0,n=this.$target.numElements,r=this.elementSizeTable,o=0;n>o;o++){var s=r[o];isNaN(s)&&(s=t),i+=s+e}return i-=e},n.prototype.elementAdded=function(t){this.useVirtualLayout&&(i.prototype.elementAdded.call(this,t),this.elementSizeTable.splice(t,0,this.$typicalWidth))},n.prototype.getIndexInView=function(){var t=this.$target;if(!t||0==t.numElements)return this.startIndex=this.endIndex=-1,!1;var e=t.$UIComponent;if(e[10]<=0||e[11]<=0)return this.startIndex=this.endIndex=-1,!1;var i=t.numElements,n=this.getStartPosition(i-1)+this.elementSizeTable[i-1]+this.$paddingRight,r=t.scrollH;if(r>n-this.$paddingRight)return this.startIndex=-1,this.endIndex=-1,!1;var o=t.scrollH+e[10];if(o0?this._requestedColumnCount:this._columnCount,l=this._requestedRowCount>0?this._requestedRowCount:this._rowCount,u=isNaN(this._horizontalGap)?0:this._horizontalGap,p=isNaN(this._verticalGap)?0:this._verticalGap;h>0&&(o=h*(this._columnWidth+u)-u),l>0&&(s=l*(this._rowHeight+p)-p);var c=this._paddingLeft+this._paddingRight,d=this._paddingTop+this._paddingBottom;t.setMeasuredSize(o+c,s+d),this._columnCount=e,this._rowCount=i,this._columnWidth=n,this._rowHeight=r}},n.prototype.calculateRowAndColumn=function(i,n){var r=this.$target,o=isNaN(this._horizontalGap)?0:this._horizontalGap,s=isNaN(this._verticalGap)?0:this._verticalGap;this._rowCount=this._columnCount=-1;for(var a=r.numElements,h=a,l=0;h>l;l++){var u=r.getElementAt(l);!u||egret.is(u,e)&&u.$includeInLayout||a--}if(0==a)return void(this._rowCount=this._columnCount=0);(isNaN(this.explicitColumnWidth)||isNaN(this.explicitRowHeight))&&this.updateMaxElementSize(),isNaN(this.explicitColumnWidth)?this._columnWidth=this.maxElementWidth:this._columnWidth=this.explicitColumnWidth,isNaN(this.explicitRowHeight)?this._rowHeight=this.maxElementHeight:this._rowHeight=this.explicitRowHeight;var p=this._columnWidth+o;0>=p&&(p=1);var c=this._rowHeight+s;0>=c&&(c=1);var d=this._orientation==t.TileOrientation.COLUMNS,f=!isNaN(i),g=!isNaN(n),y=this._paddingLeft,v=this._paddingRight,m=this._paddingTop,$=this._paddingBottom;if(this._requestedColumnCount>0||this._requestedRowCount>0)this._requestedRowCount>0&&(this._rowCount=Math.min(this._requestedRowCount,a)),this._requestedColumnCount>0&&(this._columnCount=Math.min(this._requestedColumnCount,a));else if(f||g)if(!f||g&&d){var E=Math.max(0,n-m-$);this._rowCount=Math.floor((E+s)/c),this._rowCount=Math.max(1,Math.min(this._rowCount,a))}else{var C=Math.max(0,i-y-v);this._columnCount=Math.floor((C+o)/p),this._columnCount=Math.max(1,Math.min(this._columnCount,a))}else{var _=Math.sqrt(a*p*c);d?this._rowCount=Math.max(1,Math.round(_/c)):this._columnCount=Math.max(1,Math.round(_/p))}-1==this._rowCount&&(this._rowCount=Math.max(1,Math.ceil(a/this._columnCount))),-1==this._columnCount&&(this._columnCount=Math.max(1,Math.ceil(a/this._rowCount))),this._requestedColumnCount>0&&this._requestedRowCount>0&&(this._orientation==t.TileOrientation.ROWS?this._rowCount=Math.max(1,Math.ceil(a/this._requestedColumnCount)):this._columnCount=Math.max(1,Math.ceil(a/this._requestedRowCount)))},n.prototype.updateMaxElementSize=function(){this.$target&&(this.$useVirtualLayout?(this.maxElementWidth=Math.max(this.maxElementWidth,this.$typicalWidth),this.maxElementHeight=Math.max(this.maxElementHeight,this.$typicalHeight),this.doUpdateMaxElementSize(this.startIndex,this.endIndex)):this.doUpdateMaxElementSize(0,this.$target.numElements-1))},n.prototype.doUpdateMaxElementSize=function(t,i){var n=this.maxElementWidth,r=this.maxElementHeight,o=egret.$TempRectangle,s=this.$target;if(-1!=t&&-1!=i)for(var a=t;i>=a;a++){var h=s.getVirtualElementAt(a);egret.is(h,e)&&h.$includeInLayout&&(h.getPreferredBounds(o),n=Math.max(n,o.width),r=Math.max(r,o.height))}this.maxElementWidth=n,this.maxElementHeight=r},n.prototype.clearVirtualLayoutCache=function(){i.prototype.clearVirtualLayoutCache.call(this),this.maxElementWidth=0,this.maxElementHeight=0},n.prototype.scrollPositionChanged=function(){if(this.$useVirtualLayout){var t=this.getIndexInView();t&&(this.indexInViewCalculated=!0,this.$target.invalidateDisplayList())}},n.prototype.getIndexInView=function(){if(!this.$target||0==this.$target.numElements)return this.startIndex=this.endIndex=-1,!1;var e=this.$target,i=e.numElements;if(!this.$useVirtualLayout)return this.startIndex=0,this.endIndex=i-1,!1;var n=e.$UIComponent;if(0==n[10]||0==n[11])return this.startIndex=this.endIndex=-1,!1;var r=this.startIndex,o=this.endIndex,s=this._paddingLeft,a=this._paddingTop,h=isNaN(this._horizontalGap)?0:this._horizontalGap,l=isNaN(this._verticalGap)?0:this._verticalGap;if(this._orientation==t.TileOrientation.COLUMNS){var u=this._columnWidth+h;if(0>=u)return this.startIndex=0,this.endIndex=i-1,!1;var p=e.scrollH,c=p+n[10],d=Math.floor((p-s)/u);0>d&&(d=0);var f=Math.ceil((c-s)/u);0>f&&(f=0),this.startIndex=Math.min(i-1,Math.max(0,d*this._rowCount)),this.endIndex=Math.min(i-1,Math.max(0,f*this._rowCount-1))}else{var g=this._rowHeight+l;if(0>=g)return this.startIndex=0,this.endIndex=i-1,!1;var y=e.scrollV,v=y+n[11],m=Math.floor((y-a)/g);0>m&&(m=0);var $=Math.ceil((v-a)/g);0>$&&($=0),this.startIndex=Math.min(i-1,Math.max(0,m*this._columnCount)),this.endIndex=Math.min(i-1,Math.max(0,$*this._columnCount-1))}return this.startIndex!=r||this.endIndex!=o},n.prototype.updateDisplayList=function(n,r){if(i.prototype.updateDisplayList.call(this,n,r),this.$target){var o=this.$target,s=this._paddingLeft,a=this._paddingRight,h=this._paddingTop,l=this._paddingBottom;if(this.indexInViewCalculated)this.indexInViewCalculated=!1;else{if(this.calculateRowAndColumn(n,r),0==this._rowCount||0==this._columnCount)return void o.setContentSize(s+a,h+l);this.adjustForJustify(n,r),this.getIndexInView()}if(this.$useVirtualLayout&&(this.calculateRowAndColumn(n,r),this.adjustForJustify(n,r)),-1==this.startIndex||-1==this.endIndex)return void o.setContentSize(0,0); -var u=this.endIndex;o.setVirtualElementIndicesInView(this.startIndex,u);for(var p,c,d,f,g,y=this._orientation==t.TileOrientation.COLUMNS,v=this.startIndex,m=isNaN(this._horizontalGap)?0:this._horizontalGap,$=isNaN(this._verticalGap)?0:this._verticalGap,E=this._rowCount,C=this._columnCount,_=this._columnWidth,b=this._rowHeight,T=this.startIndex;u>=T;T++)if(p=this.$useVirtualLayout?this.target.getVirtualElementAt(T):this.target.getElementAt(T),egret.is(p,e)&&p.$includeInLayout){switch(y?(f=Math.ceil((v+1)/E)-1,g=Math.ceil((v+1)%E)-1,-1==g&&(g=E-1)):(f=Math.ceil((v+1)%C)-1,-1==f&&(f=C-1),g=Math.ceil((v+1)/C)-1),this._horizontalAlign){case egret.HorizontalAlign.RIGHT:c=n-(f+1)*(_+m)+m-a;break;case egret.HorizontalAlign.LEFT:c=f*(_+m)+s;break;default:c=f*(_+m)+s}switch(this._verticalAlign){case egret.VerticalAlign.TOP:d=g*(b+$)+h;break;case egret.VerticalAlign.BOTTOM:d=r-(g+1)*(b+$)+$-l;break;default:d=g*(b+$)+h}this.sizeAndPositionElement(p,c,d,_,b),v++}var S=s+a,x=h+l,I=(_+m)*C-m,P=(b+$)*E-$;o.setContentSize(I+S,P+x)}},n.prototype.sizeAndPositionElement=function(e,i,n,r,o){var s=0/0,a=0/0,h=e.$UIComponent;this._horizontalAlign==t.JustifyAlign.JUSTIFY?s=r:isNaN(h[6])||(s=r*h[6]*.01),this._verticalAlign==t.JustifyAlign.JUSTIFY?a=o:isNaN(h[7])||(a=o*h[7]*.01),e.setLayoutBoundsSize(Math.round(s),Math.round(a));var l=i,u=egret.$TempRectangle;switch(e.getLayoutBounds(u),this._horizontalAlign){case egret.HorizontalAlign.RIGHT:l+=r-u.width;break;case egret.HorizontalAlign.CENTER:l=i+(r-u.width)/2}var p=n;switch(this._verticalAlign){case egret.VerticalAlign.BOTTOM:p+=o-u.height;break;case egret.VerticalAlign.MIDDLE:p+=(o-u.height)/2}e.setLayoutBoundsPosition(Math.round(l),Math.round(p))},n.prototype.adjustForJustify=function(e,i){var n=this._paddingLeft,r=this._paddingRight,o=this._paddingTop,s=this._paddingBottom,a=Math.max(0,e-n-r),h=Math.max(0,i-o-s);isNaN(this.explicitVerticalGap)||(this._verticalGap=this.explicitVerticalGap),isNaN(this.explicitHorizontalGap)||(this._horizontalGap=this.explicitHorizontalGap),this._verticalGap=isNaN(this._verticalGap)?0:this._verticalGap,this._horizontalGap=isNaN(this._horizontalGap)?0:this._horizontalGap;var l,u=h-this._rowHeight*this._rowCount,p=a-this._columnWidth*this._columnCount;u>0&&(this._rowAlign==t.RowAlign.JUSTIFY_USING_GAP?(l=Math.max(1,this._rowCount-1),this._verticalGap=u/l):this._rowAlign==t.RowAlign.JUSTIFY_USING_HEIGHT&&this._rowCount>0&&(this._rowHeight+=(u-(this._rowCount-1)*this._verticalGap)/this._rowCount)),p>0&&(this._columnAlign==t.ColumnAlign.JUSTIFY_USING_GAP?(l=Math.max(1,this._columnCount-1),this._horizontalGap=p/l):this._columnAlign==t.ColumnAlign.JUSTIFY_USING_WIDTH&&this._columnCount>0&&(this._columnWidth+=(p-(this._columnCount-1)*this._horizontalGap)/this._columnCount))},n}(t.LayoutBase);t.TileLayout=i,__reflect(i.prototype,"eui.TileLayout")}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}return t.ROWS="rows",t.COLUMNS="columns",t}();t.TileOrientation=e,__reflect(e.prototype,"eui.TileOrientation")}(eui||(eui={}));var eui;!function(t){var e="eui.UIComponent",i=function(i){function n(){return null!==i&&i.apply(this,arguments)||this}return __extends(n,i),n.prototype.measureReal=function(){for(var t=this.$target,i=t.numElements,n=i,r=0,o=0,s=egret.$TempRectangle,a=0;i>a;a++){var h=t.getElementAt(a);egret.is(h,e)&&h.$includeInLayout?(h.getPreferredBounds(s),o+=s.height,r=Math.max(r,s.width)):n--}o+=(n-1)*this.$gap;var l=this.$paddingLeft+this.$paddingRight,u=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(r+l,o+u)},n.prototype.measureVirtual=function(){for(var t=this.$target,i=this.$typicalHeight,n=this.getElementTotalSize(),r=Math.max(this.maxElementSize,this.$typicalWidth),o=egret.$TempRectangle,s=this.endIndex,a=this.elementSizeTable,h=this.startIndex;s>h;h++){var l=t.getElementAt(h);egret.is(l,e)&&l.$includeInLayout&&(l.getPreferredBounds(o),n+=o.height,n-=isNaN(a[h])?i:a[h],r=Math.max(r,o.width))}var u=this.$paddingLeft+this.$paddingRight,p=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(r+u,n+p)},n.prototype.updateDisplayListReal=function(i,n){var r=this.$target,o=this.$paddingLeft,s=this.$paddingRight,a=this.$paddingTop,h=this.$paddingBottom,l=this.$gap,u=Math.max(0,i-o-s),p=Math.max(0,n-a-h),c=this.$verticalAlign==t.JustifyAlign.JUSTIFY,d=this.$horizontalAlign==t.JustifyAlign.JUSTIFY||this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY,f=0;d||(this.$horizontalAlign==egret.HorizontalAlign.CENTER?f=.5:this.$horizontalAlign==egret.HorizontalAlign.RIGHT&&(f=1));var g,y,v,m=r.numElements,$=m,E=o,C=a,_=0,b=0,T=[],S=p,x=this.maxElementSize,I=egret.$TempRectangle;for(g=0;m>g;g++){var P=r.getElementAt(g);if(egret.is(P,e)&&P.$includeInLayout)if(P.getPreferredBounds(I),x=Math.max(x,I.width),c)_+=I.height;else{var L=P.$UIComponent;isNaN(L[7])?S-=I.height:(b+=L[7],v=new t.sys.ChildInfo,v.layoutElement=P,v.percent=L[7],v.min=L[14],v.max=L[15],T.push(v))}else $--}S-=l*($-1),S=S>0?S:0;var N,O=p-_-l*($-1),A=$,B={};if(c){if(0>O){for(N=S/$,g=0;m>g;g++)y=r.getElementAt(g),egret.is(y,e)&&y.$includeInLayout&&(y.getPreferredBounds(I),I.height<=N&&(S-=I.height,A--));S=S>0?S:0}}else if(b>0){this.flexChildrenProportionally(p,S,b,T);var D=0,R=T.length;for(g=0;R>g;g++){v=T[g];var M=Math.round(v.size+D);D+=v.size-M,B[v.layoutElement.$hashCode]=M,S-=M}S=S>0?S:0}this.$verticalAlign==egret.VerticalAlign.MIDDLE?C=a+.5*S:this.$verticalAlign==egret.VerticalAlign.BOTTOM&&(C=a+S);var w=o,V=a,H=0,z=0,U=Math.ceil(u);this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY&&(U=Math.ceil(Math.max(u,x)));var k,F,G=0;for(g=0;m>g;g++){var j=0;if(y=r.getElementAt(g),egret.is(y,e)&&y.$includeInLayout){if(y.getPreferredBounds(I),k=0/0,c?(F=0/0,O>0?F=S*I.height/_:0>O&&I.height>N&&(F=S/A),isNaN(F)||(k=Math.round(F+G),G+=F-k)):k=B[y.$hashCode],d)E=o,y.setLayoutBoundsSize(U,k),y.getLayoutBounds(I);else{var W=0/0,L=y.$UIComponent;if(!isNaN(L[6])){var X=Math.min(100,L[6]);W=Math.round(u*X*.01)}y.setLayoutBoundsSize(W,k),y.getLayoutBounds(I),j=(u-I.width)*f,j=j>0?j:0,E=o+j}y.setLayoutBoundsPosition(Math.round(E),Math.round(C)),H=Math.ceil(I.width),z=Math.ceil(I.height),w=Math.max(w,E+H),V=Math.max(V,C+z),C+=z+l}}this.maxElementSize=x,r.setContentSize(w+s,V+h)},n.prototype.updateDisplayListVirtual=function(i,n){var r=this.$target;this.indexInViewCalculated?this.indexInViewCalculated=!1:this.getIndexInView();var o,s=this.$paddingBottom,a=this.$paddingLeft,h=this.$paddingRight,l=this.$gap,u=r.numElements;if(-1==this.startIndex||-1==this.endIndex)return o=this.getStartPosition(u)-l+s,void r.setContentSize(r.contentWidth,o);var p=this.endIndex;r.setVirtualElementIndicesInView(this.startIndex,p);var c=this.$horizontalAlign==t.JustifyAlign.JUSTIFY||this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY,d=this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY,f=0;c||(this.$horizontalAlign==egret.HorizontalAlign.CENTER?f=.5:this.$horizontalAlign==egret.HorizontalAlign.RIGHT&&(f=1));var g,y=egret.$TempRectangle,v=Math.max(0,i-a-h),m=Math.ceil(v),$=this.$typicalHeight,E=this.$typicalWidth,C=this.maxElementSize,_=Math.max(E,this.maxElementSize);if(d){for(var b=this.startIndex;p>=b;b++)g=r.getVirtualElementAt(b),egret.is(g,e)&&g.$includeInLayout&&(g.getPreferredBounds(y),C=Math.max(C,y.width));m=Math.ceil(Math.max(v,C))}for(var T,S=0,x=0,I=0,P=!1,L=this.elementSizeTable,N=this.startIndex;p>=N;N++){var O=0;g=r.getVirtualElementAt(N),egret.is(g,e)&&g.$includeInLayout&&(g.getPreferredBounds(y),d||(C=Math.max(C,y.width)),c?(S=a,g.setLayoutBoundsSize(m,0/0),g.getLayoutBounds(y)):(g.getLayoutBounds(y),O=(v-y.width)*f,O=O>0?O:0,S=a+O),I=Math.max(I,y.width),P||(T=isNaN(L[N])?$:L[N],T!=y.height&&(P=!0)),L[N]=y.height,x=this.getStartPosition(N),g.setLayoutBoundsPosition(Math.round(S),Math.round(x)))}I+=a+h,o=this.getStartPosition(u)-l+s,this.maxElementSize=C,r.setContentSize(I,o),(P||_s;s++){var a=o[s];isNaN(a)&&(a=i),n+=a+r}return n},n.prototype.getElementSize=function(t){if(this.$useVirtualLayout){var e=this.elementSizeTable[t];return isNaN(e)&&(e=this.$typicalHeight),e}return this.$target?this.$target.getElementAt(t).height:0},n.prototype.getElementTotalSize=function(){for(var t=this.$typicalHeight,e=this.$gap,i=0,n=this.$target.numElements,r=this.elementSizeTable,o=0;n>o;o++){var s=r[o];isNaN(s)&&(s=t),i+=s+e}return i-=e},n.prototype.elementAdded=function(t){this.$useVirtualLayout&&(i.prototype.elementAdded.call(this,t),this.elementSizeTable.splice(t,0,this.$typicalHeight))},n.prototype.getIndexInView=function(){var t=this.$target;if(!t||0==t.numElements)return this.startIndex=this.endIndex=-1,!1;var e=t.$UIComponent;if(0==e[10]||0==e[11])return this.startIndex=this.endIndex=-1,!1;var i=t.numElements,n=this.getStartPosition(i-1)+this.elementSizeTable[i-1]+this.$paddingBottom,r=t.scrollV;if(r>n-this.$paddingBottom)return this.startIndex=-1,this.endIndex=-1,!1;var o=t.scrollV+e[11];if(o=h){var p=s*(1- -h/(.5*u));p=Math.max(5,Math.round(p)),n.setLayoutBoundsSize(p,0/0),n.setLayoutBoundsPosition(0,a)}else if(h>=l-u){var p=s*(1-(h-l+u)/(.5*u));p=Math.max(5,Math.round(p)),n.setLayoutBoundsSize(p,0/0),n.setLayoutBoundsPosition(e-p,a)}else{var c=(e-s)*h/(l-u);n.setLayoutBoundsSize(0/0,0/0),n.setLayoutBoundsPosition(c,a)}}},e.prototype.onPropertyChanged=function(t){switch(t.property){case"scrollH":case"contentWidth":this.invalidateDisplayList()}},e}(t.ScrollBarBase);t.HScrollBar=e,__reflect(e.prototype,"eui.HScrollBar")}(eui||(eui={}));var eui;!function(t){var e=function(){function t(t,e,i,n){this.target=t,this.propertyName=e,this.position=i,this.relativeTo=n}return t.prototype.apply=function(t,e){var i,n=t[this.relativeTo],r=t[this.target],o=this.propertyName?t[this.propertyName]:e;if(r&&o){switch(this.position){case 0:i=0;break;case 1:i=-1;break;case 2:i=o.getChildIndex(n);break;case 3:i=o.getChildIndex(n)+1}-1==i&&(i=o.numChildren),egret.is(o,"eui.Component")&&o.$Component[8].$elementsContent.push(r),o.addChildAt(r,i)}},t.prototype.remove=function(t,e){var i=this.propertyName?t[this.propertyName]:e,n=t[this.target];if(n&&i&&(n.$parent===i&&i.removeChild(n),egret.is(i,"eui.Component"))){var r=i.$Component[8].$elementsContent,o=r.indexOf(n);o>-1&&r.splice(o,1)}},t}();t.AddItems=e,__reflect(e.prototype,"eui.AddItems",["eui.IOverride"])}(eui||(eui={}));var eui;!function(t){var e=function(){function t(t,e,i){this.target=t,this.name=e,this.value=i}return t.prototype.apply=function(t,e){var i=this.target?t[this.target]:t;i&&(this.oldValue=i[this.name],this.setPropertyValue(i,this.name,this.value,this.oldValue))},t.prototype.remove=function(t,e){var i=this.target?t[this.target]:t;i&&(this.setPropertyValue(i,this.name,this.oldValue,this.oldValue),this.oldValue=null)},t.prototype.setPropertyValue=function(t,e,i,n){void 0===i||null===i?t[e]=i:"number"==typeof n?t[e]=+i:"boolean"==typeof n?t[e]=this.toBoolean(i):t[e]=i},t.prototype.toBoolean=function(t){return"string"==typeof t?"true"==t.toLowerCase():0!=t},t}();t.SetProperty=e,__reflect(e.prototype,"eui.SetProperty",["eui.IOverride"])}(eui||(eui={}));var eui;!function(t){var e=function(){function e(t,e,i,n,r){this.host=t,this.templates=e,this.chainIndex=i,this.target=n,this.prop=r}return e.prototype.apply=function(e,i){if(this.target){var n=this.target[this.prop];this.oldValue&&this.setPropertyValue(this.target,this.prop,this.oldValue,this.oldValue),n&&(this.oldValue=n),t.Binding.$bindProperties(this.host,this.templates.concat(),this.chainIndex.concat(),this.target,this.prop)}},e.prototype.remove=function(t,e){if(this.target){var i=this.oldValue;this.target[this.prop]&&(this.oldValue=this.target[this.prop]),i&&this.setPropertyValue(this.target,this.prop,i,i)}},e.prototype.setPropertyValue=function(t,e,i,n){void 0===i||null===i?t[e]=i:"number"==typeof n?t[e]=+i:"boolean"==typeof n?t[e]=this.toBoolean(i):t[e]=i},e.prototype.toBoolean=function(t){return"string"==typeof t?"true"==t.toLowerCase():0!=t},e}();t.SetStateProperty=e,__reflect(e.prototype,"eui.SetStateProperty",["eui.IOverride"])}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t,e,i,n,o,s,a,h,l,u){var p;if(!isNaN(i)&&isNaN(n)){if(p=r(t,e,i,s,i,h,i,u))return p}else if(isNaN(i)&&!isNaN(n)&&(p=r(t,e,o,n,a,n,l,n)))return p;return p=r(t,e,o,s,a,h,l,u)}function i(t,e,i,r,o,s,a,h,l,u){var p;if(!isNaN(i)&&isNaN(r)){if(p=n(t,e,i,s,i,h,i,u))return p}else if(isNaN(i)&&!isNaN(r)&&(p=n(t,e,o,r,a,r,l,r)))return p;return p=n(t,e,o,s,a,h,l,u)}function n(t,e,i,n,r,s,h,l){var u=e.b,p=e.d;if(u>-1e-9&&1e-9>u&&(u=0),p>-1e-9&&1e-9>p&&(p=0),0==u&&0==p)return null;if(0==u&&0==p)return null;if(0==u)return egret.Point.create(i,t/Math.abs(p));if(0==p)return egret.Point.create(t/Math.abs(u),n);var c,d,f,g=u*p>=0?p:-p;if(0!=g&&i>0){var y=1/g;i=Math.max(r,Math.min(h,i)),d=i,f=(t-u*d)*y,f>=s&&l>=f&&u*d+g*f>=0&&(c=egret.Point.create(d,f)),f=(-t-u*d)*y,f>=s&&l>=f&&0>u*d+g*f&&(!c||a(c.x,c.y,e).width>a(d,f,e).width)&&(egret.Point.release(c),c=egret.Point.create(d,f))}if(0!=u&&n>0){var v=1/u;n=Math.max(s,Math.min(l,n)),f=n,d=(t-g*f)*v,d>=r&&h>=d&&u*d+g*f>=0&&(!c||a(c.x,c.y,e).width>a(d,f,e).width)&&(c=egret.Point.create(d,f)),d=(-t-g*f)*v,d>=r&&h>=d&&0>u*d+g*f&&(!c||a(c.x,c.y,e).width>a(d,f,e).width)&&(egret.Point.release(c),c=egret.Point.create(d,f))}if(c)return c;var m=e.a,$=e.c,E=m*$>=0?$:-$;return o(u,g,t,r,s,h,l,m,E)}function r(t,e,i,n,r,s,h,l){var u=e.a,p=e.c;if(u>-1e-9&&1e-9>u&&(u=0),p>-1e-9&&1e-9>p&&(p=0),0==u&&0==p)return null;if(0==u)return egret.Point.create(i,t/Math.abs(p));if(0==p)return egret.Point.create(t/Math.abs(u),n);var c,d,f,g=u*p>=0?p:-p;if(0!=g&&i>0){var y=1/g;i=Math.max(r,Math.min(h,i)),d=i,f=(t-u*d)*y,f>=s&&l>=f&&u*d+g*f>=0&&(c=egret.Point.create(d,f)),f=(-t-u*d)*y,f>=s&&l>=f&&0>u*d+g*f&&(!c||a(c.x,c.y,e).height>a(d,f,e).height)&&(egret.Point.release(c),c=egret.Point.create(d,f))}if(0!=u&&n>0){var v=1/u;n=Math.max(s,Math.min(l,n)),f=n,d=(t-g*f)*v,d>=r&&h>=d&&u*d+g*f>=0&&(!c||a(c.x,c.y,e).height>a(d,f,e).height)&&(egret.Point.release(c),c=egret.Point.create(d,f)),d=(-t-g*f)*v,d>=r&&h>=d&&0>u*d+g*f&&(!c||a(c.x,c.y,e).height>a(d,f,e).height)&&(egret.Point.release(c),c=egret.Point.create(d,f))}if(c)return c;var m=e.b,$=e.d,E=m*$>=0?$:-$;return o(u,g,t,r,s,h,l,m,E)}function o(t,e,i,n,r,o,s,a,h){if(0==t||0==e)return null;var l,u,p=(i-n*t)/e,c=(i-o*t)/e,d=Math.max(r,Math.min(p,c)),f=Math.min(s,Math.max(p,c)),g=a*e-t*h;return f>=d?(u=Math.abs(g)<1e-9?i/(t+e):a*i/g,u=Math.max(d,Math.min(u,f)),l=(i-e*u)/t,egret.Point.create(l,u)):(p=-(n*t+i)/e,c=-(o*t+i)/e,d=Math.max(r,Math.min(p,c)),f=Math.min(s,Math.max(p,c)),f>=d?(u=Math.abs(g)<1e-9?-i/(t+e):-a*i/g,u=Math.max(d,Math.min(u,f)),l=(-i-e*u)/t,egret.Point.create(l,u)):null)}function s(t,e,i,n,r,s,a){var l=i.a,u=i.b,p=i.c,c=i.d;if(l>-1e-9&&1e-9>l&&(l=0),u>-1e-9&&1e-9>u&&(u=0),p>-1e-9&&1e-9>p&&(p=0),c>-1e-9&&1e-9>c&&(c=0),0==u&&0==p)return 0==l||0==c?null:egret.Point.create(t/Math.abs(l),e/Math.abs(c));if(0==l&&0==c)return 0==u||0==p?null:egret.Point.create(e/Math.abs(u),t/Math.abs(p));var d=l*p>=0?p:-p,f=u*c>=0?c:-c,g=l*f-u*d;if(Math.abs(g)<1e-9)return 0==d||0==l||l==-d?null:Math.abs(l*e-u*t)>1e-9?null:o(l,d,t,n,n,s,a,u,f);var y=1/g;t*=y,e*=y;var v;return v=h(l,d,u,f,t,e),v&&n<=v.x&&v.x<=s&&r<=v.y&&v.y<=a&&l*v.x+d*v.x>=0&&u*v.x+f*v.y>=0?v:(v=h(l,d,u,f,t,-e),v&&n<=v.x&&v.x<=s&&r<=v.y&&v.y<=a&&l*v.x+d*v.x>=0&&u*v.x+f*v.y<0?v:(v=h(l,d,u,f,-t,e),v&&n<=v.x&&v.x<=s&&r<=v.y&&v.y<=a&&l*v.x+d*v.x<0&&u*v.x+f*v.y>=0?v:(v=h(l,d,u,f,-t,-e),v&&n<=v.x&&v.x<=s&&r<=v.y&&v.y<=a&&l*v.x+d*v.x<0&&u*v.x+f*v.y<0?v:(egret.Point.release(v),null))))}function a(t,e,i){var n=egret.$TempRectangle.setTo(0,0,t,e);return i.$transformBounds(n),n}function h(t,e,i,n,r,o){return egret.Point.create(n*r-e*o,t*o-i*r)}var l=.1,u=.1,p=function(){function t(){}return t.fitBounds=function(t,n,r,o,h,p,c,d,f,g,y){if(isNaN(t)&&isNaN(n))return egret.Point.create(p,c);var v,m=u>d?0:d-u,$=u>f?0:f-u,E=g+u,C=y+u;if(isNaN(t)||isNaN(n))return isNaN(t)?i(n,r,o,h,p,c,m,$,E,C):e(t,r,o,h,p,c,m,$,E,C);if(v=s(t,n,r,m,$,E,C),!v){var _=void 0;if(_=e(t,r,o,h,p,c,m,$,E,C)){var b=a(_.x,_.y,r).height;b-l>n&&(egret.Point.release(_),_=null)}var T=void 0;if(T=i(n,r,o,h,p,c,m,$,E,C)){var S=a(T.x,T.y,r).width;S-l>t&&(egret.Point.release(T),T=null)}v=_&&T?_.x*_.y>T.x*T.y?_:T:_?_:T,egret.Point.release(_),egret.Point.release(T)}return v},t}();t.MatrixUtil=p,__reflect(p.prototype,"eui.sys.MatrixUtil")}(e=t.sys||(t.sys={}))}(eui||(eui={})); \ No newline at end of file diff --git a/demo/libs/modules/game/game.d.ts b/demo/libs/modules/game/game.d.ts deleted file mode 100644 index 69d11c03..00000000 --- a/demo/libs/modules/game/game.d.ts +++ /dev/null @@ -1,2502 +0,0 @@ -declare namespace egret { - /** - * The URLLoaderDataFormat class provides values that specify how downloaded data is received. - * @see http://edn.egret.com/cn/docs/page/600 Read different data format - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoaderDataFormat.ts - * @language en_US - */ - /** - * URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。 - * @see http://edn.egret.com/cn/docs/page/600 读取不同数据格式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoaderDataFormat.ts - * @language zh_CN - */ - class URLLoaderDataFormat { - /** - * Specify that downloaded data is received as raw binary data. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 指定以原始二进制数据形式接收下载的数据。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - static BINARY: string; - /** - * Specify that downloaded data is received as text. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以文本形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TEXT: string; - /** - * Specify that downloaded data is received as URL-encoded variables. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以 URL 编码变量形式接收下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static VARIABLES: string; - /** - * Specify that downloaded data is received as bitmap texture. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以位图纹理形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TEXTURE: string; - /** - * Specify that downloaded data is received as sound. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以声音形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static SOUND: string; - } -} -declare namespace egret { - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - class FrameLabel extends EventDispatcher { - /** - * @private - */ - private _name; - /** - * @private - */ - private _frame; - /** - * @private - */ - private _end; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(name: string, frame: number, end?: number); - /** - * Frame number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签名 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly name: string; - /** - * Frame serial number of the label - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签所在帧序号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly frame: number; - /** - * Frame serial number, the end of the label - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签对应的结束帧序号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly end: number; - /** - * Duplicate the current frame label object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 复制当前帧标签对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): FrameLabel; - } -} -declare namespace egret { - /** - * @classdesc 使用 MovieClipData 类,您可以创建 MovieClip 对象和处理 MovieClip 对象的数据。MovieClipData 一般由MovieClipDataFactory生成 - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - */ - class MovieClipData extends HashObject { - /** - * @private - * MovieClip数据 - */ - $mcData: any; - /** - * 总帧数 - * @version Egret 2.4 - * @platform Web,Native - */ - numFrames: number; - /** - * 帧数据列表 - * @version Egret 2.4 - * @platform Web,Native - */ - frames: any[]; - /** - * 帧标签列表 - * @version Egret 2.4 - * @platform Web,Native - */ - labels: any[]; - /** - * 帧事件列表 - * @version Egret 2.4 - * @platform Web,Native - */ - events: any[]; - /** - * 帧率 - * @version Egret 2.4 - * @platform Web,Native - */ - frameRate: number; - /** - * 纹理数据 - * @version Egret 2.4 - * @platform Web,Native - */ - textureData: any; - /** - * 纹理集 - * @version Egret 2.4 - * @platform Web,Native - */ - spriteSheet: SpriteSheet; - /** - * 创建一个 egret.MovieClipData 对象 - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * @private - * - * @param mcData - * @param textureData - * @param spriteSheet - */ - $init(mcData: any, textureData: any, spriteSheet: SpriteSheet): void; - /** - * 根据指定帧序号获取该帧对应的关键帧数据 - * @param frame {number} 帧序号 - * @returns {any} 帧数据对象 - * @version Egret 2.4 - * @platform Web,Native - */ - getKeyFrameData(frame: number): any; - /** - * 根据指定帧序号获取该帧对应的Texture对象 - * @param frame {number} 帧序号 - * @returns {egret.Texture} Texture对象 - * @version Egret 2.4 - * @platform Web,Native - */ - getTextureByFrame(frame: number): Texture; - $getOffsetByFrame(frame: number, point: Point): void; - /** - * @private - * - * @param resName - * @returns - */ - private getTextureByResName(resName); - /** - * @private - * - * @returns - */ - $isDataValid(): boolean; - /** - * @private - * - * @returns - */ - $isTextureValid(): boolean; - /** - * @private - * - * @param mcData - */ - $fillMCData(mcData: any): void; - /** - * @private - * - * @param framesData - */ - private fillFramesData(framesData); - /** - * @private - * - * @param frameLabelsData - */ - private fillFrameLabelsData(frameLabelsData); - /** - * @private - * - * @param frameEventsData - */ - private fillFrameEventsData(frameEventsData); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * MovieClip数据源 - */ - mcData: MovieClipData; - /** - * @private - * - * @param value - */ - private setMCData(value); - } -} -declare namespace egret { - /** - * @classdesc 使用 MovieClipDataFactory 类,可以生成 MovieClipData 对象用于创建MovieClip - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - */ - class MovieClipDataFactory extends EventDispatcher { - /** - * 是否开启缓存 - * @version Egret 2.4 - * @platform Web,Native - */ - enableCache: boolean; - /** - * @private - */ - $mcDataSet: any; - /** - * @private - */ - $spriteSheet: SpriteSheet; - /** - * @private - */ - $mcDataCache: any; - /** - * 创建一个 egret.MovieClipDataFactory 对象 - * @param movieClipDataSet {any} MovieClip数据集,该数据集必须由Egret官方工具生成 - * @param texture {Texture} 纹理 - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(movieClipDataSet?: any, texture?: Texture); - /** - * 清空缓存 - * @version Egret 2.4 - * @platform Web,Native - */ - clearCache(): void; - /** - * 根据名字生成一个MovieClipData实例。可以用于创建MovieClip。 - * @param movieClipName {string} MovieClip名字. 可选参数,默认为"", 相当于取第一个MovieClip数据 - * @returns {MovieClipData} 生成的MovieClipData对象 - * @version Egret 2.4 - * @platform Web,Native - */ - generateMovieClipData(movieClipName?: string): MovieClipData; - /** - * @private - * - * @param movieClipName - * @param cache - * @returns - */ - private findFromCache(movieClipName, cache); - /** - * @private - * - * @param movieClipName - * @param movieClip - * @param cache - */ - private fillData(movieClipName, movieClip, cache); - /** - * MovieClip数据集 - * @version Egret 2.4 - * @platform Web,Native - */ - mcDataSet: any; - /** - * MovieClip需要使用的纹理图 - */ - texture: Texture; - /** - * 由纹理图生成的精灵表 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly spriteSheet: SpriteSheet; - /** - * @private - * - * @param value - */ - private setTexture(value); - } -} -declare namespace egret { - /** - * When the movieClip's current frame have a frameLabel, dispatches MovieClipEvent object. FrameLabel Event type: MovieClipEvent.FRAME_LABEL - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当动画的当前帧有事件,将调度 MovieClipEvent 对象。帧事件类型 MovieClipEvent.FRAME_LABEL. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class MovieClipEvent extends Event { - /** - * TextEvent create an object that contains information about movieClip events. - * @param type Type of event, you can access the MovieClipEvent.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determine whether the Event object can be canceled. The default value is false. - * @param frameLabel When the current frame have a frameLabel, the event listeners can access this information through the frameLabel property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 MovieClipEvent 对象,其中包含有关帧事件的信息。 - * @param type 事件的类型,可以作为 MovieClipEvent.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param frameLabel 动画上的帧事件。事件侦听器可以通过 frameLabel 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, frameLabel?: string); - /** - * Dispatched whenever the current frame have a frameLabel. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 动画的当前帧上有事件时调度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FRAME_LABEL: string; - /** - * In MovieClipEvent.FRAME_LABEL event, event corresponding string. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在 MovieClipEvent.FRAME_LABEL 事件中,event对应的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - frameLabel: string; - /** - * EventDispatcher object using the specified event object thrown MovieClipEvent. The objects will be thrown in the object cache pool for the next round robin. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param frameLabel MovieClipEvent object frameLabel - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出 MovieClipEvent 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件类型 - * @param frameLabel MovieClipEvent 对象的 frameLabel 赋值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchMovieClipEvent(target: IEventDispatcher, type: string, frameLabel?: string): boolean; - } -} -declare namespace egret { - /** - * @private - */ - class ScrollEase { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * - * @param amount - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - static get(amount: any): Function; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - static quintOut: Function; - /** - * - * @param pow - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - static getPowOut(pow: any): Function; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - static quartOut: Function; - } - /** - * @private - */ - class ScrollTween extends EventDispatcher { - /** - * @private - */ - private static _tweens; - /** - * @private - */ - private static IGNORE; - /** - * @private - */ - private static _plugins; - /** - * @private - */ - private static _inited; - /** - * @private - */ - private _target; - /** - * @private - */ - private _useTicks; - /** - * @private - */ - private ignoreGlobalPause; - /** - * @private - */ - private loop; - /** - * @private - */ - private pluginData; - /** - * @private - */ - private _curQueueProps; - /** - * @private - */ - private _initQueueProps; - /** - * @private - */ - private _steps; - /** - * @private - */ - private _actions; - /** - * @private - */ - private paused; - /** - * @private - */ - private duration; - /** - * @private - */ - private _prevPos; - /** - * @private - */ - private position; - /** - * @private - */ - private _prevPosition; - /** - * @private - */ - private _stepPosition; - /** - * @private - */ - private passive; - /** - * Activate an object and add a ScrollTween animation to the object - * @param target {any} The object to be activated - * @param props {any} Parameters, support loop onChange onChangeObj - * @param pluginData {any} Write realized - * @param override {boolean} Whether to remove the object before adding a tween, the default value false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 激活一个对象,对其添加 ScrollTween 动画 - * @param target {any} 要激活 ScrollTween 的对象 - * @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域) - * @param pluginData {any} 暂未实现 - * @param override {boolean} 是否移除对象之前添加的tween,默认值false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static get(target: any, props?: any, pluginData?: any, override?: boolean): ScrollTween; - /** - * Delete all ScrollTween animations from an object - * @param target The object whose ScrollTween to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除一个对象上的全部 ScrollTween 动画 - * @param target 需要移除 ScrollTween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static removeTweens(target: any): void; - /** - * @private - * - * @param delta - * @param paused - */ - private static tick(timeStamp, paused?); - private static _lastTime; - /** - * @private - * - * @param tween - * @param value - */ - private static _register(tween, value); - /** - * 创建一个 egret.ScrollTween 对象 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(target: any, props: any, pluginData: any); - /** - * @private - * - * @param target - * @param props - * @param pluginData - */ - private initialize(target, props, pluginData); - /** - * @private - * - * @param value - * @param actionsMode - * @returns - */ - private setPosition(value, actionsMode?); - /** - * @private - * - * @param startPos - * @param endPos - * @param includeStart - */ - private _runActions(startPos, endPos, includeStart?); - /** - * @private - * - * @param step - * @param ratio - */ - private _updateTargetProps(step, ratio); - /** - * Whether setting is paused - * @param value {boolean} Whether to pause - * @returns ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否暂停 - * @param value {boolean} 是否暂停 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setPaused(value: boolean): ScrollTween; - /** - * @private - * - * @param props - * @returns - */ - private _cloneProps(props); - /** - * @private - * - * @param o - * @returns - */ - private _addStep(o); - /** - * @private - * - * @param o - * @returns - */ - private _appendQueueProps(o); - /** - * @private - * - * @param o - * @returns - */ - private _addAction(o); - /** - * Modify the property of the specified display object to a specified value - * @param props {Object} Property set of an object - * @param duration {number} Duration - * @param ease {egret.ScrollEase} Easing algorithm - * @returns {egret.ScrollTween} ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定显示对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param duration {number} 持续时间 - * @param ease {egret.ScrollEase} 缓动算法 - * @returns {egret.ScrollTween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - to(props: any, duration?: number, ease?: Function): ScrollTween; - /** - * Execute callback function - * @param callback {Function} Callback method - * @param thisObj {any} this action scope of the callback method - * @param params {any[]} Parameter of the callback method - * @returns {egret.ScrollTween} ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行回调函数 - * @param callback {Function} 回调方法 - * @param thisObj {any} 回调方法this作用域 - * @param params {any[]} 回调方法参数 - * @returns {egret.ScrollTween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - call(callback: Function, thisObj?: any, params?: any[]): ScrollTween; - /** - * @method egret.ScrollTween#tick - * @param delta {number} - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - tick(delta: number): void; - } -} -declare namespace egret { - /** - * ScrollView auxiliary classes for slides, you will pass a display object constructor. It can display more than the range display object within the specified size range. And can easily drag in this range. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/ScrollView.ts - * @language en_US - */ - /** - * ScrollView 是用于滑动的辅助类,将一个显示对象传入构造函数即可。可以在指定的尺寸范围内显示超过该范围的显示对象。并可以在此范围内随意拖动。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/ScrollView.ts - * @language zh_CN - */ - class ScrollView extends DisplayObjectContainer { - /** - * @private - */ - _ScrV_Props_: ScrollViewProperties; - /** - * Start rolling threshold when the touch point from the initial touch point at a distance exceeding this value will trigger roll - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 开始滚动的阈值,当触摸点偏离初始触摸点的距离超过这个值时才会触发滚动 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollBeginThreshold: number; - /** - * Scrolling speed, the speed is required and the default speed ratio. - * The range of scrollSpeed> 0 assigned to 2:00, the speed is 2 times the default speed - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 滚动速度,这个值为需要的速度与默认速度的比值。 - * 取值范围为 scrollSpeed > 0 赋值为 2 时,速度是默认速度的 2 倍 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollSpeed: number; - /** - * Whether to enable rebound, rebound When enabled, ScrollView contents allowed to continue to drag the border after arriving at the end user drag operation, and then bounce back boundary position - * @default true - * @version Egret 2.4 - * @language en_US - */ - /** - * 是否启用回弹,当启用回弹后,ScrollView中内容在到达边界后允许继续拖动,在用户拖动操作结束后,再反弹回边界位置 - * @default true - * @version Egret 2.4 - * @language zh_CN - */ - bounces: boolean; - /** - * Create a egret.ScrollView objects - * @param content {egret.DisplayObject} You need to scroll object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.ScrollView 对象 - * @param content {egret.DisplayObject} 需要滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(content?: DisplayObject); - /** - * @private - */ - _content: DisplayObject; - /** - * Set to scroll object - * @param content {egret.DisplayObject} You need to scroll object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置需要滚动的对象 - * @param content {egret.DisplayObject} 需要滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setContent(content: DisplayObject): void; - /** - * Remove rolling objects - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 移除滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeContent(): void; - /** - * Vertical scroll bar display policy, on / off / auto. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直滚动条显示策略,on/off/auto。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - verticalScrollPolicy: string; - /** - * The horizontal scroll bar display policy, on / off / auto. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 水平滚动条显示策略,on/off/auto。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - horizontalScrollPolicy: string; - /** - * Gets or sets the horizontal scroll position - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取或设置水平滚动位置, - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollLeft: number; - /** - * Gets or sets the vertical scroll position - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取或设置垂直滚动位置, - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollTop: number; - /** - * Set scroll position - * @param top {number} The vertical scroll position - * @param left {number} The horizontal scroll position - * @param isOffset {boolean} Optional parameter, the default is false, whether it is the amount of scrolling increase as top = 1 on behalf of one pixel scroll up - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动位置 - * @param top {number} 垂直滚动位置 - * @param left {number} 水平滚动位置 - * @param isOffset {boolean} 可选参数,默认是false,是否是滚动增加量,如 top=1 代表往上滚动1像素 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setScrollPosition(top: number, left: number, isOffset?: boolean): void; - /** - * @private - * - * @param top - * @param left - */ - private _validatePosition(top?, left?); - /** - * @private - * @inheritDoc - */ - $setWidth(value: number): void; - /** - * @private - * @inheritDoc - */ - $setHeight(value: number): void; - /** - * @private - * - */ - _updateContentPosition(): void; - /** - * @private - * - * @returns - */ - _checkScrollPolicy(): boolean; - /** - * @private - * - * @param policy - * @param contentLength - * @param viewLength - * @returns - */ - private __checkScrollPolicy(policy, contentLength, viewLength); - /** - * @private - * - * @returns - */ - _addEvents(): void; - /** - * @private - * - * @returns - */ - _removeEvents(): void; - private _tempStage; - /** - * @private - * - * @param e - */ - _onTouchBegin(e: TouchEvent): void; - /** - * @private - */ - private delayTouchBeginEvent; - /** - * @private - */ - private touchBeginTimer; - /** - * @private - * - * @param event - */ - _onTouchBeginCapture(event: TouchEvent): void; - /** - * @private - * - * @param event - * @returns - */ - private _onTouchEndCapture(event); - /** - * @private - * - */ - private _onTouchBeginTimer(); - /** - * @private - * - * @param event - * @returns - */ - private dispatchPropagationEvent(event); - /** - * @private - * - * @param event - * @returns - */ - _onTouchMove(event: TouchEvent): void; - /** - * @private - * - * @param event - * @returns - */ - _onTouchEnd(event: TouchEvent): void; - /** - * @private - * - * @param event - * @returns - */ - _onEnterFrame(event: Event): void; - /** - * @private - * - * @param e - * @returns - */ - private _logTouchEvent(e); - /** - * @private - * - * @param e - * @returns - */ - private _getPointChange(e); - /** - * @private - * - * @param e - * @returns - */ - private _calcVelocitys(e); - /** - * @private - * - * @returns - */ - _getContentWidth(): number; - /** - * @private - * - * @returns - */ - _getContentHeight(): number; - /** - * The left side of the maximum distance - * @returns The left side of the maximum distance - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 距离左侧的最大值 - * @returns 距离左侧最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getMaxScrollLeft(): number; - /** - * Above the maximum distance - * @returns Above the maximum distance - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 距离上方最大值 - * @returns 距离上方最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getMaxScrollTop(): number; - /** - * @private - */ - private static weight; - /** - * @private - * - */ - private _moveAfterTouchEnd(); - /** - * @private - * - * @param tw - */ - private onTweenFinished(tw); - /** - * @private - * - * @returns - */ - _onScrollStarted(): void; - /** - * @private - * - * @returns - */ - _onScrollFinished(): void; - /** - * Set the scroll position above the distance - * @param scrollTop Position above distance - * @param duration Easing of time, in milliseconds - * @returns Get tween vertical scrolling - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动距离上方的位置 - * @param scrollTop 距离上方的位置 - * @param duration 缓动时间,毫秒单位 - * @returns 获取垂直滚动的tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setScrollTop(scrollTop: number, duration?: number): void; - /** - * Set the scroll position from the left side - * @param scrollLeft From the position on the left side - * @param duration Get tween vertical scrolling - * @returns Gets the horizontal scroll tween - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动距离左侧的位置 - * @param scrollLeft 距离左侧的位置 - * @param duration 缓动时间,毫秒单位 - * @returns 获取水平滚动的tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setScrollLeft(scrollLeft: number, duration?: number): void; - /** - * @private - * - * @param pixelsPerMS - * @param curPos - * @param maxPos - * @returns - */ - private getAnimationDatas(pixelsPerMS, curPos, maxPos); - /** - * @private - * - * @param event - * @returns - */ - private cloneTouchEvent(event); - /** - * @private - * - * @returns - */ - private throwNotSupportedError(); - /** - * @deprecated - * @inheritDoc - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - addChild(child: DisplayObject): DisplayObject; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - addChildAt(child: DisplayObject, index: number): DisplayObject; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeChild(child: DisplayObject): DisplayObject; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeChildAt(index: number): DisplayObject; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - setChildIndex(child: DisplayObject, index: number): void; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - swapChildren(child1: DisplayObject, child2: DisplayObject): void; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - swapChildrenAt(index1: number, index2: number): void; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class ScrollViewProperties { - /** - * @private - */ - _verticalScrollPolicy: string; - /** - * @private - */ - _horizontalScrollPolicy: string; - /** - * @private - */ - _scrollLeft: number; - /** - * @private - */ - _scrollTop: number; - /** - * @private - */ - _hCanScroll: boolean; - /** - * @private - */ - _vCanScroll: boolean; - /** - * @private - */ - _lastTouchPosition: egret.Point; - /** - * @private - */ - _touchStartPosition: egret.Point; - /** - * @private - */ - _scrollStarted: boolean; - /** - * @private - */ - _lastTouchTime: number; - /** - * @private - */ - _lastTouchEvent: TouchEvent; - /** - * @private - */ - _velocitys: Array<{ - x: number; - y: number; - }>; - /** - * @private - */ - _isHTweenPlaying: boolean; - /** - * @private - */ - _isVTweenPlaying: boolean; - /** - * @private - */ - _hScrollTween: ScrollTween; - /** - * @private - */ - _vScrollTween: ScrollTween; - /** - * @private - */ - _bounces: boolean; - } -} -declare namespace egret { - /** - * UThe URLLoader class downloads data from a URL as text, binary data, or URL-encoded variables. It is useful for downloading text files, XML, or other information to be used in a dynamic, data-driven application. - * A URLLoader object downloads all of the data from a URL before making it available to code in the applications. It sends out notifications about the progress of the download, - * which you can monitor through bytesLoaded and bytesTotal properties, as well as through dispatched events. - * @see http://edn.egret.com/cn/docs/page/601 Build communication request - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.IOErrorEvent.IO_ERROR io error. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoader.ts - * @language en_US - */ - /** - * URLLoader 类以文本、二进制数据或 URL 编码变量的形式从 URL 下载数据。在下载文本文件、XML 或其他用于动态数据驱动应用程序的信息时,它很有用。 - * URLLoader 对象会先从 URL 中下载所有数据,然后才将数据用于应用程序中的代码。它会发出有关下载进度的通知, - * 通过 bytesLoaded 和 bytesTotal 属性以及已调度的事件,可以监视下载进度。 - * @see http://edn.egret.com/cn/docs/page/601 构建通信请求 - * @event egret.Event.COMPLETE 加载完成后调度。 - * @event egret.IOErrorEvent.IO_ERROR 加载错误后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoader.ts - * @language zh_CN - */ - class URLLoader extends EventDispatcher { - /** - * Create an egret.URLLoader object - * @param request {URLRequest} A URLRequest object specifies the URL to be downloaded. - * If this parameter is omitted, no load operation begins. If a parameter is specified, the load operation begins immediately - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 egret.URLLoader 对象 - * @param request {URLRequest} 一个 URLRequest 对象,指定要下载的 URL。 - * 如果省略该参数,则不开始加载操作。如果已指定参数,则立即开始加载操作 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(request?: URLRequest); - /** - * Control whether the downloaded data is received as text (URLLoaderDataFormat.TEXT), raw binary data (URLLoaderDataFormat.BINARY), or URL-encoded variables (URLLoaderDataFormat.VARIABLES). - * If the value of the dataFormat property is URLLoaderDataFormat.TEXT, the received data is a string containing the text of the loaded file. - * If the value of the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object containing the raw binary data. - * If the value of the dataFormat property is URLLoaderDataFormat.TEXTURE, the received data is a Texture object containing the bitmap data. - * If the value of the dataFormat property is URLLoaderDataFormat.VARIABLES, the received data is a URLVariables object containing the URL-encoded variables. - * The default value is URLLoaderDataFormat.TEXT. - * @default egret.URLLoaderDataFormat.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 控制是以文本 (URLLoaderDataFormat.TEXT)、原始二进制数据 (URLLoaderDataFormat.BINARY) 还是 URL 编码变量 (URLLoaderDataFormat.VARIABLES) 接收下载的数据。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.TEXT,则所接收的数据是一个包含已加载文件文本的字符串。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.BINARY,则所接收的数据是一个包含原始二进制数据的 ByteArray 对象。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.TEXTURE,则所接收的数据是一个包含位图数据的Texture对象。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.VARIABLES,则所接收的数据是一个包含 URL 编码变量的 URLVariables 对象。 - * @default egret.URLLoaderDataFormat.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dataFormat: string; - /** - * The data received from the load operation. This property is populated only when the load operation is complete. The format of the data depends on the setting of the dataFormat property: - * If the dataFormat property is URLLoaderDataFormat.TEXT, the received data is a string containing the text of the loaded file. - * If the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object containing the raw binary data. - * If the dataFormat property is URLLoaderDataFormat.TEXTURE, the received data is a Texture object containing the bitmap data. - * If the dataFormat property is URLLoaderDataFormat.VARIABLES, the received data is a URLVariables object containing the URL-encoded variables. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从加载操作接收的数据。只有完成加载操作时,才会填充该属性。该数据的格式取决于 dataFormat 属性的设置: - * 如果 dataFormat 属性是 URLLoaderDataFormat.TEXT,则所接收的数据是一个包含已加载文件文本的字符串。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.BINARY,则所接收的数据是一个包含原始二进制数据的 ByteArray 对象。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.TEXTURE,则所接收的数据是一个包含位图数据的Texture对象。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.VARIABLES,则所接收的数据是一个包含 URL 编码变量的 URLVariables 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: any; - /** - * @private - */ - _request: URLRequest; - /** - * Send and load data from the specified URL. The data can be received as text, raw binary data, or URL-encoded variables, depending on the value you set for the dataFormat property. - * Note that the default value of the dataFormat property is text. If you want to send data to the specified URL, you can set the data property in the URLRequest object. - * @param request {URLRequest} A URLRequest object specifies the URL to be downloaded. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从指定的 URL 发送和加载数据。可以以文本、原始二进制数据或 URL 编码变量格式接收数据,这取决于为 dataFormat 属性所设置的值。 - * 请注意 dataFormat 属性的默认值为文本。如果想将数据发送至指定的 URL,则可以在 URLRequest 对象中设置 data 属性。 - * @param request {URLRequest} 一个 URLRequest 对象,指定要下载的 URL。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(request: URLRequest): void; - private getResponseType(dataFormat); - /** - * @private - */ - private sound; - /** - * @private - * - * @param loader - */ - private loadSound(loader); - private onSoundoadComplete(event); - private onSoundLoaderPostProgress(event); - private onSoundLoaderError(event); - private removeSoundLoaderListeners(); - /** - * @private - */ - private imageLoader; - /** - * @private - */ - private virtualUrl; - /** - * @private - * - * @param loader - */ - private loadTexture(loader); - private onImageLoadComplete(event); - private onImageLoaderPostProgress(event); - private onImageLoaderError(event); - private removeImageLoaderListeners(); - /** - * @private - */ - _status: number; - /** - * @private - * - */ - __recycle(): void; - } -} -declare namespace egret { - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/MovieClip.ts - * @language en_US - */ - /** - * 影片剪辑,可以通过影片剪辑播放序列帧动画。MovieClip 类从以下类继承而来:DisplayObject 和 EventDispatcher。不同于 DisplayObject 对象,MovieClip 对象拥有一个时间轴。 - * @extends egret.DisplayObject - * @event egret.Event.COMPLETE 动画播放完成。 - * @event egret.Event.LOOP_COMPLETE 动画循环播放完成。循环最后一次只派发 COMPLETE 事件,不派发 LOOP_COMPLETE 事件。 - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/MovieClip.ts - * @language zh_CN - */ - class MovieClip extends DisplayObject { - $texture: Texture; - private offsetPoint; - $movieClipData: MovieClipData; - /** - * @private - */ - private frames; - /** - * @private - */ - $totalFrames: number; - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - frameLabels: any[]; - /** - * @private - */ - $frameLabelStart: number; - /** - * @private - */ - $frameLabelEnd: number; - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - frameEvents: any[]; - /** - * @private - */ - private frameIntervalTime; - /** - * @private - */ - $eventPool: string[]; - $isPlaying: boolean; - /** - * @private - */ - private isStopped; - /** - * @private - */ - private playTimes; - /** - * @private - */ - $currentFrameNum: number; - /** - * @private - */ - $nextFrameNum: number; - /** - * @private - */ - private displayedKeyFrameNum; - /** - * @private - */ - private passedTime; - /** - * @private - */ - private $frameRate; - /** - * 创建新的 MovieClip 实例。创建 MovieClip 之后,调用舞台上的显示对象容器的addElement方法。 - * @param movieClipData {movieClipData} 被引用的 movieClipData 对象 - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(movieClipData?: MovieClipData); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $smoothing: boolean; - /** - * Whether or not is smoothed when scaled. - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - smoothing: boolean; - /** - * @private - * - */ - $init(): void; - /** - * @private - * - */ - $reset(): void; - /** - * @private - * - */ - private _initFrame(); - /** - * @private - */ - $updateRenderNode(): void; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - * - * @param stage - * @param nestLevel - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * - */ - $onRemoveFromStage(): void; - /** - * @private - * 返回帧标签为指定字符串的FrameLabel对象 - * @param labelName {string} 帧标签名 - * @param ignoreCase {boolean} 是否忽略大小写,可选参数,默认false - * @returns {egret.FrameLabel} FrameLabel对象 - */ - private getFrameLabelByName(labelName, ignoreCase?); - /** - * @private - * 根据帧标签,设置开始和结束的帧数 - * @param labelName {string} 帧标签名 - */ - private getFrameStartEnd(labelName); - /** - * @private - * 返回指定序号的帧的FrameLabel对象 - * @param frame {number} 帧序号 - * @returns {egret.FrameLabel} FrameLabel对象 - */ - private getFrameLabelByFrame(frame); - /** - * @private - * 返回指定序号的帧对应的FrameLabel对象,如果当前帧没有标签,则返回前面最近的有标签的帧的FrameLabel对象 - * @method egret.MovieClip#getFrameLabelForFrame - * @param frame {number} 帧序号 - * @returns {egret.FrameLabel} FrameLabel对象 - */ - private getFrameLabelForFrame(frame); - /** - * 继续播放当前动画 - * @param playTimes {number} 播放次数。 参数为整数,可选参数,>=1:设定播放次数,<0:循环播放,默认值 0:不改变播放次数(MovieClip初始播放次数设置为1), - * @version Egret 2.4 - * @platform Web,Native - */ - play(playTimes?: number): void; - /** - * 暂停播放动画 - * @version Egret 2.4 - * @platform Web,Native - */ - stop(): void; - /** - * 将播放头移到前一帧并停止 - * @version Egret 2.4 - * @platform Web,Native - */ - prevFrame(): void; - /** - * 跳到后一帧并停止 - * @version Egret 2.4 - * @platform Web,Native - */ - nextFrame(): void; - /** - * 将播放头移到指定帧并播放 - * @param frame {any} 指定帧的帧号或帧标签 - * @param playTimes {number} 播放次数。 参数为整数,可选参数,>=1:设定播放次数,<0:循环播放,默认值 0:不改变播放次数, - * @version Egret 2.4 - * @platform Web,Native - */ - gotoAndPlay(frame: string | number, playTimes?: number): void; - /** - * 将播放头移到指定帧并停止 - * @param frame {any} 指定帧的帧号或帧标签 - * @version Egret 2.4 - * @platform Web,Native - */ - gotoAndStop(frame: string | number): void; - /** - * @private - * - * @param frame - */ - private gotoFrame(frame); - /** - * @private - */ - private lastTime; - /** - * @private - * - * @param advancedTime - * @returns - */ - private advanceTime(timeStamp); - /** - * @private - * - */ - private advanceFrame(); - /** - * @private - * - */ - private constructFrame(); - /** - * @private - * - */ - $renderFrame(): void; - /** - * @private - * - */ - private handlePendingEvent(); - /** - * MovieClip 实例中帧的总数 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly totalFrames: number; - /** - * MovieClip 实例当前播放的帧的序号 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly currentFrame: number; - /** - * MovieClip 实例当前播放的帧的标签。如果当前帧没有标签,则 currentFrameLabel返回null。 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly currentFrameLabel: string; - /** - * 当前播放的帧对应的标签,如果当前帧没有标签,则currentLabel返回包含标签的先前帧的标签。如果当前帧和先前帧都不包含标签,currentLabel返回null。 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly currentLabel: string; - /** - * MovieClip 实例的帧频 - * @version Egret 2.4 - * @platform Web,Native - */ - frameRate: number; - /** - * MovieClip 实例当前是否正在播放 - * @version Egret 2.4 - * @platform Web,Native - */ - readonly isPlaying: boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * MovieClip数据源 - */ - movieClipData: MovieClipData; - /** - * @private - * - * @param value - */ - private setMovieClipData(value); - /** - * @private - * - * @param value - */ - private setPlayTimes(value); - /** - * @private - * - * @param value - */ - private setIsStopped(value); - } -} -declare namespace egret { - /** - * The URLRequest class captures all of the information in a single HTTP request. - * @see http://edn.egret.com/cn/index.php/article/index/id/601 Build communication request - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequest.ts - * @language en_US - */ - /** - * URLRequest 类可捕获单个 HTTP 请求中的所有信息。 - * @see http://edn.egret.com/cn/index.php/article/index/id/601 构建通信请求 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequest.ts - * @language zh_CN - */ - class URLRequest extends HashObject { - /** - * Create an egret.URLRequest object - * @param url {string} Addresses for URL requests - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLRequest 对象 - * @param url {string} 进行网络请求的地址 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(url?: string); - /** - * An object contains data to be transmitted with the URL request. - * This property is used in conjunction with the method property. When the value of method is GET, the value of data is appended to the value of URLRequest.url, using HTTP query-string syntax. - * When the method value is POST (or any value other than GET), the value of data is transmitted in the body of the HTTP request. - * The URLRequest API offers binary POST support and support for URL-encoded variables, as well as support for strings. The data object can be a ArrayBuffer, URLVariables, or String object. - * The way in which the data is used depends on the type of object used: - * If the object is a ArrayBuffer object, the binary data of the ArrayBuffer object is used as POST data. For GET, data of ArrayBuffer type is not supported. - * If the object is a URLVariables object and the method is POST, then the variables are encoded using x-www-form-urlencoded format and the resulting string is used as POST data. - * If the object is a URLVariables object and the method is GET, the URLVariables object will define variables to be sent with the URLRequest object. - * Otherwise, the object is converted into a string, and the string is used as the POST or GET data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个对象,它包含将随 URL 请求一起传输的数据。 - * 该属性与 method 属性配合使用。当 method 值为 GET 时,将使用 HTTP 查询字符串语法将 data 值追加到 URLRequest.url 值。 - * 当 method 值为 POST(或 GET 之外的任何值)时,将在 HTTP 请求体中传输 data 值。 - * URLRequest API 支持二进制 POST,并支持 URL 编码变量和字符串。该数据对象可以是 ArrayBuffer、URLVariables 或 String 对象。 - * 该数据的使用方式取决于所用对象的类型: - * 如果该对象为 ArrayBuffer 对象,则 ArrayBuffer 对象的二进制数据用作 POST 数据。对于 GET,不支持 ArrayBuffer 类型的数据。 - * 如果该对象是 URLVariables 对象,并且该方法是 POST,则使用 x-www-form-urlencoded 格式对变量进行编码,并且生成的字符串会用作 POST 数据。 - * 如果该对象是 URLVariables 对象,并且该方法是 GET,则 URLVariables 对象将定义要随 URLRequest 对象一起发送的变量。 - * 否则,该对象会转换为字符串,并且该字符串会用作 POST 或 GET 数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: any; - /** - * Request method, valid values are URLRequestMethod.GET or URLRequestMethod.POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 请求方式,有效值为URLRequestMethod.GET 或 URLRequestMethod.POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - method: string; - /** - * The requested URL. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 所请求的 URL。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - url: string; - /** - * The array of HTTP request headers to be appended to the HTTP request. The array is composed of URLRequestHeader objects. - * Each object in the array must be a URLRequestHeader object that contains a name string and a value string. - * Because of browser compatibility, this property has not been achieved in html5 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要追加到 HTTP 请求的 HTTP 请求标头的数组。该数组由 URLRequestHeader 对象组成。 - * 数组中的每一对象必须是包含一个名称字符串和一个值字符串的 URLRequestHeader 对象。 - * 由于浏览器兼容性原因,该属性在 html5 中并未实现 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - requestHeaders: Array; - } -} -declare namespace egret { - /** - * A URLRequestHeader object encapsulates a single HTTP request header and consists of a name/value pair. URLRequestHeader objects are used in the requestHeaders property of the URLRequest class. - * Note: Because of browser compatibility, this property has not been achieved in html5 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestHeader.ts - * @language en_US - */ - /** - * URLRequestHeader 对象封装了一个 HTTP 请求标头并由一个名称/值对组成。URLRequestHeader 对象在 URLRequest 类的 requestHeaders 属性中使用。 - * 注意:由于浏览器兼容性原因,在 html5 中并未实现 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestHeader.ts - * @language zh_CN - */ - class URLRequestHeader { - /** - * HTTP request header name, such as Content-Type - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HTTP 请求标头名称,如 Content-Type - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * The values associated with the name property (such as text/plain). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 与 name 属性相关联的值,如 text/plain - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - value: string; - /** - * Create an egret.URLRequestHeader object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLRequestHeader 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(name: string, value: string); - } -} -declare namespace egret { - /** - * The URLRequestMethod class provides values that specify whether the - * URLRequest object should use the POST method or the GET method when sending data to a server. - * @see http://edn.egret.com/cn/docs/page/599 POST与GET - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestMethod.ts - * @language en_US - */ - /** - * URLRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时, - * URLRequest 对象应使用 POST 方法还是 GET 方法。 - * @see http://edn.egret.com/cn/docs/page/599 POST与GET - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestMethod.ts - * @language zh_CN - */ - class URLRequestMethod { - /** - * Specify that the URLRequest object is a GET. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 URLRequest 对象是一个 GET。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static GET: string; - /** - * Specify that the URLRequest object is a POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 URLRequest 对象是一个 POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static POST: string; - } -} -declare namespace egret { - /** - * The URLVariables class allows you to transfer variables between an application and a server. - * Use URLVariables objects with methods of the URLLoader class and the data property of the URLRequest class. - * @see http://edn.egret.com/cn/docs/page/598 Send the request with parameters - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLVariables.ts - * @language en_US - */ - /** - * 使用 URLVariables 类可以在应用程序和服务器之间传输变量。 - * 将 URLVariables 对象与 URLLoader 类的方法、URLRequest 类的 data 属性一起使用。 - * @see http://edn.egret.com/cn/docs/page/598 发送带参数的请求 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLVariables.ts - * @language zh_CN - */ - class URLVariables extends HashObject { - /** - * Create an egret.URLVariable object - * @param source {String} A URL-encoded string containing name/value pairs. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLVariables 对象 - * @param source {String} 包含名称/值对的 URL 编码的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(source?: string); - /** - * Key-value pair data object saved in this URLVariables object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 此 URLVariables 储存的键值对数据对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - variables: Object; - /** - * Convert the variable string into the property of this URLVariables.variables object. - * @param source {string} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将变量字符串转换为此 URLVariables.variables 对象的属性。 - * @param source {string} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - decode(source: string): void; - /** - * Return a string containing all enumerable variables using the MIME content encoding format : application/x-www-form-urlencoded. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 以 MIME 内容编码格式 application/x-www-form-urlencoded 返回包含所有可枚举变量的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - /** - * @private - * - * @param key - * @param value - */ - private encodeValue(key, value); - /** - * @private - * - * @param key - * @param value - */ - private encodeArray(key, value); - } -} -declare namespace egret { - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/player/Ticker.ts - * @language en_US - */ - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/player/Ticker.ts - * @language zh_CN - */ - class Ticker extends EventDispatcher { - /** - * @deprecated - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - private _timeScale; - private _paused; - private _callIndex; - private _callList; - private _lastTime; - private update(timeStamp); - private callBackList; - /** - * 注册帧回调事件,同一函数的重复监听会被忽略。推荐使用 egret.startTick 替代此方法。 - * @method egret.Ticker#register - * @param listener {Function} 帧回调函数,参数返回上一帧和这帧的间隔时间。示例:onEnterFrame(frameTime:number):void - * @param thisObject {any} 帧回调函数的this对象 - * @param priority {number} 事件优先级,开发者请勿传递 Number.NEGATIVE_INFINITY 和 Number.POSITIVE_INFINITY - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - register(listener: Function, thisObject: any, priority?: number): void; - /** - * 取消侦听enterFrame事件。推荐使用 egret.stopTick 替代此方法。 - * @method egret.Ticker#unregister - * @param listener {Function} 事件侦听函数 - * @param thisObject {any} 侦听函数的this对象 - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - unregister(listener: Function, thisObject: any): void; - /** - * @deprecated - * @param timeScale {number} - * @private - */ - setTimeScale(timeScale: number): void; - /** - * @deprecated - * @method egret.Ticker#getTimeScale - * @private - */ - getTimeScale(): number; - /** - * 暂停 - * @deprecated - * @method egret.Ticker#pause - */ - pause(): void; - /** - * 继续 - * @deprecated - * @method egret.Ticker#resume - */ - resume(): void; - /** - * @private - */ - private static instance; - /** - * @method egret.Ticker.getInstance - * @returns {Ticker} - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - static getInstance(): egret.Ticker; - } -} -declare namespace egret { - /** - * @class egret.MainContext - * @classdesc - * MainContext是游戏的核心跨平台接口,组合了多个功能Context,并是游戏启动的主入口 - * @extends egret.EventDispatcher - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class MainContext extends EventDispatcher { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * 渲染Context - * @member egret.MainContext#rendererContext - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * 触摸Context - * @member egret.MainContext#touchContext - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * 设备divice - * @member egret.MainContext#deviceContext - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * 舞台 - * @member egret.MainContext#stage - * @version Egret 2.4 - * @platform Web,Native - */ - readonly stage: Stage; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - static deviceType: string; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - static DEVICE_PC: string; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - static DEVICE_MOBILE: string; - /** - * 游戏启动,开启主循环,参考Flash的滑动跑道模型 - * @method egret.MainContext#run - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @private - */ - private static _instance; - /** - * @method egret.Ticker.getInstance - * @returns {Ticker} - * @version Egret 2.4 - * @platform Web,Native - */ - static readonly instance: egret.MainContext; - } -} -declare namespace egret { - /** - * Tool class for object cache repeat use, which can be used to construct an object pool. Objects are automatically recycled after a certain duration. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/Recycler.ts - * @private - * @language en_US - */ - /** - * 对象缓存复用工具类,可用于构建对象池,一段时间后会自动回收对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/Recycler.ts - * @private - * @language zh_CN - */ - class Recycler extends HashObject { - /** - * Create an egret.Recycler object - * @param autoDisposeTime {number} Number of frames when objects are destroyed automatically. Default value: 300 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Recycler 对象 - * @param autoDisposeTime {number} 多少帧后自动销毁对象,默认值300 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(autoDisposeTime?: number); - /** - * @private - */ - static _callBackList: any[]; - static $init(): void; - static onUpdate(timeStamp: number): boolean; - /** - * @private - * 多少帧后自动销毁对象。 - */ - private autoDisposeTime; - /** - * @private - */ - private frameCount; - /** - * @private - * - */ - $checkFrame(): void; - /** - * @private - */ - private objectPool; - /** - * @private - */ - private _length; - /** - * Number of cached objects" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓存的对象数量 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly length: number; - /** - * Cache an object for repeat use - * @param object {any} The object to be cached - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓存一个对象以复用 - * @param object {any} 需要缓存的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - push(object: any): void; - /** - * Obtain a cached object - * @returns {any} The obtained cached object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个缓存的对象 - * @returns {any} 获得的缓存对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pop(): any; - /** - * Immediately clear all cached objects. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 立即清空所有缓存的对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispose(): void; - } -} -declare namespace egret { - /** - * To specify a delay (in milliseconds) calls the function specified interval loop. - * @param listener {Function} Listener function - * @param thisObject {any} this object - * @param delay {number} Delay time, in milliseconds - * @param ...args {any} Parameter list - * @returns {number} Return index which can be used for clearInterval - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setInterval.ts - * @language en_US - */ - /** - * 以指定的延迟(以毫秒为单位)间隔循环调用指定的函数。 - * @param listener {Function} 侦听函数 - * @param thisObject {any} this对象 - * @param delay {number} 延迟时间,以毫秒为单位 - * @param ...args {any} 参数列表 - * @returns {number} 返回索引,可以用于 clearInterval - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setInterval.ts - * @language zh_CN - */ - function setInterval(listener: (this: Z, ...arg) => void, thisObject: Z, delay: number, ...args: any[]): number; - /** - * Clear function to run after a specified delay. - * @param key {number} Index that egret.setInterval returns - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/setInterval.ts - * @language en_US - */ - /** - * 清除指定延迟后运行的函数。 - * @param key {number} egret.setInterval所返回的索引 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/setInterval.ts - * @language zh_CN - */ - function clearInterval(key: number): void; -} -declare namespace egret { - /** - * Run the designated function in specified delay (in milliseconds). - * @param listener {Function} Listener function - * @param thisObject {any} this object - * @param delay {number} Delay time, in milliseconds - * @param ...args {any} Parameter list - * @returns {number} Return index which can be used for clearTimeout - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setTimeout.ts - * @language en_US - */ - /** - * 在指定的延迟(以毫秒为单位)后运行指定的函数。 - * @param listener {Function} 侦听函数 - * @param thisObject {any} this对象 - * @param delay {number} 延迟时间,以毫秒为单位 - * @param ...args {any} 参数列表 - * @returns {number} 返回索引,可以用于 clearTimeout - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setTimeout.ts - * @language zh_CN - */ - function setTimeout(listener: (this: Z, ...arg) => void, thisObject: Z, delay: number, ...args: any[]): number; - /** - * Function run after the specified delay is cleared. - * @param key {number} Index that egret.setTimeout returns - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除指定延迟后运行的函数。 - * @param key {number} egret.setTimeout所返回的索引 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function clearTimeout(key: number): void; -} diff --git a/demo/libs/modules/game/game.js b/demo/libs/modules/game/game.js deleted file mode 100644 index 3adb691b..00000000 --- a/demo/libs/modules/game/game.js +++ /dev/null @@ -1,4818 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The URLLoaderDataFormat class provides values that specify how downloaded data is received. - * @see http://edn.egret.com/cn/docs/page/600 Read different data format - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoaderDataFormat.ts - * @language en_US - */ - /** - * URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。 - * @see http://edn.egret.com/cn/docs/page/600 读取不同数据格式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoaderDataFormat.ts - * @language zh_CN - */ - var URLLoaderDataFormat = (function () { - function URLLoaderDataFormat() { - } - /** - * Specify that downloaded data is received as raw binary data. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 指定以原始二进制数据形式接收下载的数据。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - URLLoaderDataFormat.BINARY = "binary"; - /** - * Specify that downloaded data is received as text. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以文本形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLLoaderDataFormat.TEXT = "text"; - /** - * Specify that downloaded data is received as URL-encoded variables. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以 URL 编码变量形式接收下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLLoaderDataFormat.VARIABLES = "variables"; - /** - * Specify that downloaded data is received as bitmap texture. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以位图纹理形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLLoaderDataFormat.TEXTURE = "texture"; - /** - * Specify that downloaded data is received as sound. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定以声音形式接收已下载的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLLoaderDataFormat.SOUND = "sound"; - return URLLoaderDataFormat; - }()); - egret.URLLoaderDataFormat = URLLoaderDataFormat; - __reflect(URLLoaderDataFormat.prototype, "egret.URLLoaderDataFormat"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - var FrameLabel = (function (_super) { - __extends(FrameLabel, _super); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function FrameLabel(name, frame /*int*/, end /*int*/) { - var _this = _super.call(this) || this; - _this._name = name; - _this._frame = frame | 0; - if (end) - _this._end = end | 0; - return _this; - } - Object.defineProperty(FrameLabel.prototype, "name", { - /** - * Frame number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签名 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(FrameLabel.prototype, "frame", { - /** - * Frame serial number of the label - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签所在帧序号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._frame; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(FrameLabel.prototype, "end", { - /** - * Frame serial number, the end of the label - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 标签对应的结束帧序号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._end; - }, - enumerable: true, - configurable: true - }); - /** - * Duplicate the current frame label object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 复制当前帧标签对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - FrameLabel.prototype.clone = function () { - return new FrameLabel(this._name, this._frame, this._end); - }; - return FrameLabel; - }(egret.EventDispatcher)); - egret.FrameLabel = FrameLabel; - __reflect(FrameLabel.prototype, "egret.FrameLabel"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @classdesc 使用 MovieClipData 类,您可以创建 MovieClip 对象和处理 MovieClip 对象的数据。MovieClipData 一般由MovieClipDataFactory生成 - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - */ - var MovieClipData = (function (_super) { - __extends(MovieClipData, _super); - /** - * 创建一个 egret.MovieClipData 对象 - * @version Egret 2.4 - * @platform Web,Native - */ - function MovieClipData() { - var _this = _super.call(this) || this; - /** - * @private - * MovieClip数据 - */ - _this.$mcData = null; - /** - * 总帧数 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.numFrames = 1; - /** - * 帧数据列表 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.frames = []; - /** - * 帧标签列表 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.labels = null; - /** - * 帧事件列表 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.events = []; - /** - * 帧率 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.frameRate = 0; - /** - * 纹理数据 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.textureData = null; - /** - * 纹理集 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.spriteSheet = null; - return _this; - } - /** - * @private - * - * @param mcData - * @param textureData - * @param spriteSheet - */ - MovieClipData.prototype.$init = function (mcData, textureData, spriteSheet) { - this.textureData = textureData; - this.spriteSheet = spriteSheet; - this.setMCData(mcData); - }; - /** - * 根据指定帧序号获取该帧对应的关键帧数据 - * @param frame {number} 帧序号 - * @returns {any} 帧数据对象 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClipData.prototype.getKeyFrameData = function (frame) { - var outputFrameData = this.frames[frame - 1]; - if (outputFrameData.frame) { - outputFrameData = this.frames[outputFrameData.frame - 1]; - } - return outputFrameData; - }; - /** - * 根据指定帧序号获取该帧对应的Texture对象 - * @param frame {number} 帧序号 - * @returns {egret.Texture} Texture对象 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClipData.prototype.getTextureByFrame = function (frame) { - var frameData = this.getKeyFrameData(frame); - if (frameData.res) { - var outputTexture = this.getTextureByResName(frameData.res); - return outputTexture; - } - return null; - }; - MovieClipData.prototype.$getOffsetByFrame = function (frame, point) { - var frameData = this.getKeyFrameData(frame); - if (frameData.res) { - point.setTo(frameData.x | 0, frameData.y | 0); - } - }; - /** - * @private - * - * @param resName - * @returns - */ - MovieClipData.prototype.getTextureByResName = function (resName) { - if (this.spriteSheet == null) { - return null; - } - var texture = this.spriteSheet.getTexture(resName); - if (!texture) { - var textureData = this.textureData[resName]; - texture = this.spriteSheet.createTexture(resName, textureData.x, textureData.y, textureData.w, textureData.h); - } - return texture; - }; - /** - * @private - * - * @returns - */ - MovieClipData.prototype.$isDataValid = function () { - return this.frames.length > 0; - }; - /** - * @private - * - * @returns - */ - MovieClipData.prototype.$isTextureValid = function () { - return this.textureData != null && this.spriteSheet != null; - }; - /** - * @private - * - * @param mcData - */ - MovieClipData.prototype.$fillMCData = function (mcData) { - this.frameRate = mcData["frameRate"] || 24; - this.fillFramesData(mcData.frames); - this.fillFrameLabelsData(mcData.labels); - this.fillFrameEventsData(mcData.events); - }; - /** - * @private - * - * @param framesData - */ - MovieClipData.prototype.fillFramesData = function (framesData) { - var frames = this.frames; - var length = framesData ? framesData.length : 0; - var keyFramePosition; - for (var i = 0; i < length; i++) { - var frameData = framesData[i]; - frames.push(frameData); - if (frameData.duration) { - var duration = parseInt(frameData.duration); - if (duration > 1) { - keyFramePosition = frames.length; - for (var j = 1; j < duration; j++) { - frames.push({ "frame": keyFramePosition }); - } - } - } - } - this.numFrames = frames.length; - }; - /** - * @private - * - * @param frameLabelsData - */ - MovieClipData.prototype.fillFrameLabelsData = function (frameLabelsData) { - if (frameLabelsData) { - var length_1 = frameLabelsData.length; - if (length_1 > 0) { - this.labels = []; - for (var i = 0; i < length_1; i++) { - var label = frameLabelsData[i]; - this.labels.push(new egret.FrameLabel(label.name, label.frame, label.end)); - } - } - } - }; - /** - * @private - * - * @param frameEventsData - */ - MovieClipData.prototype.fillFrameEventsData = function (frameEventsData) { - if (frameEventsData) { - var length_2 = frameEventsData.length; - if (length_2 > 0) { - this.events = []; - for (var i = 0; i < length_2; i++) { - var events = frameEventsData[i]; - this.events[events.frame] = events.name; - } - } - } - }; - Object.defineProperty(MovieClipData.prototype, "mcData", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$mcData; - }, - /** - * MovieClip数据源 - */ - set: function (value) { - this.setMCData(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - MovieClipData.prototype.setMCData = function (value) { - if (this.$mcData == value) { - return; - } - this.$mcData = value; - if (value) { - this.$fillMCData(value); - } - }; - return MovieClipData; - }(egret.HashObject)); - egret.MovieClipData = MovieClipData; - __reflect(MovieClipData.prototype, "egret.MovieClipData"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @classdesc 使用 MovieClipDataFactory 类,可以生成 MovieClipData 对象用于创建MovieClip - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - */ - var MovieClipDataFactory = (function (_super) { - __extends(MovieClipDataFactory, _super); - /** - * 创建一个 egret.MovieClipDataFactory 对象 - * @param movieClipDataSet {any} MovieClip数据集,该数据集必须由Egret官方工具生成 - * @param texture {Texture} 纹理 - * @version Egret 2.4 - * @platform Web,Native - */ - function MovieClipDataFactory(movieClipDataSet, texture) { - var _this = _super.call(this) || this; - /** - * 是否开启缓存 - * @version Egret 2.4 - * @platform Web,Native - */ - _this.enableCache = true; - /** - * @private - */ - _this.$mcDataCache = {}; - _this.$mcDataSet = movieClipDataSet; - _this.setTexture(texture); - return _this; - } - /** - * 清空缓存 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClipDataFactory.prototype.clearCache = function () { - this.$mcDataCache = {}; - }; - /** - * 根据名字生成一个MovieClipData实例。可以用于创建MovieClip。 - * @param movieClipName {string} MovieClip名字. 可选参数,默认为"", 相当于取第一个MovieClip数据 - * @returns {MovieClipData} 生成的MovieClipData对象 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClipDataFactory.prototype.generateMovieClipData = function (movieClipName) { - if (movieClipName === void 0) { movieClipName = ""; } - if (movieClipName == "") { - if (this.$mcDataSet) { - for (movieClipName in this.$mcDataSet.mc) { - break; - } - } - } - if (movieClipName == "") { - return null; - } - var output = this.findFromCache(movieClipName, this.$mcDataCache); - if (!output) { - output = new egret.MovieClipData(); - this.fillData(movieClipName, output, this.$mcDataCache); - } - return output; - }; - /** - * @private - * - * @param movieClipName - * @param cache - * @returns - */ - MovieClipDataFactory.prototype.findFromCache = function (movieClipName, cache) { - if (this.enableCache && cache[movieClipName]) { - return cache[movieClipName]; - } - return null; - }; - /** - * @private - * - * @param movieClipName - * @param movieClip - * @param cache - */ - MovieClipDataFactory.prototype.fillData = function (movieClipName, movieClip, cache) { - if (this.$mcDataSet) { - var mcData = this.$mcDataSet.mc[movieClipName]; - if (mcData) { - movieClip.$init(mcData, this.$mcDataSet.res, this.$spriteSheet); - if (this.enableCache) { - cache[movieClipName] = movieClip; - } - } - } - }; - Object.defineProperty(MovieClipDataFactory.prototype, "mcDataSet", { - /** - * MovieClip数据集 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$mcDataSet; - }, - set: function (value) { - this.$mcDataSet = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClipDataFactory.prototype, "texture", { - /** - * MovieClip需要使用的纹理图 - */ - set: function (value) { - this.setTexture(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClipDataFactory.prototype, "spriteSheet", { - /** - * 由纹理图生成的精灵表 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$spriteSheet; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - MovieClipDataFactory.prototype.setTexture = function (value) { - this.$spriteSheet = value ? new egret.SpriteSheet(value) : null; - }; - return MovieClipDataFactory; - }(egret.EventDispatcher)); - egret.MovieClipDataFactory = MovieClipDataFactory; - __reflect(MovieClipDataFactory.prototype, "egret.MovieClipDataFactory"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * When the movieClip's current frame have a frameLabel, dispatches MovieClipEvent object. FrameLabel Event type: MovieClipEvent.FRAME_LABEL - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当动画的当前帧有事件,将调度 MovieClipEvent 对象。帧事件类型 MovieClipEvent.FRAME_LABEL. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var MovieClipEvent = (function (_super) { - __extends(MovieClipEvent, _super); - /** - * TextEvent create an object that contains information about movieClip events. - * @param type Type of event, you can access the MovieClipEvent.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determine whether the Event object can be canceled. The default value is false. - * @param frameLabel When the current frame have a frameLabel, the event listeners can access this information through the frameLabel property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 MovieClipEvent 对象,其中包含有关帧事件的信息。 - * @param type 事件的类型,可以作为 MovieClipEvent.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param frameLabel 动画上的帧事件。事件侦听器可以通过 frameLabel 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function MovieClipEvent(type, bubbles, cancelable, frameLabel) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - if (frameLabel === void 0) { frameLabel = null; } - var _this = _super.call(this, type, bubbles, cancelable) || this; - /** - * In MovieClipEvent.FRAME_LABEL event, event corresponding string. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在 MovieClipEvent.FRAME_LABEL 事件中,event对应的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.frameLabel = null; - _this.frameLabel = frameLabel; - return _this; - } - /** - * EventDispatcher object using the specified event object thrown MovieClipEvent. The objects will be thrown in the object cache pool for the next round robin. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param frameLabel MovieClipEvent object frameLabel - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出 MovieClipEvent 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件类型 - * @param frameLabel MovieClipEvent 对象的 frameLabel 赋值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - MovieClipEvent.dispatchMovieClipEvent = function (target, type, frameLabel) { - if (frameLabel === void 0) { frameLabel = null; } - var event = egret.Event.create(MovieClipEvent, type); - event.frameLabel = frameLabel; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Dispatched whenever the current frame have a frameLabel. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 动画的当前帧上有事件时调度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - MovieClipEvent.FRAME_LABEL = "frame_label"; - return MovieClipEvent; - }(egret.Event)); - egret.MovieClipEvent = MovieClipEvent; - __reflect(MovieClipEvent.prototype, "egret.MovieClipEvent"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - */ - var ScrollEase = (function () { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function ScrollEase() { - egret.$error(1014); - } - /** - * - * @param amount - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollEase.get = function (amount) { - if (amount < -1) { - amount = -1; - } - if (amount > 1) { - amount = 1; - } - return function (t) { - if (amount == 0) { - return t; - } - if (amount < 0) { - return t * (t * -amount + 1 + amount); - } - return t * ((2 - t) * amount + (1 - amount)); - }; - }; - /** - * - * @param pow - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollEase.getPowOut = function (pow) { - return function (t) { - return 1 - Math.pow(1 - t, pow); - }; - }; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollEase.quintOut = ScrollEase.getPowOut(5); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollEase.quartOut = ScrollEase.getPowOut(4); - return ScrollEase; - }()); - egret.ScrollEase = ScrollEase; - __reflect(ScrollEase.prototype, "egret.ScrollEase"); - /** - * @private - */ - var ScrollTween = (function (_super) { - __extends(ScrollTween, _super); - /** - * 创建一个 egret.ScrollTween 对象 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - function ScrollTween(target, props, pluginData) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this._target = null; - /** - * @private - */ - _this._useTicks = false; - /** - * @private - */ - _this.ignoreGlobalPause = false; - /** - * @private - */ - _this.loop = false; - /** - * @private - */ - _this.pluginData = null; - /** - * @private - */ - _this._steps = null; - /** - * @private - */ - _this._actions = null; - /** - * @private - */ - _this.paused = false; - /** - * @private - */ - _this.duration = 0; - /** - * @private - */ - _this._prevPos = -1; - /** - * @private - */ - _this.position = null; - /** - * @private - */ - _this._prevPosition = 0; - /** - * @private - */ - _this._stepPosition = 0; - /** - * @private - */ - _this.passive = false; - _this.initialize(target, props, pluginData); - return _this; - } - /** - * Activate an object and add a ScrollTween animation to the object - * @param target {any} The object to be activated - * @param props {any} Parameters, support loop onChange onChangeObj - * @param pluginData {any} Write realized - * @param override {boolean} Whether to remove the object before adding a tween, the default value false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 激活一个对象,对其添加 ScrollTween 动画 - * @param target {any} 要激活 ScrollTween 的对象 - * @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域) - * @param pluginData {any} 暂未实现 - * @param override {boolean} 是否移除对象之前添加的tween,默认值false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollTween.get = function (target, props, pluginData, override) { - if (props === void 0) { props = null; } - if (pluginData === void 0) { pluginData = null; } - if (override === void 0) { override = false; } - if (override) { - ScrollTween.removeTweens(target); - } - return new ScrollTween(target, props, pluginData); - }; - /** - * Delete all ScrollTween animations from an object - * @param target The object whose ScrollTween to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除一个对象上的全部 ScrollTween 动画 - * @param target 需要移除 ScrollTween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollTween.removeTweens = function (target) { - if (!target.tween_count) { - return; - } - var tweens = ScrollTween._tweens; - for (var i = tweens.length - 1; i >= 0; i--) { - if (tweens[i]._target == target) { - tweens[i].paused = true; - tweens.splice(i, 1); - } - } - target.tween_count = 0; - }; - /** - * @private - * - * @param delta - * @param paused - */ - ScrollTween.tick = function (timeStamp, paused) { - if (paused === void 0) { paused = false; } - var delta = timeStamp - ScrollTween._lastTime; - ScrollTween._lastTime = timeStamp; - var tweens = ScrollTween._tweens.concat(); - for (var i = tweens.length - 1; i >= 0; i--) { - var tween = tweens[i]; - if ((paused && !tween.ignoreGlobalPause) || tween.paused) { - continue; - } - tween.tick(tween._useTicks ? 1 : delta); - } - return false; - }; - /** - * @private - * - * @param tween - * @param value - */ - ScrollTween._register = function (tween, value) { - var target = tween._target; - var tweens = ScrollTween._tweens; - if (value) { - if (target) { - target.tween_count = target.tween_count > 0 ? target.tween_count + 1 : 1; - } - tweens.push(tween); - if (!ScrollTween._inited) { - ScrollTween._lastTime = egret.getTimer(); - egret.ticker.$startTick(ScrollTween.tick, null); - ScrollTween._inited = true; - } - } - else { - if (target) { - target.tween_count--; - } - var i = tweens.length; - while (i--) { - if (tweens[i] == tween) { - tweens.splice(i, 1); - return; - } - } - } - }; - /** - * @private - * - * @param target - * @param props - * @param pluginData - */ - ScrollTween.prototype.initialize = function (target, props, pluginData) { - this._target = target; - if (props) { - this._useTicks = props.useTicks; - this.ignoreGlobalPause = props.ignoreGlobalPause; - this.loop = props.loop; - props.onChange && this.addEventListener("change", props.onChange, props.onChangeObj); - if (props.override) { - ScrollTween.removeTweens(target); - } - } - this.pluginData = pluginData || {}; - this._curQueueProps = {}; - this._initQueueProps = {}; - this._steps = []; - this._actions = []; - if (props && props.paused) { - this.paused = true; - } - else { - ScrollTween._register(this, true); - } - if (props && props.position != null) { - this.setPosition(props.position); - } - }; - /** - * @private - * - * @param value - * @param actionsMode - * @returns - */ - ScrollTween.prototype.setPosition = function (value, actionsMode) { - if (actionsMode === void 0) { actionsMode = 1; } - if (value < 0) { - value = 0; - } - //正常化位置 - var t = value; - var end = false; - if (t >= this.duration) { - if (this.loop) { - t = t % this.duration; - } - else { - t = this.duration; - end = true; - } - } - if (t == this._prevPos) { - return end; - } - var prevPos = this._prevPos; - this.position = this._prevPos = t; - this._prevPosition = value; - if (this._target) { - if (end) { - //结束 - this._updateTargetProps(null, 1); - } - else if (this._steps.length > 0) { - // 找到新的tween - var i = void 0; - var l = this._steps.length; - for (i = 0; i < l; i++) { - if (this._steps[i].t > t) { - break; - } - } - var step = this._steps[i - 1]; - this._updateTargetProps(step, (this._stepPosition = t - step.t) / step.d); - } - } - if (end) { - this.setPaused(true); - } - //执行actions - if (actionsMode != 0 && this._actions.length > 0) { - if (this._useTicks) { - this._runActions(t, t); - } - else if (actionsMode == 1 && t < prevPos) { - if (prevPos != this.duration) { - this._runActions(prevPos, this.duration); - } - this._runActions(0, t, true); - } - else { - this._runActions(prevPos, t); - } - } - this.dispatchEventWith("change"); - return end; - }; - /** - * @private - * - * @param startPos - * @param endPos - * @param includeStart - */ - ScrollTween.prototype._runActions = function (startPos, endPos, includeStart) { - if (includeStart === void 0) { includeStart = false; } - var sPos = startPos; - var ePos = endPos; - var i = -1; - var j = this._actions.length; - var k = 1; - if (startPos > endPos) { - //把所有的倒置 - sPos = endPos; - ePos = startPos; - i = j; - j = k = -1; - } - while ((i += k) != j) { - var action = this._actions[i]; - var pos = action.t; - if (pos == ePos || (pos > sPos && pos < ePos) || (includeStart && pos == startPos)) { - action.f.apply(action.o, action.p); - } - } - }; - /** - * @private - * - * @param step - * @param ratio - */ - ScrollTween.prototype._updateTargetProps = function (step, ratio) { - var p0, p1, v, v0, v1, arr; - if (!step && ratio == 1) { - this.passive = false; - p0 = p1 = this._curQueueProps; - } - else { - this.passive = !!step.v; - //不更新props. - if (this.passive) { - return; - } - //使用ease - if (step.e) { - ratio = step.e(ratio, 0, 1, 1); - } - p0 = step.p0; - p1 = step.p1; - } - for (var n in this._initQueueProps) { - if ((v0 = p0[n]) == null) { - p0[n] = v0 = this._initQueueProps[n]; - } - if ((v1 = p1[n]) == null) { - p1[n] = v1 = v0; - } - if (v0 == v1 || ratio == 0 || ratio == 1 || (typeof (v0) != "number")) { - v = ratio == 1 ? v1 : v0; - } - else { - v = v0 + (v1 - v0) * ratio; - } - var ignore = false; - if (arr = ScrollTween._plugins[n]) { - for (var i = 0, l = arr.length; i < l; i++) { - var v2 = arr[i].tween(this, n, v, p0, p1, ratio, !!step && p0 == p1, !step); - if (v2 == ScrollTween.IGNORE) { - ignore = true; - } - else { - v = v2; - } - } - } - if (!ignore) { - this._target[n] = v; - } - } - }; - /** - * Whether setting is paused - * @param value {boolean} Whether to pause - * @returns ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否暂停 - * @param value {boolean} 是否暂停 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollTween.prototype.setPaused = function (value) { - this.paused = value; - ScrollTween._register(this, !value); - return this; - }; - /** - * @private - * - * @param props - * @returns - */ - ScrollTween.prototype._cloneProps = function (props) { - var o = {}; - for (var n in props) { - o[n] = props[n]; - } - return o; - }; - /** - * @private - * - * @param o - * @returns - */ - ScrollTween.prototype._addStep = function (o) { - if (o.d > 0) { - this._steps.push(o); - o.t = this.duration; - this.duration += o.d; - } - return this; - }; - /** - * @private - * - * @param o - * @returns - */ - ScrollTween.prototype._appendQueueProps = function (o) { - var arr, oldValue, i, l, injectProps; - for (var n in o) { - if (this._initQueueProps[n] === undefined) { - oldValue = this._target[n]; - //设置plugins - if (arr = ScrollTween._plugins[n]) { - for (i = 0, l = arr.length; i < l; i++) { - oldValue = arr[i].init(this, n, oldValue); - } - } - this._initQueueProps[n] = this._curQueueProps[n] = (oldValue === undefined) ? null : oldValue; - } - else { - oldValue = this._curQueueProps[n]; - } - } - for (var n in o) { - oldValue = this._curQueueProps[n]; - if (arr = ScrollTween._plugins[n]) { - injectProps = injectProps || {}; - for (i = 0, l = arr.length; i < l; i++) { - if (arr[i].step) { - arr[i].step(this, n, oldValue, o[n], injectProps); - } - } - } - this._curQueueProps[n] = o[n]; - } - if (injectProps) { - this._appendQueueProps(injectProps); - } - return this._curQueueProps; - }; - /** - * @private - * - * @param o - * @returns - */ - ScrollTween.prototype._addAction = function (o) { - o.t = this.duration; - this._actions.push(o); - return this; - }; - /** - * Modify the property of the specified display object to a specified value - * @param props {Object} Property set of an object - * @param duration {number} Duration - * @param ease {egret.ScrollEase} Easing algorithm - * @returns {egret.ScrollTween} ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定显示对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param duration {number} 持续时间 - * @param ease {egret.ScrollEase} 缓动算法 - * @returns {egret.ScrollTween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollTween.prototype.to = function (props, duration, ease) { - if (ease === void 0) { ease = undefined; } - if (isNaN(duration) || duration < 0) { - duration = 0; - } - return this._addStep({ d: duration || 0, p0: this._cloneProps(this._curQueueProps), e: ease, p1: this._cloneProps(this._appendQueueProps(props)) }); - }; - /** - * Execute callback function - * @param callback {Function} Callback method - * @param thisObj {any} this action scope of the callback method - * @param params {any[]} Parameter of the callback method - * @returns {egret.ScrollTween} ScrollTween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行回调函数 - * @param callback {Function} 回调方法 - * @param thisObj {any} 回调方法this作用域 - * @param params {any[]} 回调方法参数 - * @returns {egret.ScrollTween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollTween.prototype.call = function (callback, thisObj, params) { - if (thisObj === void 0) { thisObj = undefined; } - if (params === void 0) { params = undefined; } - return this._addAction({ f: callback, p: params ? params : [], o: thisObj ? thisObj : this._target }); - }; - /** - * @method egret.ScrollTween#tick - * @param delta {number} - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollTween.prototype.tick = function (delta) { - if (this.paused) { - return; - } - this.setPosition(this._prevPosition + delta); - }; - /** - * @private - */ - ScrollTween._tweens = []; - /** - * @private - */ - ScrollTween.IGNORE = {}; - /** - * @private - */ - ScrollTween._plugins = {}; - /** - * @private - */ - ScrollTween._inited = false; - ScrollTween._lastTime = 0; - return ScrollTween; - }(egret.EventDispatcher)); - egret.ScrollTween = ScrollTween; - __reflect(ScrollTween.prototype, "egret.ScrollTween"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * ScrollView auxiliary classes for slides, you will pass a display object constructor. It can display more than the range display object within the specified size range. And can easily drag in this range. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/ScrollView.ts - * @language en_US - */ - /** - * ScrollView 是用于滑动的辅助类,将一个显示对象传入构造函数即可。可以在指定的尺寸范围内显示超过该范围的显示对象。并可以在此范围内随意拖动。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/ScrollView.ts - * @language zh_CN - */ - var ScrollView = (function (_super) { - __extends(ScrollView, _super); - /** - * Create a egret.ScrollView objects - * @param content {egret.DisplayObject} You need to scroll object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.ScrollView 对象 - * @param content {egret.DisplayObject} 需要滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function ScrollView(content) { - if (content === void 0) { content = null; } - var _this = _super.call(this) || this; - /** - * Start rolling threshold when the touch point from the initial touch point at a distance exceeding this value will trigger roll - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 开始滚动的阈值,当触摸点偏离初始触摸点的距离超过这个值时才会触发滚动 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.scrollBeginThreshold = 10; - /** - * Scrolling speed, the speed is required and the default speed ratio. - * The range of scrollSpeed> 0 assigned to 2:00, the speed is 2 times the default speed - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 滚动速度,这个值为需要的速度与默认速度的比值。 - * 取值范围为 scrollSpeed > 0 赋值为 2 时,速度是默认速度的 2 倍 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.scrollSpeed = 1; - /** - * @private - */ - _this._content = null; - /** - * @private - */ - _this.delayTouchBeginEvent = null; - /** - * @private - */ - _this.touchBeginTimer = null; - _this.touchEnabled = true; - _this._ScrV_Props_ = new egret.ScrollViewProperties(); - if (content) { - _this.setContent(content); - } - return _this; - } - Object.defineProperty(ScrollView.prototype, "bounces", { - /** - * Whether to enable rebound, rebound When enabled, ScrollView contents allowed to continue to drag the border after arriving at the end user drag operation, and then bounce back boundary position - * @default true - * @version Egret 2.4 - * @language en_US - */ - /** - * 是否启用回弹,当启用回弹后,ScrollView中内容在到达边界后允许继续拖动,在用户拖动操作结束后,再反弹回边界位置 - * @default true - * @version Egret 2.4 - * @language zh_CN - */ - get: function () { - return this._ScrV_Props_._bounces; - }, - set: function (value) { - this._ScrV_Props_._bounces = !!value; - }, - enumerable: true, - configurable: true - }); - /** - * Set to scroll object - * @param content {egret.DisplayObject} You need to scroll object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置需要滚动的对象 - * @param content {egret.DisplayObject} 需要滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.setContent = function (content) { - if (this._content === content) - return; - this.removeContent(); - if (content) { - this._content = content; - _super.prototype.addChild.call(this, content); - this._addEvents(); - } - }; - /** - * Remove rolling objects - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 移除滚动的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.removeContent = function () { - if (this._content) { - this._removeEvents(); - _super.prototype.removeChildAt.call(this, 0); - } - this._content = null; - }; - Object.defineProperty(ScrollView.prototype, "verticalScrollPolicy", { - /** - * Vertical scroll bar display policy, on / off / auto. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直滚动条显示策略,on/off/auto。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._ScrV_Props_._verticalScrollPolicy; - }, - set: function (value) { - if (value == this._ScrV_Props_._verticalScrollPolicy) - return; - this._ScrV_Props_._verticalScrollPolicy = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollView.prototype, "horizontalScrollPolicy", { - /** - * The horizontal scroll bar display policy, on / off / auto. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 水平滚动条显示策略,on/off/auto。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._ScrV_Props_._horizontalScrollPolicy; - }, - set: function (value) { - if (value == this._ScrV_Props_._horizontalScrollPolicy) - return; - this._ScrV_Props_._horizontalScrollPolicy = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollView.prototype, "scrollLeft", { - /** - * Gets or sets the horizontal scroll position - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取或设置水平滚动位置, - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._ScrV_Props_._scrollLeft; - }, - set: function (value) { - if (value == this._ScrV_Props_._scrollLeft) - return; - this._ScrV_Props_._scrollLeft = value; - this._validatePosition(false, true); - this._updateContentPosition(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollView.prototype, "scrollTop", { - /** - * Gets or sets the vertical scroll position - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取或设置垂直滚动位置, - * @returns {number} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._ScrV_Props_._scrollTop; - }, - set: function (value) { - if (value == this._ScrV_Props_._scrollTop) - return; - this._ScrV_Props_._scrollTop = value; - this._validatePosition(true, false); - this._updateContentPosition(); - }, - enumerable: true, - configurable: true - }); - /** - * Set scroll position - * @param top {number} The vertical scroll position - * @param left {number} The horizontal scroll position - * @param isOffset {boolean} Optional parameter, the default is false, whether it is the amount of scrolling increase as top = 1 on behalf of one pixel scroll up - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动位置 - * @param top {number} 垂直滚动位置 - * @param left {number} 水平滚动位置 - * @param isOffset {boolean} 可选参数,默认是false,是否是滚动增加量,如 top=1 代表往上滚动1像素 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.setScrollPosition = function (top, left, isOffset) { - if (isOffset === void 0) { isOffset = false; } - if (isOffset && top == 0 && left == 0) - return; - if (!isOffset && this._ScrV_Props_._scrollTop == top - && this._ScrV_Props_._scrollLeft == left) - return; - var oldTop = this._ScrV_Props_._scrollTop, oldLeft = this._ScrV_Props_._scrollLeft; - if (isOffset) { - var maxLeft = this.getMaxScrollLeft(); - var maxTop = this.getMaxScrollTop(); - if (oldTop <= 0 || oldTop >= maxTop) { - top = top / 2; - } - if (oldLeft <= 0 || oldLeft >= maxLeft) { - left = left / 2; - } - var newTop = oldTop + top; - var newLeft = oldLeft + left; - //判断是否回弹 - var bounces = this._ScrV_Props_._bounces; - if (!bounces) { - if (newTop <= 0 || newTop >= maxTop) - newTop = Math.max(0, Math.min(newTop, maxTop)); - if (newLeft <= 0 || newLeft >= maxLeft) - newLeft = Math.max(0, Math.min(newLeft, maxLeft)); - } - this._ScrV_Props_._scrollTop = newTop; - this._ScrV_Props_._scrollLeft = newLeft; - } - else { - this._ScrV_Props_._scrollTop = top; - this._ScrV_Props_._scrollLeft = left; - } - this._validatePosition(true, true); - this._updateContentPosition(); - }; - /** - * @private - * - * @param top - * @param left - */ - ScrollView.prototype._validatePosition = function (top, left) { - if (top === void 0) { top = false; } - if (left === void 0) { left = false; } - if (top) { - var height = this.height; - var contentHeight = this._getContentHeight(); - this._ScrV_Props_._scrollTop = Math.max(this._ScrV_Props_._scrollTop, (0 - height) / 2); - this._ScrV_Props_._scrollTop = Math.min(this._ScrV_Props_._scrollTop, contentHeight > height ? (contentHeight - height / 2) : height / 2); - } - if (left) { - var width = this.width; - var contentWidth = this._getContentWidth(); - this._ScrV_Props_._scrollLeft = Math.max(this._ScrV_Props_._scrollLeft, (0 - width) / 2); - this._ScrV_Props_._scrollLeft = Math.min(this._ScrV_Props_._scrollLeft, contentWidth > width ? (contentWidth - width / 2) : width / 2); - } - }; - /** - * @private - * @inheritDoc - */ - ScrollView.prototype.$setWidth = function (value) { - if (this.$explicitWidth == value) { - return; - } - _super.prototype.$setWidth.call(this, value); - this._updateContentPosition(); - }; - /** - * @private - * @inheritDoc - */ - ScrollView.prototype.$setHeight = function (value) { - if (this.$explicitHeight == value) { - return; - } - _super.prototype.$setHeight.call(this, value); - this._updateContentPosition(); - }; - /** - * @private - * - */ - ScrollView.prototype._updateContentPosition = function () { - var height = this.height; - var width = this.width; - //这里将坐标取整,避免有些浏览器精度低产生“黑线”问题 - this.scrollRect = new egret.Rectangle(Math.round(this._ScrV_Props_._scrollLeft), Math.round(this._ScrV_Props_._scrollTop), width, height); - this.dispatchEvent(new egret.Event(egret.Event.CHANGE)); - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._checkScrollPolicy = function () { - var hpolicy = this._ScrV_Props_._horizontalScrollPolicy; - var hCanScroll = this.__checkScrollPolicy(hpolicy, this._getContentWidth(), this.width); - this._ScrV_Props_._hCanScroll = hCanScroll; - var vpolicy = this._ScrV_Props_._verticalScrollPolicy; - var vCanScroll = this.__checkScrollPolicy(vpolicy, this._getContentHeight(), this.height); - this._ScrV_Props_._vCanScroll = vCanScroll; - return hCanScroll || vCanScroll; - }; - /** - * @private - * - * @param policy - * @param contentLength - * @param viewLength - * @returns - */ - ScrollView.prototype.__checkScrollPolicy = function (policy, contentLength, viewLength) { - if (policy == "on") - return true; - if (policy == "off") - return false; - return contentLength > viewLength; - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._addEvents = function () { - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this._onTouchBegin, this); - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this._onTouchBeginCapture, this, true); - this.addEventListener(egret.TouchEvent.TOUCH_END, this._onTouchEndCapture, this, true); - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._removeEvents = function () { - this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this._onTouchBegin, this); - this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this._onTouchBeginCapture, this, true); - this.removeEventListener(egret.TouchEvent.TOUCH_END, this._onTouchEndCapture, this, true); - }; - /** - * @private - * - * @param e - */ - ScrollView.prototype._onTouchBegin = function (e) { - if (e.$isDefaultPrevented) { - return; - } - var canScroll = this._checkScrollPolicy(); - if (!canScroll) { - return; - } - this._ScrV_Props_._touchStartPosition.x = e.stageX; - this._ScrV_Props_._touchStartPosition.y = e.stageY; - if (this._ScrV_Props_._isHTweenPlaying || this._ScrV_Props_._isVTweenPlaying) { - this._onScrollFinished(); - } - this._tempStage = this.stage; - this._tempStage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this._onTouchMove, this); - this._tempStage.addEventListener(egret.TouchEvent.TOUCH_END, this._onTouchEnd, this); - this._tempStage.addEventListener(egret.TouchEvent.LEAVE_STAGE, this._onTouchEnd, this); - this.addEventListener(egret.Event.ENTER_FRAME, this._onEnterFrame, this); - this._logTouchEvent(e); - e.preventDefault(); - }; - /** - * @private - * - * @param event - */ - ScrollView.prototype._onTouchBeginCapture = function (event) { - var canScroll = this._checkScrollPolicy(); - if (!canScroll) { - return; - } - var target = event.target; - while (target != this) { - if ("_checkScrollPolicy" in target) { - canScroll = target._checkScrollPolicy(); - if (canScroll) { - return; - } - } - target = target.parent; - } - event.stopPropagation(); - var evt = this.cloneTouchEvent(event); - this.delayTouchBeginEvent = evt; - if (!this.touchBeginTimer) { - this.touchBeginTimer = new egret.Timer(100, 1); - this.touchBeginTimer.addEventListener(egret.TimerEvent.TIMER_COMPLETE, this._onTouchBeginTimer, this); - } - this.touchBeginTimer.start(); - this._onTouchBegin(event); - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype._onTouchEndCapture = function (event) { - var _this = this; - if (!this.delayTouchBeginEvent) { - return; - } - this._onTouchBeginTimer(); - event.stopPropagation(); - var evt = this.cloneTouchEvent(event); - egret.callLater(function () { - if (_this.stage) { - _this.dispatchPropagationEvent(evt); - } - }, this); - }; - /** - * @private - * - */ - ScrollView.prototype._onTouchBeginTimer = function () { - this.touchBeginTimer.stop(); - var event = this.delayTouchBeginEvent; - this.delayTouchBeginEvent = null; - //Dispatch event only if the scroll view is still on the stage - if (this.stage) - this.dispatchPropagationEvent(event); - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype.dispatchPropagationEvent = function (event) { - var target = event.$target; - var list = this.$getPropagationList(target); - var length = list.length; - var targetIndex = list.length * 0.5; - var startIndex = -1; - for (var i = 0; i < length; i++) { - if (list[i] === this._content) { - startIndex = i; - break; - } - } - list.splice(0, startIndex + 1); - targetIndex -= startIndex + 1; - this.$dispatchPropagationEvent(event, list, targetIndex); - egret.Event.release(event); - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype._onTouchMove = function (event) { - if (this._ScrV_Props_._lastTouchPosition.x == event.stageX && this._ScrV_Props_._lastTouchPosition.y == event.stageY) - return; - if (!this._ScrV_Props_._scrollStarted) { - var x = event.stageX - this._ScrV_Props_._touchStartPosition.x, y = event.stageY - this._ScrV_Props_._touchStartPosition.y; - var distance = Math.sqrt(x * x + y * y); - if (distance < this.scrollBeginThreshold) { - this._logTouchEvent(event); - return; - } - } - this._ScrV_Props_._scrollStarted = true; - if (this.delayTouchBeginEvent) { - this.delayTouchBeginEvent = null; - this.touchBeginTimer.stop(); - } - this.touchChildren = false; - var offset = this._getPointChange(event); - this.setScrollPosition(offset.y, offset.x, true); - this._calcVelocitys(event); - this._logTouchEvent(event); - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype._onTouchEnd = function (event) { - this.touchChildren = true; - this._ScrV_Props_._scrollStarted = false; - this._tempStage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this._onTouchMove, this); - this._tempStage.removeEventListener(egret.TouchEvent.TOUCH_END, this._onTouchEnd, this); - this._tempStage.removeEventListener(egret.TouchEvent.LEAVE_STAGE, this._onTouchEnd, this); - this.removeEventListener(egret.Event.ENTER_FRAME, this._onEnterFrame, this); - this._moveAfterTouchEnd(); - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype._onEnterFrame = function (event) { - var time = egret.getTimer(); - if (time - this._ScrV_Props_._lastTouchTime > 100 && time - this._ScrV_Props_._lastTouchTime < 300) { - this._calcVelocitys(this._ScrV_Props_._lastTouchEvent); - } - }; - /** - * @private - * - * @param e - * @returns - */ - ScrollView.prototype._logTouchEvent = function (e) { - this._ScrV_Props_._lastTouchPosition.x = e.stageX; - this._ScrV_Props_._lastTouchPosition.y = e.stageY; - this._ScrV_Props_._lastTouchEvent = this.cloneTouchEvent(e); - this._ScrV_Props_._lastTouchTime = egret.getTimer(); - }; - /** - * @private - * - * @param e - * @returns - */ - ScrollView.prototype._getPointChange = function (e) { - return { - x: this._ScrV_Props_._hCanScroll === false ? 0 : (this._ScrV_Props_._lastTouchPosition.x - e.stageX), - y: this._ScrV_Props_._vCanScroll === false ? 0 : (this._ScrV_Props_._lastTouchPosition.y - e.stageY) - }; - }; - /** - * @private - * - * @param e - * @returns - */ - ScrollView.prototype._calcVelocitys = function (e) { - var time = egret.getTimer(); - if (this._ScrV_Props_._lastTouchTime == 0) { - this._ScrV_Props_._lastTouchTime = time; - return; - } - var change = this._getPointChange(e); - var timeoffset = time - this._ScrV_Props_._lastTouchTime; - change.x /= timeoffset; - change.y /= timeoffset; - this._ScrV_Props_._velocitys.push(change); - if (this._ScrV_Props_._velocitys.length > 5) - this._ScrV_Props_._velocitys.shift(); - this._ScrV_Props_._lastTouchPosition.x = e.stageX; - this._ScrV_Props_._lastTouchPosition.y = e.stageY; - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._getContentWidth = function () { - return this._content.$explicitWidth || this._content.width; - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._getContentHeight = function () { - return this._content.$explicitHeight || this._content.height; - }; - /** - * The left side of the maximum distance - * @returns The left side of the maximum distance - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 距离左侧的最大值 - * @returns 距离左侧最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.getMaxScrollLeft = function () { - var max = this._getContentWidth() - this.width; - return Math.max(0, max); - }; - /** - * Above the maximum distance - * @returns Above the maximum distance - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 距离上方最大值 - * @returns 距离上方最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.getMaxScrollTop = function () { - var max = this._getContentHeight() - this.height; - return Math.max(0, max); - }; - /** - * @private - * - */ - ScrollView.prototype._moveAfterTouchEnd = function () { - if (this._ScrV_Props_._velocitys.length == 0) - return; - var sum = { x: 0, y: 0 }, totalW = 0; - for (var i = 0; i < this._ScrV_Props_._velocitys.length; i++) { - var v = this._ScrV_Props_._velocitys[i]; - var w = ScrollView.weight[i]; - sum.x += v.x * w; - sum.y += v.y * w; - totalW += w; - } - this._ScrV_Props_._velocitys.length = 0; - if (this.scrollSpeed <= 0) - this.scrollSpeed = 1; - var x = sum.x / totalW * this.scrollSpeed, y = sum.y / totalW * this.scrollSpeed; - var pixelsPerMSX = Math.abs(x), pixelsPerMSY = Math.abs(y); - var maxLeft = this.getMaxScrollLeft(); - var maxTop = this.getMaxScrollTop(); - var datax = pixelsPerMSX > 0.02 ? this.getAnimationDatas(x, this._ScrV_Props_._scrollLeft, maxLeft) : { - position: this._ScrV_Props_._scrollLeft, - duration: 1 - }; - var datay = pixelsPerMSY > 0.02 ? this.getAnimationDatas(y, this._ScrV_Props_._scrollTop, maxTop) : { - position: this._ScrV_Props_._scrollTop, - duration: 1 - }; - this.setScrollLeft(datax.position, datax.duration); - this.setScrollTop(datay.position, datay.duration); - }; - /** - * @private - * - * @param tw - */ - ScrollView.prototype.onTweenFinished = function (tw) { - if (tw == this._ScrV_Props_._vScrollTween) - this._ScrV_Props_._isVTweenPlaying = false; - if (tw == this._ScrV_Props_._hScrollTween) - this._ScrV_Props_._isHTweenPlaying = false; - if (this._ScrV_Props_._isHTweenPlaying == false && this._ScrV_Props_._isVTweenPlaying == false) { - this._onScrollFinished(); - } - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._onScrollStarted = function () { - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype._onScrollFinished = function () { - egret.ScrollTween.removeTweens(this); - this._ScrV_Props_._hScrollTween = null; - this._ScrV_Props_._vScrollTween = null; - this._ScrV_Props_._isHTweenPlaying = false; - this._ScrV_Props_._isVTweenPlaying = false; - this.dispatchEvent(new egret.Event(egret.Event.COMPLETE)); - }; - /** - * Set the scroll position above the distance - * @param scrollTop Position above distance - * @param duration Easing of time, in milliseconds - * @returns Get tween vertical scrolling - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动距离上方的位置 - * @param scrollTop 距离上方的位置 - * @param duration 缓动时间,毫秒单位 - * @returns 获取垂直滚动的tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.setScrollTop = function (scrollTop, duration) { - if (duration === void 0) { duration = 0; } - var finalPosition = Math.min(this.getMaxScrollTop(), Math.max(scrollTop, 0)); - if (duration == 0) { - this.scrollTop = finalPosition; - return; - } - if (this._ScrV_Props_._bounces == false) - scrollTop = finalPosition; - var vtween = egret.ScrollTween.get(this).to({ scrollTop: scrollTop }, duration, egret.ScrollEase.quartOut); - if (finalPosition != scrollTop) { - vtween.to({ scrollTop: finalPosition }, 300, egret.ScrollEase.quintOut); - } - this._ScrV_Props_._isVTweenPlaying = true; - this._ScrV_Props_._vScrollTween = vtween; - vtween.call(this.onTweenFinished, this, [vtween]); - if (!this._ScrV_Props_._isHTweenPlaying) - this._onScrollStarted(); - }; - /** - * Set the scroll position from the left side - * @param scrollLeft From the position on the left side - * @param duration Get tween vertical scrolling - * @returns Gets the horizontal scroll tween - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置滚动距离左侧的位置 - * @param scrollLeft 距离左侧的位置 - * @param duration 缓动时间,毫秒单位 - * @returns 获取水平滚动的tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ScrollView.prototype.setScrollLeft = function (scrollLeft, duration) { - if (duration === void 0) { duration = 0; } - var finalPosition = Math.min(this.getMaxScrollLeft(), Math.max(scrollLeft, 0)); - if (duration == 0) { - this.scrollLeft = finalPosition; - return; - } - if (this._ScrV_Props_._bounces == false) - scrollLeft = finalPosition; - var htween = egret.ScrollTween.get(this).to({ scrollLeft: scrollLeft }, duration, egret.ScrollEase.quartOut); - if (finalPosition != scrollLeft) { - htween.to({ scrollLeft: finalPosition }, 300, egret.ScrollEase.quintOut); - } - this._ScrV_Props_._isHTweenPlaying = true; - this._ScrV_Props_._hScrollTween = htween; - htween.call(this.onTweenFinished, this, [htween]); - if (!this._ScrV_Props_._isVTweenPlaying) - this._onScrollStarted(); - }; - /** - * @private - * - * @param pixelsPerMS - * @param curPos - * @param maxPos - * @returns - */ - ScrollView.prototype.getAnimationDatas = function (pixelsPerMS, curPos, maxPos) { - var absPixelsPerMS = Math.abs(pixelsPerMS); - var extraFricition = 0.95; - var duration = 0; - var friction = 0.998; - var minVelocity = 0.02; - var posTo = curPos + pixelsPerMS * 500; - if (posTo < 0 || posTo > maxPos) { - posTo = curPos; - while (Math.abs(pixelsPerMS) != Infinity && Math.abs(pixelsPerMS) > minVelocity) { - posTo += pixelsPerMS; - if (posTo < 0 || posTo > maxPos) { - pixelsPerMS *= friction * extraFricition; - } - else { - pixelsPerMS *= friction; - } - duration++; - } - } - else { - duration = -Math.log(minVelocity / absPixelsPerMS) * 500; - } - var result = { - position: Math.min(maxPos + 50, Math.max(posTo, -50)), - duration: duration - }; - return result; - }; - /** - * @private - * - * @param event - * @returns - */ - ScrollView.prototype.cloneTouchEvent = function (event) { - var evt = new egret.TouchEvent(event.type, event.bubbles, event.cancelable); - evt.touchPointID = event.touchPointID; - evt.$stageX = event.stageX; - evt.$stageY = event.stageY; - //evt.ctrlKey = event.ctrlKey; - //evt.altKey = event.altKey; - //evt.shiftKey = event.shiftKey; - evt.touchDown = event.touchDown; - evt.$isDefaultPrevented = false; - evt.$target = event.target; - return evt; - }; - /** - * @private - * - * @returns - */ - ScrollView.prototype.throwNotSupportedError = function () { - egret.$error(1023); - }; - /** - * @deprecated - * @inheritDoc - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.addChild = function (child) { - this.throwNotSupportedError(); - return null; - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.addChildAt = function (child, index) { - this.throwNotSupportedError(); - return null; - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.removeChild = function (child) { - this.throwNotSupportedError(); - return null; - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.removeChildAt = function (index) { - this.throwNotSupportedError(); - return null; - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.setChildIndex = function (child, index) { - this.throwNotSupportedError(); - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.swapChildren = function (child1, child2) { - this.throwNotSupportedError(); - }; - /** - * @deprecated - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - ScrollView.prototype.swapChildrenAt = function (index1, index2) { - this.throwNotSupportedError(); - }; - /** - * @private - */ - ScrollView.weight = [1, 1.33, 1.66, 2, 2.33]; - return ScrollView; - }(egret.DisplayObjectContainer)); - egret.ScrollView = ScrollView; - __reflect(ScrollView.prototype, "egret.ScrollView"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - var ScrollViewProperties = (function () { - function ScrollViewProperties() { - /** - * @private - */ - this._verticalScrollPolicy = "auto"; - /** - * @private - */ - this._horizontalScrollPolicy = "auto"; - /** - * @private - */ - this._scrollLeft = 0; - /** - * @private - */ - this._scrollTop = 0; - /** - * @private - */ - this._hCanScroll = false; - /** - * @private - */ - this._vCanScroll = false; - /** - * @private - */ - this._lastTouchPosition = new egret.Point(0, 0); - /** - * @private - */ - this._touchStartPosition = new egret.Point(0, 0); - /** - * @private - */ - this._scrollStarted = false; - /** - * @private - */ - this._lastTouchTime = 0; - /** - * @private - */ - this._lastTouchEvent = null; - /** - * @private - */ - this._velocitys = []; - /** - * @private - */ - this._isHTweenPlaying = false; - /** - * @private - */ - this._isVTweenPlaying = false; - /** - * @private - */ - this._hScrollTween = null; - /** - * @private - */ - this._vScrollTween = null; - /** - * @private - */ - this._bounces = true; - } - return ScrollViewProperties; - }()); - egret.ScrollViewProperties = ScrollViewProperties; - __reflect(ScrollViewProperties.prototype, "egret.ScrollViewProperties"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - function $getUrl(request) { - var url = request.url; - //get请求没有设置参数,而是设置URLVariables的情况 - if (url.indexOf("?") == -1 && request.method == egret.URLRequestMethod.GET && request.data && request.data instanceof egret.URLVariables) { - url = url + "?" + request.data.toString(); - } - return url; - } - /** - * UThe URLLoader class downloads data from a URL as text, binary data, or URL-encoded variables. It is useful for downloading text files, XML, or other information to be used in a dynamic, data-driven application. - * A URLLoader object downloads all of the data from a URL before making it available to code in the applications. It sends out notifications about the progress of the download, - * which you can monitor through bytesLoaded and bytesTotal properties, as well as through dispatched events. - * @see http://edn.egret.com/cn/docs/page/601 Build communication request - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.IOErrorEvent.IO_ERROR io error. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoader.ts - * @language en_US - */ - /** - * URLLoader 类以文本、二进制数据或 URL 编码变量的形式从 URL 下载数据。在下载文本文件、XML 或其他用于动态数据驱动应用程序的信息时,它很有用。 - * URLLoader 对象会先从 URL 中下载所有数据,然后才将数据用于应用程序中的代码。它会发出有关下载进度的通知, - * 通过 bytesLoaded 和 bytesTotal 属性以及已调度的事件,可以监视下载进度。 - * @see http://edn.egret.com/cn/docs/page/601 构建通信请求 - * @event egret.Event.COMPLETE 加载完成后调度。 - * @event egret.IOErrorEvent.IO_ERROR 加载错误后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLLoader.ts - * @language zh_CN - */ - var URLLoader = (function (_super) { - __extends(URLLoader, _super); - /** - * Create an egret.URLLoader object - * @param request {URLRequest} A URLRequest object specifies the URL to be downloaded. - * If this parameter is omitted, no load operation begins. If a parameter is specified, the load operation begins immediately - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 egret.URLLoader 对象 - * @param request {URLRequest} 一个 URLRequest 对象,指定要下载的 URL。 - * 如果省略该参数,则不开始加载操作。如果已指定参数,则立即开始加载操作 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function URLLoader(request) { - if (request === void 0) { request = null; } - var _this = _super.call(this) || this; - /** - * Control whether the downloaded data is received as text (URLLoaderDataFormat.TEXT), raw binary data (URLLoaderDataFormat.BINARY), or URL-encoded variables (URLLoaderDataFormat.VARIABLES). - * If the value of the dataFormat property is URLLoaderDataFormat.TEXT, the received data is a string containing the text of the loaded file. - * If the value of the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object containing the raw binary data. - * If the value of the dataFormat property is URLLoaderDataFormat.TEXTURE, the received data is a Texture object containing the bitmap data. - * If the value of the dataFormat property is URLLoaderDataFormat.VARIABLES, the received data is a URLVariables object containing the URL-encoded variables. - * The default value is URLLoaderDataFormat.TEXT. - * @default egret.URLLoaderDataFormat.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 控制是以文本 (URLLoaderDataFormat.TEXT)、原始二进制数据 (URLLoaderDataFormat.BINARY) 还是 URL 编码变量 (URLLoaderDataFormat.VARIABLES) 接收下载的数据。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.TEXT,则所接收的数据是一个包含已加载文件文本的字符串。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.BINARY,则所接收的数据是一个包含原始二进制数据的 ByteArray 对象。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.TEXTURE,则所接收的数据是一个包含位图数据的Texture对象。 - * 如果 dataFormat 属性的值是 URLLoaderDataFormat.VARIABLES,则所接收的数据是一个包含 URL 编码变量的 URLVariables 对象。 - * @default egret.URLLoaderDataFormat.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.dataFormat = egret.URLLoaderDataFormat.TEXT; - /** - * The data received from the load operation. This property is populated only when the load operation is complete. The format of the data depends on the setting of the dataFormat property: - * If the dataFormat property is URLLoaderDataFormat.TEXT, the received data is a string containing the text of the loaded file. - * If the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object containing the raw binary data. - * If the dataFormat property is URLLoaderDataFormat.TEXTURE, the received data is a Texture object containing the bitmap data. - * If the dataFormat property is URLLoaderDataFormat.VARIABLES, the received data is a URLVariables object containing the URL-encoded variables. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从加载操作接收的数据。只有完成加载操作时,才会填充该属性。该数据的格式取决于 dataFormat 属性的设置: - * 如果 dataFormat 属性是 URLLoaderDataFormat.TEXT,则所接收的数据是一个包含已加载文件文本的字符串。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.BINARY,则所接收的数据是一个包含原始二进制数据的 ByteArray 对象。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.TEXTURE,则所接收的数据是一个包含位图数据的Texture对象。 - * 如果 dataFormat 属性是 URLLoaderDataFormat.VARIABLES,则所接收的数据是一个包含 URL 编码变量的 URLVariables 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.data = null; - /** - * @private - */ - _this._request = null; - /** - * @private - */ - _this._status = -1; - if (request) { - _this.load(request); - } - return _this; - } - /** - * Send and load data from the specified URL. The data can be received as text, raw binary data, or URL-encoded variables, depending on the value you set for the dataFormat property. - * Note that the default value of the dataFormat property is text. If you want to send data to the specified URL, you can set the data property in the URLRequest object. - * @param request {URLRequest} A URLRequest object specifies the URL to be downloaded. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从指定的 URL 发送和加载数据。可以以文本、原始二进制数据或 URL 编码变量格式接收数据,这取决于为 dataFormat 属性所设置的值。 - * 请注意 dataFormat 属性的默认值为文本。如果想将数据发送至指定的 URL,则可以在 URLRequest 对象中设置 data 属性。 - * @param request {URLRequest} 一个 URLRequest 对象,指定要下载的 URL。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLLoader.prototype.load = function (request) { - this._request = request; - this.data = null; - var loader = this; - if (loader.dataFormat == egret.URLLoaderDataFormat.TEXTURE) { - this.loadTexture(loader); - return; - } - if (loader.dataFormat == egret.URLLoaderDataFormat.SOUND) { - this.loadSound(loader); - return; - } - var virtualUrl = $getUrl(request); - var httpRequest = new egret.HttpRequest(); - httpRequest.open(virtualUrl, request.method == egret.URLRequestMethod.POST ? egret.HttpMethod.POST : egret.HttpMethod.GET); - var sendData; - if (request.method == egret.URLRequestMethod.GET || !request.data) { - } - else if (request.data instanceof egret.URLVariables) { - httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - var urlVars = request.data; - sendData = urlVars.toString(); - } - else { - httpRequest.setRequestHeader("Content-Type", "multipart/form-data"); - sendData = request.data; - } - var length = request.requestHeaders.length; - for (var i = 0; i < length; i++) { - var urlRequestHeader = request.requestHeaders[i]; - httpRequest.setRequestHeader(urlRequestHeader.name, urlRequestHeader.value); - } - httpRequest.addEventListener(egret.Event.COMPLETE, function () { - loader.data = httpRequest.response; - egret.Event.dispatchEvent(loader, egret.Event.COMPLETE); - }, this); - httpRequest.addEventListener(egret.IOErrorEvent.IO_ERROR, function () { - egret.IOErrorEvent.dispatchIOErrorEvent(loader); - }, this); - httpRequest.responseType = loader.dataFormat == egret.URLLoaderDataFormat.BINARY ? egret.HttpResponseType.ARRAY_BUFFER : egret.HttpResponseType.TEXT; - httpRequest.send(sendData); - }; - URLLoader.prototype.getResponseType = function (dataFormat) { - switch (dataFormat) { - case egret.URLLoaderDataFormat.TEXT: - case egret.URLLoaderDataFormat.VARIABLES: - return egret.URLLoaderDataFormat.TEXT; - case egret.URLLoaderDataFormat.BINARY: - return "arraybuffer"; - default: - return dataFormat; - } - }; - /** - * @private - * - * @param loader - */ - URLLoader.prototype.loadSound = function (loader) { - var self = this; - var virtualUrl = loader._request.url; - var sound = new egret.Sound(); - this.sound = sound; - sound.addEventListener(egret.Event.COMPLETE, this.onSoundoadComplete, this); - sound.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onSoundLoaderError, this); - sound.addEventListener(egret.ProgressEvent.PROGRESS, this.onSoundLoaderPostProgress, this); - sound.load(virtualUrl); - }; - URLLoader.prototype.onSoundoadComplete = function (event) { - var _this = this; - this.removeSoundLoaderListeners(); - this.data = this.sound; - window.setTimeout(function () { - _this.dispatchEventWith(egret.Event.COMPLETE); - }, 0); - }; - URLLoader.prototype.onSoundLoaderPostProgress = function (event) { - this.dispatchEvent(event); - }; - URLLoader.prototype.onSoundLoaderError = function (event) { - this.dispatchEvent(event); - }; - URLLoader.prototype.removeSoundLoaderListeners = function () { - this.sound.removeEventListener(egret.Event.COMPLETE, this.onSoundoadComplete, this); - this.sound.removeEventListener(egret.IOErrorEvent.IO_ERROR, this.onSoundLoaderError, this); - this.sound.removeEventListener(egret.ProgressEvent.PROGRESS, this.onSoundLoaderPostProgress, this); - }; - /** - * @private - * - * @param loader - */ - URLLoader.prototype.loadTexture = function (loader) { - this.virtualUrl = loader._request.url; - var imageLoader = new egret.ImageLoader(); - this.imageLoader = imageLoader; - imageLoader.addEventListener(egret.Event.COMPLETE, this.onImageLoadComplete, this); - imageLoader.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onImageLoaderError, this); - imageLoader.addEventListener(egret.ProgressEvent.PROGRESS, this.onImageLoaderPostProgress, this); - imageLoader.load(this.virtualUrl); - }; - URLLoader.prototype.onImageLoadComplete = function (event) { - var _this = this; - this.removeImageLoaderListeners(); - var texture = new egret.Texture(); - var bitmapData = this.imageLoader.data; - if (bitmapData.source.setAttribute) { - bitmapData.source.setAttribute("bitmapSrc", this.virtualUrl); - } - texture._setBitmapData(bitmapData); - this.data = texture; - window.setTimeout(function () { - _this.dispatchEventWith(egret.Event.COMPLETE); - }, 0); - }; - URLLoader.prototype.onImageLoaderPostProgress = function (event) { - this.dispatchEvent(event); - }; - URLLoader.prototype.onImageLoaderError = function (event) { - this.dispatchEvent(event); - }; - URLLoader.prototype.removeImageLoaderListeners = function () { - this.imageLoader.removeEventListener(egret.Event.COMPLETE, this.onImageLoadComplete, this); - this.imageLoader.removeEventListener(egret.IOErrorEvent.IO_ERROR, this.onImageLoaderError, this); - this.imageLoader.removeEventListener(egret.ProgressEvent.PROGRESS, this.onImageLoaderPostProgress, this); - }; - /** - * @private - * - */ - URLLoader.prototype.__recycle = function () { - this._request = null; - this.data = null; - }; - return URLLoader; - }(egret.EventDispatcher)); - egret.URLLoader = URLLoader; - __reflect(URLLoader.prototype, "egret.URLLoader"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/MovieClip.ts - * @language en_US - */ - /** - * 影片剪辑,可以通过影片剪辑播放序列帧动画。MovieClip 类从以下类继承而来:DisplayObject 和 EventDispatcher。不同于 DisplayObject 对象,MovieClip 对象拥有一个时间轴。 - * @extends egret.DisplayObject - * @event egret.Event.COMPLETE 动画播放完成。 - * @event egret.Event.LOOP_COMPLETE 动画循环播放完成。循环最后一次只派发 COMPLETE 事件,不派发 LOOP_COMPLETE 事件。 - * @see http://edn.egret.com/cn/docs/page/596 MovieClip序列帧动画 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/display/MovieClip.ts - * @language zh_CN - */ - var MovieClip = (function (_super) { - __extends(MovieClip, _super); - //Construct Function - /** - * 创建新的 MovieClip 实例。创建 MovieClip 之后,调用舞台上的显示对象容器的addElement方法。 - * @param movieClipData {movieClipData} 被引用的 movieClipData 对象 - * @version Egret 2.4 - * @platform Web,Native - */ - function MovieClip(movieClipData) { - var _this = _super.call(this) || this; - //Render Property - _this.$texture = null; - //Render Property - _this.offsetPoint = egret.Point.create(0, 0); - //Data Property - _this.$movieClipData = null; - /** - * @private - */ - _this.frames = null; - /** - * @private - */ - _this.$totalFrames = 0; - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - _this.frameLabels = null; - /** - * @private - */ - _this.$frameLabelStart = 0; - /** - * @private - */ - _this.$frameLabelEnd = 0; - /** - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - _this.frameEvents = null; - /** - * @private - */ - _this.frameIntervalTime = 0; - /** - * @private - */ - _this.$eventPool = null; - //Animation Property - _this.$isPlaying = false; - /** - * @private - */ - _this.isStopped = true; - /** - * @private - */ - _this.playTimes = 0; - /** - * @private - */ - _this.$currentFrameNum = 0; - /** - * @private - */ - _this.$nextFrameNum = 1; - /** - * @private - */ - _this.displayedKeyFrameNum = 0; - /** - * @private - */ - _this.passedTime = 0; - /** - * @private - */ - _this.$frameRate = NaN; - /** - * @private - */ - _this.lastTime = 0; - _this.$smoothing = egret.Bitmap.defaultSmoothing; - _this.setMovieClipData(movieClipData); - if (!egret.nativeRender) { - _this.$renderNode = new egret.sys.NormalBitmapNode(); - } - return _this; - } - MovieClip.prototype.createNativeDisplayObject = function () { - this.$nativeDisplayObject = new egret_native.NativeDisplayObject(11 /* BITMAP_TEXT */); - }; - Object.defineProperty(MovieClip.prototype, "smoothing", { - /** - * Whether or not is smoothed when scaled. - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - get: function () { - return this.$smoothing; - }, - set: function (value) { - if (value == this.$smoothing) { - return; - } - this.$smoothing = value; - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - */ - MovieClip.prototype.$init = function () { - this.$reset(); - var movieClipData = this.$movieClipData; - if (movieClipData && movieClipData.$isDataValid()) { - this.frames = movieClipData.frames; - this.$totalFrames = movieClipData.numFrames; - this.frameLabels = movieClipData.labels; - this.frameEvents = movieClipData.events; - this.$frameRate = movieClipData.frameRate; - this.frameIntervalTime = 1000 / this.$frameRate; - this._initFrame(); - } - }; - /** - * @private - * - */ - MovieClip.prototype.$reset = function () { - this.frames = null; - this.playTimes = 0; - this.$isPlaying = false; - this.setIsStopped(true); - this.$currentFrameNum = 0; - this.$nextFrameNum = 1; - this.displayedKeyFrameNum = 0; - this.passedTime = 0; - this.$eventPool = []; - }; - /** - * @private - * - */ - MovieClip.prototype._initFrame = function () { - if (this.$movieClipData.$isTextureValid()) { - this.advanceFrame(); - this.constructFrame(); - } - }; - /** - * @private - */ - MovieClip.prototype.$updateRenderNode = function () { - var texture = this.$texture; - if (texture) { - var offsetX = Math.round(this.offsetPoint.x); - var offsetY = Math.round(this.offsetPoint.y); - var bitmapWidth = texture.$bitmapWidth; - var bitmapHeight = texture.$bitmapHeight; - var textureWidth = texture.$getTextureWidth(); - var textureHeight = texture.$getTextureHeight(); - var destW = Math.round(texture.$getScaleBitmapWidth()); - var destH = Math.round(texture.$getScaleBitmapHeight()); - var sourceWidth = texture.$sourceWidth; - var sourceHeight = texture.$sourceHeight; - egret.sys.BitmapNode.$updateTextureData(this.$renderNode, texture.$bitmapData, texture.$bitmapX, texture.$bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH, sourceWidth, sourceHeight, egret.BitmapFillMode.SCALE, this.$smoothing); - } - }; - /** - * @private - */ - MovieClip.prototype.$measureContentBounds = function (bounds) { - var texture = this.$texture; - if (texture) { - var x = this.offsetPoint.x; - var y = this.offsetPoint.y; - var w = texture.$getTextureWidth(); - var h = texture.$getTextureHeight(); - bounds.setTo(x, y, w, h); - } - else { - bounds.setEmpty(); - } - }; - /** - * @private - * - * @param stage - * @param nestLevel - */ - MovieClip.prototype.$onAddToStage = function (stage, nestLevel) { - _super.prototype.$onAddToStage.call(this, stage, nestLevel); - if (this.$isPlaying && this.$totalFrames > 1) { - this.setIsStopped(false); - } - }; - /** - * @private - * - */ - MovieClip.prototype.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - this.setIsStopped(true); - }; - //Data Function - /** - * @private - * 返回帧标签为指定字符串的FrameLabel对象 - * @param labelName {string} 帧标签名 - * @param ignoreCase {boolean} 是否忽略大小写,可选参数,默认false - * @returns {egret.FrameLabel} FrameLabel对象 - */ - MovieClip.prototype.getFrameLabelByName = function (labelName, ignoreCase) { - if (ignoreCase === void 0) { ignoreCase = false; } - if (ignoreCase) { - labelName = labelName.toLowerCase(); - } - var frameLabels = this.frameLabels; - if (frameLabels) { - var outputFramelabel = null; - for (var i = 0; i < frameLabels.length; i++) { - outputFramelabel = frameLabels[i]; - if (ignoreCase ? outputFramelabel.name.toLowerCase() == labelName : outputFramelabel.name == labelName) { - return outputFramelabel; - } - } - } - return null; - }; - /** - * @private - * 根据帧标签,设置开始和结束的帧数 - * @param labelName {string} 帧标签名 - */ - MovieClip.prototype.getFrameStartEnd = function (labelName) { - var frameLabels = this.frameLabels; - if (frameLabels) { - var outputFramelabel = null; - for (var i = 0; i < frameLabels.length; i++) { - outputFramelabel = frameLabels[i]; - if (labelName == outputFramelabel.name) { - this.$frameLabelStart = outputFramelabel.frame; - this.$frameLabelEnd = outputFramelabel.end; - break; - } - } - } - }; - /** - * @private - * 返回指定序号的帧的FrameLabel对象 - * @param frame {number} 帧序号 - * @returns {egret.FrameLabel} FrameLabel对象 - */ - MovieClip.prototype.getFrameLabelByFrame = function (frame) { - var frameLabels = this.frameLabels; - if (frameLabels) { - var outputFramelabel = null; - for (var i = 0; i < frameLabels.length; i++) { - outputFramelabel = frameLabels[i]; - if (outputFramelabel.frame == frame) { - return outputFramelabel; - } - } - } - return null; - }; - /** - * @private - * 返回指定序号的帧对应的FrameLabel对象,如果当前帧没有标签,则返回前面最近的有标签的帧的FrameLabel对象 - * @method egret.MovieClip#getFrameLabelForFrame - * @param frame {number} 帧序号 - * @returns {egret.FrameLabel} FrameLabel对象 - */ - MovieClip.prototype.getFrameLabelForFrame = function (frame) { - var outputFrameLabel = null; - var tempFrameLabel = null; - var frameLabels = this.frameLabels; - if (frameLabels) { - for (var i = 0; i < frameLabels.length; i++) { - tempFrameLabel = frameLabels[i]; - if (tempFrameLabel.frame > frame) { - return outputFrameLabel; - } - outputFrameLabel = tempFrameLabel; - } - } - return outputFrameLabel; - }; - //Animation Function - /** - * 继续播放当前动画 - * @param playTimes {number} 播放次数。 参数为整数,可选参数,>=1:设定播放次数,<0:循环播放,默认值 0:不改变播放次数(MovieClip初始播放次数设置为1), - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.play = function (playTimes) { - if (playTimes === void 0) { playTimes = 0; } - this.lastTime = egret.getTimer(); - this.passedTime = 0; - this.$isPlaying = true; - this.setPlayTimes(playTimes); - if (this.$totalFrames > 1 && this.$stage) { - this.setIsStopped(false); - } - }; - /** - * 暂停播放动画 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.stop = function () { - this.$isPlaying = false; - this.setIsStopped(true); - }; - /** - * 将播放头移到前一帧并停止 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.prevFrame = function () { - this.gotoAndStop(this.$currentFrameNum - 1); - }; - /** - * 跳到后一帧并停止 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.nextFrame = function () { - this.gotoAndStop(this.$currentFrameNum + 1); - }; - /** - * 将播放头移到指定帧并播放 - * @param frame {any} 指定帧的帧号或帧标签 - * @param playTimes {number} 播放次数。 参数为整数,可选参数,>=1:设定播放次数,<0:循环播放,默认值 0:不改变播放次数, - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.gotoAndPlay = function (frame, playTimes) { - if (playTimes === void 0) { playTimes = 0; } - if (arguments.length == 0 || arguments.length > 2) { - egret.$error(1022, "MovieClip.gotoAndPlay()"); - } - if (typeof frame === "string") { - this.getFrameStartEnd(frame); - } - else { - this.$frameLabelStart = 0; - this.$frameLabelEnd = 0; - } - this.play(playTimes); - this.gotoFrame(frame); - }; - /** - * 将播放头移到指定帧并停止 - * @param frame {any} 指定帧的帧号或帧标签 - * @version Egret 2.4 - * @platform Web,Native - */ - MovieClip.prototype.gotoAndStop = function (frame) { - if (arguments.length != 1) { - egret.$error(1022, "MovieClip.gotoAndStop()"); - } - this.stop(); - this.gotoFrame(frame); - }; - /** - * @private - * - * @param frame - */ - MovieClip.prototype.gotoFrame = function (frame) { - var frameNum; - if (typeof frame === "string") { - frameNum = this.getFrameLabelByName(frame).frame; - } - else { - frameNum = parseInt(frame + '', 10); - if (frameNum != frame) { - egret.$error(1022, "Frame Label Not Found"); - } - } - if (frameNum < 1) { - frameNum = 1; - } - else if (frameNum > this.$totalFrames) { - frameNum = this.$totalFrames; - } - if (frameNum == this.$nextFrameNum) { - return; - } - this.$nextFrameNum = frameNum; - this.advanceFrame(); - this.constructFrame(); - this.handlePendingEvent(); - }; - /** - * @private - * - * @param advancedTime - * @returns - */ - MovieClip.prototype.advanceTime = function (timeStamp) { - var self = this; - var advancedTime = timeStamp - self.lastTime; - self.lastTime = timeStamp; - var frameIntervalTime = self.frameIntervalTime; - var currentTime = self.passedTime + advancedTime; - self.passedTime = currentTime % frameIntervalTime; - var num = currentTime / frameIntervalTime; - if (num < 1) { - return false; - } - while (num >= 1) { - num--; - self.$nextFrameNum++; - if (self.$nextFrameNum > self.$totalFrames || (self.$frameLabelStart > 0 && self.$nextFrameNum > self.$frameLabelEnd)) { - if (self.playTimes == -1) { - self.$eventPool.push(egret.Event.LOOP_COMPLETE); - self.$nextFrameNum = 1; - } - else { - self.playTimes--; - if (self.playTimes > 0) { - self.$eventPool.push(egret.Event.LOOP_COMPLETE); - self.$nextFrameNum = 1; - } - else { - self.$nextFrameNum = self.$totalFrames; - self.$eventPool.push(egret.Event.COMPLETE); - self.stop(); - break; - } - } - } - if (self.$currentFrameNum == self.$frameLabelEnd) { - self.$nextFrameNum = self.$frameLabelStart; - } - self.advanceFrame(); - } - self.constructFrame(); - self.handlePendingEvent(); - return false; - }; - /** - * @private - * - */ - MovieClip.prototype.advanceFrame = function () { - this.$currentFrameNum = this.$nextFrameNum; - var event = this.frameEvents[this.$nextFrameNum]; - if (event && event != "") { - egret.MovieClipEvent.dispatchMovieClipEvent(this, egret.MovieClipEvent.FRAME_LABEL, event); - } - }; - /** - * @private - * - */ - MovieClip.prototype.constructFrame = function () { - var self = this; - var currentFrameNum = self.$currentFrameNum; - if (self.displayedKeyFrameNum == currentFrameNum) { - return; - } - var texture = self.$movieClipData.getTextureByFrame(currentFrameNum); - self.$texture = texture; - self.$movieClipData.$getOffsetByFrame(currentFrameNum, self.offsetPoint); - self.displayedKeyFrameNum = currentFrameNum; - self.$renderDirty = true; - if (egret.nativeRender) { - self.$nativeDisplayObject.setDataToBitmapNode(self.$nativeDisplayObject.id, texture, [texture.$bitmapX, texture.$bitmapY, texture.$bitmapWidth, texture.$bitmapHeight, - self.offsetPoint.x, self.offsetPoint.y, texture.$getScaleBitmapWidth(), texture.$getScaleBitmapHeight(), - texture.$sourceWidth, texture.$sourceHeight]); - //todo 负数offsetPoint - self.$nativeDisplayObject.setWidth(texture.$getTextureWidth() + self.offsetPoint.x); - self.$nativeDisplayObject.setHeight(texture.$getTextureHeight() + self.offsetPoint.y); - } - else { - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - } - }; - /** - * @private - * - */ - MovieClip.prototype.$renderFrame = function () { - var self = this; - self.$texture = self.$movieClipData.getTextureByFrame(self.$currentFrameNum); - self.$renderDirty = true; - var p = self.$parent; - if (p && !p.$cacheDirty) { - p.$cacheDirty = true; - p.$cacheDirtyUp(); - } - var maskedObject = self.$maskedObject; - if (maskedObject && !maskedObject.$cacheDirty) { - maskedObject.$cacheDirty = true; - maskedObject.$cacheDirtyUp(); - } - }; - /** - * @private - * - */ - MovieClip.prototype.handlePendingEvent = function () { - if (this.$eventPool.length != 0) { - this.$eventPool.reverse(); - var eventPool = this.$eventPool; - var length_3 = eventPool.length; - var isComplete = false; - var isLoopComplete = false; - for (var i = 0; i < length_3; i++) { - var event_1 = eventPool.pop(); - if (event_1 == egret.Event.LOOP_COMPLETE) { - isLoopComplete = true; - } - else if (event_1 == egret.Event.COMPLETE) { - isComplete = true; - } - else { - this.dispatchEventWith(event_1); - } - } - if (isLoopComplete) { - this.dispatchEventWith(egret.Event.LOOP_COMPLETE); - } - if (isComplete) { - this.dispatchEventWith(egret.Event.COMPLETE); - } - } - }; - Object.defineProperty(MovieClip.prototype, "totalFrames", { - //Properties - /** - * MovieClip 实例中帧的总数 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$totalFrames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "currentFrame", { - /** - * MovieClip 实例当前播放的帧的序号 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$currentFrameNum; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "currentFrameLabel", { - /** - * MovieClip 实例当前播放的帧的标签。如果当前帧没有标签,则 currentFrameLabel返回null。 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - var label = this.getFrameLabelByFrame(this.$currentFrameNum); - return label && label.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "currentLabel", { - /** - * 当前播放的帧对应的标签,如果当前帧没有标签,则currentLabel返回包含标签的先前帧的标签。如果当前帧和先前帧都不包含标签,currentLabel返回null。 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - var label = this.getFrameLabelForFrame(this.$currentFrameNum); - return label ? label.name : null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "frameRate", { - /** - * MovieClip 实例的帧频 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$frameRate; - }, - set: function (value) { - if (value == this.$frameRate) { - return; - } - this.$frameRate = value; - this.frameIntervalTime = 1000 / this.$frameRate; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "isPlaying", { - /** - * MovieClip 实例当前是否正在播放 - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$isPlaying; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "movieClipData", { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return this.$movieClipData; - }, - /** - * MovieClip数据源 - */ - set: function (value) { - this.setMovieClipData(value); - }, - enumerable: true, - configurable: true - }); - /** - * @private - * - * @param value - */ - MovieClip.prototype.setMovieClipData = function (value) { - if (this.$movieClipData == value) { - return; - } - this.$movieClipData = value; - this.$init(); - }; - /** - * @private - * - * @param value - */ - MovieClip.prototype.setPlayTimes = function (value) { - if (value < 0 || value >= 1) { - this.playTimes = value < 0 ? -1 : Math.floor(value); - } - }; - /** - * @private - * - * @param value - */ - MovieClip.prototype.setIsStopped = function (value) { - if (this.isStopped == value) { - return; - } - this.isStopped = value; - if (value) { - egret.ticker.$stopTick(this.advanceTime, this); - } - else { - this.playTimes = this.playTimes == 0 ? 1 : this.playTimes; - this.lastTime = egret.getTimer(); - egret.ticker.$startTick(this.advanceTime, this); - } - }; - return MovieClip; - }(egret.DisplayObject)); - egret.MovieClip = MovieClip; - __reflect(MovieClip.prototype, "egret.MovieClip"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The URLRequest class captures all of the information in a single HTTP request. - * @see http://edn.egret.com/cn/index.php/article/index/id/601 Build communication request - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequest.ts - * @language en_US - */ - /** - * URLRequest 类可捕获单个 HTTP 请求中的所有信息。 - * @see http://edn.egret.com/cn/index.php/article/index/id/601 构建通信请求 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequest.ts - * @language zh_CN - */ - var URLRequest = (function (_super) { - __extends(URLRequest, _super); - /** - * Create an egret.URLRequest object - * @param url {string} Addresses for URL requests - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLRequest 对象 - * @param url {string} 进行网络请求的地址 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function URLRequest(url) { - if (url === void 0) { url = null; } - var _this = _super.call(this) || this; - /** - * An object contains data to be transmitted with the URL request. - * This property is used in conjunction with the method property. When the value of method is GET, the value of data is appended to the value of URLRequest.url, using HTTP query-string syntax. - * When the method value is POST (or any value other than GET), the value of data is transmitted in the body of the HTTP request. - * The URLRequest API offers binary POST support and support for URL-encoded variables, as well as support for strings. The data object can be a ArrayBuffer, URLVariables, or String object. - * The way in which the data is used depends on the type of object used: - * If the object is a ArrayBuffer object, the binary data of the ArrayBuffer object is used as POST data. For GET, data of ArrayBuffer type is not supported. - * If the object is a URLVariables object and the method is POST, then the variables are encoded using x-www-form-urlencoded format and the resulting string is used as POST data. - * If the object is a URLVariables object and the method is GET, the URLVariables object will define variables to be sent with the URLRequest object. - * Otherwise, the object is converted into a string, and the string is used as the POST or GET data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个对象,它包含将随 URL 请求一起传输的数据。 - * 该属性与 method 属性配合使用。当 method 值为 GET 时,将使用 HTTP 查询字符串语法将 data 值追加到 URLRequest.url 值。 - * 当 method 值为 POST(或 GET 之外的任何值)时,将在 HTTP 请求体中传输 data 值。 - * URLRequest API 支持二进制 POST,并支持 URL 编码变量和字符串。该数据对象可以是 ArrayBuffer、URLVariables 或 String 对象。 - * 该数据的使用方式取决于所用对象的类型: - * 如果该对象为 ArrayBuffer 对象,则 ArrayBuffer 对象的二进制数据用作 POST 数据。对于 GET,不支持 ArrayBuffer 类型的数据。 - * 如果该对象是 URLVariables 对象,并且该方法是 POST,则使用 x-www-form-urlencoded 格式对变量进行编码,并且生成的字符串会用作 POST 数据。 - * 如果该对象是 URLVariables 对象,并且该方法是 GET,则 URLVariables 对象将定义要随 URLRequest 对象一起发送的变量。 - * 否则,该对象会转换为字符串,并且该字符串会用作 POST 或 GET 数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.data = null; - /** - * Request method, valid values are URLRequestMethod.GET or URLRequestMethod.POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 请求方式,有效值为URLRequestMethod.GET 或 URLRequestMethod.POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.method = egret.URLRequestMethod.GET; - /** - * The requested URL. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 所请求的 URL。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.url = ""; - /** - * The array of HTTP request headers to be appended to the HTTP request. The array is composed of URLRequestHeader objects. - * Each object in the array must be a URLRequestHeader object that contains a name string and a value string. - * Because of browser compatibility, this property has not been achieved in html5 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要追加到 HTTP 请求的 HTTP 请求标头的数组。该数组由 URLRequestHeader 对象组成。 - * 数组中的每一对象必须是包含一个名称字符串和一个值字符串的 URLRequestHeader 对象。 - * 由于浏览器兼容性原因,该属性在 html5 中并未实现 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.requestHeaders = []; - _this.url = url; - return _this; - } - return URLRequest; - }(egret.HashObject)); - egret.URLRequest = URLRequest; - __reflect(URLRequest.prototype, "egret.URLRequest"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * A URLRequestHeader object encapsulates a single HTTP request header and consists of a name/value pair. URLRequestHeader objects are used in the requestHeaders property of the URLRequest class. - * Note: Because of browser compatibility, this property has not been achieved in html5 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestHeader.ts - * @language en_US - */ - /** - * URLRequestHeader 对象封装了一个 HTTP 请求标头并由一个名称/值对组成。URLRequestHeader 对象在 URLRequest 类的 requestHeaders 属性中使用。 - * 注意:由于浏览器兼容性原因,在 html5 中并未实现 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestHeader.ts - * @language zh_CN - */ - var URLRequestHeader = (function () { - /** - * Create an egret.URLRequestHeader object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLRequestHeader 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function URLRequestHeader(name, value) { - /** - * HTTP request header name, such as Content-Type - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HTTP 请求标头名称,如 Content-Type - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - this.name = ""; - /** - * The values associated with the name property (such as text/plain). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 与 name 属性相关联的值,如 text/plain - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - this.value = ""; - this.name = name; - this.value = value; - } - return URLRequestHeader; - }()); - egret.URLRequestHeader = URLRequestHeader; - __reflect(URLRequestHeader.prototype, "egret.URLRequestHeader"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The URLRequestMethod class provides values that specify whether the - * URLRequest object should use the POST method or the GET method when sending data to a server. - * @see http://edn.egret.com/cn/docs/page/599 POST与GET - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestMethod.ts - * @language en_US - */ - /** - * URLRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时, - * URLRequest 对象应使用 POST 方法还是 GET 方法。 - * @see http://edn.egret.com/cn/docs/page/599 POST与GET - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLRequestMethod.ts - * @language zh_CN - */ - var URLRequestMethod = (function () { - function URLRequestMethod() { - } - /** - * Specify that the URLRequest object is a GET. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 URLRequest 对象是一个 GET。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLRequestMethod.GET = "get"; - /** - * Specify that the URLRequest object is a POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 URLRequest 对象是一个 POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLRequestMethod.POST = "post"; - return URLRequestMethod; - }()); - egret.URLRequestMethod = URLRequestMethod; - __reflect(URLRequestMethod.prototype, "egret.URLRequestMethod"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * The URLVariables class allows you to transfer variables between an application and a server. - * Use URLVariables objects with methods of the URLLoader class and the data property of the URLRequest class. - * @see http://edn.egret.com/cn/docs/page/598 Send the request with parameters - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLVariables.ts - * @language en_US - */ - /** - * 使用 URLVariables 类可以在应用程序和服务器之间传输变量。 - * 将 URLVariables 对象与 URLLoader 类的方法、URLRequest 类的 data 属性一起使用。 - * @see http://edn.egret.com/cn/docs/page/598 发送带参数的请求 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/net/URLVariables.ts - * @language zh_CN - */ - var URLVariables = (function (_super) { - __extends(URLVariables, _super); - /** - * Create an egret.URLVariable object - * @param source {String} A URL-encoded string containing name/value pairs. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.URLVariables 对象 - * @param source {String} 包含名称/值对的 URL 编码的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function URLVariables(source) { - if (source === void 0) { source = null; } - var _this = _super.call(this) || this; - /** - * Key-value pair data object saved in this URLVariables object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 此 URLVariables 储存的键值对数据对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - _this.variables = null; - if (source !== null) { - _this.decode(source); - } - return _this; - } - /** - * Convert the variable string into the property of this URLVariables.variables object. - * @param source {string} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将变量字符串转换为此 URLVariables.variables 对象的属性。 - * @param source {string} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLVariables.prototype.decode = function (source) { - if (!this.variables) { - this.variables = {}; - } - source = source.split("+").join(" "); - var tokens, re = /[?&]?([^=]+)=([^&]*)/g; - while (tokens = re.exec(source)) { - var key = decodeURIComponent(tokens[1]), val = decodeURIComponent(tokens[2]); - //没有重复键值,直接赋值 - if ((key in this.variables) == false) { - this.variables[key] = val; - continue; - } - //有重复键值,如果已经存在数组,直接push到数组,否则创建一个新数组 - var value = this.variables[key]; - if (value instanceof Array) { - value.push(val); - } - else { - this.variables[key] = [value, val]; - } - } - }; - /** - * Return a string containing all enumerable variables using the MIME content encoding format : application/x-www-form-urlencoded. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 以 MIME 内容编码格式 application/x-www-form-urlencoded 返回包含所有可枚举变量的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - URLVariables.prototype.toString = function () { - if (!this.variables) { - return ""; - } - var variables = this.variables; - var stringArray = []; - for (var key in variables) { - stringArray.push(this.encodeValue(key, variables[key])); - } - return stringArray.join("&"); - }; - /** - * @private - * - * @param key - * @param value - */ - URLVariables.prototype.encodeValue = function (key, value) { - if (value instanceof Array) { - return this.encodeArray(key, value); - } - else { - return encodeURIComponent(key) + "=" + encodeURIComponent(value); - } - }; - /** - * @private - * - * @param key - * @param value - */ - URLVariables.prototype.encodeArray = function (key, value) { - if (!key) - return ""; - if (value.length == 0) { - return encodeURIComponent(key) + "="; - } - return value.map(function (v) { return encodeURIComponent(key) + "=" + encodeURIComponent(v); }).join("&"); - }; - return URLVariables; - }(egret.HashObject)); - egret.URLVariables = URLVariables; - __reflect(URLVariables.prototype, "egret.URLVariables"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/player/Ticker.ts - * @language en_US - */ - /** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/player/Ticker.ts - * @language zh_CN - */ - var Ticker = (function (_super) { - __extends(Ticker, _super); - /** - * @deprecated - * @version Egret 2.4 - * @platform Web,Native - */ - function Ticker() { - var _this = _super.call(this) || this; - _this._timeScale = 1; - _this._paused = false; - _this._callIndex = -1; - _this._lastTime = 0; - _this.callBackList = []; - if (Ticker.instance != null) { - if (true) { - egret.$error(1033); - } - } - egret.ticker.$startTick(_this.update, _this); - _this._lastTime = egret.getTimer(); - return _this; - } - Ticker.prototype.update = function (timeStamp) { - var advancedTime = timeStamp - this._lastTime; - this._lastTime = timeStamp; - if (this._paused) { - return false; - } - var frameTime = advancedTime * this._timeScale; - this._callList = this.callBackList.concat(); - this._callIndex = 0; - for (; this._callIndex < this._callList.length; this._callIndex++) { - var eventBin = this._callList[this._callIndex]; - eventBin.listener.call(eventBin.thisObject, frameTime); - } - this._callIndex = -1; - this._callList = null; - return false; - }; - /** - * 注册帧回调事件,同一函数的重复监听会被忽略。推荐使用 egret.startTick 替代此方法。 - * @method egret.Ticker#register - * @param listener {Function} 帧回调函数,参数返回上一帧和这帧的间隔时间。示例:onEnterFrame(frameTime:number):void - * @param thisObject {any} 帧回调函数的this对象 - * @param priority {number} 事件优先级,开发者请勿传递 Number.NEGATIVE_INFINITY 和 Number.POSITIVE_INFINITY - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - Ticker.prototype.register = function (listener, thisObject, priority) { - if (priority === void 0) { priority = 0; } - this.$insertEventBin(this.callBackList, "", listener, thisObject, false, priority, false); - }; - /** - * 取消侦听enterFrame事件。推荐使用 egret.stopTick 替代此方法。 - * @method egret.Ticker#unregister - * @param listener {Function} 事件侦听函数 - * @param thisObject {any} 侦听函数的this对象 - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - Ticker.prototype.unregister = function (listener, thisObject) { - this.$removeEventBin(this.callBackList, listener, thisObject); - }; - /** - * @deprecated - * @param timeScale {number} - * @private - */ - Ticker.prototype.setTimeScale = function (timeScale) { - this._timeScale = timeScale; - }; - /** - * @deprecated - * @method egret.Ticker#getTimeScale - * @private - */ - Ticker.prototype.getTimeScale = function () { - return this._timeScale; - }; - /** - * 暂停 - * @deprecated - * @method egret.Ticker#pause - */ - Ticker.prototype.pause = function () { - this._paused = true; - }; - /** - * 继续 - * @deprecated - * @method egret.Ticker#resume - */ - Ticker.prototype.resume = function () { - this._paused = false; - }; - /** - * @method egret.Ticker.getInstance - * @returns {Ticker} - * @version Egret 2.4 - * @platform Web,Native - * @deprecated - */ - Ticker.getInstance = function () { - if (Ticker.instance == null) { - Ticker.instance = new Ticker(); - } - return Ticker.instance; - }; - return Ticker; - }(egret.EventDispatcher)); - egret.Ticker = Ticker; - __reflect(Ticker.prototype, "egret.Ticker"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @class egret.MainContext - * @classdesc - * MainContext是游戏的核心跨平台接口,组合了多个功能Context,并是游戏启动的主入口 - * @extends egret.EventDispatcher - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - var MainContext = (function (_super) { - __extends(MainContext, _super); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function MainContext() { - return _super.call(this) || this; - } - Object.defineProperty(MainContext.prototype, "stage", { - /** - * 渲染Context - * @member egret.MainContext#rendererContext - * @version Egret 2.4 - * @platform Web,Native - */ - //public rendererContext:RendererContext = null; - /** - * 触摸Context - * @member egret.MainContext#touchContext - * @version Egret 2.4 - * @platform Web,Native - */ - //public touchContext:TouchContext = null; - /** - * 设备divice - * @member egret.MainContext#deviceContext - * @version Egret 2.4 - * @platform Web,Native - */ - //public deviceContext:DeviceContext = null; - /** - * 舞台 - * @member egret.MainContext#stage - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - return egret.sys.$TempStage; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MainContext, "instance", { - /** - * @method egret.Ticker.getInstance - * @returns {Ticker} - * @version Egret 2.4 - * @platform Web,Native - */ - get: function () { - if (MainContext._instance == null) { - MainContext._instance = new MainContext(); - } - return MainContext._instance; - }, - enumerable: true, - configurable: true - }); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - MainContext.deviceType = null; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - MainContext.DEVICE_PC = "web"; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - MainContext.DEVICE_MOBILE = "native"; - return MainContext; - }(egret.EventDispatcher)); - egret.MainContext = MainContext; - __reflect(MainContext.prototype, "egret.MainContext"); -})(egret || (egret = {})); -/** - * @private - */ -egret["testDeviceType1"] = function () { - if (!window["navigator"] || !navigator) { - return true; - } - var ua = navigator.userAgent.toLowerCase(); - return (ua.indexOf('mobile') != -1 || ua.indexOf('android') != -1); -}; -egret.MainContext.deviceType = egret["testDeviceType1"]() ? egret.MainContext.DEVICE_MOBILE : egret.MainContext.DEVICE_PC; -delete egret["testDeviceType1"]; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Tool class for object cache repeat use, which can be used to construct an object pool. Objects are automatically recycled after a certain duration. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/Recycler.ts - * @private - * @language en_US - */ - /** - * 对象缓存复用工具类,可用于构建对象池,一段时间后会自动回收对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/Recycler.ts - * @private - * @language zh_CN - */ - var Recycler = (function (_super) { - __extends(Recycler, _super); - /** - * Create an egret.Recycler object - * @param autoDisposeTime {number} Number of frames when objects are destroyed automatically. Default value: 300 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Recycler 对象 - * @param autoDisposeTime {number} 多少帧后自动销毁对象,默认值300 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function Recycler(autoDisposeTime) { - if (autoDisposeTime === void 0) { autoDisposeTime = 300; } - var _this = _super.call(this) || this; - /** - * @private - */ - _this.objectPool = []; - /** - * @private - */ - _this._length = 0; - if (autoDisposeTime < 1) - autoDisposeTime = 1; - _this.autoDisposeTime = autoDisposeTime; - _this.frameCount = 0; - return _this; - } - Recycler.$init = function () { - egret.ticker.$startTick(Recycler.onUpdate, Recycler); - }; - Recycler.onUpdate = function (timeStamp) { - var list = Recycler._callBackList; - for (var i = list.length - 1; i >= 0; i--) { - list[i].$checkFrame(); - } - return false; - }; - /** - * @private - * - */ - Recycler.prototype.$checkFrame = function () { - this.frameCount--; - if (this.frameCount <= 0) { - this.dispose(); - } - }; - Object.defineProperty(Recycler.prototype, "length", { - /** - * Number of cached objects" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓存的对象数量 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._length; - }, - enumerable: true, - configurable: true - }); - /** - * Cache an object for repeat use - * @param object {any} The object to be cached - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓存一个对象以复用 - * @param object {any} 需要缓存的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Recycler.prototype.push = function (object) { - var pool = this.objectPool; - if (pool.indexOf(object) == -1) { - pool.push(object); - if (object.__recycle) { - object.__recycle(); - } - this._length++; - if (this.frameCount == 0) { - this.frameCount = this.autoDisposeTime; - Recycler._callBackList.push(this); - } - } - }; - /** - * Obtain a cached object - * @returns {any} The obtained cached object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个缓存的对象 - * @returns {any} 获得的缓存对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Recycler.prototype.pop = function () { - if (this._length == 0) - return null; - this._length--; - return this.objectPool.pop(); - }; - /** - * Immediately clear all cached objects. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 立即清空所有缓存的对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Recycler.prototype.dispose = function () { - if (this._length > 0) { - this.objectPool = []; - this._length = 0; - } - this.frameCount = 0; - var list = Recycler._callBackList; - var index = list.indexOf(this); - if (index != -1) { - list.splice(index, 1); - } - }; - /** - * @private - */ - Recycler._callBackList = []; - return Recycler; - }(egret.HashObject)); - egret.Recycler = Recycler; - __reflect(Recycler.prototype, "egret.Recycler"); - Recycler.$init(); -})(egret || (egret = {})); -var egret; -(function (egret) { - var setIntervalCache = {}; - var setIntervalIndex = 0; - var setIntervalCount = 0; - var lastTime = 0; - /** - * To specify a delay (in milliseconds) calls the function specified interval loop. - * @param listener {Function} Listener function - * @param thisObject {any} this object - * @param delay {number} Delay time, in milliseconds - * @param ...args {any} Parameter list - * @returns {number} Return index which can be used for clearInterval - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setInterval.ts - * @language en_US - */ - /** - * 以指定的延迟(以毫秒为单位)间隔循环调用指定的函数。 - * @param listener {Function} 侦听函数 - * @param thisObject {any} this对象 - * @param delay {number} 延迟时间,以毫秒为单位 - * @param ...args {any} 参数列表 - * @returns {number} 返回索引,可以用于 clearInterval - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setInterval.ts - * @language zh_CN - */ - function setInterval(listener, thisObject, delay) { - var args = []; - for (var _i = 3; _i < arguments.length; _i++) { - args[_i - 3] = arguments[_i]; - } - var data = { listener: listener, thisObject: thisObject, delay: delay, originDelay: delay, params: args }; - setIntervalCount++; - if (setIntervalCount == 1) { - lastTime = egret.getTimer(); - egret.ticker.$startTick(intervalUpdate, null); - } - setIntervalIndex++; - setIntervalCache[setIntervalIndex] = data; - return setIntervalIndex; - } - egret.setInterval = setInterval; - /** - * Clear function to run after a specified delay. - * @param key {number} Index that egret.setInterval returns - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/setInterval.ts - * @language en_US - */ - /** - * 清除指定延迟后运行的函数。 - * @param key {number} egret.setInterval所返回的索引 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/setInterval.ts - * @language zh_CN - */ - function clearInterval(key) { - if (setIntervalCache[key]) { - setIntervalCount--; - delete setIntervalCache[key]; - if (setIntervalCount == 0) { - egret.ticker.$stopTick(intervalUpdate, null); - } - } - } - egret.clearInterval = clearInterval; - /** - * @private - * - * @param dt - */ - function intervalUpdate(timeStamp) { - var dt = timeStamp - lastTime; - lastTime = timeStamp; - for (var key in setIntervalCache) { - var data = setIntervalCache[key]; - data.delay -= dt; - if (data.delay <= 0) { - data.delay = data.originDelay; - data.listener.apply(data.thisObject, data.params); - } - } - return false; - } -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var setTimeoutCache = {}; - var setTimeoutIndex = 0; - var setTimeoutCount = 0; - var lastTime = 0; - /** - * Run the designated function in specified delay (in milliseconds). - * @param listener {Function} Listener function - * @param thisObject {any} this object - * @param delay {number} Delay time, in milliseconds - * @param ...args {any} Parameter list - * @returns {number} Return index which can be used for clearTimeout - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setTimeout.ts - * @language en_US - */ - /** - * 在指定的延迟(以毫秒为单位)后运行指定的函数。 - * @param listener {Function} 侦听函数 - * @param thisObject {any} this对象 - * @param delay {number} 延迟时间,以毫秒为单位 - * @param ...args {any} 参数列表 - * @returns {number} 返回索引,可以用于 clearTimeout - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/game/utils/setTimeout.ts - * @language zh_CN - */ - function setTimeout(listener, thisObject, delay) { - var args = []; - for (var _i = 3; _i < arguments.length; _i++) { - args[_i - 3] = arguments[_i]; - } - var data = { listener: listener, thisObject: thisObject, delay: delay, params: args }; - setTimeoutCount++; - if (setTimeoutCount == 1 && egret.ticker) { - lastTime = egret.getTimer(); - egret.ticker.$startTick(timeoutUpdate, null); - } - setTimeoutIndex++; - setTimeoutCache[setTimeoutIndex] = data; - return setTimeoutIndex; - } - egret.setTimeout = setTimeout; - /** - * Function run after the specified delay is cleared. - * @param key {number} Index that egret.setTimeout returns - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除指定延迟后运行的函数。 - * @param key {number} egret.setTimeout所返回的索引 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function clearTimeout(key) { - if (setTimeoutCache[key]) { - setTimeoutCount--; - delete setTimeoutCache[key]; - if (setTimeoutCount == 0 && egret.ticker) { - egret.ticker.$stopTick(timeoutUpdate, null); - } - } - } - egret.clearTimeout = clearTimeout; - /** - * @private - * - * @param dt - */ - function timeoutUpdate(timeStamp) { - var dt = timeStamp - lastTime; - lastTime = timeStamp; - for (var key in setTimeoutCache) { - var key2 = key; - var data = setTimeoutCache[key2]; - data.delay -= dt; - if (data.delay <= 0) { - clearTimeout(key2); - data.listener.apply(data.thisObject, data.params); - } - } - return false; - } -})(egret || (egret = {})); diff --git a/demo/libs/modules/game/game.min.js b/demo/libs/modules/game/game.min.js deleted file mode 100644 index b9bd0ea1..00000000 --- a/demo/libs/modules/game/game.min.js +++ /dev/null @@ -1,2 +0,0 @@ -var __reflect=this&&this.__reflect||function(t,e,r){t.__class__=e,r?r.push(e):r=[e],t.__types__=t.__types__?r.concat(t.__types__):r},__extends=this&&this.__extends||function(t,e){function r(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);r.prototype=e.prototype,t.prototype=new r},egret;!function(t){var e=function(){function t(){}return t.BINARY="binary",t.TEXT="text",t.VARIABLES="variables",t.TEXTURE="texture",t.SOUND="sound",t}();t.URLLoaderDataFormat=e,__reflect(e.prototype,"egret.URLLoaderDataFormat")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,r,i){var o=t.call(this)||this;return o._name=e,o._frame=0|r,i&&(o._end=0|i),o}return __extends(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"frame",{get:function(){return this._frame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),e.prototype.clone=function(){return new e(this._name,this._frame,this._end)},e}(t.EventDispatcher);t.FrameLabel=e,__reflect(e.prototype,"egret.FrameLabel")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(){var t=e.call(this)||this;return t.$mcData=null,t.numFrames=1,t.frames=[],t.labels=null,t.events=[],t.frameRate=0,t.textureData=null,t.spriteSheet=null,t}return __extends(r,e),r.prototype.$init=function(t,e,r){this.textureData=e,this.spriteSheet=r,this.setMCData(t)},r.prototype.getKeyFrameData=function(t){var e=this.frames[t-1];return e.frame&&(e=this.frames[e.frame-1]),e},r.prototype.getTextureByFrame=function(t){var e=this.getKeyFrameData(t);if(e.res){var r=this.getTextureByResName(e.res);return r}return null},r.prototype.$getOffsetByFrame=function(t,e){var r=this.getKeyFrameData(t);r.res&&e.setTo(0|r.x,0|r.y)},r.prototype.getTextureByResName=function(t){if(null==this.spriteSheet)return null;var e=this.spriteSheet.getTexture(t);if(!e){var r=this.textureData[t];e=this.spriteSheet.createTexture(t,r.x,r.y,r.w,r.h)}return e},r.prototype.$isDataValid=function(){return this.frames.length>0},r.prototype.$isTextureValid=function(){return null!=this.textureData&&null!=this.spriteSheet},r.prototype.$fillMCData=function(t){this.frameRate=t.frameRate||24,this.fillFramesData(t.frames),this.fillFrameLabelsData(t.labels),this.fillFrameEventsData(t.events)},r.prototype.fillFramesData=function(t){for(var e,r=this.frames,i=t?t.length:0,o=0;i>o;o++){var n=t[o];if(r.push(n),n.duration){var s=parseInt(n.duration);if(s>1){e=r.length;for(var a=1;s>a;a++)r.push({frame:e})}}}this.numFrames=r.length},r.prototype.fillFrameLabelsData=function(e){if(e){var r=e.length;if(r>0){this.labels=[];for(var i=0;r>i;i++){var o=e[i];this.labels.push(new t.FrameLabel(o.name,o.frame,o.end))}}}},r.prototype.fillFrameEventsData=function(t){if(t){var e=t.length;if(e>0){this.events=[];for(var r=0;e>r;r++){var i=t[r];this.events[i.frame]=i.name}}}},Object.defineProperty(r.prototype,"mcData",{get:function(){return this.$mcData},set:function(t){this.setMCData(t)},enumerable:!0,configurable:!0}),r.prototype.setMCData=function(t){this.$mcData!=t&&(this.$mcData=t,t&&this.$fillMCData(t))},r}(t.HashObject);t.MovieClipData=e,__reflect(e.prototype,"egret.MovieClipData")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(t,r){var i=e.call(this)||this;return i.enableCache=!0,i.$mcDataCache={},i.$mcDataSet=t,i.setTexture(r),i}return __extends(r,e),r.prototype.clearCache=function(){this.$mcDataCache={}},r.prototype.generateMovieClipData=function(e){if(void 0===e&&(e=""),""==e&&this.$mcDataSet)for(e in this.$mcDataSet.mc)break;if(""==e)return null;var r=this.findFromCache(e,this.$mcDataCache);return r||(r=new t.MovieClipData,this.fillData(e,r,this.$mcDataCache)),r},r.prototype.findFromCache=function(t,e){return this.enableCache&&e[t]?e[t]:null},r.prototype.fillData=function(t,e,r){if(this.$mcDataSet){var i=this.$mcDataSet.mc[t];i&&(e.$init(i,this.$mcDataSet.res,this.$spriteSheet),this.enableCache&&(r[t]=e))}},Object.defineProperty(r.prototype,"mcDataSet",{get:function(){return this.$mcDataSet},set:function(t){this.$mcDataSet=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"texture",{set:function(t){this.setTexture(t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"spriteSheet",{get:function(){return this.$spriteSheet},enumerable:!0,configurable:!0}),r.prototype.setTexture=function(e){this.$spriteSheet=e?new t.SpriteSheet(e):null},r}(t.EventDispatcher);t.MovieClipDataFactory=e,__reflect(e.prototype,"egret.MovieClipDataFactory")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(t,r,i,o){void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===o&&(o=null);var n=e.call(this,t,r,i)||this;return n.frameLabel=null,n.frameLabel=o,n}return __extends(r,e),r.dispatchMovieClipEvent=function(e,i,o){void 0===o&&(o=null);var n=t.Event.create(r,i);n.frameLabel=o;var s=e.dispatchEvent(n);return t.Event.release(n),s},r.FRAME_LABEL="frame_label",r}(t.Event);t.MovieClipEvent=e,__reflect(e.prototype,"egret.MovieClipEvent")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){t.$error(1014)}return e.get=function(t){return-1>t&&(t=-1),t>1&&(t=1),function(e){return 0==t?e:0>t?e*(e*-t+1+t):e*((2-e)*t+(1-t))}},e.getPowOut=function(t){return function(e){return 1-Math.pow(1-e,t)}},e.quintOut=e.getPowOut(5),e.quartOut=e.getPowOut(4),e}();t.ScrollEase=e,__reflect(e.prototype,"egret.ScrollEase");var r=function(e){function r(t,r,i){var o=e.call(this)||this;return o._target=null,o._useTicks=!1,o.ignoreGlobalPause=!1,o.loop=!1,o.pluginData=null,o._steps=null,o._actions=null,o.paused=!1,o.duration=0,o._prevPos=-1,o.position=null,o._prevPosition=0,o._stepPosition=0,o.passive=!1,o.initialize(t,r,i),o}return __extends(r,e),r.get=function(t,e,i,o){return void 0===e&&(e=null),void 0===i&&(i=null),void 0===o&&(o=!1),o&&r.removeTweens(t),new r(t,e,i)},r.removeTweens=function(t){if(t.tween_count){for(var e=r._tweens,i=e.length-1;i>=0;i--)e[i]._target==t&&(e[i].paused=!0,e.splice(i,1));t.tween_count=0}},r.tick=function(t,e){void 0===e&&(e=!1);var i=t-r._lastTime;r._lastTime=t;for(var o=r._tweens.concat(),n=o.length-1;n>=0;n--){var s=o[n];e&&!s.ignoreGlobalPause||s.paused||s.tick(s._useTicks?1:i)}return!1},r._register=function(e,i){var o=e._target,n=r._tweens;if(i)o&&(o.tween_count=o.tween_count>0?o.tween_count+1:1),n.push(e),r._inited||(r._lastTime=t.getTimer(),t.ticker.$startTick(r.tick,null),r._inited=!0);else{o&&o.tween_count--;for(var s=n.length;s--;)if(n[s]==e)return void n.splice(s,1)}},r.prototype.initialize=function(t,e,i){this._target=t,e&&(this._useTicks=e.useTicks,this.ignoreGlobalPause=e.ignoreGlobalPause,this.loop=e.loop,e.onChange&&this.addEventListener("change",e.onChange,e.onChangeObj),e.override&&r.removeTweens(t)),this.pluginData=i||{},this._curQueueProps={},this._initQueueProps={},this._steps=[],this._actions=[],e&&e.paused?this.paused=!0:r._register(this,!0),e&&null!=e.position&&this.setPosition(e.position)},r.prototype.setPosition=function(t,e){void 0===e&&(e=1),0>t&&(t=0);var r=t,i=!1;if(r>=this.duration&&(this.loop?r%=this.duration:(r=this.duration,i=!0)),r==this._prevPos)return i;var o=this._prevPos;if(this.position=this._prevPos=r,this._prevPosition=t,this._target)if(i)this._updateTargetProps(null,1);else if(this._steps.length>0){var n=void 0,s=this._steps.length;for(n=0;s>n&&!(this._steps[n].t>r);n++);var a=this._steps[n-1];this._updateTargetProps(a,(this._stepPosition=r-a.t)/a.d)}return i&&this.setPaused(!0),0!=e&&this._actions.length>0&&(this._useTicks?this._runActions(r,r):1==e&&o>r?(o!=this.duration&&this._runActions(o,this.duration),this._runActions(0,r,!0)):this._runActions(o,r)),this.dispatchEventWith("change"),i},r.prototype._runActions=function(t,e,r){void 0===r&&(r=!1);var i=t,o=e,n=-1,s=this._actions.length,a=1;for(t>e&&(i=e,o=t,n=s,s=a=-1);(n+=a)!=s;){var h=this._actions[n],c=h.t;(c==o||c>i&&o>c||r&&c==t)&&h.f.apply(h.o,h.p)}},r.prototype._updateTargetProps=function(t,e){var i,o,n,s,a,h;if(t||1!=e){if(this.passive=!!t.v,this.passive)return;t.e&&(e=t.e(e,0,1,1)),i=t.p0,o=t.p1}else this.passive=!1,i=o=this._curQueueProps;for(var c in this._initQueueProps){null==(s=i[c])&&(i[c]=s=this._initQueueProps[c]),null==(a=o[c])&&(o[c]=a=s),n=s==a||0==e||1==e||"number"!=typeof s?1==e?a:s:s+(a-s)*e;var l=!1;if(h=r._plugins[c])for(var u=0,p=h.length;p>u;u++){var _=h[u].tween(this,c,n,i,o,e,!!t&&i==o,!t);_==r.IGNORE?l=!0:n=_}l||(this._target[c]=n)}},r.prototype.setPaused=function(t){return this.paused=t,r._register(this,!t),this},r.prototype._cloneProps=function(t){var e={};for(var r in t)e[r]=t[r];return e},r.prototype._addStep=function(t){return t.d>0&&(this._steps.push(t),t.t=this.duration,this.duration+=t.d),this},r.prototype._appendQueueProps=function(t){var e,i,o,n,s;for(var a in t)if(void 0===this._initQueueProps[a]){if(i=this._target[a],e=r._plugins[a])for(o=0,n=e.length;n>o;o++)i=e[o].init(this,a,i);this._initQueueProps[a]=this._curQueueProps[a]=void 0===i?null:i}else i=this._curQueueProps[a];for(var a in t){if(i=this._curQueueProps[a],e=r._plugins[a])for(s=s||{},o=0,n=e.length;n>o;o++)e[o].step&&e[o].step(this,a,i,t[a],s);this._curQueueProps[a]=t[a]}return s&&this._appendQueueProps(s),this._curQueueProps},r.prototype._addAction=function(t){return t.t=this.duration,this._actions.push(t),this},r.prototype.to=function(t,e,r){return void 0===r&&(r=void 0),(isNaN(e)||0>e)&&(e=0),this._addStep({d:e||0,p0:this._cloneProps(this._curQueueProps),e:r,p1:this._cloneProps(this._appendQueueProps(t))})},r.prototype.call=function(t,e,r){return void 0===e&&(e=void 0),void 0===r&&(r=void 0),this._addAction({f:t,p:r?r:[],o:e?e:this._target})},r.prototype.tick=function(t){this.paused||this.setPosition(this._prevPosition+t)},r._tweens=[],r.IGNORE={},r._plugins={},r._inited=!1,r._lastTime=0,r}(t.EventDispatcher);t.ScrollTween=r,__reflect(r.prototype,"egret.ScrollTween")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(r){void 0===r&&(r=null);var i=e.call(this)||this;return i.scrollBeginThreshold=10,i.scrollSpeed=1,i._content=null,i.delayTouchBeginEvent=null,i.touchBeginTimer=null,i.touchEnabled=!0,i._ScrV_Props_=new t.ScrollViewProperties,r&&i.setContent(r),i}return __extends(r,e),Object.defineProperty(r.prototype,"bounces",{get:function(){return this._ScrV_Props_._bounces},set:function(t){this._ScrV_Props_._bounces=!!t},enumerable:!0,configurable:!0}),r.prototype.setContent=function(t){this._content!==t&&(this.removeContent(),t&&(this._content=t,e.prototype.addChild.call(this,t),this._addEvents()))},r.prototype.removeContent=function(){this._content&&(this._removeEvents(),e.prototype.removeChildAt.call(this,0)),this._content=null},Object.defineProperty(r.prototype,"verticalScrollPolicy",{get:function(){return this._ScrV_Props_._verticalScrollPolicy},set:function(t){t!=this._ScrV_Props_._verticalScrollPolicy&&(this._ScrV_Props_._verticalScrollPolicy=t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"horizontalScrollPolicy",{get:function(){return this._ScrV_Props_._horizontalScrollPolicy},set:function(t){t!=this._ScrV_Props_._horizontalScrollPolicy&&(this._ScrV_Props_._horizontalScrollPolicy=t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollLeft",{get:function(){return this._ScrV_Props_._scrollLeft},set:function(t){t!=this._ScrV_Props_._scrollLeft&&(this._ScrV_Props_._scrollLeft=t,this._validatePosition(!1,!0),this._updateContentPosition())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollTop",{get:function(){return this._ScrV_Props_._scrollTop},set:function(t){t!=this._ScrV_Props_._scrollTop&&(this._ScrV_Props_._scrollTop=t,this._validatePosition(!0,!1),this._updateContentPosition())},enumerable:!0,configurable:!0}),r.prototype.setScrollPosition=function(t,e,r){if(void 0===r&&(r=!1),(!r||0!=t||0!=e)&&(r||this._ScrV_Props_._scrollTop!=t||this._ScrV_Props_._scrollLeft!=e)){var i=this._ScrV_Props_._scrollTop,o=this._ScrV_Props_._scrollLeft;if(r){var n=this.getMaxScrollLeft(),s=this.getMaxScrollTop();(0>=i||i>=s)&&(t/=2),(0>=o||o>=n)&&(e/=2);var a=i+t,h=o+e,c=this._ScrV_Props_._bounces;c||((0>=a||a>=s)&&(a=Math.max(0,Math.min(a,s))),(0>=h||h>=n)&&(h=Math.max(0,Math.min(h,n)))),this._ScrV_Props_._scrollTop=a,this._ScrV_Props_._scrollLeft=h}else this._ScrV_Props_._scrollTop=t,this._ScrV_Props_._scrollLeft=e;this._validatePosition(!0,!0),this._updateContentPosition()}},r.prototype._validatePosition=function(t,e){if(void 0===t&&(t=!1),void 0===e&&(e=!1),t){var r=this.height,i=this._getContentHeight();this._ScrV_Props_._scrollTop=Math.max(this._ScrV_Props_._scrollTop,(0-r)/2),this._ScrV_Props_._scrollTop=Math.min(this._ScrV_Props_._scrollTop,i>r?i-r/2:r/2)}if(e){var o=this.width,n=this._getContentWidth();this._ScrV_Props_._scrollLeft=Math.max(this._ScrV_Props_._scrollLeft,(0-o)/2),this._ScrV_Props_._scrollLeft=Math.min(this._ScrV_Props_._scrollLeft,n>o?n-o/2:o/2)}},r.prototype.$setWidth=function(t){this.$explicitWidth!=t&&(e.prototype.$setWidth.call(this,t),this._updateContentPosition())},r.prototype.$setHeight=function(t){this.$explicitHeight!=t&&(e.prototype.$setHeight.call(this,t),this._updateContentPosition())},r.prototype._updateContentPosition=function(){var e=this.height,r=this.width;this.scrollRect=new t.Rectangle(Math.round(this._ScrV_Props_._scrollLeft),Math.round(this._ScrV_Props_._scrollTop),r,e),this.dispatchEvent(new t.Event(t.Event.CHANGE))},r.prototype._checkScrollPolicy=function(){var t=this._ScrV_Props_._horizontalScrollPolicy,e=this.__checkScrollPolicy(t,this._getContentWidth(),this.width);this._ScrV_Props_._hCanScroll=e;var r=this._ScrV_Props_._verticalScrollPolicy,i=this.__checkScrollPolicy(r,this._getContentHeight(),this.height);return this._ScrV_Props_._vCanScroll=i,e||i},r.prototype.__checkScrollPolicy=function(t,e,r){return"on"==t?!0:"off"==t?!1:e>r},r.prototype._addEvents=function(){this.addEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBegin,this),this.addEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBeginCapture,this,!0),this.addEventListener(t.TouchEvent.TOUCH_END,this._onTouchEndCapture,this,!0)},r.prototype._removeEvents=function(){this.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBegin,this),this.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this._onTouchBeginCapture,this,!0),this.removeEventListener(t.TouchEvent.TOUCH_END,this._onTouchEndCapture,this,!0)},r.prototype._onTouchBegin=function(e){if(!e.$isDefaultPrevented){var r=this._checkScrollPolicy();r&&(this._ScrV_Props_._touchStartPosition.x=e.stageX,this._ScrV_Props_._touchStartPosition.y=e.stageY,(this._ScrV_Props_._isHTweenPlaying||this._ScrV_Props_._isVTweenPlaying)&&this._onScrollFinished(),this._tempStage=this.stage,this._tempStage.addEventListener(t.TouchEvent.TOUCH_MOVE,this._onTouchMove,this),this._tempStage.addEventListener(t.TouchEvent.TOUCH_END,this._onTouchEnd,this),this._tempStage.addEventListener(t.TouchEvent.LEAVE_STAGE,this._onTouchEnd,this),this.addEventListener(t.Event.ENTER_FRAME,this._onEnterFrame,this),this._logTouchEvent(e),e.preventDefault())}},r.prototype._onTouchBeginCapture=function(e){var r=this._checkScrollPolicy();if(r){for(var i=e.target;i!=this;){if("_checkScrollPolicy"in i&&(r=i._checkScrollPolicy()))return;i=i.parent}e.stopPropagation();var o=this.cloneTouchEvent(e);this.delayTouchBeginEvent=o,this.touchBeginTimer||(this.touchBeginTimer=new t.Timer(100,1),this.touchBeginTimer.addEventListener(t.TimerEvent.TIMER_COMPLETE,this._onTouchBeginTimer,this)),this.touchBeginTimer.start(),this._onTouchBegin(e)}},r.prototype._onTouchEndCapture=function(e){var r=this;if(this.delayTouchBeginEvent){this._onTouchBeginTimer(),e.stopPropagation();var i=this.cloneTouchEvent(e);t.callLater(function(){r.stage&&r.dispatchPropagationEvent(i)},this)}},r.prototype._onTouchBeginTimer=function(){this.touchBeginTimer.stop();var t=this.delayTouchBeginEvent;this.delayTouchBeginEvent=null,this.stage&&this.dispatchPropagationEvent(t)},r.prototype.dispatchPropagationEvent=function(e){for(var r=e.$target,i=this.$getPropagationList(r),o=i.length,n=.5*i.length,s=-1,a=0;o>a;a++)if(i[a]===this._content){s=a;break}i.splice(0,s+1),n-=s+1,this.$dispatchPropagationEvent(e,i,n),t.Event.release(e)},r.prototype._onTouchMove=function(t){if(this._ScrV_Props_._lastTouchPosition.x!=t.stageX||this._ScrV_Props_._lastTouchPosition.y!=t.stageY){if(!this._ScrV_Props_._scrollStarted){var e=t.stageX-this._ScrV_Props_._touchStartPosition.x,r=t.stageY-this._ScrV_Props_._touchStartPosition.y,i=Math.sqrt(e*e+r*r);if(i100&&r-this._ScrV_Props_._lastTouchTime<300&&this._calcVelocitys(this._ScrV_Props_._lastTouchEvent)},r.prototype._logTouchEvent=function(e){this._ScrV_Props_._lastTouchPosition.x=e.stageX,this._ScrV_Props_._lastTouchPosition.y=e.stageY,this._ScrV_Props_._lastTouchEvent=this.cloneTouchEvent(e),this._ScrV_Props_._lastTouchTime=t.getTimer()},r.prototype._getPointChange=function(t){return{x:this._ScrV_Props_._hCanScroll===!1?0:this._ScrV_Props_._lastTouchPosition.x-t.stageX,y:this._ScrV_Props_._vCanScroll===!1?0:this._ScrV_Props_._lastTouchPosition.y-t.stageY}},r.prototype._calcVelocitys=function(e){var r=t.getTimer();if(0==this._ScrV_Props_._lastTouchTime)return void(this._ScrV_Props_._lastTouchTime=r);var i=this._getPointChange(e),o=r-this._ScrV_Props_._lastTouchTime;i.x/=o,i.y/=o,this._ScrV_Props_._velocitys.push(i),this._ScrV_Props_._velocitys.length>5&&this._ScrV_Props_._velocitys.shift(),this._ScrV_Props_._lastTouchPosition.x=e.stageX,this._ScrV_Props_._lastTouchPosition.y=e.stageY},r.prototype._getContentWidth=function(){return this._content.$explicitWidth||this._content.width},r.prototype._getContentHeight=function(){return this._content.$explicitHeight||this._content.height},r.prototype.getMaxScrollLeft=function(){var t=this._getContentWidth()-this.width;return Math.max(0,t)},r.prototype.getMaxScrollTop=function(){var t=this._getContentHeight()-this.height;return Math.max(0,t)},r.prototype._moveAfterTouchEnd=function(){if(0!=this._ScrV_Props_._velocitys.length){for(var t={x:0,y:0},e=0,i=0;i.02?this.getAnimationDatas(s,this._ScrV_Props_._scrollLeft,l):{position:this._ScrV_Props_._scrollLeft,duration:1},_=c>.02?this.getAnimationDatas(a,this._ScrV_Props_._scrollTop,u):{position:this._ScrV_Props_._scrollTop,duration:1};this.setScrollLeft(p.position,p.duration),this.setScrollTop(_.position,_.duration)}},r.prototype.onTweenFinished=function(t){t==this._ScrV_Props_._vScrollTween&&(this._ScrV_Props_._isVTweenPlaying=!1),t==this._ScrV_Props_._hScrollTween&&(this._ScrV_Props_._isHTweenPlaying=!1),0==this._ScrV_Props_._isHTweenPlaying&&0==this._ScrV_Props_._isVTweenPlaying&&this._onScrollFinished()},r.prototype._onScrollStarted=function(){},r.prototype._onScrollFinished=function(){t.ScrollTween.removeTweens(this),this._ScrV_Props_._hScrollTween=null,this._ScrV_Props_._vScrollTween=null,this._ScrV_Props_._isHTweenPlaying=!1,this._ScrV_Props_._isVTweenPlaying=!1,this.dispatchEvent(new t.Event(t.Event.COMPLETE))},r.prototype.setScrollTop=function(e,r){void 0===r&&(r=0);var i=Math.min(this.getMaxScrollTop(),Math.max(e,0));if(0==r)return void(this.scrollTop=i);0==this._ScrV_Props_._bounces&&(e=i);var o=t.ScrollTween.get(this).to({scrollTop:e},r,t.ScrollEase.quartOut);i!=e&&o.to({scrollTop:i},300,t.ScrollEase.quintOut),this._ScrV_Props_._isVTweenPlaying=!0,this._ScrV_Props_._vScrollTween=o,o.call(this.onTweenFinished,this,[o]),this._ScrV_Props_._isHTweenPlaying||this._onScrollStarted()},r.prototype.setScrollLeft=function(e,r){void 0===r&&(r=0);var i=Math.min(this.getMaxScrollLeft(),Math.max(e,0));if(0==r)return void(this.scrollLeft=i);0==this._ScrV_Props_._bounces&&(e=i);var o=t.ScrollTween.get(this).to({scrollLeft:e},r,t.ScrollEase.quartOut);i!=e&&o.to({scrollLeft:i},300,t.ScrollEase.quintOut),this._ScrV_Props_._isHTweenPlaying=!0,this._ScrV_Props_._hScrollTween=o,o.call(this.onTweenFinished,this,[o]),this._ScrV_Props_._isVTweenPlaying||this._onScrollStarted()},r.prototype.getAnimationDatas=function(t,e,r){var i=Math.abs(t),o=.95,n=0,s=.998,a=.02,h=e+500*t;if(0>h||h>r)for(h=e;Math.abs(t)!=1/0&&Math.abs(t)>a;)h+=t,t*=0>h||h>r?s*o:s,n++;else n=500*-Math.log(a/i);var c={position:Math.min(r+50,Math.max(h,-50)),duration:n};return c},r.prototype.cloneTouchEvent=function(e){var r=new t.TouchEvent(e.type,e.bubbles,e.cancelable);return r.touchPointID=e.touchPointID,r.$stageX=e.stageX,r.$stageY=e.stageY,r.touchDown=e.touchDown,r.$isDefaultPrevented=!1,r.$target=e.target,r},r.prototype.throwNotSupportedError=function(){t.$error(1023)},r.prototype.addChild=function(t){return this.throwNotSupportedError(),null},r.prototype.addChildAt=function(t,e){return this.throwNotSupportedError(),null},r.prototype.removeChild=function(t){return this.throwNotSupportedError(),null},r.prototype.removeChildAt=function(t){return this.throwNotSupportedError(),null},r.prototype.setChildIndex=function(t,e){this.throwNotSupportedError()},r.prototype.swapChildren=function(t,e){this.throwNotSupportedError()},r.prototype.swapChildrenAt=function(t,e){this.throwNotSupportedError()},r.weight=[1,1.33,1.66,2,2.33],r}(t.DisplayObjectContainer);t.ScrollView=e,__reflect(e.prototype,"egret.ScrollView")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){this._verticalScrollPolicy="auto",this._horizontalScrollPolicy="auto",this._scrollLeft=0,this._scrollTop=0,this._hCanScroll=!1,this._vCanScroll=!1,this._lastTouchPosition=new t.Point(0,0),this._touchStartPosition=new t.Point(0,0),this._scrollStarted=!1,this._lastTouchTime=0,this._lastTouchEvent=null,this._velocitys=[],this._isHTweenPlaying=!1,this._isVTweenPlaying=!1,this._hScrollTween=null,this._vScrollTween=null,this._bounces=!0}return e}();t.ScrollViewProperties=e,__reflect(e.prototype,"egret.ScrollViewProperties")}(egret||(egret={}));var egret;!function(t){function e(e){var r=e.url;return-1==r.indexOf("?")&&e.method==t.URLRequestMethod.GET&&e.data&&e.data instanceof t.URLVariables&&(r=r+"?"+e.data.toString()),r}var r=function(r){function i(e){void 0===e&&(e=null);var i=r.call(this)||this;return i.dataFormat=t.URLLoaderDataFormat.TEXT,i.data=null,i._request=null,i._status=-1,e&&i.load(e),i}return __extends(i,r),i.prototype.load=function(r){this._request=r,this.data=null;var i=this;if(i.dataFormat==t.URLLoaderDataFormat.TEXTURE)return void this.loadTexture(i);if(i.dataFormat==t.URLLoaderDataFormat.SOUND)return void this.loadSound(i);var o=e(r),n=new t.HttpRequest;n.open(o,r.method==t.URLRequestMethod.POST?t.HttpMethod.POST:t.HttpMethod.GET);var s;if(r.method!=t.URLRequestMethod.GET&&r.data)if(r.data instanceof t.URLVariables){n.setRequestHeader("Content-Type","application/x-www-form-urlencoded");var a=r.data;s=a.toString()}else n.setRequestHeader("Content-Type","multipart/form-data"),s=r.data;else;for(var h=r.requestHeaders.length,c=0;h>c;c++){var l=r.requestHeaders[c];n.setRequestHeader(l.name,l.value)}n.addEventListener(t.Event.COMPLETE,function(){i.data=n.response,t.Event.dispatchEvent(i,t.Event.COMPLETE)},this),n.addEventListener(t.IOErrorEvent.IO_ERROR,function(){t.IOErrorEvent.dispatchIOErrorEvent(i)},this),n.responseType=i.dataFormat==t.URLLoaderDataFormat.BINARY?t.HttpResponseType.ARRAY_BUFFER:t.HttpResponseType.TEXT,n.send(s)},i.prototype.getResponseType=function(e){switch(e){case t.URLLoaderDataFormat.TEXT:case t.URLLoaderDataFormat.VARIABLES:return t.URLLoaderDataFormat.TEXT;case t.URLLoaderDataFormat.BINARY:return"arraybuffer";default:return e}},i.prototype.loadSound=function(e){var r=e._request.url,i=new t.Sound;this.sound=i,i.addEventListener(t.Event.COMPLETE,this.onSoundoadComplete,this),i.addEventListener(t.IOErrorEvent.IO_ERROR,this.onSoundLoaderError,this),i.addEventListener(t.ProgressEvent.PROGRESS,this.onSoundLoaderPostProgress,this),i.load(r)},i.prototype.onSoundoadComplete=function(e){var r=this;this.removeSoundLoaderListeners(),this.data=this.sound,window.setTimeout(function(){r.dispatchEventWith(t.Event.COMPLETE)},0)},i.prototype.onSoundLoaderPostProgress=function(t){this.dispatchEvent(t)},i.prototype.onSoundLoaderError=function(t){this.dispatchEvent(t)},i.prototype.removeSoundLoaderListeners=function(){this.sound.removeEventListener(t.Event.COMPLETE,this.onSoundoadComplete,this),this.sound.removeEventListener(t.IOErrorEvent.IO_ERROR,this.onSoundLoaderError,this),this.sound.removeEventListener(t.ProgressEvent.PROGRESS,this.onSoundLoaderPostProgress,this)},i.prototype.loadTexture=function(e){this.virtualUrl=e._request.url;var r=new t.ImageLoader;this.imageLoader=r,r.addEventListener(t.Event.COMPLETE,this.onImageLoadComplete,this),r.addEventListener(t.IOErrorEvent.IO_ERROR,this.onImageLoaderError,this),r.addEventListener(t.ProgressEvent.PROGRESS,this.onImageLoaderPostProgress,this),r.load(this.virtualUrl)},i.prototype.onImageLoadComplete=function(e){var r=this;this.removeImageLoaderListeners();var i=new t.Texture,o=this.imageLoader.data;o.source.setAttribute&&o.source.setAttribute("bitmapSrc",this.virtualUrl),i._setBitmapData(o),this.data=i,window.setTimeout(function(){r.dispatchEventWith(t.Event.COMPLETE)},0)},i.prototype.onImageLoaderPostProgress=function(t){this.dispatchEvent(t)},i.prototype.onImageLoaderError=function(t){this.dispatchEvent(t)},i.prototype.removeImageLoaderListeners=function(){this.imageLoader.removeEventListener(t.Event.COMPLETE,this.onImageLoadComplete,this),this.imageLoader.removeEventListener(t.IOErrorEvent.IO_ERROR,this.onImageLoaderError,this),this.imageLoader.removeEventListener(t.ProgressEvent.PROGRESS,this.onImageLoaderPostProgress,this)},i.prototype.__recycle=function(){this._request=null,this.data=null},i}(t.EventDispatcher);t.URLLoader=r,__reflect(r.prototype,"egret.URLLoader")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(r){var i=e.call(this)||this;return i.$texture=null,i.offsetPoint=t.Point.create(0,0),i.$movieClipData=null,i.frames=null,i.$totalFrames=0,i.frameLabels=null,i.$frameLabelStart=0,i.$frameLabelEnd=0,i.frameEvents=null,i.frameIntervalTime=0,i.$eventPool=null,i.$isPlaying=!1,i.isStopped=!0,i.playTimes=0,i.$currentFrameNum=0,i.$nextFrameNum=1,i.displayedKeyFrameNum=0,i.passedTime=0,i.$frameRate=0/0,i.lastTime=0,i.$smoothing=t.Bitmap.defaultSmoothing,i.setMovieClipData(r),t.nativeRender||(i.$renderNode=new t.sys.NormalBitmapNode),i}return __extends(r,e),r.prototype.createNativeDisplayObject=function(){this.$nativeDisplayObject=new egret_native.NativeDisplayObject(11)},Object.defineProperty(r.prototype,"smoothing",{get:function(){return this.$smoothing},set:function(t){t!=this.$smoothing&&(this.$smoothing=t)},enumerable:!0,configurable:!0}),r.prototype.$init=function(){this.$reset();var t=this.$movieClipData;t&&t.$isDataValid()&&(this.frames=t.frames,this.$totalFrames=t.numFrames,this.frameLabels=t.labels,this.frameEvents=t.events,this.$frameRate=t.frameRate,this.frameIntervalTime=1e3/this.$frameRate,this._initFrame())},r.prototype.$reset=function(){this.frames=null,this.playTimes=0,this.$isPlaying=!1,this.setIsStopped(!0),this.$currentFrameNum=0,this.$nextFrameNum=1,this.displayedKeyFrameNum=0,this.passedTime=0,this.$eventPool=[]},r.prototype._initFrame=function(){this.$movieClipData.$isTextureValid()&&(this.advanceFrame(),this.constructFrame())},r.prototype.$updateRenderNode=function(){var e=this.$texture;if(e){var r=Math.round(this.offsetPoint.x),i=Math.round(this.offsetPoint.y),o=e.$bitmapWidth,n=e.$bitmapHeight,s=e.$getTextureWidth(),a=e.$getTextureHeight(),h=Math.round(e.$getScaleBitmapWidth()),c=Math.round(e.$getScaleBitmapHeight()),l=e.$sourceWidth,u=e.$sourceHeight;t.sys.BitmapNode.$updateTextureData(this.$renderNode,e.$bitmapData,e.$bitmapX,e.$bitmapY,o,n,r,i,s,a,h,c,l,u,t.BitmapFillMode.SCALE,this.$smoothing)}},r.prototype.$measureContentBounds=function(t){var e=this.$texture;if(e){var r=this.offsetPoint.x,i=this.offsetPoint.y,o=e.$getTextureWidth(),n=e.$getTextureHeight();t.setTo(r,i,o,n)}else t.setEmpty()},r.prototype.$onAddToStage=function(t,r){e.prototype.$onAddToStage.call(this,t,r),this.$isPlaying&&this.$totalFrames>1&&this.setIsStopped(!1)},r.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this),this.setIsStopped(!0)},r.prototype.getFrameLabelByName=function(t,e){void 0===e&&(e=!1),e&&(t=t.toLowerCase());var r=this.frameLabels;if(r)for(var i=null,o=0;ot)return e;e=r}return e},r.prototype.play=function(e){void 0===e&&(e=0),this.lastTime=t.getTimer(),this.passedTime=0,this.$isPlaying=!0,this.setPlayTimes(e),this.$totalFrames>1&&this.$stage&&this.setIsStopped(!1)},r.prototype.stop=function(){this.$isPlaying=!1,this.setIsStopped(!0)},r.prototype.prevFrame=function(){this.gotoAndStop(this.$currentFrameNum-1)},r.prototype.nextFrame=function(){this.gotoAndStop(this.$currentFrameNum+1)},r.prototype.gotoAndPlay=function(e,r){void 0===r&&(r=0),(0==arguments.length||arguments.length>2)&&t.$error(1022,"MovieClip.gotoAndPlay()"),"string"==typeof e?this.getFrameStartEnd(e):(this.$frameLabelStart=0,this.$frameLabelEnd=0),this.play(r),this.gotoFrame(e)},r.prototype.gotoAndStop=function(e){1!=arguments.length&&t.$error(1022,"MovieClip.gotoAndStop()"),this.stop(),this.gotoFrame(e)},r.prototype.gotoFrame=function(e){var r;"string"==typeof e?r=this.getFrameLabelByName(e).frame:(r=parseInt(e+"",10),r!=e&&t.$error(1022,"Frame Label Not Found")),1>r?r=1:r>this.$totalFrames&&(r=this.$totalFrames),r!=this.$nextFrameNum&&(this.$nextFrameNum=r,this.advanceFrame(),this.constructFrame(),this.handlePendingEvent())},r.prototype.advanceTime=function(e){var r=this,i=e-r.lastTime;r.lastTime=e;var o=r.frameIntervalTime,n=r.passedTime+i;r.passedTime=n%o;var s=n/o;if(1>s)return!1;for(;s>=1;){if(s--,r.$nextFrameNum++,r.$nextFrameNum>r.$totalFrames||r.$frameLabelStart>0&&r.$nextFrameNum>r.$frameLabelEnd)if(-1==r.playTimes)r.$eventPool.push(t.Event.LOOP_COMPLETE),r.$nextFrameNum=1;else{if(r.playTimes--,!(r.playTimes>0)){r.$nextFrameNum=r.$totalFrames,r.$eventPool.push(t.Event.COMPLETE),r.stop();break}r.$eventPool.push(t.Event.LOOP_COMPLETE),r.$nextFrameNum=1}r.$currentFrameNum==r.$frameLabelEnd&&(r.$nextFrameNum=r.$frameLabelStart),r.advanceFrame()}return r.constructFrame(),r.handlePendingEvent(),!1},r.prototype.advanceFrame=function(){this.$currentFrameNum=this.$nextFrameNum; -var e=this.frameEvents[this.$nextFrameNum];e&&""!=e&&t.MovieClipEvent.dispatchMovieClipEvent(this,t.MovieClipEvent.FRAME_LABEL,e)},r.prototype.constructFrame=function(){var e=this,r=e.$currentFrameNum;if(e.displayedKeyFrameNum!=r){var i=e.$movieClipData.getTextureByFrame(r);if(e.$texture=i,e.$movieClipData.$getOffsetByFrame(r,e.offsetPoint),e.displayedKeyFrameNum=r,e.$renderDirty=!0,t.nativeRender)e.$nativeDisplayObject.setDataToBitmapNode(e.$nativeDisplayObject.id,i,[i.$bitmapX,i.$bitmapY,i.$bitmapWidth,i.$bitmapHeight,e.offsetPoint.x,e.offsetPoint.y,i.$getScaleBitmapWidth(),i.$getScaleBitmapHeight(),i.$sourceWidth,i.$sourceHeight]),e.$nativeDisplayObject.setWidth(i.$getTextureWidth()+e.offsetPoint.x),e.$nativeDisplayObject.setHeight(i.$getTextureHeight()+e.offsetPoint.y);else{var o=e.$parent;o&&!o.$cacheDirty&&(o.$cacheDirty=!0,o.$cacheDirtyUp());var n=e.$maskedObject;n&&!n.$cacheDirty&&(n.$cacheDirty=!0,n.$cacheDirtyUp())}}},r.prototype.$renderFrame=function(){var t=this;t.$texture=t.$movieClipData.getTextureByFrame(t.$currentFrameNum),t.$renderDirty=!0;var e=t.$parent;e&&!e.$cacheDirty&&(e.$cacheDirty=!0,e.$cacheDirtyUp());var r=t.$maskedObject;r&&!r.$cacheDirty&&(r.$cacheDirty=!0,r.$cacheDirtyUp())},r.prototype.handlePendingEvent=function(){if(0!=this.$eventPool.length){this.$eventPool.reverse();for(var e=this.$eventPool,r=e.length,i=!1,o=!1,n=0;r>n;n++){var s=e.pop();s==t.Event.LOOP_COMPLETE?o=!0:s==t.Event.COMPLETE?i=!0:this.dispatchEventWith(s)}o&&this.dispatchEventWith(t.Event.LOOP_COMPLETE),i&&this.dispatchEventWith(t.Event.COMPLETE)}},Object.defineProperty(r.prototype,"totalFrames",{get:function(){return this.$totalFrames},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"currentFrame",{get:function(){return this.$currentFrameNum},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"currentFrameLabel",{get:function(){var t=this.getFrameLabelByFrame(this.$currentFrameNum);return t&&t.name},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"currentLabel",{get:function(){var t=this.getFrameLabelForFrame(this.$currentFrameNum);return t?t.name:null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"frameRate",{get:function(){return this.$frameRate},set:function(t){t!=this.$frameRate&&(this.$frameRate=t,this.frameIntervalTime=1e3/this.$frameRate)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isPlaying",{get:function(){return this.$isPlaying},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"movieClipData",{get:function(){return this.$movieClipData},set:function(t){this.setMovieClipData(t)},enumerable:!0,configurable:!0}),r.prototype.setMovieClipData=function(t){this.$movieClipData!=t&&(this.$movieClipData=t,this.$init())},r.prototype.setPlayTimes=function(t){(0>t||t>=1)&&(this.playTimes=0>t?-1:Math.floor(t))},r.prototype.setIsStopped=function(e){this.isStopped!=e&&(this.isStopped=e,e?t.ticker.$stopTick(this.advanceTime,this):(this.playTimes=0==this.playTimes?1:this.playTimes,this.lastTime=t.getTimer(),t.ticker.$startTick(this.advanceTime,this)))},r}(t.DisplayObject);t.MovieClip=e,__reflect(e.prototype,"egret.MovieClip")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(r){void 0===r&&(r=null);var i=e.call(this)||this;return i.data=null,i.method=t.URLRequestMethod.GET,i.url="",i.requestHeaders=[],i.url=r,i}return __extends(r,e),r}(t.HashObject);t.URLRequest=e,__reflect(e.prototype,"egret.URLRequest")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(t,e){this.name="",this.value="",this.name=t,this.value=e}return t}();t.URLRequestHeader=e,__reflect(e.prototype,"egret.URLRequestHeader")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}return t.GET="get",t.POST="post",t}();t.URLRequestMethod=e,__reflect(e.prototype,"egret.URLRequestMethod")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e){void 0===e&&(e=null);var r=t.call(this)||this;return r.variables=null,null!==e&&r.decode(e),r}return __extends(e,t),e.prototype.decode=function(t){this.variables||(this.variables={}),t=t.split("+").join(" ");for(var e,r=/[?&]?([^=]+)=([^&]*)/g;e=r.exec(t);){var i=decodeURIComponent(e[1]),o=decodeURIComponent(e[2]);if(i in this.variables!=0){var n=this.variables[i];n instanceof Array?n.push(o):this.variables[i]=[n,o]}else this.variables[i]=o}},e.prototype.toString=function(){if(!this.variables)return"";var t=this.variables,e=[];for(var r in t)e.push(this.encodeValue(r,t[r]));return e.join("&")},e.prototype.encodeValue=function(t,e){return e instanceof Array?this.encodeArray(t,e):encodeURIComponent(t)+"="+encodeURIComponent(e)},e.prototype.encodeArray=function(t,e){return t?0==e.length?encodeURIComponent(t)+"=":e.map(function(e){return encodeURIComponent(t)+"="+encodeURIComponent(e)}).join("&"):""},e}(t.HashObject);t.URLVariables=e,__reflect(e.prototype,"egret.URLVariables")}(egret||(egret={}));var egret;!function(t){var e=function(e){function r(){var i=e.call(this)||this;return i._timeScale=1,i._paused=!1,i._callIndex=-1,i._lastTime=0,i.callBackList=[],null!=r.instance,t.ticker.$startTick(i.update,i),i._lastTime=t.getTimer(),i}return __extends(r,e),r.prototype.update=function(t){var e=t-this._lastTime;if(this._lastTime=t,this._paused)return!1;var r=e*this._timeScale;for(this._callList=this.callBackList.concat(),this._callIndex=0;this._callIndext&&(t=1),r.autoDisposeTime=t,r.frameCount=0,r}return __extends(r,e),r.$init=function(){t.ticker.$startTick(r.onUpdate,r)},r.onUpdate=function(t){for(var e=r._callBackList,i=e.length-1;i>=0;i--)e[i].$checkFrame();return!1},r.prototype.$checkFrame=function(){this.frameCount--,this.frameCount<=0&&this.dispose()},Object.defineProperty(r.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),r.prototype.push=function(t){var e=this.objectPool;-1==e.indexOf(t)&&(e.push(t),t.__recycle&&t.__recycle(),this._length++,0==this.frameCount&&(this.frameCount=this.autoDisposeTime,r._callBackList.push(this)))},r.prototype.pop=function(){return 0==this._length?null:(this._length--,this.objectPool.pop())},r.prototype.dispose=function(){this._length>0&&(this.objectPool=[],this._length=0),this.frameCount=0;var t=r._callBackList,e=t.indexOf(this);-1!=e&&t.splice(e,1)},r._callBackList=[],r}(t.HashObject);t.Recycler=e,__reflect(e.prototype,"egret.Recycler"),e.$init()}(egret||(egret={}));var egret;!function(t){function e(e,r,h){for(var c=[],l=3;l postsJSON - values[1] // => commentsJSON - - return values; - }); - ``` - - @class Promise - @param {function} resolver - Useful for tooling. - @constructor -*/ -function Promise(resolver) { - this[PROMISE_ID] = nextId(); - this._result = this._state = undefined; - this._subscribers = []; - - if (noop !== resolver) { - typeof resolver !== 'function' && needsResolver(); - this instanceof Promise ? initializePromise(this, resolver) : needsNew(); - } -} - -Promise.all = all; -Promise.race = race; -Promise.resolve = resolve; -Promise.reject = reject; -Promise._setScheduler = setScheduler; -Promise._setAsap = setAsap; -Promise._asap = asap; - -Promise.prototype = { - constructor: Promise, - - /** - The primary way of interacting with a promise is through its `then` method, - which registers callbacks to receive either a promise's eventual value or the - reason why the promise cannot be fulfilled. - - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - - Chaining - -------- - - The return value of `then` is itself a promise. This second, 'downstream' - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return 'default name'; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `'default name'` - }); - - findUser().then(function (user) { - throw new Error('Found user, but still unhappy'); - }, function (reason) { - throw new Error('`findUser` rejected and we're unhappy'); - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. - // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - - ```js - findUser().then(function (user) { - throw new PedagogicalException('Upstream error'); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - - Assimilation - ------------ - - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - - If the assimliated promise rejects, then the downstream promise will also reject. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - - Simple Example - -------------- - - Synchronous Example - - ```javascript - let result; - - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // success - } - }); - ``` - - Promise Example; - - ```javascript - findResult().then(function(result){ - // success - }, function(reason){ - // failure - }); - ``` - - Advanced Example - -------------- - - Synchronous Example - - ```javascript - let author, books; - - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - - function foundBooks(books) { - - } - - function failure(reason) { - - } - - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { - failure(err); - } - // success - } - }); - ``` - - Promise Example; - - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong - }); - ``` - - @method then - @param {Function} onFulfilled - @param {Function} onRejected - Useful for tooling. - @return {Promise} - */ - then: then, - - /** - `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same - as the catch block of a try/catch statement. - - ```js - function findAuthor(){ - throw new Error('couldn't find that author'); - } - - // synchronous - try { - findAuthor(); - } catch(reason) { - // something went wrong - } - - // async with promises - findAuthor().catch(function(reason){ - // something went wrong - }); - ``` - - @method catch - @param {Function} onRejection - Useful for tooling. - @return {Promise} - */ - 'catch': function _catch(onRejection) { - return this.then(null, onRejection); - } -}; - -function polyfill() { - var local = undefined; - - if (typeof global !== 'undefined') { - local = global; - } else if (typeof self !== 'undefined') { - local = self; - } else { - try { - local = Function('return this')(); - } catch (e) { - throw new Error('polyfill failed because global object is unavailable in this environment'); - } - } - - var P = local.Promise; - - if (typeof egret_native != "undefined" && egret_native.capability && !egret_native.capability("Promise")) { - P = undefined; - } - - if (P) { - var promiseToString = null; - try { - promiseToString = Object.prototype.toString.call(P.resolve()); - } catch (e) { - // silently ignored - } - - if (promiseToString === '[object Promise]' && !P.cast) { - return; - } - } - - local.Promise = Promise; -} - -// Strange compat.. -Promise.polyfill = polyfill; -Promise.Promise = Promise; - -return Promise; - -}))); - -ES6Promise.polyfill(); \ No newline at end of file diff --git a/demo/libs/modules/promise/promise.min.js b/demo/libs/modules/promise/promise.min.js deleted file mode 100644 index 765fa21d..00000000 --- a/demo/libs/modules/promise/promise.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ES6Promise=e()}(this,function(){"use strict";function t(t){return"function"==typeof t||"object"==typeof t&&null!==t}function e(t){return"function"==typeof t}function n(t){I=t}function r(t){J=t}function o(){return function(){return process.nextTick(a)}}function i(){return"undefined"!=typeof H?function(){H(a)}:c()}function s(){var t=0,e=new V(a),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function u(){var t=new MessageChannel;return t.port1.onmessage=a,function(){return t.port2.postMessage(0)}}function c(){var t=setTimeout;return function(){return t(a,1)}}function a(){for(var t=0;G>t;t+=2){var e=$[t],n=$[t+1];e(n),$[t]=void 0,$[t+1]=void 0}G=0}function f(){try{var t=require,e=t("vertx");return H=e.runOnLoop||e.runOnContext,i()}catch(n){return c()}}function l(t,e){var n=arguments,r=this,o=new this.constructor(p);void 0===o[ee]&&k(o);var i=r._state;return i?!function(){var t=n[i-1];J(function(){return x(i,o,t,r._result)})}():E(r,o,t,e),o}function h(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(p);return w(n,t),n}function p(){}function v(){return new TypeError("You cannot resolve a promise with itself")}function d(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return ie.error=e,ie}}function y(t,e,n,r){try{t.call(e,n,r)}catch(o){return o}}function m(t,e,n){J(function(t){var r=!1,o=y(n,e,function(n){r||(r=!0,e!==n?w(t,n):S(t,n))},function(e){r||(r=!0,j(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,j(t,o))},t)}function b(t,e){e._state===re?S(t,e._result):e._state===oe?j(t,e._result):E(e,void 0,function(e){return w(t,e)},function(e){return j(t,e)})}function g(t,n,r){n.constructor===t.constructor&&r===l&&n.constructor.resolve===h?b(t,n):r===ie?j(t,ie.error):void 0===r?S(t,n):e(r)?m(t,n,r):S(t,n)}function w(e,n){e===n?j(e,v()):t(n)?g(e,n,_(n)):S(e,n)}function A(t){t._onerror&&t._onerror(t._result),P(t)}function S(t,e){t._state===ne&&(t._result=e,t._state=re,0!==t._subscribers.length&&J(P,t))}function j(t,e){t._state===ne&&(t._state=oe,t._result=e,J(A,t))}function E(t,e,n,r){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+re]=n,o[i+oe]=r,0===i&&t._state&&J(P,t)}function P(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,o=void 0,i=t._result,s=0;si;i++)e.resolve(t[i]).then(n,r)}:function(t,e){return e(new TypeError("You must pass an array to race."))})}function K(t){var e=this,n=new e(p);return j(n,t),n}function L(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function N(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function U(t){this[ee]=O(),this._result=this._state=void 0,this._subscribers=[],p!==t&&("function"!=typeof t&&L(),this instanceof U?C(this,t):N())}function W(){var t=void 0;if("undefined"!=typeof global)t=global;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;if("undefined"!=typeof egret_native&&egret_native.capability&&!egret_native.capability("Promise")&&(n=void 0),n){var r=null;try{r=Object.prototype.toString.call(n.resolve())}catch(e){}if("[object Promise]"===r&&!n.cast)return}t.Promise=U}var z=void 0;z=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var B=z,G=0,H=void 0,I=void 0,J=function(t,e){$[G]=t,$[G+1]=e,G+=2,2===G&&(I?I(a):te())},Q="undefined"!=typeof window?window:void 0,R=Q||{},V=R.MutationObserver||R.WebKitMutationObserver,X="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),Z="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,$=new Array(1e3),te=void 0;te=X?o():V?s():Z?u():void 0===Q&&"function"==typeof require?f():c();var ee=Math.random().toString(36).substring(16),ne=void 0,re=1,oe=2,ie=new T,se=new T,ue=0;return Y.prototype._enumerate=function(){for(var t=this.length,e=this._input,n=0;this._state===ne&&t>n;n++)this._eachEntry(e[n],n)},Y.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===h){var o=_(t);if(o===l&&t._state!==ne)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(n===U){var i=new n(p);g(i,t,o),this._willSettleAt(i,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},Y.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===ne&&(this._remaining--,t===oe?j(r,n):this._result[e]=n),0===this._remaining&&S(r,this._result)},Y.prototype._willSettleAt=function(t,e){var n=this;E(t,void 0,function(t){return n._settledAt(re,e,t)},function(t){return n._settledAt(oe,e,t)})},U.all=F,U.race=D,U.resolve=h,U.reject=K,U._setScheduler=n,U._setAsap=r,U._asap=J,U.prototype={constructor:U,then:l,"catch":function(t){return this.then(null,t)}},U.polyfill=W,U.Promise=U,U}),ES6Promise.polyfill(); \ No newline at end of file diff --git a/demo/libs/modules/tween/tween.d.ts b/demo/libs/modules/tween/tween.d.ts deleted file mode 100644 index 6a3093a3..00000000 --- a/demo/libs/modules/tween/tween.d.ts +++ /dev/null @@ -1,1350 +0,0 @@ -declare namespace egret { - /** - * Easing function set. Different easing functions are used to make an animation proceed according to the corresponding equation - * @see http://edn.egret.com/cn/index.php/article/index/id/53 Easing effect Demo - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓动函数集合,使用不同的缓动函数使得动画按照对应的方程进行 - * @see http://edn.egret.com/cn/index.php/article/index/id/53 缓动效果演示 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class Ease { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * get.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static get(amount: number): (t: number) => number; - /** - * get pow in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getPowIn(pow: number): (t: number) => number; - /** - * get pow out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getPowOut(pow: number): (t: number) => number; - /** - * get pow in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getPowInOut(pow: number): (t: number) => number; - /** - * quad in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quadIn: (t: number) => number; - /** - * quad out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quadOut: (t: number) => number; - /** - * quad in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quadInOut: (t: number) => number; - /** - * cubic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cubicIn: (t: number) => number; - /** - * cubic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cubicOut: (t: number) => number; - /** - * cubic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cubicInOut: (t: number) => number; - /** - * quart in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quartIn: (t: number) => number; - /** - * quart out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quartOut: (t: number) => number; - /** - * quart in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quartInOut: (t: number) => number; - /** - * quint in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quintIn: (t: number) => number; - /** - * quint out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quintOut: (t: number) => number; - /** - * quint in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quintInOut: (t: number) => number; - /** - * sine in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sineIn(t: number): number; - /** - * sine out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sineOut(t: number): number; - /** - * sine in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sineInOut(t: number): number; - /** - * get back in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getBackIn(amount: number): (t: number) => number; - /** - * back in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static backIn: (t: number) => number; - /** - * get back out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getBackOut(amount: number): (t: any) => number; - /** - * back out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static backOut: (t: any) => number; - /** - * get back in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getBackInOut(amount: number): (t: number) => number; - /** - * back in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static backInOut: (t: number) => number; - /** - * circ in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static circIn(t: number): number; - /** - * circ out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static circOut(t: number): number; - /** - * circ in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static circInOut(t: number): number; - /** - * bounce in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static bounceIn(t: number): number; - /** - * bounce out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static bounceOut(t: number): number; - /** - * bounce in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static bounceInOut(t: number): number; - /** - * get elastic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getElasticIn(amplitude: number, period: number): (t: number) => number; - /** - * elastic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static elasticIn: (t: number) => number; - /** - * get elastic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getElasticOut(amplitude: number, period: number): (t: number) => number; - /** - * elastic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static elasticOut: (t: number) => number; - /** - * get elastic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getElasticInOut(amplitude: number, period: number): (t: number) => number; - /** - * elastic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static elasticInOut: (t: number) => number; - } -} -declare namespace egret { - /** - * Tween is the animation easing class of Egret - * @see http://edn.egret.com/cn/docs/page/576 Tween ease animation - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/tween/Tween.ts - * @language en_US - */ - /** - * Tween是Egret的动画缓动类 - * @see http://edn.egret.com/cn/docs/page/576 Tween缓动动画 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/tween/Tween.ts - * @language zh_CN - */ - class Tween extends EventDispatcher { - /** - * 不做特殊处理 - * @constant {number} egret.Tween.NONE - * @private - */ - private static NONE; - /** - * 循环 - * @constant {number} egret.Tween.LOOP - * @private - */ - private static LOOP; - /** - * 倒序 - * @constant {number} egret.Tween.REVERSE - * @private - */ - private static REVERSE; - /** - * @private - */ - private static _tweens; - /** - * @private - */ - private static IGNORE; - /** - * @private - */ - private static _plugins; - /** - * @private - */ - private static _inited; - /** - * @private - */ - private _target; - /** - * @private - */ - private _useTicks; - /** - * @private - */ - private ignoreGlobalPause; - /** - * @private - */ - private loop; - /** - * @private - */ - private pluginData; - /** - * @private - */ - private _curQueueProps; - /** - * @private - */ - private _initQueueProps; - /** - * @private - */ - private _steps; - /** - * @private - */ - private paused; - /** - * @private - */ - private duration; - /** - * @private - */ - private _prevPos; - /** - * @private - */ - private position; - /** - * @private - */ - private _prevPosition; - /** - * @private - */ - private _stepPosition; - /** - * @private - */ - private passive; - /** - * Activate an object and add a Tween animation to the object - * @param target {any} The object to be activated - * @param props {any} Parameters, support loop onChange onChangeObj - * @param pluginData {any} Write realized - * @param override {boolean} Whether to remove the object before adding a tween, the default value false - * Not recommended, you can use Tween.removeTweens(target) instead. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 激活一个对象,对其添加 Tween 动画 - * @param target {any} 要激活 Tween 的对象 - * @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域) - * @param pluginData {any} 暂未实现 - * @param override {boolean} 是否移除对象之前添加的tween,默认值false。 - * 不建议使用,可使用 Tween.removeTweens(target) 代替。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static get(target: any, props?: { - loop?: boolean; - onChange?: Function; - onChangeObj?: any; - }, pluginData?: any, override?: boolean): Tween; - /** - * Delete all Tween animations from an object - * @param target The object whose Tween to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除一个对象上的全部 Tween 动画 - * @param target 需要移除 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static removeTweens(target: any): void; - /** - * Pause all Tween animations of a certain object - * @param target The object whose Tween to be paused - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停某个对象的所有 Tween - * @param target 要暂停 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static pauseTweens(target: any): void; - /** - * Resume playing all easing of a certain object - * @param target The object whose Tween to be resumed - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 继续播放某个对象的所有缓动 - * @param target 要继续播放 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static resumeTweens(target: any): void; - /** - * @private - * - * @param delta - * @param paused - */ - private static tick(timeStamp, paused?); - private static _lastTime; - /** - * @private - * - * @param tween - * @param value - */ - private static _register(tween, value); - /** - * Delete all Tween - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除所有 Tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static removeAllTweens(): void; - /** - * 创建一个 egret.Tween 对象 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(target: any, props: any, pluginData: any); - /** - * @private - * - * @param target - * @param props - * @param pluginData - */ - private initialize(target, props, pluginData); - /** - * @private - * - * @param value - * @param actionsMode - * @returns - */ - setPosition(value: number, actionsMode?: number): boolean; - /** - * @private - * - * @param startPos - * @param endPos - * @param includeStart - */ - private _runAction(action, startPos, endPos, includeStart?); - /** - * @private - * - * @param step - * @param ratio - */ - private _updateTargetProps(step, ratio); - /** - * Whether setting is paused - * @param value {boolean} Whether to pause - * @returns Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否暂停 - * @param value {boolean} 是否暂停 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setPaused(value: boolean): Tween; - /** - * @private - * - * @param props - * @returns - */ - private _cloneProps(props); - /** - * @private - * - * @param o - * @returns - */ - private _addStep(o); - /** - * @private - * - * @param o - * @returns - */ - private _appendQueueProps(o); - /** - * @private - * - * @param o - * @returns - */ - private _addAction(o); - /** - * @private - * - * @param props - * @param o - */ - private _set(props, o); - /** - * Wait the specified milliseconds before the execution of the next animation - * @param duration {number} Waiting time, in milliseconds - * @param passive {boolean} Whether properties are updated during the waiting time - * @returns Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等待指定毫秒后执行下一个动画 - * @param duration {number} 要等待的时间,以毫秒为单位 - * @param passive {boolean} 等待期间属性是否会更新 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - wait(duration: number, passive?: boolean): Tween; - /** - * Modify the property of the specified object to a specified value - * @param props {Object} Property set of an object - * @param duration {number} Duration - * @param ease {egret.Ease} Easing algorithm - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param duration {number} 持续时间 - * @param ease {egret.Ease} 缓动算法 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - to(props: any, duration?: number, ease?: Function): Tween; - /** - * Execute callback function - * @param callback {Function} Callback method - * @param thisObj {any} this action scope of the callback method - * @param params {any[]} Parameter of the callback method - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @example - *
      -         *  egret.Tween.get(display).call(function (a:number, b:string) {
      -         *      console.log("a: " + a); // the first parameter passed 233
      -         *      console.log("b: " + b); // the second parameter passed “hello”
      -         *  }, this, [233, "hello"]);
      -         * 
      - * @language en_US - */ - /** - * 执行回调函数 - * @param callback {Function} 回调方法 - * @param thisObj {any} 回调方法this作用域 - * @param params {any[]} 回调方法参数 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @example - *
      -         *  egret.Tween.get(display).call(function (a:number, b:string) {
      -         *      console.log("a: " + a); //对应传入的第一个参数 233
      -         *      console.log("b: " + b); //对应传入的第二个参数 “hello”
      -         *  }, this, [233, "hello"]);
      -         * 
      - * @language zh_CN - */ - call(callback: Function, thisObj?: any, params?: any[]): Tween; - /** - * Now modify the properties of the specified object to the specified value - * @param props {Object} Property set of an object - * @param target The object whose Tween to be resumed - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * 立即将指定对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param target 要继续播放 Tween 的对象 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - */ - set(props: any, target?: any): Tween; - /** - * Execute - * @param tween {egret.Tween} The Tween object to be operated. Default: this - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行 - * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - play(tween?: Tween): Tween; - /** - * Pause - * @param tween {egret.Tween} The Tween object to be operated. Default: this - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停 - * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pause(tween?: Tween): Tween; - /** - * @method egret.Tween#tick - * @param delta {number} - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - $tick(delta: number): void; - } -} -declare namespace egret.tween { - type EaseType = 'quadIn' | 'quadOut' | 'quadOut' | 'quadInOut' | 'cubicIn' | 'cubicOut' | 'cubicInOut' | 'quartIn' | 'quartOut' | 'quartInOut' | 'quintIn' | 'quintOut' | 'quintInOut' | 'sineIn' | 'sineOut' | 'sineInOut' | 'backIn' | 'backOut' | 'backInOut' | 'circIn' | 'circOut' | 'circInOut' | 'bounceIn' | 'bounceOut' | 'bounceInOut' | 'elasticIn' | 'elasticOut' | 'elasticInOut'; - /** - * Abstract class, Indicate the base action. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 抽象类,表示一个基本动作 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - abstract class BasePath extends EventDispatcher { - /** - * the name of this action. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 动作的名称 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - name: string; - } - /** - * Indicate the to action. See Tween.to - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个to动作,参见Tween.to - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class To extends BasePath { - /** - * Property set of an object - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 对象的属性集合 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - props: Object; - /** - * Duration - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 持续时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - duration: number; - /** - * Easing algorithm - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 缓动算法 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - ease: EaseType | Function; - } - /** - * Indicate the wait action. See Tween.wait - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个wait动作,参见Tween.wait - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class Wait extends BasePath { - /** - * Duration - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 持续时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - duration: number; - /** - * Whether properties are updated during the waiting time - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 等待期间属性是否会更新 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - passive: boolean; - } - /** - * Indicate the set action. See Tween.set - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个set动作,参见Tween.set - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class Set extends BasePath { - /** - * Property set of an object - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 对象的属性集合 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - props: Object; - } - /** - * Indicate the tick action. See Tween.tick - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个tick动作,参见Tween.tick - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class Tick extends BasePath { - /** - * Delta time - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 增加的时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - delta: number; - } - /** - * TweenItem is a wrapper for Tween, which can set the behavior of Tween by setting attributes and adding Path. - * - * @event pathComplete Dispatched when some Path has complete. - * @event complete Dispatched when all Paths has complete. - * - * @defaultProperty props - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenItem是对Tween的包装器,能通过设置属性和添加Path的方式设置Tween的行为。 - * 通常用于使用在EXML中定义组件的动画。 - * - * @event pathComplete 当某个Path执行完毕时会派发此事件。 - * @event complete 当所有Path执行完毕时会派发此事件。 - * - * @defaultProperty props - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - /** - * Use in exml: - * ``` - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - */ - class TweenItem extends EventDispatcher { - private tween; - constructor(); - /** - * @private - */ - private _props; - /** - * The Tween's props. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * Tween的props参数。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - props: any; - /** - * @private - */ - private _target; - /** - * The Tween's target. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * Tween的target参数。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - target: any; - /** - * @private - */ - private _paths; - /** - * The Actions in Tween. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenItem中添加的行为。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - paths: BasePath[]; - /** - * Play the Tween - * @position The starting position, the default is from the last position to play - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 播放Tween - * @position 播放的起始位置, 默认为从上次位置继续播放 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - play(position?: number): void; - /** - * Pause the Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - private isStop; - /** - * Stop the Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 停止Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - private createTween(position); - private applyPaths(); - private applyPath(path); - private pathComplete(path); - } - /** - * TweenGroup is a collection of TweenItem that can be played in parallel with each Item - * - * @event itemComplete Dispatched when some TweenItem has complete. - * @event complete Dispatched when all TweenItems has complete. - * - * @version Egret 3.1.8 - * @platform Web,Native - * @includeExample extension/tween/TweenWrapper.ts - * @language en_US - */ - /** - * TweenGroup是TweenItem的集合,可以并行播放每一个Item - * @version Egret 3.1.8 - * @platform Web,Native - * @includeExample extension/tween/TweenWrapper.ts - * @language zh_CN - */ - class TweenGroup extends EventDispatcher { - private completeCount; - constructor(); - /** - * @private - */ - private _items; - /** - * The Array that TweenItems in TweenGroup. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenGroup要控制的TweenItem集合。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - items: TweenItem[]; - private registerEvent(add); - /** - * Play the all TweenItems - * @time The starting position, the default is from the last position to play。If use 0, the group will play from the start position. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 播放所有的TweenItem - * @time 播放的起始位置, 默认为从上次位置继续播放。如果为0,则从起始位置开始播放。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - play(time?: number): void; - /** - * Pause the all TweenItems - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停播放所有的TweenItem - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - /** - * Stop the all TweenItems - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 停止所有的TweenItem - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - private itemComplete(e); - } -} diff --git a/demo/libs/modules/tween/tween.js b/demo/libs/modules/tween/tween.js deleted file mode 100644 index 7ac1d955..00000000 --- a/demo/libs/modules/tween/tween.js +++ /dev/null @@ -1,2095 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Easing function set. Different easing functions are used to make an animation proceed according to the corresponding equation - * @see http://edn.egret.com/cn/index.php/article/index/id/53 Easing effect Demo - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓动函数集合,使用不同的缓动函数使得动画按照对应的方程进行 - * @see http://edn.egret.com/cn/index.php/article/index/id/53 缓动效果演示 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - var Ease = (function () { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function Ease() { - egret.$error(1014); - } - /** - * get.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.get = function (amount) { - if (amount < -1) { - amount = -1; - } - if (amount > 1) { - amount = 1; - } - return function (t) { - if (amount == 0) { - return t; - } - if (amount < 0) { - return t * (t * -amount + 1 + amount); - } - return t * ((2 - t) * amount + (1 - amount)); - }; - }; - /** - * get pow in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getPowIn = function (pow) { - return function (t) { - return Math.pow(t, pow); - }; - }; - /** - * get pow out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getPowOut = function (pow) { - return function (t) { - return 1 - Math.pow(1 - t, pow); - }; - }; - /** - * get pow in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getPowInOut = function (pow) { - return function (t) { - if ((t *= 2) < 1) - return 0.5 * Math.pow(t, pow); - return 1 - 0.5 * Math.abs(Math.pow(2 - t, pow)); - }; - }; - /** - * sine in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.sineIn = function (t) { - return 1 - Math.cos(t * Math.PI / 2); - }; - /** - * sine out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.sineOut = function (t) { - return Math.sin(t * Math.PI / 2); - }; - /** - * sine in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.sineInOut = function (t) { - return -0.5 * (Math.cos(Math.PI * t) - 1); - }; - /** - * get back in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getBackIn = function (amount) { - return function (t) { - return t * t * ((amount + 1) * t - amount); - }; - }; - /** - * get back out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getBackOut = function (amount) { - return function (t) { - return (--t * t * ((amount + 1) * t + amount) + 1); - }; - }; - /** - * get back in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getBackInOut = function (amount) { - amount *= 1.525; - return function (t) { - if ((t *= 2) < 1) - return 0.5 * (t * t * ((amount + 1) * t - amount)); - return 0.5 * ((t -= 2) * t * ((amount + 1) * t + amount) + 2); - }; - }; - /** - * circ in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.circIn = function (t) { - return -(Math.sqrt(1 - t * t) - 1); - }; - /** - * circ out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.circOut = function (t) { - return Math.sqrt(1 - (--t) * t); - }; - /** - * circ in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.circInOut = function (t) { - if ((t *= 2) < 1) { - return -0.5 * (Math.sqrt(1 - t * t) - 1); - } - return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1); - }; - /** - * bounce in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.bounceIn = function (t) { - return 1 - Ease.bounceOut(1 - t); - }; - /** - * bounce out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.bounceOut = function (t) { - if (t < 1 / 2.75) { - return (7.5625 * t * t); - } - else if (t < 2 / 2.75) { - return (7.5625 * (t -= 1.5 / 2.75) * t + 0.75); - } - else if (t < 2.5 / 2.75) { - return (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375); - } - else { - return (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375); - } - }; - /** - * bounce in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.bounceInOut = function (t) { - if (t < 0.5) - return Ease.bounceIn(t * 2) * .5; - return Ease.bounceOut(t * 2 - 1) * 0.5 + 0.5; - }; - /** - * get elastic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getElasticIn = function (amplitude, period) { - var pi2 = Math.PI * 2; - return function (t) { - if (t == 0 || t == 1) - return t; - var s = period / pi2 * Math.asin(1 / amplitude); - return -(amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period)); - }; - }; - /** - * get elastic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getElasticOut = function (amplitude, period) { - var pi2 = Math.PI * 2; - return function (t) { - if (t == 0 || t == 1) - return t; - var s = period / pi2 * Math.asin(1 / amplitude); - return (amplitude * Math.pow(2, -10 * t) * Math.sin((t - s) * pi2 / period) + 1); - }; - }; - /** - * get elastic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.getElasticInOut = function (amplitude, period) { - var pi2 = Math.PI * 2; - return function (t) { - var s = period / pi2 * Math.asin(1 / amplitude); - if ((t *= 2) < 1) - return -0.5 * (amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period)); - return amplitude * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * 0.5 + 1; - }; - }; - /** - * quad in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quadIn = Ease.getPowIn(2); - /** - * quad out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quadOut = Ease.getPowOut(2); - /** - * quad in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quadInOut = Ease.getPowInOut(2); - /** - * cubic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.cubicIn = Ease.getPowIn(3); - /** - * cubic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.cubicOut = Ease.getPowOut(3); - /** - * cubic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.cubicInOut = Ease.getPowInOut(3); - /** - * quart in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quartIn = Ease.getPowIn(4); - /** - * quart out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quartOut = Ease.getPowOut(4); - /** - * quart in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quartInOut = Ease.getPowInOut(4); - /** - * quint in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quintIn = Ease.getPowIn(5); - /** - * quint out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quintOut = Ease.getPowOut(5); - /** - * quint in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.quintInOut = Ease.getPowInOut(5); - /** - * back in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.backIn = Ease.getBackIn(1.7); - /** - * back out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.backOut = Ease.getBackOut(1.7); - /** - * back in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.backInOut = Ease.getBackInOut(1.7); - /** - * elastic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.elasticIn = Ease.getElasticIn(1, 0.3); - /** - * elastic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.elasticOut = Ease.getElasticOut(1, 0.3); - /** - * elastic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Ease.elasticInOut = Ease.getElasticInOut(1, 0.3 * 1.5); - return Ease; - }()); - egret.Ease = Ease; - __reflect(Ease.prototype, "egret.Ease"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * Tween is the animation easing class of Egret - * @see http://edn.egret.com/cn/docs/page/576 Tween ease animation - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/tween/Tween.ts - * @language en_US - */ - /** - * Tween是Egret的动画缓动类 - * @see http://edn.egret.com/cn/docs/page/576 Tween缓动动画 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/tween/Tween.ts - * @language zh_CN - */ - var Tween = (function (_super) { - __extends(Tween, _super); - /** - * 创建一个 egret.Tween 对象 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - function Tween(target, props, pluginData) { - var _this = _super.call(this) || this; - /** - * @private - */ - _this._target = null; - /** - * @private - */ - _this._useTicks = false; - /** - * @private - */ - _this.ignoreGlobalPause = false; - /** - * @private - */ - _this.loop = false; - /** - * @private - */ - _this.pluginData = null; - /** - * @private - */ - _this._steps = null; - /** - * @private - */ - _this.paused = false; - /** - * @private - */ - _this.duration = 0; - /** - * @private - */ - _this._prevPos = -1; - /** - * @private - */ - _this.position = null; - /** - * @private - */ - _this._prevPosition = 0; - /** - * @private - */ - _this._stepPosition = 0; - /** - * @private - */ - _this.passive = false; - _this.initialize(target, props, pluginData); - return _this; - } - /** - * Activate an object and add a Tween animation to the object - * @param target {any} The object to be activated - * @param props {any} Parameters, support loop onChange onChangeObj - * @param pluginData {any} Write realized - * @param override {boolean} Whether to remove the object before adding a tween, the default value false - * Not recommended, you can use Tween.removeTweens(target) instead. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 激活一个对象,对其添加 Tween 动画 - * @param target {any} 要激活 Tween 的对象 - * @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域) - * @param pluginData {any} 暂未实现 - * @param override {boolean} 是否移除对象之前添加的tween,默认值false。 - * 不建议使用,可使用 Tween.removeTweens(target) 代替。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.get = function (target, props, pluginData, override) { - if (pluginData === void 0) { pluginData = null; } - if (override === void 0) { override = false; } - if (override) { - Tween.removeTweens(target); - } - return new Tween(target, props, pluginData); - }; - /** - * Delete all Tween animations from an object - * @param target The object whose Tween to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除一个对象上的全部 Tween 动画 - * @param target 需要移除 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.removeTweens = function (target) { - if (!target.tween_count) { - return; - } - var tweens = Tween._tweens; - for (var i = tweens.length - 1; i >= 0; i--) { - if (tweens[i]._target == target) { - tweens[i].paused = true; - tweens.splice(i, 1); - } - } - target.tween_count = 0; - }; - /** - * Pause all Tween animations of a certain object - * @param target The object whose Tween to be paused - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停某个对象的所有 Tween - * @param target 要暂停 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.pauseTweens = function (target) { - if (!target.tween_count) { - return; - } - var tweens = egret.Tween._tweens; - for (var i = tweens.length - 1; i >= 0; i--) { - if (tweens[i]._target == target) { - tweens[i].paused = true; - } - } - }; - /** - * Resume playing all easing of a certain object - * @param target The object whose Tween to be resumed - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 继续播放某个对象的所有缓动 - * @param target 要继续播放 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.resumeTweens = function (target) { - if (!target.tween_count) { - return; - } - var tweens = egret.Tween._tweens; - for (var i = tweens.length - 1; i >= 0; i--) { - if (tweens[i]._target == target) { - tweens[i].paused = false; - } - } - }; - /** - * @private - * - * @param delta - * @param paused - */ - Tween.tick = function (timeStamp, paused) { - if (paused === void 0) { paused = false; } - var delta = timeStamp - Tween._lastTime; - Tween._lastTime = timeStamp; - var tweens = Tween._tweens.concat(); - for (var i = tweens.length - 1; i >= 0; i--) { - var tween_1 = tweens[i]; - if ((paused && !tween_1.ignoreGlobalPause) || tween_1.paused) { - continue; - } - tween_1.$tick(tween_1._useTicks ? 1 : delta); - } - return false; - }; - /** - * @private - * - * @param tween - * @param value - */ - Tween._register = function (tween, value) { - var target = tween._target; - var tweens = Tween._tweens; - if (value) { - if (target) { - target.tween_count = target.tween_count > 0 ? target.tween_count + 1 : 1; - } - tweens.push(tween); - if (!Tween._inited) { - Tween._lastTime = egret.getTimer(); - egret.ticker.$startTick(Tween.tick, null); - Tween._inited = true; - } - } - else { - if (target) { - target.tween_count--; - } - var i = tweens.length; - while (i--) { - if (tweens[i] == tween) { - tweens.splice(i, 1); - return; - } - } - } - }; - /** - * Delete all Tween - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除所有 Tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.removeAllTweens = function () { - var tweens = Tween._tweens; - for (var i = 0, l = tweens.length; i < l; i++) { - var tween_2 = tweens[i]; - tween_2.paused = true; - tween_2._target.tween_count = 0; - } - tweens.length = 0; - }; - /** - * @private - * - * @param target - * @param props - * @param pluginData - */ - Tween.prototype.initialize = function (target, props, pluginData) { - this._target = target; - if (props) { - this._useTicks = props.useTicks; - this.ignoreGlobalPause = props.ignoreGlobalPause; - this.loop = props.loop; - props.onChange && this.addEventListener("change", props.onChange, props.onChangeObj); - if (props.override) { - Tween.removeTweens(target); - } - } - this.pluginData = pluginData || {}; - this._curQueueProps = {}; - this._initQueueProps = {}; - this._steps = []; - if (props && props.paused) { - this.paused = true; - } - else { - Tween._register(this, true); - } - if (props && props.position != null) { - this.setPosition(props.position, Tween.NONE); - } - }; - /** - * @private - * - * @param value - * @param actionsMode - * @returns - */ - Tween.prototype.setPosition = function (value, actionsMode) { - if (actionsMode === void 0) { actionsMode = 1; } - if (value < 0) { - value = 0; - } - //正常化位置 - var t = value; - var end = false; - if (t >= this.duration) { - if (this.loop) { - var newTime = t % this.duration; - if (t > 0 && newTime === 0) { - t = this.duration; - } - else { - t = newTime; - } - } - else { - t = this.duration; - end = true; - } - } - if (t == this._prevPos) { - return end; - } - if (end) { - this.setPaused(true); - } - var prevPos = this._prevPos; - this.position = this._prevPos = t; - this._prevPosition = value; - if (this._target) { - if (this._steps.length > 0) { - // 找到新的tween - var l = this._steps.length; - var stepIndex = -1; - for (var i = 0; i < l; i++) { - if (this._steps[i].type == "step") { - stepIndex = i; - if (this._steps[i].t <= t && this._steps[i].t + this._steps[i].d >= t) { - break; - } - } - } - for (var i = 0; i < l; i++) { - if (this._steps[i].type == "action") { - //执行actions - if (actionsMode != 0) { - if (this._useTicks) { - this._runAction(this._steps[i], t, t); - } - else if (actionsMode == 1 && t < prevPos) { - if (prevPos != this.duration) { - this._runAction(this._steps[i], prevPos, this.duration); - } - this._runAction(this._steps[i], 0, t, true); - } - else { - this._runAction(this._steps[i], prevPos, t); - } - } - } - else if (this._steps[i].type == "step") { - if (stepIndex == i) { - var step = this._steps[stepIndex]; - this._updateTargetProps(step, Math.min((this._stepPosition = t - step.t) / step.d, 1)); - } - } - } - } - } - this.dispatchEventWith("change"); - return end; - }; - /** - * @private - * - * @param startPos - * @param endPos - * @param includeStart - */ - Tween.prototype._runAction = function (action, startPos, endPos, includeStart) { - if (includeStart === void 0) { includeStart = false; } - var sPos = startPos; - var ePos = endPos; - if (startPos > endPos) { - //把所有的倒置 - sPos = endPos; - ePos = startPos; - } - var pos = action.t; - if (pos == ePos || (pos > sPos && pos < ePos) || (includeStart && pos == startPos)) { - action.f.apply(action.o, action.p); - } - }; - /** - * @private - * - * @param step - * @param ratio - */ - Tween.prototype._updateTargetProps = function (step, ratio) { - var p0, p1, v, v0, v1, arr; - if (!step && ratio == 1) { - this.passive = false; - p0 = p1 = this._curQueueProps; - } - else { - this.passive = !!step.v; - //不更新props. - if (this.passive) { - return; - } - //使用ease - if (step.e) { - ratio = step.e(ratio, 0, 1, 1); - } - p0 = step.p0; - p1 = step.p1; - } - for (var n in this._initQueueProps) { - if ((v0 = p0[n]) == null) { - p0[n] = v0 = this._initQueueProps[n]; - } - if ((v1 = p1[n]) == null) { - p1[n] = v1 = v0; - } - if (v0 == v1 || ratio == 0 || ratio == 1 || (typeof (v0) != "number")) { - v = ratio == 1 ? v1 : v0; - } - else { - v = v0 + (v1 - v0) * ratio; - } - var ignore = false; - if (arr = Tween._plugins[n]) { - for (var i = 0, l = arr.length; i < l; i++) { - var v2 = arr[i].tween(this, n, v, p0, p1, ratio, !!step && p0 == p1, !step); - if (v2 == Tween.IGNORE) { - ignore = true; - } - else { - v = v2; - } - } - } - if (!ignore) { - this._target[n] = v; - } - } - }; - /** - * Whether setting is paused - * @param value {boolean} Whether to pause - * @returns Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否暂停 - * @param value {boolean} 是否暂停 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.prototype.setPaused = function (value) { - if (this.paused == value) { - return this; - } - this.paused = value; - Tween._register(this, !value); - return this; - }; - /** - * @private - * - * @param props - * @returns - */ - Tween.prototype._cloneProps = function (props) { - var o = {}; - for (var n in props) { - o[n] = props[n]; - } - return o; - }; - /** - * @private - * - * @param o - * @returns - */ - Tween.prototype._addStep = function (o) { - if (o.d > 0) { - o.type = "step"; - this._steps.push(o); - o.t = this.duration; - this.duration += o.d; - } - return this; - }; - /** - * @private - * - * @param o - * @returns - */ - Tween.prototype._appendQueueProps = function (o) { - var arr, oldValue, i, l, injectProps; - for (var n in o) { - if (this._initQueueProps[n] === undefined) { - oldValue = this._target[n]; - //设置plugins - if (arr = Tween._plugins[n]) { - for (i = 0, l = arr.length; i < l; i++) { - oldValue = arr[i].init(this, n, oldValue); - } - } - this._initQueueProps[n] = this._curQueueProps[n] = (oldValue === undefined) ? null : oldValue; - } - else { - oldValue = this._curQueueProps[n]; - } - } - for (var n in o) { - oldValue = this._curQueueProps[n]; - if (arr = Tween._plugins[n]) { - injectProps = injectProps || {}; - for (i = 0, l = arr.length; i < l; i++) { - if (arr[i].step) { - arr[i].step(this, n, oldValue, o[n], injectProps); - } - } - } - this._curQueueProps[n] = o[n]; - } - if (injectProps) { - this._appendQueueProps(injectProps); - } - return this._curQueueProps; - }; - /** - * @private - * - * @param o - * @returns - */ - Tween.prototype._addAction = function (o) { - o.t = this.duration; - o.type = "action"; - this._steps.push(o); - return this; - }; - /** - * @private - * - * @param props - * @param o - */ - Tween.prototype._set = function (props, o) { - for (var n in props) { - o[n] = props[n]; - } - }; - /** - * Wait the specified milliseconds before the execution of the next animation - * @param duration {number} Waiting time, in milliseconds - * @param passive {boolean} Whether properties are updated during the waiting time - * @returns Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等待指定毫秒后执行下一个动画 - * @param duration {number} 要等待的时间,以毫秒为单位 - * @param passive {boolean} 等待期间属性是否会更新 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.prototype.wait = function (duration, passive) { - if (duration == null || duration <= 0) { - return this; - } - var o = this._cloneProps(this._curQueueProps); - return this._addStep({ d: duration, p0: o, p1: o, v: passive }); - }; - /** - * Modify the property of the specified object to a specified value - * @param props {Object} Property set of an object - * @param duration {number} Duration - * @param ease {egret.Ease} Easing algorithm - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param duration {number} 持续时间 - * @param ease {egret.Ease} 缓动算法 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.prototype.to = function (props, duration, ease) { - if (ease === void 0) { ease = undefined; } - if (isNaN(duration) || duration < 0) { - duration = 0; - } - this._addStep({ d: duration || 0, p0: this._cloneProps(this._curQueueProps), e: ease, p1: this._cloneProps(this._appendQueueProps(props)) }); - //加入一步set,防止游戏极其卡顿时候,to后面的call取到的属性值不对 - return this.set(props); - }; - /** - * Execute callback function - * @param callback {Function} Callback method - * @param thisObj {any} this action scope of the callback method - * @param params {any[]} Parameter of the callback method - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @example - *
      -         *  egret.Tween.get(display).call(function (a:number, b:string) {
      -         *      console.log("a: " + a); // the first parameter passed 233
      -         *      console.log("b: " + b); // the second parameter passed “hello”
      -         *  }, this, [233, "hello"]);
      -         * 
      - * @language en_US - */ - /** - * 执行回调函数 - * @param callback {Function} 回调方法 - * @param thisObj {any} 回调方法this作用域 - * @param params {any[]} 回调方法参数 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @example - *
      -         *  egret.Tween.get(display).call(function (a:number, b:string) {
      -         *      console.log("a: " + a); //对应传入的第一个参数 233
      -         *      console.log("b: " + b); //对应传入的第二个参数 “hello”
      -         *  }, this, [233, "hello"]);
      -         * 
      - * @language zh_CN - */ - Tween.prototype.call = function (callback, thisObj, params) { - if (thisObj === void 0) { thisObj = undefined; } - if (params === void 0) { params = undefined; } - return this._addAction({ f: callback, p: params ? params : [], o: thisObj ? thisObj : this._target }); - }; - /** - * Now modify the properties of the specified object to the specified value - * @param props {Object} Property set of an object - * @param target The object whose Tween to be resumed - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * 立即将指定对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param target 要继续播放 Tween 的对象 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - */ - Tween.prototype.set = function (props, target) { - if (target === void 0) { target = null; } - //更新当前数据,保证缓动流畅性 - this._appendQueueProps(props); - return this._addAction({ f: this._set, o: this, p: [props, target ? target : this._target] }); - }; - /** - * Execute - * @param tween {egret.Tween} The Tween object to be operated. Default: this - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行 - * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.prototype.play = function (tween) { - if (!tween) { - tween = this; - } - return this.call(tween.setPaused, tween, [false]); - }; - /** - * Pause - * @param tween {egret.Tween} The Tween object to be operated. Default: this - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停 - * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - Tween.prototype.pause = function (tween) { - if (!tween) { - tween = this; - } - return this.call(tween.setPaused, tween, [true]); - }; - /** - * @method egret.Tween#tick - * @param delta {number} - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - Tween.prototype.$tick = function (delta) { - if (this.paused) { - return; - } - this.setPosition(this._prevPosition + delta); - }; - /** - * 不做特殊处理 - * @constant {number} egret.Tween.NONE - * @private - */ - Tween.NONE = 0; - /** - * 循环 - * @constant {number} egret.Tween.LOOP - * @private - */ - Tween.LOOP = 1; - /** - * 倒序 - * @constant {number} egret.Tween.REVERSE - * @private - */ - Tween.REVERSE = 2; - /** - * @private - */ - Tween._tweens = []; - /** - * @private - */ - Tween.IGNORE = {}; - /** - * @private - */ - Tween._plugins = {}; - /** - * @private - */ - Tween._inited = false; - Tween._lastTime = 0; - return Tween; - }(egret.EventDispatcher)); - egret.Tween = Tween; - __reflect(Tween.prototype, "egret.Tween"); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var tween; - (function (tween) { - /** - * Abstract class, Indicate the base action. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 抽象类,表示一个基本动作 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - var BasePath = (function (_super) { - __extends(BasePath, _super); - function BasePath() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * the name of this action. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 动作的名称 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.name = ""; - return _this; - } - return BasePath; - }(egret.EventDispatcher)); - tween.BasePath = BasePath; - __reflect(BasePath.prototype, "egret.tween.BasePath"); - /** - * Indicate the to action. See Tween.to - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个to动作,参见Tween.to - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - var To = (function (_super) { - __extends(To, _super); - function To() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * Property set of an object - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 对象的属性集合 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.props = undefined; - /** - * Duration - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 持续时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.duration = 500; - /** - * Easing algorithm - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 缓动算法 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.ease = undefined; - return _this; - } - return To; - }(BasePath)); - tween.To = To; - __reflect(To.prototype, "egret.tween.To"); - /** - * Indicate the wait action. See Tween.wait - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个wait动作,参见Tween.wait - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - var Wait = (function (_super) { - __extends(Wait, _super); - function Wait() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * Duration - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 持续时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.duration = 500; - /** - * Whether properties are updated during the waiting time - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 等待期间属性是否会更新 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.passive = undefined; - return _this; - } - return Wait; - }(BasePath)); - tween.Wait = Wait; - __reflect(Wait.prototype, "egret.tween.Wait"); - /** - * Indicate the set action. See Tween.set - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个set动作,参见Tween.set - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - var Set = (function (_super) { - __extends(Set, _super); - function Set() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * Property set of an object - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 对象的属性集合 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.props = undefined; - return _this; - } - return Set; - }(BasePath)); - tween.Set = Set; - __reflect(Set.prototype, "egret.tween.Set"); - /** - * Indicate the tick action. See Tween.tick - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个tick动作,参见Tween.tick - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - var Tick = (function (_super) { - __extends(Tick, _super); - function Tick() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * Delta time - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 增加的时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - _this.delta = 0; - return _this; - } - return Tick; - }(BasePath)); - tween.Tick = Tick; - __reflect(Tick.prototype, "egret.tween.Tick"); - function convertEase(ease) { - if (typeof ease === 'function') { - return ease; - } - else { - var func = egret.Ease[ease]; - if (typeof func === 'function') { - return func; - } - } - return null; - } - /** - * TweenItem is a wrapper for Tween, which can set the behavior of Tween by setting attributes and adding Path. - * - * @event pathComplete Dispatched when some Path has complete. - * @event complete Dispatched when all Paths has complete. - * - * @defaultProperty props - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenItem是对Tween的包装器,能通过设置属性和添加Path的方式设置Tween的行为。 - * 通常用于使用在EXML中定义组件的动画。 - * - * @event pathComplete 当某个Path执行完毕时会派发此事件。 - * @event complete 当所有Path执行完毕时会派发此事件。 - * - * @defaultProperty props - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - /** - * Use in exml: - * ``` - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - */ - var TweenItem = (function (_super) { - __extends(TweenItem, _super); - function TweenItem() { - var _this = _super.call(this) || this; - _this.isStop = false; - return _this; - } - Object.defineProperty(TweenItem.prototype, "props", { - /** - * The Tween's props. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * Tween的props参数。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._props; - }, - set: function (value) { - this._props = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TweenItem.prototype, "target", { - /** - * The Tween's target. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * Tween的target参数。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._target; - }, - set: function (value) { - this._target = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TweenItem.prototype, "paths", { - /** - * The Actions in Tween. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenItem中添加的行为。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._paths; - }, - set: function (value) { - this._paths = value || []; - }, - enumerable: true, - configurable: true - }); - /** - * Play the Tween - * @position The starting position, the default is from the last position to play - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 播放Tween - * @position 播放的起始位置, 默认为从上次位置继续播放 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenItem.prototype.play = function (position) { - if (!this.tween) { - this.createTween(position); - } - else { - this.tween.setPaused(false); - if (this.isStop && position == undefined) { - position = 0; - this.isStop = false; - } - if (position !== undefined && position !== null) { - this.tween.setPosition(position); - } - } - }; - /** - * Pause the Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenItem.prototype.pause = function () { - if (this.tween) { - this.tween.setPaused(true); - } - }; - /** - * Stop the Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 停止Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenItem.prototype.stop = function () { - this.pause(); - this.isStop = true; - }; - TweenItem.prototype.createTween = function (position) { - this.tween = egret.Tween.get(this._target, this._props); - if (this._paths) { - this.applyPaths(); - } - if (position !== undefined && position !== null) { - this.tween.setPosition(position); - } - }; - TweenItem.prototype.applyPaths = function () { - for (var i = 0; i < this._paths.length; i++) { - var path = this._paths[i]; - this.applyPath(path); - } - }; - TweenItem.prototype.applyPath = function (path) { - var _this = this; - if (path instanceof To) { - this.tween.to(path.props, path.duration, convertEase(path.ease)); - } - else if (path instanceof Wait) { - this.tween.wait(path.duration, path.passive); - } - else if (path instanceof Set) { - this.tween.set(path.props); - } - else if (path instanceof Tick) { - this.tween.$tick(path.delta); - } - this.tween.call(function () { return _this.pathComplete(path); }); - }; - TweenItem.prototype.pathComplete = function (path) { - path.dispatchEventWith('complete'); - this.dispatchEventWith('pathComplete', false, path); - var index = this._paths.indexOf(path); - if (index >= 0 && index === this._paths.length - 1) { - this.dispatchEventWith('complete'); - } - }; - return TweenItem; - }(egret.EventDispatcher)); - tween.TweenItem = TweenItem; - __reflect(TweenItem.prototype, "egret.tween.TweenItem"); - registerProperty(TweenItem, 'paths', 'Array', true); - /** - * TweenGroup is a collection of TweenItem that can be played in parallel with each Item - * - * @event itemComplete Dispatched when some TweenItem has complete. - * @event complete Dispatched when all TweenItems has complete. - * - * @version Egret 3.1.8 - * @platform Web,Native - * @includeExample extension/tween/TweenWrapper.ts - * @language en_US - */ - /** - * TweenGroup是TweenItem的集合,可以并行播放每一个Item - * @version Egret 3.1.8 - * @platform Web,Native - * @includeExample extension/tween/TweenWrapper.ts - * @language zh_CN - */ - var TweenGroup = (function (_super) { - __extends(TweenGroup, _super); - function TweenGroup() { - var _this = _super.call(this) || this; - _this.completeCount = 0; - return _this; - } - Object.defineProperty(TweenGroup.prototype, "items", { - /** - * The Array that TweenItems in TweenGroup. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenGroup要控制的TweenItem集合。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - get: function () { - return this._items; - }, - set: function (value) { - this.completeCount = 0; - this.registerEvent(false); - this._items = value; - this.registerEvent(true); - }, - enumerable: true, - configurable: true - }); - TweenGroup.prototype.registerEvent = function (add) { - var _this = this; - this._items && this._items.forEach(function (item) { - if (add) { - item.addEventListener('complete', _this.itemComplete, _this); - } - else { - item.removeEventListener('complete', _this.itemComplete, _this); - } - }); - }; - /** - * Play the all TweenItems - * @time The starting position, the default is from the last position to play。If use 0, the group will play from the start position. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 播放所有的TweenItem - * @time 播放的起始位置, 默认为从上次位置继续播放。如果为0,则从起始位置开始播放。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenGroup.prototype.play = function (time) { - if (!this._items) { - return; - } - for (var i = 0; i < this._items.length; i++) { - var item = this._items[i]; - item.play(time); - } - }; - /** - * Pause the all TweenItems - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停播放所有的TweenItem - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenGroup.prototype.pause = function () { - if (!this._items) { - return; - } - for (var i = 0; i < this._items.length; i++) { - var item = this._items[i]; - item.pause(); - } - }; - /** - * Stop the all TweenItems - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 停止所有的TweenItem - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - TweenGroup.prototype.stop = function () { - if (!this._items) { - return; - } - for (var i = 0; i < this._items.length; i++) { - var item = this._items[i]; - item.stop(); - } - }; - TweenGroup.prototype.itemComplete = function (e) { - var item = e.currentTarget; - this.completeCount++; - this.dispatchEventWith('itemComplete', false, item); - if (this.completeCount === this.items.length) { - this.dispatchEventWith('complete'); - this.completeCount = 0; - } - }; - return TweenGroup; - }(egret.EventDispatcher)); - tween.TweenGroup = TweenGroup; - __reflect(TweenGroup.prototype, "egret.tween.TweenGroup"); - registerProperty(TweenGroup, 'items', 'Array', true); - function registerProperty(classDefinition, property, type, asDefault) { - var prototype = classDefinition.prototype; - prototype.__meta__ = prototype.__meta__ || {}; - prototype.__meta__[property] = type; - if (asDefault) { - prototype.__defaultProperty__ = property; - } - } - })(tween = egret.tween || (egret.tween = {})); -})(egret || (egret = {})); diff --git a/demo/libs/modules/tween/tween.min.js b/demo/libs/modules/tween/tween.min.js deleted file mode 100644 index abe1c4bd..00000000 --- a/demo/libs/modules/tween/tween.min.js +++ /dev/null @@ -1 +0,0 @@ -var __reflect=this&&this.__reflect||function(t,e,n){t.__class__=e,n?n.push(e):n=[e],t.__types__=t.__types__?n.concat(t.__types__):n},__extends=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);n.prototype=e.prototype,t.prototype=new n},egret;!function(t){var e=function(){function e(){t.$error(1014)}return e.get=function(t){return-1>t&&(t=-1),t>1&&(t=1),function(e){return 0==t?e:0>t?e*(e*-t+1+t):e*((2-e)*t+(1-t))}},e.getPowIn=function(t){return function(e){return Math.pow(e,t)}},e.getPowOut=function(t){return function(e){return 1-Math.pow(1-e,t)}},e.getPowInOut=function(t){return function(e){return(e*=2)<1?.5*Math.pow(e,t):1-.5*Math.abs(Math.pow(2-e,t))}},e.sineIn=function(t){return 1-Math.cos(t*Math.PI/2)},e.sineOut=function(t){return Math.sin(t*Math.PI/2)},e.sineInOut=function(t){return-.5*(Math.cos(Math.PI*t)-1)},e.getBackIn=function(t){return function(e){return e*e*((t+1)*e-t)}},e.getBackOut=function(t){return function(e){return--e*e*((t+1)*e+t)+1}},e.getBackInOut=function(t){return t*=1.525,function(e){return(e*=2)<1?.5*(e*e*((t+1)*e-t)):.5*((e-=2)*e*((t+1)*e+t)+2)}},e.circIn=function(t){return-(Math.sqrt(1-t*t)-1)},e.circOut=function(t){return Math.sqrt(1- --t*t)},e.circInOut=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},e.bounceIn=function(t){return 1-e.bounceOut(1-t)},e.bounceOut=function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},e.bounceInOut=function(t){return.5>t?.5*e.bounceIn(2*t):.5*e.bounceOut(2*t-1)+.5},e.getElasticIn=function(t,e){var n=2*Math.PI;return function(i){if(0==i||1==i)return i;var s=e/n*Math.asin(1/t);return-(t*Math.pow(2,10*(i-=1))*Math.sin((i-s)*n/e))}},e.getElasticOut=function(t,e){var n=2*Math.PI;return function(i){if(0==i||1==i)return i;var s=e/n*Math.asin(1/t);return t*Math.pow(2,-10*i)*Math.sin((i-s)*n/e)+1}},e.getElasticInOut=function(t,e){var n=2*Math.PI;return function(i){var s=e/n*Math.asin(1/t);return(i*=2)<1?-.5*(t*Math.pow(2,10*(i-=1))*Math.sin((i-s)*n/e)):t*Math.pow(2,-10*(i-=1))*Math.sin((i-s)*n/e)*.5+1}},e.quadIn=e.getPowIn(2),e.quadOut=e.getPowOut(2),e.quadInOut=e.getPowInOut(2),e.cubicIn=e.getPowIn(3),e.cubicOut=e.getPowOut(3),e.cubicInOut=e.getPowInOut(3),e.quartIn=e.getPowIn(4),e.quartOut=e.getPowOut(4),e.quartInOut=e.getPowInOut(4),e.quintIn=e.getPowIn(5),e.quintOut=e.getPowOut(5),e.quintInOut=e.getPowInOut(5),e.backIn=e.getBackIn(1.7),e.backOut=e.getBackOut(1.7),e.backInOut=e.getBackInOut(1.7),e.elasticIn=e.getElasticIn(1,.3),e.elasticOut=e.getElasticOut(1,.3),e.elasticInOut=e.getElasticInOut(1,.3*1.5),e}();t.Ease=e,__reflect(e.prototype,"egret.Ease")}(egret||(egret={}));var egret;!function(t){var e=function(e){function n(t,n,i){var s=e.call(this)||this;return s._target=null,s._useTicks=!1,s.ignoreGlobalPause=!1,s.loop=!1,s.pluginData=null,s._steps=null,s.paused=!1,s.duration=0,s._prevPos=-1,s.position=null,s._prevPosition=0,s._stepPosition=0,s.passive=!1,s.initialize(t,n,i),s}return __extends(n,e),n.get=function(t,e,i,s){return void 0===i&&(i=null),void 0===s&&(s=!1),s&&n.removeTweens(t),new n(t,e,i)},n.removeTweens=function(t){if(t.tween_count){for(var e=n._tweens,i=e.length-1;i>=0;i--)e[i]._target==t&&(e[i].paused=!0,e.splice(i,1));t.tween_count=0}},n.pauseTweens=function(e){if(e.tween_count)for(var n=t.Tween._tweens,i=n.length-1;i>=0;i--)n[i]._target==e&&(n[i].paused=!0)},n.resumeTweens=function(e){if(e.tween_count)for(var n=t.Tween._tweens,i=n.length-1;i>=0;i--)n[i]._target==e&&(n[i].paused=!1)},n.tick=function(t,e){void 0===e&&(e=!1);var i=t-n._lastTime;n._lastTime=t;for(var s=n._tweens.concat(),r=s.length-1;r>=0;r--){var o=s[r];e&&!o.ignoreGlobalPause||o.paused||o.$tick(o._useTicks?1:i)}return!1},n._register=function(e,i){var s=e._target,r=n._tweens;if(i)s&&(s.tween_count=s.tween_count>0?s.tween_count+1:1),r.push(e),n._inited||(n._lastTime=t.getTimer(),t.ticker.$startTick(n.tick,null),n._inited=!0);else{s&&s.tween_count--;for(var o=r.length;o--;)if(r[o]==e)return void r.splice(o,1)}},n.removeAllTweens=function(){for(var t=n._tweens,e=0,i=t.length;i>e;e++){var s=t[e];s.paused=!0,s._target.tween_count=0}t.length=0},n.prototype.initialize=function(t,e,i){this._target=t,e&&(this._useTicks=e.useTicks,this.ignoreGlobalPause=e.ignoreGlobalPause,this.loop=e.loop,e.onChange&&this.addEventListener("change",e.onChange,e.onChangeObj),e.override&&n.removeTweens(t)),this.pluginData=i||{},this._curQueueProps={},this._initQueueProps={},this._steps=[],e&&e.paused?this.paused=!0:n._register(this,!0),e&&null!=e.position&&this.setPosition(e.position,n.NONE)},n.prototype.setPosition=function(t,e){void 0===e&&(e=1),0>t&&(t=0);var n=t,i=!1;if(n>=this.duration)if(this.loop){var s=n%this.duration;n=n>0&&0===s?this.duration:s}else n=this.duration,i=!0;if(n==this._prevPos)return i;i&&this.setPaused(!0);var r=this._prevPos;if(this.position=this._prevPos=n,this._prevPosition=t,this._target&&this._steps.length>0){for(var o=this._steps.length,u=-1,a=0;o>a&&!("step"==this._steps[a].type&&(u=a,this._steps[a].t<=n&&this._steps[a].t+this._steps[a].d>=n));a++);for(var a=0;o>a;a++)if("action"==this._steps[a].type)0!=e&&(this._useTicks?this._runAction(this._steps[a],n,n):1==e&&r>n?(r!=this.duration&&this._runAction(this._steps[a],r,this.duration),this._runAction(this._steps[a],0,n,!0)):this._runAction(this._steps[a],r,n));else if("step"==this._steps[a].type&&u==a){var p=this._steps[u];this._updateTargetProps(p,Math.min((this._stepPosition=n-p.t)/p.d,1))}}return this.dispatchEventWith("change"),i},n.prototype._runAction=function(t,e,n,i){void 0===i&&(i=!1);var s=e,r=n;e>n&&(s=n,r=e);var o=t.t;(o==r||o>s&&r>o||i&&o==e)&&t.f.apply(t.o,t.p)},n.prototype._updateTargetProps=function(t,e){var i,s,r,o,u,a;if(t||1!=e){if(this.passive=!!t.v,this.passive)return;t.e&&(e=t.e(e,0,1,1)),i=t.p0,s=t.p1}else this.passive=!1,i=s=this._curQueueProps;for(var p in this._initQueueProps){null==(o=i[p])&&(i[p]=o=this._initQueueProps[p]),null==(u=s[p])&&(s[p]=u=o),r=o==u||0==e||1==e||"number"!=typeof o?1==e?u:o:o+(u-o)*e;var h=!1;if(a=n._plugins[p])for(var c=0,_=a.length;_>c;c++){var f=a[c].tween(this,p,r,i,s,e,!!t&&i==s,!t);f==n.IGNORE?h=!0:r=f}h||(this._target[p]=r)}},n.prototype.setPaused=function(t){return this.paused==t?this:(this.paused=t,n._register(this,!t),this)},n.prototype._cloneProps=function(t){var e={};for(var n in t)e[n]=t[n];return e},n.prototype._addStep=function(t){return t.d>0&&(t.type="step",this._steps.push(t),t.t=this.duration,this.duration+=t.d),this},n.prototype._appendQueueProps=function(t){var e,i,s,r,o;for(var u in t)if(void 0===this._initQueueProps[u]){if(i=this._target[u],e=n._plugins[u])for(s=0,r=e.length;r>s;s++)i=e[s].init(this,u,i);this._initQueueProps[u]=this._curQueueProps[u]=void 0===i?null:i}else i=this._curQueueProps[u];for(var u in t){if(i=this._curQueueProps[u],e=n._plugins[u])for(o=o||{},s=0,r=e.length;r>s;s++)e[s].step&&e[s].step(this,u,i,t[u],o);this._curQueueProps[u]=t[u]}return o&&this._appendQueueProps(o),this._curQueueProps},n.prototype._addAction=function(t){return t.t=this.duration,t.type="action",this._steps.push(t),this},n.prototype._set=function(t,e){for(var n in t)e[n]=t[n]},n.prototype.wait=function(t,e){if(null==t||0>=t)return this;var n=this._cloneProps(this._curQueueProps);return this._addStep({d:t,p0:n,p1:n,v:e})},n.prototype.to=function(t,e,n){return void 0===n&&(n=void 0),(isNaN(e)||0>e)&&(e=0),this._addStep({d:e||0,p0:this._cloneProps(this._curQueueProps),e:n,p1:this._cloneProps(this._appendQueueProps(t))}),this.set(t)},n.prototype.call=function(t,e,n){return void 0===e&&(e=void 0),void 0===n&&(n=void 0),this._addAction({f:t,p:n?n:[],o:e?e:this._target})},n.prototype.set=function(t,e){return void 0===e&&(e=null),this._appendQueueProps(t),this._addAction({f:this._set,o:this,p:[t,e?e:this._target]})},n.prototype.play=function(t){return t||(t=this),this.call(t.setPaused,t,[!1])},n.prototype.pause=function(t){return t||(t=this),this.call(t.setPaused,t,[!0])},n.prototype.$tick=function(t){this.paused||this.setPosition(this._prevPosition+t)},n.NONE=0,n.LOOP=1,n.REVERSE=2,n._tweens=[],n.IGNORE={},n._plugins={},n._inited=!1,n._lastTime=0,n}(t.EventDispatcher);t.Tween=e,__reflect(e.prototype,"egret.Tween")}(egret||(egret={}));var egret;!function(t){var e;!function(e){function n(e){if("function"==typeof e)return e;var n=t.Ease[e];return"function"==typeof n?n:null}function i(t,e,n,i){var s=t.prototype;s.__meta__=s.__meta__||{},s.__meta__[e]=n,i&&(s.__defaultProperty__=e)}var s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="",e}return __extends(e,t),e}(t.EventDispatcher);e.BasePath=s,__reflect(s.prototype,"egret.tween.BasePath");var r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.props=void 0,e.duration=500,e.ease=void 0,e}return __extends(e,t),e}(s);e.To=r,__reflect(r.prototype,"egret.tween.To");var o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.duration=500,e.passive=void 0,e}return __extends(e,t),e}(s);e.Wait=o,__reflect(o.prototype,"egret.tween.Wait");var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.props=void 0,e}return __extends(e,t),e}(s);e.Set=u,__reflect(u.prototype,"egret.tween.Set");var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.delta=0,e}return __extends(e,t),e}(s);e.Tick=a,__reflect(a.prototype,"egret.tween.Tick");var p=function(e){function i(){var t=e.call(this)||this;return t.isStop=!1,t}return __extends(i,e),Object.defineProperty(i.prototype,"props",{get:function(){return this._props},set:function(t){this._props=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"target",{get:function(){return this._target},set:function(t){this._target=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"paths",{get:function(){return this._paths},set:function(t){this._paths=t||[]},enumerable:!0,configurable:!0}),i.prototype.play=function(t){this.tween?(this.tween.setPaused(!1),this.isStop&&void 0==t&&(t=0,this.isStop=!1),void 0!==t&&null!==t&&this.tween.setPosition(t)):this.createTween(t)},i.prototype.pause=function(){this.tween&&this.tween.setPaused(!0)},i.prototype.stop=function(){this.pause(),this.isStop=!0},i.prototype.createTween=function(e){this.tween=t.Tween.get(this._target,this._props),this._paths&&this.applyPaths(),void 0!==e&&null!==e&&this.tween.setPosition(e)},i.prototype.applyPaths=function(){for(var t=0;t=0&&e===this._paths.length-1&&this.dispatchEventWith("complete")},i}(t.EventDispatcher);e.TweenItem=p,__reflect(p.prototype,"egret.tween.TweenItem"),i(p,"paths","Array",!0);var h=function(t){function e(){var e=t.call(this)||this;return e.completeCount=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"items",{get:function(){return this._items},set:function(t){this.completeCount=0,this.registerEvent(!1),this._items=t,this.registerEvent(!0)},enumerable:!0,configurable:!0}),e.prototype.registerEvent=function(t){var e=this;this._items&&this._items.forEach(function(n){t?n.addEventListener("complete",e.itemComplete,e):n.removeEventListener("complete",e.itemComplete,e)})},e.prototype.play=function(t){if(this._items)for(var e=0;e UserConfig, - /** - * 设置资源类型 - */ - typeSelector: (path: string) => (string | null | undefined) - /** - * 设置资源的合并策略 - */ - mergeSelector?: (path: string) => (string | null | undefined), - /** - * 设置资源的命名策略 - * beta 功能,请勿随意使用 - */ - nameSelector?: (path: string) => (string | null | undefined) -} -/** - * 构建配置 - */ -type UserConfig = { - /** - * 输出路径 - */ - outputDir: string, - /** - * 插件 - */ - commands: (string | plugins.Command)[] -} - -type BuildConfigParam = { - - - /** - * 当前命令,build 或者 command - */ - readonly command: string; - - /** - * 发布平台 - */ - readonly target: string; - - /** - * 开发者指定的版本号 - */ - readonly version: string; - - /** - * 项目名称 - */ - readonly projectName: string; - - /** - * 项目路径 - */ - readonly projectRoot: string; - - /** - * 项目配置 - */ - readonly projectConfig: ProjectConfig; -} - -type ProjectConfig = { - entryClassName: string; - orientation: string; - frameRate: number; - scaleMode: string; - contentWidth: number; - contentHeight: number; - showFPS: boolean; - fpsStyles: string; - showLog: boolean; - maxTouches: number; -} -/** - * 匹配机制,将满足 from 的文件输出为 to 格式的文件 - * from 采用 glob 表达式 , to 包含 [path][name][hash][ext]四个变量 - * 示例:{ from:"resource/**.*" , to:"[path][name]_[hash].[ext]" } - */ -type Matcher = { - - from: string, - - to: string - -} - - -declare namespace plugins { - - interface CommandContext { - - /** - * 可以用此接口进行文件创建 - */ - createFile(relativeFilePath: string, contents: Buffer); - - /** - * 构建配置 - */ - buildConfig: BuildConfigParam; - - /** - * 项目绝对路径 - */ - projectRoot: string; - - /** - * 项目输出绝对路径 - */ - outputDir: string; - - } - - /** - * 构建管线命令 - */ - interface Command { - - /** - * 项目中的每个文件都会执行此函数,返回 file 表示保留此文件,返回 null 表示将此文件从构建管线中删除,即不会发布 - */ - onFile?(file: File): Promise - - /** - * 项目中所有文件均执行完后,最终会执行此函数。 - * 这个函数主要被用于创建新文件 - */ - onFinish?(pluginContext?: CommandContext): Promise - - [options: string]: any; - } - - interface File { - - /** - * 文件内容的二进制流,如果开发者需要修改文件内容,请修改此属性 - */ - contents: Buffer; - - - /** - * 文件绝对路径,如果开发者需要对文件进行重命名,请修改此属性 - */ - path: string; - - /** - * 文件所在的项目的项目路径 - */ - readonly base: string; - - /** - * 文件的相对于 base 属性的相对路径 - */ - readonly relative: string; - - - /** - * 文件变更历史,history[0] 即 origin 属性 - */ - readonly history: ReadonlyArray; - - - /** - * 文件所在的文件夹的绝对路径 - */ - readonly dirname: string; - - /** - * 文件的文件名 - */ - readonly basename: string; - - - /** - * 文件的扩展名 - */ - readonly extname: string; - - /** - * 文件的初始文件名 - */ - readonly origin: string; - - /** - * 其他自定义属性 - */ - [customProperty: string]: any; - - } - -} - - - - - - - - - - -declare module 'built-in' { - - /** - * 混淆插件参数,设置源代码和目标代码 - */ - type UglifyPluginOption = { sources: string[], target: string }; - - type UglifyPluginOptions = UglifyPluginOption[]; - - /** - * 混淆插件 - */ - export class UglifyPlugin implements plugins.Command { - - constructor(mergeSelector: UglifyPluginOptions); - - } - - - type LibraryType = "debug" | "release"; - - type CompilePluginOptions = { libraryType: LibraryType, defines?: any }; - /** - * 编译命令 - */ - export class CompilePlugin implements plugins.Command { - - constructor(options: CompilePluginOptions); - } - - /** - * EXML 插件,用于发布 EXML 文件 - */ - export class ExmlPlugin implements plugins.Command { - - constructor(publishPolicy: EXML_Publish_Policy); - - } - - /** - * 发布策略 - * * debug : 默认策略,用于开发环境 - * * contents : 将 EXML 的内容写入到主题文件中 - * * gjs : 将生成的JS文件写入到主题文件中 - * * commonjs : 将EXML合并为一个 CommonJS 风格的文件 - * * commonjs2 : 将EXML合并为一个含有解析方法和皮肤定义的文件,且皮肤抽离为一份配置 - * * json : 将每个EXML文件生成一份配置 - */ - type EXML_Publish_Policy = "debug" | "contents" | "gjs" | "commonjs" | "commonjs2" | "json" - - - - - /** - * 生成 manifest 文件,这个文件会被用于记录 JavaScript 文件的版本号 - */ - export class ManifestPlugin implements plugins.Command { - constructor(options?: ManifestPluginOptions) - } - - /** - * 生成文件的文件名 - * 支持 json 与 js 两种格式 - */ - type ManifestPluginOptions = { - - output: string, - - hash?: "crc32", - - /** - * 是否输出转换过程 - */ - verbose?: boolean, - /** - * 其他传递的消息参数 - */ - info?:any - /** - * use wechat engine plugin - */ - useWxPlugin?: boolean - /** - * use QQgame engine plugin - */ - qqPlugin?: { use: boolean, pluginList: string[] } - } - - /** - * EmitResConfigFilePlugin 的参数 - * * output: 生成路径,可以指定生成为 *.res.js 文件或者 *.res.json 文件 - * * typeSelector: 根据文件路径决定文件类型 - * * nameSelector: 根据文件路径决定文件的资源名 - * * groupSelector: 根据文件路径决定资源所述的资源组 - */ - type EmitResConfigFilePluginOptions = { - output: string, - typeSelector: (path: string) => string | null | undefined, - nameSelector: (path: string) => string | null | undefined, - groupSelector: (path: string) => string | null | undefined, - } - - - /** - * 生成 res.json 文件或者 res.js 文件 - */ - export class EmitResConfigFilePlugin implements plugins.Command { - - constructor(options: EmitResConfigFilePluginOptions) - - } - - export type ConvertResourceConfigPluginOption = { - - resourceConfigFiles: { filename: string, root: string }[]; - - nameSelector: (url: string) => string; - - TM_Verbose: boolean; - } - - export class ConvertResConfigFilePlugin implements plugins.Command { - - constructor(options: ConvertResourceConfigPluginOption); - } - - - /** - * 增量编译 - * 这个插件生成的 JavaScript 代码不会被添加到构建管线中,后续其他插件无法获取生成的 js 文件 - * 这个功能将会在未来被 watch 模式代替掉 - */ - export class IncrementCompilePlugin implements plugins.Command { - - } - - type TextureMergerOptions = { - textureMergerRoot: string[]; - } - - /** - * 使用 TextureMerger 实现纹理自动合并,依赖 TextureMerger 1.7 以上的版本 - */ - export class TextureMergerPlugin implements plugins.Command { - - constructor(options: TextureMergerOptions); - - } - - type CleanPluginOptions = { - - matchers: string[] - } - - - export class CleanPlugin implements plugins.Command { - constructor(options: CleanPluginOptions); - } - - - type RenamePluginOptions = { - - /** - * 是否输出日志 - * Whether to output the log - */ - verbose?: boolean - - /** - * 采用何种 hash 算法,目前暂时只支持 crc32 - * What hash algorithm is used, currently only crc32 is supported - */ - hash?: "crc32" - - - /** - * 设置匹配规则,将指定文件进行改名 - * 该参数是个数组,允许设置多个匹配规则 - * Set up matching rules to copy specified files to other folders - * This parameter is an array that allows multiple matching rules to be set - */ - matchers: Matcher[] - - /** - * 回调函数,返回值里包括文件的一些信息 - * The callback function, return value includes some information about the file - */ - callback?: Function - } - - - /** - * 修改文件名插件 - */ - export class RenamePlugin implements plugins.Command { - constructor(options: RenamePluginOptions); - } - - type ResSplitPluginOptions = { - - /** - * 是否输出日志 - * Whether to output the log - */ - verbose?: boolean - - /** - * 设置匹配规则,将指定文件拷贝至其他文件夹 - * 该参数是个数组,允许设置多个匹配规则 - * Set up matching rules to copy specified files to other folders - * This parameter is an array that allows multiple matching rules to be set - */ - matchers: Matcher[] - } - - export class ResSplitPlugin implements plugins.Command { - constructor(options: ResSplitPluginOptions); - } - - - type ZipPluginOptions = { - - mergeSelector: (p: string) => string - } - - export class ZipPlugin implements plugins.Command { - - constructor(option: ZipPluginOptions); - } - - type MergeEuiJsonPluginOptions = { - - mergeSelector?: (p: string) => string | null, - - createConfig?: boolean - } - export class MergeEuiJsonPlugin implements plugins.Command { - - constructor(option?: MergeEuiJsonPluginOptions); - } -} diff --git a/demo/scripts/baidugame/baidugame.ts b/demo/scripts/baidugame/baidugame.ts deleted file mode 100644 index c3edb959..00000000 --- a/demo/scripts/baidugame/baidugame.ts +++ /dev/null @@ -1,82 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; -export class BaidugamePlugin implements plugins.Command { - - constructor() { - } - async onFile(file: plugins.File) { - if (file.extname == '.js') { - const filename = file.origin; - if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { - return null; - } - if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { - let content = file.contents.toString(); - content += `;window.egret = egret;`; - content = content.replace(/definition = __global/, "definition = window"); - file.contents = new Buffer(content); - } - else { - let content = file.contents.toString(); - if ( - filename == "libs/modules/res/res.js" || - filename == 'libs/modules/res/res.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.js' - ) { - content += ";window.RES = RES;" - } - if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') { - content += ";window.eui = eui;" - } - if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') { - content += ';window.dragonBones = dragonBones'; - } - content = "var egret = window.egret;" + content; - if (filename == 'main.js') { - content += "\n;window.Main = Main;" - } - file.contents = new Buffer(content); - } - } - return file; - } - async onFinish(pluginContext: plugins.CommandContext) { - //同步 index.html 配置到 game.js - const gameJSPath = path.join(pluginContext.outputDir, "game.js"); - if(!fs.existsSync(gameJSPath)) { - console.log(`${gameJSPath}不存在,请先使用 Launcher 发布百度小游戏`); - return; - } - let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" }); - const projectConfig = pluginContext.buildConfig.projectConfig; - const optionStr = - `entryClassName: ${projectConfig.entryClassName},\n\t\t` + - `orientation: ${projectConfig.orientation},\n\t\t` + - `frameRate: ${projectConfig.frameRate},\n\t\t` + - `scaleMode: ${projectConfig.scaleMode},\n\t\t` + - `contentWidth: ${projectConfig.contentWidth},\n\t\t` + - `contentHeight: ${projectConfig.contentHeight},\n\t\t` + - `showFPS: ${projectConfig.showFPS},\n\t\t` + - `fpsStyles: ${projectConfig.fpsStyles},\n\t\t` + - `showLog: ${projectConfig.showLog},\n\t\t` + - `maxTouches: ${projectConfig.maxTouches},`; - const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/; - const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----'; - gameJSContent = gameJSContent.replace(reg, replaceStr); - fs.writeFileSync(gameJSPath, gameJSContent); - - //修改横竖屏 - let orientation; - if (projectConfig.orientation == '"landscape"') { - orientation = "landscape"; - } - else { - orientation = "portrait"; - } - const gameJSONPath = path.join(pluginContext.outputDir, "game.json"); - let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); - gameJSONContent.deviceOrientation = orientation; - fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); - } -} \ No newline at end of file diff --git a/demo/scripts/bricks/bricks.ts b/demo/scripts/bricks/bricks.ts deleted file mode 100644 index 2cfe04da..00000000 --- a/demo/scripts/bricks/bricks.ts +++ /dev/null @@ -1,64 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; - - -type ManifestConfig = { - - initial: string[], - - game: string[] - -} - -export class BricksPlugin implements plugins.Command { - - constructor() { - } - async onFile(file: plugins.File) { - const filename = file.basename; - if (filename == 'manifest.json') { - const contents = file.contents.toString(); - const jsonData: ManifestConfig = JSON.parse(contents); - - let content = ''; - content += `BK.Script.loadlib("GameRes://js/promise.js");\n`; - for (let item of jsonData.initial) { - if (item != 'js/promise.js' && item != 'js/promise.min.js') { - content += `BK.Script.loadlib("GameRes://${item}");\n` - } - } - for (let item of jsonData.game) { - content += `BK.Script.loadlib("GameRes://${item}");\n` - } - content += `BK.Script.loadlib("GameRes://egret.bricks.js");\n` - file.path = file.dirname + '/manifest.js' - file.contents = new Buffer(content); - } else if (filename == 'main.js') { - const content = file.contents.toString(); - let result = content.replace(/RES\.loadConfig\("resource\/default\.res\.json", "resource\/"\)/gm, 'RES.loadConfig("GameRes://resource/default.res.json", "GameRes://resource/")'); - result = result.replace(/eui\.Theme\("resource\/default\.thm\.json", _this\.stage\)/gm, 'eui.Theme("GameRes://resource/default.thm.json", _this.stage)'); - result += ";global.Main = Main;"; - file.path = file.dirname + '/main.js' - file.contents = new Buffer(result); - } else if (filename == 'promise.js') { - return null; - } - return file; - } - async onFinish(pluginContext: plugins.CommandContext) { - //同步index.html 配置到main.js - let mainJSPath = path.join(pluginContext.outputDir, 'main.js'); - let mainJSContent = fs.readFileSync(mainJSPath, { encoding: "utf8" }); - let projectConfig = pluginContext.buildConfig.projectConfig; - - mainJSContent = mainJSContent.replace(/frameRate: 30/gm, `frameRate: ${projectConfig.frameRate}`); - mainJSContent = mainJSContent.replace(/contentWidth: 640/gm, `contentWidth: ${projectConfig.contentWidth}`); - mainJSContent = mainJSContent.replace(/contentHeight: 1136/gm, `contentHeight: ${projectConfig.contentHeight}`); - mainJSContent = mainJSContent.replace(/entryClassName: "Main"/gm, `entryClassName: ${projectConfig.entryClassName}`); - mainJSContent = mainJSContent.replace(/scaleMode: "showAll"/gm, `scaleMode: ${projectConfig.scaleMode}`); - mainJSContent = mainJSContent.replace(/orientation: "auto"/gm, `orientation: ${projectConfig.orientation}`); - fs.writeFileSync(mainJSPath, mainJSContent); - } -} - -declare var egret; \ No newline at end of file diff --git a/demo/scripts/config.android.ts b/demo/scripts/config.android.ts deleted file mode 100644 index b4d7dea7..00000000 --- a/demo/scripts/config.android.ts +++ /dev/null @@ -1,52 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_android/assets/game`; - if (command == 'build') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new ManifestPlugin({ output: 'manifest.json' }) - ] - } - } - else if (command == 'publish') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new UglifyPlugin([{ - sources: ["main.js"], - target: "main.min.js" - } - ]), - new ManifestPlugin({ output: 'manifest.json' }) - ] - } - } - else { - throw `unknown command : ${params.command}`; - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/demo/scripts/config.baidugame.ts b/demo/scripts/config.baidugame.ts deleted file mode 100644 index 640c7b11..00000000 --- a/demo/scripts/config.baidugame.ts +++ /dev/null @@ -1,63 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; -import { BaidugamePlugin } from './baidugame/baidugame'; -import { CustomPlugin } from './myplugin'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_baidugame`; - if (command == 'build') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new BaidugamePlugin(), - new ManifestPlugin({ output: 'manifest.js' }) - ] - } - } - else if (command == 'publish') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new BaidugamePlugin(), - new UglifyPlugin([ - // 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置 - // { - // sources: ["resource/default.thm.js"], - // target: "default.thm.min.js" - // }, - { - sources: ["main.js"], - target: "main.min.js" - } - ]), - new ManifestPlugin({ output: 'manifest.js' }) - ] - } - } - else { - throw `unknown command : ${params.command}`; - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/demo/scripts/config.bricks.ts b/demo/scripts/config.bricks.ts deleted file mode 100644 index 6c5d05ad..00000000 --- a/demo/scripts/config.bricks.ts +++ /dev/null @@ -1,55 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; -import { BricksPlugin } from './bricks/bricks'; -import { CustomPlugin } from './myplugin'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_bricks/PublicBrickEngineGame/Res`; - if (command == 'build') { - return { - outputDir, - commands: [ - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new ManifestPlugin({ output: 'manifest.json' }), - new BricksPlugin() - ] - } - } - else if (command == 'publish') { - console.log('执行publish') - return { - outputDir, - commands: [ - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new ManifestPlugin({ output: 'manifest.json' }), - new UglifyPlugin([{ - sources: ["main.js"], - target: "js/main.min.js" - } - ]), - new BricksPlugin(), - ] - } - } else { - throw `unknown command : ${params.command}`; - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/demo/scripts/config.ios.ts b/demo/scripts/config.ios.ts deleted file mode 100644 index 2592c1a7..00000000 --- a/demo/scripts/config.ios.ts +++ /dev/null @@ -1,52 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_ios/assets/game`; - if (command == 'build') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new ManifestPlugin({ output: 'manifest.json' }) - ] - } - } - else if (command == 'publish') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new UglifyPlugin([{ - sources: ["main.js"], - target: "main.min.js" - } - ]), - new ManifestPlugin({ output: 'manifest.json' }) - ] - } - } - else { - throw `unknown command : ${params.command}`; - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/demo/scripts/config.mygame.ts b/demo/scripts/config.mygame.ts deleted file mode 100644 index bc814caa..00000000 --- a/demo/scripts/config.mygame.ts +++ /dev/null @@ -1,63 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; -import { MygamePlugin } from './mygame/mygame'; -import { CustomPlugin } from './myplugin'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_mygame`; - if (command == 'build') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new MygamePlugin(), - new ManifestPlugin({ output: 'manifest.js' }) - ] - } - } - else if (command == 'publish') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new MygamePlugin(), - new UglifyPlugin([ - // 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置 - // { - // sources: ["resource/default.thm.js"], - // target: "default.thm.min.js" - // }, - { - sources: ["main.js"], - target: "main.min.js" - } - ]), - new ManifestPlugin({ output: 'manifest.js' }) - ] - } - } - else { - throw `unknown command : ${params.command}`; - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/demo/scripts/config.oppogame.ts b/demo/scripts/config.oppogame.ts deleted file mode 100644 index a2b240bc..00000000 --- a/demo/scripts/config.oppogame.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in'; -import { OppogamePlugin } from './oppogame/oppogame'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_oppogame`; - if (command == 'build') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new OppogamePlugin(), - new ManifestPlugin({ output: 'manifest.js' }) - ] - } - } - else if (command == 'publish') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new OppogamePlugin(), - new UglifyPlugin([ - // 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置 - // { - // sources: ["resource/default.thm.js"], - // target: "default.thm.min.js" - // }, - { - sources: ["main.js"], - target: "main.min.js" - } - ]), - new ManifestPlugin({ output: 'manifest.js' }) - ] - } - } - else { - throw `unknown command : ${params.command}`; - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/demo/scripts/config.qgame.ts b/demo/scripts/config.qgame.ts deleted file mode 100644 index 168fcf65..00000000 --- a/demo/scripts/config.qgame.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in'; -import { MiqgamePlugin } from './qgame/qgame'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_qgame`; - if (command == 'build') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new MiqgamePlugin(), - new ManifestPlugin({ output: 'manifest.js' }) - ] - } - } - else if (command == 'publish') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new MiqgamePlugin(), - new UglifyPlugin([ - // 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置 - // { - // sources: ["resource/default.thm.js"], - // target: "default.thm.min.js" - // }, - { - sources: ["main.js"], - target: "main.min.js" - } - ]), - new ManifestPlugin({ output: 'manifest.js' }) - ] - } - } - else { - throw `unknown command : ${params.command}`; - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/demo/scripts/config.qqgame.ts b/demo/scripts/config.qqgame.ts deleted file mode 100644 index 7168ec4b..00000000 --- a/demo/scripts/config.qqgame.ts +++ /dev/null @@ -1,65 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; -import { QQgamePlugin } from './qqgame/qqgame'; -import { CustomPlugin } from './myplugin'; -import * as defaultConfig from './config'; -//是否使用QQ小游戏引擎插件 -const useQQPlugin: boolean = false; -let pluginList: string[] = [] -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_qqgame`; - if (command == 'build') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new QQgamePlugin(useQQPlugin, pluginList), - new ManifestPlugin({ output: 'manifest.js', qqPlugin: { use: useQQPlugin, pluginList: pluginList } }) - ] - } - } - else if (command == 'publish') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource"] }), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new QQgamePlugin(useQQPlugin, pluginList), - new UglifyPlugin([ - // 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置 - // { - // sources: ["resource/default.thm.js"], - // target: "default.thm.min.js" - // }, - { - sources: ["main.js"], - target: "main.min.js" - } - ]), - new ManifestPlugin({ output: 'manifest.js', qqPlugin: { use: useQQPlugin, pluginList: pluginList } }) - ] - } - } - else { - throw `unknown command : ${params.command}`; - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/demo/scripts/config.ts b/demo/scripts/config.ts deleted file mode 100644 index 71c5e999..00000000 --- a/demo/scripts/config.ts +++ /dev/null @@ -1,95 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, IncrementCompilePlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, RenamePlugin } from 'built-in'; -import { WxgamePlugin } from './wxgame/wxgame'; -import { BricksPlugin } from './bricks/bricks'; -import { CustomPlugin } from './myplugin'; - -const config: ResourceManagerConfig = { - - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - - if (command == 'build') { - const outputDir = '.'; - return { - outputDir, - commands: [ - // new EmitResConfigFilePlugin({ - // output: "resource/default.res.json", - // typeSelector: config.typeSelector, - // nameSelector: p => path.basename(p).replace(/\./gi, "_"), - // groupSelector: p => "preload" - // }), - new ExmlPlugin('debug'), // 非 EUI 项目关闭此设置 - new IncrementCompilePlugin(), - ] - } - } - else if (command == 'publish') { - const outputDir = `bin-release/web/${version}`; - return { - outputDir, - commands: [ - new CustomPlugin(), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new UglifyPlugin([{ - sources: ["main.js"], - target: "main.min.js" - }]), - new RenamePlugin({ - verbose: true, hash: 'crc32', matchers: [ - { from: "**/*.js", to: "[path][name]_[hash].[ext]" } - ] - }), - new ManifestPlugin({ output: "manifest.json" }) - ] - } - } - else { - throw `unknown command : ${params.command}` - } - }, - - mergeSelector: (path) => { - if (path.indexOf("assets/bitmap/") >= 0) { - return "assets/bitmap/sheet.sheet" - } - else if (path.indexOf("armature") >= 0 && path.indexOf(".json") >= 0) { - return "assets/armature/1.zip"; - } - }, - - typeSelector: (path) => { - const ext = path.substr(path.lastIndexOf(".") + 1); - const typeMap = { - "jpg": "image", - "png": "image", - "webp": "image", - "json": "json", - "fnt": "font", - "pvr": "pvr", - "mp3": "sound", - "zip": "zip", - "sheet": "sheet", - "exml": "text" - } - let type = typeMap[ext]; - if (type == "json") { - if (path.indexOf("sheet") >= 0) { - type = "sheet"; - } else if (path.indexOf("movieclip") >= 0) { - type = "movieclip"; - }; - } - return type; - } -} - - -export = config; diff --git a/demo/scripts/config.vivogame.ts b/demo/scripts/config.vivogame.ts deleted file mode 100644 index 6b4d8ee0..00000000 --- a/demo/scripts/config.vivogame.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in'; -import { VivogamePlugin } from './vivogame/vivogame'; -import * as defaultConfig from './config'; - -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_vivogame/src`; - if (command == 'build') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["../engine/js", "resource"] }), - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new VivogamePlugin(), - new ManifestPlugin({ output: 'manifest.js', info: { target: 'vivogame' } }) - ] - } - } - else if (command == 'publish') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["../engine/js", "resource"] }), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new VivogamePlugin(), - new UglifyPlugin([ - // 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置 - // { - // sources: ["resource/default.thm.js"], - // target: "default.thm.min.js" - // }, - { - sources: ["main.js"], - target: "main.min.js" - } - ]), - new ManifestPlugin({ output: 'manifest.js', info: { target: 'vivogame' } }) - ] - } - } - else { - throw `unknown command : ${params.command}`; - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/demo/scripts/config.wxgame.ts b/demo/scripts/config.wxgame.ts deleted file mode 100644 index 1ebf1409..00000000 --- a/demo/scripts/config.wxgame.ts +++ /dev/null @@ -1,65 +0,0 @@ -/// 阅读 api.d.ts 查看文档 -/// - -import * as path from 'path'; -import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, EmitResConfigFilePlugin, TextureMergerPlugin, CleanPlugin } from 'built-in'; -import { WxgamePlugin } from './wxgame/wxgame'; -import { CustomPlugin } from './myplugin'; -import * as defaultConfig from './config'; - -//是否使用微信分离插件 -const useWxPlugin: boolean = false; -const config: ResourceManagerConfig = { - - buildConfig: (params) => { - - const { target, command, projectName, version } = params; - const outputDir = `../${projectName}_wxgame`; - if (command == 'build') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource", "egret-library"] }), - new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new WxgamePlugin(useWxPlugin), - new ManifestPlugin({ output: 'manifest.js' }) - ] - } - } - else if (command == 'publish') { - return { - outputDir, - commands: [ - new CleanPlugin({ matchers: ["js", "resource", "egret-library"] }), - new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), - new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 - new WxgamePlugin(useWxPlugin), - new UglifyPlugin([ - // 使用 EUI 项目,要压缩皮肤文件,可以开启这个压缩配置 - // { - // sources: ["resource/default.thm.js"], - // target: "default.thm.min.js" - // }, - { - sources: ["main.js"], - target: "main.min.js" - } - ]), - new ManifestPlugin({ output: 'manifest.js', useWxPlugin: useWxPlugin }) - ] - } - } - else { - throw `unknown command : ${params.command}`; - } - }, - - mergeSelector: defaultConfig.mergeSelector, - - typeSelector: defaultConfig.typeSelector -} - - - -export = config; diff --git a/demo/scripts/mygame/mygame.ts b/demo/scripts/mygame/mygame.ts deleted file mode 100644 index bea256f9..00000000 --- a/demo/scripts/mygame/mygame.ts +++ /dev/null @@ -1,82 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; -export class MygamePlugin implements plugins.Command { - - constructor() { - } - async onFile(file: plugins.File) { - if (file.extname == '.js') { - const filename = file.origin; - if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { - return null; - } - if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { - let content = file.contents.toString(); - content += `;window.egret = egret;`; - content = content.replace(/definition = __global/, "definition = window"); - file.contents = new Buffer(content); - } - else { - let content = file.contents.toString(); - if ( - filename == "libs/modules/res/res.js" || - filename == 'libs/modules/res/res.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.js' - ) { - content += ";window.RES = RES;" - } - if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') { - content += ";window.eui = eui;" - } - if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') { - content += ';window.dragonBones = dragonBones'; - } - content = "var egret = window.egret;" + content; - if (filename == 'main.js') { - content += "\n;window.Main = Main;" - } - file.contents = new Buffer(content); - } - } - return file; - } - async onFinish(pluginContext: plugins.CommandContext) { - //同步 index.html 配置到 game.js - const gameJSPath = path.join(pluginContext.outputDir, "game.js"); - if (!fs.existsSync(gameJSPath)) { - console.log(`${gameJSPath}不存在,请先使用 Launcher 发布支付宝小游戏`); - return; - } - let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" }); - const projectConfig = pluginContext.buildConfig.projectConfig; - const optionStr = - `entryClassName: ${projectConfig.entryClassName},\n\t\t` + - `orientation: ${projectConfig.orientation},\n\t\t` + - `frameRate: ${projectConfig.frameRate},\n\t\t` + - `scaleMode: ${projectConfig.scaleMode},\n\t\t` + - `contentWidth: ${projectConfig.contentWidth},\n\t\t` + - `contentHeight: ${projectConfig.contentHeight},\n\t\t` + - `showFPS: ${projectConfig.showFPS},\n\t\t` + - `fpsStyles: ${projectConfig.fpsStyles},\n\t\t` + - `showLog: ${projectConfig.showLog},\n\t\t` + - `maxTouches: ${projectConfig.maxTouches},`; - const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/; - const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----'; - gameJSContent = gameJSContent.replace(reg, replaceStr); - fs.writeFileSync(gameJSPath, gameJSContent); - - //修改横竖屏 - let orientation; - if (projectConfig.orientation == '"landscape"') { - orientation = "landscape"; - } - else { - orientation = "portrait"; - } - const gameJSONPath = path.join(pluginContext.outputDir, "game.json"); - let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); - gameJSONContent.deviceOrientation = orientation; - fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); - } -} diff --git a/demo/scripts/myplugin.ts b/demo/scripts/myplugin.ts deleted file mode 100644 index 096133a6..00000000 --- a/demo/scripts/myplugin.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 示例自定义插件,您可以查阅 http://developer.egret.com/cn/github/egret-docs/Engine2D/projectConfig/cmdExtensionPlugin/index.html - * 了解如何开发一个自定义插件 - */ -export class CustomPlugin implements plugins.Command { - - constructor() { - } - - async onFile(file: plugins.File) { - return file; - } - - async onFinish(commandContext: plugins.CommandContext) { - - } -} \ No newline at end of file diff --git a/demo/scripts/node.d.ts b/demo/scripts/node.d.ts deleted file mode 100644 index 239fd389..00000000 --- a/demo/scripts/node.d.ts +++ /dev/null @@ -1,4209 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/a4a912a0cd1849fa7df0e5d909c8625fba04e49d/node/index.d.ts -interface Console { - Console: NodeJS.ConsoleConstructor; - assert(value: any, message?: string, ...optionalParams: any[]): void; - dir(obj: any, options?: {showHidden?: boolean, depth?: number, colors?: boolean}): void; - error(message?: any, ...optionalParams: any[]): void; - info(message?: any, ...optionalParams: any[]): void; - log(message?: any, ...optionalParams: any[]): void; - time(label: string): void; - timeEnd(label: string): void; - trace(message?: any, ...optionalParams: any[]): void; - warn(message?: any, ...optionalParams: any[]): void; -} - -interface Error { - stack?: string; -} - -interface ErrorConstructor { - captureStackTrace(targetObject: Object, constructorOpt?: Function): void; - stackTraceLimit: number; -} - -// compat for TypeScript 1.8 -// if you use with --target es3 or --target es5 and use below definitions, -// use the lib.es6.d.ts that is bundled with TypeScript 1.8. -interface MapConstructor { } -interface WeakMapConstructor { } -interface SetConstructor { } -interface WeakSetConstructor { } - -// Forward-declare needed types from lib.es2015.d.ts (in case users are using `--lib es5`) -interface Iterable {} -interface Iterator { - next(value?: any): IteratorResult; -} -interface IteratorResult {} -interface SymbolConstructor { - readonly iterator: symbol; -} -declare var Symbol: SymbolConstructor; - -/************************************************ -* * -* GLOBAL * -* * -************************************************/ -declare var process: NodeJS.Process; -declare var global: NodeJS.Global; -declare var console: Console; - -declare var __filename: string; -declare var __dirname: string; - -declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; -declare function clearTimeout(timeoutId: NodeJS.Timer): void; -declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; -declare function clearInterval(intervalId: NodeJS.Timer): void; -declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; -declare function clearImmediate(immediateId: any): void; - -interface NodeRequireFunction { - (id: string): any; -} - -interface NodeRequire extends NodeRequireFunction { - resolve(id: string): string; - cache: any; - extensions: any; - main: NodeModule | undefined; -} - -declare var require: NodeRequire; - -interface NodeModule { - exports: any; - require: NodeRequireFunction; - id: string; - filename: string; - loaded: boolean; - parent: NodeModule | null; - children: NodeModule[]; -} - -declare var module: NodeModule; - -// Same as module.exports -declare var exports: any; -declare var SlowBuffer: { - new (str: string, encoding?: string): Buffer; - new (size: number): Buffer; - new (size: Uint8Array): Buffer; - new (array: any[]): Buffer; - prototype: Buffer; - isBuffer(obj: any): boolean; - byteLength(string: string, encoding?: string): number; - concat(list: Buffer[], totalLength?: number): Buffer; -}; - - -// Buffer class -type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "binary" | "hex"; -interface Buffer extends NodeBuffer { } - -/** - * Raw data is stored in instances of the Buffer class. - * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. - * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' - */ -declare var Buffer: { - /** - * Allocates a new buffer containing the given {str}. - * - * @param str String to store in buffer. - * @param encoding encoding to use, optional. Default is 'utf8' - */ - new (str: string, encoding?: string): Buffer; - /** - * Allocates a new buffer of {size} octets. - * - * @param size count of octets to allocate. - */ - new (size: number): Buffer; - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - new (array: Uint8Array): Buffer; - /** - * Produces a Buffer backed by the same allocated memory as - * the given {ArrayBuffer}. - * - * - * @param arrayBuffer The ArrayBuffer with which to share memory. - */ - new (arrayBuffer: ArrayBuffer): Buffer; - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - new (array: any[]): Buffer; - /** - * Copies the passed {buffer} data onto a new {Buffer} instance. - * - * @param buffer The buffer to copy. - */ - new (buffer: Buffer): Buffer; - prototype: Buffer; - /** - * Allocates a new Buffer using an {array} of octets. - * - * @param array - */ - from(array: any[]): Buffer; - /** - * When passed a reference to the .buffer property of a TypedArray instance, - * the newly created Buffer will share the same allocated memory as the TypedArray. - * The optional {byteOffset} and {length} arguments specify a memory range - * within the {arrayBuffer} that will be shared by the Buffer. - * - * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer() - * @param byteOffset - * @param length - */ - from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; - /** - * Copies the passed {buffer} data onto a new Buffer instance. - * - * @param buffer - */ - from(buffer: Buffer): Buffer; - /** - * Creates a new Buffer containing the given JavaScript string {str}. - * If provided, the {encoding} parameter identifies the character encoding. - * If not provided, {encoding} defaults to 'utf8'. - * - * @param str - */ - from(str: string, encoding?: string): Buffer; - /** - * Returns true if {obj} is a Buffer - * - * @param obj object to test. - */ - isBuffer(obj: any): obj is Buffer; - /** - * Returns true if {encoding} is a valid encoding argument. - * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' - * - * @param encoding string to test. - */ - isEncoding(encoding: string): boolean; - /** - * Gives the actual byte length of a string. encoding defaults to 'utf8'. - * This is not the same as String.prototype.length since that returns the number of characters in a string. - * - * @param string string to test. - * @param encoding encoding used to evaluate (defaults to 'utf8') - */ - byteLength(string: string, encoding?: string): number; - /** - * Returns a buffer which is the result of concatenating all the buffers in the list together. - * - * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. - * If the list has exactly one item, then the first item of the list is returned. - * If the list has more than one item, then a new Buffer is created. - * - * @param list An array of Buffer objects to concatenate - * @param totalLength Total length of the buffers when concatenated. - * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. - */ - concat(list: Buffer[], totalLength?: number): Buffer; - /** - * The same as buf1.compare(buf2). - */ - compare(buf1: Buffer, buf2: Buffer): number; - /** - * Allocates a new buffer of {size} octets. - * - * @param size count of octets to allocate. - * @param fill if specified, buffer will be initialized by calling buf.fill(fill). - * If parameter is omitted, buffer will be filled with zeros. - * @param encoding encoding used for call to buf.fill while initalizing - */ - alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; - /** - * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents - * of the newly created Buffer are unknown and may contain sensitive data. - * - * @param size count of octets to allocate - */ - allocUnsafe(size: number): Buffer; - /** - * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents - * of the newly created Buffer are unknown and may contain sensitive data. - * - * @param size count of octets to allocate - */ - allocUnsafeSlow(size: number): Buffer; -}; - -/************************************************ -* * -* GLOBAL INTERFACES * -* * -************************************************/ -declare namespace NodeJS { - export interface ConsoleConstructor { - prototype: Console; - new(stdout: WritableStream, stderr?: WritableStream): Console; - } - - export interface ErrnoException extends Error { - errno?: number; - code?: string; - path?: string; - syscall?: string; - stack?: string; - } - - export class EventEmitter { - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; - removeAllListeners(event?: string | symbol): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string | symbol): Function[]; - emit(event: string | symbol, ...args: any[]): boolean; - listenerCount(type: string | symbol): number; - // Added in Node 6... - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; - eventNames(): (string | symbol)[]; - } - - export interface ReadableStream extends EventEmitter { - readable: boolean; - isTTY?: boolean; - read(size?: number): string | Buffer; - setEncoding(encoding: string | null): this; - pause(): this; - resume(): this; - isPaused(): boolean; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): this; - unshift(chunk: string): void; - unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; - } - - export interface WritableStream extends EventEmitter { - writable: boolean; - isTTY?: boolean; - write(buffer: Buffer | string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - } - - export interface ReadWriteStream extends ReadableStream, WritableStream { } - - export interface Events extends EventEmitter { } - - export interface Domain extends Events { - run(fn: Function): void; - add(emitter: Events): void; - remove(emitter: Events): void; - bind(cb: (err: Error, data: any) => any): any; - intercept(cb: (data: any) => any): any; - dispose(): void; - - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; - removeAllListeners(event?: string): this; - } - - export interface MemoryUsage { - rss: number; - heapTotal: number; - heapUsed: number; - } - - export interface CpuUsage { - user: number; - system: number; - } - - export interface ProcessVersions { - http_parser: string; - node: string; - v8: string; - ares: string; - uv: string; - zlib: string; - modules: string; - openssl: string; - } - - type Platform = 'aix' - | 'android' - | 'darwin' - | 'freebsd' - | 'linux' - | 'openbsd' - | 'sunos' - | 'win32'; - - export interface Process extends EventEmitter { - stdout: WritableStream; - stderr: WritableStream; - stdin: ReadableStream; - argv: string[]; - argv0: string; - execArgv: string[]; - execPath: string; - abort(): void; - chdir(directory: string): void; - cwd(): string; - env: any; - exit(code?: number): void; - exitCode: number; - getgid(): number; - setgid(id: number): void; - setgid(id: string): void; - getuid(): number; - setuid(id: number): void; - setuid(id: string): void; - version: string; - versions: ProcessVersions; - config: { - target_defaults: { - cflags: any[]; - default_configuration: string; - defines: string[]; - include_dirs: string[]; - libraries: string[]; - }; - variables: { - clang: number; - host_arch: string; - node_install_npm: boolean; - node_install_waf: boolean; - node_prefix: string; - node_shared_openssl: boolean; - node_shared_v8: boolean; - node_shared_zlib: boolean; - node_use_dtrace: boolean; - node_use_etw: boolean; - node_use_openssl: boolean; - target_arch: string; - v8_no_strict_aliasing: number; - v8_use_snapshot: boolean; - visibility: string; - }; - }; - kill(pid: number, signal?: string | number): void; - pid: number; - title: string; - arch: string; - platform: Platform; - mainModule?: NodeModule; - memoryUsage(): MemoryUsage; - cpuUsage(previousValue?: CpuUsage): CpuUsage; - nextTick(callback: Function, ...args: any[]): void; - umask(mask?: number): number; - uptime(): number; - hrtime(time?: [number, number]): [number, number]; - domain: Domain; - - // Worker - send?(message: any, sendHandle?: any): void; - disconnect(): void; - connected: boolean; - } - - export interface Global { - Array: typeof Array; - ArrayBuffer: typeof ArrayBuffer; - Boolean: typeof Boolean; - Buffer: typeof Buffer; - DataView: typeof DataView; - Date: typeof Date; - Error: typeof Error; - EvalError: typeof EvalError; - Float32Array: typeof Float32Array; - Float64Array: typeof Float64Array; - Function: typeof Function; - GLOBAL: Global; - Infinity: typeof Infinity; - Int16Array: typeof Int16Array; - Int32Array: typeof Int32Array; - Int8Array: typeof Int8Array; - Intl: typeof Intl; - JSON: typeof JSON; - Map: MapConstructor; - Math: typeof Math; - NaN: typeof NaN; - Number: typeof Number; - Object: typeof Object; - Promise: Function; - RangeError: typeof RangeError; - ReferenceError: typeof ReferenceError; - RegExp: typeof RegExp; - Set: SetConstructor; - String: typeof String; - Symbol: Function; - SyntaxError: typeof SyntaxError; - TypeError: typeof TypeError; - URIError: typeof URIError; - Uint16Array: typeof Uint16Array; - Uint32Array: typeof Uint32Array; - Uint8Array: typeof Uint8Array; - Uint8ClampedArray: Function; - WeakMap: WeakMapConstructor; - WeakSet: WeakSetConstructor; - clearImmediate: (immediateId: any) => void; - clearInterval: (intervalId: NodeJS.Timer) => void; - clearTimeout: (timeoutId: NodeJS.Timer) => void; - console: typeof console; - decodeURI: typeof decodeURI; - decodeURIComponent: typeof decodeURIComponent; - encodeURI: typeof encodeURI; - encodeURIComponent: typeof encodeURIComponent; - escape: (str: string) => string; - eval: typeof eval; - global: Global; - isFinite: typeof isFinite; - isNaN: typeof isNaN; - parseFloat: typeof parseFloat; - parseInt: typeof parseInt; - process: Process; - root: Global; - setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; - setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - undefined: typeof undefined; - unescape: (str: string) => string; - gc: () => void; - v8debug?: any; - } - - export interface Timer { - ref(): void; - unref(): void; - } -} - -interface IterableIterator { } - -/** - * @deprecated - */ -interface NodeBuffer extends Uint8Array { - write(string: string, offset?: number, length?: number, encoding?: string): number; - toString(encoding?: string, start?: number, end?: number): string; - toJSON(): { type: 'Buffer', data: any[] }; - equals(otherBuffer: Buffer): boolean; - compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number; - copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; - slice(start?: number, end?: number): Buffer; - writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readUInt8(offset: number, noAssert?: boolean): number; - readUInt16LE(offset: number, noAssert?: boolean): number; - readUInt16BE(offset: number, noAssert?: boolean): number; - readUInt32LE(offset: number, noAssert?: boolean): number; - readUInt32BE(offset: number, noAssert?: boolean): number; - readInt8(offset: number, noAssert?: boolean): number; - readInt16LE(offset: number, noAssert?: boolean): number; - readInt16BE(offset: number, noAssert?: boolean): number; - readInt32LE(offset: number, noAssert?: boolean): number; - readInt32BE(offset: number, noAssert?: boolean): number; - readFloatLE(offset: number, noAssert?: boolean): number; - readFloatBE(offset: number, noAssert?: boolean): number; - readDoubleLE(offset: number, noAssert?: boolean): number; - readDoubleBE(offset: number, noAssert?: boolean): number; - swap16(): Buffer; - swap32(): Buffer; - swap64(): Buffer; - writeUInt8(value: number, offset: number, noAssert?: boolean): number; - writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeInt8(value: number, offset: number, noAssert?: boolean): number; - writeInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeFloatLE(value: number, offset: number, noAssert?: boolean): number; - writeFloatBE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; - fill(value: any, offset?: number, end?: number): this; - indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; - lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; - entries(): IterableIterator<[number, number]>; - includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean; - keys(): IterableIterator; - values(): IterableIterator; -} - -/************************************************ -* * -* MODULES * -* * -************************************************/ -declare module "buffer" { - export var INSPECT_MAX_BYTES: number; - var BuffType: typeof Buffer; - var SlowBuffType: typeof SlowBuffer; - export { BuffType as Buffer, SlowBuffType as SlowBuffer }; -} - -declare module "querystring" { - export interface StringifyOptions { - encodeURIComponent?: Function; - } - - export interface ParseOptions { - maxKeys?: number; - decodeURIComponent?: Function; - } - - export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string; - export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any; - export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T; - export function escape(str: string): string; - export function unescape(str: string): string; -} - -declare module "events" { - class internal extends NodeJS.EventEmitter { } - - namespace internal { - export class EventEmitter extends internal { - static listenerCount(emitter: EventEmitter, event: string | symbol): number; // deprecated - static defaultMaxListeners: number; - - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; - removeAllListeners(event?: string | symbol): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string | symbol): Function[]; - emit(event: string | symbol, ...args: any[]): boolean; - eventNames(): (string | symbol)[]; - listenerCount(type: string | symbol): number; - } - } - - export = internal; -} - -declare module "http" { - import * as events from "events"; - import * as net from "net"; - import * as stream from "stream"; - - export interface RequestOptions { - protocol?: string; - host?: string; - hostname?: string; - family?: number; - port?: number; - localAddress?: string; - socketPath?: string; - method?: string; - path?: string; - headers?: { [key: string]: any }; - auth?: string; - agent?: Agent | boolean; - timeout?: number; - } - - export interface Server extends net.Server { - setTimeout(msecs: number, callback: Function): void; - maxHeadersCount: number; - timeout: number; - listening: boolean; - } - /** - * @deprecated Use IncomingMessage - */ - export interface ServerRequest extends IncomingMessage { - connection: net.Socket; - } - export interface ServerResponse extends stream.Writable { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - writeContinue(): void; - writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; - writeHead(statusCode: number, headers?: any): void; - statusCode: number; - statusMessage: string; - headersSent: boolean; - setHeader(name: string, value: string | string[]): void; - setTimeout(msecs: number, callback: Function): ServerResponse; - sendDate: boolean; - getHeader(name: string): string; - removeHeader(name: string): void; - write(chunk: any, encoding?: string): any; - addTrailers(headers: any): void; - finished: boolean; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - export interface ClientRequest extends stream.Writable { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - write(chunk: any, encoding?: string): void; - abort(): void; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; - - setHeader(name: string, value: string | string[]): void; - getHeader(name: string): string; - removeHeader(name: string): void; - addTrailers(headers: any): void; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - export interface IncomingMessage extends stream.Readable { - httpVersion: string; - httpVersionMajor: number; - httpVersionMinor: number; - connection: net.Socket; - headers: any; - rawHeaders: string[]; - trailers: any; - rawTrailers: any; - setTimeout(msecs: number, callback: Function): NodeJS.Timer; - /** - * Only valid for request obtained from http.Server. - */ - method?: string; - /** - * Only valid for request obtained from http.Server. - */ - url?: string; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusCode?: number; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusMessage?: string; - socket: net.Socket; - destroy(error?: Error): void; - } - /** - * @deprecated Use IncomingMessage - */ - export interface ClientResponse extends IncomingMessage { } - - export interface AgentOptions { - /** - * Keep sockets around in a pool to be used by other requests in the future. Default = false - */ - keepAlive?: boolean; - /** - * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. - * Only relevant if keepAlive is set to true. - */ - keepAliveMsecs?: number; - /** - * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity - */ - maxSockets?: number; - /** - * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. - */ - maxFreeSockets?: number; - } - - export class Agent { - maxSockets: number; - sockets: any; - requests: any; - - constructor(opts?: AgentOptions); - - /** - * Destroy any sockets that are currently in use by the agent. - * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, - * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, - * sockets may hang open for quite a long time before the server terminates them. - */ - destroy(): void; - } - - export var METHODS: string[]; - - export var STATUS_CODES: { - [errorCode: number]: string; - [errorCode: string]: string; - }; - export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server; - export function createClient(port?: number, host?: string): any; - export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; - export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest; - export var globalAgent: Agent; -} - -declare module "cluster" { - import * as child from "child_process"; - import * as events from "events"; - import * as net from "net"; - - // interfaces - export interface ClusterSettings { - execArgv?: string[]; // default: process.execArgv - exec?: string; - args?: string[]; - silent?: boolean; - stdio?: any[]; - uid?: number; - gid?: number; - } - - export interface ClusterSetupMasterSettings { - exec?: string; // default: process.argv[1] - args?: string[]; // default: process.argv.slice(2) - silent?: boolean; // default: false - stdio?: any[]; - } - - export interface Address { - address: string; - port: number; - addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6" - } - - export class Worker extends events.EventEmitter { - id: string; - process: child.ChildProcess; - suicide: boolean; - send(message: any, sendHandle?: any): boolean; - kill(signal?: string): void; - destroy(signal?: string): void; - disconnect(): void; - isConnected(): boolean; - isDead(): boolean; - exitedAfterDisconnect: boolean; - - /** - * events.EventEmitter - * 1. disconnect - * 2. error - * 3. exit - * 4. listening - * 5. message - * 6. online - */ - addListener(event: string, listener: Function): this; - addListener(event: "disconnect", listener: () => void): this; - addListener(event: "error", listener: (code: number, signal: string) => void): this; - addListener(event: "exit", listener: (code: number, signal: string) => void): this; - addListener(event: "listening", listener: (address: Address) => void): this; - addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - addListener(event: "online", listener: () => void): this; - - emit(event: string, listener: Function): boolean - emit(event: "disconnect", listener: () => void): boolean - emit(event: "error", listener: (code: number, signal: string) => void): boolean - emit(event: "exit", listener: (code: number, signal: string) => void): boolean - emit(event: "listening", listener: (address: Address) => void): boolean - emit(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): boolean - emit(event: "online", listener: () => void): boolean - - on(event: string, listener: Function): this; - on(event: "disconnect", listener: () => void): this; - on(event: "error", listener: (code: number, signal: string) => void): this; - on(event: "exit", listener: (code: number, signal: string) => void): this; - on(event: "listening", listener: (address: Address) => void): this; - on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - on(event: "online", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "disconnect", listener: () => void): this; - once(event: "error", listener: (code: number, signal: string) => void): this; - once(event: "exit", listener: (code: number, signal: string) => void): this; - once(event: "listening", listener: (address: Address) => void): this; - once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - once(event: "online", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "disconnect", listener: () => void): this; - prependListener(event: "error", listener: (code: number, signal: string) => void): this; - prependListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependListener(event: "listening", listener: (address: Address) => void): this; - prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependListener(event: "online", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "disconnect", listener: () => void): this; - prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "listening", listener: (address: Address) => void): this; - prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependOnceListener(event: "online", listener: () => void): this; - } - - export interface Cluster extends events.EventEmitter { - Worker: Worker; - disconnect(callback?: Function): void; - fork(env?: any): Worker; - isMaster: boolean; - isWorker: boolean; - // TODO: cluster.schedulingPolicy - settings: ClusterSettings; - setupMaster(settings?: ClusterSetupMasterSettings): void; - worker: Worker; - workers: { - [index: string]: Worker - }; - - /** - * events.EventEmitter - * 1. disconnect - * 2. exit - * 3. fork - * 4. listening - * 5. message - * 6. online - * 7. setup - */ - addListener(event: string, listener: Function): this; - addListener(event: "disconnect", listener: (worker: Worker) => void): this; - addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - addListener(event: "fork", listener: (worker: Worker) => void): this; - addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - addListener(event: "online", listener: (worker: Worker) => void): this; - addListener(event: "setup", listener: (settings: any) => void): this; - - emit(event: string, listener: Function): boolean; - emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - emit(event: "fork", listener: (worker: Worker) => void): boolean; - emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - emit(event: "online", listener: (worker: Worker) => void): boolean; - emit(event: "setup", listener: (settings: any) => void): boolean; - - on(event: string, listener: Function): this; - on(event: "disconnect", listener: (worker: Worker) => void): this; - on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - on(event: "fork", listener: (worker: Worker) => void): this; - on(event: "listening", listener: (worker: Worker, address: Address) => void): this; - on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - on(event: "online", listener: (worker: Worker) => void): this; - on(event: "setup", listener: (settings: any) => void): this; - - once(event: string, listener: Function): this; - once(event: "disconnect", listener: (worker: Worker) => void): this; - once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - once(event: "fork", listener: (worker: Worker) => void): this; - once(event: "listening", listener: (worker: Worker, address: Address) => void): this; - once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - once(event: "online", listener: (worker: Worker) => void): this; - once(event: "setup", listener: (settings: any) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "disconnect", listener: (worker: Worker) => void): this; - prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - prependListener(event: "fork", listener: (worker: Worker) => void): this; - prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependListener(event: "online", listener: (worker: Worker) => void): this; - prependListener(event: "setup", listener: (settings: any) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this; - prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - prependOnceListener(event: "fork", listener: (worker: Worker) => void): this; - prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependOnceListener(event: "online", listener: (worker: Worker) => void): this; - prependOnceListener(event: "setup", listener: (settings: any) => void): this; - - } - - export function disconnect(callback?: Function): void; - export function fork(env?: any): Worker; - export var isMaster: boolean; - export var isWorker: boolean; - // TODO: cluster.schedulingPolicy - export var settings: ClusterSettings; - export function setupMaster(settings?: ClusterSetupMasterSettings): void; - export var worker: Worker; - export var workers: { - [index: string]: Worker - }; - - /** - * events.EventEmitter - * 1. disconnect - * 2. exit - * 3. fork - * 4. listening - * 5. message - * 6. online - * 7. setup - */ - export function addListener(event: string, listener: Function): Cluster; - export function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function addListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function addListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function emit(event: string, listener: Function): boolean; - export function emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - export function emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - export function emit(event: "fork", listener: (worker: Worker) => void): boolean; - export function emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - export function emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - export function emit(event: "online", listener: (worker: Worker) => void): boolean; - export function emit(event: "setup", listener: (settings: any) => void): boolean; - - export function on(event: string, listener: Function): Cluster; - export function on(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function on(event: "fork", listener: (worker: Worker) => void): Cluster; - export function on(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function on(event: "online", listener: (worker: Worker) => void): Cluster; - export function on(event: "setup", listener: (settings: any) => void): Cluster; - - export function once(event: string, listener: Function): Cluster; - export function once(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function once(event: "fork", listener: (worker: Worker) => void): Cluster; - export function once(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function once(event: "online", listener: (worker: Worker) => void): Cluster; - export function once(event: "setup", listener: (settings: any) => void): Cluster; - - export function removeListener(event: string, listener: Function): Cluster; - export function removeAllListeners(event?: string): Cluster; - export function setMaxListeners(n: number): Cluster; - export function getMaxListeners(): number; - export function listeners(event: string): Function[]; - export function listenerCount(type: string): number; - - export function prependListener(event: string, listener: Function): Cluster; - export function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function prependListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function prependOnceListener(event: string, listener: Function): Cluster; - export function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function prependOnceListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function eventNames(): string[]; -} - -declare module "zlib" { - import * as stream from "stream"; - - export interface ZlibOptions { - flush?: number; // default: zlib.constants.Z_NO_FLUSH - finishFlush?: number; // default: zlib.constants.Z_FINISH - chunkSize?: number; // default: 16*1024 - windowBits?: number; - level?: number; // compression only - memLevel?: number; // compression only - strategy?: number; // compression only - dictionary?: any; // deflate/inflate only, empty dictionary by default - } - - export interface Gzip extends stream.Transform { } - export interface Gunzip extends stream.Transform { } - export interface Deflate extends stream.Transform { } - export interface Inflate extends stream.Transform { } - export interface DeflateRaw extends stream.Transform { } - export interface InflateRaw extends stream.Transform { } - export interface Unzip extends stream.Transform { } - - export function createGzip(options?: ZlibOptions): Gzip; - export function createGunzip(options?: ZlibOptions): Gunzip; - export function createDeflate(options?: ZlibOptions): Deflate; - export function createInflate(options?: ZlibOptions): Inflate; - export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; - export function createInflateRaw(options?: ZlibOptions): InflateRaw; - export function createUnzip(options?: ZlibOptions): Unzip; - - export function deflate(buf: Buffer | string, callback: (error: Error, result: Buffer) => void): void; - export function deflateSync(buf: Buffer | string, options?: ZlibOptions): Buffer; - export function deflateRaw(buf: Buffer | string, callback: (error: Error, result: Buffer) => void): void; - export function deflateRawSync(buf: Buffer | string, options?: ZlibOptions): Buffer; - export function gzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function gzipSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function gunzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function gunzipSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function inflate(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function inflateSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function inflateRaw(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function inflateRawSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function unzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function unzipSync(buf: Buffer, options?: ZlibOptions): Buffer; - - export namespace constants { - // Allowed flush values. - - export const Z_NO_FLUSH: number; - export const Z_PARTIAL_FLUSH: number; - export const Z_SYNC_FLUSH: number; - export const Z_FULL_FLUSH: number; - export const Z_FINISH: number; - export const Z_BLOCK: number; - export const Z_TREES: number; - - // Return codes for the compression/decompression functions. Negative values are errors, positive values are used for special but normal events. - - export const Z_OK: number; - export const Z_STREAM_END: number; - export const Z_NEED_DICT: number; - export const Z_ERRNO: number; - export const Z_STREAM_ERROR: number; - export const Z_DATA_ERROR: number; - export const Z_MEM_ERROR: number; - export const Z_BUF_ERROR: number; - export const Z_VERSION_ERROR: number; - - // Compression levels. - - export const Z_NO_COMPRESSION: number; - export const Z_BEST_SPEED: number; - export const Z_BEST_COMPRESSION: number; - export const Z_DEFAULT_COMPRESSION: number; - - // Compression strategy. - - export const Z_FILTERED: number; - export const Z_HUFFMAN_ONLY: number; - export const Z_RLE: number; - export const Z_FIXED: number; - export const Z_DEFAULT_STRATEGY: number; - } - - // Constants - export var Z_NO_FLUSH: number; - export var Z_PARTIAL_FLUSH: number; - export var Z_SYNC_FLUSH: number; - export var Z_FULL_FLUSH: number; - export var Z_FINISH: number; - export var Z_BLOCK: number; - export var Z_TREES: number; - export var Z_OK: number; - export var Z_STREAM_END: number; - export var Z_NEED_DICT: number; - export var Z_ERRNO: number; - export var Z_STREAM_ERROR: number; - export var Z_DATA_ERROR: number; - export var Z_MEM_ERROR: number; - export var Z_BUF_ERROR: number; - export var Z_VERSION_ERROR: number; - export var Z_NO_COMPRESSION: number; - export var Z_BEST_SPEED: number; - export var Z_BEST_COMPRESSION: number; - export var Z_DEFAULT_COMPRESSION: number; - export var Z_FILTERED: number; - export var Z_HUFFMAN_ONLY: number; - export var Z_RLE: number; - export var Z_FIXED: number; - export var Z_DEFAULT_STRATEGY: number; - export var Z_BINARY: number; - export var Z_TEXT: number; - export var Z_ASCII: number; - export var Z_UNKNOWN: number; - export var Z_DEFLATED: number; -} - -declare module "os" { - export interface CpuInfo { - model: string; - speed: number; - times: { - user: number; - nice: number; - sys: number; - idle: number; - irq: number; - }; - } - - export interface NetworkInterfaceInfo { - address: string; - netmask: string; - family: string; - mac: string; - internal: boolean; - } - - export function hostname(): string; - export function loadavg(): number[]; - export function uptime(): number; - export function freemem(): number; - export function totalmem(): number; - export function cpus(): CpuInfo[]; - export function type(): string; - export function release(): string; - export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] }; - export function homedir(): string; - export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: any, homedir: string } - export var constants: { - UV_UDP_REUSEADDR: number, - errno: { - SIGHUP: number; - SIGINT: number; - SIGQUIT: number; - SIGILL: number; - SIGTRAP: number; - SIGABRT: number; - SIGIOT: number; - SIGBUS: number; - SIGFPE: number; - SIGKILL: number; - SIGUSR1: number; - SIGSEGV: number; - SIGUSR2: number; - SIGPIPE: number; - SIGALRM: number; - SIGTERM: number; - SIGCHLD: number; - SIGSTKFLT: number; - SIGCONT: number; - SIGSTOP: number; - SIGTSTP: number; - SIGTTIN: number; - SIGTTOU: number; - SIGURG: number; - SIGXCPU: number; - SIGXFSZ: number; - SIGVTALRM: number; - SIGPROF: number; - SIGWINCH: number; - SIGIO: number; - SIGPOLL: number; - SIGPWR: number; - SIGSYS: number; - SIGUNUSED: number; - }, - signals: { - E2BIG: number; - EACCES: number; - EADDRINUSE: number; - EADDRNOTAVAIL: number; - EAFNOSUPPORT: number; - EAGAIN: number; - EALREADY: number; - EBADF: number; - EBADMSG: number; - EBUSY: number; - ECANCELED: number; - ECHILD: number; - ECONNABORTED: number; - ECONNREFUSED: number; - ECONNRESET: number; - EDEADLK: number; - EDESTADDRREQ: number; - EDOM: number; - EDQUOT: number; - EEXIST: number; - EFAULT: number; - EFBIG: number; - EHOSTUNREACH: number; - EIDRM: number; - EILSEQ: number; - EINPROGRESS: number; - EINTR: number; - EINVAL: number; - EIO: number; - EISCONN: number; - EISDIR: number; - ELOOP: number; - EMFILE: number; - EMLINK: number; - EMSGSIZE: number; - EMULTIHOP: number; - ENAMETOOLONG: number; - ENETDOWN: number; - ENETRESET: number; - ENETUNREACH: number; - ENFILE: number; - ENOBUFS: number; - ENODATA: number; - ENODEV: number; - ENOENT: number; - ENOEXEC: number; - ENOLCK: number; - ENOLINK: number; - ENOMEM: number; - ENOMSG: number; - ENOPROTOOPT: number; - ENOSPC: number; - ENOSR: number; - ENOSTR: number; - ENOSYS: number; - ENOTCONN: number; - ENOTDIR: number; - ENOTEMPTY: number; - ENOTSOCK: number; - ENOTSUP: number; - ENOTTY: number; - ENXIO: number; - EOPNOTSUPP: number; - EOVERFLOW: number; - EPERM: number; - EPIPE: number; - EPROTO: number; - EPROTONOSUPPORT: number; - EPROTOTYPE: number; - ERANGE: number; - EROFS: number; - ESPIPE: number; - ESRCH: number; - ESTALE: number; - ETIME: number; - ETIMEDOUT: number; - ETXTBSY: number; - EWOULDBLOCK: number; - EXDEV: number; - }, - }; - export function arch(): string; - export function platform(): NodeJS.Platform; - export function tmpdir(): string; - export var EOL: string; - export function endianness(): "BE" | "LE"; -} - -declare module "https" { - import * as tls from "tls"; - import * as events from "events"; - import * as http from "http"; - - export interface ServerOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - crl?: any; - ciphers?: string; - honorCipherOrder?: boolean; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: any; - SNICallback?: (servername: string, cb: (err: Error, ctx: tls.SecureContext) => any) => any; - } - - export interface RequestOptions extends http.RequestOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - ciphers?: string; - rejectUnauthorized?: boolean; - secureProtocol?: string; - } - - export interface Agent extends http.Agent { } - - export interface AgentOptions extends http.AgentOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - ciphers?: string; - rejectUnauthorized?: boolean; - secureProtocol?: string; - maxCachedSessions?: number; - } - - export var Agent: { - new (options?: AgentOptions): Agent; - }; - export interface Server extends tls.Server { } - export function createServer(options: ServerOptions, requestListener?: Function): Server; - export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; - export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; - export var globalAgent: Agent; -} - -declare module "punycode" { - export function decode(string: string): string; - export function encode(string: string): string; - export function toUnicode(domain: string): string; - export function toASCII(domain: string): string; - export var ucs2: ucs2; - interface ucs2 { - decode(string: string): number[]; - encode(codePoints: number[]): string; - } - export var version: any; -} - -declare module "repl" { - import * as stream from "stream"; - import * as readline from "readline"; - - export interface ReplOptions { - prompt?: string; - input?: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - terminal?: boolean; - eval?: Function; - useColors?: boolean; - useGlobal?: boolean; - ignoreUndefined?: boolean; - writer?: Function; - completer?: Function; - replMode?: any; - breakEvalOnSigint?: any; - } - - export interface REPLServer extends readline.ReadLine { - defineCommand(keyword: string, cmd: Function | { help: string, action: Function }): void; - displayPrompt(preserveCursor?: boolean): void; - - /** - * events.EventEmitter - * 1. exit - * 2. reset - **/ - - addListener(event: string, listener: Function): this; - addListener(event: "exit", listener: () => void): this; - addListener(event: "reset", listener: Function): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "exit"): boolean; - emit(event: "reset", context: any): boolean; - - on(event: string, listener: Function): this; - on(event: "exit", listener: () => void): this; - on(event: "reset", listener: Function): this; - - once(event: string, listener: Function): this; - once(event: "exit", listener: () => void): this; - once(event: "reset", listener: Function): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "exit", listener: () => void): this; - prependListener(event: "reset", listener: Function): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "exit", listener: () => void): this; - prependOnceListener(event: "reset", listener: Function): this; - } - - export function start(options: ReplOptions): REPLServer; -} - -declare module "readline" { - import * as events from "events"; - import * as stream from "stream"; - - export interface Key { - sequence?: string; - name?: string; - ctrl?: boolean; - meta?: boolean; - shift?: boolean; - } - - export interface ReadLine extends events.EventEmitter { - setPrompt(prompt: string): void; - prompt(preserveCursor?: boolean): void; - question(query: string, callback: (answer: string) => void): void; - pause(): ReadLine; - resume(): ReadLine; - close(): void; - write(data: string | Buffer, key?: Key): void; - - /** - * events.EventEmitter - * 1. close - * 2. line - * 3. pause - * 4. resume - * 5. SIGCONT - * 6. SIGINT - * 7. SIGTSTP - **/ - - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "line", listener: (input: any) => void): this; - addListener(event: "pause", listener: () => void): this; - addListener(event: "resume", listener: () => void): this; - addListener(event: "SIGCONT", listener: () => void): this; - addListener(event: "SIGINT", listener: () => void): this; - addListener(event: "SIGTSTP", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "line", input: any): boolean; - emit(event: "pause"): boolean; - emit(event: "resume"): boolean; - emit(event: "SIGCONT"): boolean; - emit(event: "SIGINT"): boolean; - emit(event: "SIGTSTP"): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "line", listener: (input: any) => void): this; - on(event: "pause", listener: () => void): this; - on(event: "resume", listener: () => void): this; - on(event: "SIGCONT", listener: () => void): this; - on(event: "SIGINT", listener: () => void): this; - on(event: "SIGTSTP", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "line", listener: (input: any) => void): this; - once(event: "pause", listener: () => void): this; - once(event: "resume", listener: () => void): this; - once(event: "SIGCONT", listener: () => void): this; - once(event: "SIGINT", listener: () => void): this; - once(event: "SIGTSTP", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "line", listener: (input: any) => void): this; - prependListener(event: "pause", listener: () => void): this; - prependListener(event: "resume", listener: () => void): this; - prependListener(event: "SIGCONT", listener: () => void): this; - prependListener(event: "SIGINT", listener: () => void): this; - prependListener(event: "SIGTSTP", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "line", listener: (input: any) => void): this; - prependOnceListener(event: "pause", listener: () => void): this; - prependOnceListener(event: "resume", listener: () => void): this; - prependOnceListener(event: "SIGCONT", listener: () => void): this; - prependOnceListener(event: "SIGINT", listener: () => void): this; - prependOnceListener(event: "SIGTSTP", listener: () => void): this; - } - - type Completer = (line: string) => CompleterResult; - type AsyncCompleter = (line: string, callback: (err: any, result: CompleterResult) => void) => any; - - export type CompleterResult = [string[], string]; - - export interface ReadLineOptions { - input: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - completer?: Completer | AsyncCompleter; - terminal?: boolean; - historySize?: number; - } - - export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): ReadLine; - export function createInterface(options: ReadLineOptions): ReadLine; - - export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; - export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void; - export function clearLine(stream: NodeJS.WritableStream, dir: number): void; - export function clearScreenDown(stream: NodeJS.WritableStream): void; -} - -declare module "vm" { - export interface Context { } - export interface ScriptOptions { - filename?: string; - lineOffset?: number; - columnOffset?: number; - displayErrors?: boolean; - timeout?: number; - cachedData?: Buffer; - produceCachedData?: boolean; - } - export interface RunningScriptOptions { - filename?: string; - lineOffset?: number; - columnOffset?: number; - displayErrors?: boolean; - timeout?: number; - } - export class Script { - constructor(code: string, options?: ScriptOptions); - runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any; - runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any; - runInThisContext(options?: RunningScriptOptions): any; - } - export function createContext(sandbox?: Context): Context; - export function isContext(sandbox: Context): boolean; - export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions): any; - export function runInDebugContext(code: string): any; - export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions): any; - export function runInThisContext(code: string, options?: RunningScriptOptions): any; -} - -declare module "child_process" { - import * as events from "events"; - import * as stream from "stream"; - import * as net from "net"; - - export interface ChildProcess extends events.EventEmitter { - stdin: stream.Writable; - stdout: stream.Readable; - stderr: stream.Readable; - stdio: [stream.Writable, stream.Readable, stream.Readable]; - pid: number; - kill(signal?: string): void; - send(message: any, sendHandle?: any): boolean; - connected: boolean; - disconnect(): void; - unref(): void; - ref(): void; - - /** - * events.EventEmitter - * 1. close - * 2. disconnet - * 3. error - * 4. exit - * 5. message - **/ - - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: (code: number, signal: string) => void): this; - addListener(event: "disconnet", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "exit", listener: (code: number, signal: string) => void): this; - addListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close", code: number, signal: string): boolean; - emit(event: "disconnet"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "exit", code: number, signal: string): boolean; - emit(event: "message", message: any, sendHandle: net.Socket | net.Server): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: (code: number, signal: string) => void): this; - on(event: "disconnet", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "exit", listener: (code: number, signal: string) => void): this; - on(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: (code: number, signal: string) => void): this; - once(event: "disconnet", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "exit", listener: (code: number, signal: string) => void): this; - once(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: (code: number, signal: string) => void): this; - prependListener(event: "disconnet", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "disconnet", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - } - - export interface SpawnOptions { - cwd?: string; - env?: any; - stdio?: any; - detached?: boolean; - uid?: number; - gid?: number; - shell?: boolean | string; - } - export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess; - - export interface ExecOptions { - cwd?: string; - env?: any; - shell?: string; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - uid?: number; - gid?: number; - } - export interface ExecOptionsWithStringEncoding extends ExecOptions { - encoding: BufferEncoding; - } - export interface ExecOptionsWithBufferEncoding extends ExecOptions { - encoding: string; // specify `null`. - } - export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function exec(command: string, options: ExecOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - // usage. child_process.exec("tsc", {encoding: null as string}, (err, stdout, stderr) => {}); - export function exec(command: string, options: ExecOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - - export interface ExecFileOptions { - cwd?: string; - env?: any; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - uid?: number; - gid?: number; - } - export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions { - encoding: BufferEncoding; - } - export interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions { - encoding: string; // specify `null`. - } - export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - // usage. child_process.execFile("file.sh", {encoding: null as string}, (err, stdout, stderr) => {}); - export function execFile(file: string, options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function execFile(file: string, options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, args?: string[], callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - // usage. child_process.execFile("file.sh", ["foo"], {encoding: null as string}, (err, stdout, stderr) => {}); - export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function execFile(file: string, args?: string[], options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - - export interface ForkOptions { - cwd?: string; - env?: any; - execPath?: string; - execArgv?: string[]; - silent?: boolean; - uid?: number; - gid?: number; - } - export function fork(modulePath: string, args?: string[], options?: ForkOptions): ChildProcess; - - export interface SpawnSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - shell?: boolean | string; - } - export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions { - encoding: BufferEncoding; - } - export interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions { - encoding: string; // specify `null`. - } - export interface SpawnSyncReturns { - pid: number; - output: string[]; - stdout: T; - stderr: T; - status: number; - signal: string; - error: Error; - } - export function spawnSync(command: string): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions): SpawnSyncReturns; - - export interface ExecSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - shell?: string; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - } - export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions { - encoding: BufferEncoding; - } - export interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions { - encoding: string; // specify `null`. - } - export function execSync(command: string): Buffer; - export function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string; - export function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer; - export function execSync(command: string, options?: ExecSyncOptions): Buffer; - - export interface ExecFileSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - } - export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions { - encoding: BufferEncoding; - } - export interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions { - encoding: string; // specify `null`. - } - export function execFileSync(command: string): Buffer; - export function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string; - export function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer; - export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithStringEncoding): string; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithBufferEncoding): Buffer; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions): Buffer; -} - -declare module "url" { - export interface Url { - href?: string; - protocol?: string; - auth?: string; - hostname?: string; - port?: string; - host?: string; - pathname?: string; - search?: string; - query?: string | any; - slashes?: boolean; - hash?: string; - path?: string; - } - - export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url; - export function format(url: Url): string; - export function resolve(from: string, to: string): string; - - export class URLSearchParams implements Iterable { - constructor(init?: URLSearchParams | string); - append(name: string, value: string): void; - delete(name: string): void; - entries(): Iterator; - forEach(callback: (value: string, name: string) => void): void; - get(name: string): string | null; - getAll(name: string): string[]; - has(name: string): boolean; - keys(): Iterator; - set(name: string, value: string): void; - sort(): void; - toString(): string; - values(): Iterator; - [Symbol.iterator](): Iterator; - } - - export class URL { - constructor(input: string, base?: string | URL); - hash: string; - host: string; - hostname: string; - href: string; - readonly origin: string; - password: string; - pathname: string; - port: string; - protocol: string; - search: string; - readonly searchParams: URLSearchParams; - username: string; - toString(): string; - toJSON(): string; - } -} - -declare module "dns" { - export interface MxRecord { - exchange: string, - priority: number - } - - export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) => void): string; - export function lookup(domain: string, callback: (err: Error, address: string, family: number) => void): string; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveMx(domain: string, callback: (err: Error, addresses: MxRecord[]) => void): string[]; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[][]) => void): string[][]; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[]; - export function setServers(servers: string[]): void; - - //Error codes - export var NODATA: string; - export var FORMERR: string; - export var SERVFAIL: string; - export var NOTFOUND: string; - export var NOTIMP: string; - export var REFUSED: string; - export var BADQUERY: string; - export var BADNAME: string; - export var BADFAMILY: string; - export var BADRESP: string; - export var CONNREFUSED: string; - export var TIMEOUT: string; - export var EOF: string; - export var FILE: string; - export var NOMEM: string; - export var DESTRUCTION: string; - export var BADSTR: string; - export var BADFLAGS: string; - export var NONAME: string; - export var BADHINTS: string; - export var NOTINITIALIZED: string; - export var LOADIPHLPAPI: string; - export var ADDRGETNETWORKPARAMS: string; - export var CANCELLED: string; -} - -declare module "net" { - import * as stream from "stream"; - import * as events from "events"; - - export interface Socket extends stream.Duplex { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - connect(port: number, host?: string, connectionListener?: Function): void; - connect(path: string, connectionListener?: Function): void; - bufferSize: number; - setEncoding(encoding?: string): this; - write(data: any, encoding?: string, callback?: Function): void; - destroy(err?: any): void; - pause(): this; - resume(): this; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setKeepAlive(enable?: boolean, initialDelay?: number): void; - address(): { port: number; family: string; address: string; }; - unref(): void; - ref(): void; - - remoteAddress: string; - remoteFamily: string; - remotePort: number; - localAddress: string; - localPort: number; - bytesRead: number; - bytesWritten: number; - destroyed: boolean; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - - /** - * events.EventEmitter - * 1. close - * 2. connect - * 3. data - * 4. drain - * 5. end - * 6. error - * 7. lookup - * 8. timeout - */ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: (had_error: boolean) => void): this; - addListener(event: "connect", listener: () => void): this; - addListener(event: "data", listener: (data: Buffer) => void): this; - addListener(event: "drain", listener: () => void): this; - addListener(event: "end", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - addListener(event: "timeout", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close", had_error: boolean): boolean; - emit(event: "connect"): boolean; - emit(event: "data", data: Buffer): boolean; - emit(event: "drain"): boolean; - emit(event: "end"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean; - emit(event: "timeout"): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: (had_error: boolean) => void): this; - on(event: "connect", listener: () => void): this; - on(event: "data", listener: (data: Buffer) => void): this; - on(event: "drain", listener: () => void): this; - on(event: "end", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - on(event: "timeout", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: (had_error: boolean) => void): this; - once(event: "connect", listener: () => void): this; - once(event: "data", listener: (data: Buffer) => void): this; - once(event: "drain", listener: () => void): this; - once(event: "end", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - once(event: "timeout", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: (had_error: boolean) => void): this; - prependListener(event: "connect", listener: () => void): this; - prependListener(event: "data", listener: (data: Buffer) => void): this; - prependListener(event: "drain", listener: () => void): this; - prependListener(event: "end", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - prependListener(event: "timeout", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: (had_error: boolean) => void): this; - prependOnceListener(event: "connect", listener: () => void): this; - prependOnceListener(event: "data", listener: (data: Buffer) => void): this; - prependOnceListener(event: "drain", listener: () => void): this; - prependOnceListener(event: "end", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - prependOnceListener(event: "timeout", listener: () => void): this; - } - - export var Socket: { - new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket; - }; - - export interface ListenOptions { - port?: number; - host?: string; - backlog?: number; - path?: string; - exclusive?: boolean; - } - - export interface Server extends events.EventEmitter { - listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): Server; - listen(port: number, hostname?: string, listeningListener?: Function): Server; - listen(port: number, backlog?: number, listeningListener?: Function): Server; - listen(port: number, listeningListener?: Function): Server; - listen(path: string, backlog?: number, listeningListener?: Function): Server; - listen(path: string, listeningListener?: Function): Server; - listen(options: ListenOptions, listeningListener?: Function): Server; - listen(handle: any, backlog?: number, listeningListener?: Function): Server; - listen(handle: any, listeningListener?: Function): Server; - close(callback?: Function): Server; - address(): { port: number; family: string; address: string; }; - getConnections(cb: (error: Error, count: number) => void): void; - ref(): Server; - unref(): Server; - maxConnections: number; - connections: number; - listening: boolean; - - /** - * events.EventEmitter - * 1. close - * 2. connection - * 3. error - * 4. listening - */ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "connection", listener: (socket: Socket) => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "listening", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "connection", socket: Socket): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "listening"): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "connection", listener: (socket: Socket) => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "listening", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "connection", listener: (socket: Socket) => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "listening", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "connection", listener: (socket: Socket) => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "listening", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "listening", listener: () => void): this; - } - export function createServer(connectionListener?: (socket: Socket) => void): Server; - export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) => void): Server; - export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function connect(port: number, host?: string, connectionListener?: Function): Socket; - export function connect(path: string, connectionListener?: Function): Socket; - export function createConnection(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; - export function createConnection(path: string, connectionListener?: Function): Socket; - export function isIP(input: string): number; - export function isIPv4(input: string): boolean; - export function isIPv6(input: string): boolean; -} - -declare module "dgram" { - import * as events from "events"; - - interface RemoteInfo { - address: string; - family: string; - port: number; - } - - interface AddressInfo { - address: string; - family: string; - port: number; - } - - interface BindOptions { - port: number; - address?: string; - exclusive?: boolean; - } - - interface SocketOptions { - type: "udp4" | "udp6"; - reuseAddr?: boolean; - } - - export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; - export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; - - export interface Socket extends events.EventEmitter { - send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - bind(port?: number, address?: string, callback?: () => void): void; - bind(options: BindOptions, callback?: Function): void; - close(callback?: () => void): void; - address(): AddressInfo; - setBroadcast(flag: boolean): void; - setTTL(ttl: number): void; - setMulticastTTL(ttl: number): void; - setMulticastLoopback(flag: boolean): void; - addMembership(multicastAddress: string, multicastInterface?: string): void; - dropMembership(multicastAddress: string, multicastInterface?: string): void; - ref(): this; - unref(): this; - - /** - * events.EventEmitter - * 1. close - * 2. error - * 3. listening - * 4. message - **/ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "listening", listener: () => void): this; - addListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "listening"): boolean; - emit(event: "message", msg: Buffer, rinfo: AddressInfo): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "listening", listener: () => void): this; - on(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "listening", listener: () => void): this; - once(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "listening", listener: () => void): this; - prependListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "listening", listener: () => void): this; - prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - } -} - -declare module "fs" { - import * as stream from "stream"; - import * as events from "events"; - - interface Stats { - isFile(): boolean; - isDirectory(): boolean; - isBlockDevice(): boolean; - isCharacterDevice(): boolean; - isSymbolicLink(): boolean; - isFIFO(): boolean; - isSocket(): boolean; - dev: number; - ino: number; - mode: number; - nlink: number; - uid: number; - gid: number; - rdev: number; - size: number; - blksize: number; - blocks: number; - atime: Date; - mtime: Date; - ctime: Date; - birthtime: Date; - } - - interface FSWatcher extends events.EventEmitter { - close(): void; - - /** - * events.EventEmitter - * 1. change - * 2. error - */ - addListener(event: string, listener: Function): this; - addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - addListener(event: "error", listener: (code: number, signal: string) => void): this; - - on(event: string, listener: Function): this; - on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - on(event: "error", listener: (code: number, signal: string) => void): this; - - once(event: string, listener: Function): this; - once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - once(event: "error", listener: (code: number, signal: string) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - prependListener(event: "error", listener: (code: number, signal: string) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; - } - - export interface ReadStream extends stream.Readable { - close(): void; - destroy(): void; - bytesRead: number; - path: string | Buffer; - - /** - * events.EventEmitter - * 1. open - * 2. close - */ - addListener(event: string, listener: Function): this; - addListener(event: "open", listener: (fd: number) => void): this; - addListener(event: "close", listener: () => void): this; - - on(event: string, listener: Function): this; - on(event: "open", listener: (fd: number) => void): this; - on(event: "close", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "open", listener: (fd: number) => void): this; - once(event: "close", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "open", listener: (fd: number) => void): this; - prependListener(event: "close", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "open", listener: (fd: number) => void): this; - prependOnceListener(event: "close", listener: () => void): this; - } - - export interface WriteStream extends stream.Writable { - close(): void; - bytesWritten: number; - path: string | Buffer; - - /** - * events.EventEmitter - * 1. open - * 2. close - */ - addListener(event: string, listener: Function): this; - addListener(event: "open", listener: (fd: number) => void): this; - addListener(event: "close", listener: () => void): this; - - on(event: string, listener: Function): this; - on(event: "open", listener: (fd: number) => void): this; - on(event: "close", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "open", listener: (fd: number) => void): this; - once(event: "close", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "open", listener: (fd: number) => void): this; - prependListener(event: "close", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "open", listener: (fd: number) => void): this; - prependOnceListener(event: "close", listener: () => void): this; - } - - /** - * Asynchronous rename. - * @param oldPath - * @param newPath - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Synchronous rename - * @param oldPath - * @param newPath - */ - export function renameSync(oldPath: string, newPath: string): void; - export function truncate(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncate(path: string | Buffer, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncateSync(path: string | Buffer, len?: number): void; - export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncateSync(fd: number, len?: number): void; - export function chown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chownSync(path: string | Buffer, uid: number, gid: number): void; - export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchownSync(fd: number, uid: number, gid: number): void; - export function lchown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchownSync(path: string | Buffer, uid: number, gid: number): void; - export function chmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmodSync(path: string | Buffer, mode: number): void; - export function chmodSync(path: string | Buffer, mode: string): void; - export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmodSync(fd: number, mode: number): void; - export function fchmodSync(fd: number, mode: string): void; - export function lchmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmodSync(path: string | Buffer, mode: number): void; - export function lchmodSync(path: string | Buffer, mode: string): void; - export function stat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function lstat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function statSync(path: string | Buffer): Stats; - export function lstatSync(path: string | Buffer): Stats; - export function fstatSync(fd: number): Stats; - export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function linkSync(srcpath: string | Buffer, dstpath: string | Buffer): void; - export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function symlinkSync(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): void; - export function readlink(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; - export function readlinkSync(path: string | Buffer): string; - export function realpath(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; - export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; - export function realpathSync(path: string | Buffer, cache?: { [path: string]: string }): string; - /** - * Asynchronous unlink - deletes the file specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function unlink(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Synchronous unlink - deletes the file specified in {path} - * - * @param path - */ - export function unlinkSync(path: string | Buffer): void; - /** - * Asynchronous rmdir - removes the directory specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rmdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Synchronous rmdir - removes the directory specified in {path} - * - * @param path - */ - export function rmdirSync(path: string | Buffer): void; - /** - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string | Buffer, mode?: number): void; - /** - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string | Buffer, mode?: string): void; - /** - * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. - * - * @param prefix - * @param callback The created folder path is passed as a string to the callback's second parameter. - */ - export function mkdtemp(prefix: string, callback?: (err: NodeJS.ErrnoException, folder: string) => void): void; - /** - * Synchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. - * - * @param prefix - * @returns Returns the created folder path. - */ - export function mkdtempSync(prefix: string): string; - export function readdir(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; - export function readdirSync(path: string | Buffer): string[]; - export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function closeSync(fd: number): void; - export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; - export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; - export function openSync(path: string | Buffer, flags: string | number, mode?: number): number; - export function utimes(path: string | Buffer, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimesSync(path: string | Buffer, atime: number, mtime: number): void; - export function utimesSync(path: string | Buffer, atime: Date, mtime: Date): void; - export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimesSync(fd: number, atime: number, mtime: number): void; - export function futimesSync(fd: number, atime: Date, mtime: Date): void; - export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position?: number): number; - export function writeSync(fd: number, data: any, position?: number, enconding?: string): number; - export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; - export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - /** - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /** - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /** - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /** - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /** - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - */ - export function readFileSync(filename: string, encoding: string): string; - /** - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; - /** - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; - export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; - export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; - export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; - export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; - export function watch(filename: string, encoding: string, listener?: (event: string, filename: string | Buffer) => any): FSWatcher; - export function watch(filename: string, options: { persistent?: boolean; recursive?: boolean; encoding?: string }, listener?: (event: string, filename: string | Buffer) => any): FSWatcher; - export function exists(path: string | Buffer, callback?: (exists: boolean) => void): void; - export function existsSync(path: string | Buffer): boolean; - - export namespace constants { - // File Access Constants - - /** Constant for fs.access(). File is visible to the calling process. */ - export const F_OK: number; - - /** Constant for fs.access(). File can be read by the calling process. */ - export const R_OK: number; - - /** Constant for fs.access(). File can be written by the calling process. */ - export const W_OK: number; - - /** Constant for fs.access(). File can be executed by the calling process. */ - export const X_OK: number; - - // File Open Constants - - /** Constant for fs.open(). Flag indicating to open a file for read-only access. */ - export const O_RDONLY: number; - - /** Constant for fs.open(). Flag indicating to open a file for write-only access. */ - export const O_WRONLY: number; - - /** Constant for fs.open(). Flag indicating to open a file for read-write access. */ - export const O_RDWR: number; - - /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */ - export const O_CREAT: number; - - /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */ - export const O_EXCL: number; - - /** Constant for fs.open(). Flag indicating that if path identifies a terminal device, opening the path shall not cause that terminal to become the controlling terminal for the process (if the process does not already have one). */ - export const O_NOCTTY: number; - - /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */ - export const O_TRUNC: number; - - /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */ - export const O_APPEND: number; - - /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */ - export const O_DIRECTORY: number; - - /** Constant for fs.open(). Flag indicating reading accesses to the file system will no longer result in an update to the atime information associated with the file. This flag is available on Linux operating systems only. */ - export const O_NOATIME: number; - - /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */ - export const O_NOFOLLOW: number; - - /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */ - export const O_SYNC: number; - - /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */ - export const O_SYMLINK: number; - - /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */ - export const O_DIRECT: number; - - /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */ - export const O_NONBLOCK: number; - - // File Type Constants - - /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */ - export const S_IFMT: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */ - export const S_IFREG: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */ - export const S_IFDIR: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */ - export const S_IFCHR: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */ - export const S_IFBLK: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */ - export const S_IFIFO: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */ - export const S_IFLNK: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */ - export const S_IFSOCK: number; - - // File Mode Constants - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */ - export const S_IRWXU: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */ - export const S_IRUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */ - export const S_IWUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */ - export const S_IXUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */ - export const S_IRWXG: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */ - export const S_IRGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */ - export const S_IWGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */ - export const S_IXGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */ - export const S_IRWXO: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */ - export const S_IROTH: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */ - export const S_IWOTH: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */ - export const S_IXOTH: number; - } - - /** Tests a user's permissions for the file specified by path. */ - export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; - export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; - /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */ - export function accessSync(path: string | Buffer, mode?: number): void; - export function createReadStream(path: string | Buffer, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - start?: number; - end?: number; - }): ReadStream; - export function createWriteStream(path: string | Buffer, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - start?: number; - }): WriteStream; - export function fdatasync(fd: number, callback: Function): void; - export function fdatasyncSync(fd: number): void; -} - -declare module "path" { - - /** - * A parsed path object generated by path.parse() or consumed by path.format(). - */ - export interface ParsedPath { - /** - * The root of the path such as '/' or 'c:\' - */ - root: string; - /** - * The full directory path such as '/home/user/dir' or 'c:\path\dir' - */ - dir: string; - /** - * The file name including extension (if any) such as 'index.html' - */ - base: string; - /** - * The file extension (if any) such as '.html' - */ - ext: string; - /** - * The file name without extension (if any) such as 'index' - */ - name: string; - } - - /** - * Normalize a string path, reducing '..' and '.' parts. - * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. - * - * @param p string path to normalize. - */ - export function normalize(p: string): string; - /** - * Join all arguments together and normalize the resulting path. - * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. - * - * @param paths paths to join. - */ - export function join(...paths: string[]): string; - /** - * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. - * - * Starting from leftmost {from} paramter, resolves {to} to an absolute path. - * - * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. - * - * @param pathSegments string paths to join. Non-string arguments are ignored. - */ - export function resolve(...pathSegments: any[]): string; - /** - * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. - * - * @param path path to test. - */ - export function isAbsolute(path: string): boolean; - /** - * Solve the relative path from {from} to {to}. - * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. - * - * @param from - * @param to - */ - export function relative(from: string, to: string): string; - /** - * Return the directory name of a path. Similar to the Unix dirname command. - * - * @param p the path to evaluate. - */ - export function dirname(p: string): string; - /** - * Return the last portion of a path. Similar to the Unix basename command. - * Often used to extract the file name from a fully qualified path. - * - * @param p the path to evaluate. - * @param ext optionally, an extension to remove from the result. - */ - export function basename(p: string, ext?: string): string; - /** - * Return the extension of the path, from the last '.' to end of string in the last portion of the path. - * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string - * - * @param p the path to evaluate. - */ - export function extname(p: string): string; - /** - * The platform-specific file separator. '\\' or '/'. - */ - export var sep: string; - /** - * The platform-specific file delimiter. ';' or ':'. - */ - export var delimiter: string; - /** - * Returns an object from a path string - the opposite of format(). - * - * @param pathString path to evaluate. - */ - export function parse(pathString: string): ParsedPath; - /** - * Returns a path string from an object - the opposite of parse(). - * - * @param pathString path to evaluate. - */ - export function format(pathObject: ParsedPath): string; - - export module posix { - export function normalize(p: string): string; - export function join(...paths: any[]): string; - export function resolve(...pathSegments: any[]): string; - export function isAbsolute(p: string): boolean; - export function relative(from: string, to: string): string; - export function dirname(p: string): string; - export function basename(p: string, ext?: string): string; - export function extname(p: string): string; - export var sep: string; - export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } - - export module win32 { - export function normalize(p: string): string; - export function join(...paths: any[]): string; - export function resolve(...pathSegments: any[]): string; - export function isAbsolute(p: string): boolean; - export function relative(from: string, to: string): string; - export function dirname(p: string): string; - export function basename(p: string, ext?: string): string; - export function extname(p: string): string; - export var sep: string; - export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } -} - -declare module "string_decoder" { - export interface NodeStringDecoder { - write(buffer: Buffer): string; - end(buffer?: Buffer): string; - } - export var StringDecoder: { - new (encoding?: string): NodeStringDecoder; - }; -} - -declare module "tls" { - import * as crypto from "crypto"; - import * as net from "net"; - import * as stream from "stream"; - - var CLIENT_RENEG_LIMIT: number; - var CLIENT_RENEG_WINDOW: number; - - export interface Certificate { - /** - * Country code. - */ - C: string; - /** - * Street. - */ - ST: string; - /** - * Locality. - */ - L: string; - /** - * Organization. - */ - O: string; - /** - * Organizational unit. - */ - OU: string; - /** - * Common name. - */ - CN: string; - } - - export interface CipherNameAndProtocol { - /** - * The cipher name. - */ - name: string; - /** - * SSL/TLS protocol version. - */ - version: string; - } - - export class TLSSocket extends net.Socket { - /** - * Construct a new tls.TLSSocket object from an existing TCP socket. - */ - constructor(socket:net.Socket, options?: { - /** - * An optional TLS context object from tls.createSecureContext() - */ - secureContext?: SecureContext, - /** - * If true the TLS socket will be instantiated in server-mode. - * Defaults to false. - */ - isServer?: boolean, - /** - * An optional net.Server instance. - */ - server?: net.Server, - /** - * If true the server will request a certificate from clients that - * connect and attempt to verify that certificate. Defaults to - * false. - */ - requestCert?: boolean, - /** - * If true the server will reject any connection which is not - * authorized with the list of supplied CAs. This option only has an - * effect if requestCert is true. Defaults to false. - */ - rejectUnauthorized?: boolean, - /** - * An array of strings or a Buffer naming possible NPN protocols. - * (Protocols should be ordered by their priority.) - */ - NPNProtocols?: string[] | Buffer, - /** - * An array of strings or a Buffer naming possible ALPN protocols. - * (Protocols should be ordered by their priority.) When the server - * receives both NPN and ALPN extensions from the client, ALPN takes - * precedence over NPN and the server does not send an NPN extension - * to the client. - */ - ALPNProtocols?: string[] | Buffer, - /** - * SNICallback(servername, cb) A function that will be - * called if the client supports SNI TLS extension. Two arguments - * will be passed when called: servername and cb. SNICallback should - * invoke cb(null, ctx), where ctx is a SecureContext instance. - * (tls.createSecureContext(...) can be used to get a proper - * SecureContext.) If SNICallback wasn't provided the default callback - * with high-level API will be used (see below). - */ - SNICallback?: Function, - /** - * An optional Buffer instance containing a TLS session. - */ - session?: Buffer, - /** - * If true, specifies that the OCSP status request extension will be - * added to the client hello and an 'OCSPResponse' event will be - * emitted on the socket before establishing a secure communication - */ - requestOCSP?: boolean - }); - /** - * Returns the bound address, the address family name and port of the underlying socket as reported by - * the operating system. - * @returns {any} - An object with three properties, e.g. { port: 12346, family: 'IPv4', address: '127.0.0.1' }. - */ - address(): { port: number; family: string; address: string }; - /** - * A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false. - */ - authorized: boolean; - /** - * The reason why the peer's certificate has not been verified. - * This property becomes available only when tlsSocket.authorized === false. - */ - authorizationError: Error; - /** - * Static boolean value, always true. - * May be used to distinguish TLS sockets from regular ones. - */ - encrypted: boolean; - /** - * Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection. - * @returns {CipherNameAndProtocol} - Returns an object representing the cipher name - * and the SSL/TLS protocol version of the current connection. - */ - getCipher(): CipherNameAndProtocol; - /** - * Returns an object representing the peer's certificate. - * The returned object has some properties corresponding to the field of the certificate. - * If detailed argument is true the full chain with issuer property will be returned, - * if false only the top certificate without issuer property. - * If the peer does not provide a certificate, it returns null or an empty object. - * @param {boolean} detailed - If true; the full chain with issuer property will be returned. - * @returns {any} - An object representing the peer's certificate. - */ - getPeerCertificate(detailed?: boolean): { - subject: Certificate; - issuerInfo: Certificate; - issuer: Certificate; - raw: any; - valid_from: string; - valid_to: string; - fingerprint: string; - serialNumber: string; - }; - /** - * Could be used to speed up handshake establishment when reconnecting to the server. - * @returns {any} - ASN.1 encoded TLS session or undefined if none was negotiated. - */ - getSession(): any; - /** - * NOTE: Works only with client TLS sockets. - * Useful only for debugging, for session reuse provide session option to tls.connect(). - * @returns {any} - TLS session ticket or undefined if none was negotiated. - */ - getTLSTicket(): any; - /** - * The string representation of the local IP address. - */ - localAddress: string; - /** - * The numeric representation of the local port. - */ - localPort: number; - /** - * The string representation of the remote IP address. - * For example, '74.125.127.100' or '2001:4860:a005::68'. - */ - remoteAddress: string; - /** - * The string representation of the remote IP family. 'IPv4' or 'IPv6'. - */ - remoteFamily: string; - /** - * The numeric representation of the remote port. For example, 443. - */ - remotePort: number; - /** - * Initiate TLS renegotiation process. - * - * NOTE: Can be used to request peer's certificate after the secure connection has been established. - * ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout. - * @param {TlsOptions} options - The options may contain the following fields: rejectUnauthorized, - * requestCert (See tls.createServer() for details). - * @param {Function} callback - callback(err) will be executed with null as err, once the renegotiation - * is successfully completed. - */ - renegotiate(options: TlsOptions, callback: (err: Error) => any): any; - /** - * Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512). - * Smaller fragment size decreases buffering latency on the client: large fragments are buffered by - * the TLS layer until the entire fragment is received and its integrity is verified; - * large fragments can span multiple roundtrips, and their processing can be delayed due to packet - * loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead, - * which may decrease overall server throughput. - * @param {number} size - TLS fragment size (default and maximum value is: 16384, minimum is: 512). - * @returns {boolean} - Returns true on success, false otherwise. - */ - setMaxSendFragment(size: number): boolean; - - /** - * events.EventEmitter - * 1. OCSPResponse - * 2. secureConnect - **/ - addListener(event: string, listener: Function): this; - addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - addListener(event: "secureConnect", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "OCSPResponse", response: Buffer): boolean; - emit(event: "secureConnect"): boolean; - - on(event: string, listener: Function): this; - on(event: "OCSPResponse", listener: (response: Buffer) => void): this; - on(event: "secureConnect", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "OCSPResponse", listener: (response: Buffer) => void): this; - once(event: "secureConnect", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - prependListener(event: "secureConnect", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - prependOnceListener(event: "secureConnect", listener: () => void): this; - } - - export interface TlsOptions { - host?: string; - port?: number; - pfx?: string | Buffer[]; - key?: string | string[] | Buffer | any[]; - passphrase?: string; - cert?: string | string[] | Buffer | Buffer[]; - ca?: string | string[] | Buffer | Buffer[]; - crl?: string | string[]; - ciphers?: string; - honorCipherOrder?: boolean; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: string[] | Buffer; - SNICallback?: (servername: string, cb: (err: Error, ctx: SecureContext) => any) => any; - ecdhCurve?: string; - dhparam?: string | Buffer; - handshakeTimeout?: number; - ALPNProtocols?: string[] | Buffer; - sessionTimeout?: number; - ticketKeys?: any; - sessionIdContext?: string; - secureProtocol?: string; - } - - export interface ConnectionOptions { - host?: string; - port?: number; - socket?: net.Socket; - pfx?: string | Buffer - key?: string | string[] | Buffer | Buffer[]; - passphrase?: string; - cert?: string | string[] | Buffer | Buffer[]; - ca?: string | Buffer | (string | Buffer)[]; - rejectUnauthorized?: boolean; - NPNProtocols?: (string | Buffer)[]; - servername?: string; - path?: string; - ALPNProtocols?: (string | Buffer)[]; - checkServerIdentity?: (servername: string, cert: string | Buffer | (string | Buffer)[]) => any; - secureProtocol?: string; - secureContext?: Object; - session?: Buffer; - minDHSize?: number; - } - - export interface Server extends net.Server { - close(callback?: Function): Server; - address(): { port: number; family: string; address: string; }; - addContext(hostName: string, credentials: { - key: string; - cert: string; - ca: string; - }): void; - maxConnections: number; - connections: number; - - /** - * events.EventEmitter - * 1. tlsClientError - * 2. newSession - * 3. OCSPRequest - * 4. resumeSession - * 5. secureConnection - **/ - addListener(event: string, listener: Function): this; - addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - addListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - addListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean; - emit(event: "newSession", sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void): boolean; - emit(event: "OCSPRequest", certificate: Buffer, issuer: Buffer, callback: Function): boolean; - emit(event: "resumeSession", sessionId: any, callback: (err: Error, sessionData: any) => void): boolean; - emit(event: "secureConnection", tlsSocket: TLSSocket): boolean; - - on(event: string, listener: Function): this; - on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - on(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - on(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - once(event: string, listener: Function): this; - once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - once(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - once(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - prependListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - prependListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - prependOnceListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - prependOnceListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - } - - export interface ClearTextStream extends stream.Duplex { - authorized: boolean; - authorizationError: Error; - getPeerCertificate(): any; - getCipher: { - name: string; - version: string; - }; - address: { - port: number; - family: string; - address: string; - }; - remoteAddress: string; - remotePort: number; - } - - export interface SecurePair { - encrypted: any; - cleartext: any; - } - - export interface SecureContextOptions { - pfx?: string | Buffer; - key?: string | Buffer; - passphrase?: string; - cert?: string | Buffer; - ca?: string | Buffer; - crl?: string | string[] - ciphers?: string; - honorCipherOrder?: boolean; - } - - export interface SecureContext { - context: any; - } - - export function createServer(options: TlsOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server; - export function connect(options: ConnectionOptions, secureConnectionListener?: () => void): TLSSocket; - export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket; - export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket; - export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; - export function createSecureContext(details: SecureContextOptions): SecureContext; -} - -declare module "crypto" { - export interface Certificate { - exportChallenge(spkac: string | Buffer): Buffer; - exportPublicKey(spkac: string | Buffer): Buffer; - verifySpkac(spkac: Buffer): boolean; - } - export var Certificate: { - new (): Certificate; - (): Certificate; - } - - export var fips: boolean; - - export interface CredentialDetails { - pfx: string; - key: string; - passphrase: string; - cert: string; - ca: string | string[]; - crl: string | string[]; - ciphers: string; - } - export interface Credentials { context?: any; } - export function createCredentials(details: CredentialDetails): Credentials; - export function createHash(algorithm: string): Hash; - export function createHmac(algorithm: string, key: string | Buffer): Hmac; - - type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1"; - type HexBase64Latin1Encoding = "latin1" | "hex" | "base64"; - type Utf8AsciiBinaryEncoding = "utf8" | "ascii" | "binary"; - type HexBase64BinaryEncoding = "binary" | "base64" | "hex"; - type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid"; - - export interface Hash extends NodeJS.ReadWriteStream { - update(data: string | Buffer): Hash; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hash; - digest(): Buffer; - digest(encoding: HexBase64Latin1Encoding): string; - } - export interface Hmac extends NodeJS.ReadWriteStream { - update(data: string | Buffer): Hmac; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hmac; - digest(): Buffer; - digest(encoding: HexBase64Latin1Encoding): string; - } - export function createCipher(algorithm: string, password: any): Cipher; - export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; - export interface Cipher extends NodeJS.ReadWriteStream { - update(data: Buffer): Buffer; - update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: HexBase64BinaryEncoding): string; - update(data: string, input_encoding: Utf8AsciiBinaryEncoding, output_encoding: HexBase64BinaryEncoding): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding?: boolean): void; - getAuthTag(): Buffer; - setAAD(buffer: Buffer): void; - } - export function createDecipher(algorithm: string, password: any): Decipher; - export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; - export interface Decipher extends NodeJS.ReadWriteStream { - update(data: Buffer): Buffer; - update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: Utf8AsciiBinaryEncoding): string; - update(data: string, input_encoding: HexBase64BinaryEncoding, output_encoding: Utf8AsciiBinaryEncoding): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding?: boolean): void; - setAuthTag(tag: Buffer): void; - setAAD(buffer: Buffer): void; - } - export function createSign(algorithm: string): Signer; - export interface Signer extends NodeJS.WritableStream { - update(data: string | Buffer): Signer; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Signer; - sign(private_key: string | { key: string; passphrase: string }): Buffer; - sign(private_key: string | { key: string; passphrase: string }, output_format: HexBase64Latin1Encoding): string; - } - export function createVerify(algorith: string): Verify; - export interface Verify extends NodeJS.WritableStream { - update(data: string | Buffer): Verify; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Verify; - verify(object: string, signature: Buffer): boolean; - verify(object: string, signature: string, signature_format: HexBase64Latin1Encoding): boolean; - } - export function createDiffieHellman(prime_length: number, generator?: number): DiffieHellman; - export function createDiffieHellman(prime: Buffer): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Buffer): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman; - export interface DiffieHellman { - generateKeys(): Buffer; - generateKeys(encoding: HexBase64Latin1Encoding): string; - computeSecret(other_public_key: Buffer): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string; - getPrime(): Buffer; - getPrime(encoding: HexBase64Latin1Encoding): string; - getGenerator(): Buffer; - getGenerator(encoding: HexBase64Latin1Encoding): string; - getPublicKey(): Buffer; - getPublicKey(encoding: HexBase64Latin1Encoding): string; - getPrivateKey(): Buffer; - getPrivateKey(encoding: HexBase64Latin1Encoding): string; - setPublicKey(public_key: Buffer): void; - setPublicKey(public_key: string, encoding: string): void; - setPrivateKey(private_key: Buffer): void; - setPrivateKey(private_key: string, encoding: string): void; - verifyError: number; - } - export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string): Buffer; - export function randomBytes(size: number): Buffer; - export function randomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; - export function pseudoRandomBytes(size: number): Buffer; - export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; - export interface RsaPublicKey { - key: string; - padding?: number; - } - export interface RsaPrivateKey { - key: string; - passphrase?: string, - padding?: number; - } - export function publicEncrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer - export function privateDecrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer - export function privateEncrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer - export function publicDecrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer - export function getCiphers(): string[]; - export function getCurves(): string[]; - export function getHashes(): string[]; - export interface ECDH { - generateKeys(): Buffer; - generateKeys(encoding: HexBase64Latin1Encoding): string; - generateKeys(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string; - computeSecret(other_public_key: Buffer): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string; - getPrivateKey(): Buffer; - getPrivateKey(encoding: HexBase64Latin1Encoding): string; - getPublicKey(): Buffer; - getPublicKey(encoding: HexBase64Latin1Encoding): string; - getPublicKey(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string; - setPrivateKey(private_key: Buffer): void; - setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void; - } - export function createECDH(curve_name: string): ECDH; - export function timingSafeEqual(a: Buffer, b: Buffer): boolean; - export var DEFAULT_ENCODING: string; -} - -declare module "stream" { - import * as events from "events"; - - class internal extends events.EventEmitter { - pipe(destination: T, options?: { end?: boolean; }): T; - } - namespace internal { - - export class Stream extends internal { } - - export interface ReadableOptions { - highWaterMark?: number; - encoding?: string; - objectMode?: boolean; - read?: (size?: number) => any; - } - - export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { - readable: boolean; - constructor(opts?: ReadableOptions); - protected _read(size: number): void; - read(size?: number): any; - setEncoding(encoding: string): this; - pause(): this; - resume(): this; - isPaused(): boolean; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): this; - unshift(chunk: any): void; - wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; - push(chunk: any, encoding?: string): boolean; - - /** - * Event emitter - * The defined events on documents including: - * 1. close - * 2. data - * 3. end - * 4. readable - * 5. error - **/ - addListener(event: string, listener: Function): this; - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "data", listener: (chunk: Buffer | string) => void): this; - addListener(event: "end", listener: () => void): this; - addListener(event: "readable", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "data", chunk: Buffer | string): boolean; - emit(event: "end"): boolean; - emit(event: "readable"): boolean; - emit(event: "error", err: Error): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "data", listener: (chunk: Buffer | string) => void): this; - on(event: "end", listener: () => void): this; - on(event: "readable", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "data", listener: (chunk: Buffer | string) => void): this; - once(event: "end", listener: () => void): this; - once(event: "readable", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; - prependListener(event: "end", listener: () => void): this; - prependListener(event: "readable", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; - prependOnceListener(event: "end", listener: () => void): this; - prependOnceListener(event: "readable", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - - removeListener(event: string, listener: Function): this; - removeListener(event: "close", listener: () => void): this; - removeListener(event: "data", listener: (chunk: Buffer | string) => void): this; - removeListener(event: "end", listener: () => void): this; - removeListener(event: "readable", listener: () => void): this; - removeListener(event: "error", listener: (err: Error) => void): this; - } - - export interface WritableOptions { - highWaterMark?: number; - decodeStrings?: boolean; - objectMode?: boolean; - write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; - } - - export class Writable extends events.EventEmitter implements NodeJS.WritableStream { - writable: boolean; - constructor(opts?: WritableOptions); - protected _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - - /** - * Event emitter - * The defined events on documents including: - * 1. close - * 2. drain - * 3. error - * 4. finish - * 5. pipe - * 6. unpipe - **/ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "drain", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "finish", listener: () => void): this; - addListener(event: "pipe", listener: (src: Readable) => void): this; - addListener(event: "unpipe", listener: (src: Readable) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "drain", chunk: Buffer | string): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "finish"): boolean; - emit(event: "pipe", src: Readable): boolean; - emit(event: "unpipe", src: Readable): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "drain", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "finish", listener: () => void): this; - on(event: "pipe", listener: (src: Readable) => void): this; - on(event: "unpipe", listener: (src: Readable) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "drain", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "finish", listener: () => void): this; - once(event: "pipe", listener: (src: Readable) => void): this; - once(event: "unpipe", listener: (src: Readable) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "drain", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "finish", listener: () => void): this; - prependListener(event: "pipe", listener: (src: Readable) => void): this; - prependListener(event: "unpipe", listener: (src: Readable) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "drain", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "finish", listener: () => void): this; - prependOnceListener(event: "pipe", listener: (src: Readable) => void): this; - prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this; - - removeListener(event: string, listener: Function): this; - removeListener(event: "close", listener: () => void): this; - removeListener(event: "drain", listener: () => void): this; - removeListener(event: "error", listener: (err: Error) => void): this; - removeListener(event: "finish", listener: () => void): this; - removeListener(event: "pipe", listener: (src: Readable) => void): this; - removeListener(event: "unpipe", listener: (src: Readable) => void): this; - } - - export interface DuplexOptions extends ReadableOptions, WritableOptions { - allowHalfOpen?: boolean; - readableObjectMode?: boolean; - writableObjectMode?: boolean; - } - - // Note: Duplex extends both Readable and Writable. - export class Duplex extends Readable implements NodeJS.ReadWriteStream { - // Readable - pause(): this; - resume(): this; - // Writeable - writable: boolean; - constructor(opts?: DuplexOptions); - protected _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export interface TransformOptions extends DuplexOptions { - transform?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - flush?: (callback: Function) => any; - } - - // Note: Transform lacks the _read and _write methods of Readable/Writable. - export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { - readable: boolean; - writable: boolean; - constructor(opts?: TransformOptions); - protected _transform(chunk: any, encoding: string, callback: Function): void; - protected _flush(callback: Function): void; - read(size?: number): any; - setEncoding(encoding: string): this; - pause(): this; - resume(): this; - isPaused(): boolean; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): this; - unshift(chunk: any): void; - wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; - push(chunk: any, encoding?: string): boolean; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export class PassThrough extends Transform { } - } - - export = internal; -} - -declare module "util" { - export interface InspectOptions { - showHidden?: boolean; - depth?: number; - colors?: boolean; - customInspect?: boolean; - } - - export function format(format: any, ...param: any[]): string; - export function debug(string: string): void; - export function error(...param: any[]): void; - export function puts(...param: any[]): void; - export function print(...param: any[]): void; - export function log(string: string): void; - export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; - export function inspect(object: any, options: InspectOptions): string; - export function isArray(object: any): boolean; - export function isRegExp(object: any): boolean; - export function isDate(object: any): boolean; - export function isError(object: any): boolean; - export function inherits(constructor: any, superConstructor: any): void; - export function debuglog(key: string): (msg: string, ...param: any[]) => void; - export function isBoolean(object: any): boolean; - export function isBuffer(object: any): boolean; - export function isFunction(object: any): boolean; - export function isNull(object: any): boolean; - export function isNullOrUndefined(object: any): boolean; - export function isNumber(object: any): boolean; - export function isObject(object: any): boolean; - export function isPrimitive(object: any): boolean; - export function isString(object: any): boolean; - export function isSymbol(object: any): boolean; - export function isUndefined(object: any): boolean; - export function deprecate(fn: Function, message: string): Function; -} - -declare module "assert" { - function internal(value: any, message?: string): void; - namespace internal { - export class AssertionError implements Error { - name: string; - message: string; - actual: any; - expected: any; - operator: string; - generatedMessage: boolean; - - constructor(options?: { - message?: string; actual?: any; expected?: any; - operator?: string; stackStartFunction?: Function - }); - } - - export function fail(actual: any, expected: any, message: string, operator: string): void; - export function ok(value: any, message?: string): void; - export function equal(actual: any, expected: any, message?: string): void; - export function notEqual(actual: any, expected: any, message?: string): void; - export function deepEqual(actual: any, expected: any, message?: string): void; - export function notDeepEqual(acutal: any, expected: any, message?: string): void; - export function strictEqual(actual: any, expected: any, message?: string): void; - export function notStrictEqual(actual: any, expected: any, message?: string): void; - export function deepStrictEqual(actual: any, expected: any, message?: string): void; - export function notDeepStrictEqual(actual: any, expected: any, message?: string): void; - export var throws: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export var doesNotThrow: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export function ifError(value: any): void; - } - - export = internal; -} - -declare module "tty" { - import * as net from "net"; - - export function isatty(fd: number): boolean; - export interface ReadStream extends net.Socket { - isRaw: boolean; - setRawMode(mode: boolean): void; - isTTY: boolean; - } - export interface WriteStream extends net.Socket { - columns: number; - rows: number; - isTTY: boolean; - } -} - -declare module "domain" { - import * as events from "events"; - - export class Domain extends events.EventEmitter implements NodeJS.Domain { - run(fn: Function): void; - add(emitter: events.EventEmitter): void; - remove(emitter: events.EventEmitter): void; - bind(cb: (err: Error, data: any) => any): any; - intercept(cb: (data: any) => any): any; - dispose(): void; - members: any[]; - enter(): void; - exit(): void; - } - - export function create(): Domain; -} - -declare module "constants" { - export var E2BIG: number; - export var EACCES: number; - export var EADDRINUSE: number; - export var EADDRNOTAVAIL: number; - export var EAFNOSUPPORT: number; - export var EAGAIN: number; - export var EALREADY: number; - export var EBADF: number; - export var EBADMSG: number; - export var EBUSY: number; - export var ECANCELED: number; - export var ECHILD: number; - export var ECONNABORTED: number; - export var ECONNREFUSED: number; - export var ECONNRESET: number; - export var EDEADLK: number; - export var EDESTADDRREQ: number; - export var EDOM: number; - export var EEXIST: number; - export var EFAULT: number; - export var EFBIG: number; - export var EHOSTUNREACH: number; - export var EIDRM: number; - export var EILSEQ: number; - export var EINPROGRESS: number; - export var EINTR: number; - export var EINVAL: number; - export var EIO: number; - export var EISCONN: number; - export var EISDIR: number; - export var ELOOP: number; - export var EMFILE: number; - export var EMLINK: number; - export var EMSGSIZE: number; - export var ENAMETOOLONG: number; - export var ENETDOWN: number; - export var ENETRESET: number; - export var ENETUNREACH: number; - export var ENFILE: number; - export var ENOBUFS: number; - export var ENODATA: number; - export var ENODEV: number; - export var ENOENT: number; - export var ENOEXEC: number; - export var ENOLCK: number; - export var ENOLINK: number; - export var ENOMEM: number; - export var ENOMSG: number; - export var ENOPROTOOPT: number; - export var ENOSPC: number; - export var ENOSR: number; - export var ENOSTR: number; - export var ENOSYS: number; - export var ENOTCONN: number; - export var ENOTDIR: number; - export var ENOTEMPTY: number; - export var ENOTSOCK: number; - export var ENOTSUP: number; - export var ENOTTY: number; - export var ENXIO: number; - export var EOPNOTSUPP: number; - export var EOVERFLOW: number; - export var EPERM: number; - export var EPIPE: number; - export var EPROTO: number; - export var EPROTONOSUPPORT: number; - export var EPROTOTYPE: number; - export var ERANGE: number; - export var EROFS: number; - export var ESPIPE: number; - export var ESRCH: number; - export var ETIME: number; - export var ETIMEDOUT: number; - export var ETXTBSY: number; - export var EWOULDBLOCK: number; - export var EXDEV: number; - export var WSAEINTR: number; - export var WSAEBADF: number; - export var WSAEACCES: number; - export var WSAEFAULT: number; - export var WSAEINVAL: number; - export var WSAEMFILE: number; - export var WSAEWOULDBLOCK: number; - export var WSAEINPROGRESS: number; - export var WSAEALREADY: number; - export var WSAENOTSOCK: number; - export var WSAEDESTADDRREQ: number; - export var WSAEMSGSIZE: number; - export var WSAEPROTOTYPE: number; - export var WSAENOPROTOOPT: number; - export var WSAEPROTONOSUPPORT: number; - export var WSAESOCKTNOSUPPORT: number; - export var WSAEOPNOTSUPP: number; - export var WSAEPFNOSUPPORT: number; - export var WSAEAFNOSUPPORT: number; - export var WSAEADDRINUSE: number; - export var WSAEADDRNOTAVAIL: number; - export var WSAENETDOWN: number; - export var WSAENETUNREACH: number; - export var WSAENETRESET: number; - export var WSAECONNABORTED: number; - export var WSAECONNRESET: number; - export var WSAENOBUFS: number; - export var WSAEISCONN: number; - export var WSAENOTCONN: number; - export var WSAESHUTDOWN: number; - export var WSAETOOMANYREFS: number; - export var WSAETIMEDOUT: number; - export var WSAECONNREFUSED: number; - export var WSAELOOP: number; - export var WSAENAMETOOLONG: number; - export var WSAEHOSTDOWN: number; - export var WSAEHOSTUNREACH: number; - export var WSAENOTEMPTY: number; - export var WSAEPROCLIM: number; - export var WSAEUSERS: number; - export var WSAEDQUOT: number; - export var WSAESTALE: number; - export var WSAEREMOTE: number; - export var WSASYSNOTREADY: number; - export var WSAVERNOTSUPPORTED: number; - export var WSANOTINITIALISED: number; - export var WSAEDISCON: number; - export var WSAENOMORE: number; - export var WSAECANCELLED: number; - export var WSAEINVALIDPROCTABLE: number; - export var WSAEINVALIDPROVIDER: number; - export var WSAEPROVIDERFAILEDINIT: number; - export var WSASYSCALLFAILURE: number; - export var WSASERVICE_NOT_FOUND: number; - export var WSATYPE_NOT_FOUND: number; - export var WSA_E_NO_MORE: number; - export var WSA_E_CANCELLED: number; - export var WSAEREFUSED: number; - export var SIGHUP: number; - export var SIGINT: number; - export var SIGILL: number; - export var SIGABRT: number; - export var SIGFPE: number; - export var SIGKILL: number; - export var SIGSEGV: number; - export var SIGTERM: number; - export var SIGBREAK: number; - export var SIGWINCH: number; - export var SSL_OP_ALL: number; - export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; - export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; - export var SSL_OP_CISCO_ANYCONNECT: number; - export var SSL_OP_COOKIE_EXCHANGE: number; - export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; - export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; - export var SSL_OP_EPHEMERAL_RSA: number; - export var SSL_OP_LEGACY_SERVER_CONNECT: number; - export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; - export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; - export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; - export var SSL_OP_NETSCAPE_CA_DN_BUG: number; - export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; - export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NO_COMPRESSION: number; - export var SSL_OP_NO_QUERY_MTU: number; - export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; - export var SSL_OP_NO_SSLv2: number; - export var SSL_OP_NO_SSLv3: number; - export var SSL_OP_NO_TICKET: number; - export var SSL_OP_NO_TLSv1: number; - export var SSL_OP_NO_TLSv1_1: number; - export var SSL_OP_NO_TLSv1_2: number; - export var SSL_OP_PKCS1_CHECK_1: number; - export var SSL_OP_PKCS1_CHECK_2: number; - export var SSL_OP_SINGLE_DH_USE: number; - export var SSL_OP_SINGLE_ECDH_USE: number; - export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; - export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; - export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; - export var SSL_OP_TLS_D5_BUG: number; - export var SSL_OP_TLS_ROLLBACK_BUG: number; - export var ENGINE_METHOD_DSA: number; - export var ENGINE_METHOD_DH: number; - export var ENGINE_METHOD_RAND: number; - export var ENGINE_METHOD_ECDH: number; - export var ENGINE_METHOD_ECDSA: number; - export var ENGINE_METHOD_CIPHERS: number; - export var ENGINE_METHOD_DIGESTS: number; - export var ENGINE_METHOD_STORE: number; - export var ENGINE_METHOD_PKEY_METHS: number; - export var ENGINE_METHOD_PKEY_ASN1_METHS: number; - export var ENGINE_METHOD_ALL: number; - export var ENGINE_METHOD_NONE: number; - export var DH_CHECK_P_NOT_SAFE_PRIME: number; - export var DH_CHECK_P_NOT_PRIME: number; - export var DH_UNABLE_TO_CHECK_GENERATOR: number; - export var DH_NOT_SUITABLE_GENERATOR: number; - export var NPN_ENABLED: number; - export var RSA_PKCS1_PADDING: number; - export var RSA_SSLV23_PADDING: number; - export var RSA_NO_PADDING: number; - export var RSA_PKCS1_OAEP_PADDING: number; - export var RSA_X931_PADDING: number; - export var RSA_PKCS1_PSS_PADDING: number; - export var POINT_CONVERSION_COMPRESSED: number; - export var POINT_CONVERSION_UNCOMPRESSED: number; - export var POINT_CONVERSION_HYBRID: number; - export var O_RDONLY: number; - export var O_WRONLY: number; - export var O_RDWR: number; - export var S_IFMT: number; - export var S_IFREG: number; - export var S_IFDIR: number; - export var S_IFCHR: number; - export var S_IFBLK: number; - export var S_IFIFO: number; - export var S_IFSOCK: number; - export var S_IRWXU: number; - export var S_IRUSR: number; - export var S_IWUSR: number; - export var S_IXUSR: number; - export var S_IRWXG: number; - export var S_IRGRP: number; - export var S_IWGRP: number; - export var S_IXGRP: number; - export var S_IRWXO: number; - export var S_IROTH: number; - export var S_IWOTH: number; - export var S_IXOTH: number; - export var S_IFLNK: number; - export var O_CREAT: number; - export var O_EXCL: number; - export var O_NOCTTY: number; - export var O_DIRECTORY: number; - export var O_NOATIME: number; - export var O_NOFOLLOW: number; - export var O_SYNC: number; - export var O_SYMLINK: number; - export var O_DIRECT: number; - export var O_NONBLOCK: number; - export var O_TRUNC: number; - export var O_APPEND: number; - export var F_OK: number; - export var R_OK: number; - export var W_OK: number; - export var X_OK: number; - export var UV_UDP_REUSEADDR: number; - export var SIGQUIT: number; - export var SIGTRAP: number; - export var SIGIOT: number; - export var SIGBUS: number; - export var SIGUSR1: number; - export var SIGUSR2: number; - export var SIGPIPE: number; - export var SIGALRM: number; - export var SIGCHLD: number; - export var SIGSTKFLT: number; - export var SIGCONT: number; - export var SIGSTOP: number; - export var SIGTSTP: number; - export var SIGTTIN: number; - export var SIGTTOU: number; - export var SIGURG: number; - export var SIGXCPU: number; - export var SIGXFSZ: number; - export var SIGVTALRM: number; - export var SIGPROF: number; - export var SIGIO: number; - export var SIGPOLL: number; - export var SIGPWR: number; - export var SIGSYS: number; - export var SIGUNUSED: number; - export var defaultCoreCipherList: string; - export var defaultCipherList: string; - export var ENGINE_METHOD_RSA: number; - export var ALPN_ENABLED: number; -} - -declare module "process" { - export = process; -} - -declare module "v8" { - interface HeapSpaceInfo { - space_name: string; - space_size: number; - space_used_size: number; - space_available_size: number; - physical_space_size: number; - } - - //** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */ - type DoesZapCodeSpaceFlag = 0 | 1; - - interface HeapInfo { - total_heap_size: number; - total_heap_size_executable: number; - total_physical_size: number; - total_available_size: number; - used_heap_size: number; - heap_size_limit: number; - malloced_memory: number; - peak_malloced_memory: number; - does_zap_garbage: DoesZapCodeSpaceFlag; - } - - export function getHeapStatistics(): HeapInfo; - export function getHeapSpaceStatistics(): HeapSpaceInfo[]; - export function setFlagsFromString(flags: string): void; -} - -declare module "timers" { - export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; - export function clearTimeout(timeoutId: NodeJS.Timer): void; - export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; - export function clearInterval(intervalId: NodeJS.Timer): void; - export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; - export function clearImmediate(immediateId: any): void; -} - -declare module "console" { - export = console; -} - -/** - * _debugger module is not documented. - * Source code is at https://github.com/nodejs/node/blob/master/lib/_debugger.js - */ -declare module "_debugger" { - export interface Packet { - raw: string; - headers: string[]; - body: Message; - } - - export interface Message { - seq: number; - type: string; - } - - export interface RequestInfo { - command: string; - arguments: any; - } - - export interface Request extends Message, RequestInfo { - } - - export interface Event extends Message { - event: string; - body?: any; - } - - export interface Response extends Message { - request_seq: number; - success: boolean; - /** Contains error message if success === false. */ - message?: string; - /** Contains message body if success === true. */ - body?: any; - } - - export interface BreakpointMessageBody { - type: string; - target: number; - line: number; - } - - export class Protocol { - res: Packet; - state: string; - execute(data: string): void; - serialize(rq: Request): string; - onResponse: (pkt: Packet) => void; - } - - export var NO_FRAME: number; - export var port: number; - - export interface ScriptDesc { - name: string; - id: number; - isNative?: boolean; - handle?: number; - type: string; - lineOffset?: number; - columnOffset?: number; - lineCount?: number; - } - - export interface Breakpoint { - id: number; - scriptId: number; - script: ScriptDesc; - line: number; - condition?: string; - scriptReq?: string; - } - - export interface RequestHandler { - (err: boolean, body: Message, res: Packet): void; - request_seq?: number; - } - - export interface ResponseBodyHandler { - (err: boolean, body?: any): void; - request_seq?: number; - } - - export interface ExceptionInfo { - text: string; - } - - export interface BreakResponse { - script?: ScriptDesc; - exception?: ExceptionInfo; - sourceLine: number; - sourceLineText: string; - sourceColumn: number; - } - - export function SourceInfo(body: BreakResponse): string; - - export interface ClientInstance extends NodeJS.EventEmitter { - protocol: Protocol; - scripts: ScriptDesc[]; - handles: ScriptDesc[]; - breakpoints: Breakpoint[]; - currentSourceLine: number; - currentSourceColumn: number; - currentSourceLineText: string; - currentFrame: number; - currentScript: string; - - connect(port: number, host: string): void; - req(req: any, cb: RequestHandler): void; - reqFrameEval(code: string, frame: number, cb: RequestHandler): void; - mirrorObject(obj: any, depth: number, cb: ResponseBodyHandler): void; - setBreakpoint(rq: BreakpointMessageBody, cb: RequestHandler): void; - clearBreakpoint(rq: Request, cb: RequestHandler): void; - listbreakpoints(cb: RequestHandler): void; - reqSource(from: number, to: number, cb: RequestHandler): void; - reqScripts(cb: any): void; - reqContinue(cb: RequestHandler): void; - } - - export var Client : { - new (): ClientInstance - } -} diff --git a/demo/scripts/oppogame/oppogame.ts b/demo/scripts/oppogame/oppogame.ts deleted file mode 100644 index f6142d37..00000000 --- a/demo/scripts/oppogame/oppogame.ts +++ /dev/null @@ -1,90 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; -export class OppogamePlugin implements plugins.Command { - - constructor() { - } - async onFile(file: plugins.File) { - if (file.extname == '.js') { - const filename = file.origin; - if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { - return null; - } - if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { - let content = file.contents.toString(); - content += `;window.egret = egret;`; - content = content.replace(/definition = __global/, "definition = window"); - file.contents = new Buffer(content); - } - else { - let content = file.contents.toString(); - if ( - filename == "libs/modules/res/res.js" || - filename == 'libs/modules/res/res.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.js' - ) { - content += ";window.RES = RES;" - } - if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') { - content += ";window.eui = eui;" - if(filename == "libs/modules/eui/eui.js"){ - content = content.replace("function getRepeatedIds","window.getRepeatedIds=function getRepeatedIds"); - content = content.replace("function getIds","window.getIds=function getIds"); - content = content.replace("function toXMLString","window.toXMLString=function toXMLString"); - content = content.replace("function checkDeclarations","window.checkDeclarations=function checkDeclarations"); - content = content.replace("function getPropertyStr","window.getPropertyStr=function getPropertyStr"); - } - } - if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') { - content += ';window.dragonBones = dragonBones'; - } - content = "var egret = window.egret;" + content; - - if (filename == 'main.js') { - content += "\n;window.Main = Main;" - } - file.contents = new Buffer(content); - } - } - return file; - } - async onFinish(pluginContext: plugins.CommandContext) { - //同步 index.html 配置到 game.js - const gameJSPath = path.join(pluginContext.outputDir, "main.js"); - if(!fs.existsSync(gameJSPath)) { - console.log(`${gameJSPath}不存在,请先使用 Launcher 发布Oppo快游戏`); - return; - } - let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" }); - const projectConfig = pluginContext.buildConfig.projectConfig; - const optionStr = - `entryClassName: ${projectConfig.entryClassName},\n\t\t` + - `orientation: ${projectConfig.orientation},\n\t\t` + - `frameRate: ${projectConfig.frameRate},\n\t\t` + - `scaleMode: ${projectConfig.scaleMode},\n\t\t` + - `contentWidth: ${projectConfig.contentWidth},\n\t\t` + - `contentHeight: ${projectConfig.contentHeight},\n\t\t` + - `showFPS: ${projectConfig.showFPS},\n\t\t` + - `fpsStyles: ${projectConfig.fpsStyles},\n\t\t` + - `showLog: ${projectConfig.showLog},\n\t\t` + - `maxTouches: ${projectConfig.maxTouches},`; - const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/; - const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----'; - gameJSContent = gameJSContent.replace(reg, replaceStr); - fs.writeFileSync(gameJSPath, gameJSContent); - - //修改横竖屏 - let orientation; - if (projectConfig.orientation == '"landscape"') { - orientation = "landscape"; - } - else { - orientation = "portrait"; - } - const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); - let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); - gameJSONContent.orientation = orientation; - fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); - } -} diff --git a/demo/scripts/qgame/qgame.ts b/demo/scripts/qgame/qgame.ts deleted file mode 100644 index 949226d6..00000000 --- a/demo/scripts/qgame/qgame.ts +++ /dev/null @@ -1,90 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; -export class MiqgamePlugin implements plugins.Command { - - constructor() { - } - async onFile(file: plugins.File) { - if (file.extname == '.js') { - const filename = file.origin; - if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { - return null; - } - if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { - let content = file.contents.toString(); - content += `;window.egret = egret;`; - content = content.replace(/definition = __global/, "definition = window"); - file.contents = new Buffer(content); - } - else { - let content = file.contents.toString(); - if ( - filename == "libs/modules/res/res.js" || - filename == 'libs/modules/res/res.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.js' - ) { - content += ";window.RES = RES;" - } - if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') { - content += ";window.eui = eui;" - if(filename == "libs/modules/eui/eui.js"){ - content = content.replace("function getRepeatedIds","window.getRepeatedIds=function getRepeatedIds"); - content = content.replace("function getIds","window.getIds=function getIds"); - content = content.replace("function toXMLString","window.toXMLString=function toXMLString"); - content = content.replace("function checkDeclarations","window.checkDeclarations=function checkDeclarations"); - content = content.replace("function getPropertyStr","window.getPropertyStr=function getPropertyStr"); - } - } - if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') { - content += ';window.dragonBones = dragonBones'; - } - content = "var egret = window.egret;" + content; - - if (filename == 'main.js') { - content += "\n;window.Main = Main;" - } - file.contents = new Buffer(content); - } - } - return file; - } - async onFinish(pluginContext: plugins.CommandContext) { - //同步 index.html 配置到 game.js - const gameJSPath = path.join(pluginContext.outputDir, "main.js"); - if(!fs.existsSync(gameJSPath)) { - console.log(`${gameJSPath}不存在,请先使用 Launcher 发布小米快游戏`); - return; - } - let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" }); - const projectConfig = pluginContext.buildConfig.projectConfig; - const optionStr = - `entryClassName: ${projectConfig.entryClassName},\n\t\t` + - `orientation: ${projectConfig.orientation},\n\t\t` + - `frameRate: ${projectConfig.frameRate},\n\t\t` + - `scaleMode: ${projectConfig.scaleMode},\n\t\t` + - `contentWidth: ${projectConfig.contentWidth},\n\t\t` + - `contentHeight: ${projectConfig.contentHeight},\n\t\t` + - `showFPS: ${projectConfig.showFPS},\n\t\t` + - `fpsStyles: ${projectConfig.fpsStyles},\n\t\t` + - `showLog: ${projectConfig.showLog},\n\t\t` + - `maxTouches: ${projectConfig.maxTouches},`; - const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/; - const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----'; - gameJSContent = gameJSContent.replace(reg, replaceStr); - fs.writeFileSync(gameJSPath, gameJSContent); - - //修改横竖屏 - let orientation; - if (projectConfig.orientation == '"landscape"') { - orientation = "landscape"; - } - else { - orientation = "portrait"; - } - const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); - let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); - gameJSONContent.orientation = orientation; - fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); - } -} diff --git a/demo/scripts/qqgame/qqgame.ts b/demo/scripts/qqgame/qqgame.ts deleted file mode 100644 index caf27acf..00000000 --- a/demo/scripts/qqgame/qqgame.ts +++ /dev/null @@ -1,118 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; -export class QQgamePlugin implements plugins.Command { - private useQQPlugin: boolean = false; - private pliginList: string[] = [];//qq engine plugin - constructor(useQQPlugin: boolean, pliginList: string[]) { - this.useQQPlugin = useQQPlugin - this.pliginList = pliginList - } - - async onFile(file: plugins.File) { - if (file.extname == '.js') { - - const filename = file.origin; - if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { - return null; - } - if (this.useQQPlugin) { - const basename = file.basename - //QQ 小游戏引擎插件,支持下列官方库 - let engineJS = ['assetsmanager', 'dragonBones', 'egret', 'game', 'eui', 'socket', 'tween'] - for (let i in engineJS) { - let jsName = engineJS[i] - if (basename == jsName + ".js" || basename == jsName + ".min.js") { - this.pliginList.push(`requirePlugin("egret-library/${jsName}.min.js")`); - return null - } - } - } - if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { - let content = file.contents.toString(); - content += `;window.egret = egret;`; - content = content.replace(/definition = __global/, "definition = window"); - file.contents = new Buffer(content); - } - else { - let content = file.contents.toString(); - if ( - filename == "libs/modules/res/res.js" || - filename == 'libs/modules/res/res.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.js' - ) { - content += ";window.RES = RES;" - } - if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') { - content += ";window.eui = eui;" - } - if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') { - content += ';window.dragonBones = dragonBones'; - } - content = "var egret = window.egret;" + content; - if (filename == 'main.js') { - content += "\n;window.Main = Main;" - } - file.contents = new Buffer(content); - } - } - return file; - } - async onFinish(pluginContext: plugins.CommandContext) { - let { projectRoot, outputDir, buildConfig } = pluginContext - //同步 index.html 配置到 game.js - const gameJSPath = path.join(outputDir, "game.js"); - if (!fs.existsSync(gameJSPath)) { - console.log(`${gameJSPath}不存在,请先使用 Launcher 发布QQ小游戏`); - return; - } - let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" }); - const projectConfig = buildConfig.projectConfig; - const optionStr = - `entryClassName: ${projectConfig.entryClassName},\n\t\t` + - `orientation: ${projectConfig.orientation},\n\t\t` + - `frameRate: ${projectConfig.frameRate},\n\t\t` + - `scaleMode: ${projectConfig.scaleMode},\n\t\t` + - `contentWidth: ${projectConfig.contentWidth},\n\t\t` + - `contentHeight: ${projectConfig.contentHeight},\n\t\t` + - `showFPS: ${projectConfig.showFPS},\n\t\t` + - `fpsStyles: ${projectConfig.fpsStyles},\n\t\t` + - `showLog: ${projectConfig.showLog},\n\t\t` + - `maxTouches: ${projectConfig.maxTouches},`; - const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/; - const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----'; - gameJSContent = gameJSContent.replace(reg, replaceStr); - fs.writeFileSync(gameJSPath, gameJSContent); - - //修改横竖屏 - let orientation; - if (projectConfig.orientation == '"landscape"') { - orientation = "landscape"; - } - else { - orientation = "portrait"; - } - const gameJSONPath = path.join(outputDir, "game.json"); - let gameJSONContent = this.readData(gameJSONPath); - gameJSONContent.deviceOrientation = orientation; - if (!gameJSONContent.plugins) { - gameJSONContent.plugins = {} - } - if (!this.useQQPlugin) { - delete gameJSONContent.plugins["egret-library"] - } else { - let engineVersion = this.readData(path.join(projectRoot, "egretProperties.json")).engineVersion; - gameJSONContent.plugins["egret-library"] = { - "provider": "1110108620", - "version": engineVersion - } - } - this.writeData(gameJSONContent, gameJSONPath) - } - readData(filePath: string): any { - return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); - } - writeData(data: object, filePath: string) { - fs.writeFileSync(filePath, JSON.stringify(data, null, "\t")); - } -} diff --git a/demo/scripts/tsconfig.json b/demo/scripts/tsconfig.json deleted file mode 100644 index 1868374d..00000000 --- a/demo/scripts/tsconfig.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "compilerOptions": { - /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - "lib": [ - "es5", - "es2015.promise" - ], /* Specify library files to be included in the compilation: */ - "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - "noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - } -} \ No newline at end of file diff --git a/demo/scripts/vivogame/vivogame.ts b/demo/scripts/vivogame/vivogame.ts deleted file mode 100644 index 84756dd1..00000000 --- a/demo/scripts/vivogame/vivogame.ts +++ /dev/null @@ -1,126 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; -export class VivogamePlugin implements plugins.Command { - jsFileList: any = [] - constructor() { - } - async onFile(file: plugins.File) { - if (file.extname == '.js') { - const filename = file.origin; - - if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { - return null; - } - this.jsFileList.push(file.basename) - if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { - let content = file.contents.toString(); - content += `;window.egret = egret;`; - content = content.replace(/definition = __global/, "definition = window"); - file.contents = new Buffer(content); - } - else { - let content = file.contents.toString(); - if ( - filename == "libs/modules/res/res.js" || - filename == 'libs/modules/res/res.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.js' - ) { - content += ";window.RES = RES;" - } - if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') { - content += ";window.eui = eui;" - if (filename == "libs/modules/eui/eui.js") { - content = content.replace("function getRepeatedIds", "window.getRepeatedIds=function getRepeatedIds"); - content = content.replace("function getIds", "window.getIds=function getIds"); - content = content.replace("function toXMLString", "window.toXMLString=function toXMLString"); - content = content.replace("function checkDeclarations", "window.checkDeclarations=function checkDeclarations"); - content = content.replace("function getPropertyStr", "window.getPropertyStr=function getPropertyStr"); - } - } - if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') { - content += ';window.dragonBones = dragonBones'; - } - content = "var egret = window.egret;" + content; - - if (filename == 'main.js') { - content += "\n;window.Main = Main;" - } - file.contents = new Buffer(content); - } - } - return file; - } - async onFinish(pluginContext: plugins.CommandContext) { - //同步 index.html 配置到 game.js - const gameJSPath = path.join(pluginContext.outputDir, "game.js"); - if (!fs.existsSync(gameJSPath)) { - console.log(`${gameJSPath}不存在,请先使用 Launcher 发布 Vivo 小游戏`); - return; - } - let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" }); - const projectConfig = pluginContext.buildConfig.projectConfig; - const optionStr = - `entryClassName: ${projectConfig.entryClassName},\n\t\t` + - `orientation: ${projectConfig.orientation},\n\t\t` + - `frameRate: ${projectConfig.frameRate},\n\t\t` + - `scaleMode: ${projectConfig.scaleMode},\n\t\t` + - `contentWidth: ${projectConfig.contentWidth},\n\t\t` + - `contentHeight: ${projectConfig.contentHeight},\n\t\t` + - `showFPS: ${projectConfig.showFPS},\n\t\t` + - `fpsStyles: ${projectConfig.fpsStyles},\n\t\t` + - `showLog: ${projectConfig.showLog},\n\t\t` + - `maxTouches: ${projectConfig.maxTouches},`; - const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/; - const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----'; - gameJSContent = gameJSContent.replace(reg, replaceStr); - fs.writeFileSync(gameJSPath, gameJSContent); - - //修改横竖屏 - let orientation; - if (projectConfig.orientation == '"landscape"') { - orientation = "landscape"; - } - else { - orientation = "portrait"; - } - const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); - let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); - gameJSONContent.deviceOrientation = orientation; - let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion - if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} - gameJSONContent.thirdEngine.egret = engineVersion - - fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); - let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configArr: any[] = [] - for (var i = 0, len = this.jsFileList.length; i < len; i++) { - let jsFile = this.jsFileList[i]; - if (isPublish) { - if (jsFile == "main.js") { - jsFile = 'main.min.js' - } else if (jsFile == "default.thm.js") { - jsFile = "default.thm.min.js" - } - } - configArr.push(JSON.stringify({ - module_name: `./js/${jsFile}`, - module_path: `./js/${jsFile}`, - module_from: `engine/js/${jsFile}`, - }, null, "\t")) - } - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; - const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); - if(!fs.existsSync(minigameConfigPath)){ - //5.2.28版本,vivo更新了项目结构,老项目需要升级 - fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); - }else{ - let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(minigameConfigPath, configJSContent); - } - } - readData(filePath: string): any { - return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); - } -} diff --git a/demo/scripts/wxgame/wxgame.ts b/demo/scripts/wxgame/wxgame.ts deleted file mode 100644 index 13943ce1..00000000 --- a/demo/scripts/wxgame/wxgame.ts +++ /dev/null @@ -1,149 +0,0 @@ -import * as fs from 'fs'; -import * as path from 'path'; -const crypto = require('crypto'); -export class WxgamePlugin implements plugins.Command { - private useWxPlugin:boolean = false; - constructor(useWxPlugin:boolean) { - this.useWxPlugin = useWxPlugin - } - md5Obj = {} - md5(content) { - let md5 = crypto.createHash('md5'); - return md5.update(content).digest('hex'); - } - async onFile(file: plugins.File) { - if (file.extname == '.js') { - const filename = file.origin; - if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { - return null; - } - if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { - let content = file.contents.toString(); - content += `;window.egret = egret;`; - content = content.replace(/definition = __global/, "definition = window"); - this.md5Obj[path.basename(filename)] = this.md5(content) - file.contents = new Buffer(content); - } - else { - let content = file.contents.toString(); - if ( - filename == "libs/modules/res/res.js" || - filename == 'libs/modules/res/res.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.min.js' || - filename == 'libs/modules/assetsmanager/assetsmanager.js' - ) { - content += ";window.RES = RES;" - } - if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') { - content += ";window.eui = eui;" - } - if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') { - content += ';window.dragonBones = dragonBones'; - } - content = "var egret = window.egret;" + content; - if (filename == 'main.js') { - content += "\n;window.Main = Main;" - } - if (filename == 'libs/long/long.js' || filename == 'libs/long/long.min.js'){ - content += "window.Long = long;" - } - this.md5Obj[path.basename(filename)] = this.md5(content) - file.contents = new Buffer(content); - } - } - return file; - } - async onFinish(pluginContext: plugins.CommandContext) { - let { projectRoot, outputDir, buildConfig } = pluginContext - //同步 index.html 配置到 game.js - const gameJSPath = path.join(outputDir, "game.js"); - if (!fs.existsSync(gameJSPath)) { - console.log(`${gameJSPath}不存在,请先使用 Launcher 发布微信小游戏`); - return; - } - let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" }); - const projectConfig = buildConfig.projectConfig; - const optionStr = - `entryClassName: ${projectConfig.entryClassName},\n\t\t` + - `orientation: ${projectConfig.orientation},\n\t\t` + - `frameRate: ${projectConfig.frameRate},\n\t\t` + - `scaleMode: ${projectConfig.scaleMode},\n\t\t` + - `contentWidth: ${projectConfig.contentWidth},\n\t\t` + - `contentHeight: ${projectConfig.contentHeight},\n\t\t` + - `showFPS: ${projectConfig.showFPS},\n\t\t` + - `fpsStyles: ${projectConfig.fpsStyles},\n\t\t` + - `showLog: ${projectConfig.showLog},\n\t\t` + - `maxTouches: ${projectConfig.maxTouches},`; - const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/; - const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----'; - gameJSContent = gameJSContent.replace(reg, replaceStr); - fs.writeFileSync(gameJSPath, gameJSContent); - - //修改横竖屏 - let orientation; - if (projectConfig.orientation == '"landscape"') { - orientation = "landscape"; - } - else { - orientation = "portrait"; - } - const gameJSONPath = path.join(outputDir, "game.json"); - let gameJSONContent = this.readData(gameJSONPath) - gameJSONContent.deviceOrientation = orientation; - if (buildConfig.command !== "publish" && gameJSONContent.plugins && gameJSONContent.plugins['egret-library']) { - delete gameJSONContent.plugins["egret-library"] - } - this.writeData(gameJSONContent, gameJSONPath) - - //下面的流程是配置开启微信插件的功能 - let engineVersion = this.readData(path.join(projectRoot, "egretProperties.json")).engineVersion; - if (!gameJSONContent.plugins) { - gameJSONContent.plugins = {} - } - if(buildConfig.command == "publish" && this.useWxPlugin){ - gameJSONContent.plugins["egret-library"] = { - "provider": "wx7e2186943221985d", - "version": engineVersion, - "path": "egret-library" - } - }else{ - gameJSONContent.plugins = {} - } - - this.writeData(gameJSONContent, gameJSONPath) - - if (buildConfig.command !== "publish" || !this.useWxPlugin) { - return - } - - let libDir = path.join(outputDir, "egret-library") - fs.mkdirSync(libDir) - let pluginData = { "main": "index.js" } - this.writeData(pluginData, path.join(libDir, "plugin.json")) - let engineJS = ['assetsmanager', 'dragonBones', 'egret', 'game', 'eui', 'socket', 'tween'] - let signatureData: any = { - "provider": "wx7e2186943221985d", - "signature": [] - } - for (let i in engineJS) { - let name = engineJS[i] + '.min.js' - if (this.md5Obj[name]) { - let jsInfo: any = { - "path": name, - "md5": this.md5Obj[name] - } - signatureData.signature.push(jsInfo) - } - } - this.writeData(signatureData, path.join(libDir, "signature.json")) - fs.writeFileSync(path.join(libDir, "index.js"), null); - - } - - readData(filePath: string): any { - return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); - } - writeData(data: object, filePath: string) { - fs.writeFileSync(filePath, JSON.stringify(data, null, "\t")); - } -} diff --git a/demo/src/AssetAdapter.ts b/demo/src/AssetAdapter.ts deleted file mode 100644 index cc2dae27..00000000 --- a/demo/src/AssetAdapter.ts +++ /dev/null @@ -1,56 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// - - -class AssetAdapter implements eui.IAssetAdapter { - /** - * @language zh_CN - * 解析素材 - * @param source 待解析的新素材标识符 - * @param compFunc 解析完成回调函数,示例:callBack(content:any,source:string):void; - * @param thisObject callBack的 this 引用 - */ - public getAsset(source: string, compFunc:Function, thisObject: any): void { - function onGetRes(data: any): void { - compFunc.call(thisObject, data, source); - } - if (RES.hasRes(source)) { - let data = RES.getRes(source); - if (data) { - onGetRes(data); - } - else { - RES.getResAsync(source, onGetRes, this); - } - } - else { - RES.getResByUrl(source, onGetRes, this, RES.ResourceItem.TYPE_IMAGE); - } - } -} diff --git a/demo/src/Fgui/common/UI_com_tips.ts b/demo/src/Fgui/common/UI_com_tips.ts deleted file mode 100644 index 959bf25e..00000000 --- a/demo/src/Fgui/common/UI_com_tips.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** This is an automatically generated class by FairyGUI. Please do not modify it. **/ - -module FUI.common { - - export class UI_com_tips extends fairygui.GComponent { - public m_content:fairygui.GTextField; - public static URL:string = "ui://minsdstak7mf0"; - - public static createInstance():UI_com_tips { - return (fairygui.UIPackage.createObject("common", "com_tips")); - } - - protected constructFromXML(xml:any):void { - super.constructFromXML(xml); - - this.m_content = (this.getChildAt(1)); - } - } -} \ No newline at end of file diff --git a/demo/src/Fgui/common/commonBinder.ts b/demo/src/Fgui/common/commonBinder.ts deleted file mode 100644 index 1c05d82d..00000000 --- a/demo/src/Fgui/common/commonBinder.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** This is an automatically generated class by FairyGUI. Please do not modify it. **/ - -module FUI.common { - - export class commonBinder { - public static bindAll():void { - fairygui.UIObjectFactory.setPackageItemExtension(UI_com_tips.URL, UI_com_tips); - } - } -} \ No newline at end of file diff --git a/demo/src/Fgui/loading/UI_View_loading.ts b/demo/src/Fgui/loading/UI_View_loading.ts deleted file mode 100644 index 4d07a886..00000000 --- a/demo/src/Fgui/loading/UI_View_loading.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** This is an automatically generated class by FairyGUI. Please do not modify it. **/ - -module FUI.loading { - - export class UI_View_loading extends fairygui.GComponent { - public m_title:fairygui.GTextField; - public m_pg_loading:fairygui.GProgressBar; - public static URL:string = "ui://mk2d64e7r5ro0"; - - public static createInstance():UI_View_loading { - return (fairygui.UIPackage.createObject("loading", "View_loading")); - } - - protected constructFromXML(xml:any):void { - super.constructFromXML(xml); - - this.m_title = (this.getChildAt(1)); - this.m_pg_loading = (this.getChildAt(2)); - } - } -} \ No newline at end of file diff --git a/demo/src/Fgui/loading/loadingBinder.ts b/demo/src/Fgui/loading/loadingBinder.ts deleted file mode 100644 index d299cf33..00000000 --- a/demo/src/Fgui/loading/loadingBinder.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** This is an automatically generated class by FairyGUI. Please do not modify it. **/ - -module FUI.loading { - - export class loadingBinder { - public static bindAll():void { - fairygui.UIObjectFactory.setPackageItemExtension(UI_View_loading.URL, UI_View_loading); - } - } -} \ No newline at end of file diff --git a/demo/src/Fgui/sc/UI_View_sc.ts b/demo/src/Fgui/sc/UI_View_sc.ts deleted file mode 100644 index 814ebdfc..00000000 --- a/demo/src/Fgui/sc/UI_View_sc.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** This is an automatically generated class by FairyGUI. Please do not modify it. **/ - -module FUI.sc { - - export class UI_View_sc extends fairygui.GComponent { - public m_list_sc:fairygui.GList; - public m_combo_transition:fairygui.GComboBox; - public static URL:string = "ui://m4sln17ak7mf0"; - - public static createInstance():UI_View_sc { - return (fairygui.UIPackage.createObject("sc", "View_sc")); - } - - protected constructFromXML(xml:any):void { - super.constructFromXML(xml); - - this.m_list_sc = (this.getChildAt(0)); - this.m_combo_transition = (this.getChildAt(1)); - } - } -} \ No newline at end of file diff --git a/demo/src/Fgui/sc/UI_btn_sc.ts b/demo/src/Fgui/sc/UI_btn_sc.ts deleted file mode 100644 index 5a9e042f..00000000 --- a/demo/src/Fgui/sc/UI_btn_sc.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** This is an automatically generated class by FairyGUI. Please do not modify it. **/ - -module FUI.sc { - - export class UI_btn_sc extends fairygui.GButton { - public m_name:fairygui.GTextField; - public static URL:string = "ui://m4sln17ak7mf2"; - - public static createInstance():UI_btn_sc { - return (fairygui.UIPackage.createObject("sc", "btn_sc")); - } - - protected constructFromXML(xml:any):void { - super.constructFromXML(xml); - - this.m_name = (this.getChildAt(3)); - } - } -} \ No newline at end of file diff --git a/demo/src/Fgui/sc/UI_combo_sc_popup.ts b/demo/src/Fgui/sc/UI_combo_sc_popup.ts deleted file mode 100644 index 67a39ec8..00000000 --- a/demo/src/Fgui/sc/UI_combo_sc_popup.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** This is an automatically generated class by FairyGUI. Please do not modify it. **/ - -module FUI.sc { - - export class UI_combo_sc_popup extends fairygui.GComponent { - public m_list:fairygui.GList; - public static URL:string = "ui://m4sln17ajde14"; - - public static createInstance():UI_combo_sc_popup { - return (fairygui.UIPackage.createObject("sc", "combo_sc_popup")); - } - - protected constructFromXML(xml:any):void { - super.constructFromXML(xml); - - this.m_list = (this.getChildAt(1)); - } - } -} \ No newline at end of file diff --git a/demo/src/Fgui/sc/scBinder.ts b/demo/src/Fgui/sc/scBinder.ts deleted file mode 100644 index 4842bdce..00000000 --- a/demo/src/Fgui/sc/scBinder.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** This is an automatically generated class by FairyGUI. Please do not modify it. **/ - -module FUI.sc { - - export class scBinder { - public static bindAll():void { - fairygui.UIObjectFactory.setPackageItemExtension(UI_combo_sc_popup.URL, UI_combo_sc_popup); - fairygui.UIObjectFactory.setPackageItemExtension(UI_View_sc.URL, UI_View_sc); - fairygui.UIObjectFactory.setPackageItemExtension(UI_btn_sc.URL, UI_btn_sc); - } - } -} \ No newline at end of file diff --git a/demo/src/Main.ts b/demo/src/Main.ts deleted file mode 100644 index 01a7c7cd..00000000 --- a/demo/src/Main.ts +++ /dev/null @@ -1,70 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// - -import LoadingView = loading.LoadingView; - -class Main extends es.Core { - protected initialize() { - try { - es.Core.debugRenderEndabled = true; - es.TimeRuler.Instance.showLog = true; - this.runGame(); - } catch(err) { - console.error(err); - } - } - - private runGame() { - egret.ImageLoader.crossOrigin = "anonymous"; - this.initUIConfig(); - this.loadResource(); - this.initGameControl(); - } - - private initUIConfig(){ - LayerManager.getInstance().init(this.stage); - FguiUtils.packageNamespace = FUI; - fairygui.UIConfig.defaultFont = "黑体"; - fairygui.UIConfig.bringWindowToFrontOnClick = false; - this.stage.addChild(fgui.GRoot.inst.displayListContainer); - } - - private loadResource() { - RES.loadConfig("resource/default.res.json", "resource/").then(()=>{ - EventManager.getInstance().dispatch(loading.LoadingEvents.OPENVIEW); - }).catch(err =>{ - console.error(err); - }); - } - - private initGameControl(){ - loading.LoadingControl.getInstance(); - sc.ScControl.getInstance(); - } -} diff --git a/demo/src/Platform.ts b/demo/src/Platform.ts deleted file mode 100644 index 4942b996..00000000 --- a/demo/src/Platform.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 平台数据接口。 - * 由于每款游戏通常需要发布到多个平台上,所以提取出一个统一的接口用于开发者获取平台数据信息 - * 推荐开发者通过这种方式封装平台逻辑,以保证整体结构的稳定 - * 由于不同平台的接口形式各有不同,白鹭推荐开发者将所有接口封装为基于 Promise 的异步形式 - */ -declare interface Platform { - - getUserInfo(): Promise; - - login(): Promise - -} - -class DebugPlatform implements Platform { - async getUserInfo() { - return { nickName: "username" } - } - async login() { - - } -} - - -if (!window.platform) { - window.platform = new DebugPlatform(); -} - - - -declare let platform: Platform; - -declare interface Window { - - platform: Platform -} - - - - - diff --git a/demo/src/SampleHelpers/SampleScene.ts b/demo/src/SampleHelpers/SampleScene.ts deleted file mode 100644 index eee8cb62..00000000 --- a/demo/src/SampleHelpers/SampleScene.ts +++ /dev/null @@ -1,27 +0,0 @@ -module samples { - import ScreenSpaceRenderer = es.ScreenSpaceRenderer; - import RenderLayerExcludeRenderer = es.RenderLayerExcludeRenderer; - import SpriteRenderer = es.SpriteRenderer; - - export class SampleScene extends es.Scene { - public static readonly screenSpaceRenderLayer = 999; - - public static _needsFullRender: boolean; - public _screenSpaceRenderer: ScreenSpaceRenderer; - - constructor(addExcludeRenderer: boolean = true, needsFullRender: boolean = false){ - super(); - SampleScene._needsFullRender = needsFullRender; - - if (needsFullRender){ - this._screenSpaceRenderer = this.addRenderer(new ScreenSpaceRenderer(100, SampleScene.screenSpaceRenderLayer)); - this._screenSpaceRenderer.shouldDebugRender = false; - }else{ - this.addRenderer(new ScreenSpaceRenderer(100, SampleScene.screenSpaceRenderLayer)); - } - - if (addExcludeRenderer) - this.addRenderer(new RenderLayerExcludeRenderer(0, SampleScene.screenSpaceRenderLayer)); - } - } -} \ No newline at end of file diff --git a/demo/src/Scenes/AnimatedTiles/AnimatedTilesScene.ts b/demo/src/Scenes/AnimatedTiles/AnimatedTilesScene.ts deleted file mode 100644 index 4ff250ae..00000000 --- a/demo/src/Scenes/AnimatedTiles/AnimatedTilesScene.ts +++ /dev/null @@ -1,21 +0,0 @@ -module samples { - export class AnimatedTilesScene extends SampleScene { - constructor(){ - super(true, true); - } - - public initialize(){ - super.initialize(); - - let tiledEntity = this.createEntity("tiled-map-entity"); - try { - es.TiledMapLoader.loadTmxMap(new es.TmxMap(), "orthogonal-outside_json").then(map => { - tiledEntity.addComponent(new es.TiledMapRenderer(map)); - manager.AlterManager.alter_tips("Tiled tiles场景加载成功"); - }); - } catch (err){ - console.error(err); - } - } - } -} \ No newline at end of file diff --git a/demo/src/Scenes/EmptyScene/BasicScene.ts b/demo/src/Scenes/EmptyScene/BasicScene.ts deleted file mode 100644 index 1d65a67c..00000000 --- a/demo/src/Scenes/EmptyScene/BasicScene.ts +++ /dev/null @@ -1,27 +0,0 @@ -module samples { - export class BasicScene extends SampleScene { - public async onStart() { - super.onStart(); - manager.AlterManager.alter_tips("空白场景加载成功"); - - this.content.loadRes("moon_png").then(moonTexture => { - let moonEntity = this.createEntity("moon"); - moonEntity.position = new es.Vector2(0, 0); - moonEntity.addComponent(new es.SpriteRenderer(moonTexture)); - - this.camera.entity.addComponent(new es.FollowCamera(moonEntity)); - - // this.entities.frameAllocate = true; - // this.entities.maxAllocate = 10; - // for (let i = 0; i < 10000; i ++){ - // this.createEntity(""); - // } - }); - } - - public update(){ - super.update(); - // console.log(this.entities.buffer.length); - } - } -} \ No newline at end of file diff --git a/demo/src/Scenes/GOAP/GoapScene.ts b/demo/src/Scenes/GOAP/GoapScene.ts deleted file mode 100644 index a5985b28..00000000 --- a/demo/src/Scenes/GOAP/GoapScene.ts +++ /dev/null @@ -1,117 +0,0 @@ -module samples { - export class MinerState { - public readonly maxFatigue = 10; - public readonly maxGold = 8; - public readonly maxThirst = 5; - - public fatigue: number = 10; - public thirst: number = 0; - public gold: number = 0; - public goldInBank: number = 0; - - public currentLocation: Location = Location.home; - } - - export class GoapScene extends SampleScene { - public _destinationLocation: Location; - public planner: es.ActionPlanner; - public _actionPlan: es.Action[]; - - public minerState: MinerState; - - public initialize(): void { - super.initialize(); - - // 在我们做任何事情之前,我们需要一个行动计划 - this.planner = new es.ActionPlanner(); - this.minerState = new MinerState(); - - // 设置我们的动作并将它们添加到计划器中 - let sleep = new es.Action("sleep"); - sleep.setPrecondition("fatigued", true); - sleep.setPostcondition("fatigued", false); - this.planner.addAction(sleep); - - let drink = new es.Action("drink"); - drink.setPrecondition("thirsty", true); - drink.setPostcondition("thirsty", false); - this.planner.addAction(drink); - - let mine = new es.Action("mine"); - mine.setPrecondition("hasenoughgold", false); - mine.setPostcondition("hasenoughgold", true); - this.planner.addAction(mine); - - let depositGold = new es.Action("depositGold"); - depositGold.setPrecondition("hasenoughgold", true); - depositGold.setPostcondition("hasenoughgold", false); - this.planner.addAction(depositGold); - - // 制定一个计划,让我们从当前状态运行到目标状态 - this._actionPlan = this.planner.plan(this.getWorldState(), this.getGoalState()); - if (this._actionPlan != null && this._actionPlan.length > 0){ - this.goTo(); - console.log(`得到了一个行动计划与${this._actionPlan.length}行动`); - } else { - console.log(`没有满足我们目标的行动计划`); - } - } - - private goTo(){ - let action = this._actionPlan[this._actionPlan.length - 1].name; - switch (action){ - case "sleep": - this._destinationLocation = Location.home; - break; - case "drink": - this._destinationLocation = Location.saloon; - break; - case "mine": - this._destinationLocation = Location.mine; - break; - case "depositeGold": - this._destinationLocation = Location.bank; - break; - } - - if (this.minerState.currentLocation == this._destinationLocation){ - - } else { - this.minerState.currentLocation = Location.inTransit; - } - } - - public getWorldState(): es.WorldState { - let worldState = this.planner.createWorldState(); - worldState.set("fatigued", this.minerState.fatigue >= this.minerState.maxFatigue); - worldState.set("thirsty", this.minerState.thirst >= this.minerState.maxThirst); - worldState.set("hasenoughgold", this.minerState.gold >= this.minerState.maxGold); - - return worldState; - } - - public getGoalState(): es.WorldState { - let goalState = this.planner.createWorldState(); - - if (this.minerState.fatigue >= this.minerState.maxFatigue){ - goalState.set("fatigued", false); - } else if(this.minerState.thirst >= this.minerState.maxThirst){ - goalState.set("thirsty", false); - } else if(this.minerState.gold >= this.minerState.maxGold){ - goalState.set("hasenoughgold", false); - } else { - goalState.set("hasenoughgold", true); - } - - return goalState; - } - } - - enum Location { - inTransit, - bank, - mine, - home, - saloon, - } -} \ No newline at end of file diff --git a/demo/src/Scenes/LineCasting/LineCaster.ts b/demo/src/Scenes/LineCasting/LineCaster.ts deleted file mode 100644 index 56b441f3..00000000 --- a/demo/src/Scenes/LineCasting/LineCaster.ts +++ /dev/null @@ -1,89 +0,0 @@ -module samples { - import RenderableComponent = es.RenderableComponent; - import Vector2 = es.Vector2; - import Physics = es.Physics; - - export class LineCaster extends RenderableComponent { - private _lastPosition = new Vector2(101, 101); - private _collisionPosition = new Vector2(-1, -1); - private _pixelShape1: egret.Shape; - private _pixelShape2: egret.Shape; - private _lineShape: egret.Shape; - private _pixelShape3: egret.Shape; - private _delayTime = 0.2; - private _pressTime = 0; - private _canTouch = true; - - public get width(){ - return 1000; - } - - public get height(){ - return 1000; - } - - constructor() { - super(); - - this._pixelShape1 = new egret.Shape(); - this._pixelShape2 = new egret.Shape(); - this._lineShape = new egret.Shape(); - this._pixelShape3 = new egret.Shape(); - - this.displayObject = new egret.DisplayObjectContainer(); - let displayContainer = this.displayObject as egret.DisplayObjectContainer; - displayContainer.addChild(this._pixelShape1); - displayContainer.addChild(this._pixelShape2); - displayContainer.addChild(this._pixelShape3); - displayContainer.addChild(this._lineShape); - } - - public render(camera: es.Camera): any { - this._pixelShape1.graphics.clear(); - this._pixelShape1.graphics.beginFill(0xffff00); - this._pixelShape1.graphics.lineStyle(4, 0xffff00); - this._pixelShape1.graphics.moveTo(this._lastPosition.x, this._lastPosition.y); - this._pixelShape1.graphics.endFill(); - - this._pixelShape2.graphics.clear(); - this._pixelShape2.graphics.beginFill(0xffffff); - this._pixelShape2.graphics.lineStyle(4, 0xffffff); - this._pixelShape2.graphics.moveTo(this.transform.position.x, this.transform.position.y); - this._pixelShape2.graphics.endFill(); - - this._lineShape.graphics.clear(); - this._lineShape.graphics.beginFill(0xffffff); - this._lineShape.graphics.lineStyle(1, 0xffffff); - this._lineShape.graphics.moveTo(this._lastPosition.x, this._lastPosition.y); - this._lineShape.graphics.lineTo(this.transform.position.x, this.transform.position.y); - this._lineShape.graphics.endFill(); - - this._pixelShape3.graphics.clear(); - if (this._collisionPosition.x > 0 && this._collisionPosition.y > 0){ - this._pixelShape3.graphics.beginFill(0xff0000); - this._pixelShape3.graphics.lineStyle(10, 0xff0000); - this._pixelShape3.graphics.moveTo(this._collisionPosition.x, this._collisionPosition.y); - this._pixelShape3.graphics.endFill(); - } - } - - public update(): void { - if (!this._canTouch){ - if (this._pressTime > this._delayTime){ - this._canTouch = true; - this._pressTime = 0; - }else{ - this._pressTime += es.Time.deltaTime; - } - return; - } - - if (!es.Input.touchPosition.equals(Vector2.zero)){ - this._lastPosition = this.transform.position; - this.transform.position = es.Input.touchPosition; - this._collisionPosition = new Vector2(-1, -1); - this._canTouch = false; - } - } - } -} \ No newline at end of file diff --git a/demo/src/Scenes/LineCasting/LineCastingScene.ts b/demo/src/Scenes/LineCasting/LineCastingScene.ts deleted file mode 100644 index 840c2240..00000000 --- a/demo/src/Scenes/LineCasting/LineCastingScene.ts +++ /dev/null @@ -1,25 +0,0 @@ -module samples { - import Vector2 = es.Vector2; - import SpriteRenderer = es.SpriteRenderer; - import BoxCollider = es.BoxCollider; - - export class LineCastingScene extends SampleScene { - public initialize(): void { - super.initialize(); - - this.content.loadRes("moon_png").then((moonTex: egret.Texture) => { - let playerEntity = this.createEntity("player"); - playerEntity.position = new Vector2(es.Core.scene.width / 2, es.Core.scene.height / 2); - playerEntity.addComponent(new SpriteRenderer(moonTex)); - let coll = new BoxCollider().setSize(moonTex.textureWidth, moonTex.textureHeight); - playerEntity.addComponent(coll); - playerEntity.position = new Vector2(200, 100); - - let lineCaster = this.createEntity("linecaster").addComponent(new LineCaster()); - lineCaster.transform.position = new Vector2(300, 100); - - manager.AlterManager.alter_tips("lineCasting加载成功"); - }); - } - } -} \ No newline at end of file diff --git a/demo/src/Scenes/NinjaAdventure/CameraBounds.ts b/demo/src/Scenes/NinjaAdventure/CameraBounds.ts deleted file mode 100644 index 182c6401..00000000 --- a/demo/src/Scenes/NinjaAdventure/CameraBounds.ts +++ /dev/null @@ -1,37 +0,0 @@ -module samples { - import Component = es.Component; - import Vector2 = es.Vector2; - - export class CameraBounds extends Component { - public min: Vector2; - public max: Vector2; - - constructor(min: Vector2 = Vector2.zero, max: Vector2 = Vector2.zero){ - super(); - - this.min = min; - this.max = max; - this.setUpdateOrder(Number.MAX_VALUE); - } - - public onAddedToEntity(): void { - this.entity.updateOrder = Number.MAX_VALUE; - } - - public update(): void { - let cameraBounds = this.entity.scene.camera.bounds; - - if (cameraBounds.top < this.min.y) - this.entity.scene.camera.position.add(new Vector2(0, this.min.y - cameraBounds.top)); - - if (cameraBounds.left < this.min.x) - this.entity.scene.camera.position.add(new Vector2(this.min.x - cameraBounds.left, 0)); - - if (cameraBounds.bottom > this.max.y) - this.entity.scene.camera.position.add(new Vector2(0, this.max.y - cameraBounds.bottom)); - - if (cameraBounds.right > this.max.x) - this.entity.scene.camera.position.add(new Vector2(this.max.x - cameraBounds.right, 0)); - } - } -} \ No newline at end of file diff --git a/demo/src/Scenes/NinjaAdventure/FireballProjectileController.ts b/demo/src/Scenes/NinjaAdventure/FireballProjectileController.ts deleted file mode 100644 index 5e53a7f6..00000000 --- a/demo/src/Scenes/NinjaAdventure/FireballProjectileController.ts +++ /dev/null @@ -1,28 +0,0 @@ -module samples { - import Component = es.Component; - import Vector2 = es.Vector2; - import ProjectileMover = es.ProjectileMover; - import Time = es.Time; - - /** - * 移动一个投射器并在它击中任何东西时摧毁它 - */ - export class FireballProjectileController extends Component { - public velocity: Vector2; - public _mover: ProjectileMover; - - constructor(velocity: Vector2){ - super(); - this.velocity = velocity; - } - - public onAddedToEntity(): void { - this._mover = this.entity.getComponent(ProjectileMover); - } - - public update(): void { - if (this._mover.move(Vector2.multiply(this.velocity, new Vector2(Time.deltaTime)))) - this.entity.destroy(); - } - } -} \ No newline at end of file diff --git a/demo/src/Scenes/NinjaAdventure/Ninja.ts b/demo/src/Scenes/NinjaAdventure/Ninja.ts deleted file mode 100644 index 1d1944a3..00000000 --- a/demo/src/Scenes/NinjaAdventure/Ninja.ts +++ /dev/null @@ -1,145 +0,0 @@ -module samples { - import SpriteAnimator = es.SpriteAnimator; - import Mover = es.Mover; - import VirtualButton = es.VirtualButton; - import VirtualIntegerAxis = es.VirtualIntegerAxis; - import KeyboardKey = es.KeyboardKey; - import KeyboardKeys = es.KeyboardKeys; - import OverlapBehavior = es.OverlapBehavior; - import Vector2 = es.Vector2; - import Time = es.Time; - import Keys = es.Keys; - import CollisionResult = es.CollisionResult; - import SubpixelVector2 = es.SubpixelVector2; - import ITriggerListener = es.ITriggerListener; - - export class Ninja extends es.Component implements ITriggerListener{ - public _animator: SpriteAnimator; - - public _subpixelV2: SubpixelVector2 = new SubpixelVector2(); - public _mover: Mover; - public _moveSpeed = 100; - public _projectileVelocity: Vector2 = new Vector2(175); - - public _fireInput: VirtualButton; - public _xAxisInput: VirtualIntegerAxis; - public _yAxisInput: VirtualIntegerAxis; - - public onAddedToEntity(): void { - let characterPng = RandomUtils.randint(1, 6); - let texture = RES.getRes(`${characterPng}_png`); - let sprites = es.Sprite.spritesFromAtlas(texture, 16, 16); - - this._mover = this.entity.addComponent(new Mover()); - this._animator = this.entity.addComponent(new SpriteAnimator()); - - this._animator.addAnimation("walkLeft", new es.SpriteAnimation([ - sprites[2], - sprites[6], - sprites[10], - sprites[14] - ], 4)); - - this._animator.addAnimation("walkRight", new es.SpriteAnimation([ - sprites[3], - sprites[7], - sprites[11], - sprites[15] - ], 4)); - - this._animator.addAnimation("walkDown", new es.SpriteAnimation([ - sprites[0], - sprites[4], - sprites[8], - sprites[12] - ], 4)); - - this._animator.addAnimation("walkUp", new es.SpriteAnimation([ - sprites[1], - sprites[5], - sprites[9], - sprites[13] - ], 4)); - - this.setupInput(); - } - - public onRemovedFromEntity(): void { - this._fireInput.deregister(); - } - - public setupInput(){ - // 设置输入射击一个火球。我们允许在键盘z上使用 - this._fireInput = new VirtualButton(); - this._fireInput.nodes.push(new KeyboardKey(Keys.z)); - - this._xAxisInput = new VirtualIntegerAxis(); - this._xAxisInput.nodes.push(new KeyboardKeys(OverlapBehavior.takeNewer, Keys.left, Keys.right)); - - this._yAxisInput = new VirtualIntegerAxis(); - this._yAxisInput.nodes.push(new KeyboardKeys(OverlapBehavior.takeNewer, Keys.up, Keys.down)); - } - - public update(): void { - let moveDir = new Vector2(this._xAxisInput.value, this._yAxisInput.value); - let animation = "walkDown"; - - if (moveDir.x < 0) - animation = "walkLeft"; - else if(moveDir.x > 0) - animation = "walkRight"; - - if (moveDir.y < 0) - animation = "walkUp"; - else if(moveDir.y > 0) - animation = "walkDown"; - - if (!moveDir.equals(Vector2.zero)){ - if (!this._animator.isAnimationActive(animation)) - this._animator.play(animation); - else - this._animator.unPause(); - - let movement = Vector2.multiply(moveDir, new Vector2(this._moveSpeed * Time.deltaTime)); - let res: CollisionResult = new CollisionResult(); - this._mover.calculateMovement(movement, res); - this._subpixelV2.update(movement); - this._mover.applyMovement(movement); - }else{ - this._animator.pause(); - } - - if (this._fireInput.isPressed){ - let dir = Vector2.zero; - switch (this._animator.currentAnimationName) { - case "walkUp": - dir.y = -1; - break; - case "walkDown": - dir.y = 1; - break; - case "walkRight": - dir.x = 1; - break; - case "walkLeft": - dir.x = -1; - break; - default: - dir = new Vector2(1, 0); - break; - } - - let ninjaScene = this.entity.scene as NinjaAdventureScene; - ninjaScene.createProjectiles(this.entity.transform.position, Vector2.multiply(this._projectileVelocity, dir)); - } - } - - public onTriggerEnter(other: es.Collider, local: es.Collider): any { - console.log(`triggerEnter: ${other.entity.name}`); - } - - public onTriggerExit(other: es.Collider, local: es.Collider): any { - console.log(`triggerExit: ${other.entity.name}`); - } - } -} \ No newline at end of file diff --git a/demo/src/Scenes/NinjaAdventure/NinjaAdventureScene.ts b/demo/src/Scenes/NinjaAdventure/NinjaAdventureScene.ts deleted file mode 100644 index 7c01ac5e..00000000 --- a/demo/src/Scenes/NinjaAdventure/NinjaAdventureScene.ts +++ /dev/null @@ -1,89 +0,0 @@ -module samples { - import CircleCollider = es.CircleCollider; - import Flags = es.Flags; - import SpriteRenderer = es.SpriteRenderer; - import ProjectileHitDetector = es.ProjectileHitDetector; - import FollowCamera = es.FollowCamera; - import TiledMapLoader = es.TiledMapLoader; - import TiledMapRenderer = es.TiledMapRenderer; - import Vector2 = es.Vector2; - import ProjectileMover = es.ProjectileMover; - import Sprite = es.Sprite; - import SpriteAnimator = es.SpriteAnimator; - import SpriteAnimation = es.SpriteAnimation; - - export class NinjaAdventureScene extends SampleScene { - public async onStart() { - super.onStart(); - - let tiledEntity = this.createEntity("tiled-map-entity"); - TiledMapLoader.loadTmxMap(new es.TmxMap(), "tilemap_json").then(map => { - let tiledMapRenderer = tiledEntity.addComponent(new TiledMapRenderer(map, "collision")); - tiledMapRenderer.setLayersToRender("tiles", "terrain", "details"); - - tiledMapRenderer.renderLayer = 10; - - let tiledMapDetailsComp = tiledEntity.addComponent(new TiledMapRenderer(map)); - tiledMapRenderer.setLayerToRender("above-details"); - tiledMapRenderer.renderLayer = -1; - - let topLeft = new Vector2(map.tileWidth, map.tileWidth); - let bottomRight = new Vector2(map.tileWidth * (map.width - 1), - map.tileWidth * (map.height - 1)); - tiledEntity.addComponent(new CameraBounds(topLeft, bottomRight)); - }); - - - let playerEntity = this.createEntity("player"); - playerEntity.position = new es.Vector2(256 / 2, 224 / 2); - playerEntity.addComponent(new Ninja()); - let collider = playerEntity.addComponent(new CircleCollider()); - - // 我们只希望与默认图层0上的组件发生冲突 - Flags.setFlagExclusive(collider.collidesWithLayers, 0); - // 移动到第1层 保证自己的图层不会如果增加攻击方式则不会攻击到自身 - Flags.setFlagExclusive(collider.physicsLayer, 1); - - this.camera.entity.addComponent(new FollowCamera(playerEntity)); - - this.content.loadRes("moon_png").then(moonTexture => { - let moonEntity = this.createEntity("moon"); - moonEntity.position = new es.Vector2(412, 460); - moonEntity.addComponent(new SpriteRenderer(moonTexture)); - moonEntity.addComponent(new ProjectileHitDetector()); - moonEntity.addComponent(new CircleCollider()); - }); - - manager.AlterManager.alter_tips("Ninja 场景加载成功"); - } - - /** - * 创建抛射物并使其运动 - * @param position - * @param velocity - */ - public createProjectiles(position: Vector2, velocity: Vector2) { - // 创建一个实体来存放投射程序及其逻辑 - let entity = this.createEntity("projectile"); - entity.position = position; - entity.addComponent(new ProjectileMover()); - entity.addComponent(new FireballProjectileController(velocity)); - - let collider = entity.addComponent(new CircleCollider()); - Flags.setFlagExclusive(collider.collidesWithLayers, 0); - Flags.setFlagExclusive(collider.physicsLayer, 1); - - this.content.loadRes("plume_png").then(()=>{ - let texture = RES.getRes("plume_png"); - let sprites = Sprite.spritesFromAtlas(texture, 16, 16); - let animator = entity.addComponent(new SpriteAnimator()); - animator.renderLayer = 1; - - animator.addAnimation("default", new SpriteAnimation(sprites)); - animator.play("default"); - }); - - return entity; - } - } -} \ No newline at end of file diff --git a/demo/src/Scenes/NinjaAdventure/ProjectileHitDetector.ts b/demo/src/Scenes/NinjaAdventure/ProjectileHitDetector.ts deleted file mode 100644 index a46dfec1..00000000 --- a/demo/src/Scenes/NinjaAdventure/ProjectileHitDetector.ts +++ /dev/null @@ -1,30 +0,0 @@ -module es { - /** - * 简单的组件,可以检测它是否被弹丸击中。当被击中时,它会闪烁并在被击中一定次数后自我毁灭。 - */ - export class ProjectileHitDetector extends Component implements ITriggerListener{ - public hitsUntilDead: number = 10; - public _hitCounter: number; - public _sprite: SpriteRenderer; - - public onAddedToEntity(): void { - this._sprite = this.entity.getComponent(SpriteRenderer); - } - - public onTriggerEnter(other: es.Collider, local: es.Collider): any { - this._hitCounter ++; - if (this.hitsUntilDead >= this.hitsUntilDead){ - this.entity.destroy(); - return; - } - - this._sprite.color = 0xFF0000; - Core.schedule(0.1, false, this, timer => { - this._sprite.color = 0x000000; - }); - } - - public onTriggerExit(other: es.Collider, local: es.Collider): any { - } - } -} \ No newline at end of file diff --git a/demo/src/ThemeAdapter.ts b/demo/src/ThemeAdapter.ts deleted file mode 100644 index 9922e6e3..00000000 --- a/demo/src/ThemeAdapter.ts +++ /dev/null @@ -1,97 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// - - -class ThemeAdapter implements eui.IThemeAdapter { - - /** - * 解析主题 - * @param url 待解析的主题url - * @param onSuccess 解析完成回调函数,示例:compFunc(e:egret.Event):void; - * @param onError 解析失败回调函数,示例:errorFunc():void; - * @param thisObject 回调的this引用 - */ - public getTheme(url: string, onSuccess: Function, onError: Function, thisObject: any): void { - function onResGet(e: string): void { - onSuccess.call(thisObject, e); - } - function onResError(e: RES.ResourceEvent): void { - if (e.resItem.url == url) { - RES.removeEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, onResError, null); - onError.call(thisObject); - } - } - - if (typeof generateEUI !== 'undefined') { - egret.callLater(() => { - onSuccess.call(thisObject, generateEUI); - }, this); - } - else if (typeof generateEUI2 !== 'undefined') { - RES.getResByUrl("resource/gameEui.json", (data, url) => { - window["JSONParseClass"]["setData"](data); - egret.callLater(() => { - onSuccess.call(thisObject, generateEUI2); - }, this); - }, this, RES.ResourceItem.TYPE_JSON); - } - else if (typeof generateJSON !== 'undefined') { - if (url.indexOf(".exml") > -1) { - let dataPath = url.split("/"); - dataPath.pop(); - let dirPath = dataPath.join("/") + "_EUI.json"; - if (!generateJSON.paths[url]) { - RES.getResByUrl(dirPath, (data) => { - window["JSONParseClass"]["setData"](data); - egret.callLater(() => { - onSuccess.call(thisObject, generateJSON.paths[url]); - }, this); - }, this, RES.ResourceItem.TYPE_JSON); - } else { - egret.callLater(() => { - onSuccess.call(thisObject, generateJSON.paths[url]); - }, this); - } - } - else { - egret.callLater(() => { - onSuccess.call(thisObject, generateJSON); - }, this); - } - } - else { - RES.addEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, onResError, null); - RES.getResByUrl(url, onResGet, this, RES.ResourceItem.TYPE_TEXT); - } - } -} - -declare var generateEUI: { paths: string[], skins: any } -declare var generateEUI2: { paths: string[], skins: any } -declare var generateJSON: { paths: string[], skins: any } \ No newline at end of file diff --git a/demo/src/UI/PopManager.ts b/demo/src/UI/PopManager.ts deleted file mode 100644 index b8730706..00000000 --- a/demo/src/UI/PopManager.ts +++ /dev/null @@ -1,25 +0,0 @@ -module manager { - export class AlterManager { - public static alter_tips(txt: string){ - let item_tip = FUI.common.UI_com_tips.createInstance(); - if (!item_tip) - return; - item_tip.m_content.text = txt; - item_tip.ensureBoundsCorrect(); - item_tip.x = es.Core.Instance.stage.stageWidth / 2 - item_tip.width / 2; - item_tip.y = es.Core.Instance.stage.stageHeight / 2 - item_tip.height / 2; - LayerManager.getInstance().tipsLayer.addChild(item_tip.displayObject); - - item_tip.alpha = 0; - let originY = item_tip.y; - egret.Tween.get(item_tip).to({alpha: 1, y: originY - 100}, 700, egret.Ease.cubicInOut).wait(1000) - .to({alpha: 0, y: originY - 200}, 700, egret.Ease.cubicInOut).call(()=>{ - egret.Tween.removeTweens(item_tip.displayObject); - if (item_tip.displayObject && item_tip.displayObject.parent) - item_tip.displayObject.parent.removeChild(item_tip.displayObject); - item_tip.dispose(); - item_tip = null; - }); - } - } -} \ No newline at end of file diff --git a/demo/src/UI/loading/LoadingControl.ts b/demo/src/UI/loading/LoadingControl.ts deleted file mode 100644 index e19f1726..00000000 --- a/demo/src/UI/loading/LoadingControl.ts +++ /dev/null @@ -1,27 +0,0 @@ -module loading { - export class LoadingControl { - private _eventManager: EventManager; - private _viewManager: ViewManager; - private static single: LoadingControl; - public static getInstance(){ - if (!this.single) this.single = new LoadingControl(); - - return this.single; - } - - constructor(){ - this.addEvents(); - } - - private addEvents(){ - this._eventManager = EventManager.getInstance(); - this._viewManager = ViewManager.getInstance(); - // 事件监听 - this._eventManager.addListener(LoadingEvents.OPENVIEW, this.openView, this); - } - - private openView(){ - this._viewManager.openView(LoadingView); - } - } -} \ No newline at end of file diff --git a/demo/src/UI/loading/LoadingEvents.ts b/demo/src/UI/loading/LoadingEvents.ts deleted file mode 100644 index 7c7b9776..00000000 --- a/demo/src/UI/loading/LoadingEvents.ts +++ /dev/null @@ -1,5 +0,0 @@ -module loading { - export module LoadingEvents { - export const OPENVIEW = Symbol(); - } -} \ No newline at end of file diff --git a/demo/src/UI/loading/LoadingView.ts b/demo/src/UI/loading/LoadingView.ts deleted file mode 100644 index d6694074..00000000 --- a/demo/src/UI/loading/LoadingView.ts +++ /dev/null @@ -1,59 +0,0 @@ -module loading { - import commonBinder = FUI.common.commonBinder; - import ResourceInfo = RES.ResourceInfo; - - export class LoadingView extends BaseView implements RES.PromiseTaskReporter { - private _ui: FUI.loading.UI_View_loading; - private _loadGroup = ["preload", "common", "characters"]; - private _maxProgress = 0; - private _currentProgress = 0; - - constructor() { - super("loading"); - } - - public init() { - this._ui = this._fuiView = FUI.loading.UI_View_loading.createInstance(); - this.addChild(this._ui.displayObject); - super.init(); - } - - public async show() { - this._ui.m_pg_loading.value = 0; - for (let i = 0; i < this._loadGroup.length; i ++){ - this._maxProgress += RES.getGroupByName(this._loadGroup[i]).length; - } - this._ui.m_pg_loading.max = this._maxProgress; - for (let i = 0; i < this._loadGroup.length; i ++){ - await RES.loadGroup(this._loadGroup[i], 0, this); - } - } - - public onProgress(current: number, total: number, resItem: ResourceInfo): void { - this._ui.m_pg_loading.tweenValue(this._currentProgress++, 1); - if (this._currentProgress == this._maxProgress) { - if (resItem.name == "common"){ - fairygui.UIPackage.addPackage(resItem.name); - commonBinder.bindAll(); - } - egret.setTimeout(() => { - this.openMainScene(); - }, this, 1000) - } - } - - public openMainScene() { - es.Core.scene = new samples.BasicScene(); - EventManager.getInstance().dispatch(sc.ScEvents.OPENVIEW); - this.close(); - } - - public destroy() { - if (this._ui) { - this._ui.dispose(); - this._ui = null; - } - super.destroy(); - } - } -} \ No newline at end of file diff --git a/demo/src/UI/mvc/BaseView.ts b/demo/src/UI/mvc/BaseView.ts deleted file mode 100644 index 4c541442..00000000 --- a/demo/src/UI/mvc/BaseView.ts +++ /dev/null @@ -1,101 +0,0 @@ -class BaseView extends egret.DisplayObjectContainer { - private _name: string; - public get name(){ - return this._name; - } - public set name(value: string){ - this._name = value; - } - public viewLayer: viewLayer = viewLayer.pop; - /** 是否可以被销毁 */ - protected _destoryChildren: boolean; - protected _isDispose: boolean; - /** fui界面 */ - protected _fuiView: fairygui.GComponent; - /** 是否已经显示 */ - protected _isShow: boolean; - /** 视图数据 */ - protected _showData: any; - - constructor(name?: string){ - super(); - this._isDispose = false; - if (name){ - this.name = name; - } - } - - /** - * 当界面被初始化时调用 - */ - public init(){ - this._destoryChildren = true; - } - - /** - * 当界面大小被改变时 - */ - public resize(){ - if (this._fuiView && this._isShow){ - this._fuiView.width = LayerManager.getInstance().stage.stageWidth; - this._fuiView.height = LayerManager.getInstance().stage.stageHeight; - } - } - - /** - * - * @param showData - */ - public baseShow(showData?: any){ - this._isShow = true; - this._showData = showData; - egret.callLater(this.resize, this); - } - - /** - * 打开界面时调用 - */ - public show() { - - } - - /** - * 当界面关闭时调用 - */ - public close() { - this._isShow = false; - ViewManager.getInstance().closeView(this); - } - - /** - * - * @param showData - */ - public baseRefresh(showData?: any){ - this._showData = showData; - } - - /** - * 当界面刷新时调用 - */ - public refresh(showData?: any){ - this._showData = showData; - } - - /** - * 当界面销毁时调用 - */ - public destroy(){ - this._isDispose = true; - if (this.parent) - this.parent.removeChild(this); - - if (this._destoryChildren){ - this._fuiView = null; - while (this.numChildren > 0){ - this.removeChildAt(0); - } - this._destoryChildren = false; - } - } -} \ No newline at end of file diff --git a/demo/src/UI/mvc/EventManager.ts b/demo/src/UI/mvc/EventManager.ts deleted file mode 100644 index f6738bec..00000000 --- a/demo/src/UI/mvc/EventManager.ts +++ /dev/null @@ -1,104 +0,0 @@ -class EventManager { - private static _single: EventManager; - private _dict: any; - private _eventList: EventVo[]; - - public static getInstance() { - if (!this._single) this._single = new EventManager(); - return this._single; - } - - constructor() { - this._dict = {}; - this._eventList = []; - } - - /** - * 添加消息监听 - * @param type - * @param listener - * @param thisObj - */ - public addListener(type: string | symbol, listener: Function, thisObj: any): void { - var arr: any[] = this._dict[type]; - if (arr == null) { - arr = []; - this._dict[type] = arr; - } - var i: number, len: number = arr.length; - for (i = 0; i < len; i++) { - if (arr[i][0] == listener && arr[i][1] == thisObj) return; - } - arr.push([listener, thisObj]); - } - - /** - * 移除监听 - * @param type - * @param listener - * @param thisObj - */ - public removeListener(type: string | symbol, listener: Function, thisObj: any): void { - var arr: any[] = this._dict[type]; - if (arr == null) return; - - var i: number, len: number = Array.length; - for (i = 0; i < len; i++) { - if (arr[i][0] == listener && arr[i][1] == thisObj) { - arr.splice(i, 1); - i--; - break; - } - } - - if (arr.length == 0) { - delete this._dict[type]; - this._dict[type] = null; - } - } - - /** - * 事件派发 - * @param type - * @param param - */ - public dispatch(type: string | symbol, ...param: any[]): void { - if (this._dict[type] == null) return; - - var vo: EventVo = new EventVo(); - vo.type = type; - vo.param = param; - - this.dealMsg(vo); - } - - /** - * 事件处理 - * @param vo - */ - private dealMsg(vo: EventVo): void { - var listeners: Array = this._dict[vo.type]; - if (listeners && listeners.length > 0) { - var i: number = 0, len: number = listeners.length, listener: Array = null; - while (i < len) { - listener = listeners[i]; - listener[0].apply(listener[1], vo.param); - if (listeners.length != len) { - len = listeners.length; - i--; - } - i++; - } - } - vo.dispose(); - } -} - -class EventVo { - public type: string | symbol; - public param: any[]; - public dispose() { - this.type = null; - this.param = null; - } -} \ No newline at end of file diff --git a/demo/src/UI/mvc/Extension.ts b/demo/src/UI/mvc/Extension.ts deleted file mode 100644 index 132a61d6..00000000 --- a/demo/src/UI/mvc/Extension.ts +++ /dev/null @@ -1,389 +0,0 @@ -declare interface String { - /** - * 去除字符串头部空格或指定字符 - * @param c 指定字符(字符串) - */ - trimStart(c); - /** - * 去除字符串尾部空格或指定字符 - * @param c 指定字符(字符串) - */ - trimEnd(c); -} - -String.prototype.trimStart = function (c) { - function trimStart(str, c) { - let regExp; - if (!c) { - regExp = new RegExp(/^\s*/); - } else { - regExp = new RegExp("^" + c); - } - - return str.replace(regExp, ""); - } - - return trimStart(this, c); -}; - -String.prototype.trimEnd = function (c) { - function trimEnd(str, c) { - let regExp; - if (!c) { - regExp = new RegExp(/\s*$/); - } else { - regExp = new RegExp(c + "$"); - } - - return str.replace(regExp, ""); - } - - return trimEnd(this, c); -}; - -declare interface Array { - /** - * 获取满足表达式的数组元素索引 - * @param predicate 表达式 - */ - findIndex(predicate: Function): number; - /** - * 是否存在满足表达式的数组元素 - * @param predicate 表达式 - */ - any(predicate: Function): boolean; - /** - * 获取满足表达式的第一个或默认数组元素 - * @param predicate 表达式 - */ - firstOrDefault(predicate: Function): T; - /** - * 获取满足表达式的第一个数组元素 - * @param predicate 表达式 - */ - find(predicate: Function): T; - /** - * 筛选满足表达式的数组元素 - * @param predicate 表达式 - */ - where(predicate: Function): Array; - /** - * 获取满足表达式的数组元素的计数 - * @param predicate 表达式 - */ - count(predicate: Function): number; - /** - * 获取满足表达式的数组元素的数组 - * @param predicate 表达式 - */ - findAll(predicate: Function): Array; - /** - * 移除满足表达式的数组元素 - * @param predicate 表达式 - */ - removeAll(predicate: Function): void; - /** - * 移除数组元素 - * @param element 数组元素 - */ - remove(element): boolean; - /** - * 移除特定索引数组元素 - * @param index 索引 - */ - removeAt(index): void; - /** - * 移除范围数组元素 - * @param index 开始索引 - * @param count 删除的个数 - */ - removeRange(index, count): void; - /** - * 获取通过选择器转换的数组 - * @param selector 选择器 - */ - select(selector: Function): Array; - /** - * 排序(升序) - * @param keySelector key选择器 - * @param comparer 比较器 - */ - orderBy(keySelector: Function, comparer: Function): Array; - /** - * 排序(降序) - * @param keySelector key选择器 - * @param comparer 比较器 - */ - orderByDescending(keySelector: Function, comparer: Function): Array; - /** - * 分组 - * @param keySelector key选择器 - */ - groupBy(keySelector: Function): Array; - /** - * 求和 - * @param selector 选择器 - */ - sum(selector); -} - -Array.prototype.findIndex = function (predicate) { - function findIndex(array, predicate) { - for (let i = 0, len = array.length; i < len; i++) { - if (predicate.call(arguments[2], array[i], i, array)) { - return i; - } - } - - return -1; - } - - return findIndex(this, predicate); -}; - -Array.prototype.any = function (predicate) { - function any(array, predicate) { - return array.findIndex(predicate) > -1; - } - - return any(this, predicate); -}; - -Array.prototype.firstOrDefault = function (predicate) { - function firstOrDefault(array, predicate) { - let index = array.findIndex(predicate); - return index == -1 ? null : array[index]; - } - - return firstOrDefault(this, predicate); -}; - -Array.prototype.find = function (predicate) { - function find(array, predicate) { - return array.firstOrDefault(predicate); - } - - return find(this, predicate); -}; - -Array.prototype.where = function (predicate) { - function where(array, predicate) { - if (typeof array.reduce === "function") { - return array.reduce(function (ret, element, index) { - if (predicate.call(arguments[2], element, index, array)) { - ret.push(element); - } - - return ret; - }, []); - } else { - let ret = []; - for (let i = 0, len = array.length; i < len; i++) { - let element = array[i]; - if (predicate.call(arguments[2], element, i, array)) { - ret.push(element); - } - } - - return ret; - } - } - - return where(this, predicate); -}; - -Array.prototype.count = function (predicate) { - function count(array, predicate) { - return array.where(predicate).length; - } - - return count(this, predicate); -}; - -Array.prototype.findAll = function (predicate) { - function findAll(array, predicate) { - return array.where(predicate); - } - - return findAll(this, predicate); -}; - -Array.prototype.removeAll = function (predicate) { - function removeAll(array, predicate) { - let index; - do { - index = array.findIndex(predicate); - if (index >= 0) { - array.splice(index, 1); - } - } while (index >= 0); - } - - removeAll(this, predicate); -}; - -Array.prototype.remove = function (element) { - function remove(array, element) { - let index = array.findIndex(function (x) { - return x === element; - }); - - if (index >= 0) { - array.splice(index, 1); - return true; - } else { - return false; - } - } - - return remove(this, element); -}; - -Array.prototype.removeAt = function (index) { - function removeAt(array, index) { - array.splice(index, 1); - } - - return removeAt(this, index); -}; - -Array.prototype.removeRange = function (index, count) { - function removeRange(array, index, count) { - array.splice(index, count); - } - - return removeRange(this, index, count); -}; - -Array.prototype.select = function (selector) { - function select(array, selector) { - if (typeof array.reduce === "function") { - return array.reduce(function (ret, element, index) { - ret.push(selector.call(arguments[2], element, index, array)); - return ret; - }, []); - } else { - let ret = []; - for (let i = 0, len = array.length; i < len; i++) { - ret.push(selector.call(arguments[2], array[i], i, array)); - } - - return ret; - } - } - - return select(this, selector); -}; - -Array.prototype.orderBy = function (keySelector, comparer) { - function orderBy(array, keySelector, comparer) { - array.sort(function (x, y) { - let v1 = keySelector(x); - let v2 = keySelector(y); - if (comparer) { - return comparer(v1, v2); - } else { - return v1 > v2 ? 1 : -1; - } - }); - - return array; - } - - return orderBy(this, keySelector, comparer); -}; - -Array.prototype.orderByDescending = function (keySelector, comparer) { - function orderByDescending(array, keySelector, comparer) { - array.sort(function (x, y) { - let v1 = keySelector(x); - let v2 = keySelector(y); - if (comparer) { - return -comparer(v1, v2); - } else { - return v1 < v2 ? 1 : -1; - } - }); - - return array; - } - - return orderByDescending(this, keySelector, comparer); -}; - -Array.prototype.groupBy = function (keySelector) { - function groupBy(array, keySelector) { - if (typeof array.reduce === "function") { - let keys = []; - return array.reduce(function (groups, element, index) { - let key = JSON.stringify( - keySelector.call(arguments[1], element, index, array) - ); - let index2 = keys.findIndex(function (x) { - return x === key; - }); - - if (index2 < 0) { - index2 = keys.push(key) - 1; - } - - if (!groups[index2]) { - groups[index2] = []; - } - - groups[index2].push(element); - return groups; - }, []); - } else { - let groups = []; - let keys = []; - for (let i = 0, len = array.length; i < len; i++) { - let key = JSON.stringify( - keySelector.call(arguments[1], array[i], i, array) - ); - let index = keys.findIndex(function (x) { - return x === key; - }); - - if (index < 0) { - index = keys.push(key) - 1; - } - - if (!groups[index]) { - groups[index] = []; - } - - groups[index].push(array[i]); - } - - return groups; - } - } - - return groupBy(this, keySelector); -}; - -Array.prototype.sum = function (selector) { - function sum(array, selector) { - let ret; - for (let i = 0, len = array.length; i < len; i++) { - if (i == 0) { - if (selector) { - ret = selector.call(arguments[2], array[i], i, array); - } else { - ret = array[i]; - } - } else { - if (selector) { - ret += selector.call(arguments[2], array[i], i, array); - } else { - ret += array[i]; - } - } - } - - return ret; - } - - return sum(this, selector); -}; \ No newline at end of file diff --git a/demo/src/UI/mvc/FguiUtils.ts b/demo/src/UI/mvc/FguiUtils.ts deleted file mode 100644 index 58206834..00000000 --- a/demo/src/UI/mvc/FguiUtils.ts +++ /dev/null @@ -1,25 +0,0 @@ -class FguiUtils { - /** 包的命名空间 */ - public static packageNamespace: any; - /** 加载fgui资源 */ - public static load(name: string): Promise { - return new Promise((resolve, reject) => { - let existPkg = fairygui.UIPackage.getByName(name); - if (existPkg) { - resolve(); - } - - RES.loadGroup(name, 0).then(()=>{ - fairygui.UIPackage.addPackage(name); - if (this.packageNamespace[name][name + "Binder"]) - this.packageNamespace[name][name + "Binder"].bindAll(); - - resolve(); - }).catch(err => { - console.error("loadfgui error:" + err); - reject(); - }); - }); - - } -} \ No newline at end of file diff --git a/demo/src/UI/mvc/LayerManager.ts b/demo/src/UI/mvc/LayerManager.ts deleted file mode 100644 index 7f9b4e5c..00000000 --- a/demo/src/UI/mvc/LayerManager.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 视图类型 - */ -enum viewLayer { - pop, -} - -/** - * 视图管理器 - */ -class LayerManager { - private static _single: LayerManager; - public static getInstance(): LayerManager{ - if (!this._single) this._single = new LayerManager(); - - return this._single; - } - - private _stage: egret.Stage; - /** 弹窗层 */ - public popLayer: egret.DisplayObjectContainer; - public tipsLayer: egret.DisplayObjectContainer; - /** 获取舞台 */ - public get stage(){ - return this._stage; - } - - public init(stage: egret.Stage){ - this._stage = stage; - - this.popLayer = new egret.DisplayObjectContainer(); - this.tipsLayer = new egret.DisplayObjectContainer(); - - this._stage.addChild(this.popLayer); - this._stage.addChild(this.tipsLayer); - } - - /** - * 添加到layer上 - * @param view - */ - public addLayerToView(view: BaseView){ - let layerName = viewLayer[view.viewLayer] + "Layer"; - this[layerName].addChild(view); - } -} \ No newline at end of file diff --git a/demo/src/UI/mvc/ViewManager.ts b/demo/src/UI/mvc/ViewManager.ts deleted file mode 100644 index 979e4e27..00000000 --- a/demo/src/UI/mvc/ViewManager.ts +++ /dev/null @@ -1,125 +0,0 @@ -/** 窗口控制器 */ -class ViewManager { - private static _single: ViewManager; - /** 已打开的列表 存储视图实例 */ - private _openDic: BaseView[] = []; - /** 跳过关闭的列表 用于主视图 存储视图类型 */ - private _skipCloseDic = []; - /** 层级管理器 */ - private _layerManager: LayerManager; - - public static getInstance(): ViewManager{ - if (!this._single) this._single = new ViewManager(); - - return this._single; - } - - constructor(){ - this._layerManager = LayerManager.getInstance(); - } - - /** - * 打开界面 - * @param viewCls 视图类型 - * @param viewData 视图数据 - */ - public openView(viewCls, viewData?: any): Promise{ - return new Promise((resolve, reject)=>{ - let newView: BaseView = this.getView(viewCls); - if (!newView) newView = new viewCls(); - - if (this.isOpenView(viewCls)){ - newView.refresh(viewData); - return; - } - - this._openDic.push(newView); - FguiUtils.load(newView.name).then(()=>{ - newView.init(); - newView.baseShow(viewData); - newView.show(); - - this._layerManager.addLayerToView(newView); - resolve(); - }).catch(()=>{ - this._openDic.remove(newView); - newView.destroy(); - newView = null; - reject(); - }); - }); - } - - /** - * 根据视图关闭 - * @param view 视图实例 - */ - public closeView(view: BaseView){ - let wantToCloseView = this._openDic.firstOrDefault(a => { - return a == view; - }) - if (wantToCloseView) { - this._openDic.remove(wantToCloseView); - - wantToCloseView.destroy(); - wantToCloseView = null; - } - } - - /** - * 关闭所有视图 - */ - public closeAll(){ - for (let z = 0; z < this._openDic.length; z++) { - let element = this._openDic[z]; - let canClose = true; - for (let i = 0; i < this._skipCloseDic.length; i ++){ - if (element == this.getView(this._skipCloseDic[i])){ - canClose = false; - } - } - if (canClose) { - this.closeView(element); - z--; - } - } - } - - /** - * 根据视图类型关闭窗口 - * @param viewCls 视图类型 - */ - public closeViewByCls(viewCls){ - let wantToCloseView = this._openDic.firstOrDefault(a => { - return a instanceof viewCls; - }) - if (wantToCloseView) { - this._openDic.remove(wantToCloseView); - wantToCloseView.destroy(); - wantToCloseView = null; - } - } - - /** - * 根据视图类型获得窗口 - * 如果窗口未打开则返回null - * @param viewCls 视图类型 - */ - public getView(viewCls: new () => T): T{ - let result: any = this._openDic.firstOrDefault(a => { - return a instanceof viewCls; - }); - - return result as T; - } - - /** - * 根据视图类型获得窗口是否打开 - * @param viewCls - */ - public isOpenView(viewCls: any): boolean { - return this._openDic.findIndex(a => { - return a instanceof viewCls; - }) != -1; - } -} \ No newline at end of file diff --git a/demo/src/UI/sc/ScControl.ts b/demo/src/UI/sc/ScControl.ts deleted file mode 100644 index 090613a6..00000000 --- a/demo/src/UI/sc/ScControl.ts +++ /dev/null @@ -1,27 +0,0 @@ -module sc { - export class ScControl { - private _eventManager: EventManager; - private _viewManager: ViewManager; - private static single: ScControl; - public static getInstance(){ - if (!this.single) this.single = new ScControl(); - - return this.single; - } - - constructor(){ - this.addEvents(); - } - - private addEvents(){ - this._eventManager = EventManager.getInstance(); - this._viewManager = ViewManager.getInstance(); - // 事件监听 - this._eventManager.addListener(ScEvents.OPENVIEW, this.openView, this); - } - - private openView(){ - this._viewManager.openView(ScView); - } - } -} \ No newline at end of file diff --git a/demo/src/UI/sc/ScEvents.ts b/demo/src/UI/sc/ScEvents.ts deleted file mode 100644 index d6d8e5a0..00000000 --- a/demo/src/UI/sc/ScEvents.ts +++ /dev/null @@ -1,5 +0,0 @@ -module sc { - export module ScEvents { - export const OPENVIEW = Symbol(); - } -} \ No newline at end of file diff --git a/demo/src/UI/sc/ScView.ts b/demo/src/UI/sc/ScView.ts deleted file mode 100644 index f5377b93..00000000 --- a/demo/src/UI/sc/ScView.ts +++ /dev/null @@ -1,82 +0,0 @@ -module sc { - export class ScView extends BaseView { - private _ui: FUI.sc.UI_View_sc; - private _sceneList: SceneData[] = [ - new SceneData("空白场景", samples.BasicScene), - new SceneData("Tiled Tiles", samples.AnimatedTilesScene), - new SceneData("Linecasting", samples.LineCastingScene), - new SceneData("Ninja Adventure", samples.NinjaAdventureScene), - new SceneData("GOAP", samples.GoapScene), - ]; - - private _transitionList: TransitionData[] = [ - new TransitionData("渐变", es.FadeTransition), - new TransitionData("wind", es.WindTransition), - ]; - - constructor() { - super("sc"); - } - - public init() { - this._ui = this._fuiView = FUI.sc.UI_View_sc.createInstance(); - this.addChild(this._ui.displayObject); - super.init(); - } - - public show() { - this._ui.m_list_sc.callbackThisObj = this; - this._ui.m_list_sc.itemRenderer = this.scItemRender; - this._ui.m_list_sc.numItems = this._sceneList.length; - - for (let i = 0; i < this._transitionList.length; i ++){ - this._ui.m_combo_transition.items.push(this._transitionList[i].name); - } - this._ui.m_combo_transition.selectedIndex = 0; - } - - public scItemRender(index: number, item: FUI.sc.UI_btn_sc){ - let sceneData = this._sceneList[index]; - item.m_name.text = sceneData.name; - item.data = sceneData.type; - item.addClickListener(this.scItemOnClick, this); - } - - private scItemOnClick(evt: egret.Event){ - let data = evt.currentTarget.data; - let currentTransition = this._transitionList[this._ui.m_combo_transition.selectedIndex].type; - es.Core.startSceneTransition(new currentTransition(()=>{ - es.Core.scene.camera.position = es.Vector2.zero; - return new data(); - })); - } - - public destroy() { - if (this._ui) { - this._ui.dispose(); - this._ui = null; - } - super.destroy(); - } - } - - export class SceneData { - public name: string; - public type: any; - - constructor(name: string, type: any){ - this.name = name; - this.type = type; - } - } - - export class TransitionData { - public name: string; - public type: any; - - constructor(name: string, type: any){ - this.name = name; - this.type = type; - } - } -} \ No newline at end of file diff --git a/demo/template/runtime/native_loader.js b/demo/template/runtime/native_loader.js deleted file mode 100644 index ad942850..00000000 --- a/demo/template/runtime/native_loader.js +++ /dev/null @@ -1,8 +0,0 @@ -require("launcher/native_require.js"); - -egret_native.egtMain = function () { - egret_native.nativeType = "native"; - - egret_native.egretInit(); - egret_native.egretStart(); -}; diff --git a/demo/template/runtime/native_require.js b/demo/template/runtime/native_require.js deleted file mode 100644 index 3df96bc9..00000000 --- a/demo/template/runtime/native_require.js +++ /dev/null @@ -1,53 +0,0 @@ -var manifest = JSON.parse(egret_native.readFileSync("manifest.json")); -var game_file_list = manifest.initial.concat(manifest.game); - -var window = this; - -egret_native.setSearchPaths([""]); - -egret_native.requireFiles = function () { - for (var key in game_file_list) { - var src = game_file_list[key]; - require(src); - } -}; - -egret_native.egretInit = function () { - if(egret_native.featureEnable) { - //控制一些优化方案是否开启 - //Control whether some optimization options are open - var result = egret_native.featureEnable({ - - }); - } - egret_native.requireFiles(); - egret.dom = {}; - egret.dom.drawAsCanvas = function () { - }; -}; - -egret_native.egretStart = function () { - var option = { - //以下为自动修改,请勿修改 - //The following is automatically modified, please do not modify - //----auto option start---- - entryClassName: "Main", - frameRate: 60, - scaleMode: "fixedWidth", - contentWidth: 640, - contentHeight: 1136, - showPaintRect: false, - showFPS: false, - fpsStyles: "x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9", - showLog: false, - logFilter: "", - maxTouches: 2, - textureScaleFactor: 1 - //----auto option end---- - }; - - egret.native.NativePlayer.option = option; - egret.runEgret(); - egret_native.Label.createLabel("/system/fonts/DroidSansFallback.ttf", 20, "", 0); - egret_native.EGTView.preSetOffScreenBufferEnable(true); -}; \ No newline at end of file diff --git a/demo/template/runtime/runtime_loader.js b/demo/template/runtime/runtime_loader.js deleted file mode 100644 index 5b5f76bf..00000000 --- a/demo/template/runtime/runtime_loader.js +++ /dev/null @@ -1,8 +0,0 @@ -require("launcher/native_require.js"); - -egret_native.egtMain = function () { - egret_native.nativeType = "runtime"; - - egret_native.egretInit(); - egret_native.egretStart(); -}; \ No newline at end of file diff --git a/demo/template/web/index.html b/demo/template/web/index.html deleted file mode 100644 index 9fe15208..00000000 --- a/demo/template/web/index.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - Egret - - - - - - - - - - -
      -
      - - - - \ No newline at end of file diff --git a/demo/tsconfig.json b/demo/tsconfig.json deleted file mode 100644 index 23bf9dbf..00000000 --- a/demo/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "outDir": "bin-debug", - "sourceMap": true, - "experimentalDecorators": true, - "emitDecoratorMetadata": true, - "lib": [ - "es5", - "dom", - "es2015.promise", - "es6" - ], - "types": [] - }, - "include": [ - "src", - "libs" - ] -} \ No newline at end of file diff --git a/demo/wingProperties.json b/demo/wingProperties.json deleted file mode 100644 index 31cf46d1..00000000 --- a/demo/wingProperties.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "resourcePlugin":{ - "configs":[{ - "configPath":"resource/default.res.json", - "relativePath":"resource/" - }] - }, - "theme":"resource/default.thm.json" -} \ No newline at end of file diff --git a/demo_fgui/.objs/fonts.json b/demo_fgui/.objs/fonts.json deleted file mode 100644 index e69de29b..00000000 diff --git a/demo_fgui/.objs/metas/m4sln17a/k7mf0.info b/demo_fgui/.objs/metas/m4sln17a/k7mf0.info deleted file mode 100644 index 9e26dfee..00000000 --- a/demo_fgui/.objs/metas/m4sln17a/k7mf0.info +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/demo_fgui/.objs/workspace.json b/demo_fgui/.objs/workspace.json deleted file mode 100644 index 67374ac6..00000000 --- a/demo_fgui/.objs/workspace.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "doc.openedDocs": [ - "ui://m4sln17ak7mf0", - "ui://m4sln17ajde15" - ], - "libview.iconScale": 0, - "auxline1": true, - "doc.activeDoc": "ui://m4sln17ak7mf0", - "libview.twoColumn": false, - "libview.currentGroup": "", - "libview.firstColumnWidth": 459, - "auxline2": true, - "backgroundColor": 6710886, - "canvasColor": 10066329, - "libview.expandedNodes": [ - "m4sln17a", - "/", - "m4sln17a", - "/资源/", - "m4sln17a", - "/组件/" - ] -} \ No newline at end of file diff --git a/demo_fgui/assets/common/com_tips.xml b/demo_fgui/assets/common/com_tips.xml deleted file mode 100644 index 560d2c34..00000000 --- a/demo_fgui/assets/common/com_tips.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/demo_fgui/assets/common/package.xml b/demo_fgui/assets/common/package.xml deleted file mode 100644 index d6962ec1..00000000 --- a/demo_fgui/assets/common/package.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/demo_fgui/assets/loading/View_loading.xml b/demo_fgui/assets/loading/View_loading.xml deleted file mode 100644 index 88614486..00000000 --- a/demo_fgui/assets/loading/View_loading.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/demo_fgui/assets/loading/package.xml b/demo_fgui/assets/loading/package.xml deleted file mode 100644 index f3c57e05..00000000 --- a/demo_fgui/assets/loading/package.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/demo_fgui/assets/loading/组件/pg_loading.xml b/demo_fgui/assets/loading/组件/pg_loading.xml deleted file mode 100644 index e977c372..00000000 --- a/demo_fgui/assets/loading/组件/pg_loading.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/demo_fgui/assets/sc/View_sc.xml b/demo_fgui/assets/sc/View_sc.xml deleted file mode 100644 index 87c868b9..00000000 --- a/demo_fgui/assets/sc/View_sc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/demo_fgui/assets/sc/package.xml b/demo_fgui/assets/sc/package.xml deleted file mode 100644 index 0c878a8b..00000000 --- a/demo_fgui/assets/sc/package.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/demo_fgui/assets/sc/组件/btn_sc.xml b/demo_fgui/assets/sc/组件/btn_sc.xml deleted file mode 100644 index 0688b85b..00000000 --- a/demo_fgui/assets/sc/组件/btn_sc.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -