Skip to content

Commit

Permalink
ADD support for custom json style
Browse files Browse the repository at this point in the history
  • Loading branch information
deepnight committed Aug 29, 2024
1 parent 6b10d8f commit 5b5af3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/electron.renderer/data/Project.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Project {
public var defaultLevelBgColor : UInt;

public var minifyJson = false;
public var jsonStyle : ldtk.Json.JsonStyle = ldtk.Json.JsonStyle.Full;
public var externalLevels = false;
public var exportTiled = false;
public var simplifiedExport = false;
Expand Down Expand Up @@ -300,6 +301,7 @@ class Project {
p.externalLevels = JsonTools.readBool(json.externalLevels, false);

p.minifyJson = JsonTools.readBool( json.minifyJson, false );
p.jsonStyle = JsonTools.readEnum( ldtk.Json.JsonStyle, json.jsonStyle, false, Compact ); // uses Compact for pre-1.5.4 versions
p.exportTiled = JsonTools.readBool( json.exportTiled, false );
p.simplifiedExport = JsonTools.readBool( json.simplifiedExport, false );
p.backupOnSave = JsonTools.readBool( json.backupOnSave, false );
Expand Down Expand Up @@ -652,6 +654,7 @@ class Project {
defaultLevelBgColor: JsonTools.writeColor(defaultLevelBgColor),

minifyJson: minifyJson,
jsonStyle: JsonTools.writeEnum(jsonStyle, false),
externalLevels: externalLevels,
exportTiled: exportTiled,
simplifiedExport: simplifiedExport,
Expand Down
6 changes: 5 additions & 1 deletion src/electron.renderer/ui/ProjectSaver.hx
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,11 @@ class ProjectSaver extends dn.Process {
public static function jsonStringify(p:data.Project, obj:Dynamic, ?skipHeader=false) {
return dn.data.JsonPretty.stringify(
obj,
p.minifyJson ? Minified : Compact,
switch p.jsonStyle {
case Minified: Minified;
case Compact: Compact;
case Full: Full;
},
skipHeader ? null : Const.JSON_HEADER
);
}
Expand Down

0 comments on commit 5b5af3e

Please sign in to comment.