Further fixes

This commit is contained in:
SpreedBLood 2021-02-04 02:49:10 +01:00
parent bc60a2b244
commit 7a7d913282
9 changed files with 56 additions and 42 deletions

View File

@ -1,18 +0,0 @@
output.folder.furniture=/home/user/WebstormProjects/sites/assets.nitro.se/game/dcr/furniture-test/
output.folder.figure=/home/user/WebstormProjects/sites/assets.nitro.se/game/gordon/figure-test/
output.folder.effect=/home/user/WebstormProjects/sites/assets.nitro.se/game/gordon/effect-test/
output.folder.pet=/home/user/WebstormProjects/sites/assets.nitro.se/game/gordon/pet-test/
furnidata.url=http://assets.nitro.se/game/gamedata/furnidata-entry.xml
figuremap.url=http://assets.nitro.se/game/gordon/PRODUCTION-201701242205-837386173/figuremap.xml
effectmap.url=http://assets.nitro.se/game/gordon/PRODUCTION-201701242205-837386173/effectmap.xml
external_vars.url=http://assets.nitro.se/game/gamedata/external_variables.txt
dynamic.download.url.furniture=http://assets.nitro.se/game/dcr/endrit/hof_furni/%className%.swf
dynamic.download.url.figure=http://assets.nitro.se/game/gordon/PRODUCTION-201701242205-837386173/%className%.swf
dynamic.download.url.effect=http://assets.nitro.se/game/gordon/PRODUCTION-201701242205-837386173/%className%.swf
dynamic.download.url.pet=http://assets.nitro.se/game/gordon/PRODUCTION-201701242205-837386173/%className%.swf
convert.furniture=0
convert.figure=0
convert.effect=1
convert.pet=0
figure.rotation.enabled=0
figure.skip.non-existing.asset.images=0

View File

@ -21,5 +21,6 @@
"png-stream": "^1.0.5", "png-stream": "^1.0.5",
"stream-to-array": "^2.3.0", "stream-to-array": "^2.3.0",
"xml2js": "^0.4.23" "xml2js": "^0.4.23"
} },
"devDependencies": {}
} }

20
src/config.json Normal file
View File

@ -0,0 +1,20 @@
{
"output.folder.furniture": "/home/user/WebstormProjects/sites/assets.nitro.se/game/dcr/furniture-test/",
"output.folder.figure": "/home/user/WebstormProjects/sites/assets.nitro.se/game/gordon/figure-test/",
"output.folder.effect": "/home/user/WebstormProjects/sites/assets.nitro.se/game/gordon/effect-test/",
"output.folder.pet": "/home/user/WebstormProjects/sites/assets.nitro.se/game/gordon/pet-test/",
"furnidata.url": "http://assets.nitro.se/game/gamedata/furnidata-entry.xml",
"figuremap.url": "http://assets.nitro.se/game/gordon/PRODUCTION-201701242205-837386173/figuremap.xml",
"effectmap.url": "http://assets.nitro.se/game/gordon/PRODUCTION-201701242205-837386173/effectmap.xml",
"external_vars.url": "http://assets.nitro.se/game/gamedata/external_variables.txt",
"dynamic.download.url.furniture": "/home/user/WebstormProjects/sites/assets.nitro.se/game/dcr/endrit/hof_furni/%className%.swf",
"dynamic.download.url.figure": "/home/user/WebstormProjects/sites/assets.nitro.se/game/gordon/PRODUCTION-201701242205-837386173/%className%.swf",
"dynamic.download.url.effect": "/home/user/WebstormProjects/sites/assets.nitro.se/game/gordon/PRODUCTION-201701242205-837386173/%className%.swf",
"dynamic.download.url.pet": "/home/user/WebstormProjects/sites/assets.nitro.se/game/gordon/PRODUCTION-201701242205-837386173/%className%.swf",
"convert.furniture": "1",
"convert.figure": "0",
"convert.effect": "0",
"convert.pet": "0",
"figure.rotation.enabled": "0",
"figure.skip.non-existing.asset.images": "0"
}

View File

