Skip to content

Commit

Permalink
ADD json style to project panel
Browse files Browse the repository at this point in the history
  • Loading branch information
deepnight committed Aug 29, 2024
1 parent 4b7d9f2 commit c578ad5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
9 changes: 4 additions & 5 deletions app/assets/tpl/editProject.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,14 @@ <h2>
</dd>

<dt>
<label for="minify">Minify JSON</label>
<label for="jsonStyle">JSON indent style</label>
<info>
Enable this to save project JSON file without any "pretty" formatting (ie. white spaces and indentation).
This is NOT necessarily recommended if your project is stored on a versioning system (git, svn etc.) because this could cause issues with diffs and merging operations.
Only use this option if you really need to reduce the project files size.
You can adjust the way the JSON file is formated by LDtk (ie. white spaces and indentation).
Only use Minified if you really need to reduce the project files size. This will cause issues with diffs and merging operations.
</info>
</dt>
<dd>
<input type="checkbox" name="minify" id="minify"/>
<select id="jsonStyle"></select>
</dd>

<dt>
Expand Down
28 changes: 22 additions & 6 deletions src/electron.renderer/ui/modal/panel/EditProject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,29 @@ class EditProject extends ui.modal.Panel {
jForms.find(".backupRecommend").css("visibility", project.recommendsBackup() ? "visible" : "hidden");


// Json minifiying
var i = Input.linkToHtmlInput( project.minifyJson, jForms.find("[name=minify]") );
// Json style
var jSelect = jForms.find("select#jsonStyle");
var i = new form.input.EnumSelect(
jSelect,
ldtk.Json.JsonStyle,
()->project.jsonStyle,
(v)->{
project.jsonStyle = v;
},
(v)->switch v {
case Minified: L.t._("MINIFIED (minimal file size, no indentation)");
case Compact: L.t._("COMPACT (mostly indented, but small arrays are inlined)");
case Full: L.t._("FULL (fully indented)");
}
);
i.linkEvent(ProjectSettingsChanged);
i.onChange = ()->{
editor.invalidateAllLevelsCache;
recommendSaving();
}
// Json minifiying
// var i = Input.linkToHtmlInput( project.minifyJson, jForms.find("[name=minify]") );
// i.linkEvent(ProjectSettingsChanged);
// i.onChange = ()->{
// editor.invalidateAllLevelsCache;
// recommendSaving();
// }

// Simplified format
var i = Input.linkToHtmlInput( project.simplifiedExport, jForms.find("[name=simplifiedExport]") );
Expand Down

0 comments on commit c578ad5

Please sign in to comment.