mirror of
https://github.com/OMGeeky/ATCS.git
synced 2026-02-23 15:38:23 +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 jsonResPrefix = "@raw/";
|
||||||
String tmxResPrefix = "@xml/";
|
String tmxResPrefix = "@xml/";
|
||||||
String jsonFileSuffix = ".json";
|
String jsonFileSuffix = ".json";
|
||||||
String tmxFileSuffix = ".xml";
|
String tmxFileSuffix = ".tmx";
|
||||||
|
|
||||||
if (!xmlFile.exists()) return;
|
if (!xmlFile.exists()) return;
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
Document doc;
|
Document doc;
|
||||||
try {
|
try {
|
||||||
factory.setIgnoringComments(true);
|
|
||||||
factory.setIgnoringElementContentWhitespace(true);
|
factory.setIgnoringElementContentWhitespace(true);
|
||||||
factory.setExpandEntityReferences(false);
|
factory.setExpandEntityReferences(false);
|
||||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
|
|
||||||
InputSource insrc = new InputSource(new FileInputStream(xmlFile));
|
InputSource insrc = new InputSource(new FileInputStream(xmlFile));
|
||||||
// insrc.setSystemId("http://worldmap/");
|
|
||||||
insrc.setEncoding("UTF-8");
|
insrc.setEncoding("UTF-8");
|
||||||
doc = builder.parse(insrc);
|
doc = builder.parse(insrc);
|
||||||
|
|
||||||
@@ -1296,8 +1295,9 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
Result output = new StreamResult(new FileOutputStream(outputFile));
|
Result output = new StreamResult(new FileOutputStream(outputFile));
|
||||||
Source input = new DOMSource(doc);
|
Source input = new DOMSource(doc);
|
||||||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||||
|
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
|
||||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
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);
|
transformer.transform(input, output);
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
});
|
});
|
||||||
if (source.type == GameSource.Type.created | source.type == GameSource.Type.altered) {
|
if (source.type == GameSource.Type.created | source.type == GameSource.Type.altered) {
|
||||||
final Path folderPath = Paths.get(mapFolder.getAbsolutePath());
|
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() {
|
public void run() {
|
||||||
WatchService watchService;
|
WatchService watchService;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ package com.gpl.rpg.atcontentstudio.utils;
|
|||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||||
@@ -18,7 +21,7 @@ public class DesktopIntegration {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
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) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -40,7 +43,7 @@ public class DesktopIntegration {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
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) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -63,5 +66,43 @@ public class DesktopIntegration {
|
|||||||
return OSType.Other;
|
return OSType.Other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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