mirror of
https://github.com/AndorsTrailRelease/ATCS.git
synced 2025-10-27 18:44:03 +01:00
Fixed a bug in loadresources.xml generation.
Enhanced custom command handling for desktop tools integration.
This commit is contained in:
@@ -1232,18 +1232,17 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
String jsonResPrefix = "@raw/";
|
||||
String tmxResPrefix = "@xml/";
|
||||
String jsonFileSuffix = ".json";
|
||||
String tmxFileSuffix = ".xml";
|
||||
String tmxFileSuffix = ".tmx";
|
||||
|
||||
if (!xmlFile.exists()) return;
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
Document doc;
|
||||
try {
|
||||
factory.setIgnoringComments(true);
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
factory.setExpandEntityReferences(false);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
InputSource insrc = new InputSource(new FileInputStream(xmlFile));
|
||||
// insrc.setSystemId("http://worldmap/");
|
||||
insrc.setEncoding("UTF-8");
|
||||
doc = builder.parse(insrc);
|
||||
|
||||
@@ -1296,8 +1295,9 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
Result output = new StreamResult(new FileOutputStream(outputFile));
|
||||
Source input = new DOMSource(doc);
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
||||
transformer.transform(input, output);
|
||||
} catch (SAXException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -92,7 +92,7 @@ public class TMXMapSet implements ProjectTreeNode {
|
||||
});
|
||||
if (source.type == GameSource.Type.created | source.type == GameSource.Type.altered) {
|
||||
final Path folderPath = Paths.get(mapFolder.getAbsolutePath());
|
||||
Thread watcher = new Thread("Map folder watcher for "+source.type) {
|
||||
Thread watcher = new Thread("Map folder watcher for "+getProject().name+"/"+source.type) {
|
||||
public void run() {
|
||||
WatchService watchService;
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.gpl.rpg.atcontentstudio.utils;
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
@@ -18,7 +21,7 @@ public class DesktopIntegration {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Runtime.getRuntime().exec(Workspace.activeWorkspace.settings.mapEditorCommand.getCurrentValue()+" \""+f.getAbsolutePath()+"\"");
|
||||
Runtime.getRuntime().exec(tokenize(Workspace.activeWorkspace.settings.mapEditorCommand.getCurrentValue()+" \""+f.getAbsolutePath()+"\""));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -40,7 +43,7 @@ public class DesktopIntegration {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Runtime.getRuntime().exec(Workspace.activeWorkspace.settings.imageEditorCommand.getCurrentValue()+" \""+f.getAbsolutePath()+"\"");
|
||||
Runtime.getRuntime().exec(tokenize(Workspace.activeWorkspace.settings.imageEditorCommand.getCurrentValue()+" \""+f.getAbsolutePath()+"\""));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -64,4 +67,42 @@ public class DesktopIntegration {
|
||||
}
|
||||
|
||||
|
||||
private static List<Character> quotes = Arrays.asList(new Character[]{'\'', '"'});
|
||||
private static List<Character> delims = Arrays.asList(new Character[]{' ', '\r', '\n', '\t'});
|
||||
|
||||
private static String[] tokenize(String command) {
|
||||
List<String> tokens = new ArrayList<String>();
|
||||
boolean inQuote = false;
|
||||
char usedQuote = '\0';
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (char c : command.toCharArray()) {
|
||||
if (inQuote) {
|
||||
if (c == usedQuote) {
|
||||
inQuote = false;
|
||||
continue;
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
} else {
|
||||
if (quotes.contains(c)) {
|
||||
inQuote = true;
|
||||
usedQuote = c;
|
||||
} else if (delims.contains(c)) {
|
||||
if (sb.length() > 0) {
|
||||
tokens.add(sb.toString());
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
} else {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
tokens.add(sb.toString());
|
||||
}
|
||||
return tokens.toArray(new String[tokens.size()]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user