satisfactory-json
Advanced tools
Comparing version 0.0.20 to 0.0.21
@@ -51,5 +51,5 @@ /// <reference types="node" /> | ||
export declare class LoadingArchive extends BaseArchive { | ||
buffer: Buffer; | ||
cursor: number; | ||
bytesRead: number; | ||
private buffer; | ||
private cursor; | ||
constructor(buffer: Buffer); | ||
@@ -56,0 +56,0 @@ isSaving(): boolean; |
@@ -27,3 +27,2 @@ "use strict"; | ||
class LoadingArchive extends BaseArchive { | ||
//#endregion | ||
constructor(buffer) { | ||
@@ -30,0 +29,0 @@ super(); |
@@ -7,2 +7,3 @@ "use strict"; | ||
property.value = { | ||
type: '', | ||
values: [] | ||
@@ -9,0 +10,0 @@ }; |
@@ -6,6 +6,10 @@ "use strict"; | ||
if (ar.isLoading()) { | ||
property.value = {}; | ||
property.value = { | ||
keyType: '', | ||
valueType: '', | ||
values: [] | ||
}; | ||
} | ||
ar._String(property.value, 'name', false); // Tag.InnerType | ||
ar._String(property.value, 'type', false); // Tag.ValueType | ||
ar._String(property.value, 'keyType', false); // Tag.InnerType | ||
ar._String(property.value, 'valueType', false); // Tag.ValueType | ||
ar.transformAssertNullByte(false); // Tag.HasPropertyGuid | ||
@@ -17,45 +21,63 @@ const nullInt = { value: 0 }; | ||
} | ||
// TODO find a better way to make this bidirectional? | ||
if (ar.isSaving()) { | ||
const sar = ar; | ||
const keys = Object.keys(property.value.values); | ||
sar.writeInt(keys.length); | ||
for (const key of keys) { | ||
const value = property.value.values[key]; | ||
sar.writeInt(+key); // parse key to int | ||
for (const element of value) { | ||
ar._String(element, 'name'); // Tag.Name | ||
Property_1.default(ar, element); | ||
} | ||
sar.writeLengthPrefixedString('None'); // end of properties | ||
const count = { count: property.value.values.length }; | ||
ar._Int(count, 'count'); | ||
for (let i = 0; i < count.count; i++) { | ||
if (ar.isLoading()) { | ||
property.value.values[i] = { key: '', value: '' }; | ||
} | ||
} | ||
else { | ||
const lar = ar; | ||
const count = lar.readInt(); | ||
// console.log('counti', count); | ||
const mapValues = {}; | ||
for (let i = 0; i < count; i++) { | ||
const key = lar.readInt(); | ||
const props = []; | ||
while (true) { | ||
const innerProperty = { | ||
name: '', | ||
type: '', | ||
index: 0, | ||
value: '' | ||
}; | ||
ar._String(innerProperty, 'name'); // Tag.Name | ||
if (innerProperty.name === 'None') { | ||
break; // end of properties | ||
// transform key | ||
switch (property.value.keyType) { | ||
case 'IntProperty': | ||
ar._Int(property.value.values[i], 'key'); | ||
break; | ||
case 'ObjectProperty': | ||
if (ar.isLoading()) { | ||
property.value.values[i].key = {}; | ||
} | ||
Property_1.default(ar, innerProperty); | ||
props.push(innerProperty); | ||
// console.log('inner', innerProperty); | ||
} | ||
mapValues[key] = props; | ||
ar._String(property.value.values[i].key, 'levelName'); | ||
ar._String(property.value.values[i].key, 'pathName'); | ||
break; | ||
default: | ||
throw new Error('Unimplemented key type `' + property.value.keyType | ||
+ '` in MapProperty `' + property.name + '`'); | ||
} | ||
property.value.values = mapValues; | ||
// transform value | ||
switch (property.value.valueType) { | ||
case 'StructProperty': | ||
if (ar.isSaving()) { | ||
const sar = ar; | ||
for (const element of property.value.values[i].value) { | ||
ar._String(element, 'name'); // Tag.Name | ||
Property_1.default(ar, element); | ||
} | ||
sar.writeLengthPrefixedString('None'); // end of properties | ||
} | ||
else { | ||
const props = []; | ||
while (true) { | ||
const innerProperty = { | ||
name: '', | ||
type: '', | ||
index: 0, | ||
value: '' | ||
}; | ||
ar._String(innerProperty, 'name'); // Tag.Name | ||
if (innerProperty.name === 'None') { | ||
break; // end of properties | ||
} | ||
Property_1.default(ar, innerProperty); | ||
props.push(innerProperty); | ||
} | ||
property.value.values[i].value = props; | ||
} | ||
break; | ||
case 'ByteProperty': | ||
ar._Byte(property.value.values[i], 'value'); | ||
break; | ||
default: | ||
throw new Error('Unimplemented value type `' + property.value.valueType | ||
+ '` in MapProperty `' + property.name + '`'); | ||
} | ||
} | ||
} | ||
exports.default = transformMapProperty; |
@@ -14,3 +14,5 @@ "use strict"; | ||
if (ar.isLoading()) { | ||
property.value = {}; | ||
property.value = { | ||
type: '' | ||
}; | ||
} | ||
@@ -17,0 +19,0 @@ ar._String(property.value, 'type'); // Tag.StructName |
@@ -107,17 +107,30 @@ export interface SaveGame { | ||
export interface StructProperty extends BaseProperty { | ||
structUnknown: string; | ||
value: any; | ||
value: { | ||
type: string; | ||
[id: string]: any; | ||
}; | ||
} | ||
export interface ArrayProperty extends BaseProperty { | ||
structName?: string; | ||
structType?: string; | ||
structInnerType?: string; | ||
structUnknown?: string; | ||
value: any; | ||
value: { | ||
type: string; | ||
structName?: string; | ||
structType?: string; | ||
structInnerType?: string; | ||
structUnknown?: string; | ||
propertyGuid?: string; | ||
values: any[]; | ||
}; | ||
} | ||
export interface MapProperty extends BaseProperty { | ||
value: { | ||
[key: string]: any; | ||
keyType: string; | ||
valueType: string; | ||
values: MapEntry[]; | ||
}; | ||
} | ||
interface MapEntry { | ||
key: any; | ||
value: any; | ||
} | ||
export declare type Property = IntProperty | BoolProperty | FloatProperty | StringProperty | NameProperty | TextProperty | ByteProperty | EnumProperty | ObjectProperty | StructProperty | ArrayProperty | MapProperty; | ||
export {}; |
{ | ||
"name": "satisfactory-json", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "Convert Satisfactory save files to JSON and back", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70537
1845