Fix issues from newly found class type
This commit is contained in:
parent
ad439e4832
commit
1b06d9ca94
3 changed files with 27 additions and 19 deletions
|
|
@ -100,7 +100,7 @@ stringval "string value"
|
|||
|
||||
class = key:stringkey singlequote_mark chars:pathchar* singlequote_mark { return [ key, chars.join("") ]; }
|
||||
|
||||
keychar = sequence:( [a-zA-Z] / "_" ) { return sequence; }
|
||||
keychar = sequence:( [a-zA-Z0-9] / "_" ) { return sequence; }
|
||||
|
||||
pathchar = sequence:(
|
||||
[a-zA-Z0-9]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
function deparseJson(input) {
|
||||
function deparseJson(input, key) {
|
||||
switch (typeof input) {
|
||||
case "object":
|
||||
return deparseObject(input);
|
||||
case "number":
|
||||
return deparseNumber(input);
|
||||
return deparseNumber(input, key);
|
||||
case "string":
|
||||
return deparseString(input);
|
||||
case "undefined":
|
||||
|
|
@ -35,7 +35,7 @@ function deparseObject(input) {
|
|||
Object.keys(input).forEach(function (key, idx, array) {
|
||||
output += key;
|
||||
output += nameSeparator;
|
||||
output += deparseJson(input[key]);
|
||||
output += deparseJson(input[key], key);
|
||||
|
||||
if (idx !== array.length - 1) {
|
||||
// Not the last item
|
||||
|
|
@ -49,14 +49,20 @@ function deparseObject(input) {
|
|||
|
||||
function deparseArray(input) {
|
||||
// We have one funky array option, where its 2 values and one of them is a recognised class.
|
||||
if (input[0] === "BlueprintGeneratedClass") {
|
||||
return "BlueprintGeneratedClass" + "'" + input[1] + "'";
|
||||
}
|
||||
if (input[0] === "Blueprint") {
|
||||
return "Blueprint" + "'" + input[1] + "'";
|
||||
}
|
||||
if (input[0] === "SoundWave") {
|
||||
return "SoundWave" + "'" + input[1] + "'"
|
||||
// These are here for easier maintenance, as adding any new ones should just work. These all
|
||||
// Work off string equality, see found below.
|
||||
var specialCases = [
|
||||
'BlueprintGeneratedClass',
|
||||
'Blueprint',
|
||||
'SoundWave',
|
||||
'Texture2D'
|
||||
];
|
||||
|
||||
var found = specialCases.indexOf(input[0]);
|
||||
if (found > -1) {
|
||||
// We found one of our special cases!
|
||||
var val = specialCases[found];
|
||||
return val + "'" + input[1] + "'";
|
||||
}
|
||||
|
||||
var beginObject = '(';
|
||||
|
|
@ -78,8 +84,15 @@ function deparseArray(input) {
|
|||
return output;
|
||||
}
|
||||
|
||||
function deparseNumber(input) {
|
||||
// All numbers seem to be a string to 6 decimal places
|
||||
function deparseNumber(input, key) {
|
||||
// Any number which has a decimal is stored to 6 decimal places
|
||||
// Except for IDs. Unless they actually have such a number... erm...
|
||||
if (key.substr(key.length - 2, 2) === "ID") {
|
||||
if (input % 1 === 0) {
|
||||
return Number(input).toString();
|
||||
}
|
||||
// Else drop out and return as normal
|
||||
}
|
||||
return Number(input).toFixed(6);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,6 @@ function fromAtlasToJson() {
|
|||
|
||||
function fromJsonToAtlas() {
|
||||
var input = JSON.parse(jsonEditor.getValue());
|
||||
|
||||
console.log(input);
|
||||
|
||||
var output = deparseJson(input);
|
||||
|
||||
console.log(output);
|
||||
atlasEditor.setValue(output);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue