diff --git a/CHANGES b/CHANGES
index eebb3e2..325649d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,6 @@
[4.10.1]
- Fixed file path editing for FileChooser may result in a crash.
+- Option to append input file extensions to region names.
- Window validates and fixes its dimensions on startup.
- Minor UI cleanup and improvements.
diff --git a/assets/i18n/bundle.properties b/assets/i18n/bundle.properties
index e4e29c7..1482ca8 100644
--- a/assets/i18n/bundle.properties
+++ b/assets/i18n/bundle.properties
@@ -224,7 +224,7 @@ dPbChangeBackground = Change background
dInputFileTitleFile = Input file properties
dInputFileTitleDir = Input directory properties
dInputFileTitleFileIgnore = Ignored file properties
-dInputFileRegionsPrefix = Regions' prefix
+dInputFileRegionsPrefix = Region prefix
dInputFileRegionName = Region name
dInputFileRecursive = Recursive
dInputFileFlattenPaths = Flatten paths
@@ -264,7 +264,7 @@ psWrapY = Wrap Y
psJpegQuality = Jpeg quality
psScaleFactors = Scale factors
-psUseFastAlgorithm = Use fast algorithm
+psUseFastAlgorithm = Fast algorithm
psEdgePadding = Edge padding
psStripWhitespaceX = Strip whitespace X
psStripWhitespaceY = Strip whitespace Y
@@ -285,6 +285,7 @@ psSquare = Force square
psLimitMemory = Limit memory
psLegacyOutput = Legacy format
psPrettyPrint = Pretty print
+psKeepFileExtensions = Keep file extensions
psTtPot = If checked, output pages will have power of two dimensions.
psTtMof = If checked, output pages will have multiple of four dimensions.
@@ -322,6 +323,7 @@ psTtScaleSuffix = For each scale, the suffix to use for the output files. If omi
psTtLegacyOutput = Use the old LibGDX texture atlas data file format (for pre LibGDX 1.9.13 projects)
psTtPrettyPrint = Render more explicit and human-readable atlas data files. \
Has effect only for the new LibGDX texture atlas format. See "Legacy format" option.
+psTtKeepFileExtensions = Append the image file extension to region names (if the region name is not set explicitelly).
canvasInfoNoPageToShow = N/A
canvasInfoTtZoom = Zoom
diff --git a/assets/lml/panePackSettings.lml b/assets/lml/panePackSettings.lml
index 5155072..4613bf5 100644
--- a/assets/lml/panePackSettings.lml
+++ b/assets/lml/panePackSettings.lml
@@ -213,6 +213,7 @@
@psLimitMemory
+ @psKeepFileExtensions
diff --git a/core/src/com/crashinvaders/texturepackergui/controllers/main/MainController.java b/core/src/com/crashinvaders/texturepackergui/controllers/main/MainController.java
index e3107b5..457b8d4 100644
--- a/core/src/com/crashinvaders/texturepackergui/controllers/main/MainController.java
+++ b/core/src/com/crashinvaders/texturepackergui/controllers/main/MainController.java
@@ -24,10 +24,7 @@
import com.crashinvaders.texturepackergui.controllers.*;
import com.crashinvaders.texturepackergui.controllers.main.filetype.*;
import com.crashinvaders.texturepackergui.controllers.main.inputfiles.PackInputFilesController;
-import com.crashinvaders.texturepackergui.controllers.model.ModelService;
-import com.crashinvaders.texturepackergui.controllers.model.PackModel;
-import com.crashinvaders.texturepackergui.controllers.model.ProjectModel;
-import com.crashinvaders.texturepackergui.controllers.model.ScaleFactorModel;
+import com.crashinvaders.texturepackergui.controllers.model.*;
import com.crashinvaders.texturepackergui.controllers.model.filetype.*;
import com.crashinvaders.texturepackergui.controllers.projectserializer.ProjectSerializer;
import com.crashinvaders.texturepackergui.events.*;
@@ -241,6 +238,7 @@ public void resize(Stage stage, int width, int height) {
switch (event.getProperty()) {
case NAME:
case SCALE_FACTORS:
+ case KEEP_FILE_EXTENSIONS:
case SETTINGS:
if (event.getPack() == getSelectedPack()) {
updateViewsFromPack(event.getPack());
@@ -447,6 +445,7 @@ public void clicked(InputEvent e, float x, float y) {
break;
}
case "cbPrettyPrint": settings.prettyPrint = checkBox.isChecked(); break;
+ case "cbKeepFileExtensions": pack.setKeepInputFileExtensions(checkBox.isChecked()); break;
}
}
@@ -584,6 +583,7 @@ private void updateViewsFromPack(PackModel pack) {
actorsPackSettings.cbLimitMemory.setChecked(settings.limitMemory);
actorsPackSettings.cbLegacyOutput.setChecked(settings.legacyOutput);
actorsPackSettings.cbPrettyPrint.setChecked(settings.prettyPrint);
+ actorsPackSettings.cbKeepFileExtensions.setChecked(pack.isKeepInputFileExtensions());
((IntSeekBarModel) actorsPackSettings.skbMinPageWidth.getModel()).setValue(settings.minWidth, false);
((IntSeekBarModel) actorsPackSettings.skbMinPageHeight.getModel()).setValue(settings.minHeight, false);
diff --git a/core/src/com/crashinvaders/texturepackergui/controllers/main/PackSettingsActors.java b/core/src/com/crashinvaders/texturepackergui/controllers/main/PackSettingsActors.java
index 857928e..65f6d62 100644
--- a/core/src/com/crashinvaders/texturepackergui/controllers/main/PackSettingsActors.java
+++ b/core/src/com/crashinvaders/texturepackergui/controllers/main/PackSettingsActors.java
@@ -41,4 +41,5 @@ public class PackSettingsActors {
@LmlActor("cbLimitMemory") VisCheckBox cbLimitMemory;
@LmlActor("cbLegacyOutput") VisCheckBox cbLegacyOutput;
@LmlActor("cbPrettyPrint") VisCheckBox cbPrettyPrint;
+ @LmlActor("cbKeepFileExtensions") VisCheckBox cbKeepFileExtensions;
}
diff --git a/core/src/com/crashinvaders/texturepackergui/controllers/main/inputfiles/InputFilePropertiesDialogController.java b/core/src/com/crashinvaders/texturepackergui/controllers/main/inputfiles/InputFilePropertiesDialogController.java
index e3419a8..c264b6c 100644
--- a/core/src/com/crashinvaders/texturepackergui/controllers/main/inputfiles/InputFilePropertiesDialogController.java
+++ b/core/src/com/crashinvaders/texturepackergui/controllers/main/inputfiles/InputFilePropertiesDialogController.java
@@ -3,7 +3,6 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
-import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.PixmapIO;
import com.badlogic.gdx.scenes.scene2d.Group;
@@ -15,12 +14,11 @@
import com.crashinvaders.common.scene2d.Scene2dUtils;
import com.crashinvaders.common.scene2d.ShrinkContainer;
import com.crashinvaders.texturepackergui.controllers.ErrorDialogController;
-import com.crashinvaders.texturepackergui.controllers.model.InputFile;
-import com.crashinvaders.texturepackergui.controllers.model.ModelService;
-import com.crashinvaders.texturepackergui.controllers.model.ModelUtils;
+import com.crashinvaders.texturepackergui.controllers.model.*;
import com.crashinvaders.texturepackergui.controllers.ninepatcheditor.NinePatchEditorDialog;
import com.crashinvaders.texturepackergui.controllers.ninepatcheditor.NinePatchEditorModel;
import com.crashinvaders.texturepackergui.events.InputFilePropertyChangedEvent;
+import com.crashinvaders.texturepackergui.events.PackPropertyChangedEvent;
import com.crashinvaders.texturepackergui.events.ShowToastEvent;
import com.crashinvaders.texturepackergui.utils.AppIconProvider;
import com.crashinvaders.texturepackergui.utils.FileUtils;
@@ -89,11 +87,21 @@ public class InputFilePropertiesDialogController implements ActionContainer {
}
@OnEvent(InputFilePropertyChangedEvent.class) void onEvent(InputFilePropertyChangedEvent event) {
- if (event.getInputFile() != inputFile || ignoreInputFileUpdateEvents) return;
+ if (!isShown() || event.getInputFile() != inputFile || ignoreInputFileUpdateEvents) return;
mapDataFromModel();
}
+ @OnEvent(PackPropertyChangedEvent.class) void onEvent(PackPropertyChangedEvent event) {
+ if (!isShown() || inputFile == null) return;
+
+ switch (event.getProperty()) {
+ case KEEP_FILE_EXTENSIONS:
+ mapDataFromModel();
+ break;
+ }
+ }
+
@LmlAction("showFilePicker") void showFilePicker() {
final FileChooser fileChooser = new FileChooser(inputFile.getFileHandle().parent(), FileChooser.Mode.OPEN);
fileChooser.setIconProvider(new AppIconProvider(fileChooser));
@@ -128,8 +136,7 @@ public void selected (Array files) {
dialog.hide();
}
- @LmlAction("onFilePrefixTextChanged")
- void onFilePrefixFocusChanged() {
+ @LmlAction("onFilePrefixTextChanged") void onFilePrefixFocusChanged() {
inputFile.setDirFilePrefix(edtFilePrefix.getText().trim());
}
@@ -144,8 +151,7 @@ void onFilePrefixFocusChanged() {
inputFile.setFlattenPaths(checked);
}
- @LmlAction("onRegionNameTextChanged")
- void onRegionNameTextChanged() {
+ @LmlAction("onRegionNameTextChanged") void onRegionNameTextChanged() {
inputFile.setRegionName(edtRegionName.getText().trim());
}
@@ -215,6 +221,8 @@ public void setInputFile(InputFile inputFile) {
}
private void mapDataFromModel() {
+ final PackModel packModel = modelService.getProject().getSelectedPack();
+
dialog.pack();
boolean fileShortened = false;
@@ -250,10 +258,11 @@ private void mapDataFromModel() {
if (!inputFile.isDirectory() && inputFile.getType() == InputFile.Type.Input) {
dialog.getTitleLabel().setText(localeService.getI18nBundle().get("dInputFileTitleFile"));
shrinkInputFile.setVisible(true);
- String defaultRegionName = inputFile.getFileHandle().nameWithoutExtension();
- if (defaultRegionName.endsWith(".9")) {
- defaultRegionName = defaultRegionName.substring(0, defaultRegionName.length() - 2);
- }
+
+ String defaultRegionName = InputFile.evalDefaultRegionName(
+ inputFile.getFileHandle(),
+ packModel.isKeepInputFileExtensions());
+
edtRegionName.setMessageText(defaultRegionName);
edtRegionName.setText(inputFile.getRegionName());
@@ -284,4 +293,8 @@ private boolean checkFileExists(InputFile inputFile, boolean showErrorToast) {
}
return exists;
}
+
+ private boolean isShown() {
+ return stage != null;
+ }
}
diff --git a/core/src/com/crashinvaders/texturepackergui/controllers/model/InputFile.java b/core/src/com/crashinvaders/texturepackergui/controllers/model/InputFile.java
index d346ccc..081ff3f 100644
--- a/core/src/com/crashinvaders/texturepackergui/controllers/model/InputFile.java
+++ b/core/src/com/crashinvaders/texturepackergui/controllers/model/InputFile.java
@@ -131,6 +131,17 @@ public boolean isNinePatch() {
return isProgrammaticNinePatch() || isFileBasedNinePatch();
}
+ public static String evalDefaultRegionName(FileHandle fileHandle, boolean keepExtension) {
+ String result = fileHandle.nameWithoutExtension();
+ if (result.endsWith(".9")) {
+ result = result.substring(0, result.length() - 2);
+ }
+ if (keepExtension) {
+ result += "." + fileHandle.extension();
+ }
+ return result;
+ }
+
@Override
public String toString() {
return fileHandle.toString();
diff --git a/core/src/com/crashinvaders/texturepackergui/controllers/model/PackModel.java b/core/src/com/crashinvaders/texturepackergui/controllers/model/PackModel.java
index 73baa00..66d20f0 100644
--- a/core/src/com/crashinvaders/texturepackergui/controllers/model/PackModel.java
+++ b/core/src/com/crashinvaders/texturepackergui/controllers/model/PackModel.java
@@ -26,6 +26,7 @@ public class PackModel implements StateHashable {
private String name = "";
private String filename = "";
private String outputDir = "";
+ private boolean keepInputFileExtensions = false;
private EventDispatcher eventDispatcher;
@@ -39,6 +40,7 @@ public PackModel(PackModel pack) {
this.name = pack.name;
this.filename = pack.filename;
this.outputDir = pack.outputDir;
+ this.keepInputFileExtensions = pack.keepInputFileExtensions;
scaleFactors.addAll(pack.scaleFactors);
@@ -80,6 +82,15 @@ public void setOutputDir(String outputDir) {
}
}
+ public void setKeepInputFileExtensions(boolean value) {
+ if (this.keepInputFileExtensions == value) return;
+
+ this.keepInputFileExtensions = value;
+ if (eventDispatcher != null) {
+ eventDispatcher.postEvent(new PackPropertyChangedEvent(this, Property.KEEP_FILE_EXTENSIONS));
+ }
+ }
+
public String getName() {
return name;
}
@@ -96,6 +107,10 @@ public Array getInputFiles() {
return inputFiles;
}
+ public boolean isKeepInputFileExtensions() {
+ return keepInputFileExtensions;
+ }
+
public Settings getSettings() {
return settings;
}
@@ -208,7 +223,7 @@ public String toString() {
@Override
public int computeStateHash() {
int settingsHash = computeSettingsStateHash(settings);
- return StateHashUtils.computeHash(scaleFactors, inputFiles, settingsHash, name, filename, outputDir);
+ return StateHashUtils.computeHash(scaleFactors, inputFiles, settingsHash, name, filename, outputDir, keepInputFileExtensions);
}
private static int computeSettingsStateHash(Settings s) {
diff --git a/core/src/com/crashinvaders/texturepackergui/controllers/model/ProjectModel.java b/core/src/com/crashinvaders/texturepackergui/controllers/model/ProjectModel.java
index 45de546..363c938 100644
--- a/core/src/com/crashinvaders/texturepackergui/controllers/model/ProjectModel.java
+++ b/core/src/com/crashinvaders/texturepackergui/controllers/model/ProjectModel.java
@@ -15,6 +15,7 @@ public class ProjectModel implements StateHashable {
private final Array packs = new Array<>(true, 16);
private final Color previewBackgroundColor = new Color(Color.WHITE);
+ private final ProjectSettingsModel settings = new ProjectSettingsModel();
private FileHandle projectFile;
private FileTypeModel fileType = new PngFileTypeModel(); // PNG file type by default
@@ -32,6 +33,10 @@ public void setEventDispatcher(EventDispatcher eventDispatcher) {
}
}
+ public ProjectSettingsModel getSettings() {
+ return settings;
+ }
+
public FileHandle getProjectFile() {
return projectFile;
}
@@ -114,6 +119,6 @@ public void setPreviewBackgroundColor(Color color) {
@Override
public int computeStateHash() {
- return StateHashUtils.computeHash(packs, previewBackgroundColor, projectFile, fileType);
+ return StateHashUtils.computeHash(packs, previewBackgroundColor, projectFile, fileType, settings);
}
}
diff --git a/core/src/com/crashinvaders/texturepackergui/controllers/model/ProjectSettingsModel.java b/core/src/com/crashinvaders/texturepackergui/controllers/model/ProjectSettingsModel.java
new file mode 100644
index 0000000..d9d52c1
--- /dev/null
+++ b/core/src/com/crashinvaders/texturepackergui/controllers/model/ProjectSettingsModel.java
@@ -0,0 +1,110 @@
+package com.crashinvaders.texturepackergui.controllers.model;
+
+import com.badlogic.gdx.utils.*;
+import com.crashinvaders.common.statehash.StateHashUtils;
+import com.crashinvaders.common.statehash.StateHashable;
+import com.github.czyzby.autumn.processor.event.EventDispatcher;
+
+import java.io.StringWriter;
+
+public class ProjectSettingsModel implements StateHashable {
+
+ protected EventDispatcher eventDispatcher;
+
+ private final InputFileSettingsModel inputFiles = new InputFileSettingsModel();
+
+ public InputFileSettingsModel getInputFiles() {
+ return inputFiles;
+ }
+
+ public void setEventDispatcher(EventDispatcher eventDispatcher) {
+ this.eventDispatcher = eventDispatcher;
+ }
+
+ public String serializeState() {
+ StringWriter buffer = new StringWriter();
+ try {
+ Json json = new Json();
+ json.setWriter(new JsonWriter(buffer));
+ json.writeObjectStart();
+ json.writeValue("inputFiles", inputFiles);
+ json.writeObjectEnd();
+ return buffer.toString();
+ } finally {
+ StreamUtils.closeQuietly(buffer);
+ }
+ }
+
+ public void deserializeState(String data) {
+ if (data == null) return;
+
+ JsonValue jsonValue = new JsonReader().parse(data);
+ this.inputFiles.read(null, jsonValue.get("inputFiles"));
+ }
+
+ @Override
+ public int computeStateHash() {
+ return StateHashUtils.computeHash(inputFiles);
+ }
+
+ public class InputFileSettingsModel implements StateHashable, Json.Serializable {
+
+// private boolean keepInputFileExtensions = false;
+
+// public boolean isKeepInputFileExtensions() {
+// return keepInputFileExtensions;
+// }
+
+// public void setKeepInputFileExtensions(boolean value) {
+// if (this.keepInputFileExtensions == value) return;
+//
+// this.keepInputFileExtensions = value;
+//
+// if (eventDispatcher != null) {
+// eventDispatcher.postEvent(new ChangedEvent(
+// ProjectSettingsModel.this,
+// ChangedEvent.Property.INPUT_FILES));
+// }
+// }
+
+ @Override
+ public void write(Json json) {
+// json.writeValue("keepInputFileExtensions", keepInputFileExtensions);
+ }
+
+ @Override
+ public void read(Json json, JsonValue jsonData) {
+// this.keepInputFileExtensions = jsonData.getBoolean("keepInputFileExtensions", this.keepInputFileExtensions);
+ }
+
+ @Override
+ public int computeStateHash() {
+// return StateHashUtils.computeHash(keepInputFileExtensions);
+ return 0;
+ }
+ }
+
+ public static class ChangedEvent {
+
+ private final ProjectSettingsModel settings;
+ private final Property property;
+
+ public ChangedEvent(ProjectSettingsModel settings, Property property) {
+ this.settings = settings;
+ this.property = property;
+ }
+
+ public ProjectSettingsModel getSettings() {
+ return settings;
+ }
+
+ public Property getProperty() {
+ return property;
+ }
+
+ public enum Property {
+// INPUT_FILES,
+ }
+ }
+
+}
diff --git a/core/src/com/crashinvaders/texturepackergui/controllers/packing/processors/PackingProcessor.java b/core/src/com/crashinvaders/texturepackergui/controllers/packing/processors/PackingProcessor.java
index a2e471c..93265da 100644
--- a/core/src/com/crashinvaders/texturepackergui/controllers/packing/processors/PackingProcessor.java
+++ b/core/src/com/crashinvaders/texturepackergui/controllers/packing/processors/PackingProcessor.java
@@ -8,6 +8,7 @@
import com.badlogic.gdx.utils.ObjectSet;
import com.crashinvaders.texturepackergui.controllers.model.InputFile;
import com.crashinvaders.texturepackergui.controllers.model.PackModel;
+import com.crashinvaders.texturepackergui.controllers.model.ProjectSettingsModel;
import com.crashinvaders.texturepackergui.utils.packprocessing.PackProcessingNode;
import com.crashinvaders.texturepackergui.utils.packprocessing.PackProcessor;
import com.github.czyzby.kiwi.util.common.Strings;
@@ -36,15 +37,16 @@ public void processPackage(PackProcessingNode node) throws Exception {
System.out.println("Packing is started");
+ ProjectSettingsModel projSettings = node.getProject().getSettings();
String settingsOrigExtension = pack.getSettings().atlasExtension;
- performPacking(pack, pageFileWriter);
+ performPacking(projSettings, pack, pageFileWriter);
pack.getSettings().atlasExtension = settingsOrigExtension;
System.out.println("Packing is done");
}
- private void performPacking(PackModel packModel, PageFileWriter pageFileWriter) throws Exception {
- Array imageEntries = collectImageFiles(packModel);
+ private void performPacking(ProjectSettingsModel projSettings, PackModel packModel, PageFileWriter pageFileWriter) throws Exception {
+ Array imageEntries = collectImageFiles(projSettings, packModel);
if (imageEntries.size == 0) {
throw new IllegalStateException("No images to pack");
}
@@ -63,7 +65,7 @@ private void performPacking(PackModel packModel, PageFileWriter pageFileWriter)
packer.pack(new File(packModel.getOutputDir()), filename);
}
- private static Array collectImageFiles(PackModel packModel) {
+ private static Array collectImageFiles(ProjectSettingsModel projSettings, PackModel packModel) {
final ImageEntryList images = new ImageEntryList();
Array inputFiles = new Array<>(packModel.getInputFiles());
inputFiles.sort(new Comparator() {
@@ -100,7 +102,7 @@ class RecursiveCollector {
void collectImages(FileHandle fileHandle, String prefix, boolean recursive, boolean flattenPath) {
FileHandle[] children = fileHandle.list((FileFilter) new SuffixFileFilter(new String[]{".png", ".jpg", "jpeg"}));
for (FileHandle child : children) {
- String name = child.nameWithoutExtension();
+ String name = InputFile.evalDefaultRegionName(child, packModel.isKeepInputFileExtensions());
name = prefix + name;
images.add(new ImageEntry(child, name));
}
@@ -125,14 +127,17 @@ void collectImages(FileHandle fileHandle, String prefix, boolean recursive, bool
for (InputFile inputFile : inputFiles) {
if (inputFile.getType() == InputFile.Type.Input && !inputFile.isDirectory()) {
FileHandle fileHandle = inputFile.getFileHandle();
- String name = fileHandle.nameWithoutExtension();
- String regionName = inputFile.getRegionName();
- if (Strings.isNotEmpty(regionName)) {
- name = regionName;
+ String regionName;
+ if (Strings.isNotEmpty(inputFile.getRegionName())) {
+ regionName = inputFile.getRegionName();
+ } else {
+ regionName = InputFile.evalDefaultRegionName(
+ inputFile.getFileHandle(),
+ packModel.isKeepInputFileExtensions());
}
- ImageEntry imageEntry = new ImageEntry(fileHandle, name);
+ ImageEntry imageEntry = new ImageEntry(fileHandle, regionName);
if (inputFile.isProgrammaticNinePatch()) {
imageEntry.setNinePatch(inputFile.getNinePatchProps());
}
diff --git a/core/src/com/crashinvaders/texturepackergui/controllers/projectserializer/ProjectSerializer.java b/core/src/com/crashinvaders/texturepackergui/controllers/projectserializer/ProjectSerializer.java
index 023cea0..e3f1862 100644
--- a/core/src/com/crashinvaders/texturepackergui/controllers/projectserializer/ProjectSerializer.java
+++ b/core/src/com/crashinvaders/texturepackergui/controllers/projectserializer/ProjectSerializer.java
@@ -8,10 +8,8 @@
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Json;
import com.crashinvaders.common.Version;
-import com.crashinvaders.texturepackergui.App;
import com.crashinvaders.texturepackergui.AppConstants;
import com.crashinvaders.texturepackergui.controllers.ErrorDialogController;
-import com.crashinvaders.texturepackergui.controllers.TePng8CompDialogController;
import com.crashinvaders.texturepackergui.controllers.model.filetype.*;
import com.crashinvaders.texturepackergui.events.ProjectSerializerEvent;
import com.crashinvaders.texturepackergui.events.ShowToastEvent;
@@ -21,7 +19,6 @@
import com.github.czyzby.autumn.annotation.Initiate;
import com.github.czyzby.autumn.annotation.Inject;
import com.github.czyzby.autumn.mvc.component.i18n.LocaleService;
-import com.github.czyzby.autumn.mvc.component.ui.InterfaceService;
import com.github.czyzby.autumn.processor.event.EventDispatcher;
import java.io.File;
@@ -116,6 +113,8 @@ private void serializeProjectSection(ProjectModel projectModel, StringBuilder sb
sb.append("fileTypeData=").append(fileType.serializeState()).append("\n");
sb.append("previewBackgroundColor=").append(projectModel.getPreviewBackgroundColor().toString()).append("\n");
+
+ sb.append("projectSettings=").append(projectModel.getSettings().serializeState()).append("\n");
}
private String serializePack(PackModel pack, FileHandle root) {
@@ -169,6 +168,8 @@ private String serializePack(PackModel pack, FileHandle root) {
inputFileSerializer.setRoot(root.file());
sb.append("inputFiles=").append(json.toJson(pack.getInputFiles())).append("\n");
+ sb.append("keepInputFileExtensions=").append(pack.isKeepInputFileExtensions()).append("\n");
+
return sb.toString();
}
@@ -237,6 +238,11 @@ private Version deserializeProjectSection(ProjectModel project, String projectSe
project.setPreviewBackgroundColor(Color.valueOf(previewBgColorHex));
}
+ String projectSettings = find(lines, "projectSettings=", null);
+ if (projectSettings != null) {
+ project.getSettings().deserializeState(projectSettings);
+ }
+
String versionString = find(lines, "version=", null);
Version version = null;
try { version = new Version(versionString); } catch (Exception ignore) {}
@@ -254,6 +260,8 @@ private PackModel deserializePack(String serializedData, FileHandle root, Versio
if (line.startsWith("filename=")) pack.setFilename(PathUtils.trim(line.substring("filename=".length())).trim());
if (line.startsWith("input=")) inputDir = PathUtils.trim(line.substring("input=".length())).trim();
if (line.startsWith("output=")) pack.setOutputDir(PathUtils.trim(line.substring("output=".length())).trim());
+ if (line.startsWith("keepInputFileExtensions=")) pack.setKeepInputFileExtensions(
+ Boolean.parseBoolean(line.substring("keepInputFileExtensions=".length())));
}
try {
diff --git a/core/src/com/crashinvaders/texturepackergui/events/PackPropertyChangedEvent.java b/core/src/com/crashinvaders/texturepackergui/events/PackPropertyChangedEvent.java
index 69726c7..dc314fb 100644
--- a/core/src/com/crashinvaders/texturepackergui/events/PackPropertyChangedEvent.java
+++ b/core/src/com/crashinvaders/texturepackergui/events/PackPropertyChangedEvent.java
@@ -38,7 +38,8 @@ public enum Property {
SCALE_FACTORS,
INPUT_FILE_ADDED,
INPUT_FILE_REMOVED,
- SETTINGS // Generic TexturePacker.Settings change event.
+ KEEP_FILE_EXTENSIONS,
+ SETTINGS, // Generic TexturePacker.Settings change event.
;
}
}