mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-26 17:30:52 +01:00
Switch figuredata to json
This commit is contained in:
parent
6f04f28261
commit
90fe77abd1
24
package-lock.json
generated
24
package-lock.json
generated
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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<string>('avatar.default.figuredata');
|
||||
const defaultFigureData = (Nitro.instance.getConfiguration<string>('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<string>('avatar.figuredata.url'), (this._structure.figureData as IFigureSetData));
|
||||
|
@ -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
|
||||
|
8
src/nitro/avatar/interfaces/figuredata/IFigureData.ts
Normal file
8
src/nitro/avatar/interfaces/figuredata/IFigureData.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { IFigureDataPalette } from './IFigureDataPalette';
|
||||
import { IFigureDataSetType } from './IFigureDataSetType';
|
||||
|
||||
export interface IFigureData
|
||||
{
|
||||
palettes?: IFigureDataPalette[];
|
||||
setTypes?: IFigureDataSetType[];
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
export interface IFigureDataColor
|
||||
{
|
||||
id?: number;
|
||||
index?: number;
|
||||
club?: number;
|
||||
selectable?: boolean;
|
||||
hexCode?: string;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
export interface IFigureDataHiddenLayer
|
||||
{
|
||||
partType?: string;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
import { IFigureDataColor } from './IFigureDataColor';
|
||||
|
||||
export interface IFigureDataPalette
|
||||
{
|
||||
id?: number;
|
||||
colors?: IFigureDataColor[];
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
export interface IFigureDataPart
|
||||
{
|
||||
id?: number;
|
||||
type?: string;
|
||||
colorable?: boolean;
|
||||
index?: number;
|
||||
colorindex?: number;
|
||||
}
|
15
src/nitro/avatar/interfaces/figuredata/IFigureDataSet.ts
Normal file
15
src/nitro/avatar/interfaces/figuredata/IFigureDataSet.ts
Normal file
@ -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[];
|
||||
}
|
12
src/nitro/avatar/interfaces/figuredata/IFigureDataSetType.ts
Normal file
12
src/nitro/avatar/interfaces/figuredata/IFigureDataSetType.ts
Normal file
@ -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[];
|
||||
}
|
7
src/nitro/avatar/interfaces/figuredata/index.ts
Normal file
7
src/nitro/avatar/interfaces/figuredata/index.ts
Normal file
@ -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';
|
1
src/nitro/avatar/interfaces/index.ts
Normal file
1
src/nitro/avatar/interfaces/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './figuredata';
|
@ -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)
|
||||
{
|
||||
|
@ -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 =>
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<string, IPartColor>;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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<string, IFigurePartSet>;
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user