diff --git a/package-lock.json b/package-lock.json index 20e43479..365ee52e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -914,11 +914,6 @@ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==" }, - "events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==" - }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -1526,11 +1521,6 @@ "queue-microtask": "^1.2.2" } }, - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" - }, "semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", @@ -1832,20 +1822,6 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, - "xml2js": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", - "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", - "requires": { - "sax": ">=0.6.0", - "xmlbuilder": "~11.0.0" - } - }, - "xmlbuilder": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", - "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" - }, "y18n": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", diff --git a/package.json b/package.json index de47cbbe..b44dfb49 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,9 @@ "@pixi/canvas-renderer": "^6.1.0", "@pixi/extract": "^6.1.0", "@pixi/filter-adjustment": "^4.1.3", - "events": "^3.3.0", "pako": "^2.0.4", "pixi.js": "^6.1.0", - "tslib": "^2.3.0", - "xml2js": "^0.4.23" + "tslib": "^2.3.0" }, "devDependencies": { "@types/node": "^14.17.7", diff --git a/src/nitro/avatar/AvatarRenderManager.ts b/src/nitro/avatar/AvatarRenderManager.ts index f99c19b8..f6e703ef 100644 --- a/src/nitro/avatar/AvatarRenderManager.ts +++ b/src/nitro/avatar/AvatarRenderManager.ts @@ -1,4 +1,3 @@ -import { Parser } from 'xml2js'; import { IAssetManager } from '../../core/asset/IAssetManager'; import { NitroManager } from '../../core/common/NitroManager'; import { NitroEvent } from '../../core/events/NitroEvent'; @@ -21,6 +20,7 @@ import { IAvatarFigureContainer } from './IAvatarFigureContainer'; import { IAvatarImage } from './IAvatarImage'; import { IAvatarImageListener } from './IAvatarImageListener'; import { IAvatarRenderManager } from './IAvatarRenderManager'; +import { IFigureData } from './interfaces'; import { PlaceHolderAvatarImage } from './PlaceHolderAvatarImage'; import { AvatarStructureDownload } from './structure/AvatarStructureDownload'; import { IFigurePartSet } from './structure/figure/IFigurePartSet'; @@ -194,18 +194,13 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa private loadFigureData(): void { - const defaultFigureData = Nitro.instance.getConfiguration('avatar.default.figuredata'); + const defaultFigureData = (Nitro.instance.getConfiguration('avatar.default.figuredata') as IFigureData); if(defaultFigureData) { - const parser = new Parser(); + if(!defaultFigureData) throw new Error('invalid_default_figure_data'); - parser.parseString(defaultFigureData, (err: Error, results: any) => - { - if(err || !results || !results.figuredata) throw new Error('invalid_default_figure_data'); - - if(this._structure) this._structure.initFigureData(results.figuredata); - }); + if(this._structure) this._structure.initFigureData(defaultFigureData); } const structureDownloader = new AvatarStructureDownload(Nitro.instance.getConfiguration('avatar.figuredata.url'), (this._structure.figureData as IFigureSetData)); diff --git a/src/nitro/avatar/AvatarStructure.ts b/src/nitro/avatar/AvatarStructure.ts index 1ebe4a2c..ffa0fdc9 100644 --- a/src/nitro/avatar/AvatarStructure.ts +++ b/src/nitro/avatar/AvatarStructure.ts @@ -16,6 +16,7 @@ import { AvatarModelGeometry } from './geometry/AvatarModelGeometry'; import { IAvatarFigureContainer } from './IAvatarFigureContainer'; import { IAvatarImage } from './IAvatarImage'; import { IAvatarRenderManager } from './IAvatarRenderManager'; +import { IFigureData } from './interfaces'; import { AnimationAction } from './structure/animation/AnimationAction'; import { AvatarAnimationFrame } from './structure/animation/AvatarAnimationFrame'; import { AvatarAnimationData } from './structure/AvatarAnimationData'; @@ -115,16 +116,16 @@ export class AvatarStructure extends EventDispatcher return this._animationData.parse(k); } - public initFigureData(k: any): boolean + public initFigureData(k: IFigureData): boolean { if(!k) return false; return this._figureData.parse(k); } - public injectFigureData(data: any): void + public injectFigureData(data: IFigureData): void { - this._figureData.injectXML(data); + this._figureData.injectJSON(data); } public registerAnimations(k: IAssetManager, _arg_2: string = 'fx', _arg_3: number = 200): void diff --git a/src/nitro/avatar/interfaces/figuredata/IFigureData.ts b/src/nitro/avatar/interfaces/figuredata/IFigureData.ts new file mode 100644 index 00000000..86e79017 --- /dev/null +++ b/src/nitro/avatar/interfaces/figuredata/IFigureData.ts @@ -0,0 +1,8 @@ +import { IFigureDataPalette } from './IFigureDataPalette'; +import { IFigureDataSetType } from './IFigureDataSetType'; + +export interface IFigureData +{ + palettes?: IFigureDataPalette[]; + setTypes?: IFigureDataSetType[]; +} diff --git a/src/nitro/avatar/interfaces/figuredata/IFigureDataColor.ts b/src/nitro/avatar/interfaces/figuredata/IFigureDataColor.ts new file mode 100644 index 00000000..535dead5 --- /dev/null +++ b/src/nitro/avatar/interfaces/figuredata/IFigureDataColor.ts @@ -0,0 +1,8 @@ +export interface IFigureDataColor +{ + id?: number; + index?: number; + club?: number; + selectable?: boolean; + hexCode?: string; +} diff --git a/src/nitro/avatar/interfaces/figuredata/IFigureDataHiddenLayer.ts b/src/nitro/avatar/interfaces/figuredata/IFigureDataHiddenLayer.ts new file mode 100644 index 00000000..80f42e69 --- /dev/null +++ b/src/nitro/avatar/interfaces/figuredata/IFigureDataHiddenLayer.ts @@ -0,0 +1,4 @@ +export interface IFigureDataHiddenLayer +{ + partType?: string; +} diff --git a/src/nitro/avatar/interfaces/figuredata/IFigureDataPalette.ts b/src/nitro/avatar/interfaces/figuredata/IFigureDataPalette.ts new file mode 100644 index 00000000..f83fa067 --- /dev/null +++ b/src/nitro/avatar/interfaces/figuredata/IFigureDataPalette.ts @@ -0,0 +1,7 @@ +import { IFigureDataColor } from './IFigureDataColor'; + +export interface IFigureDataPalette +{ + id?: number; + colors?: IFigureDataColor[]; +} diff --git a/src/nitro/avatar/interfaces/figuredata/IFigureDataPart.ts b/src/nitro/avatar/interfaces/figuredata/IFigureDataPart.ts new file mode 100644 index 00000000..e57ef476 --- /dev/null +++ b/src/nitro/avatar/interfaces/figuredata/IFigureDataPart.ts @@ -0,0 +1,8 @@ +export interface IFigureDataPart +{ + id?: number; + type?: string; + colorable?: boolean; + index?: number; + colorindex?: number; +} diff --git a/src/nitro/avatar/interfaces/figuredata/IFigureDataSet.ts b/src/nitro/avatar/interfaces/figuredata/IFigureDataSet.ts new file mode 100644 index 00000000..f3c89d92 --- /dev/null +++ b/src/nitro/avatar/interfaces/figuredata/IFigureDataSet.ts @@ -0,0 +1,15 @@ +import { IFigureDataHiddenLayer } from './IFigureDataHiddenLayer'; +import { IFigureDataPart } from './IFigureDataPart'; + +export interface IFigureDataSet +{ + id?: number; + gender?: string; + club?: number; + colorable?: boolean; + selectable?: boolean; + preselectable?: boolean; + sellable?: boolean; + parts?: IFigureDataPart[]; + hiddenLayers?: IFigureDataHiddenLayer[]; +} diff --git a/src/nitro/avatar/interfaces/figuredata/IFigureDataSetType.ts b/src/nitro/avatar/interfaces/figuredata/IFigureDataSetType.ts new file mode 100644 index 00000000..d9a2d972 --- /dev/null +++ b/src/nitro/avatar/interfaces/figuredata/IFigureDataSetType.ts @@ -0,0 +1,12 @@ +import { IFigureDataSet } from './IFigureDataSet'; + +export interface IFigureDataSetType +{ + type?: string; + paletteId?: number; + mandatory_m_0?: boolean; + mandatory_f_0?: boolean; + mandatory_m_1?: boolean; + mandatory_f_1?: boolean; + sets?: IFigureDataSet[]; +} diff --git a/src/nitro/avatar/interfaces/figuredata/index.ts b/src/nitro/avatar/interfaces/figuredata/index.ts new file mode 100644 index 00000000..579987b7 --- /dev/null +++ b/src/nitro/avatar/interfaces/figuredata/index.ts @@ -0,0 +1,7 @@ +export * from './IFigureData'; +export * from './IFigureDataColor'; +export * from './IFigureDataHiddenLayer'; +export * from './IFigureDataPalette'; +export * from './IFigureDataPart'; +export * from './IFigureDataSet'; +export * from './IFigureDataSetType'; diff --git a/src/nitro/avatar/interfaces/index.ts b/src/nitro/avatar/interfaces/index.ts new file mode 100644 index 00000000..c44ce3e6 --- /dev/null +++ b/src/nitro/avatar/interfaces/index.ts @@ -0,0 +1 @@ +export * from './figuredata'; diff --git a/src/nitro/avatar/structure/AvatarAnimationData.ts b/src/nitro/avatar/structure/AvatarAnimationData.ts index 433b4f3b..1ac42316 100644 --- a/src/nitro/avatar/structure/AvatarAnimationData.ts +++ b/src/nitro/avatar/structure/AvatarAnimationData.ts @@ -28,7 +28,7 @@ export class AvatarAnimationData implements IFigureSetData return true; } - public appendXML(k: any): boolean + public appendJSON(k: any): boolean { for(const _local_2 of k.action) { diff --git a/src/nitro/avatar/structure/AvatarStructureDownload.ts b/src/nitro/avatar/structure/AvatarStructureDownload.ts index 6adb935b..39aedf97 100644 --- a/src/nitro/avatar/structure/AvatarStructureDownload.ts +++ b/src/nitro/avatar/structure/AvatarStructureDownload.ts @@ -1,4 +1,3 @@ -import { Parser } from 'xml2js'; import { NitroLogger } from '../../../core/common/logger/NitroLogger'; import { EventDispatcher } from '../../../core/events/EventDispatcher'; import { NitroEvent } from '../../../core/events/NitroEvent'; @@ -31,16 +30,13 @@ export class AvatarStructureDownload extends EventDispatcher request.onloadend = e => { - const parser = new Parser(); + const response = request.responseText; - parser.parseString(request.responseText, (err: Error, results: any) => - { - if(err || !results || !results.figuredata) throw new Error('invalid_figure_data'); + if(!response || !response.length) throw new Error('invalid_figure_data'); - if(this._dataReceiver) this._dataReceiver.appendXML(results.figuredata); + if(this._dataReceiver) this._dataReceiver.appendJSON(JSON.parse(response)); - this.dispatchEvent(new NitroEvent(AvatarStructureDownload.AVATAR_STRUCTURE_DONE)); - }); + this.dispatchEvent(new NitroEvent(AvatarStructureDownload.AVATAR_STRUCTURE_DONE)); }; request.onerror = e => diff --git a/src/nitro/avatar/structure/FigureSetData.ts b/src/nitro/avatar/structure/FigureSetData.ts index 90328880..5fe429c5 100644 --- a/src/nitro/avatar/structure/FigureSetData.ts +++ b/src/nitro/avatar/structure/FigureSetData.ts @@ -1,3 +1,4 @@ +import { IFigureData } from '../interfaces'; import { IFigurePartSet } from './figure/IFigurePartSet'; import { IPalette } from './figure/IPalette'; import { ISetType } from './figure/ISetType'; @@ -22,11 +23,11 @@ export class FigureSetData implements IFigureSetData, IStructureData } - public parse(data: any): boolean + public parse(data: IFigureData): boolean { if(!data) return false; - for(const palette of data.colors[0].palette) + for(const palette of data.palettes) { const newPalette = new Palette(palette); @@ -35,7 +36,7 @@ export class FigureSetData implements IFigureSetData, IStructureData this._palettes.set(newPalette.id.toString(), newPalette); } - for(const set of data.sets[0].settype) + for(const set of data.setTypes) { const newSet = new SetType(set); @@ -47,57 +48,39 @@ export class FigureSetData implements IFigureSetData, IStructureData return true; } - public injectXML(k: any): void + public injectJSON(data: IFigureData): void { - for(const _local_2 of k.sets[0].settype) + for(const setType of data.setTypes) { - const setType = this._setTypes.get(_local_2['$'].type); + const existingSetType = this._setTypes.get(setType.type); - if(setType) - { - setType.cleanUp(_local_2); - } - else - { - this._setTypes.set(_local_2['$'].type, new SetType(_local_2)); - } + if(existingSetType) existingSetType.cleanUp(setType); + else this._setTypes.set(setType.type, new SetType(setType)); } - this.appendXML(k); + this.appendJSON(data); } - public appendXML(k: any): boolean + public appendJSON(data: IFigureData): boolean { - if(!k) return false; + if(!data) return false; - for(const _local_2 of k.colors[0].palette) + for(const palette of data.palettes) { - const id = _local_2['$'].id.toString(); - const _local_4 = this._palettes.get(id); + const id = palette.id.toString(); + const existingPalette = this._palettes.get(id); - if(!_local_4) - { - this._palettes.set(id, new Palette(_local_2)); - } - else - { - _local_4.append(_local_2); - } + if(!existingPalette) this._palettes.set(id, new Palette(palette)); + else existingPalette.append(palette); } - for(const _local_3 of k.sets[0].settype) + for(const setType of data.setTypes) { - const type = _local_3['$'].type; - const _local_5 = this._setTypes.get(type); + const type = setType.type; + const existingSetType = this._setTypes.get(type); - if(!_local_5) - { - this._setTypes.set(type, new SetType(_local_3)); - } - else - { - _local_5.append(_local_3); - } + if(!existingSetType) this._setTypes.set(type, new SetType(setType)); + else existingSetType.append(setType); } return false; diff --git a/src/nitro/avatar/structure/IFigureSetData.ts b/src/nitro/avatar/structure/IFigureSetData.ts index 5c0f6492..fb747e10 100644 --- a/src/nitro/avatar/structure/IFigureSetData.ts +++ b/src/nitro/avatar/structure/IFigureSetData.ts @@ -1,5 +1,7 @@ -export interface IFigureSetData +import { IFigureData } from '../interfaces'; + +export interface IFigureSetData { parse(data: any): boolean; - appendXML(data: any): boolean; + appendJSON(data: IFigureData): boolean; } diff --git a/src/nitro/avatar/structure/IStructureData.ts b/src/nitro/avatar/structure/IStructureData.ts index 44ab14f1..e8506c3c 100644 --- a/src/nitro/avatar/structure/IStructureData.ts +++ b/src/nitro/avatar/structure/IStructureData.ts @@ -5,7 +5,7 @@ import { ISetType } from './figure/ISetType'; export interface IStructureData { parse(data: any): boolean; - appendXML(k: any): boolean; + appendJSON(k: any): boolean; getSetType(_arg_1: string): ISetType; getPalette(_arg_1: number): IPalette; getFigurePartSet(_arg_1: number): IFigurePartSet; diff --git a/src/nitro/avatar/structure/PartSetsData.ts b/src/nitro/avatar/structure/PartSetsData.ts index dbd5971e..6f052e8e 100644 --- a/src/nitro/avatar/structure/PartSetsData.ts +++ b/src/nitro/avatar/structure/PartSetsData.ts @@ -40,7 +40,7 @@ export class PartSetsData implements IFigureSetData return true; } - public appendXML(data: any): boolean + public appendJSON(data: any): boolean { if(data.partSet && (data.partSet.length > 0)) { diff --git a/src/nitro/avatar/structure/figure/FigurePart.ts b/src/nitro/avatar/structure/figure/FigurePart.ts index f94df787..8214b973 100644 --- a/src/nitro/avatar/structure/figure/FigurePart.ts +++ b/src/nitro/avatar/structure/figure/FigurePart.ts @@ -1,3 +1,4 @@ +import { IFigureDataPart } from '../../interfaces'; import { IFigurePart } from './IFigurePart'; export class FigurePart implements IFigurePart @@ -9,24 +10,16 @@ export class FigurePart implements IFigurePart private _colorLayerIndex: number; private _paletteMapId: number; - constructor(data: any) + constructor(data: IFigureDataPart) { if(!data) throw new Error('invalid_data'); - this._id = parseInt(data['$'].id); - this._type = data['$'].type; - this._index = parseInt(data['$'].index); - this._colorLayerIndex = parseInt(data['$'].colorindex); - - const paletteMapId = data['$'].palettemapid; - - if(!isNaN(paletteMapId)) this._paletteMapId = parseInt(paletteMapId); - else this._paletteMapId = -1; - - const breed = data['$'].palettemapid; - - if(!isNaN(breed)) this._breed = parseInt(breed); - else this._breed = -1; + this._id = data.id; + this._type = data.type; + this._index = data.index; + this._colorLayerIndex = data.colorindex; + this._paletteMapId = -1; + this._breed = -1; } public dispose(): void diff --git a/src/nitro/avatar/structure/figure/FigurePartSet.ts b/src/nitro/avatar/structure/figure/FigurePartSet.ts index bb7392b0..aafcde5c 100644 --- a/src/nitro/avatar/structure/figure/FigurePartSet.ts +++ b/src/nitro/avatar/structure/figure/FigurePartSet.ts @@ -1,3 +1,4 @@ +import { IFigureDataSet } from '../../interfaces'; import { FigurePart } from './FigurePart'; import { IFigurePart } from './IFigurePart'; import { IFigurePartSet } from './IFigurePartSet'; @@ -15,22 +16,22 @@ export class FigurePartSet implements IFigurePartSet private _isPreSelectable: boolean; private _isSellable: boolean; - constructor(type: string, data: any) + constructor(type: string, data: IFigureDataSet) { if(!type || !data) throw new Error('invalid_data'); - this._id = parseInt(data['$'].id); + this._id = data.id; this._type = type; - this._gender = data['$'].gender; - this._clubLevel = parseInt(data['$'].club); - this._isColorable = parseInt(data['$'].colorable) === 1; - this._isSelectable = parseInt(data['$'].selectable) === 1; + this._gender = data.gender; + this._clubLevel = data.club; + this._isColorable = data.colorable; + this._isSelectable = data.selectable; this._parts = []; this._hiddenLayers = []; - this._isPreSelectable = parseInt(data['$'].preselectable) === 1; - this._isSellable = parseInt(data['$'].sellable) === 1; + this._isPreSelectable = data.preselectable; + this._isSellable = data.sellable; - for(const part of data.part) + for(const part of data.parts) { const newPart = new FigurePart(part); const partIndex = this.getPartIndex(newPart); @@ -39,11 +40,9 @@ export class FigurePartSet implements IFigurePartSet else this._parts.push(newPart); } - if(data.hiddenlayers) + if(data.hiddenLayers) { - const hiddenLayers = data.hiddenlayers[0]; - - for(const layer of hiddenLayers.layer) this._hiddenLayers.push(layer['$'].parttype); + for(const hiddenLayer of data.hiddenLayers) this._hiddenLayers.push(hiddenLayer.partType); } } diff --git a/src/nitro/avatar/structure/figure/Palette.ts b/src/nitro/avatar/structure/figure/Palette.ts index d461e2a5..281bd2ac 100644 --- a/src/nitro/avatar/structure/figure/Palette.ts +++ b/src/nitro/avatar/structure/figure/Palette.ts @@ -1,3 +1,4 @@ +import { IFigureDataPalette } from '../../interfaces'; import { IPalette } from './IPalette'; import { IPartColor } from './IPartColor'; import { PartColor } from './PartColor'; @@ -7,23 +8,23 @@ export class Palette implements IPalette private _id: number; private _colors: Map; - constructor(data: any) + constructor(data: IFigureDataPalette) { if(!data) throw new Error('invalid_data'); - this._id = parseInt(data['$'].id); + this._id = data.id; this._colors = new Map(); this.append(data); } - public append(data: any): void + public append(data: IFigureDataPalette): void { - for(const color of data.color) + for(const color of data.colors) { const newColor = new PartColor(color); - this._colors.set(color['$'].id.toString(), newColor); + this._colors.set(color.id.toString(), newColor); } } diff --git a/src/nitro/avatar/structure/figure/PartColor.ts b/src/nitro/avatar/structure/figure/PartColor.ts index 9102d025..06e558b5 100644 --- a/src/nitro/avatar/structure/figure/PartColor.ts +++ b/src/nitro/avatar/structure/figure/PartColor.ts @@ -1,3 +1,4 @@ +import { IFigureDataColor } from '../../interfaces'; import { IPartColor } from './IPartColor'; export class PartColor implements IPartColor @@ -8,15 +9,15 @@ export class PartColor implements IPartColor private _isSelectable: boolean; private _rgb: number; - constructor(data: any) + constructor(data: IFigureDataColor) { if(!data) throw new Error('invalid_data'); - this._id = parseInt(data['$'].id); - this._index = parseInt(data['$'].index); - this._clubLevel = parseInt(data['$'].club); - this._isSelectable = parseInt(data['$'].selectable) === 1; - this._rgb = parseInt('0x' + data['_'], 16); + this._id = data.id; + this._index = data.index; + this._clubLevel = data.club; + this._isSelectable = data.selectable; + this._rgb = parseInt('0x' + data.hexCode, 16); } public get id(): number diff --git a/src/nitro/avatar/structure/figure/SetType.ts b/src/nitro/avatar/structure/figure/SetType.ts index 21ce8e56..b1abd899 100644 --- a/src/nitro/avatar/structure/figure/SetType.ts +++ b/src/nitro/avatar/structure/figure/SetType.ts @@ -1,4 +1,5 @@ import { AdvancedMap } from '../../../../core/utils/AdvancedMap'; +import { IFigureDataSetType } from '../../interfaces'; import { FigurePartSet } from './FigurePartSet'; import { IFigurePartSet } from './IFigurePartSet'; import { ISetType } from './ISetType'; @@ -10,15 +11,15 @@ export class SetType implements ISetType private _isMandatory: { [index: string]: boolean[] }; private _partSets: AdvancedMap; - constructor(data: any) + constructor(data: IFigureDataSetType) { if(!data) throw new Error('invalid_data'); - this._type = data['$'].type; - this._paletteId = parseInt(data['$'].paletteid); + this._type = data.type; + this._paletteId = data.paletteId; this._isMandatory = {}; - this._isMandatory['F'] = [ parseInt(data['$'].mand_f_0) === 1, parseInt(data['$'].mand_f_1) === 1 ]; - this._isMandatory['M'] = [ (parseInt(data['$'].mand_m_0) === 1), (parseInt(data['$'].mand_m_1) === 1) ]; + this._isMandatory['F'] = [ data.mandatory_f_0, data.mandatory_f_1 ]; + this._isMandatory['M'] = [ data.mandatory_m_0, data.mandatory_m_1 ]; this._partSets = new AdvancedMap(); this.append(data); @@ -36,27 +37,27 @@ export class SetType implements ISetType this._partSets = null; } - public cleanUp(k: any): void + public cleanUp(data: IFigureDataSetType): void { - for(const _local_2 of k) + for(const set of data.sets) { - const _local_3 = (_local_2.id as string); - const _local_4 = (this._partSets.getValue(_local_3) as FigurePartSet); + const setId = set.id.toString(); + const partSet = (this._partSets.getValue(setId) as FigurePartSet); - if(_local_4) + if(partSet) { - _local_4.dispose(); + partSet.dispose(); - this._partSets.remove(_local_3); + this._partSets.remove(setId); } } } - public append(k: any): void + public append(setType: IFigureDataSetType): void { - if(!k || !k.set) return; + if(!setType || !setType.sets) return; - for(const set of k.set) this._partSets.add(set['$'].id, new FigurePartSet(this._type, set)); + for(const set of setType.sets) this._partSets.add(set.id.toString(), new FigurePartSet(this._type, set)); } public getDefaultPartSet(k: string): IFigurePartSet