satisfactory-json
Advanced tools
Comparing version 0.0.54 to 0.0.55
@@ -62,7 +62,10 @@ "use strict"; | ||
function getVar(ctx, name) { | ||
var _a; | ||
switch (name.toString().charAt(0)) { | ||
case '#': | ||
case '#': // temporary with indirection | ||
return ctx.tmp[getVar(ctx, name.toString().substring(1))]; | ||
case '_': | ||
case '_': // temporary | ||
return ctx.tmp[name]; | ||
case '^': // parent | ||
return (_a = ctx.parent) === null || _a === void 0 ? void 0 : _a.obj[name.toString().substring(1)]; | ||
default: | ||
@@ -69,0 +72,0 @@ return ctx.obj[name]; |
@@ -5,2 +5,3 @@ "use strict"; | ||
var TransformationEngine_1 = require("../../engine/TransformationEngine"); | ||
var FINetworkTrace_1 = require("./structs/FINetworkTrace"); | ||
var TextProperty_1 = require("./TextProperty"); | ||
@@ -89,69 +90,7 @@ function transformArrayProperty(builder) { | ||
.loop('_itemCount', function (builder) { | ||
// Handle special cases for InventoryItem(FicsIt-Networks mod), Guid and LinearColor | ||
builder.if(function (ctx) { | ||
return ctx.parent !== undefined && | ||
ctx.parent.obj.structInnerType === 'InventoryItem'; | ||
builder.if(function (ctx) { return ctx.parent !== undefined; }, function (builder) { | ||
transformSpecialStructArray(builder); | ||
}, function (builder) { | ||
builder | ||
.elem('_index') | ||
.str('unk1', false) | ||
.str('itemName') | ||
.str('levelName') | ||
.str('pathName') | ||
// The Inventory Item is stored here without properties | ||
.endElem(); | ||
}, function (builder) { | ||
builder.if(function (ctx) { | ||
return ctx.parent !== undefined && | ||
ctx.parent.obj.structInnerType === 'Guid'; | ||
}, function (builder) { | ||
builder.hex('#_index', 16); | ||
}, function (builder) { | ||
// else | ||
builder.if(function (ctx) { | ||
return ctx.parent !== undefined && | ||
ctx.parent.obj.structInnerType === 'LinearColor'; | ||
}, function (builder) { | ||
builder | ||
.elem('_index') | ||
.float('r') | ||
.float('g') | ||
.float('b') | ||
.float('a') | ||
.endElem(); | ||
}, function (builder) { | ||
// else | ||
builder | ||
.elem('_index') | ||
// parse inner properties | ||
// TODO fix loop for writing | ||
.arr('properties') | ||
.exec(function (ctx) { | ||
return (ctx.tmp._propertiesCount = ctx.isLoading | ||
? 999999999 | ||
: ctx.obj.length); | ||
}) | ||
.loop('_propertiesCount', function (builder) { | ||
builder | ||
.exec(function (ctx) { | ||
if (!ctx.isLoading) { | ||
ctx.tmp._name = ctx.obj[ctx.tmp._index].name; | ||
} | ||
}) | ||
.str('_name') | ||
.if(function (ctx) { return ctx.tmp._name === 'None'; }, function (builder) { return builder.break(); }) | ||
.elem('_index') | ||
.exec(function (ctx) { return (ctx.obj.name = ctx.tmp._name); }) | ||
.call(TransformationEngine_1.RegisteredFunction.transformProperty) | ||
.endElem(); | ||
}) | ||
.if(function (ctx) { return !ctx.isLoading; }, function (builder) { | ||
builder | ||
.exec(function (ctx) { return (ctx.tmp._none = 'None'); }) | ||
.str('_none'); | ||
}) | ||
.endArr() | ||
.endElem(); | ||
}); | ||
}); | ||
// else | ||
transformOrdinaryStructArray(builder); | ||
}); | ||
@@ -177,2 +116,70 @@ }) | ||
exports.transformArrayProperty = transformArrayProperty; | ||
/** | ||
* Handles special cases for arrays of structs based on the structInnerType | ||
*/ | ||
function transformSpecialStructArray(builder) { | ||
// Handle special cases for InventoryItem, FINNetworkTrace(FicsIt-Networks mod), Guid and LinearColor | ||
builder.switch('^structInnerType', { | ||
InventoryItem: function (builder) { | ||
builder | ||
.elem('_index') | ||
.str('unk1', false) | ||
.str('itemName') | ||
.str('levelName') | ||
.str('pathName') | ||
// The Inventory Item is stored here without properties | ||
.endElem(); | ||
}, | ||
Guid: function (builder) { | ||
builder.hex('#_index', 16); | ||
}, | ||
LinearColor: function (builder) { | ||
builder | ||
.elem('_index') | ||
.float('r') | ||
.float('g') | ||
.float('b') | ||
.float('a') | ||
.endElem(); | ||
}, | ||
FINNetworkTrace: function (builder) { | ||
builder.elem('_index'); | ||
FINetworkTrace_1.transformFINNetworkTrace(builder); | ||
builder.endElem(); | ||
}, | ||
$default: function (builder) { return transformOrdinaryStructArray(builder); }, | ||
}); | ||
} | ||
/** | ||
* Transforms the default case for an array of structs | ||
*/ | ||
function transformOrdinaryStructArray(builder) { | ||
builder | ||
.elem('_index') | ||
// parse inner properties | ||
// TODO fix loop for writing | ||
.arr('properties') | ||
.exec(function (ctx) { | ||
return (ctx.tmp._propertiesCount = ctx.isLoading ? 999999999 : ctx.obj.length); | ||
}) | ||
.loop('_propertiesCount', function (builder) { | ||
builder | ||
.exec(function (ctx) { | ||
if (!ctx.isLoading) { | ||
ctx.tmp._name = ctx.obj[ctx.tmp._index].name; | ||
} | ||
}) | ||
.str('_name') | ||
.if(function (ctx) { return ctx.tmp._name === 'None'; }, function (builder) { return builder.break(); }) | ||
.elem('_index') | ||
.exec(function (ctx) { return (ctx.obj.name = ctx.tmp._name); }) | ||
.call(TransformationEngine_1.RegisteredFunction.transformProperty) | ||
.endElem(); | ||
}) | ||
.if(function (ctx) { return !ctx.isLoading; }, function (builder) { | ||
builder.exec(function (ctx) { return (ctx.tmp._none = 'None'); }).str('_none'); | ||
}) | ||
.endArr() | ||
.endElem(); | ||
} | ||
//# sourceMappingURL=ArrayProperty.js.map |
{ | ||
"name": "satisfactory-json", | ||
"version": "0.0.54", | ||
"version": "0.0.55", | ||
"description": "Convert Satisfactory save files to JSON and back", | ||
@@ -5,0 +5,0 @@ "author": "ficsit-felix", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4400
292349