mirror of
https://github.com/billsonnn/nitro-converter.git
synced 2025-01-18 22:36:28 +01:00
Add furniture counter
This commit is contained in:
parent
a6a19a595b
commit
bf9c6e9400
@ -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();
|
||||||
|
|
||||||
|
@ -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,22 +67,35 @@ 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);
|
|
||||||
|
|
||||||
this._logger.logError(`Error parsing ${ className }: ` + error.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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<IFurnitureData>
|
public async parseFurniData(): Promise<IFurnitureData>
|
||||||
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user