@ -1,6 +1,8 @@
const fs = require('fs/promises'); const fs = require('fs/promises');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const config = require('../config.json');
export default class Configuration { export default class Configuration {
private readonly _config: Map<string, string>; private readonly _config: Map<string, string>;
@ -10,19 +12,8 @@ export default class Configuration {
} }
async init() { async init() {
const content = await fs.readFile("/home/user/git/nitro-asset-converter-node/config.ini"); for (const key of Object.keys(config)) {
this._config.set(key, config[key]);
this.parseContent(content.toString("utf-8"));
}
private parseContent(content: string) {
const config: string[] = content.split("\n");
for (const configEntry of config) {
const configEntrySplit = configEntry.split("=");
const configKey = configEntrySplit[0];
const configValue = configEntrySplit[1];
this._config.set(configKey, configValue);
} }
} }
@ -44,6 +35,13 @@ export default class Configuration {
const fetchData = await fetch(url); const fetchData = await fetch(url);
const textData = await fetchData.text(); const textData = await fetchData.text();
this.parseContent(textData); const config: string[] = textData.split("\n");
for (const configEntry of config) {
const configEntrySplit = configEntry.split("=");
const configKey = configEntrySplit[0];
const configValue = configEntrySplit[1];
this._config.set(configKey, configValue);
}
} }
} }

View File

@ -69,7 +69,9 @@ export default class FurniJsonMapper {
furniAsset.source = SpriteSheetConverter.imageSource.get(asset.name) as string; furniAsset.source = SpriteSheetConverter.imageSource.get(asset.name) as string;
} }
if (asset.x !== undefined)
furniAsset.x = parseInt(asset.x.toString()); furniAsset.x = parseInt(asset.x.toString());
if (asset.y !== undefined)
furniAsset.y = parseInt(asset.y.toString()); furniAsset.y = parseInt(asset.y.toString());
furniAsset.flipH = asset.flipH as any; furniAsset.flipH = asset.flipH as any;
assets[asset.name] = furniAsset; assets[asset.name] = furniAsset;

View File

@ -67,8 +67,8 @@ export default class SpriteSheetConverter {
async packImages(documentClass: string, outputFolder: string, images: Array<{ path: string, contents: Buffer }>): Promise<ArchiveType | null> { async packImages(documentClass: string, outputFolder: string, images: Array<{ path: string, contents: Buffer }>): Promise<ArchiveType | null> {
let options = { let options = {
textureName: documentClass, textureName: documentClass,
width: 1024, width: 3072,
height: 1024, height: 2048,
fixedSize: false, fixedSize: false,
allowRotation: true, allowRotation: true,
detectIdentical: true, detectIdentical: true,

View File

@ -26,7 +26,7 @@ export default class FigureDownloader {
for (const lib of map.lib) { for (const lib of map.lib) {
const info = lib['$']; const info = lib['$'];
const className: string = info.id.split("\\*")[0]; const className: string = info.id.split("\\*")[0];
if (className === "hh_human_fx") { if (className === "hh_human_fx" || className === "hh_pets") {
continue; continue;
} }
@ -39,6 +39,8 @@ export default class FigureDownloader {
if (className !== "jacket_U_snowwar4_team1" && if (className !== "jacket_U_snowwar4_team1" &&
className !== "jacket_U_snowwar4_team2") { //TODO: Figure out why snowstorm assets aren't converting... className !== "jacket_U_snowwar4_team2") { //TODO: Figure out why snowstorm assets aren't converting...
if (className !== "hh_human_hats") continue;
const url = this._config.getValue("dynamic.download.url.figure").replace("%className%", className); const url = this._config.getValue("dynamic.download.url.figure").replace("%className%", className);
let buffer: Buffer | null = null; let buffer: Buffer | null = null;

View File

@ -104,9 +104,14 @@ export default class FurnitureDownloader {
async parseFurniData() { async parseFurniData() {
const furniDataFetch = this._config.getValue("furnidata.url"); const furniDataFetch = this._config.getValue("furnidata.url");
if (furniDataFetch.includes("http")) {
const furniFetch = await fetch(furniDataFetch); const furniFetch = await fetch(furniDataFetch);
const furniData = await furniFetch.text(); const furniData = await furniFetch.text();
return await parser.parseStringPromise(furniData); return await parser.parseStringPromise(furniData);
} else {
const content = await readFile(furniDataFetch);
return await parser.parseStringPromise(content);
}
} }
} }

View File

@ -10,5 +10,9 @@
"noImplicitAny": true, "noImplicitAny": true,
"esModuleInterop": true, "esModuleInterop": true,
"resolveJsonModule": true "resolveJsonModule": true
} },
"include": [
"src/config.json",
"src/**/*.ts"
]
} }