From 38fb35471150e8caac7396e4cb245817ceb5a4f9 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 26 Feb 2021 01:58:52 -0500 Subject: [PATCH 1/3] Fix palettes --- src/mapping/mappers/asset/AssetMapper.ts | 1 + src/mapping/xml/asset/assets/AssetXML.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mapping/mappers/asset/AssetMapper.ts b/src/mapping/mappers/asset/AssetMapper.ts index efec607..60e04a0 100644 --- a/src/mapping/mappers/asset/AssetMapper.ts +++ b/src/mapping/mappers/asset/AssetMapper.ts @@ -67,6 +67,7 @@ export class AssetMapper extends Mapper if(assetXML.y !== undefined) asset.y = assetXML.y; if(assetXML.flipH !== undefined) asset.flipH = assetXML.flipH; if(assetXML.flipV !== undefined) asset.flipV = assetXML.flipV; + if(assetXML.usesPalette !== undefined) asset.usesPalette = assetXML.usesPalette; output[assetXML.name] = asset; } diff --git a/src/mapping/xml/asset/assets/AssetXML.ts b/src/mapping/xml/asset/assets/AssetXML.ts index 2a3e6b7..9c9fd16 100644 --- a/src/mapping/xml/asset/assets/AssetXML.ts +++ b/src/mapping/xml/asset/assets/AssetXML.ts @@ -6,7 +6,7 @@ export class AssetXML private readonly _y: number; private readonly _flipH: boolean; private readonly _flipV: boolean; - private readonly _usesPalette: number; + private readonly _usesPalette: boolean; constructor(asset: any) { @@ -20,7 +20,7 @@ export class AssetXML if(attributes.x !== undefined) this._y = parseInt(attributes.y); if(attributes.flipH !== undefined) this._flipH = (attributes.flipH === '1'); if(attributes.flipV !== undefined) this._flipV = (attributes.flipV === '1'); - if(attributes.usesPalette !== undefined) this._usesPalette = parseInt(attributes.usesPalette); + if(attributes.usesPalette !== undefined) this._usesPalette = (attributes.usesPalette === '1'); } } @@ -54,7 +54,7 @@ export class AssetXML return this._flipV; } - public get usesPalette(): number + public get usesPalette(): boolean { return this._usesPalette; } From a6a19a595bcec46571b5eb025fe1f63d9af45f0f Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 26 Feb 2021 01:59:32 -0500 Subject: [PATCH 2/3] Fix frame sequences --- src/mapping/mappers/asset/VisualizationMapper.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mapping/mappers/asset/VisualizationMapper.ts b/src/mapping/mappers/asset/VisualizationMapper.ts index 4760fa2..7c580f6 100644 --- a/src/mapping/mappers/asset/VisualizationMapper.ts +++ b/src/mapping/mappers/asset/VisualizationMapper.ts @@ -305,7 +305,7 @@ export class VisualizationMapper extends Mapper { if(!xml || !xml.length || !output) return; - const i = 0; + let i = 0; for(const offsetXML of xml) { @@ -316,6 +316,8 @@ export class VisualizationMapper extends Mapper if(offsetXML.y !== undefined) offset.y = offsetXML.y; output[i.toString()] = offset; + + i++; } } From bf9c6e940080e29bbcd7fce42586a2ab084ed15c Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 26 Feb 2021 01:59:48 -0500 Subject: [PATCH 3/3] Add furniture counter --- .../furniture/FurnitureConverter.ts | 2 +- .../furniture/FurnitureDownloader.ts | 65 ++++++++++++------- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/converters/furniture/FurnitureConverter.ts b/src/converters/furniture/FurnitureConverter.ts index de4e1aa..ad931ff 100644 --- a/src/converters/furniture/FurnitureConverter.ts +++ b/src/converters/furniture/FurnitureConverter.ts @@ -36,7 +36,7 @@ export class FurnitureConverter extends SWFConverter { await this._furniDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF) => { - spinner.text = 'Parsing Furniture: ' + habboAssetSwf.getDocumentClass(); + spinner.text = (`Parsing Furniture: ${ habboAssetSwf.getDocumentClass() } (${ this._furniDownloader.totalFinished } / ${ this._furniDownloader.totalItems })`); spinner.render(); diff --git a/src/converters/furniture/FurnitureDownloader.ts b/src/converters/furniture/FurnitureDownloader.ts index 6a339b5..b52470c 100644 --- a/src/converters/furniture/FurnitureDownloader.ts +++ b/src/converters/furniture/FurnitureDownloader.ts @@ -10,6 +10,9 @@ import { FurnitureDataConverter } from '../furnituredata/FurnitureDataConverter' @singleton() export class FurnitureDownloader { + private _totalItems: number = 0; + private _totalFinished: number = 0; + constructor( private readonly _furnitureDataConverter: FurnitureDataConverter, private readonly _configuration: Configuration, @@ -25,6 +28,7 @@ export class FurnitureDownloader if(!furniData) throw new Error('invalid_furnidata'); const classNames: string[] = []; + const revisions: number[] = []; if(furniData.roomitemtypes !== undefined) { @@ -42,17 +46,7 @@ export class FurnitureDownloader if(classNames.indexOf(className) >= 0) continue; classNames.push(className); - - try - { - await this.extractFurniture(revision, className, callback); - } - - catch (error) - { - console.log(); - console.error(`Error parsing ${ className }: ` + error.message); - } + revisions.push(revision); } } } @@ -73,22 +67,35 @@ export class FurnitureDownloader if(classNames.indexOf(className) >= 0) continue; classNames.push(className); - - try - { - await this.extractFurniture(revision, className, callback); - } - - catch (error) - { - console.log(); - console.error(`Error parsing ${ className }: ` + error.message); - - this._logger.logError(`Error parsing ${ className }: ` + error.message); - } + revisions.push(revision); } } } + + this._totalItems = classNames.length; + + this._totalFinished = 0; + + while(this._totalFinished < this._totalItems) + { + const className = classNames[this._totalFinished]; + const revision = revisions[this._totalFinished]; + + try + { + await this.extractFurniture(revision, className, callback); + } + + catch (error) + { + console.log(); + console.error(`Error parsing ${ className }: ` + error.message); + + this._logger.logError(`Error parsing ${ className }: ` + error.message); + } + + this._totalFinished++; + } } public async parseFurniData(): Promise @@ -123,4 +130,14 @@ export class FurnitureDownloader await callback(newHabboAssetSWF, className); } + + public get totalItems(): number + { + return this._totalItems; + } + + public get totalFinished(): number + { + return this._totalFinished; + } }