mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-26 23:57:25 +01:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffe6a14cd9 | ||
|
|
3ab233761f | ||
|
|
e5bb59b876 | ||
|
|
1fb22ab73f | ||
|
|
6b834e0f0e | ||
|
|
9e6e1d936d | ||
|
|
c3144db751 | ||
|
|
daeb394373 | ||
|
|
e697f93cf5 | ||
|
|
407d50a01e | ||
|
|
a475180bb5 | ||
|
|
259442710b | ||
|
|
3c63ace6c1 | ||
|
|
1786860a3b | ||
|
|
cbc101b3b1 | ||
|
|
33260137d9 | ||
|
|
5a1d8637f9 | ||
|
|
97119b7101 | ||
|
|
104029124b | ||
|
|
2aad37549c | ||
|
|
8dc05bd26a |
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
|
||||
<jardesc>
|
||||
<jar path="ATCS/ATCS_v0.6.7.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/ATCS/ATCS_JAR.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||
<jar path="ATContentStudio/ATCS_v0.6.10.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/ATContentStudio/ATCS_JAR.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||
<selectedProjects/>
|
||||
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
|
||||
@@ -11,9 +11,9 @@
|
||||
</sealing>
|
||||
</manifest>
|
||||
<selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false">
|
||||
<javaElement handleIdentifier="=ATCS/res"/>
|
||||
<javaElement handleIdentifier="=ATCS/src"/>
|
||||
<javaElement handleIdentifier="=ATCS/siphash-zackehh\/src\/main\/java"/>
|
||||
<javaElement handleIdentifier="=ATCS/hacked-libtiled"/>
|
||||
<javaElement handleIdentifier="=ATContentStudio/hacked-libtiled"/>
|
||||
<javaElement handleIdentifier="=ATContentStudio/siphash-zackehh\/src\/main\/java"/>
|
||||
<javaElement handleIdentifier="=ATContentStudio/src"/>
|
||||
<javaElement handleIdentifier="=ATContentStudio/res"/>
|
||||
</selectedElements>
|
||||
</jardesc>
|
||||
|
||||
@@ -1 +1 @@
|
||||
v0.6.7
|
||||
v0.6.10
|
||||
@@ -1,6 +1,6 @@
|
||||
!include MUI2.nsh
|
||||
|
||||
!define VERSION "0.6.7"
|
||||
!define VERSION "0.6.10"
|
||||
!define TRAINER_VERSION "0.1.4"
|
||||
!define JAVA_BIN "javaw"
|
||||
|
||||
|
||||
@@ -84,4 +84,5 @@ atcs.spritesheet.effect_bluetentacle.animate=true
|
||||
atcs.spritesheet.effect_heal2.animate=true
|
||||
atcs.spritesheet.effect_poison1.animate=true
|
||||
atcs.spritesheet.effect_tometik1.animate=true
|
||||
atcs.spritesheet.effect_tometik2.animate=true
|
||||
atcs.spritesheet.effect_tometik2.animate=true
|
||||
atcs.spritesheet.monsters_guynmart.category=monster
|
||||
|
||||
@@ -43,7 +43,7 @@ import prefuse.data.expression.parser.ExpressionParser;
|
||||
public class ATContentStudio {
|
||||
|
||||
public static final String APP_NAME = "Andor's Trail Content Studio";
|
||||
public static final String APP_VERSION = "v0.6.7";
|
||||
public static final String APP_VERSION = "v0.6.10";
|
||||
|
||||
public static final String CHECK_UPDATE_URL = "https://andorstrail.com/static/ATCS_latest";
|
||||
public static final String DOWNLOAD_URL = "https://andorstrail.com/viewtopic.php?f=6&t=4806";
|
||||
|
||||
BIN
src/com/gpl/rpg/atcontentstudio/img/ui_icon_immunity.png
Normal file
BIN
src/com/gpl/rpg/atcontentstudio/img/ui_icon_immunity.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -2,27 +2,48 @@ package com.gpl.rpg.atcontentstudio.model;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringBufferInputStream;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.w3c.dom.Comment;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.Notification;
|
||||
@@ -1043,85 +1064,145 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public void generateExportPackage(final File target) {
|
||||
public void exportProjectAsZipPackage(final File target) {
|
||||
WorkerDialog.showTaskMessage("Exporting project "+name+"...", ATContentStudio.frame, true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Notification.addInfo("Exporting project \""+name+"\" as "+target.getAbsolutePath());
|
||||
File tmpDir = new File(baseFolder, "tmp");
|
||||
FileUtils.deleteDir(tmpDir);
|
||||
tmpDir.mkdir();
|
||||
File tmpJsonDataDir = new File(tmpDir, GameDataSet.DEFAULT_REL_PATH_IN_SOURCE);
|
||||
tmpJsonDataDir.mkdirs();
|
||||
|
||||
for (File createdJsonFile : createdContent.gameData.baseFolder.listFiles()) {
|
||||
FileUtils.copyFile(createdJsonFile, new File(tmpJsonDataDir, createdJsonFile.getName()));
|
||||
}
|
||||
writeAltered(alteredContent.gameData.actorConditions, baseContent.gameData.actorConditions, ActorCondition.class, tmpJsonDataDir);
|
||||
writeAltered(alteredContent.gameData.dialogues, baseContent.gameData.dialogues, Dialogue.class, tmpJsonDataDir);
|
||||
writeAltered(alteredContent.gameData.droplists, baseContent.gameData.droplists, Droplist.class, tmpJsonDataDir);
|
||||
writeAltered(alteredContent.gameData.itemCategories, baseContent.gameData.itemCategories, ItemCategory.class, tmpJsonDataDir);
|
||||
writeAltered(alteredContent.gameData.items, baseContent.gameData.items, Item.class, tmpJsonDataDir);
|
||||
writeAltered(alteredContent.gameData.npcs, baseContent.gameData.npcs, NPC.class, tmpJsonDataDir);
|
||||
writeAltered(alteredContent.gameData.quests, baseContent.gameData.quests, Quest.class, tmpJsonDataDir);
|
||||
|
||||
File tmpMapDir = new File(tmpDir, TMXMapSet.DEFAULT_REL_PATH_IN_SOURCE);
|
||||
tmpMapDir.mkdirs();
|
||||
for (File createdMapFile : createdContent.gameMaps.mapFolder.listFiles()) {
|
||||
FileUtils.copyFile(createdMapFile, new File(tmpMapDir, createdMapFile.getName()));
|
||||
}
|
||||
for (File alteredMapFile : alteredContent.gameMaps.mapFolder.listFiles()) {
|
||||
FileUtils.copyFile(alteredMapFile, new File(tmpMapDir, alteredMapFile.getName()));
|
||||
}
|
||||
|
||||
|
||||
if (!createdContent.worldmap.isEmpty() || !alteredContent.worldmap.isEmpty()) {
|
||||
try {
|
||||
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
|
||||
doc.setXmlVersion("1.0");
|
||||
Element root = doc.createElement("worldmap");
|
||||
doc.appendChild(root);
|
||||
|
||||
for (int i = 0; i < getWorldmapSegmentCount(); i++) {
|
||||
root.appendChild(getWorldmapSegment(i).toXmlElement(doc));
|
||||
}
|
||||
|
||||
Worldmap.saveDocToFile(doc, new File(tmpMapDir, "worldmap.xml"));
|
||||
} catch (ParserConfigurationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
File tmpDir = exportProjectToTmpDir();
|
||||
|
||||
FileUtils.writeToZip(tmpDir, target);
|
||||
FileUtils.deleteDir(tmpDir);
|
||||
Notification.addSuccess("Project \""+name+"\" exported as "+target.getAbsolutePath());
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void writeAltered(GameDataCategory<? extends JSONElement> altered, GameDataCategory<? extends JSONElement> source, Class<? extends JSONElement> gdeClass, File targetFolder) {
|
||||
Set<String> alteredFileNames = new LinkedHashSet<String>();
|
||||
Map<String, List<Map>> toWrite = new LinkedHashMap<String, List<Map>>();
|
||||
for (JSONElement gde : altered) {
|
||||
alteredFileNames.add(gde.jsonFile.getName());
|
||||
public void exportProjectOverGameSource(final File target) {
|
||||
WorkerDialog.showTaskMessage("Exporting project "+name+"...", ATContentStudio.frame, true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Notification.addInfo("Exporting project \""+name+"\" into "+target.getAbsolutePath());
|
||||
|
||||
File tmpDir = exportProjectToTmpDir();
|
||||
|
||||
FileUtils.copyOver(tmpDir, target);
|
||||
FileUtils.deleteDir(tmpDir);
|
||||
Notification.addSuccess("Project \""+name+"\" exported into "+target.getAbsolutePath());
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public File exportProjectToTmpDir() {
|
||||
File tmpDir = new File(baseFolder, "tmp");
|
||||
FileUtils.deleteDir(tmpDir);
|
||||
tmpDir.mkdir();
|
||||
File tmpJsonDataDir = new File(tmpDir, GameDataSet.DEFAULT_REL_PATH_IN_SOURCE);
|
||||
tmpJsonDataDir.mkdirs();
|
||||
|
||||
// for (File createdJsonFile : createdContent.gameData.baseFolder.listFiles()) {
|
||||
// FileUtils.copyFile(createdJsonFile, new File(tmpJsonDataDir, createdJsonFile.getName()));
|
||||
// }
|
||||
Map<Class<? extends GameDataElement>, List<String>> writtenFilesPerDataType = new LinkedHashMap<Class<? extends GameDataElement>, List<String>>();
|
||||
List<String> writtenFiles;
|
||||
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.actorConditions, alteredContent.gameData.actorConditions, baseContent.gameData.actorConditions, ActorCondition.class, tmpJsonDataDir);
|
||||
writtenFilesPerDataType.put(ActorCondition.class, writtenFiles);
|
||||
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.dialogues, alteredContent.gameData.dialogues, baseContent.gameData.dialogues, Dialogue.class, tmpJsonDataDir);
|
||||
writtenFilesPerDataType.put(Dialogue.class, writtenFiles);
|
||||
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.droplists, alteredContent.gameData.droplists, baseContent.gameData.droplists, Droplist.class, tmpJsonDataDir);
|
||||
writtenFilesPerDataType.put(Droplist.class, writtenFiles);
|
||||
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.itemCategories, alteredContent.gameData.itemCategories, baseContent.gameData.itemCategories, ItemCategory.class, tmpJsonDataDir);
|
||||
writtenFilesPerDataType.put(ItemCategory.class, writtenFiles);
|
||||
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.items, alteredContent.gameData.items, baseContent.gameData.items, Item.class, tmpJsonDataDir);
|
||||
writtenFilesPerDataType.put(Item.class, writtenFiles);
|
||||
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.npcs, alteredContent.gameData.npcs, baseContent.gameData.npcs, NPC.class, tmpJsonDataDir);
|
||||
writtenFilesPerDataType.put(NPC.class, writtenFiles);
|
||||
writtenFiles = writeDataDeltaForDataType(createdContent.gameData.quests, alteredContent.gameData.quests, baseContent.gameData.quests, Quest.class, tmpJsonDataDir);
|
||||
writtenFilesPerDataType.put(Quest.class, writtenFiles);
|
||||
|
||||
File tmpMapDir = new File(tmpDir, TMXMapSet.DEFAULT_REL_PATH_IN_SOURCE);
|
||||
tmpMapDir.mkdirs();
|
||||
writtenFiles = new LinkedList<String>();
|
||||
for (File createdMapFile : createdContent.gameMaps.mapFolder.listFiles()) {
|
||||
FileUtils.copyFile(createdMapFile, new File(tmpMapDir, createdMapFile.getName()));
|
||||
writtenFiles.add(createdMapFile.getName());
|
||||
}
|
||||
for (String fName : alteredFileNames) {
|
||||
for (File alteredMapFile : alteredContent.gameMaps.mapFolder.listFiles()) {
|
||||
FileUtils.copyFile(alteredMapFile, new File(tmpMapDir, alteredMapFile.getName()));
|
||||
writtenFiles.add(alteredMapFile.getName());
|
||||
}
|
||||
writtenFilesPerDataType.put(TMXMap.class, writtenFiles);
|
||||
|
||||
if (sourceSetToUse == ResourceSet.gameData) {
|
||||
writeResourceListXml(writtenFilesPerDataType, GameSource.DEFAULT_REL_PATH_FOR_GAME_RESOURCE, baseContent.baseFolder, tmpDir);
|
||||
} else if (sourceSetToUse == ResourceSet.debugData) {
|
||||
writeResourceListXml(writtenFilesPerDataType, GameSource.DEFAULT_REL_PATH_FOR_DEBUG_RESOURCE, baseContent.baseFolder, tmpDir);
|
||||
}
|
||||
|
||||
|
||||
if (!createdContent.worldmap.isEmpty() || !alteredContent.worldmap.isEmpty()) {
|
||||
try {
|
||||
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
|
||||
doc.setXmlVersion("1.0");
|
||||
Element root = doc.createElement("worldmap");
|
||||
doc.appendChild(root);
|
||||
|
||||
for (int i = 0; i < getWorldmapSegmentCount(); i++) {
|
||||
root.appendChild(getWorldmapSegment(i).toXmlElement(doc));
|
||||
}
|
||||
|
||||
Worldmap.saveDocToFile(doc, new File(tmpMapDir, "worldmap.xml"));
|
||||
} catch (ParserConfigurationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return tmpDir;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public List<String> writeDataDeltaForDataType(GameDataCategory<? extends JSONElement> created, GameDataCategory<? extends JSONElement> altered, GameDataCategory<? extends JSONElement> source, Class<? extends JSONElement> gdeClass, File targetFolder) {
|
||||
List<String> filenamesToWrite = new LinkedList<String>();
|
||||
Map<String, List<Map>> dataToWritePerFilename = new LinkedHashMap<String, List<Map>>();
|
||||
for (JSONElement gde : altered) {
|
||||
filenamesToWrite.add(gde.jsonFile.getName());
|
||||
}
|
||||
for (JSONElement gde : created) {
|
||||
if (!filenamesToWrite.contains(gde.jsonFile.getName())) {
|
||||
filenamesToWrite.add(gde.jsonFile.getName());
|
||||
}
|
||||
}
|
||||
for (String fName : filenamesToWrite) {
|
||||
for (JSONElement gde : source) {
|
||||
if (gde.jsonFile.getName().equals(fName)) {
|
||||
if (toWrite.get(fName) == null) {
|
||||
toWrite.put(fName, new ArrayList<Map>());
|
||||
if (dataToWritePerFilename.get(fName) == null) {
|
||||
dataToWritePerFilename.put(fName, new ArrayList<Map>());
|
||||
}
|
||||
toWrite.get(fName).add(getGameDataElement(gdeClass, gde.id).toJson());
|
||||
//Automatically fetches altered element over source element.
|
||||
dataToWritePerFilename.get(fName).add(getGameDataElement(gdeClass, gde.id).toJson());
|
||||
}
|
||||
}
|
||||
for (JSONElement gde : created) {
|
||||
if (gde.jsonFile.getName().equals(fName)) {
|
||||
if (dataToWritePerFilename.get(fName) == null) {
|
||||
dataToWritePerFilename.put(fName, new ArrayList<Map>());
|
||||
}
|
||||
//Add the created elements.
|
||||
dataToWritePerFilename.get(fName).add(getGameDataElement(gdeClass, gde.id).toJson());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String fName : toWrite.keySet()) {
|
||||
for (String fName : dataToWritePerFilename.keySet()) {
|
||||
File jsonFile = new File(targetFolder, fName);
|
||||
StringWriter writer = new JsonPrettyWriter();
|
||||
try {
|
||||
JSONArray.writeJSONString(toWrite.get(fName), writer);
|
||||
JSONArray.writeJSONString(dataToWritePerFilename.get(fName), writer);
|
||||
} catch (IOException e) {
|
||||
//Impossible with a StringWriter
|
||||
}
|
||||
@@ -1136,8 +1217,138 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return filenamesToWrite;
|
||||
}
|
||||
|
||||
|
||||
private void writeResourceListXml(Map<Class<? extends GameDataElement>, List<String>> writtenFilesPerDataType, String xmlFileRelPath, File baseFolder, File tmpDir) {
|
||||
File xmlFile = new File(baseFolder, xmlFileRelPath);
|
||||
File outputFile = new File(tmpDir, xmlFileRelPath);
|
||||
|
||||
Map<String, Class<? extends GameDataElement>> classNamesByArrayNames = new HashMap<String, Class<? extends GameDataElement>>();
|
||||
classNamesByArrayNames.put("loadresource_itemcategories", ItemCategory.class);
|
||||
classNamesByArrayNames.put("loadresource_actorconditions", ActorCondition.class);
|
||||
classNamesByArrayNames.put("loadresource_items", Item.class);
|
||||
classNamesByArrayNames.put("loadresource_droplists", Droplist.class);
|
||||
classNamesByArrayNames.put("loadresource_quests", Quest.class);
|
||||
classNamesByArrayNames.put("loadresource_conversationlists", Dialogue.class);
|
||||
classNamesByArrayNames.put("loadresource_monsters", NPC.class);
|
||||
classNamesByArrayNames.put("loadresource_maps", TMXMap.class);
|
||||
|
||||
String jsonResPrefix = "@raw/";
|
||||
String tmxResPrefix = "@xml/";
|
||||
String jsonFileSuffix = ".json";
|
||||
String tmxFileSuffix = ".tmx";
|
||||
|
||||
if (!xmlFile.exists()) return;
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
Document doc;
|
||||
try {
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
factory.setExpandEntityReferences(false);
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
|
||||
InputSource insrc = new InputSource(new FileInputStream(xmlFile));
|
||||
insrc.setEncoding("UTF-8");
|
||||
doc = builder.parse(insrc);
|
||||
|
||||
Element arrayNode;
|
||||
String name, resPrefix, fileSuffix, resName, resToFile, fileToRes;
|
||||
Class<? extends GameDataElement> clazz;
|
||||
List<String> writtenFiles;
|
||||
|
||||
Element root = (Element) doc.getElementsByTagName("resources").item(0);
|
||||
if (root != null) {
|
||||
NodeList arraysList = root.getElementsByTagName("array");
|
||||
if (arraysList != null) {
|
||||
for (int i = 0; i < arraysList.getLength(); i++) {
|
||||
arrayNode = (Element) arraysList.item(i);
|
||||
name = arrayNode.getAttribute("name");
|
||||
clazz = classNamesByArrayNames.get(name);
|
||||
if (clazz == null) continue;
|
||||
writtenFiles = writtenFilesPerDataType.get(clazz);
|
||||
if (writtenFiles == null) continue;
|
||||
if (clazz == TMXMap.class) {
|
||||
resPrefix = tmxResPrefix;
|
||||
fileSuffix = tmxFileSuffix;
|
||||
} else {
|
||||
resPrefix = jsonResPrefix;
|
||||
fileSuffix = jsonFileSuffix;
|
||||
}
|
||||
NodeList arrayItems = arrayNode.getElementsByTagName("item");
|
||||
if (arrayItems != null) {
|
||||
for (int j = 0; j < arrayItems.getLength(); j++) {
|
||||
resName = ((Element)arrayItems.item(j)).getTextContent();
|
||||
if (resName == null) continue;
|
||||
resToFile = resName.replaceFirst("\\A"+resPrefix, "")+fileSuffix;
|
||||
writtenFiles.remove(resToFile);
|
||||
}
|
||||
}
|
||||
if (!writtenFiles.isEmpty()) {
|
||||
Comment com = doc.createComment("Added by ATCS "+ATContentStudio.APP_VERSION+" for project "+getProject().name);
|
||||
arrayNode.appendChild(com);
|
||||
Collections.sort(writtenFiles);
|
||||
for (String missingRes : writtenFiles) {
|
||||
Element item = doc.createElement("item");
|
||||
fileToRes = resPrefix+missingRes.replaceFirst(fileSuffix+"\\z", "");
|
||||
item.setTextContent(fileToRes);
|
||||
arrayNode.appendChild(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Transformer transformer = TransformerFactory.newInstance().newTransformer();
|
||||
if (!outputFile.getParentFile().exists()) {
|
||||
outputFile.getParentFile().mkdirs();
|
||||
}
|
||||
StringWriter temp = new StringWriter();
|
||||
Result output = new StreamResult(temp);
|
||||
Source input = new DOMSource(doc);
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
|
||||
transformer.transform(input, output);
|
||||
|
||||
String tempString = temp.toString();
|
||||
doc = builder.parse(new StringBufferInputStream(tempString));
|
||||
input = new DOMSource(doc);
|
||||
transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(new StringReader(
|
||||
"<?xml version=\"1.0\"?>\r\n" +
|
||||
"<xsl:stylesheet version=\"1.0\"\r\n" +
|
||||
" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\r\n" +
|
||||
" <xsl:strip-space elements=\"*\" />\r\n" +
|
||||
" <xsl:output method=\"xml\" indent=\"yes\" />\r\n" +
|
||||
"\r\n" +
|
||||
" <xsl:template match=\"node() | @*\" name=\"identity\">\r\n" +
|
||||
" <xsl:copy>\r\n" +
|
||||
" <xsl:apply-templates select=\"node() | @*\" />\r\n" +
|
||||
" </xsl:copy>\r\n" +
|
||||
" </xsl:template>\r\n" +
|
||||
"\r\n" +
|
||||
" <xsl:template match=\"array\">\r\n" +
|
||||
" <xsl:call-template name=\"identity\"/>\r\n" +
|
||||
" <xsl:text>

    </xsl:text>\r\n" +
|
||||
" </xsl:template>\r\n" +
|
||||
"</xsl:stylesheet>")));
|
||||
output = new StreamResult(new FileOutputStream(outputFile));
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
||||
transformer.transform(input, output);
|
||||
|
||||
|
||||
} catch (SAXException e) {
|
||||
e.printStackTrace();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (TransformerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
@@ -332,7 +333,9 @@ public class Workspace implements ProjectTreeNode, Serializable {
|
||||
|
||||
private static boolean delete(File f) {
|
||||
boolean b = true;
|
||||
if (f.isDirectory()) {
|
||||
if (Files.isSymbolicLink(f.toPath())) {
|
||||
b &= f.delete();
|
||||
} else if (f.isDirectory()) {
|
||||
for (File c : f.listFiles())
|
||||
b &= delete(c);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,9 @@ public class ActorCondition extends JSONElement {
|
||||
|
||||
private static final long serialVersionUID = -3969824899972048507L;
|
||||
|
||||
public static final Integer CLEAR_AC_MAGNITUDE = -99;
|
||||
public static final Integer FOREVER_DURATION = 999;
|
||||
public static final Integer MAGNITUDE_CLEAR = -99;
|
||||
public static final Integer DURATION_FOREVER = 999;;
|
||||
public static final Integer DURATION_NONE = 0;
|
||||
|
||||
// Available from init state
|
||||
//public String id; inherited.
|
||||
@@ -207,7 +208,7 @@ public class ActorCondition extends JSONElement {
|
||||
this.full_round_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)fullRoundEffect.get("increaseCurrentAP")).get("max")));
|
||||
this.full_round_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)fullRoundEffect.get("increaseCurrentAP")).get("min")));
|
||||
}
|
||||
String vfx = (String) roundEffect.get("visualEffectID");
|
||||
String vfx = (String) fullRoundEffect.get("visualEffectID");
|
||||
this.full_round_effect.visual_effect = null;
|
||||
if (vfx != null) {
|
||||
try {
|
||||
|
||||
@@ -58,7 +58,9 @@ public class Dialogue extends JSONElement {
|
||||
dropList,
|
||||
skillIncrease,
|
||||
actorCondition,
|
||||
actorConditionImmunity,
|
||||
alignmentChange,
|
||||
alignmentSet,
|
||||
giveItem,
|
||||
createTimer,
|
||||
spawnAll,
|
||||
@@ -250,10 +252,12 @@ public class Dialogue extends JSONElement {
|
||||
reward.map = reward.map_name != null ? proj.getMap(reward.map_name) : null;
|
||||
break;
|
||||
case actorCondition:
|
||||
case actorConditionImmunity:
|
||||
reward.reward_obj = proj.getActorCondition(reward.reward_obj_id);
|
||||
break;
|
||||
case alignmentChange:
|
||||
//Nothing to do (yet ?).
|
||||
case alignmentSet:
|
||||
//Nothing to do (yet ?).
|
||||
break;
|
||||
case createTimer:
|
||||
//Nothing to do.
|
||||
|
||||
@@ -34,6 +34,7 @@ public class Item extends JSONElement {
|
||||
public String category_id = null;
|
||||
public String description = null;
|
||||
public HitEffect hit_effect = null;
|
||||
public HitReceivedEffect hit_received_effect = null;
|
||||
public KillEffect kill_effect = null;
|
||||
public EquipEffect equip_effect = null;
|
||||
|
||||
@@ -58,6 +59,14 @@ public class Item extends JSONElement {
|
||||
public List<TimedConditionEffect> conditions_target = null;
|
||||
}
|
||||
|
||||
public static class HitReceivedEffect extends HitEffect {
|
||||
//Available from parsed state
|
||||
public Integer hp_boost_min_target = null;
|
||||
public Integer hp_boost_max_target = null;
|
||||
public Integer ap_boost_min_target = null;
|
||||
public Integer ap_boost_max_target = null;
|
||||
}
|
||||
|
||||
public static class EquipEffect {
|
||||
//Available from parsed state
|
||||
public Integer damage_boost_min = null;
|
||||
@@ -246,6 +255,53 @@ public class Item extends JSONElement {
|
||||
}
|
||||
}
|
||||
|
||||
Map hitReceivedEffect = (Map) itemJson.get("hitReceivedEffect");
|
||||
if (hitReceivedEffect != null) {
|
||||
this.hit_received_effect = new HitReceivedEffect();
|
||||
if (hitReceivedEffect.get("increaseCurrentHP") != null) {
|
||||
this.hit_received_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentHP")).get("min")));
|
||||
this.hit_received_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentHP")).get("max")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseCurrentAP") != null) {
|
||||
this.hit_received_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentAP")).get("min")));
|
||||
this.hit_received_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentAP")).get("max")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseAttackerCurrentHP") != null) {
|
||||
this.hit_received_effect.hp_boost_min_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentHP")).get("min")));
|
||||
this.hit_received_effect.hp_boost_max_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentHP")).get("max")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseAttackerCurrentAP") != null) {
|
||||
this.hit_received_effect.ap_boost_min_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentAP")).get("min")));
|
||||
this.hit_received_effect.ap_boost_max_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentAP")).get("max")));
|
||||
}
|
||||
List conditionsSourceJson = (List) hitReceivedEffect.get("conditionsSource");
|
||||
if (conditionsSourceJson != null && !conditionsSourceJson.isEmpty()) {
|
||||
this.hit_received_effect.conditions_source = new ArrayList<Item.TimedConditionEffect>();
|
||||
for (Object conditionJsonObj : conditionsSourceJson) {
|
||||
Map conditionJson = (Map)conditionJsonObj;
|
||||
TimedConditionEffect condition = new TimedConditionEffect();
|
||||
condition.condition_id = (String) conditionJson.get("condition");
|
||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
||||
condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration"));
|
||||
if (conditionJson.get("chance") != null) condition.chance = JSONElement.parseChance(conditionJson.get("chance").toString());
|
||||
this.hit_received_effect.conditions_source.add(condition);
|
||||
}
|
||||
}
|
||||
List conditionsTargetJson = (List) hitReceivedEffect.get("conditionsTarget");
|
||||
if (conditionsTargetJson != null && !conditionsTargetJson.isEmpty()) {
|
||||
this.hit_received_effect.conditions_target = new ArrayList<Item.TimedConditionEffect>();
|
||||
for (Object conditionJsonObj : conditionsTargetJson) {
|
||||
Map conditionJson = (Map)conditionJsonObj;
|
||||
TimedConditionEffect condition = new TimedConditionEffect();
|
||||
condition.condition_id = (String) conditionJson.get("condition");
|
||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
||||
condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration"));
|
||||
if (conditionJson.get("chance") != null) condition.chance = JSONElement.parseChance(conditionJson.get("chance").toString());
|
||||
this.hit_received_effect.conditions_target.add(condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map killEffect = (Map) itemJson.get("killEffect");
|
||||
if (killEffect == null) {
|
||||
killEffect = (Map) itemJson.get("useEffect");
|
||||
@@ -321,6 +377,18 @@ public class Item extends JSONElement {
|
||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect != null && this.hit_received_effect.conditions_source != null) {
|
||||
for (TimedConditionEffect ce : this.hit_received_effect.conditions_source) {
|
||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect != null && this.hit_received_effect.conditions_target != null) {
|
||||
for (TimedConditionEffect ce : this.hit_received_effect.conditions_target) {
|
||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
||||
}
|
||||
}
|
||||
if (this.kill_effect != null && this.kill_effect.conditions_source != null) {
|
||||
for (TimedConditionEffect ce : this.kill_effect.conditions_source) {
|
||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
||||
@@ -422,6 +490,47 @@ public class Item extends JSONElement {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect != null) {
|
||||
clone.hit_received_effect = new HitReceivedEffect();
|
||||
clone.hit_received_effect.ap_boost_max = this.hit_received_effect.ap_boost_max;
|
||||
clone.hit_received_effect.ap_boost_min = this.hit_received_effect.ap_boost_min;
|
||||
clone.hit_received_effect.hp_boost_max = this.hit_received_effect.hp_boost_max;
|
||||
clone.hit_received_effect.hp_boost_min = this.hit_received_effect.hp_boost_min;
|
||||
clone.hit_received_effect.ap_boost_max_target = this.hit_received_effect.ap_boost_max_target;
|
||||
clone.hit_received_effect.ap_boost_min_target = this.hit_received_effect.ap_boost_min_target;
|
||||
clone.hit_received_effect.hp_boost_max_target = this.hit_received_effect.hp_boost_max_target;
|
||||
clone.hit_received_effect.hp_boost_min_target = this.hit_received_effect.hp_boost_min_target;
|
||||
if (this.hit_received_effect.conditions_source != null) {
|
||||
clone.hit_received_effect.conditions_source = new ArrayList<Item.TimedConditionEffect>();
|
||||
for (TimedConditionEffect c : this.hit_received_effect.conditions_source) {
|
||||
TimedConditionEffect cclone = new TimedConditionEffect();
|
||||
cclone.magnitude = c.magnitude;
|
||||
cclone.condition_id = c.condition_id;
|
||||
cclone.condition = c.condition;
|
||||
cclone.chance = c.chance;
|
||||
cclone.duration = c.duration;
|
||||
if (cclone.condition != null) {
|
||||
cclone.condition.addBacklink(clone);
|
||||
}
|
||||
clone.hit_received_effect.conditions_source.add(cclone);
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect.conditions_target != null) {
|
||||
clone.hit_received_effect.conditions_target = new ArrayList<Item.TimedConditionEffect>();
|
||||
for (TimedConditionEffect c : this.hit_received_effect.conditions_target) {
|
||||
TimedConditionEffect cclone = new TimedConditionEffect();
|
||||
cclone.magnitude = c.magnitude;
|
||||
cclone.condition_id = c.condition_id;
|
||||
cclone.condition = c.condition;
|
||||
cclone.chance = c.chance;
|
||||
cclone.duration = c.duration;
|
||||
if (cclone.condition != null) {
|
||||
cclone.condition.addBacklink(clone);
|
||||
}
|
||||
clone.hit_received_effect.conditions_target.add(cclone);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.kill_effect != null) {
|
||||
clone.kill_effect = new KillEffect();
|
||||
clone.kill_effect.ap_boost_max = this.kill_effect.ap_boost_max;
|
||||
@@ -600,6 +709,74 @@ public class Item extends JSONElement {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect != null) {
|
||||
Map hitReceivedEffectJson = new LinkedHashMap();
|
||||
itemJson.put("hitReceivedEffect", hitReceivedEffectJson);
|
||||
if (this.hit_received_effect.hp_boost_min != null || this.hit_received_effect.hp_boost_max != null) {
|
||||
Map hpJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseCurrentHP", hpJson);
|
||||
if (this.hit_received_effect.hp_boost_min != null) hpJson.put("min", this.hit_received_effect.hp_boost_min);
|
||||
else hpJson.put("min", 0);
|
||||
if (this.hit_received_effect.hp_boost_max != null) hpJson.put("max", this.hit_received_effect.hp_boost_max);
|
||||
else hpJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.ap_boost_min != null || this.hit_received_effect.ap_boost_max != null) {
|
||||
Map apJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseCurrentAP", apJson);
|
||||
if (this.hit_received_effect.ap_boost_min != null) apJson.put("min", this.hit_received_effect.ap_boost_min);
|
||||
else apJson.put("min", 0);
|
||||
if (this.hit_received_effect.ap_boost_max != null) apJson.put("max", this.hit_received_effect.ap_boost_max);
|
||||
else apJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.hp_boost_min_target != null || this.hit_received_effect.hp_boost_max_target != null) {
|
||||
Map hpJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseAttackerCurrentHP", hpJson);
|
||||
if (this.hit_received_effect.hp_boost_min_target != null) hpJson.put("min", this.hit_received_effect.hp_boost_min_target);
|
||||
else hpJson.put("min", 0);
|
||||
if (this.hit_received_effect.hp_boost_max_target != null) hpJson.put("max", this.hit_received_effect.hp_boost_max_target);
|
||||
else hpJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.ap_boost_min_target != null || this.hit_received_effect.ap_boost_max_target != null) {
|
||||
Map apJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseAttackerCurrentAP", apJson);
|
||||
if (this.hit_received_effect.ap_boost_min_target != null) apJson.put("min", this.hit_received_effect.ap_boost_min_target);
|
||||
else apJson.put("min", 0);
|
||||
if (this.hit_received_effect.ap_boost_max_target != null) apJson.put("max", this.hit_received_effect.ap_boost_max_target);
|
||||
else apJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.conditions_source != null) {
|
||||
List conditionsSourceJson = new ArrayList();
|
||||
hitReceivedEffectJson.put("conditionsSource", conditionsSourceJson);
|
||||
for (TimedConditionEffect condition : this.hit_received_effect.conditions_source) {
|
||||
Map conditionJson = new LinkedHashMap();
|
||||
conditionsSourceJson.add(conditionJson);
|
||||
if (condition.condition != null) {
|
||||
conditionJson.put("condition", condition.condition.id);
|
||||
} else if (condition.condition_id != null) {
|
||||
conditionJson.put("condition", condition.condition_id);
|
||||
}
|
||||
if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude);
|
||||
if (condition.duration != null) conditionJson.put("duration", condition.duration);
|
||||
if (condition.chance != null) conditionJson.put("chance", JSONElement.printJsonChance(condition.chance));
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect.conditions_target != null) {
|
||||
List conditionsTargetJson = new ArrayList();
|
||||
hitReceivedEffectJson.put("conditionsTarget", conditionsTargetJson);
|
||||
for (TimedConditionEffect condition : this.hit_received_effect.conditions_target) {
|
||||
Map conditionJson = new LinkedHashMap();
|
||||
conditionsTargetJson.add(conditionJson);
|
||||
if (condition.condition != null) {
|
||||
conditionJson.put("condition", condition.condition.id);
|
||||
} else if (condition.condition_id != null) {
|
||||
conditionJson.put("condition", condition.condition_id);
|
||||
}
|
||||
if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude);
|
||||
if (condition.duration != null) conditionJson.put("duration", condition.duration);
|
||||
if (condition.chance != null) conditionJson.put("chance", JSONElement.printJsonChance(condition.chance));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.kill_effect != null) {
|
||||
Map killEffectJson = new LinkedHashMap();
|
||||
if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.equip) {
|
||||
|
||||
@@ -47,6 +47,8 @@ public class NPC extends JSONElement {
|
||||
public Integer block_chance = null;
|
||||
public Integer damage_resistance = null;
|
||||
public HitEffect hit_effect = null;
|
||||
public HitReceivedEffect hit_received_effect = null;
|
||||
public DeathEffect death_effect = null;
|
||||
|
||||
//Available from linked state
|
||||
public Dialogue dialogue = null;
|
||||
@@ -70,17 +72,29 @@ public class NPC extends JSONElement {
|
||||
protectSpawn,
|
||||
wholeMap
|
||||
}
|
||||
|
||||
public static class HitEffect {
|
||||
|
||||
public static class DeathEffect {
|
||||
//Available from parsed state
|
||||
public Integer hp_boost_min = null;
|
||||
public Integer hp_boost_max = null;
|
||||
public Integer ap_boost_min = null;
|
||||
public Integer ap_boost_max = null;
|
||||
public List<TimedConditionEffect> conditions_source = null;
|
||||
}
|
||||
|
||||
public static class HitEffect extends DeathEffect {
|
||||
//Available from parsed state
|
||||
public List<TimedConditionEffect> conditions_target = null;
|
||||
}
|
||||
|
||||
public static class HitReceivedEffect extends HitEffect {
|
||||
//Available from parsed state
|
||||
public Integer hp_boost_min_target = null;
|
||||
public Integer hp_boost_max_target = null;
|
||||
public Integer ap_boost_min_target = null;
|
||||
public Integer ap_boost_max_target = null;
|
||||
}
|
||||
|
||||
public static class TimedConditionEffect {
|
||||
//Available from parsed state
|
||||
public Integer magnitude = null;
|
||||
@@ -224,6 +238,79 @@ public class NPC extends JSONElement {
|
||||
}
|
||||
}
|
||||
|
||||
Map hitReceivedEffect = (Map) npcJson.get("hitReceivedEffect");
|
||||
if (hitReceivedEffect != null) {
|
||||
this.hit_received_effect = new HitReceivedEffect();
|
||||
if (hitReceivedEffect.get("increaseCurrentHP") != null) {
|
||||
this.hit_received_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentHP")).get("max")));
|
||||
this.hit_received_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentHP")).get("min")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseCurrentAP") != null) {
|
||||
this.hit_received_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentAP")).get("max")));
|
||||
this.hit_received_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseCurrentAP")).get("min")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseAttackerCurrentHP") != null) {
|
||||
this.hit_received_effect.hp_boost_max_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentHP")).get("max")));
|
||||
this.hit_received_effect.hp_boost_min_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentHP")).get("min")));
|
||||
}
|
||||
if (hitReceivedEffect.get("increaseAttackerCurrentAP") != null) {
|
||||
this.hit_received_effect.ap_boost_max_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentAP")).get("max")));
|
||||
this.hit_received_effect.ap_boost_min_target = JSONElement.getInteger((Number) (((Map)hitReceivedEffect.get("increaseAttackerCurrentAP")).get("min")));
|
||||
}
|
||||
List conditionsSourceJson = (List) hitReceivedEffect.get("conditionsSource");
|
||||
if (conditionsSourceJson != null && !conditionsSourceJson.isEmpty()) {
|
||||
this.hit_received_effect.conditions_source = new ArrayList<NPC.TimedConditionEffect>();
|
||||
for (Object conditionJsonObj : conditionsSourceJson) {
|
||||
Map conditionJson = (Map)conditionJsonObj;
|
||||
TimedConditionEffect condition = new TimedConditionEffect();
|
||||
condition.condition_id = (String) conditionJson.get("condition");
|
||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
||||
condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration"));
|
||||
if (conditionJson.get("chance") != null) condition.chance = JSONElement.parseChance(conditionJson.get("chance").toString());
|
||||
this.hit_received_effect.conditions_source.add(condition);
|
||||
}
|
||||
}
|
||||
List conditionsTargetJson = (List) hitReceivedEffect.get("conditionsTarget");
|
||||
if (conditionsTargetJson != null && !conditionsTargetJson.isEmpty()) {
|
||||
this.hit_received_effect.conditions_target = new ArrayList<NPC.TimedConditionEffect>();
|
||||
for (Object conditionJsonObj : conditionsTargetJson) {
|
||||
Map conditionJson = (Map)conditionJsonObj;
|
||||
TimedConditionEffect condition = new TimedConditionEffect();
|
||||
condition.condition_id = (String) conditionJson.get("condition");
|
||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
||||
condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration"));
|
||||
if (conditionJson.get("chance") != null) condition.chance = JSONElement.parseChance(conditionJson.get("chance").toString());
|
||||
this.hit_received_effect.conditions_target.add(condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map deathEffect = (Map) npcJson.get("deathEffect");
|
||||
if (deathEffect != null) {
|
||||
this.death_effect = new HitEffect();
|
||||
if (deathEffect.get("increaseCurrentHP") != null) {
|
||||
this.death_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map)deathEffect.get("increaseCurrentHP")).get("max")));
|
||||
this.death_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map)deathEffect.get("increaseCurrentHP")).get("min")));
|
||||
}
|
||||
if (deathEffect.get("increaseCurrentAP") != null) {
|
||||
this.death_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)deathEffect.get("increaseCurrentAP")).get("max")));
|
||||
this.death_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)deathEffect.get("increaseCurrentAP")).get("min")));
|
||||
}
|
||||
List conditionsSourceJson = (List) deathEffect.get("conditionsSource");
|
||||
if (conditionsSourceJson != null && !conditionsSourceJson.isEmpty()) {
|
||||
this.death_effect.conditions_source = new ArrayList<NPC.TimedConditionEffect>();
|
||||
for (Object conditionJsonObj : conditionsSourceJson) {
|
||||
Map conditionJson = (Map)conditionJsonObj;
|
||||
TimedConditionEffect condition = new TimedConditionEffect();
|
||||
condition.condition_id = (String) conditionJson.get("condition");
|
||||
condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude"));
|
||||
condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration"));
|
||||
if (conditionJson.get("chance") != null) condition.chance = JSONElement.parseChance(conditionJson.get("chance").toString());
|
||||
this.death_effect.conditions_source.add(condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -267,6 +354,24 @@ public class NPC extends JSONElement {
|
||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect != null && this.hit_received_effect.conditions_source != null) {
|
||||
for (TimedConditionEffect ce : this.hit_received_effect.conditions_source) {
|
||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect != null && this.hit_received_effect.conditions_target != null) {
|
||||
for (TimedConditionEffect ce : this.hit_received_effect.conditions_target) {
|
||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
||||
}
|
||||
}
|
||||
if (this.death_effect != null && this.death_effect.conditions_source != null) {
|
||||
for (TimedConditionEffect ce : this.death_effect.conditions_source) {
|
||||
if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id);
|
||||
if (ce.condition != null) ce.condition.addBacklink(this);
|
||||
}
|
||||
}
|
||||
this.state = State.linked;
|
||||
}
|
||||
|
||||
@@ -343,6 +448,69 @@ public class NPC extends JSONElement {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect != null) {
|
||||
clone.hit_received_effect = new HitReceivedEffect();
|
||||
clone.hit_received_effect.ap_boost_max = this.hit_received_effect.ap_boost_max;
|
||||
clone.hit_received_effect.ap_boost_min = this.hit_received_effect.ap_boost_min;
|
||||
clone.hit_received_effect.hp_boost_max = this.hit_received_effect.hp_boost_max;
|
||||
clone.hit_received_effect.hp_boost_min = this.hit_received_effect.hp_boost_min;
|
||||
clone.hit_received_effect.ap_boost_max_target = this.hit_received_effect.ap_boost_max_target;
|
||||
clone.hit_received_effect.ap_boost_min_target = this.hit_received_effect.ap_boost_min_target;
|
||||
clone.hit_received_effect.hp_boost_max_target = this.hit_received_effect.hp_boost_max_target;
|
||||
clone.hit_received_effect.hp_boost_min_target = this.hit_received_effect.hp_boost_min_target;
|
||||
if (this.hit_received_effect.conditions_source != null) {
|
||||
clone.hit_received_effect.conditions_source = new ArrayList<TimedConditionEffect>();
|
||||
for (TimedConditionEffect c : this.hit_received_effect.conditions_source) {
|
||||
TimedConditionEffect cclone = new TimedConditionEffect();
|
||||
cclone.magnitude = c.magnitude;
|
||||
cclone.condition_id = c.condition_id;
|
||||
cclone.condition = c.condition;
|
||||
cclone.chance = c.chance;
|
||||
cclone.duration = c.duration;
|
||||
if (cclone.condition != null) {
|
||||
cclone.condition.addBacklink(clone);
|
||||
}
|
||||
clone.hit_received_effect.conditions_source.add(cclone);
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect.conditions_target != null) {
|
||||
clone.hit_received_effect.conditions_target = new ArrayList<TimedConditionEffect>();
|
||||
for (TimedConditionEffect c : this.hit_received_effect.conditions_target) {
|
||||
TimedConditionEffect cclone = new TimedConditionEffect();
|
||||
cclone.magnitude = c.magnitude;
|
||||
cclone.condition_id = c.condition_id;
|
||||
cclone.condition = c.condition;
|
||||
cclone.chance = c.chance;
|
||||
cclone.duration = c.duration;
|
||||
if (cclone.condition != null) {
|
||||
cclone.condition.addBacklink(clone);
|
||||
}
|
||||
clone.hit_received_effect.conditions_target.add(cclone);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.death_effect != null) {
|
||||
clone.death_effect = new DeathEffect();
|
||||
clone.death_effect.ap_boost_max = this.death_effect.ap_boost_max;
|
||||
clone.death_effect.ap_boost_min = this.death_effect.ap_boost_min;
|
||||
clone.death_effect.hp_boost_max = this.death_effect.hp_boost_max;
|
||||
clone.death_effect.hp_boost_min = this.death_effect.hp_boost_min;
|
||||
if (this.death_effect.conditions_source != null) {
|
||||
clone.death_effect.conditions_source = new ArrayList<TimedConditionEffect>();
|
||||
for (TimedConditionEffect c : this.death_effect.conditions_source) {
|
||||
TimedConditionEffect cclone = new TimedConditionEffect();
|
||||
cclone.magnitude = c.magnitude;
|
||||
cclone.condition_id = c.condition_id;
|
||||
cclone.condition = c.condition;
|
||||
cclone.chance = c.chance;
|
||||
cclone.duration = c.duration;
|
||||
if (cclone.condition != null) {
|
||||
cclone.condition.addBacklink(clone);
|
||||
}
|
||||
clone.death_effect.conditions_source.add(cclone);
|
||||
}
|
||||
}
|
||||
}
|
||||
clone.max_ap = this.max_ap;
|
||||
clone.max_hp = this.max_hp;
|
||||
clone.monster_class = this.monster_class;
|
||||
@@ -478,6 +646,110 @@ public class NPC extends JSONElement {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect != null) {
|
||||
Map hitReceivedEffectJson = new LinkedHashMap();
|
||||
npcJson.put("hitReceivedEffect", hitReceivedEffectJson);
|
||||
if (this.hit_received_effect.hp_boost_min != null || this.hit_received_effect.hp_boost_max != null) {
|
||||
Map hpJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseCurrentHP", hpJson);
|
||||
if (this.hit_received_effect.hp_boost_min != null) hpJson.put("min", this.hit_received_effect.hp_boost_min);
|
||||
else hpJson.put("min", 0);
|
||||
if (this.hit_received_effect.hp_boost_max != null) hpJson.put("max", this.hit_received_effect.hp_boost_max);
|
||||
else hpJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.ap_boost_min != null || this.hit_received_effect.ap_boost_max != null) {
|
||||
Map apJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseCurrentAP", apJson);
|
||||
if (this.hit_received_effect.ap_boost_min != null) apJson.put("min", this.hit_received_effect.ap_boost_min);
|
||||
else apJson.put("min", 0);
|
||||
if (this.hit_received_effect.ap_boost_max != null) apJson.put("max", this.hit_received_effect.ap_boost_max);
|
||||
else apJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.hp_boost_min_target != null || this.hit_received_effect.hp_boost_max_target != null) {
|
||||
Map hpJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseAttackerCurrentHP", hpJson);
|
||||
if (this.hit_received_effect.hp_boost_min_target != null) hpJson.put("min", this.hit_received_effect.hp_boost_min_target);
|
||||
else hpJson.put("min", 0);
|
||||
if (this.hit_received_effect.hp_boost_max_target != null) hpJson.put("max", this.hit_received_effect.hp_boost_max_target);
|
||||
else hpJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.ap_boost_min_target != null || this.hit_received_effect.ap_boost_max_target != null) {
|
||||
Map apJson = new LinkedHashMap();
|
||||
hitReceivedEffectJson.put("increaseAttackerCurrentAP", apJson);
|
||||
if (this.hit_received_effect.ap_boost_min_target != null) apJson.put("min", this.hit_received_effect.ap_boost_min_target);
|
||||
else apJson.put("min", 0);
|
||||
if (this.hit_received_effect.ap_boost_max_target != null) apJson.put("max", this.hit_received_effect.ap_boost_max_target);
|
||||
else apJson.put("max", 0);
|
||||
}
|
||||
if (this.hit_received_effect.conditions_source != null) {
|
||||
List conditionsSourceJson = new ArrayList();
|
||||
hitReceivedEffectJson.put("conditionsSource", conditionsSourceJson);
|
||||
for (TimedConditionEffect condition : this.hit_received_effect.conditions_source) {
|
||||
Map conditionJson = new LinkedHashMap();
|
||||
conditionsSourceJson.add(conditionJson);
|
||||
if (condition.condition != null) {
|
||||
conditionJson.put("condition", condition.condition.id);
|
||||
} else if (condition.condition_id != null) {
|
||||
conditionJson.put("condition", condition.condition_id);
|
||||
}
|
||||
if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude);
|
||||
if (condition.duration != null) conditionJson.put("duration", condition.duration);
|
||||
if (condition.chance != null) conditionJson.put("chance", JSONElement.printJsonChance(condition.chance));
|
||||
}
|
||||
}
|
||||
if (this.hit_received_effect.conditions_target != null) {
|
||||
List conditionsTargetJson = new ArrayList();
|
||||
hitReceivedEffectJson.put("conditionsTarget", conditionsTargetJson);
|
||||
for (TimedConditionEffect condition : this.hit_received_effect.conditions_target) {
|
||||
Map conditionJson = new LinkedHashMap();
|
||||
conditionsTargetJson.add(conditionJson);
|
||||
if (condition.condition != null) {
|
||||
conditionJson.put("condition", condition.condition.id);
|
||||
} else if (condition.condition_id != null) {
|
||||
conditionJson.put("condition", condition.condition_id);
|
||||
}
|
||||
if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude);
|
||||
if (condition.duration != null) conditionJson.put("duration", condition.duration);
|
||||
if (condition.chance != null) conditionJson.put("chance", JSONElement.printJsonChance(condition.chance));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.death_effect != null) {
|
||||
Map deathEffectJson = new LinkedHashMap();
|
||||
npcJson.put("deathEffect", deathEffectJson);
|
||||
if (this.death_effect.hp_boost_min != null || this.death_effect.hp_boost_max != null) {
|
||||
Map hpJson = new LinkedHashMap();
|
||||
deathEffectJson.put("increaseCurrentHP", hpJson);
|
||||
if (this.death_effect.hp_boost_min != null) hpJson.put("min", this.death_effect.hp_boost_min);
|
||||
else hpJson.put("min", 0);
|
||||
if (this.death_effect.hp_boost_max != null) hpJson.put("max", this.death_effect.hp_boost_max);
|
||||
else hpJson.put("max", 0);
|
||||
}
|
||||
if (this.death_effect.ap_boost_min != null || this.death_effect.ap_boost_max != null) {
|
||||
Map apJson = new LinkedHashMap();
|
||||
deathEffectJson.put("increaseCurrentAP", apJson);
|
||||
if (this.death_effect.ap_boost_min != null) apJson.put("min", this.death_effect.ap_boost_min);
|
||||
else apJson.put("min", 0);
|
||||
if (this.death_effect.ap_boost_max != null) apJson.put("max", this.death_effect.ap_boost_max);
|
||||
else apJson.put("max", 0);
|
||||
}
|
||||
if (this.death_effect.conditions_source != null) {
|
||||
List conditionsSourceJson = new ArrayList();
|
||||
deathEffectJson.put("conditionsSource", conditionsSourceJson);
|
||||
for (TimedConditionEffect condition : this.death_effect.conditions_source) {
|
||||
Map conditionJson = new LinkedHashMap();
|
||||
conditionsSourceJson.add(conditionJson);
|
||||
if (condition.condition != null) {
|
||||
conditionJson.put("condition", condition.condition.id);
|
||||
} else if (condition.condition_id != null) {
|
||||
conditionJson.put("condition", condition.condition_id);
|
||||
}
|
||||
if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude);
|
||||
if (condition.duration != null) conditionJson.put("duration", condition.duration);
|
||||
if (condition.chance != null) conditionJson.put("chance", JSONElement.printJsonChance(condition.chance));
|
||||
}
|
||||
}
|
||||
}
|
||||
return npcJson;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
||||
@@ -112,12 +113,20 @@ public class WorldmapSegment extends GameDataElement {
|
||||
mapLocations.remove(oldOne.id);
|
||||
modified = true;
|
||||
}
|
||||
List<String> deprecatedLabels = new ArrayList<String>();
|
||||
for (String label : labelledMaps.keySet()) {
|
||||
if (labelledMaps.get(label).contains(oldOne.id)) {
|
||||
labelledMaps.get(label).remove(oldOne.id);
|
||||
modified = true;
|
||||
if (labelledMaps.get(label).isEmpty()) {
|
||||
deprecatedLabels.add(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String label : deprecatedLabels) {
|
||||
labelledMaps.remove(label);
|
||||
labels.remove(label);
|
||||
}
|
||||
}
|
||||
|
||||
oldOne.removeBacklink(this);
|
||||
@@ -126,6 +135,7 @@ public class WorldmapSegment extends GameDataElement {
|
||||
if (modified) {
|
||||
this.state = GameDataElement.State.modified;
|
||||
childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,10 @@ public class DefaultIcons {
|
||||
private static String SKILL_RES = "/com/gpl/rpg/atcontentstudio/img/ui_icon_skill.png";
|
||||
public static Image getSkillImage() { return getImage(SKILL_RES); }
|
||||
public static Image getSkillIcon() { return getIcon(SKILL_RES); }
|
||||
|
||||
private static String IMMUNITY_RES = "/com/gpl/rpg/atcontentstudio/img/ui_icon_immunity.png";
|
||||
public static Image getImmunityImage() { return getImage(IMMUNITY_RES); }
|
||||
public static Image getImmunityIcon() { return getIcon(IMMUNITY_RES); }
|
||||
|
||||
private static String ITEM_CATEGORY_RES = "/com/gpl/rpg/atcontentstudio/img/equip_weapon.png";
|
||||
public static Image getItemCategoryImage() { return getImage(ITEM_CATEGORY_RES); }
|
||||
|
||||
@@ -39,7 +39,6 @@ import javax.swing.JSpinner.NumberEditor;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.Scrollable;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
226
src/com/gpl/rpg/atcontentstudio/ui/ExportProjectWizard.java
Normal file
226
src/com/gpl/rpg/atcontentstudio/ui/ExportProjectWizard.java
Normal file
@@ -0,0 +1,226 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.SpriteSheetSet;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
public class ExportProjectWizard extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = -8745083621008868612L;
|
||||
|
||||
JPanel pane;
|
||||
JLabel errorLabel, fileSelectionLabel;
|
||||
JRadioButton asZip, overSources;
|
||||
JComboBox<String> target;
|
||||
JButton browse;
|
||||
JButton okButton, cancelButton;
|
||||
|
||||
Project proj;
|
||||
|
||||
public ExportProjectWizard(Project proj) {
|
||||
|
||||
super(ATContentStudio.frame);
|
||||
setTitle("Export project for inclusion in-game");
|
||||
|
||||
this.proj = proj;
|
||||
|
||||
pane = new JPanel();
|
||||
pane.setLayout(new JideBoxLayout(pane, JideBoxLayout.PAGE_AXIS, 6));
|
||||
|
||||
errorLabel = new JLabel();
|
||||
|
||||
pane.add(errorLabel, JideBoxLayout.FIX);
|
||||
pane.add(new JLabel("Export this ATCS project..."), JideBoxLayout.FIX);
|
||||
|
||||
ButtonGroup radioGroup = new ButtonGroup();
|
||||
|
||||
asZip = new JRadioButton("... as a Zip archive");
|
||||
radioGroup.add(asZip);
|
||||
overSources = new JRadioButton("... into a game source folder");
|
||||
radioGroup.add(overSources);
|
||||
asZip.setSelected(true);
|
||||
|
||||
pane.add(asZip, JideBoxLayout.FIX);
|
||||
pane.add(overSources, JideBoxLayout.FIX);
|
||||
|
||||
ActionListener updateListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
updateState();
|
||||
}
|
||||
};
|
||||
asZip.addActionListener(updateListener);
|
||||
overSources.addActionListener(updateListener);
|
||||
|
||||
target = new JComboBox<String>();
|
||||
target.setEditable(true);
|
||||
target.addActionListener(updateListener);
|
||||
browse = new JButton("Browse");
|
||||
browse.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser jfc = new JFileChooser(){
|
||||
private static final long serialVersionUID = -3001082967957619011L;
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
if (asZip.isSelected()) {
|
||||
if (f.isDirectory() || f.getName().endsWith(".zip") || f.getName().endsWith(".ZIP")) {
|
||||
return super.accept(f);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return f.isDirectory();
|
||||
}
|
||||
}
|
||||
};
|
||||
jfc.setFileSelectionMode(asZip.isSelected() ? JFileChooser.FILES_AND_DIRECTORIES : JFileChooser.DIRECTORIES_ONLY);
|
||||
jfc.setSelectedFile(new File(target.getSelectedItem() == null ? "" : target.getSelectedItem().toString()));
|
||||
jfc.setMultiSelectionEnabled(false);
|
||||
int result = jfc.showOpenDialog(ATContentStudio.frame);
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
File f = jfc.getSelectedFile();
|
||||
if (asZip.isSelected() && !f.getAbsolutePath().substring(f.getAbsolutePath().length() - 4, f.getAbsolutePath().length()).equalsIgnoreCase(".zip")) {
|
||||
f = new File(f.getAbsolutePath()+".zip");
|
||||
}
|
||||
target.setSelectedItem(f.getAbsolutePath());
|
||||
updateState();
|
||||
}
|
||||
}
|
||||
});
|
||||
JPanel fileSelectionPane = new JPanel();
|
||||
fileSelectionPane.setLayout(new JideBoxLayout(fileSelectionPane, JideBoxLayout.LINE_AXIS, 6));
|
||||
fileSelectionLabel = new JLabel("Zip file: ");
|
||||
fileSelectionPane.add(fileSelectionLabel, JideBoxLayout.FIX);
|
||||
fileSelectionPane.add(target, JideBoxLayout.VARY);
|
||||
fileSelectionPane.add(browse, JideBoxLayout.FIX);
|
||||
|
||||
pane.add(fileSelectionPane, JideBoxLayout.FIX);
|
||||
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS, 6));
|
||||
buttonPane.add(new JPanel(), JideBoxLayout.VARY);
|
||||
cancelButton = new JButton("Cancel");
|
||||
buttonPane.add(cancelButton, JideBoxLayout.FIX);
|
||||
okButton = new JButton("Ok");
|
||||
buttonPane.add(okButton, JideBoxLayout.FIX);
|
||||
|
||||
pane.add(new JPanel(), JideBoxLayout.VARY);
|
||||
|
||||
pane.add(buttonPane, JideBoxLayout.FIX);
|
||||
|
||||
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ExportProjectWizard.this.setVisible(false);
|
||||
ExportProjectWizard.this.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
okButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (asZip.isSelected()) {
|
||||
ExportProjectWizard.this.proj.exportProjectAsZipPackage(new File(target.getSelectedItem().toString()));
|
||||
} else {
|
||||
ExportProjectWizard.this.proj.exportProjectOverGameSource(new File(target.getSelectedItem().toString()));
|
||||
}
|
||||
ExportProjectWizard.this.setVisible(false);
|
||||
ExportProjectWizard.this.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
updateState();
|
||||
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
getContentPane().add(pane, BorderLayout.CENTER);
|
||||
|
||||
setMinimumSize(new Dimension(500,150));
|
||||
pack();
|
||||
|
||||
Dimension sdim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
Dimension wdim = getSize();
|
||||
setLocation((sdim.width - wdim.width)/2, (sdim.height - wdim.height)/2);
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
if (asZip.isSelected()) {
|
||||
fileSelectionLabel.setText("Zip file: ");
|
||||
} else {
|
||||
fileSelectionLabel.setText("Game source folder: ");
|
||||
}
|
||||
|
||||
|
||||
File f = new File(target.getSelectedItem() == null ? "" : target.getSelectedItem().toString());
|
||||
if (asZip.isSelected()) {
|
||||
if (target.getSelectedItem() == null || target.getSelectedItem().toString().length() <= 0) {
|
||||
errorLabel.setText("<html><font color=\"#FF0000\">You must select where to save the zip file.</font></html>");
|
||||
okButton.setEnabled(false);
|
||||
} else if (f.isDirectory()) {
|
||||
errorLabel.setText("<html><font color=\"#FF0000\">The selected target is a directory. It should be a zip file.</font></html>");
|
||||
okButton.setEnabled(false);
|
||||
} else if (!(f.getName().toLowerCase().endsWith(".zip"))) {
|
||||
errorLabel.setText("<html><font color=\"#FF0000\">The selected target is not a zip file. It should be a zip file.</font></html>");
|
||||
okButton.setEnabled(false);
|
||||
} else if (f.exists()) {
|
||||
errorLabel.setText("<html><font color=\"#FF9000\">The selected target is an existing zip file. It will be overwritten.</font></html>");
|
||||
okButton.setEnabled(true);
|
||||
} else {
|
||||
errorLabel.setText("<html><font color=\"#00AA00\">Everything looks good !</font></html>");
|
||||
okButton.setEnabled(true);
|
||||
}
|
||||
} else {
|
||||
if (target.getSelectedItem() == null || target.getSelectedItem().toString().length() <= 0) {
|
||||
errorLabel.setText("<html><font color=\"#FF0000\">You must select an AT source root folder.</font></html>");
|
||||
okButton.setEnabled(false);
|
||||
} else if (!f.isDirectory() || !f.exists()) {
|
||||
errorLabel.setText("<html><font color=\"#FF0000\">The selected AT source is not a folder. It should be an existing AT source root folder.</font></html>");
|
||||
okButton.setEnabled(false);
|
||||
} else {
|
||||
File res = new File(f, GameDataSet.DEFAULT_REL_PATH_IN_SOURCE);
|
||||
File drawable = new File(f, SpriteSheetSet.DEFAULT_REL_PATH_IN_SOURCE);
|
||||
File xml = new File(f, TMXMapSet.DEFAULT_REL_PATH_IN_SOURCE);
|
||||
if (!res.exists()) {
|
||||
errorLabel.setText("<html><font color=\"#FF9000\">The selected AT source root folder does not contain the \"res\" folder.</font></html>");
|
||||
okButton.setEnabled(true);
|
||||
} else if (!drawable.exists()) {
|
||||
errorLabel.setText("<html><font color=\"#FF9000\">The selected AT source root folder does not contain the \"drawable\" folder.</font></html>");
|
||||
okButton.setEnabled(true);
|
||||
} else if (!xml.exists()) {
|
||||
errorLabel.setText("<html><font color=\"#FF9000\">The selected AT source root folder does not contain the \"xml\" folder.</font></html>");
|
||||
okButton.setEnabled(true);
|
||||
} else {
|
||||
errorLabel.setText("<html><font color=\"#00AA00\">Everything looks good !</font></html>");
|
||||
okButton.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
revalidate();
|
||||
repaint();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
35
src/com/gpl/rpg/atcontentstudio/ui/OverlayIcon.java
Normal file
35
src/com/gpl/rpg/atcontentstudio/ui/OverlayIcon.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
public class OverlayIcon implements Icon {
|
||||
|
||||
private Image background;
|
||||
private Image overlay;
|
||||
|
||||
public OverlayIcon(Image background, Image overlay) {
|
||||
this.background = background;
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
g.drawImage(background, x, y, null);
|
||||
g.drawImage(overlay, x, y, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return Math.max(background.getWidth(null), overlay.getWidth(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return Math.max(background.getHeight(null), overlay.getHeight(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,7 +34,6 @@ import com.gpl.rpg.atcontentstudio.model.gamedata.JSONElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Quest;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.QuestStage;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.Worldmap;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
|
||||
import com.gpl.rpg.atcontentstudio.model.saves.SavedGamesSet;
|
||||
@@ -353,21 +352,7 @@ public class WorkspaceActions {
|
||||
public ATCSAction exportProject = new ATCSAction("Export project", "Generates a zip file containing all the created & altered resources of the project, ready to merge with the game source."){
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (selectedNode == null || selectedNode.getProject() == null) return;
|
||||
JFileChooser chooser = new JFileChooser() {
|
||||
private static final long serialVersionUID = 8039332384370636746L;
|
||||
public boolean accept(File f) {
|
||||
return f.isDirectory() || f.getName().endsWith(".zip") || f.getName().endsWith(".ZIP");
|
||||
}
|
||||
};
|
||||
chooser.setMultiSelectionEnabled(false);
|
||||
int result = chooser.showSaveDialog(ATContentStudio.frame);
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
File f = chooser.getSelectedFile();
|
||||
if (!f.getAbsolutePath().substring(f.getAbsolutePath().length() - 4, f.getAbsolutePath().length()).equalsIgnoreCase(".zip")) {
|
||||
f = new File(f.getAbsolutePath()+".zip");
|
||||
}
|
||||
selectedNode.getProject().generateExportPackage(f);
|
||||
}
|
||||
new ExportProjectWizard(selectedNode.getProject()).setVisible(true);
|
||||
};
|
||||
public void selectionChanged(ProjectTreeNode selectedNode, TreePath[] selectedPaths) {
|
||||
setEnabled(selectedNode != null && selectedNode.getProject() != null);
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.gpl.rpg.atcontentstudio.ui.BooleanBasedCheckBox;
|
||||
import com.gpl.rpg.atcontentstudio.ui.CollapsiblePanel;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
|
||||
import com.gpl.rpg.atcontentstudio.ui.OverlayIcon;
|
||||
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.dialoguetree.DialogueGraphView;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
@@ -100,6 +101,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
private JComponent rewardValue;
|
||||
private JRadioButton rewardConditionTimed;
|
||||
private JRadioButton rewardConditionForever;
|
||||
private JRadioButton rewardConditionClear;
|
||||
|
||||
private RepliesListModel repliesListModel;
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -362,6 +364,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
if (rewardObj != null) {
|
||||
removeElementListener(rewardObj);
|
||||
}
|
||||
boolean immunity = false;
|
||||
if (reward.type != null) {
|
||||
switch (reward.type) {
|
||||
case activateMapObjectGroup:
|
||||
@@ -388,6 +391,8 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
rewardObj = null;
|
||||
rewardValue = null;
|
||||
break;
|
||||
case actorConditionImmunity:
|
||||
immunity = true;
|
||||
case actorCondition:
|
||||
|
||||
rewardMap = null;
|
||||
@@ -396,16 +401,28 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
rewardObj = addActorConditionBox(pane, ((Dialogue)target).getProject(), "Actor Condition: ", (ActorCondition) reward.reward_obj, writable, listener);
|
||||
rewardConditionTimed = new JRadioButton("For a number of rounds");
|
||||
pane.add(rewardConditionTimed, JideBoxLayout.FIX);
|
||||
rewardValue = addIntegerField(pane, "Duration: ", reward.reward_value, false, writable, listener);
|
||||
rewardValue = addIntegerField(pane, "Duration: ", reward.reward_value, 1, false, writable, listener);
|
||||
rewardConditionForever = new JRadioButton("Forever");
|
||||
pane.add(rewardConditionForever, JideBoxLayout.FIX);
|
||||
|
||||
if (!immunity) {
|
||||
rewardConditionClear = new JRadioButton("Clear actor condition");
|
||||
pane.add(rewardConditionClear, JideBoxLayout.FIX);
|
||||
}
|
||||
|
||||
ButtonGroup radioGroup = new ButtonGroup();
|
||||
radioGroup.add(rewardConditionTimed);
|
||||
radioGroup.add(rewardConditionForever);
|
||||
if (!immunity) radioGroup.add(rewardConditionClear);
|
||||
|
||||
rewardConditionTimed.setSelected(reward.reward_value == null || reward.reward_value != ActorCondition.FOREVER_DURATION);
|
||||
rewardConditionForever.setSelected(!rewardConditionTimed.isSelected());
|
||||
if (immunity) {
|
||||
rewardConditionTimed.setSelected(reward.reward_value == null || (reward.reward_value != ActorCondition.DURATION_FOREVER && reward.reward_value != ActorCondition.MAGNITUDE_CLEAR));
|
||||
rewardConditionForever.setSelected(reward.reward_value != null && reward.reward_value != ActorCondition.DURATION_FOREVER);
|
||||
rewardConditionClear.setSelected(reward.reward_value != null && reward.reward_value != ActorCondition.MAGNITUDE_CLEAR);
|
||||
} else {
|
||||
rewardConditionTimed.setSelected(reward.reward_value != null && reward.reward_value != ActorCondition.DURATION_FOREVER);
|
||||
rewardConditionForever.setSelected(reward.reward_value == null || reward.reward_value == ActorCondition.DURATION_FOREVER);
|
||||
}
|
||||
rewardValue.setEnabled(rewardConditionTimed.isSelected());
|
||||
|
||||
rewardConditionTimed.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
@@ -419,9 +436,17 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
listener.valueChanged(rewardConditionForever, new Boolean(rewardConditionForever.isSelected()));
|
||||
}
|
||||
});
|
||||
|
||||
if (!immunity) {
|
||||
rewardConditionClear.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
listener.valueChanged(rewardConditionClear, new Boolean(rewardConditionClear.isSelected()));
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case alignmentChange:
|
||||
case alignmentSet:
|
||||
rewardMap = null;
|
||||
rewardObjId = addTextField(pane, "Faction: ", reward.reward_obj_id, writable, listener);
|
||||
rewardObjIdCombo = null;
|
||||
@@ -446,7 +471,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
rewardMap = null;
|
||||
rewardObjId = null;
|
||||
rewardObj = addItemBox(pane, ((Dialogue)target).getProject(), "Item: ", (Item) reward.reward_obj, writable, listener);
|
||||
rewardValue = addIntegerField(pane, "Quantity: ", reward.reward_value, false, writable, listener);
|
||||
rewardValue = addIntegerField(pane, "Quantity: ", reward.reward_value, true, writable, listener);
|
||||
break;
|
||||
case removeQuestProgress:
|
||||
case questProgress:
|
||||
@@ -843,14 +868,28 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
label.setIcon(new ImageIcon(DefaultIcons.getObjectLayerIcon()));
|
||||
break;
|
||||
case actorCondition:
|
||||
boolean rewardForever = reward.reward_value != null && reward.reward_value == ActorCondition.FOREVER_DURATION;
|
||||
label.setText("Give actor condition "+rewardObjDesc+(rewardForever ? " forever" : " for "+reward.reward_value+" turns"));
|
||||
boolean rewardClear = reward.reward_value != null && reward.reward_value.intValue() == ActorCondition.MAGNITUDE_CLEAR;
|
||||
if (rewardClear) {
|
||||
label.setText("Clear actor condition "+rewardObjDesc);
|
||||
} else {
|
||||
boolean rewardForever = reward.reward_value != null && reward.reward_value.intValue() == ActorCondition.DURATION_FOREVER;
|
||||
label.setText("Give actor condition "+rewardObjDesc+(rewardForever ? " forever" : " for "+reward.reward_value+" turns"));
|
||||
}
|
||||
if (reward.reward_obj != null) label.setIcon(new ImageIcon(reward.reward_obj.getIcon()));
|
||||
break;
|
||||
case actorConditionImmunity:
|
||||
boolean rewardForever = reward.reward_value == null || reward.reward_value.intValue() == ActorCondition.DURATION_FOREVER;
|
||||
label.setText("Give immunity to actor condition "+rewardObjDesc+(rewardForever ? " forever" : " for "+reward.reward_value+" turns"));
|
||||
if (reward.reward_obj != null) label.setIcon(new OverlayIcon(reward.reward_obj.getIcon(), DefaultIcons.getImmunityIcon()));
|
||||
break;
|
||||
case alignmentChange:
|
||||
label.setText("Change alignment for faction "+rewardObjDesc+" : "+reward.reward_value);
|
||||
label.setIcon(new ImageIcon(DefaultIcons.getAlignmentIcon()));
|
||||
break;
|
||||
case alignmentSet:
|
||||
label.setText("Set alignment for faction "+rewardObjDesc+" : "+reward.reward_value);
|
||||
label.setIcon(new ImageIcon(DefaultIcons.getAlignmentIcon()));
|
||||
break;
|
||||
case createTimer:
|
||||
label.setText("Create timer "+rewardObjDesc);
|
||||
label.setIcon(new ImageIcon(DefaultIcons.getTimerIcon()));
|
||||
@@ -1231,11 +1270,15 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
if (stage != null) stage.addBacklink(dialogue);
|
||||
}
|
||||
rewardsListModel.itemChanged(selectedReward);
|
||||
} else if (source == rewardConditionForever) {
|
||||
selectedReward.reward_value = ActorCondition.FOREVER_DURATION;
|
||||
} else if (source == rewardConditionClear) {
|
||||
selectedReward.reward_value = ActorCondition.MAGNITUDE_CLEAR;
|
||||
rewardValue.setEnabled(false);
|
||||
rewardsListModel.itemChanged(selectedReward);
|
||||
} else if (source == rewardConditionTimed) {
|
||||
} else if (source == rewardConditionForever) {
|
||||
selectedReward.reward_value = ActorCondition.DURATION_FOREVER;
|
||||
rewardValue.setEnabled(false);
|
||||
rewardsListModel.itemChanged(selectedReward);
|
||||
} else if (source == rewardConditionTimed) {
|
||||
selectedReward.reward_value = (Integer) ((JSpinner)rewardValue).getValue();
|
||||
rewardValue.setEnabled(true);
|
||||
rewardsListModel.itemChanged(selectedReward);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,6 @@ import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
@@ -191,7 +190,7 @@ public class WorldMapView extends JComponent implements Scrollable {
|
||||
FontMetrics mifm = g2.getFontMetrics();
|
||||
int mapIdLabelHeight = mifm.getHeight();
|
||||
|
||||
for (String s : mapLocations.keySet()) {
|
||||
for (String s : new HashSet<String>(mapLocations.keySet())) {
|
||||
|
||||
int x = mapLocations.get(s).x;
|
||||
int y = mapLocations.get(s).y;
|
||||
@@ -481,6 +480,10 @@ public class WorldMapView extends JComponent implements Scrollable {
|
||||
offsetX = worldmap.segmentX * TILE_SIZE;
|
||||
offsetY = worldmap.segmentY * TILE_SIZE;
|
||||
for (String s : worldmap.mapLocations.keySet()) {
|
||||
if (proj.getMap(s) == null) {
|
||||
System.err.println("Warning. Worldmap "+worldmap.id+" references map "+s+" but it doesn't exist in this project");
|
||||
continue;
|
||||
}
|
||||
int x = worldmap.mapLocations.get(s).x * TILE_SIZE;
|
||||
int w = proj.getMap(s).tmxMap.getWidth() * TILE_SIZE;
|
||||
int y = worldmap.mapLocations.get(s).y * TILE_SIZE;
|
||||
@@ -497,6 +500,10 @@ public class WorldMapView extends JComponent implements Scrollable {
|
||||
worldmap.segmentX = offsetX / TILE_SIZE;
|
||||
worldmap.segmentY = offsetY / TILE_SIZE;
|
||||
for (String id : worldmap.mapLocations.keySet()) {
|
||||
if (worldmap.getProject().getMap(id) == null) {
|
||||
System.err.println("Warning. Worldmap "+worldmap.id+" references map "+id+" but it doesn't exist in this project");
|
||||
continue;
|
||||
}
|
||||
worldmap.getProject().getMap(id).removeBacklink(worldmap);
|
||||
}
|
||||
worldmap.mapLocations.clear();
|
||||
@@ -508,6 +515,10 @@ public class WorldMapView extends JComponent implements Scrollable {
|
||||
}
|
||||
|
||||
for (String id : worldmap.mapLocations.keySet()) {
|
||||
if (worldmap.getProject().getMap(id) == null) {
|
||||
System.err.println("Warning. Worldmap "+worldmap.id+" references map "+id+" but it doesn't exist in this project");
|
||||
continue;
|
||||
}
|
||||
worldmap.getProject().getMap(id).addBacklink(worldmap);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,11 @@ import java.awt.event.FocusListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -63,5 +66,43 @@ public class DesktopIntegration {
|
||||
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()]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -78,16 +78,42 @@ public class FileUtils {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* cp sourceFolder/* targetFolder/
|
||||
* @param sourceFolder
|
||||
* @param targetFolder
|
||||
*/
|
||||
public static void copyOver(File sourceFolder, File targetFolder) {
|
||||
if (!sourceFolder.isDirectory() || !targetFolder.isDirectory()) return;
|
||||
for (File f : sourceFolder.listFiles()) {
|
||||
if (Files.isSymbolicLink(f.toPath())) {
|
||||
//Skip symlinks
|
||||
continue;
|
||||
} else if (f.isDirectory()) {
|
||||
File dest = new File(targetFolder, f.getName());
|
||||
if (!dest.exists()) {
|
||||
dest.mkdir();
|
||||
}
|
||||
copyOver(f, dest);
|
||||
} else {
|
||||
copyFile(f, new File(targetFolder, f.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void zipDir(File dir, String prefix, ZipOutputStream zos) {
|
||||
if (prefix != "") {
|
||||
prefix = prefix + File.separator;
|
||||
}
|
||||
for (File f : dir.listFiles()) {
|
||||
if (f.isDirectory()) {
|
||||
zipDir(f, prefix+File.separator+f.getName(), zos);
|
||||
zipDir(f, prefix+f.getName(), zos);
|
||||
} else {
|
||||
FileInputStream fis;
|
||||
try {
|
||||
fis = new FileInputStream(f);
|
||||
BufferedInputStream origin = new BufferedInputStream(fis, BUFFER);
|
||||
ZipEntry entry = new ZipEntry(prefix+File.separator+f.getName());
|
||||
ZipEntry entry = new ZipEntry(prefix+f.getName());
|
||||
try {
|
||||
zos.putNextEntry(entry);
|
||||
int count;
|
||||
|
||||
Reference in New Issue
Block a user