Skip to content

Commit

Permalink
Removed pre-CSV export option (#358)
Browse files Browse the repository at this point in the history
Added ExportPreCsvIntGridFormat flag
  • Loading branch information
deepnight committed Jan 7, 2022
1 parent 3b26472 commit 3ac2513
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/electron.renderer/data/Project.hx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class Project {
public static function createEmpty(filePath:String) {
var p = new Project();
p.filePath.parseFilePath(filePath);
p.setFlag(DiscardPreCsvIntGrid, true);
p.createLevel();

return p;
Expand Down Expand Up @@ -246,7 +245,7 @@ class Project {
if( json.flags!=null )
for(f in json.flags ) {
var ev = try JsonTools.readEnum(ldtk.Json.ProjectFlag, f, true)
catch(e:Dynamic) null;
catch(_) null;

if( ev!=null )
p.flags.set(ev, true);
Expand Down
23 changes: 11 additions & 12 deletions src/electron.renderer/data/inst/LayerInstance.hx
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,6 @@ class LayerInstance {
arr;
},

intGrid: { // old IntGrid format
var arr = [];
if( !_project.hasFlag(DiscardPreCsvIntGrid) )
for(e in intGrid.keyValueIterator())
arr.push({
coordId: e.key,
v: e.value-1,
});
arr;
},

intGridCsv: {
var csv : Array<Int> = [];
if( def.type==IntGrid )
Expand Down Expand Up @@ -208,8 +197,18 @@ class LayerInstance {
entityInstances: entityInstances.map( function(ei) return ei.toJson(this) ),
}

if( _project.hasFlag(DiscardPreCsvIntGrid) )
if( _project.hasFlag(ExportPreCsvIntGridFormat) ) {
json.intGrid = {
var arr = [];
for(e in intGrid.keyValueIterator())
arr.push({
coordId: e.key,
v: e.value-1,
});
arr;
}
Reflect.deleteField(json, "intGrid");
}

return json;
}
Expand Down
3 changes: 0 additions & 3 deletions src/electron.renderer/ui/modal/DebugMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ class DebugMenu extends ui.modal.ContextMenu {
for(l in p.levels)
l.invalidateJsonCache();

// IntGrid CSV change
p.setFlag(DiscardPreCsvIntGrid, true);

// Tilesets
log.general(" -> Updating tileset data...");
for(td in p.defs.tilesets) {
Expand Down
8 changes: 4 additions & 4 deletions src/electron.renderer/ui/modal/panel/EditProject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class EditProject extends ui.modal.Panel {

var showAdvanced = false;
var allAdvancedOptions = [
ldtk.Json.ProjectFlag.DiscardPreCsvIntGrid,
ldtk.Json.ProjectFlag.ExportPreCsvIntGridFormat,
];

public function new() {
Expand Down Expand Up @@ -288,9 +288,9 @@ class EditProject extends ui.modal.Panel {
var jLabel = new J('<label for="$e"/>');
jLabel.appendTo(jLi);
switch e {
case DiscardPreCsvIntGrid:
jLabel.text("Discard pre-CSV IntGrid layer data in level data");
jInput.attr("title", L.t._("If enabled, the exported JSON will not contain the deprecated array \"intGrid\", making the file smaller. Only use this if your game API supports LDtk 0.8.x or more."));
case ExportPreCsvIntGridFormat:
jLabel.text("Export legacy pre-CSV IntGrid layers data");
jInput.attr("title", L.t._("If enabled, the exported JSON file will also contain the now deprecated array \"intGrid\". The file will be significantly larger.\nOnly use this if your game API only supports LDtk 0.8.x or less."));
case _:
}

Expand Down

0 comments on commit 3ac2513

Please sign in to comment.