From 66cfa1a32b584162500c67f751b10d167ead5c28 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 19 Feb 2021 23:10:06 -0500 Subject: [PATCH] All converters working --- src/Main.ts | 11 +- src/common/bundle/BundleProvider.ts | 2 +- src/common/converters/SWFConverter.ts | 9 + src/config.json.example | 4 +- src/converters/effect/EffectConverter.ts | 77 ++++ src/converters/effect/EffectDownloader.ts | 77 ++++ src/mapping/json/asset/IAssetAlias.ts | 8 +- src/mapping/json/asset/IAssetData.ts | 2 + .../json/asset/animation/IAssetAnimation.ts | 23 ++ .../asset/animation/IAssetAnimationAdd.ts | 8 + .../asset/animation/IAssetAnimationAvatar.ts | 6 + .../animation/IAssetAnimationDirection.ts | 4 + .../asset/animation/IAssetAnimationFrame.ts | 8 + .../animation/IAssetAnimationFramePart.ts | 14 + .../animation/IAssetAnimationFramePartItem.ts | 5 + .../animation/IAssetAnimationOverride.ts | 8 + .../asset/animation/IAssetAnimationRemove.ts | 4 + .../asset/animation/IAssetAnimationShadow.ts | 4 + .../asset/animation/IAssetAnimationSprite.ts | 11 + .../IAssetAnimationSpriteDirection.ts | 7 + src/mapping/json/asset/animation/index.ts | 12 + src/mapping/json/asset/index.ts | 1 + .../visualization/IAssetVisualizationData.ts | 4 +- .../animation/IAssetAnimation.ts | 9 - .../animation/IAssetAnimationLayer.ts | 9 - .../animation/IAssetAnimationSequence.ts | 8 - .../animation/IAssetAnimationSequenceFrame.ts | 11 - .../animation/IAssetVisualAnimation.ts | 10 + .../animation/IAssetVisualAnimationLayer.ts | 9 + .../IAssetVisualAnimationSequence.ts | 8 + .../IAssetVisualAnimationSequenceFrame.ts | 11 + ...ssetVisualAnimationSequenceFrameOffset.ts} | 2 +- .../asset/visualization/animation/index.ts | 10 +- src/mapping/json/effectmap/IEffectMap.ts | 6 + .../json/effectmap/IEffectMapLibrary.ts | 7 + src/mapping/json/effectmap/index.ts | 2 + src/mapping/json/index.ts | 1 + src/mapping/mappers/asset/AnimationMapper.ts | 328 ++++++++++++++++++ src/mapping/mappers/asset/ManifestMapper.ts | 41 ++- .../mappers/asset/VisualizationMapper.ts | 23 +- src/mapping/mappers/asset/index.ts | 1 + src/mapping/xml/asset/animation/AddXML.ts | 47 +++ src/mapping/xml/asset/animation/AvatarXML.ts | 33 ++ .../xml/asset/animation/DirectionOffsetXML.ts | 19 + .../xml/asset/animation/DirectionXML.ts | 40 +++ .../xml/asset/animation/EffectAnimationXML.ts | 171 +++++++++ .../asset/animation/EffectFramePartItemXML.ts | 26 ++ .../xml/asset/animation/EffectFramePartXML.ts | 87 +++++ .../xml/asset/animation/EffectFrameXML.ts | 53 +++ .../xml/asset/animation/OverrideXML.ts | 45 +++ src/mapping/xml/asset/animation/RemoveXML.ts | 19 + src/mapping/xml/asset/animation/ShadowXML.ts | 19 + src/mapping/xml/asset/animation/SpriteXML.ts | 66 ++++ src/mapping/xml/asset/animation/index.ts | 12 + src/mapping/xml/asset/index.ts | 1 + .../asset/manifest/ManifestLibraryAliasXML.ts | 40 +++ .../xml/asset/manifest/ManifestLibraryXML.ts | 29 +- src/mapping/xml/asset/manifest/index.ts | 1 + .../visualization/animation/AnimationXML.ts | 7 + .../xml/effectmap/EffectLibraryPartXML.ts | 26 ++ src/mapping/xml/effectmap/EffectLibraryXML.ts | 46 +++ src/mapping/xml/effectmap/EffectMapXML.ts | 29 ++ src/mapping/xml/effectmap/index.ts | 3 + src/mapping/xml/index.ts | 2 + 64 files changed, 1553 insertions(+), 73 deletions(-) create mode 100644 src/converters/effect/EffectConverter.ts create mode 100644 src/converters/effect/EffectDownloader.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimation.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimationAdd.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimationAvatar.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimationDirection.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimationFrame.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimationFramePart.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimationFramePartItem.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimationOverride.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimationRemove.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimationShadow.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimationSprite.ts create mode 100644 src/mapping/json/asset/animation/IAssetAnimationSpriteDirection.ts create mode 100644 src/mapping/json/asset/animation/index.ts delete mode 100644 src/mapping/json/asset/visualization/animation/IAssetAnimation.ts delete mode 100644 src/mapping/json/asset/visualization/animation/IAssetAnimationLayer.ts delete mode 100644 src/mapping/json/asset/visualization/animation/IAssetAnimationSequence.ts delete mode 100644 src/mapping/json/asset/visualization/animation/IAssetAnimationSequenceFrame.ts create mode 100644 src/mapping/json/asset/visualization/animation/IAssetVisualAnimation.ts create mode 100644 src/mapping/json/asset/visualization/animation/IAssetVisualAnimationLayer.ts create mode 100644 src/mapping/json/asset/visualization/animation/IAssetVisualAnimationSequence.ts create mode 100644 src/mapping/json/asset/visualization/animation/IAssetVisualAnimationSequenceFrame.ts rename src/mapping/json/asset/visualization/animation/{IAssetAnimationSequenceFrameOffset.ts => IAssetVisualAnimationSequenceFrameOffset.ts} (50%) create mode 100644 src/mapping/json/effectmap/IEffectMap.ts create mode 100644 src/mapping/json/effectmap/IEffectMapLibrary.ts create mode 100644 src/mapping/json/effectmap/index.ts create mode 100644 src/mapping/mappers/asset/AnimationMapper.ts create mode 100644 src/mapping/xml/asset/animation/AddXML.ts create mode 100644 src/mapping/xml/asset/animation/AvatarXML.ts create mode 100644 src/mapping/xml/asset/animation/DirectionOffsetXML.ts create mode 100644 src/mapping/xml/asset/animation/DirectionXML.ts create mode 100644 src/mapping/xml/asset/animation/EffectAnimationXML.ts create mode 100644 src/mapping/xml/asset/animation/EffectFramePartItemXML.ts create mode 100644 src/mapping/xml/asset/animation/EffectFramePartXML.ts create mode 100644 src/mapping/xml/asset/animation/EffectFrameXML.ts create mode 100644 src/mapping/xml/asset/animation/OverrideXML.ts create mode 100644 src/mapping/xml/asset/animation/RemoveXML.ts create mode 100644 src/mapping/xml/asset/animation/ShadowXML.ts create mode 100644 src/mapping/xml/asset/animation/SpriteXML.ts create mode 100644 src/mapping/xml/asset/animation/index.ts create mode 100644 src/mapping/xml/asset/manifest/ManifestLibraryAliasXML.ts create mode 100644 src/mapping/xml/effectmap/EffectLibraryPartXML.ts create mode 100644 src/mapping/xml/effectmap/EffectLibraryXML.ts create mode 100644 src/mapping/xml/effectmap/EffectMapXML.ts create mode 100644 src/mapping/xml/effectmap/index.ts diff --git a/src/Main.ts b/src/Main.ts index aac495c..d2bb7dc 100644 --- a/src/Main.ts +++ b/src/Main.ts @@ -1,6 +1,7 @@ import 'reflect-metadata'; import { container } from 'tsyringe'; import { Configuration } from './common/config/Configuration'; +import { EffectConverter } from './converters/effect/EffectConverter'; import { FigureConverter } from './converters/figure/FigureConverter'; import { FurnitureConverter } from './converters/furniture/FurnitureConverter'; import { PetConverter } from './converters/pet/PetConverter'; @@ -28,9 +29,9 @@ import { PetConverter } from './converters/pet/PetConverter'; await petConverter.convertAsync(); } - // if(config.getBoolean('convert.effect')) - // { - // const effectConverter = container.resolve(EffectConverter); - // await effectConverter.convertAsync(); - // } + if(config.getBoolean('convert.effect')) + { + const effectConverter = container.resolve(EffectConverter); + await effectConverter.convertAsync(); + } })(); diff --git a/src/common/bundle/BundleProvider.ts b/src/common/bundle/BundleProvider.ts index c61e58c..2fcb9f6 100644 --- a/src/common/bundle/BundleProvider.ts +++ b/src/common/bundle/BundleProvider.ts @@ -62,7 +62,7 @@ export class BundleProvider width: 3072, height: 2048, fixedSize: false, - allowRotation: true, + allowRotation: false, detectIdentical: true, allowTrim: true, //@ts-ignore diff --git a/src/common/converters/SWFConverter.ts b/src/common/converters/SWFConverter.ts index b2b0ec6..eae2aad 100644 --- a/src/common/converters/SWFConverter.ts +++ b/src/common/converters/SWFConverter.ts @@ -83,6 +83,15 @@ export class SWFConverter return await parseStringPromise(binaryData.binaryData); } + protected static async getAnimationXML(habboAssetSWF: HabboAssetSWF): Promise + { + const binaryData = SWFConverter.getBinaryData(habboAssetSWF, 'animation', false); + + if(!binaryData) return null; + + return await parseStringPromise(binaryData.binaryData); + } + protected static getPalette(habboAssetSWF: HabboAssetSWF, paletteName: string): [ number, number, number ][] { const binaryData = SWFConverter.getBinaryData(habboAssetSWF, paletteName, false); diff --git a/src/config.json.example b/src/config.json.example index 1e3023e..5307ad6 100644 --- a/src/config.json.example +++ b/src/config.json.example @@ -12,7 +12,7 @@ "dynamic.download.url.effect": "/gordon/PRODUCTION/%className%.swf", "dynamic.download.url.pet": "/gordon/PRODUCTION/%className%.swf", "convert.furniture": "1", - "convert.figure": "0", - "convert.effect": "0", + "convert.figure": "1", + "convert.effect": "1", "convert.pet": "1" } diff --git a/src/converters/effect/EffectConverter.ts b/src/converters/effect/EffectConverter.ts new file mode 100644 index 0000000..50a5b13 --- /dev/null +++ b/src/converters/effect/EffectConverter.ts @@ -0,0 +1,77 @@ +import * as ora from 'ora'; +import { singleton } from 'tsyringe'; +import { BundleProvider } from '../../common/bundle/BundleProvider'; +import { Configuration } from '../../common/config/Configuration'; +import { SWFConverter } from '../../common/converters/SWFConverter'; +import { IAssetData } from '../../mapping/json'; +import { AnimationMapper, ManifestMapper } from '../../mapping/mappers'; +import { HabboAssetSWF } from '../../swf/HabboAssetSWF'; +import File from '../../utils/File'; +import Logger from '../../utils/Logger'; +import { EffectDownloader } from './EffectDownloader'; + +@singleton() +export class EffectConverter extends SWFConverter +{ + constructor( + private readonly _effectDownloader: EffectDownloader, + private readonly _configuration: Configuration, + private readonly _bundleProvider: BundleProvider, + private readonly _logger: Logger) + { + super(); + } + + public async convertAsync(): Promise + { + const now = Date.now(); + + const spinner = ora('Preparing Effects').start(); + + const outputFolder = new File(this._configuration.getValue('output.folder.effect')); + + if(!outputFolder.isDirectory()) outputFolder.mkdirs(); + + try + { + await this._effectDownloader.download(async (habboAssetSwf: HabboAssetSWF, className: string) => + { + spinner.text = 'Parsing Effect: ' + habboAssetSwf.getDocumentClass(); + + spinner.render(); + + const spriteBundle = await this._bundleProvider.generateSpriteSheet(habboAssetSwf); + const assetData = await this.mapXML2JSON(habboAssetSwf, className); + + await this.fromHabboAsset(habboAssetSwf, outputFolder.path, assetData.type, assetData, spriteBundle); + }); + + spinner.succeed(`Effects finished in ${ Date.now() - now }ms`); + } + + catch (error) + { + spinner.fail('Effects failed: ' + error.message); + } + } + + private async mapXML2JSON(habboAssetSWF: HabboAssetSWF, assetType: string): Promise + { + if(!habboAssetSWF) return null; + + const assetData: IAssetData = {}; + + assetData.name = assetType; + assetData.type = EffectDownloader.EFFECT_TYPES.get(assetType); + + const manifestXML = await EffectConverter.getManifestXML(habboAssetSWF); + + if(manifestXML) ManifestMapper.mapXML(manifestXML, assetData); + + const animationXML = await EffectConverter.getAnimationXML(habboAssetSWF); + + if(animationXML) AnimationMapper.mapXML(animationXML, assetData); + + return assetData; + } +} diff --git a/src/converters/effect/EffectDownloader.ts b/src/converters/effect/EffectDownloader.ts new file mode 100644 index 0000000..3d2e1c1 --- /dev/null +++ b/src/converters/effect/EffectDownloader.ts @@ -0,0 +1,77 @@ +import { singleton } from 'tsyringe'; +import { Configuration } from '../../common/config/Configuration'; +import { IEffectMap } from '../../mapping/json'; +import { HabboAssetSWF } from '../../swf/HabboAssetSWF'; +import { FileUtilities } from '../../utils/FileUtilities'; + +@singleton() +export class EffectDownloader +{ + public static EFFECT_TYPES: Map = new Map(); + + constructor(private readonly _configuration: Configuration) + {} + + public async download(callback: (habboAssetSwf: HabboAssetSWF, className: string) => Promise): Promise + { + const effectMap = await this.parseEffectMap(); + const classNames: string[] = []; + + if(effectMap.effects !== undefined) + { + for(const library of effectMap.effects) + { + const className = library.lib; + + if(classNames.indexOf(className) >= 0) continue; + + classNames.push(className); + + try + { + EffectDownloader.EFFECT_TYPES.set(className, library.type); + + await this.extractEffect(className, callback); + } + + catch (error) + { + console.log(); + console.error(`Error parsing ${ className }: ` + error.message); + } + } + } + } + + public async parseEffectMap(): Promise + { + const url = this._configuration.getValue('effectmap.url'); + + if(!url || !url.length) return null; + + const content = await FileUtilities.readFileAsString(url); + + if(!content || !content.length) return null; + + return (JSON.parse(content) as IEffectMap); + } + + public async extractEffect(className: string, callback: (habboAssetSwf: HabboAssetSWF, className: string) => Promise): Promise + { + let url = this._configuration.getValue('dynamic.download.url.effect'); + + if(!url || !url.length) return; + + url = url.replace('%className%', className); + + const buffer = await FileUtilities.readFileAsBuffer(url); + + if(!buffer) return; + + const newHabboAssetSWF = new HabboAssetSWF(buffer); + + await newHabboAssetSWF.setupAsync(); + + await callback(newHabboAssetSWF, className); + } +} diff --git a/src/mapping/json/asset/IAssetAlias.ts b/src/mapping/json/asset/IAssetAlias.ts index fcfec27..5c14027 100644 --- a/src/mapping/json/asset/IAssetAlias.ts +++ b/src/mapping/json/asset/IAssetAlias.ts @@ -1,6 +1,6 @@ export interface IAssetAlias { - link: string; - fliph: number; - flipv: number; -} \ No newline at end of file + link?: string; + flipH?: boolean; + flipV?: boolean; +} diff --git a/src/mapping/json/asset/IAssetData.ts b/src/mapping/json/asset/IAssetData.ts index 63e5597..8b73a34 100644 --- a/src/mapping/json/asset/IAssetData.ts +++ b/src/mapping/json/asset/IAssetData.ts @@ -1,3 +1,4 @@ +import { IAssetAnimation } from './animation'; import { IAsset } from './IAsset'; import { IAssetAlias } from './IAssetAlias'; import { IAssetDimension } from './IAssetDimension'; @@ -18,6 +19,7 @@ export interface IAssetData { directions?: number[]; assets?: { [index: string]: IAsset }; aliases?: { [index: string]: IAssetAlias }; + animations?: { [index: string]: IAssetAnimation }; palettes?: { [index: string]: IAssetPalette }; visualizations?: IAssetVisualizationData[]; } diff --git a/src/mapping/json/asset/animation/IAssetAnimation.ts b/src/mapping/json/asset/animation/IAssetAnimation.ts new file mode 100644 index 0000000..b35e0eb --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimation.ts @@ -0,0 +1,23 @@ +import { IAssetAnimationAdd } from './IAssetAnimationAdd'; +import { IAssetAnimationAvatar } from './IAssetAnimationAvatar'; +import { IAssetAnimationDirection } from './IAssetAnimationDirection'; +import { IAssetAnimationFrame } from './IAssetAnimationFrame'; +import { IAssetAnimationOverride } from './IAssetAnimationOverride'; +import { IAssetAnimationRemove } from './IAssetAnimationRemove'; +import { IAssetAnimationShadow } from './IAssetAnimationShadow'; +import { IAssetAnimationSprite } from './IAssetAnimationSprite'; + +export interface IAssetAnimation +{ + name?: string; + desc?: string; + resetOnToggle?: boolean; + directions?: IAssetAnimationDirection[]; + shadows?: IAssetAnimationShadow[]; + adds?: IAssetAnimationAdd[]; + removes?: IAssetAnimationRemove[]; + sprites?: IAssetAnimationSprite[]; + frames?: IAssetAnimationFrame[]; + avatars?: IAssetAnimationAvatar[]; + overrides?: IAssetAnimationOverride[]; +} diff --git a/src/mapping/json/asset/animation/IAssetAnimationAdd.ts b/src/mapping/json/asset/animation/IAssetAnimationAdd.ts new file mode 100644 index 0000000..3da37c6 --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimationAdd.ts @@ -0,0 +1,8 @@ +export interface IAssetAnimationAdd +{ + id?: string; + align?: string; + blend?: string; + ink?: number; + base?: string; +} diff --git a/src/mapping/json/asset/animation/IAssetAnimationAvatar.ts b/src/mapping/json/asset/animation/IAssetAnimationAvatar.ts new file mode 100644 index 0000000..dcd030e --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimationAvatar.ts @@ -0,0 +1,6 @@ +export interface IAssetAnimationAvatar +{ + ink?: number; + foreground?: string; + background?: string; +} diff --git a/src/mapping/json/asset/animation/IAssetAnimationDirection.ts b/src/mapping/json/asset/animation/IAssetAnimationDirection.ts new file mode 100644 index 0000000..0c18eae --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimationDirection.ts @@ -0,0 +1,4 @@ +export interface IAssetAnimationDirection +{ + offset?: number; +} diff --git a/src/mapping/json/asset/animation/IAssetAnimationFrame.ts b/src/mapping/json/asset/animation/IAssetAnimationFrame.ts new file mode 100644 index 0000000..b8b88a0 --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimationFrame.ts @@ -0,0 +1,8 @@ +import { IAssetAnimationFramePart } from './IAssetAnimationFramePart'; + +export interface IAssetAnimationFrame +{ + repeats?: number; + fxs?: IAssetAnimationFramePart[]; + bodyparts?: IAssetAnimationFramePart[]; +} diff --git a/src/mapping/json/asset/animation/IAssetAnimationFramePart.ts b/src/mapping/json/asset/animation/IAssetAnimationFramePart.ts new file mode 100644 index 0000000..ac8c093 --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimationFramePart.ts @@ -0,0 +1,14 @@ +import { IAssetAnimationFramePartItem } from './IAssetAnimationFramePartItem'; + +export interface IAssetAnimationFramePart +{ + id?: string; + frame?: number; + base?: string; + action?: string; + dx?: number; + dy?: number; + dz?: number; + dd?: number; + items?: IAssetAnimationFramePartItem[]; +} diff --git a/src/mapping/json/asset/animation/IAssetAnimationFramePartItem.ts b/src/mapping/json/asset/animation/IAssetAnimationFramePartItem.ts new file mode 100644 index 0000000..45a7642 --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimationFramePartItem.ts @@ -0,0 +1,5 @@ +export interface IAssetAnimationFramePartItem +{ + id?: string; + base?: string; +} diff --git a/src/mapping/json/asset/animation/IAssetAnimationOverride.ts b/src/mapping/json/asset/animation/IAssetAnimationOverride.ts new file mode 100644 index 0000000..3d56833 --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimationOverride.ts @@ -0,0 +1,8 @@ +import { IAssetAnimationFrame } from './IAssetAnimationFrame'; + +export interface IAssetAnimationOverride +{ + name?: string; + override?: string; + frames?: IAssetAnimationFrame[]; +} diff --git a/src/mapping/json/asset/animation/IAssetAnimationRemove.ts b/src/mapping/json/asset/animation/IAssetAnimationRemove.ts new file mode 100644 index 0000000..ac65fb5 --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimationRemove.ts @@ -0,0 +1,4 @@ +export interface IAssetAnimationRemove +{ + id?: string; +} diff --git a/src/mapping/json/asset/animation/IAssetAnimationShadow.ts b/src/mapping/json/asset/animation/IAssetAnimationShadow.ts new file mode 100644 index 0000000..dfe22a8 --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimationShadow.ts @@ -0,0 +1,4 @@ +export interface IAssetAnimationShadow +{ + id?: string; +} diff --git a/src/mapping/json/asset/animation/IAssetAnimationSprite.ts b/src/mapping/json/asset/animation/IAssetAnimationSprite.ts new file mode 100644 index 0000000..afc7b05 --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimationSprite.ts @@ -0,0 +1,11 @@ +import { IAssetAnimationSpriteDirection } from './IAssetAnimationSpriteDirection'; + +export interface IAssetAnimationSprite +{ + id?: string; + member?: string; + directions?: number; + staticY?: number; + ink?: number; + directionList?: IAssetAnimationSpriteDirection[]; +} diff --git a/src/mapping/json/asset/animation/IAssetAnimationSpriteDirection.ts b/src/mapping/json/asset/animation/IAssetAnimationSpriteDirection.ts new file mode 100644 index 0000000..746719d --- /dev/null +++ b/src/mapping/json/asset/animation/IAssetAnimationSpriteDirection.ts @@ -0,0 +1,7 @@ +export interface IAssetAnimationSpriteDirection +{ + id?: number; + dx?: number; + dy?: number; + dz?: number; +} diff --git a/src/mapping/json/asset/animation/index.ts b/src/mapping/json/asset/animation/index.ts new file mode 100644 index 0000000..56543d0 --- /dev/null +++ b/src/mapping/json/asset/animation/index.ts @@ -0,0 +1,12 @@ +export * from './IAssetAnimation'; +export * from './IAssetAnimationAdd'; +export * from './IAssetAnimationAvatar'; +export * from './IAssetAnimationDirection'; +export * from './IAssetAnimationFrame'; +export * from './IAssetAnimationFramePart'; +export * from './IAssetAnimationFramePartItem'; +export * from './IAssetAnimationOverride'; +export * from './IAssetAnimationRemove'; +export * from './IAssetAnimationShadow'; +export * from './IAssetAnimationSprite'; +export * from './IAssetAnimationSpriteDirection'; diff --git a/src/mapping/json/asset/index.ts b/src/mapping/json/asset/index.ts index 0ec4860..eb113bd 100644 --- a/src/mapping/json/asset/index.ts +++ b/src/mapping/json/asset/index.ts @@ -1,3 +1,4 @@ +export * from './animation'; export * from './IAsset'; export * from './IAssetAlias'; export * from './IAssetData'; diff --git a/src/mapping/json/asset/visualization/IAssetVisualizationData.ts b/src/mapping/json/asset/visualization/IAssetVisualizationData.ts index f5d37bb..e0a2d1d 100644 --- a/src/mapping/json/asset/visualization/IAssetVisualizationData.ts +++ b/src/mapping/json/asset/visualization/IAssetVisualizationData.ts @@ -1,4 +1,4 @@ -import { IAssetAnimation } from './animation/IAssetAnimation'; +import { IAssetVisualAnimation } from './animation/IAssetVisualAnimation'; import { IAssetColor } from './color/IAssetColor'; import { IAssetGesture } from './gestures/IAssetGesture'; import { IAssetVisualizationDirection } from './IAssetVisualizationDirection'; @@ -13,7 +13,7 @@ export interface IAssetVisualizationData layers?: { [index: string]: IAssetVisualizationLayer }; colors?: { [index: string]: IAssetColor }; directions?: { [index: string]: IAssetVisualizationDirection }; - animations?: { [index: string]: IAssetAnimation }; + animations?: { [index: string]: IAssetVisualAnimation }; postures?: { [index: string]: IAssetPosture }; gestures?: { [index: string]: IAssetGesture }; } diff --git a/src/mapping/json/asset/visualization/animation/IAssetAnimation.ts b/src/mapping/json/asset/visualization/animation/IAssetAnimation.ts deleted file mode 100644 index 3201671..0000000 --- a/src/mapping/json/asset/visualization/animation/IAssetAnimation.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { IAssetAnimationLayer } from './IAssetAnimationLayer'; - -export interface IAssetAnimation -{ - transitionTo?: number; - transitionFrom?: number; - immediateChangeFrom?: string; - layers?: { [index: string]: IAssetAnimationLayer }; -} diff --git a/src/mapping/json/asset/visualization/animation/IAssetAnimationLayer.ts b/src/mapping/json/asset/visualization/animation/IAssetAnimationLayer.ts deleted file mode 100644 index 7786764..0000000 --- a/src/mapping/json/asset/visualization/animation/IAssetAnimationLayer.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { IAssetAnimationSequence } from './IAssetAnimationSequence'; - -export interface IAssetAnimationLayer -{ - loopCount?: number; - frameRepeat?: number; - random?: number; - frameSequences?: { [index: string]: IAssetAnimationSequence }; -} diff --git a/src/mapping/json/asset/visualization/animation/IAssetAnimationSequence.ts b/src/mapping/json/asset/visualization/animation/IAssetAnimationSequence.ts deleted file mode 100644 index 13bc991..0000000 --- a/src/mapping/json/asset/visualization/animation/IAssetAnimationSequence.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { IAssetAnimationSequenceFrame } from './IAssetAnimationSequenceFrame'; - -export interface IAssetAnimationSequence -{ - loopCount?: number; - random?: number; - frames?: { [index: string]: IAssetAnimationSequenceFrame }; -} diff --git a/src/mapping/json/asset/visualization/animation/IAssetAnimationSequenceFrame.ts b/src/mapping/json/asset/visualization/animation/IAssetAnimationSequenceFrame.ts deleted file mode 100644 index ec79331..0000000 --- a/src/mapping/json/asset/visualization/animation/IAssetAnimationSequenceFrame.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IAssetAnimationSequenceFrameOffset } from './IAssetAnimationSequenceFrameOffset'; - -export interface IAssetAnimationSequenceFrame -{ - id?: number; - x?: number; - y?: number; - randomX?: number; - randomY?: number; - offsets?: { [index: string]: IAssetAnimationSequenceFrameOffset }; -} diff --git a/src/mapping/json/asset/visualization/animation/IAssetVisualAnimation.ts b/src/mapping/json/asset/visualization/animation/IAssetVisualAnimation.ts new file mode 100644 index 0000000..4e71438 --- /dev/null +++ b/src/mapping/json/asset/visualization/animation/IAssetVisualAnimation.ts @@ -0,0 +1,10 @@ +import { IAssetVisualAnimationLayer } from './IAssetVisualAnimationLayer'; + +export interface IAssetVisualAnimation +{ + transitionTo?: number; + transitionFrom?: number; + immediateChangeFrom?: string; + randomStart?: boolean; + layers?: { [index: string]: IAssetVisualAnimationLayer }; +} diff --git a/src/mapping/json/asset/visualization/animation/IAssetVisualAnimationLayer.ts b/src/mapping/json/asset/visualization/animation/IAssetVisualAnimationLayer.ts new file mode 100644 index 0000000..2a274ea --- /dev/null +++ b/src/mapping/json/asset/visualization/animation/IAssetVisualAnimationLayer.ts @@ -0,0 +1,9 @@ +import { IAssetVisualAnimationSequence } from './IAssetVisualAnimationSequence'; + +export interface IAssetVisualAnimationLayer +{ + loopCount?: number; + frameRepeat?: number; + random?: number; + frameSequences?: { [index: string]: IAssetVisualAnimationSequence }; +} diff --git a/src/mapping/json/asset/visualization/animation/IAssetVisualAnimationSequence.ts b/src/mapping/json/asset/visualization/animation/IAssetVisualAnimationSequence.ts new file mode 100644 index 0000000..bb25104 --- /dev/null +++ b/src/mapping/json/asset/visualization/animation/IAssetVisualAnimationSequence.ts @@ -0,0 +1,8 @@ +import { IAssetVisualAnimationSequenceFrame } from './IAssetVisualAnimationSequenceFrame'; + +export interface IAssetVisualAnimationSequence +{ + loopCount?: number; + random?: number; + frames?: { [index: string]: IAssetVisualAnimationSequenceFrame }; +} diff --git a/src/mapping/json/asset/visualization/animation/IAssetVisualAnimationSequenceFrame.ts b/src/mapping/json/asset/visualization/animation/IAssetVisualAnimationSequenceFrame.ts new file mode 100644 index 0000000..196631e --- /dev/null +++ b/src/mapping/json/asset/visualization/animation/IAssetVisualAnimationSequenceFrame.ts @@ -0,0 +1,11 @@ +import { IAssetVisualAnimationSequenceFrameOffset } from './IAssetVisualAnimationSequenceFrameOffset'; + +export interface IAssetVisualAnimationSequenceFrame +{ + id?: number; + x?: number; + y?: number; + randomX?: number; + randomY?: number; + offsets?: { [index: string]: IAssetVisualAnimationSequenceFrameOffset }; +} diff --git a/src/mapping/json/asset/visualization/animation/IAssetAnimationSequenceFrameOffset.ts b/src/mapping/json/asset/visualization/animation/IAssetVisualAnimationSequenceFrameOffset.ts similarity index 50% rename from src/mapping/json/asset/visualization/animation/IAssetAnimationSequenceFrameOffset.ts rename to src/mapping/json/asset/visualization/animation/IAssetVisualAnimationSequenceFrameOffset.ts index 9ca8ba4..bc85461 100644 --- a/src/mapping/json/asset/visualization/animation/IAssetAnimationSequenceFrameOffset.ts +++ b/src/mapping/json/asset/visualization/animation/IAssetVisualAnimationSequenceFrameOffset.ts @@ -1,4 +1,4 @@ -export interface IAssetAnimationSequenceFrameOffset +export interface IAssetVisualAnimationSequenceFrameOffset { direction?: number; x?: number; diff --git a/src/mapping/json/asset/visualization/animation/index.ts b/src/mapping/json/asset/visualization/animation/index.ts index 7e8a206..19b332c 100644 --- a/src/mapping/json/asset/visualization/animation/index.ts +++ b/src/mapping/json/asset/visualization/animation/index.ts @@ -1,5 +1,5 @@ -export * from './IAssetAnimation'; -export * from './IAssetAnimationLayer'; -export * from './IAssetAnimationSequence'; -export * from './IAssetAnimationSequenceFrame'; -export * from './IAssetAnimationSequenceFrameOffset'; +export * from './IAssetVisualAnimation'; +export * from './IAssetVisualAnimationLayer'; +export * from './IAssetVisualAnimationSequence'; +export * from './IAssetVisualAnimationSequenceFrame'; +export * from './IAssetVisualAnimationSequenceFrameOffset'; diff --git a/src/mapping/json/effectmap/IEffectMap.ts b/src/mapping/json/effectmap/IEffectMap.ts new file mode 100644 index 0000000..60893ee --- /dev/null +++ b/src/mapping/json/effectmap/IEffectMap.ts @@ -0,0 +1,6 @@ +import { IEffectMapLibrary } from './IEffectMapLibrary'; + +export interface IEffectMap +{ + effects: IEffectMapLibrary[]; +} diff --git a/src/mapping/json/effectmap/IEffectMapLibrary.ts b/src/mapping/json/effectmap/IEffectMapLibrary.ts new file mode 100644 index 0000000..9a00225 --- /dev/null +++ b/src/mapping/json/effectmap/IEffectMapLibrary.ts @@ -0,0 +1,7 @@ +export interface IEffectMapLibrary +{ + id: string; + lib: string; + type: string; + revision: number; +} diff --git a/src/mapping/json/effectmap/index.ts b/src/mapping/json/effectmap/index.ts new file mode 100644 index 0000000..fcf95f3 --- /dev/null +++ b/src/mapping/json/effectmap/index.ts @@ -0,0 +1,2 @@ +export * from './IEffectMap'; +export * from './IEffectMapLibrary'; diff --git a/src/mapping/json/index.ts b/src/mapping/json/index.ts index 15ad9a8..faf0cbe 100644 --- a/src/mapping/json/index.ts +++ b/src/mapping/json/index.ts @@ -1,3 +1,4 @@ export * from './asset'; +export * from './effectmap'; export * from './figuremap'; export * from './furnidata'; diff --git a/src/mapping/mappers/asset/AnimationMapper.ts b/src/mapping/mappers/asset/AnimationMapper.ts new file mode 100644 index 0000000..32383e2 --- /dev/null +++ b/src/mapping/mappers/asset/AnimationMapper.ts @@ -0,0 +1,328 @@ +import { IAssetAnimation, IAssetAnimationAdd, IAssetAnimationAvatar, IAssetAnimationDirection, IAssetAnimationFrame, IAssetAnimationFramePart, IAssetAnimationFramePartItem, IAssetAnimationOverride, IAssetAnimationRemove, IAssetAnimationShadow, IAssetAnimationSprite, IAssetAnimationSpriteDirection, IAssetData } from '../../json'; +import { AddXML, AvatarXML, DirectionOffsetXML, EffectAnimationXML, EffectFramePartItemXML, EffectFramePartXML, EffectFrameXML, OverrideXML, RemoveXML, ShadowXML, SpriteXML } from '../../xml'; +import { Mapper } from './Mapper'; + +export class AnimationMapper extends Mapper +{ + public static mapXML(animation: any, output: IAssetData): void + { + if(!animation || !output) return; + + if(animation.animation !== undefined) + { + output.animations = {}; + + AnimationMapper.mapAnimationXML(new EffectAnimationXML(animation.animation), output.animations); + } + } + + private static mapAnimationXML(xml: EffectAnimationXML, output: { [index: string]: IAssetAnimation }): void + { + if(!xml || !output) return; + + const animation: IAssetAnimation = {}; + + if(xml.name !== undefined) animation.name = xml.name; + if(xml.desc !== undefined) animation.desc = xml.desc; + if(xml.resetOnToggle !== undefined) animation.resetOnToggle = xml.resetOnToggle; + + if(xml.directions !== undefined) + { + if(xml.directions.length) + { + animation.directions = []; + + AnimationMapper.mapAnimationDirectionsXML(xml.directions, animation.directions); + } + } + + if(xml.shadows !== undefined) + { + if(xml.shadows.length) + { + animation.shadows = []; + + AnimationMapper.mapAnimationShadowsXML(xml.shadows, animation.shadows); + } + } + + if(xml.adds !== undefined) + { + if(xml.adds.length) + { + animation.adds = []; + + AnimationMapper.mapAnimationAddsXML(xml.adds, animation.adds); + } + } + + if(xml.removes !== undefined) + { + if(xml.removes.length) + { + animation.removes = []; + + AnimationMapper.mapAnimationRemovesXML(xml.removes, animation.removes); + } + } + + if(xml.sprites !== undefined) + { + if(xml.sprites.length) + { + animation.sprites = []; + + AnimationMapper.mapAnimationSpritesXML(xml.sprites, animation.sprites); + } + } + + if(xml.frames !== undefined) + { + if(xml.frames.length) + { + animation.frames = []; + + AnimationMapper.mapAnimationFramesXML(xml.frames, animation.frames); + } + } + + if(xml.avatars !== undefined) + { + if(xml.avatars.length) + { + animation.avatars = []; + + AnimationMapper.mapAnimationAvatarsXML(xml.avatars, animation.avatars); + } + } + + if(xml.overrides !== undefined) + { + if(xml.overrides.length) + { + animation.overrides = []; + + AnimationMapper.mapAnimationOverridesXML(xml.overrides, animation.overrides); + } + } + + output[xml.desc] = animation; + } + + private static mapAnimationDirectionsXML(xml: DirectionOffsetXML[], output: IAssetAnimationDirection[]): void + { + if(!xml || !xml.length || !output) return; + + for(const offsetXML of xml) + { + const direction: IAssetAnimationDirection = {}; + + if(offsetXML.offset !== undefined) direction.offset = offsetXML.offset; + + output.push(direction); + } + } + + private static mapAnimationShadowsXML(xml: ShadowXML[], output: IAssetAnimationShadow[]): void + { + if(!xml || !xml.length || !output) return; + + for(const shadowXML of xml) + { + const shadow: IAssetAnimationShadow = {}; + + if(shadowXML.id !== undefined) shadow.id = shadowXML.id; + + output.push(shadow); + } + } + + private static mapAnimationAddsXML(xml: AddXML[], output: IAssetAnimationAdd[]): void + { + if(!xml || !xml.length || !output) return; + + for(const addXML of xml) + { + const add: IAssetAnimationAdd = {}; + + if(addXML.id !== undefined) add.id = addXML.id; + if(addXML.align !== undefined) add.align = addXML.align; + if(addXML.blend !== undefined) add.blend = addXML.blend; + if(addXML.ink !== undefined) add.ink = addXML.ink; + if(addXML.base !== undefined) add.base = addXML.base; + + output.push(add); + } + } + + private static mapAnimationRemovesXML(xml: RemoveXML[], output: IAssetAnimationRemove[]): void + { + if(!xml || !xml.length || !output) return; + + for(const removeXML of xml) + { + const remove: IAssetAnimationRemove = {}; + + if(removeXML.id !== undefined) remove.id = removeXML.id; + + output.push(remove); + } + } + + private static mapAnimationSpritesXML(xml: SpriteXML[], output: IAssetAnimationSprite[]): void + { + if(!xml || !xml.length || !output) return; + + for(const spriteXML of xml) + { + const sprite: IAssetAnimationSprite = {}; + + if(spriteXML.id !== undefined) sprite.id = spriteXML.id; + if(spriteXML.directions !== undefined) sprite.directions = spriteXML.directions; + if(spriteXML.member !== undefined) sprite.member = spriteXML.member; + if(spriteXML.ink !== undefined) sprite.ink = spriteXML.ink; + if(spriteXML.staticY !== undefined) sprite.staticY = spriteXML.staticY; + + if(spriteXML.directionList !== undefined) + { + if(spriteXML.directionList.length) + { + sprite.directionList = []; + + for(const directionXML of spriteXML.directionList) + { + const direction: IAssetAnimationSpriteDirection = {}; + + if(directionXML.id !== undefined) direction.id = directionXML.id; + if(directionXML.dx !== undefined) direction.dx = directionXML.dx; + if(directionXML.dy !== undefined) direction.dy = directionXML.dy; + if(directionXML.dz !== undefined) direction.dz = directionXML.dz; + + sprite.directionList.push(direction); + } + } + } + + output.push(sprite); + } + } + + private static mapAnimationFramesXML(xml: EffectFrameXML[], output: IAssetAnimationFrame[]): void + { + if(!xml || !xml.length || !output) return; + + for(const frameXML of xml) + { + const frame: IAssetAnimationFrame = {}; + + if(frameXML.fxs !== undefined) + { + if(frameXML.fxs.length) + { + frame.fxs = []; + + AnimationMapper.mapAnimationFramesPartXML(frameXML.fxs, frame.fxs); + } + } + + if(frameXML.bodyParts !== undefined) + { + if(frameXML.bodyParts.length) + { + frame.bodyparts = []; + + AnimationMapper.mapAnimationFramesPartXML(frameXML.bodyParts, frame.bodyparts); + } + } + + output.push(frame); + } + } + + private static mapAnimationFramesPartXML(xml: EffectFramePartXML[], output: IAssetAnimationFramePart[]): void + { + if(!xml || !xml.length || !output) return; + + for(const framePartXML of xml) + { + const framePart: IAssetAnimationFramePart = {}; + + if(framePartXML.id !== undefined) framePart.id = framePartXML.id; + if(framePartXML.frame !== undefined) framePart.frame = framePartXML.frame; + if(framePartXML.base !== undefined) framePart.base = framePartXML.base; + if(framePartXML.action !== undefined) framePart.action = framePartXML.action; + if(framePartXML.dx !== undefined) framePart.dx = framePartXML.dx; + if(framePartXML.dy !== undefined) framePart.dy = framePartXML.dy; + if(framePartXML.dz !== undefined) framePart.dz = framePartXML.dz; + if(framePartXML.dd !== undefined) framePart.dd = framePartXML.dd; + + if(framePartXML.items !== undefined) + { + if(framePartXML.items.length) + { + framePart.items = []; + + AnimationMapper.mapAnimationFramesPartItemXML(framePartXML.items, framePart.items); + } + } + + output.push(framePart); + } + } + + private static mapAnimationFramesPartItemXML(xml: EffectFramePartItemXML[], output: IAssetAnimationFramePartItem[]): void + { + if(!xml || !xml.length || !output) return; + + for(const framePartItemXML of xml) + { + const item: IAssetAnimationFramePartItem = {}; + + if(framePartItemXML.id !== undefined) item.id = framePartItemXML.id; + if(framePartItemXML.base !== undefined) item.base = framePartItemXML.base; + + output.push(item); + } + } + + private static mapAnimationAvatarsXML(xml: AvatarXML[], output: IAssetAnimationAvatar[]): void + { + if(!xml || !xml.length || !output) return; + + for(const avatarXML of xml) + { + const avatar: IAssetAnimationAvatar = {}; + + if(avatarXML.background !== undefined) avatar.background = avatarXML.background; + if(avatarXML.foreground !== undefined) avatar.foreground = avatarXML.foreground; + if(avatarXML.ink !== undefined) avatar.ink = avatarXML.ink; + + output.push(avatar); + } + } + + private static mapAnimationOverridesXML(xml: OverrideXML[], output: IAssetAnimationOverride[]): void + { + if(!xml || !xml.length || !output) return; + + for(const overrideXML of xml) + { + const override: IAssetAnimationOverride = {}; + + if(overrideXML.name !== undefined) override.name = overrideXML.name; + if(overrideXML.override !== undefined) override.override = overrideXML.override; + + if(overrideXML.frames !== undefined) + { + if(overrideXML.frames.length) + { + override.frames = []; + + AnimationMapper.mapAnimationFramesXML(overrideXML.frames, override.frames); + } + } + + output.push(override); + } + } +} diff --git a/src/mapping/mappers/asset/ManifestMapper.ts b/src/mapping/mappers/asset/ManifestMapper.ts index 176b86a..bd26d3a 100644 --- a/src/mapping/mappers/asset/ManifestMapper.ts +++ b/src/mapping/mappers/asset/ManifestMapper.ts @@ -1,6 +1,6 @@ import { BundleProvider } from '../../../common/bundle/BundleProvider'; -import { IAsset, IAssetData } from '../../json'; -import { ManifestLibraryAssetParamXML, ManifestLibraryAssetXML, ManifestLibraryXML, ManifestXML } from '../../xml'; +import { IAsset, IAssetAlias, IAssetData } from '../../json'; +import { ManifestLibraryAliasXML, ManifestLibraryAssetParamXML, ManifestLibraryAssetXML, ManifestLibraryXML, ManifestXML } from '../../xml'; import { Mapper } from './Mapper'; export class ManifestMapper extends Mapper @@ -32,6 +32,16 @@ export class ManifestMapper extends Mapper ManifestMapper.mapManifestLibraryAssetXML(xml.assets, output.assets); } } + + if(xml.aliases !== undefined) + { + if(xml.aliases.length) + { + output.aliases = {}; + + ManifestMapper.mapManifestLibraryAliasXML(xml.aliases, output.aliases); + } + } } private static mapManifestLibraryAssetXML(xml: ManifestLibraryAssetXML[], output: { [index: string]: IAsset }): void @@ -69,4 +79,31 @@ export class ManifestMapper extends Mapper output.y = parseInt(split[1]); } } + + private static mapManifestLibraryAliasXML(xml: ManifestLibraryAliasXML[], output: { [index: string]: IAssetAlias }): void + { + if(!xml || !xml.length || !output) return; + + for(const libraryAliasXML of xml) + { + const alias: IAssetAlias = {}; + + if(libraryAliasXML.name !== undefined) + { + if(libraryAliasXML.link !== undefined) + { + if(libraryAliasXML.link.startsWith('sh_')) continue; + + if(libraryAliasXML.link.indexOf('_32_') >= 0) continue; + + alias.link = libraryAliasXML.link; + } + + if(libraryAliasXML.flipH !== undefined) alias.flipH = libraryAliasXML.flipH; + if(libraryAliasXML.flipH !== undefined) alias.flipV = libraryAliasXML.flipV; + + output[libraryAliasXML.name] = alias; + } + } + } } diff --git a/src/mapping/mappers/asset/VisualizationMapper.ts b/src/mapping/mappers/asset/VisualizationMapper.ts index 7e0c958..4760fa2 100644 --- a/src/mapping/mappers/asset/VisualizationMapper.ts +++ b/src/mapping/mappers/asset/VisualizationMapper.ts @@ -1,4 +1,4 @@ -import { IAssetAnimation, IAssetAnimationLayer, IAssetAnimationSequence, IAssetAnimationSequenceFrame, IAssetAnimationSequenceFrameOffset, IAssetColor, IAssetColorLayer, IAssetData, IAssetGesture, IAssetPosture, IAssetVisualizationData, IAssetVisualizationDirection, IAssetVisualizationLayer } from '../../json'; +import { IAssetColor, IAssetColorLayer, IAssetData, IAssetGesture, IAssetPosture, IAssetVisualAnimation, IAssetVisualAnimationLayer, IAssetVisualAnimationSequence, IAssetVisualAnimationSequenceFrame, IAssetVisualAnimationSequenceFrameOffset, IAssetVisualizationData, IAssetVisualizationDirection, IAssetVisualizationLayer } from '../../json'; import { AnimationLayerXML, AnimationXML, ColorLayerXML, ColorXML, FrameOffsetXML, FrameSequenceXML, FrameXML, GestureXML, LayerXML, PostureXML, VisualDirectionXML, VisualizationDataXML, VisualizationXML } from '../../xml'; import { Mapper } from './Mapper'; @@ -185,17 +185,18 @@ export class VisualizationMapper extends Mapper } } - private static mapVisualizationAnimationXML(xml: AnimationXML[], output: { [index: string]: IAssetAnimation }): void + private static mapVisualizationAnimationXML(xml: AnimationXML[], output: { [index: string]: IAssetVisualAnimation }): void { if(!xml || !xml.length || !output) return; for(const animationXML of xml) { - const animation: IAssetAnimation = {}; + const animation: IAssetVisualAnimation = {}; if(animationXML.transitionTo !== undefined) animation.transitionTo = animationXML.transitionTo; if(animationXML.transitionFrom !== undefined) animation.transitionFrom = animationXML.transitionFrom; if(animationXML.immediateChangeFrom !== undefined) animation.immediateChangeFrom = animationXML.immediateChangeFrom; + if(animationXML.randomStart !== undefined) animation.randomStart = animationXML.randomStart; if(animationXML.layers !== undefined) { @@ -211,13 +212,13 @@ export class VisualizationMapper extends Mapper } } - private static mapVisualizationAnimationLayerXML(xml: AnimationLayerXML[], output: { [index: string]: IAssetAnimationLayer }): void + private static mapVisualizationAnimationLayerXML(xml: AnimationLayerXML[], output: { [index: string]: IAssetVisualAnimationLayer }): void { if(!xml || !xml.length || !output) return; for(const animationLayerXML of xml) { - const animationLayer: IAssetAnimationLayer = {}; + const animationLayer: IAssetVisualAnimationLayer = {}; if(animationLayerXML.frameRepeat !== undefined) animationLayer.frameRepeat = animationLayerXML.frameRepeat; if(animationLayerXML.loopCount !== undefined) animationLayer.loopCount = animationLayerXML.loopCount; @@ -237,7 +238,7 @@ export class VisualizationMapper extends Mapper } } - private static mapVisualizationFrameSequenceXML(xml: FrameSequenceXML[], output: { [index: string]: IAssetAnimationSequence }): void + private static mapVisualizationFrameSequenceXML(xml: FrameSequenceXML[], output: { [index: string]: IAssetVisualAnimationSequence }): void { if(!xml || !xml.length || !output) return; @@ -245,7 +246,7 @@ export class VisualizationMapper extends Mapper for(const frameSequenceXML of xml) { - const frameSequence: IAssetAnimationSequence = {}; + const frameSequence: IAssetVisualAnimationSequence = {}; if(frameSequenceXML.loopCount !== undefined) frameSequence.loopCount = frameSequenceXML.loopCount; if(frameSequenceXML.random !== undefined) frameSequence.random = frameSequenceXML.random; @@ -266,7 +267,7 @@ export class VisualizationMapper extends Mapper } } - private static mapVisualizationFrameSequenceFrameXML(xml: FrameXML[], output: { [index: string]: IAssetAnimationSequenceFrame }): void + private static mapVisualizationFrameSequenceFrameXML(xml: FrameXML[], output: { [index: string]: IAssetVisualAnimationSequenceFrame }): void { if(!xml || !xml.length || !output) return; @@ -274,7 +275,7 @@ export class VisualizationMapper extends Mapper for(const frameXML of xml) { - const frame: IAssetAnimationSequenceFrame = {}; + const frame: IAssetVisualAnimationSequenceFrame = {}; if((frameXML.id === undefined) || (frameXML.id === 'NaN')) frame.id = 0; else frame.id = parseInt(frameXML.id); @@ -300,7 +301,7 @@ export class VisualizationMapper extends Mapper } } - private static mapVisualizationFrameSequenceFrameOffsetXML(xml: FrameOffsetXML[], output: { [index: string]: IAssetAnimationSequenceFrameOffset }): void + private static mapVisualizationFrameSequenceFrameOffsetXML(xml: FrameOffsetXML[], output: { [index: string]: IAssetVisualAnimationSequenceFrameOffset }): void { if(!xml || !xml.length || !output) return; @@ -308,7 +309,7 @@ export class VisualizationMapper extends Mapper for(const offsetXML of xml) { - const offset: IAssetAnimationSequenceFrameOffset = {}; + const offset: IAssetVisualAnimationSequenceFrameOffset = {}; if(offsetXML.direction !== undefined) offset.direction = offsetXML.direction; if(offsetXML.x !== undefined) offset.x = offsetXML.x; diff --git a/src/mapping/mappers/asset/index.ts b/src/mapping/mappers/asset/index.ts index f7d84ef..c2d78ad 100644 --- a/src/mapping/mappers/asset/index.ts +++ b/src/mapping/mappers/asset/index.ts @@ -1,3 +1,4 @@ +export * from './AnimationMapper'; export * from './AssetMapper'; export * from './IndexMapper'; export * from './LogicMapper'; diff --git a/src/mapping/xml/asset/animation/AddXML.ts b/src/mapping/xml/asset/animation/AddXML.ts new file mode 100644 index 0000000..7c675cd --- /dev/null +++ b/src/mapping/xml/asset/animation/AddXML.ts @@ -0,0 +1,47 @@ +export class AddXML +{ + private readonly _id: string; + private readonly _align: string; + private readonly _blend: string; + private readonly _ink: number; + private readonly _base: string; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.id !== undefined) this._id = attributes.id; + if(attributes.align !== undefined) this._align = attributes.align; + if(attributes.blend !== undefined) this._blend = attributes.blend; + if(attributes.ink !== undefined) this._ink = parseInt(attributes.ink); + if(attributes.base !== undefined) this._base = attributes.base; + } + } + + public get id(): string + { + return this._id; + } + + public get align(): string + { + return this._align; + } + + public get blend(): string + { + return this._blend; + } + + public get ink(): number + { + return this._ink; + } + + public get base(): string + { + return this._base; + } +} diff --git a/src/mapping/xml/asset/animation/AvatarXML.ts b/src/mapping/xml/asset/animation/AvatarXML.ts new file mode 100644 index 0000000..ae90ea7 --- /dev/null +++ b/src/mapping/xml/asset/animation/AvatarXML.ts @@ -0,0 +1,33 @@ +export class AvatarXML +{ + private readonly _ink: number; + private readonly _foreground: string; + private readonly _background: string; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.ink !== undefined) this._ink = parseInt(attributes.ink); + if(attributes.foreground !== undefined) this._foreground = attributes.foreground; + if(attributes.background !== undefined) this._background = attributes.background; + } + } + + public get ink(): number + { + return this._ink; + } + + public get foreground(): string + { + return this._foreground; + } + + public get background(): string + { + return this._background; + } +} diff --git a/src/mapping/xml/asset/animation/DirectionOffsetXML.ts b/src/mapping/xml/asset/animation/DirectionOffsetXML.ts new file mode 100644 index 0000000..3beb60d --- /dev/null +++ b/src/mapping/xml/asset/animation/DirectionOffsetXML.ts @@ -0,0 +1,19 @@ +export class DirectionOffsetXML +{ + private readonly _offset: number; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.offset !== undefined) this._offset = parseInt(attributes.offset); + } + } + + public get offset(): number + { + return this._offset; + } +} diff --git a/src/mapping/xml/asset/animation/DirectionXML.ts b/src/mapping/xml/asset/animation/DirectionXML.ts new file mode 100644 index 0000000..fb2781c --- /dev/null +++ b/src/mapping/xml/asset/animation/DirectionXML.ts @@ -0,0 +1,40 @@ +export class DirectionXML +{ + private readonly _id: number; + private readonly _dx: number; + private readonly _dy: number; + private readonly _dz: number; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.id !== undefined) this._id = parseInt(attributes.id); + if(attributes.dx !== undefined) this._dx = parseInt(attributes.dx); + if(attributes.dy !== undefined) this._dy = parseInt(attributes.dy); + if(attributes.dz !== undefined) this._dz = parseInt(attributes.dz); + } + } + + public get id(): number + { + return this._id; + } + + public get dx(): number + { + return this._dx; + } + + public get dy(): number + { + return this._dy; + } + + public get dz(): number + { + return this._dz; + } +} diff --git a/src/mapping/xml/asset/animation/EffectAnimationXML.ts b/src/mapping/xml/asset/animation/EffectAnimationXML.ts new file mode 100644 index 0000000..3dee7e9 --- /dev/null +++ b/src/mapping/xml/asset/animation/EffectAnimationXML.ts @@ -0,0 +1,171 @@ +import { AddXML } from './AddXML'; +import { AvatarXML } from './AvatarXML'; +import { DirectionOffsetXML } from './DirectionOffsetXML'; +import { EffectFrameXML } from './EffectFrameXML'; +import { OverrideXML } from './OverrideXML'; +import { RemoveXML } from './RemoveXML'; +import { ShadowXML } from './ShadowXML'; +import { SpriteXML } from './SpriteXML'; + +export class EffectAnimationXML +{ + private readonly _name: string; + private readonly _desc: string; + private readonly _resetOnToggle: boolean; + + private readonly _directions: DirectionOffsetXML[]; + private readonly _shadows: ShadowXML[]; + private readonly _adds: AddXML[]; + private readonly _removes: RemoveXML[]; + private readonly _sprites: SpriteXML[]; + private readonly _frames: EffectFrameXML[]; + private readonly _avatars: AvatarXML[]; + private readonly _overrides: OverrideXML[]; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.name !== undefined) this._name = attributes.name; + if(attributes.desc !== undefined) this._desc = attributes.desc; + if(attributes.resetOnToggle !== undefined) this._resetOnToggle = (attributes.resetOnToggle === '1'); + } + + if(xml.direction !== undefined) + { + if(Array.isArray(xml.direction)) + { + this._directions = []; + + for(const direction of xml.direction) this._directions.push(new DirectionOffsetXML(direction)); + } + } + + if(xml.shadow !== undefined) + { + if(Array.isArray(xml.shadow)) + { + this._shadows = []; + + for(const shadow of xml.shadow) this._shadows.push(new ShadowXML(shadow)); + } + } + + if(xml.add !== undefined) + { + if(Array.isArray(xml.add)) + { + this._adds = []; + + for(const add of xml.add) this._adds.push(new AddXML(add)); + } + } + + if(xml.remove !== undefined) + { + if(Array.isArray(xml.remove)) + { + this._removes = []; + + for(const remove of xml.remove) this._removes.push(new RemoveXML(remove)); + } + } + + if(xml.sprite !== undefined) + { + if(Array.isArray(xml.sprite)) + { + this._sprites = []; + + for(const sprite of xml.sprite) this._sprites.push(new SpriteXML(sprite)); + } + } + + if(xml.frame !== undefined) + { + if(Array.isArray(xml.frame)) + { + this._frames = []; + + for(const frame of xml.frame) this._frames.push(new EffectFrameXML(frame)); + } + } + + if(xml.avatar !== undefined) + { + if(Array.isArray(xml.avatar)) + { + this._avatars = []; + + for(const avatar of xml.avatar) this._avatars.push(new AvatarXML(avatar)); + } + } + + if(xml.override !== undefined) + { + if(Array.isArray(xml.override)) + { + this._overrides = []; + + for(const override of xml.override) this._overrides.push(new OverrideXML(override)); + } + } + } + + public get name(): string + { + return this._name; + } + + public get desc(): string + { + return this._desc; + } + + public get resetOnToggle(): boolean + { + return this._resetOnToggle; + } + + public get directions(): DirectionOffsetXML[] + { + return this._directions; + } + + public get shadows(): ShadowXML[] + { + return this._shadows; + } + + public get adds(): AddXML[] + { + return this._adds; + } + + public get removes(): RemoveXML[] + { + return this._removes; + } + + public get sprites(): SpriteXML[] + { + return this._sprites; + } + + public get frames(): EffectFrameXML[] + { + return this._frames; + } + + public get avatars(): AvatarXML[] + { + return this._avatars; + } + + public get overrides(): OverrideXML[] + { + return this._overrides; + } +} diff --git a/src/mapping/xml/asset/animation/EffectFramePartItemXML.ts b/src/mapping/xml/asset/animation/EffectFramePartItemXML.ts new file mode 100644 index 0000000..e53e98d --- /dev/null +++ b/src/mapping/xml/asset/animation/EffectFramePartItemXML.ts @@ -0,0 +1,26 @@ +export class EffectFramePartItemXML +{ + private readonly _id: string; + private readonly _base: string; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.id !== undefined) this._id = attributes.id; + if(attributes.base !== undefined) this._base = attributes.base; + } + } + + public get id(): string + { + return this._id; + } + + public get base(): string + { + return this._base; + } +} diff --git a/src/mapping/xml/asset/animation/EffectFramePartXML.ts b/src/mapping/xml/asset/animation/EffectFramePartXML.ts new file mode 100644 index 0000000..894b66a --- /dev/null +++ b/src/mapping/xml/asset/animation/EffectFramePartXML.ts @@ -0,0 +1,87 @@ +import { EffectFramePartItemXML } from './EffectFramePartItemXML'; + +export class EffectFramePartXML +{ + private readonly _id: string; + private readonly _frame: number; + private readonly _base: string; + private readonly _action: string; + private readonly _dx: number; + private readonly _dy: number; + private readonly _dz: number; + private readonly _dd: number; + + private readonly _items: EffectFramePartItemXML[]; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.id !== undefined) this._id = attributes.id; + if(attributes.frame !== undefined) this._frame = parseInt(attributes.frame); + if(attributes.base !== undefined) this._base = attributes.base; + if(attributes.action !== undefined) this._action = attributes.action; + if(attributes.dx !== undefined) this._dx = parseInt(attributes.dx); + if(attributes.dy !== undefined) this._dy = parseInt(attributes.dy); + if(attributes.dz !== undefined) this._dz = parseInt(attributes.dz); + if(attributes.dd !== undefined) this._dd = parseInt(attributes.dd); + } + + if(xml.item !== undefined) + { + if(Array.isArray(xml.item)) + { + this._items = []; + + for(const item of xml.item) this._items.push(new EffectFramePartItemXML(item)); + } + } + } + + public get id(): string + { + return this._id; + } + + public get frame(): number + { + return this._frame; + } + + public get base(): string + { + return this._base; + } + + public get action(): string + { + return this._action; + } + + public get dx(): number + { + return this._dx; + } + + public get dy(): number + { + return this._dy; + } + + public get dz(): number + { + return this._dz; + } + + public get dd(): number + { + return this._dd; + } + + public get items(): EffectFramePartItemXML[] + { + return this._items; + } +} diff --git a/src/mapping/xml/asset/animation/EffectFrameXML.ts b/src/mapping/xml/asset/animation/EffectFrameXML.ts new file mode 100644 index 0000000..2707375 --- /dev/null +++ b/src/mapping/xml/asset/animation/EffectFrameXML.ts @@ -0,0 +1,53 @@ +import { EffectFramePartXML } from './EffectFramePartXML'; + +export class EffectFrameXML +{ + private readonly _repeats: number; + private readonly _fxs: EffectFramePartXML[] + private readonly _bodyParts: EffectFramePartXML[]; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.repeats !== undefined) this._repeats = parseInt(attributes.repeats); + } + + if(xml.fx !== undefined) + { + if(Array.isArray(xml.fx)) + { + this._fxs = []; + + for(const fx of xml.fx) this._fxs.push(new EffectFramePartXML(fx)); + } + } + + if(xml.bodypart !== undefined) + { + if(Array.isArray(xml.bodypart)) + { + this._bodyParts = []; + + for(const bodypart of xml.bodypart) this._bodyParts.push(new EffectFramePartXML(bodypart)); + } + } + } + + public get repeats(): number + { + return this._repeats; + } + + public get fxs(): EffectFramePartXML[] + { + return this._fxs; + } + + public get bodyParts(): EffectFramePartXML[] + { + return this._bodyParts; + } +} diff --git a/src/mapping/xml/asset/animation/OverrideXML.ts b/src/mapping/xml/asset/animation/OverrideXML.ts new file mode 100644 index 0000000..d08bf2e --- /dev/null +++ b/src/mapping/xml/asset/animation/OverrideXML.ts @@ -0,0 +1,45 @@ +import { EffectFrameXML } from './EffectFrameXML'; + +export class OverrideXML +{ + private readonly _name: string; + private readonly _override: string; + + private readonly _frames: EffectFrameXML[]; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.name !== undefined) this._name = attributes.name; + if(attributes.override !== undefined) this._override = attributes.override; + } + + if(xml.frame !== undefined) + { + if(Array.isArray(xml.frame)) + { + this._frames = []; + + for(const frame of xml.frame) this._frames.push(new EffectFrameXML(frame)); + } + } + } + + public get name(): string + { + return this._name; + } + + public get override(): string + { + return this._override; + } + + public get frames(): EffectFrameXML[] + { + return this._frames; + } +} diff --git a/src/mapping/xml/asset/animation/RemoveXML.ts b/src/mapping/xml/asset/animation/RemoveXML.ts new file mode 100644 index 0000000..8e219b7 --- /dev/null +++ b/src/mapping/xml/asset/animation/RemoveXML.ts @@ -0,0 +1,19 @@ +export class RemoveXML +{ + private readonly _id: string; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.id !== undefined) this._id = attributes.id; + } + } + + public get id(): string + { + return this._id; + } +} diff --git a/src/mapping/xml/asset/animation/ShadowXML.ts b/src/mapping/xml/asset/animation/ShadowXML.ts new file mode 100644 index 0000000..c9f935b --- /dev/null +++ b/src/mapping/xml/asset/animation/ShadowXML.ts @@ -0,0 +1,19 @@ +export class ShadowXML +{ + private readonly _id: string; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.id !== undefined) this._id = attributes.id; + } + } + + public get id(): string + { + return this._id; + } +} diff --git a/src/mapping/xml/asset/animation/SpriteXML.ts b/src/mapping/xml/asset/animation/SpriteXML.ts new file mode 100644 index 0000000..fec06e6 --- /dev/null +++ b/src/mapping/xml/asset/animation/SpriteXML.ts @@ -0,0 +1,66 @@ +import { DirectionXML } from './DirectionXML'; + +export class SpriteXML +{ + private readonly _id: string; + private readonly _member: string; + private readonly _directions: number; + private readonly _staticY: number; + private readonly _ink: number; + + private readonly _directionList: DirectionXML[]; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.id !== undefined) this._id = attributes.id; + if(attributes.member !== undefined) this._member = attributes.member; + if(attributes.directions !== undefined) this._directions = parseInt(attributes.directions); + if(attributes.staticY !== undefined) this._staticY = parseInt(attributes.staticY); + if(attributes.ink !== undefined) this._ink = parseInt(attributes.ink); + } + + if(xml.direction !== undefined) + { + if(Array.isArray(xml.direction)) + { + this._directionList = []; + + for(const direction of xml.direction) this._directionList.push(new DirectionXML(direction)); + } + } + } + + public get id(): string + { + return this._id; + } + + public get member(): string + { + return this._member; + } + + public get directions(): number + { + return this._directions; + } + + public get staticY(): number + { + return this._staticY; + } + + public get ink(): number + { + return this._ink; + } + + public get directionList(): DirectionXML[] + { + return this._directionList; + } +} diff --git a/src/mapping/xml/asset/animation/index.ts b/src/mapping/xml/asset/animation/index.ts new file mode 100644 index 0000000..baf499a --- /dev/null +++ b/src/mapping/xml/asset/animation/index.ts @@ -0,0 +1,12 @@ +export * from './AddXML'; +export * from './AvatarXML'; +export * from './DirectionOffsetXML'; +export * from './DirectionXML'; +export * from './EffectAnimationXML'; +export * from './EffectFramePartItemXML'; +export * from './EffectFramePartXML'; +export * from './EffectFrameXML'; +export * from './OverrideXML'; +export * from './RemoveXML'; +export * from './ShadowXML'; +export * from './SpriteXML'; diff --git a/src/mapping/xml/asset/index.ts b/src/mapping/xml/asset/index.ts index 719f115..0a600b7 100644 --- a/src/mapping/xml/asset/index.ts +++ b/src/mapping/xml/asset/index.ts @@ -1,3 +1,4 @@ +export * from './animation'; export * from './assets'; export * from './index'; export * from './IndexXML'; diff --git a/src/mapping/xml/asset/manifest/ManifestLibraryAliasXML.ts b/src/mapping/xml/asset/manifest/ManifestLibraryAliasXML.ts new file mode 100644 index 0000000..714d300 --- /dev/null +++ b/src/mapping/xml/asset/manifest/ManifestLibraryAliasXML.ts @@ -0,0 +1,40 @@ +export class ManifestLibraryAliasXML +{ + private _name: string; + private _link: string; + private _flipH: boolean; + private _flipV: boolean; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes !== undefined) + { + if(attributes.name !== undefined) this._name = attributes.name; + if(attributes.link !== undefined) this._link = attributes.link; + if(attributes.fliph !== undefined) this._flipH = (attributes.fliph === '1'); + if(attributes.flipv !== undefined) this._flipV = (attributes.flipv === '1'); + } + } + + public get name(): string + { + return this._name; + } + + public get link(): string + { + return this._link; + } + + public get flipH(): boolean + { + return this._flipH; + } + + public get flipV(): boolean + { + return this._flipV; + } +} diff --git a/src/mapping/xml/asset/manifest/ManifestLibraryXML.ts b/src/mapping/xml/asset/manifest/ManifestLibraryXML.ts index 5eb5dbb..50ff89b 100644 --- a/src/mapping/xml/asset/manifest/ManifestLibraryXML.ts +++ b/src/mapping/xml/asset/manifest/ManifestLibraryXML.ts @@ -1,3 +1,4 @@ +import { ManifestLibraryAliasXML } from './ManifestLibraryAliasXML'; import { ManifestLibraryAssetXML } from './ManifestLibraryAssetXML'; export class ManifestLibraryXML @@ -5,6 +6,7 @@ export class ManifestLibraryXML private readonly _name: string; private readonly _version: string; private readonly _assets: ManifestLibraryAssetXML[]; + private readonly _aliases: ManifestLibraryAliasXML[]; constructor(xml: any) { @@ -22,11 +24,27 @@ export class ManifestLibraryXML { this._assets = []; - for(const assetPartParent of xml.assets) + for(const assetParent of xml.assets) { - if(Array.isArray(assetPartParent.asset)) + if(Array.isArray(assetParent.asset)) { - for(const asset of assetPartParent.asset) this._assets.push(new ManifestLibraryAssetXML(asset)); + for(const asset of assetParent.asset) this._assets.push(new ManifestLibraryAssetXML(asset)); + } + } + } + } + + if(xml.aliases !== undefined) + { + if(Array.isArray(xml.aliases)) + { + this._aliases = []; + + for(const aliasParent of xml.aliases) + { + if(Array.isArray(aliasParent.alias)) + { + for(const alias of aliasParent.alias) this._aliases.push(new ManifestLibraryAliasXML(alias)); } } } @@ -37,4 +55,9 @@ export class ManifestLibraryXML { return this._assets; } + + public get aliases(): ManifestLibraryAliasXML[] + { + return this._aliases; + } } diff --git a/src/mapping/xml/asset/manifest/index.ts b/src/mapping/xml/asset/manifest/index.ts index 4cf3aee..1e9a6c5 100644 --- a/src/mapping/xml/asset/manifest/index.ts +++ b/src/mapping/xml/asset/manifest/index.ts @@ -1,3 +1,4 @@ +export * from './ManifestLibraryAliasXML'; export * from './ManifestLibraryAssetParamXML'; export * from './ManifestLibraryAssetXML'; export * from './ManifestLibraryXML'; diff --git a/src/mapping/xml/asset/visualization/animation/AnimationXML.ts b/src/mapping/xml/asset/visualization/animation/AnimationXML.ts index 16df2f9..a20d0d0 100644 --- a/src/mapping/xml/asset/visualization/animation/AnimationXML.ts +++ b/src/mapping/xml/asset/visualization/animation/AnimationXML.ts @@ -6,6 +6,7 @@ export class AnimationXML private readonly _transitionTo: number; private readonly _transitionFrom: number; private readonly _immediateChangeFrom: string; + private readonly _randomStart: boolean; private readonly _layers: AnimationLayerXML[]; constructor(xml: any) @@ -18,6 +19,7 @@ export class AnimationXML if(attributes.transitionTo !== undefined) this._transitionTo = parseInt(attributes.transitionTo); if(attributes.transitionFrom !== undefined) this._transitionFrom = parseInt(attributes.transitionFrom); if(attributes.immediateChangeFrom !== undefined) this._immediateChangeFrom = attributes.immediateChangeFrom; + if(attributes.randomStart !== undefined) this._randomStart = (attributes.randomStart === '1'); } if(xml.animationLayer !== undefined) @@ -51,6 +53,11 @@ export class AnimationXML return this._immediateChangeFrom; } + public get randomStart(): boolean + { + return this._randomStart; + } + public get layers(): AnimationLayerXML[] { return this._layers; diff --git a/src/mapping/xml/effectmap/EffectLibraryPartXML.ts b/src/mapping/xml/effectmap/EffectLibraryPartXML.ts new file mode 100644 index 0000000..2165f0e --- /dev/null +++ b/src/mapping/xml/effectmap/EffectLibraryPartXML.ts @@ -0,0 +1,26 @@ +export class EffectLibraryPartXML +{ + private _id: number; + private _type: string; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes) + { + if(attributes.id !== undefined) this._id = parseInt(attributes.id); + if(attributes.type !== undefined) this._type = attributes.type; + } + } + + public get id(): number + { + return this._id; + } + + public get type(): string + { + return this._type; + } +} diff --git a/src/mapping/xml/effectmap/EffectLibraryXML.ts b/src/mapping/xml/effectmap/EffectLibraryXML.ts new file mode 100644 index 0000000..3fa6d5f --- /dev/null +++ b/src/mapping/xml/effectmap/EffectLibraryXML.ts @@ -0,0 +1,46 @@ +import { EffectLibraryPartXML } from './EffectLibraryPartXML'; + +export class EffectLibraryXML +{ + private _id: string; + private _revision: number; + private _parts: EffectLibraryPartXML[]; + + constructor(xml: any) + { + const attributes = xml.$; + + if(attributes) + { + if(attributes.id !== undefined) this._id = attributes.id; + if(attributes.revision !== undefined) this._revision = parseInt(attributes.revision); + } + + if(xml.part !== undefined) + { + this._parts = []; + + for(const partId in xml.part) + { + const part = xml.part[partId]; + + this._parts.push(new EffectLibraryPartXML(part)); + } + } + } + + public get id(): string + { + return this._id; + } + + public get revision(): number + { + return this._revision; + } + + public get parts(): EffectLibraryPartXML[] + { + return this._parts; + } +} diff --git a/src/mapping/xml/effectmap/EffectMapXML.ts b/src/mapping/xml/effectmap/EffectMapXML.ts new file mode 100644 index 0000000..64e2c8b --- /dev/null +++ b/src/mapping/xml/effectmap/EffectMapXML.ts @@ -0,0 +1,29 @@ +import { EffectLibraryXML } from './EffectLibraryXML'; + +export class EffectMapXML +{ + private _librares: EffectLibraryXML[]; + + constructor(xml: any) + { + if(xml.map !== undefined) + { + if(xml.map.lib !== undefined) + { + this._librares = []; + + for(const lib in xml.map.lib) + { + const library = xml.map.lib[lib]; + + this._librares.push(new EffectLibraryXML(library)); + } + } + } + } + + public get libraries(): EffectLibraryXML[] + { + return this._librares; + } +} diff --git a/src/mapping/xml/effectmap/index.ts b/src/mapping/xml/effectmap/index.ts new file mode 100644 index 0000000..1cd7092 --- /dev/null +++ b/src/mapping/xml/effectmap/index.ts @@ -0,0 +1,3 @@ +export * from './EffectLibraryPartXML'; +export * from './EffectLibraryXML'; +export * from './EffectMapXML'; diff --git a/src/mapping/xml/index.ts b/src/mapping/xml/index.ts index ad223d2..faf0cbe 100644 --- a/src/mapping/xml/index.ts +++ b/src/mapping/xml/index.ts @@ -1,2 +1,4 @@ export * from './asset'; +export * from './effectmap'; +export * from './figuremap'; export * from './furnidata';