This commit is contained in:
SpreedBLood 2021-03-09 00:22:05 +01:00
commit f37a028fc1
5 changed files with 49 additions and 29 deletions

View File

@ -36,7 +36,7 @@ export class FurnitureConverter extends SWFConverter
{ {
await this._furniDownloader.download(directory, async (habboAssetSwf: HabboAssetSWF) => 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(); spinner.render();

View File

@ -10,6 +10,9 @@ import { FurnitureDataConverter } from '../furnituredata/FurnitureDataConverter'
@singleton() @singleton()
export class FurnitureDownloader export class FurnitureDownloader
{ {
private _totalItems: number = 0;
private _totalFinished: number = 0;
constructor( constructor(
private readonly _furnitureDataConverter: FurnitureDataConverter, private readonly _furnitureDataConverter: FurnitureDataConverter,
private readonly _configuration: Configuration, private readonly _configuration: Configuration,
@ -25,6 +28,7 @@ export class FurnitureDownloader
if(!furniData) throw new Error('invalid_furnidata'); if(!furniData) throw new Error('invalid_furnidata');
const classNames: string[] = []; const classNames: string[] = [];
const revisions: number[] = [];
if(furniData.roomitemtypes !== undefined) if(furniData.roomitemtypes !== undefined)
{ {
@ -42,17 +46,7 @@ export class FurnitureDownloader
if(classNames.indexOf(className) >= 0) continue; if(classNames.indexOf(className) >= 0) continue;
classNames.push(className); classNames.push(className);
revisions.push(revision);
try
{
await this.extractFurniture(revision, className, callback);
}
catch (error)
{
console.log();
console.error(`Error parsing ${ className }: ` + error.message);
}
} }
} }
} }
@ -73,6 +67,19 @@ export class FurnitureDownloader
if(classNames.indexOf(className) >= 0) continue; if(classNames.indexOf(className) >= 0) continue;
classNames.push(className); classNames.push(className);
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 try
{ {
@ -86,8 +93,8 @@ export class FurnitureDownloader
this._logger.logError(`Error parsing ${ className }: ` + error.message); this._logger.logError(`Error parsing ${ className }: ` + error.message);
} }
}
} this._totalFinished++;
} }
} }
@ -123,4 +130,14 @@ export class FurnitureDownloader
await callback(newHabboAssetSWF, className); await callback(newHabboAssetSWF, className);
} }
public get totalItems(): number
{
return this._totalItems;
}
public get totalFinished(): number
{
return this._totalFinished;
}
} }

View File

@ -67,6 +67,7 @@ export class AssetMapper extends Mapper
if(assetXML.y !== undefined) asset.y = assetXML.y; if(assetXML.y !== undefined) asset.y = assetXML.y;
if(assetXML.flipH !== undefined) asset.flipH = assetXML.flipH; if(assetXML.flipH !== undefined) asset.flipH = assetXML.flipH;
if(assetXML.flipV !== undefined) asset.flipV = assetXML.flipV; if(assetXML.flipV !== undefined) asset.flipV = assetXML.flipV;
if(assetXML.usesPalette !== undefined) asset.usesPalette = assetXML.usesPalette;
output[assetXML.name] = asset; output[assetXML.name] = asset;
} }

View File

@ -305,7 +305,7 @@ export class VisualizationMapper extends Mapper
{ {
if(!xml || !xml.length || !output) return; if(!xml || !xml.length || !output) return;
const i = 0; let i = 0;
for(const offsetXML of xml) for(const offsetXML of xml)
{ {
@ -316,6 +316,8 @@ export class VisualizationMapper extends Mapper
if(offsetXML.y !== undefined) offset.y = offsetXML.y; if(offsetXML.y !== undefined) offset.y = offsetXML.y;
output[i.toString()] = offset; output[i.toString()] = offset;
i++;
} }
} }

View File

@ -6,7 +6,7 @@ export class AssetXML
private readonly _y: number; private readonly _y: number;
private readonly _flipH: boolean; private readonly _flipH: boolean;
private readonly _flipV: boolean; private readonly _flipV: boolean;
private readonly _usesPalette: number; private readonly _usesPalette: boolean;
constructor(asset: any) constructor(asset: any)
{ {
@ -20,7 +20,7 @@ export class AssetXML
if(attributes.x !== undefined) this._y = parseInt(attributes.y); if(attributes.x !== undefined) this._y = parseInt(attributes.y);
if(attributes.flipH !== undefined) this._flipH = (attributes.flipH === '1'); if(attributes.flipH !== undefined) this._flipH = (attributes.flipH === '1');
if(attributes.flipV !== undefined) this._flipV = (attributes.flipV === '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; return this._flipV;
} }
public get usesPalette(): number public get usesPalette(): boolean
{ {
return this._usesPalette; return this._usesPalette;
} }