mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-27 14:58:55 +01:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84e46ffd20 | ||
|
|
9f5666ea6d | ||
|
|
ae5822703a | ||
|
|
9b68ef6679 | ||
|
|
75d6f8e98f | ||
|
|
38c206cbaf | ||
|
|
b12ed1802f | ||
|
|
0b8bc8448a | ||
|
|
221a031c2b | ||
|
|
f2e4767eb0 | ||
|
|
78ceacb0ce | ||
|
|
1604373e6c | ||
|
|
6e2ee13da7 | ||
|
|
ea28b7475a | ||
|
|
ffe6a14cd9 | ||
|
|
3ab233761f | ||
|
|
e5bb59b876 | ||
|
|
1fb22ab73f | ||
|
|
6b834e0f0e | ||
|
|
9e6e1d936d | ||
|
|
c3144db751 | ||
|
|
daeb394373 | ||
|
|
e697f93cf5 | ||
|
|
407d50a01e | ||
|
|
a475180bb5 |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
|
||||
<jardesc>
|
||||
<jar path="ATContentStudio/ATCS_v0.6.9.jar"/>
|
||||
<jar path="ATContentStudio/ATCS_v0.6.12.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/>
|
||||
|
||||
@@ -1 +1 @@
|
||||
v0.6.9
|
||||
v0.6.11
|
||||
@@ -1,6 +1,6 @@
|
||||
!include MUI2.nsh
|
||||
|
||||
!define VERSION "0.6.9"
|
||||
!define VERSION "0.6.12"
|
||||
!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
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.zackehh.siphash;
|
||||
|
||||
import static com.zackehh.siphash.SipHashConstants.*;
|
||||
import static com.zackehh.siphash.SipHashConstants.DEFAULT_C;
|
||||
import static com.zackehh.siphash.SipHashConstants.DEFAULT_D;
|
||||
import static com.zackehh.siphash.SipHashConstants.INITIAL_V0;
|
||||
import static com.zackehh.siphash.SipHashConstants.INITIAL_V1;
|
||||
import static com.zackehh.siphash.SipHashConstants.INITIAL_V2;
|
||||
import static com.zackehh.siphash.SipHashConstants.INITIAL_V3;
|
||||
|
||||
/**
|
||||
* Main entry point for SipHash, providing a basic hash
|
||||
|
||||
@@ -32,18 +32,18 @@ import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
|
||||
import prefuse.data.expression.parser.ExpressionParser;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||
import com.gpl.rpg.atcontentstudio.ui.StudioFrame;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
|
||||
import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector;
|
||||
|
||||
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.9";
|
||||
public static final String APP_VERSION = "v0.6.12";
|
||||
|
||||
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";
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 3.9 KiB |
@@ -1,28 +1,47 @@
|
||||
package com.gpl.rpg.atcontentstudio.model;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.io.ByteArrayInputStream;
|
||||
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.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 +1062,149 @@ 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()) {
|
||||
if (createdMapFile.getName().equalsIgnoreCase("worldmap.xml")) continue;
|
||||
FileUtils.copyFile(createdMapFile, new File(tmpMapDir, createdMapFile.getName()));
|
||||
writtenFiles.add(createdMapFile.getName());
|
||||
}
|
||||
for (String fName : alteredFileNames) {
|
||||
for (File alteredMapFile : alteredContent.gameMaps.mapFolder.listFiles()) {
|
||||
if (alteredMapFile.getName().equalsIgnoreCase("worldmap.xml")) continue;
|
||||
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) {
|
||||
if (!filenamesToWrite.contains(gde.jsonFile.getName())) {
|
||||
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 +1219,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 ByteArrayInputStream(tempString.getBytes("UTF-8")));
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class WorkspaceSettings {
|
||||
value = defaultValue;
|
||||
}
|
||||
|
||||
public abstract void readFromJson(Map json);
|
||||
public abstract void readFromJson(@SuppressWarnings("rawtypes") Map json);
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void saveToJson(Map json) {
|
||||
@@ -188,6 +188,7 @@ public class WorkspaceSettings {
|
||||
super(id, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void saveToJson(Map json) {
|
||||
if (value != null) json.put(id, value);
|
||||
@@ -201,6 +202,7 @@ public class WorkspaceSettings {
|
||||
this.value = this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void readFromJson(Map json) {
|
||||
value = new ArrayList<X>();
|
||||
|
||||
@@ -60,6 +60,7 @@ public class Dialogue extends JSONElement {
|
||||
actorCondition,
|
||||
actorConditionImmunity,
|
||||
alignmentChange,
|
||||
alignmentSet,
|
||||
giveItem,
|
||||
createTimer,
|
||||
spawnAll,
|
||||
@@ -255,7 +256,8 @@ public class Dialogue extends JSONElement {
|
||||
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.
|
||||
|
||||
@@ -172,6 +172,7 @@ public class Requirement extends JSONElement {
|
||||
case skillLevel:
|
||||
case spentGold:
|
||||
case timerElapsed:
|
||||
case factionScore:
|
||||
break;
|
||||
}
|
||||
if (this.required_obj != null) this.required_obj.addBacklink((GameDataElement) this.parent);
|
||||
@@ -190,6 +191,7 @@ public class Requirement extends JSONElement {
|
||||
clone.state = this.state;
|
||||
clone.required_obj_id = this.required_obj_id;
|
||||
clone.required_value = this.required_value;
|
||||
clone.negated = this.negated;
|
||||
clone.required_obj = this.required_obj;
|
||||
clone.type = this.type;
|
||||
if (clone.required_obj != null && parent != null) {
|
||||
|
||||
@@ -19,6 +19,7 @@ public class KeyArea extends MapObject {
|
||||
String requireType = obj.getProperties().getProperty("requireType");
|
||||
String requireId = obj.getProperties().getProperty("requireId");
|
||||
String requireValue = obj.getProperties().getProperty("requireValue");
|
||||
String requireNegation = obj.getProperties().getProperty("requireNegation");
|
||||
oldSchoolRequirement = false;
|
||||
if (requireType == null) {
|
||||
String[] fields = obj.getName().split(":");
|
||||
@@ -38,7 +39,9 @@ public class KeyArea extends MapObject {
|
||||
if (requireType != null) requirement.type = Requirement.RequirementType.valueOf(requireType);
|
||||
requirement.required_obj_id = requireId;
|
||||
if (requireValue != null) requirement.required_value = Integer.parseInt(requireValue);
|
||||
if (requireNegation != null) requirement.negated = Boolean.parseBoolean(requireNegation);
|
||||
requirement.state = GameDataElement.State.parsed;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,7 +101,7 @@ public class KeyArea extends MapObject {
|
||||
|
||||
public void updateNameFromRequirementChange() {
|
||||
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
||||
name = requirement.required_obj_id+":"+((requirement.required_value == null) ? "" : Integer.toString(requirement.required_value));
|
||||
name = (requirement.negated != null && requirement.negated) ? "NOT " : "" + requirement.required_obj_id+":"+((requirement.required_value == null) ? "" : Integer.toString(requirement.required_value));
|
||||
} else if (oldSchoolRequirement) {
|
||||
int i = 0;
|
||||
String futureName = requirement.type.toString() + "#" + Integer.toString(i);
|
||||
|
||||
@@ -20,6 +20,7 @@ public class ReplaceArea extends MapObject {
|
||||
String requireType = obj.getProperties().getProperty("requireType");
|
||||
String requireId = obj.getProperties().getProperty("requireId");
|
||||
String requireValue = obj.getProperties().getProperty("requireValue");
|
||||
String requireNegation = obj.getProperties().getProperty("requireNegation");
|
||||
if (requireType == null) {
|
||||
String[] fields = obj.getName().split(":");
|
||||
if (fields.length == 2) {
|
||||
@@ -37,6 +38,7 @@ public class ReplaceArea extends MapObject {
|
||||
if (requireType != null) requirement.type = Requirement.RequirementType.valueOf(requireType);
|
||||
requirement.required_obj_id = requireId;
|
||||
if (requireValue != null) requirement.required_value = Integer.parseInt(requireValue);
|
||||
if (requireNegation != null) requirement.negated = Boolean.parseBoolean(requireNegation);
|
||||
requirement.state = GameDataElement.State.parsed;
|
||||
|
||||
|
||||
@@ -112,7 +114,7 @@ public class ReplaceArea extends MapObject {
|
||||
//Don't use yet !
|
||||
public void updateNameFromRequirementChange() {
|
||||
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
||||
name = requirement.required_obj_id+":"+((requirement.required_value == null) ? "" : Integer.toString(requirement.required_value));
|
||||
name = (requirement.negated != null && requirement.negated) ? "NOT " : "" + requirement.required_obj_id+":"+((requirement.required_value == null) ? "" : Integer.toString(requirement.required_value));
|
||||
} else if (oldSchoolRequirement) {
|
||||
int i = 0;
|
||||
String futureName = requirement.type.toString() + "#" + Integer.toString(i);
|
||||
|
||||
@@ -13,6 +13,7 @@ public class SpawnArea extends MapObject {
|
||||
public int quantity = 1;
|
||||
public int spawnchance = 10;
|
||||
public boolean active = true;
|
||||
public boolean ignoreAreas = false;
|
||||
public String spawngroup_id;
|
||||
public List<NPC> spawnGroup = new ArrayList<NPC>();
|
||||
|
||||
@@ -26,6 +27,9 @@ public class SpawnArea extends MapObject {
|
||||
if (obj.getProperties().getProperty("active") != null) {
|
||||
this.active = Boolean.parseBoolean(obj.getProperties().getProperty("active"));
|
||||
}
|
||||
if (obj.getProperties().getProperty("ignoreAreas") != null) {
|
||||
this.ignoreAreas = Boolean.parseBoolean(obj.getProperties().getProperty("ignoreAreas"));
|
||||
}
|
||||
if (obj.getProperties().getProperty("spawngroup") != null) {
|
||||
this.spawngroup_id = obj.getProperties().getProperty("spawngroup");
|
||||
} else if (obj.getName() != null ){
|
||||
@@ -84,6 +88,9 @@ public class SpawnArea extends MapObject {
|
||||
if (!this.active) {
|
||||
tmxObject.getProperties().setProperty("active", Boolean.toString(active));
|
||||
}
|
||||
if (this.ignoreAreas) {
|
||||
tmxObject.getProperties().setProperty("ignoreAreas", Boolean.toString(ignoreAreas));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class TMXMap extends GameDataElement {
|
||||
public static final String GROUND_LAYER_NAME = "Ground";
|
||||
public static final String OBJECTS_LAYER_NAME = "Objects";
|
||||
public static final String ABOVE_LAYER_NAME = "Above";
|
||||
public static final String TOP_LAYER_NAME = "Top";
|
||||
public static final String WALKABLE_LAYER_NAME = "Walkable";
|
||||
|
||||
public enum ColorFilter {
|
||||
@@ -398,6 +399,7 @@ public class TMXMap extends GameDataElement {
|
||||
return GROUND_LAYER_NAME.equalsIgnoreCase(name) ||
|
||||
OBJECTS_LAYER_NAME.equalsIgnoreCase(name) ||
|
||||
ABOVE_LAYER_NAME.equalsIgnoreCase(name) ||
|
||||
TOP_LAYER_NAME.equalsIgnoreCase(name) ||
|
||||
WALKABLE_LAYER_NAME.equalsIgnoreCase(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
@@ -92,29 +93,31 @@ 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;
|
||||
|
||||
while(getProject().open) {
|
||||
try {
|
||||
watchService = FileSystems.getDefault().newWatchService();
|
||||
WatchKey watchKey = folderPath.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
|
||||
/*WatchKey watchKey = */folderPath.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
|
||||
WatchKey wk;
|
||||
validService: while(getProject().open) {
|
||||
wk = watchService.take();
|
||||
for (WatchEvent<?> event : wk.pollEvents()) {
|
||||
Path changed = (Path) event.context();
|
||||
String name = changed.getFileName().toString();
|
||||
String id = name.substring(0, name.length() - 4);
|
||||
TMXMap map = getMap(id);
|
||||
if (map != null) {
|
||||
map.mapChangedOnDisk();
|
||||
wk = watchService.poll(10, TimeUnit.SECONDS);
|
||||
if (wk != null) {
|
||||
for (WatchEvent<?> event : wk.pollEvents()) {
|
||||
Path changed = (Path) event.context();
|
||||
String name = changed.getFileName().toString();
|
||||
String id = name.substring(0, name.length() - 4);
|
||||
TMXMap map = getMap(id);
|
||||
if (map != null) {
|
||||
map.mapChangedOnDisk();
|
||||
}
|
||||
}
|
||||
if(!wk.reset()) {
|
||||
watchService.close();
|
||||
break validService;
|
||||
}
|
||||
}
|
||||
if(!wk.reset()) {
|
||||
watchService.close();
|
||||
break validService;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -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;
|
||||
@@ -653,7 +652,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
return gdeBox;
|
||||
}
|
||||
|
||||
public JComboBox<QuestStage> addQuestStageBox(JPanel pane, Project proj, String label, Integer initialValue, boolean writable, final FieldUpdateListener listener, Quest quest, final JComboBox questSelectionBox) {
|
||||
public JComboBox<QuestStage> addQuestStageBox(JPanel pane, Project proj, String label, Integer initialValue, boolean writable, final FieldUpdateListener listener, Quest quest, @SuppressWarnings("rawtypes") final JComboBox questSelectionBox) {
|
||||
JPanel gdePane = new JPanel();
|
||||
gdePane.setLayout(new JideBoxLayout(gdePane, JideBoxLayout.LINE_AXIS, 6));
|
||||
JLabel gdeLabel = new JLabel(label);
|
||||
@@ -703,7 +702,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({ "rawtypes"})
|
||||
public JList addBacklinksList(JPanel pane, GameDataElement gde) {
|
||||
return addBacklinksList(pane, gde, "Elements linking to this one");
|
||||
}
|
||||
@@ -867,7 +866,6 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
return currentQuest.stages.get(index - 1);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void setSelectedItem(Object anItem) {
|
||||
selected = (QuestStage) anItem;
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
@@ -60,6 +59,7 @@ public class WorkspaceActions {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (!(selectedNode instanceof Project)) return;
|
||||
Workspace.closeProject((Project) selectedNode);
|
||||
selectedNode = null;
|
||||
};
|
||||
public void selectionChanged(ProjectTreeNode selectedNode, TreePath[] selectedPaths) {
|
||||
setEnabled(selectedNode instanceof Project);
|
||||
@@ -353,21 +353,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);
|
||||
|
||||
@@ -36,6 +36,7 @@ public class ActorConditionEditor extends JSONElementEditor {
|
||||
private IntegerBasedCheckBox stackingBox;
|
||||
|
||||
//private JTextField roundVisualField;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private JComboBox roundVisualField;
|
||||
private JSpinner roundHpMinField;
|
||||
private JSpinner roundHpMaxField;
|
||||
@@ -43,6 +44,7 @@ public class ActorConditionEditor extends JSONElementEditor {
|
||||
private JSpinner roundApMaxField;
|
||||
|
||||
//private JTextField fullRoundVisualField;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private JComboBox fullRoundVisualField;
|
||||
private JSpinner fullRoundHpMinField;
|
||||
private JSpinner fullRoundHpMaxField;
|
||||
|
||||
@@ -96,6 +96,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
private JPanel rewardsParamsPane;
|
||||
private MyComboBox rewardMap;
|
||||
private JTextField rewardObjId;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private JComboBox rewardObjIdCombo;
|
||||
private MyComboBox rewardObj;
|
||||
private JComponent rewardValue;
|
||||
@@ -120,6 +121,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
private JComboBox requirementTypeCombo;
|
||||
private JPanel requirementParamsPane;
|
||||
private MyComboBox requirementObj;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private JComboBox requirementSkill;
|
||||
private JTextField requirementObjId;
|
||||
private JComponent requirementValue;
|
||||
@@ -446,6 +448,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
}
|
||||
break;
|
||||
case alignmentChange:
|
||||
case alignmentSet:
|
||||
rewardMap = null;
|
||||
rewardObjId = addTextField(pane, "Faction: ", reward.reward_obj_id, writable, listener);
|
||||
rewardObjIdCombo = null;
|
||||
@@ -470,7 +473,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:
|
||||
@@ -694,7 +697,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
removeElementListener(requirementObj);
|
||||
}
|
||||
|
||||
requirementTypeCombo = addEnumValueBox(pane, "Requirement type: ", Requirement.RequirementType.values(), requirement.type, writable, listener);
|
||||
requirementTypeCombo = addEnumValueBox(pane, "Requirement type: ", Requirement.RequirementType.values(), requirement == null ? null : requirement.type, writable, listener);
|
||||
requirementParamsPane = new JPanel();
|
||||
requirementParamsPane.setLayout(new JideBoxLayout(requirementParamsPane, JideBoxLayout.PAGE_AXIS));
|
||||
updateRequirementParamsEditorPane(requirementParamsPane, requirement, listener);
|
||||
@@ -711,7 +714,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
removeElementListener(requirementObj);
|
||||
}
|
||||
|
||||
if (requirement.type != null) {
|
||||
if (requirement != null && requirement.type != null) {
|
||||
switch (requirement.type) {
|
||||
case consumedBonemeals:
|
||||
case spentGold:
|
||||
@@ -885,6 +888,10 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
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()));
|
||||
|
||||
@@ -44,7 +44,6 @@ import com.gpl.rpg.atcontentstudio.ui.ScrollablePanel;
|
||||
import com.gpl.rpg.atcontentstudio.ui.ScrollablePanel.ScrollableSizeHint;
|
||||
import com.gpl.rpg.atcontentstudio.ui.sprites.SpriteChooser;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
import com.jidesoft.swing.JideScrollPane;
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
|
||||
public abstract class JSONElementEditor extends Editor {
|
||||
@@ -303,6 +302,7 @@ public abstract class JSONElementEditor extends Editor {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean idChanging() {
|
||||
JSONElement node = (JSONElement) target;
|
||||
List<GameDataElement> toModify = new LinkedList<GameDataElement>();
|
||||
|
||||
@@ -63,6 +63,7 @@ public class NPCEditor extends JSONElementEditor {
|
||||
private JTextField idField;
|
||||
private JTextField nameField;
|
||||
private JTextField spawnGroupField;
|
||||
private JTextField factionField;
|
||||
private JSpinner experienceField;
|
||||
private MyComboBox dialogueBox;
|
||||
private MyComboBox droplistBox;
|
||||
@@ -246,6 +247,7 @@ public class NPCEditor extends JSONElementEditor {
|
||||
idField = addTextField(pane, "Internal ID: ", npc.id, npc.writable, listener);
|
||||
nameField = addTranslatableTextField(pane, "Display name: ", npc.name, npc.writable, listener);
|
||||
spawnGroupField = addTextField(pane, "Spawn group ID: ", npc.spawngroup_id, npc.writable, listener);
|
||||
factionField = addTextField(pane, "Faction ID: ", npc.faction_id, npc.writable, listener);
|
||||
experienceField = addIntegerField(pane, "Experience reward: ", npc.getMonsterExperience(), false, false, listener);
|
||||
dialogueBox = addDialogueBox(pane, npc.getProject(), "Initial phrase: ", npc.dialogue, npc.writable, listener);
|
||||
droplistBox = addDroplistBox(pane, npc.getProject(), "Droplist / Shop inventory: ", npc.droplist, npc.writable, listener);
|
||||
@@ -1256,6 +1258,8 @@ public class NPCEditor extends JSONElementEditor {
|
||||
npcIcon.repaint();
|
||||
} else if (source == spawnGroupField) {
|
||||
npc.spawngroup_id = (String) value;
|
||||
} else if (source == factionField) {
|
||||
npc.faction_id = (String) value;
|
||||
} else if (source == dialogueBox) {
|
||||
if (npc.dialogue != null) {
|
||||
npc.dialogue.removeBacklink(npc);
|
||||
@@ -1398,7 +1402,7 @@ public class NPCEditor extends JSONElementEditor {
|
||||
} else if (source == hitTargetConditionClear && (Boolean) value) {
|
||||
selectedHitEffectTargetCondition.magnitude = ActorCondition.MAGNITUDE_CLEAR;
|
||||
selectedHitEffectTargetCondition.duration = null;
|
||||
updateHitSourceTimedConditionWidgets(selectedHitEffectTargetCondition);
|
||||
updateHitTargetTimedConditionWidgets(selectedHitEffectTargetCondition);
|
||||
hitTargetConditionsListModel.itemChanged(selectedHitEffectTargetCondition);
|
||||
updateHit = true;
|
||||
} else if (source == hitTargetConditionApply && (Boolean) value) {
|
||||
@@ -1407,7 +1411,7 @@ public class NPCEditor extends JSONElementEditor {
|
||||
if (selectedHitEffectTargetCondition.duration == null || selectedHitEffectTargetCondition.duration == ActorCondition.DURATION_NONE) {
|
||||
selectedHitEffectTargetCondition.duration = 1;
|
||||
}
|
||||
updateHitSourceTimedConditionWidgets(selectedHitEffectTargetCondition);
|
||||
updateHitTargetTimedConditionWidgets(selectedHitEffectTargetCondition);
|
||||
hitTargetConditionsListModel.itemChanged(selectedHitEffectTargetCondition);
|
||||
updateHit = true;
|
||||
} else if (source == hitTargetConditionImmunity && (Boolean) value) {
|
||||
@@ -1416,7 +1420,7 @@ public class NPCEditor extends JSONElementEditor {
|
||||
if (selectedHitEffectTargetCondition.duration == null || selectedHitEffectTargetCondition.duration == ActorCondition.DURATION_NONE) {
|
||||
selectedHitEffectTargetCondition.duration = 1;
|
||||
}
|
||||
updateHitSourceTimedConditionWidgets(selectedHitEffectTargetCondition);
|
||||
updateHitTargetTimedConditionWidgets(selectedHitEffectTargetCondition);
|
||||
hitTargetConditionsListModel.itemChanged(selectedHitEffectTargetCondition);
|
||||
updateHit = true;
|
||||
} else if (source == hitTargetConditionMagnitude) {
|
||||
@@ -1428,12 +1432,12 @@ public class NPCEditor extends JSONElementEditor {
|
||||
if (selectedHitEffectTargetCondition.duration == null || selectedHitEffectTargetCondition.duration == ActorCondition.DURATION_NONE) {
|
||||
selectedHitEffectTargetCondition.duration = 1;
|
||||
}
|
||||
updateHitSourceTimedConditionWidgets(selectedHitEffectTargetCondition);
|
||||
updateHitTargetTimedConditionWidgets(selectedHitEffectTargetCondition);
|
||||
hitTargetConditionsListModel.itemChanged(selectedHitEffectTargetCondition);
|
||||
updateHit = true;
|
||||
} else if (source == hitTargetConditionForever && (Boolean) value) {
|
||||
selectedHitEffectTargetCondition.duration = ActorCondition.DURATION_FOREVER;
|
||||
updateHitSourceTimedConditionWidgets(selectedHitEffectTargetCondition);
|
||||
updateHitTargetTimedConditionWidgets(selectedHitEffectTargetCondition);
|
||||
hitTargetConditionsListModel.itemChanged(selectedHitEffectTargetCondition);
|
||||
updateHit = true;
|
||||
} else if (source == hitTargetConditionDuration) {
|
||||
|
||||
@@ -40,8 +40,6 @@ public class QuestEditor extends JSONElementEditor {
|
||||
|
||||
private static final long serialVersionUID = 5701667955210615366L;
|
||||
|
||||
private static final Integer one = 1;
|
||||
|
||||
private static final String form_view_id = "Form";
|
||||
private static final String json_view_id = "JSON";
|
||||
|
||||
|
||||
@@ -162,6 +162,7 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
private JComboBox evaluateTriggerBox;
|
||||
private JSpinner quantityField;
|
||||
private JCheckBox spawnActiveForNewGame;
|
||||
private JCheckBox spawnIgnoreAreas;
|
||||
private JTextField spawngroupField;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private JList npcList;
|
||||
@@ -211,7 +212,7 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
editorTabsHolder.add("TMX", tmxScroller);
|
||||
editorTabsHolder.add("XML", xmlScroller);
|
||||
//editorTabsHolder.add("Replacements", replScroller);
|
||||
editorTabsHolder.add("Replacements", getReplacementSimulatorPane());
|
||||
editorTabsHolder.add("Testing", getReplacementSimulatorPane());
|
||||
|
||||
}
|
||||
|
||||
@@ -629,6 +630,7 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
spawngroupField = addTextField(pane, "Spawn group ID: ", ((SpawnArea)selected).spawngroup_id, ((TMXMap)target).writable, listener);
|
||||
quantityField = addIntegerField(pane, "Number of spawned NPCs: ", ((SpawnArea)selected).quantity, false, ((TMXMap)target).writable, listener);
|
||||
spawnActiveForNewGame = addBooleanBasedCheckBox(pane, "Active in a new game: ", ((SpawnArea)selected).active, ((TMXMap)target).writable, listener);
|
||||
spawnIgnoreAreas = addBooleanBasedCheckBox(pane, "Monsters can walk on other game objects: ", ((SpawnArea)selected).ignoreAreas, ((TMXMap)target).writable, listener);
|
||||
npcListModel = new SpawnGroupNpcListModel((SpawnArea) selected);
|
||||
npcList = new JList(npcListModel);
|
||||
npcList.setCellRenderer(new GDERenderer(true, ((TMXMap)target).writable));
|
||||
@@ -780,7 +782,11 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
public JPanel getReplacementSimulatorPane() {
|
||||
JPanel replacementSimulator = new JPanel();
|
||||
replacementSimulator.setLayout(new JideBoxLayout(replacementSimulator, JideBoxLayout.PAGE_AXIS));
|
||||
JPanel toolsPane = new JPanel();
|
||||
toolsPane.setLayout(new JideBoxLayout(toolsPane, JideBoxLayout.LINE_AXIS));
|
||||
final JCheckBox walkableVisibleBox = new JCheckBox("Show \""+TMXMap.WALKABLE_LAYER_NAME+"\" layer.");
|
||||
final JCheckBox showHeroBox = new JCheckBox("Show hero on walkable tiles under the mouse pointer.");
|
||||
final JCheckBox showTooltipBox = new JCheckBox("Show tooltip with stack of tiles.");
|
||||
JPanel areasActivationPane = new JPanel();
|
||||
areasActivationPane.setLayout(new JideBoxLayout(areasActivationPane, JideBoxLayout.PAGE_AXIS));
|
||||
TreeModel areasTreeModel = new ReplaceAreasActivationTreeModel();
|
||||
@@ -798,10 +804,15 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
activateAndViewPane.add(areasActivationPane, JideBoxLayout.FIX);
|
||||
activateAndViewPane.add(new JScrollPane(viewer), JideBoxLayout.VARY);
|
||||
|
||||
replacementSimulator.add(walkableVisibleBox, JideBoxLayout.FIX);
|
||||
toolsPane.add(walkableVisibleBox, JideBoxLayout.FIX);
|
||||
toolsPane.add(showTooltipBox, JideBoxLayout.FIX);
|
||||
toolsPane.add(showHeroBox, JideBoxLayout.FIX);
|
||||
toolsPane.add(new JPanel(), JideBoxLayout.VARY);
|
||||
|
||||
replacementSimulator.add(toolsPane, JideBoxLayout.FIX);
|
||||
replacementSimulator.add(activateAndViewPane, JideBoxLayout.VARY);
|
||||
|
||||
walkableVisibleBox.setSelected(true);
|
||||
walkableVisibleBox.setSelected(viewer.showWalkable);
|
||||
walkableVisibleBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -810,6 +821,21 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
viewer.repaint();
|
||||
}
|
||||
});
|
||||
|
||||
showHeroBox.setSelected(viewer.showHeroWithMouse);
|
||||
showHeroBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
viewer.showHeroWithMouse = showHeroBox.isSelected();
|
||||
}
|
||||
});
|
||||
showTooltipBox.setSelected(viewer.showTooltip);
|
||||
showTooltipBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
viewer.showTooltip = showTooltipBox.isSelected();
|
||||
}
|
||||
});
|
||||
activate.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -1993,6 +2019,11 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
SpawnArea area = (SpawnArea) selectedMapObject;
|
||||
area.active = (Boolean) value;
|
||||
}
|
||||
} else if (source == spawnIgnoreAreas) {
|
||||
if (selectedMapObject instanceof SpawnArea) {
|
||||
SpawnArea area = (SpawnArea) selectedMapObject;
|
||||
area.ignoreAreas = (Boolean) value;
|
||||
}
|
||||
} else if (source == requirementTypeCombo) {
|
||||
if (selectedMapObject instanceof KeyArea) {
|
||||
KeyArea area = (KeyArea) selectedMapObject;
|
||||
@@ -2176,11 +2207,13 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
private TMXMap map;
|
||||
public ReplaceArea highlighted = null;
|
||||
public boolean showWalkable = true;
|
||||
public boolean showHeroWithMouse = true;
|
||||
public boolean showTooltip = true;
|
||||
private OrthogonalRenderer renderer;
|
||||
|
||||
private String groundName, objectsName, aboveName, walkableName;
|
||||
private String groundName, objectsName, aboveName, topName, walkableName;
|
||||
private Map<String, tiled.core.TileLayer> layersByName = new LinkedHashMap<String, tiled.core.TileLayer>();
|
||||
private tiled.core.TileLayer ground, objects, above, walkable;
|
||||
private tiled.core.TileLayer ground, objects, above, top, walkable;
|
||||
|
||||
private Map<String, List<ReplaceArea>> replacementsForLayer = new LinkedHashMap<String, List<ReplaceArea>>();
|
||||
public Map<ReplaceArea, Boolean> activeReplacements = new LinkedHashMap<ReplaceArea, Boolean>();
|
||||
@@ -2199,8 +2232,9 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
Point oldTooltippedTile = new Point(tooltippedTile);
|
||||
tooltippedTile.setLocation(e.getX() / 32, e.getY() / 32);
|
||||
if (!((TMXMap)target).tmxMap.contains(tooltippedTile.x, tooltippedTile.y)) {
|
||||
if (!showTooltip || !((TMXMap)target).tmxMap.contains(tooltippedTile.x, tooltippedTile.y)) {
|
||||
if (tooltipActivated) {
|
||||
//Hides the tooltip...
|
||||
ToolTipManager.sharedInstance().setEnabled(false);
|
||||
@@ -2208,12 +2242,16 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
tooltipActivated = false;
|
||||
}
|
||||
} else {
|
||||
if (!tooltipActivated) {
|
||||
if (showTooltip && !tooltipActivated) {
|
||||
ToolTipManager.sharedInstance().registerComponent(TMXReplacementViewer.this);
|
||||
ToolTipManager.sharedInstance().setEnabled(true);
|
||||
tooltipActivated = true;
|
||||
}
|
||||
}
|
||||
if (showHeroWithMouse && (oldTooltippedTile.x != tooltippedTile.x || oldTooltippedTile.y != tooltippedTile.y) ) {
|
||||
TMXReplacementViewer.this.revalidate();
|
||||
TMXReplacementViewer.this.repaint();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2223,9 +2261,9 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
}
|
||||
|
||||
public void init() {
|
||||
groundName = objectsName = aboveName = walkableName = null;
|
||||
groundName = objectsName = aboveName = walkableName = topName = null;
|
||||
layersByName.clear();
|
||||
ground = objects = above = walkable = null;
|
||||
ground = objects = above = walkable = top = null;
|
||||
replacementsForLayer.clear();
|
||||
|
||||
for (tiled.core.MapLayer layer : map.tmxMap.getLayers()) {
|
||||
@@ -2237,6 +2275,8 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
objectsName = layer.getName();
|
||||
} else if (TMXMap.ABOVE_LAYER_NAME.equalsIgnoreCase(layer.getName())) {
|
||||
aboveName = layer.getName();
|
||||
} else if (TMXMap.TOP_LAYER_NAME.equalsIgnoreCase(layer.getName())) {
|
||||
topName = layer.getName();
|
||||
} else if (TMXMap.WALKABLE_LAYER_NAME.equalsIgnoreCase(layer.getName())) {
|
||||
walkableName = layer.getName();
|
||||
}
|
||||
@@ -2266,6 +2306,7 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
ground = mergeReplacements(groundName);
|
||||
objects = mergeReplacements(objectsName);
|
||||
above = mergeReplacements(aboveName);
|
||||
top = mergeReplacements(topName);
|
||||
walkable = mergeReplacements(walkableName);
|
||||
}
|
||||
|
||||
@@ -2321,10 +2362,18 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
renderer.paintTileLayer(g2d, objects);
|
||||
}
|
||||
|
||||
if (showHeroWithMouse && tooltippedTile != null && ((TMXMap)target).tmxMap.contains(tooltippedTile.x, tooltippedTile.y) &&
|
||||
walkable != null && walkable.getTileAt(tooltippedTile.x, tooltippedTile.y) == null) {
|
||||
g2d.drawImage(DefaultIcons.getHeroImage(), tooltippedTile.x * 32, tooltippedTile.y * 32, 32, 32, null);
|
||||
}
|
||||
|
||||
if (above != null) {
|
||||
renderer.paintTileLayer(g2d, above);
|
||||
}
|
||||
|
||||
|
||||
if (top != null) {
|
||||
renderer.paintTileLayer(g2d, top);
|
||||
}
|
||||
if (walkable != null && showWalkable) {
|
||||
renderer.paintTileLayer(g2d, walkable);
|
||||
}
|
||||
@@ -2381,10 +2430,12 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
JLabel noTileGround = new JLabel(new ImageIcon(DefaultIcons.getNullifyImage().getScaledInstance(32, 32, Image.SCALE_DEFAULT)));
|
||||
JLabel noTileObjects = new JLabel(new ImageIcon(DefaultIcons.getNullifyImage().getScaledInstance(32, 32, Image.SCALE_DEFAULT)));
|
||||
JLabel noTileAbove = new JLabel(new ImageIcon(DefaultIcons.getNullifyImage().getScaledInstance(32, 32, Image.SCALE_DEFAULT)));
|
||||
JLabel noTileTop = new JLabel(new ImageIcon(DefaultIcons.getNullifyImage().getScaledInstance(32, 32, Image.SCALE_DEFAULT)));
|
||||
{
|
||||
noTileGround.setPreferredSize(new Dimension(32, 32));
|
||||
noTileObjects.setPreferredSize(new Dimension(32, 32));
|
||||
noTileAbove.setPreferredSize(new Dimension(32, 32));
|
||||
noTileTop.setPreferredSize(new Dimension(32, 32));
|
||||
}
|
||||
Point tooltippedTile = new Point();
|
||||
JToolTip tt = null;
|
||||
@@ -2406,6 +2457,20 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
if (tooltippedTile != null) {
|
||||
Image tile;
|
||||
JLabel label;
|
||||
|
||||
if (top != null && top.getTileAt(tooltippedTile.x, tooltippedTile.y) != null) {
|
||||
tile = top.getTileAt(tooltippedTile.x, tooltippedTile.y).getImage();
|
||||
} else {
|
||||
tile = null;
|
||||
}
|
||||
if (tile != null) {
|
||||
label = new JLabel(new ImageIcon(tile));
|
||||
label.setPreferredSize(new Dimension(32,32));
|
||||
content.add(label, JideBoxLayout.FIX);
|
||||
//Fix when (if?) Top is advertised publicly.
|
||||
// } else {
|
||||
// content.add(noTileTop, JideBoxLayout.FIX);
|
||||
}
|
||||
|
||||
if (above != null && above.getTileAt(tooltippedTile.x, tooltippedTile.y) != null) {
|
||||
tile = above.getTileAt(tooltippedTile.x, tooltippedTile.y).getImage();
|
||||
|
||||
@@ -316,7 +316,7 @@ public class WorldMapEditor extends Editor implements FieldUpdateListener {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
String selectedMap = null;
|
||||
boolean update = false;
|
||||
// boolean update = false;
|
||||
int x = (int) (e.getX() / mapView.zoomLevel);
|
||||
int y = (int) (e.getY() / mapView.zoomLevel);
|
||||
for (String s : mapView.mapLocations.keySet()) {
|
||||
@@ -333,19 +333,19 @@ public class WorldMapEditor extends Editor implements FieldUpdateListener {
|
||||
if (mapView.getSelectedMapsIDs().size() > 1) {
|
||||
removeFromSelection(selectedMap);
|
||||
// mapView.selected.remove(selectedMap);
|
||||
update = true;
|
||||
// update = true;
|
||||
}
|
||||
} else {
|
||||
addToSelection(selectedMap);
|
||||
// mapView.selected.add(selectedMap);
|
||||
update = true;
|
||||
// update = true;
|
||||
}
|
||||
} else {
|
||||
clearSelection();
|
||||
// mapView.selected.clear();
|
||||
addToSelection(selectedMap);
|
||||
// mapView.selected.add(selectedMap);
|
||||
update = true;
|
||||
// update = true;
|
||||
}
|
||||
}
|
||||
} else if (editMode == EditMode.addMap && mapBeingAddedID != null) {
|
||||
@@ -354,7 +354,7 @@ public class WorldMapEditor extends Editor implements FieldUpdateListener {
|
||||
pushToModel();
|
||||
}
|
||||
mapView.updateFromModel();
|
||||
update = true;
|
||||
// update = true;
|
||||
mapBeingAddedID = null;
|
||||
}
|
||||
// if (update) {
|
||||
|
||||
@@ -85,7 +85,7 @@ public class WorldMapView extends JComponent implements Scrollable {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
String selectedMap = null;
|
||||
boolean update = false;
|
||||
// boolean update = false;
|
||||
int x = (int) (e.getX() / zoomLevel);
|
||||
int y = (int) (e.getY() / zoomLevel);
|
||||
for (String s : mapLocations.keySet()) {
|
||||
|
||||
@@ -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;
|
||||
@@ -343,12 +341,12 @@ public class WriterModeEditor extends Editor {
|
||||
}
|
||||
|
||||
Node rNode;
|
||||
int i = 1;
|
||||
// int i = 1;
|
||||
for (WriterModeData.WriterReply reply : dialogue.replies) {
|
||||
if (reply instanceof EmptyReply && reply.next_dialogue != null) {
|
||||
if (cells.get(reply.next_dialogue) == null) {
|
||||
rNode = addDialogueNode(reply.next_dialogue);
|
||||
Edge e = graph.addEdge(dNode, rNode);
|
||||
/*Edge e = */graph.addEdge(dNode, rNode);
|
||||
} else {
|
||||
rNode = cells.get(reply.next_dialogue);
|
||||
Edge e = graph.addEdge(dNode, rNode);
|
||||
@@ -357,7 +355,7 @@ public class WriterModeEditor extends Editor {
|
||||
} else {
|
||||
if (cells.get(reply) == null) {
|
||||
rNode = addReplyNode(reply);
|
||||
Edge e = graph.addEdge(dNode, rNode);
|
||||
/*Edge e = */graph.addEdge(dNode, rNode);
|
||||
// e.setString(LABEL, "#"+i++);
|
||||
} else {
|
||||
rNode = cells.get(reply);
|
||||
@@ -382,7 +380,7 @@ public class WriterModeEditor extends Editor {
|
||||
if (reply.next_dialogue != null) {
|
||||
if (cells.get(reply.next_dialogue) == null) {
|
||||
Node dNode = addDialogueNode(reply.next_dialogue);
|
||||
Edge e = graph.addEdge(rNode, dNode);
|
||||
/*Edge e = */graph.addEdge(rNode, dNode);
|
||||
} else {
|
||||
Node dNode = cells.get(reply.next_dialogue);
|
||||
Edge e = graph.addEdge(rNode, dNode);
|
||||
@@ -667,7 +665,7 @@ public class WriterModeEditor extends Editor {
|
||||
cells.get(selected).set(LABEL, selected.text);
|
||||
}
|
||||
|
||||
static final String createNextDefaultNodeString = "createNextDefaultNode";
|
||||
// static final String createNextDefaultNodeString = "createNextDefaultNode";
|
||||
final AbstractAction createNextDefaultNode = new AbstractAction("Create next default") {
|
||||
private static final long serialVersionUID = 1658086056088672748L;
|
||||
|
||||
@@ -691,7 +689,7 @@ public class WriterModeEditor extends Editor {
|
||||
}
|
||||
}
|
||||
if (newNode!= null) {
|
||||
Edge edge = graph.addEdge(cells.get(selected), newNode);
|
||||
/*Edge edge = */graph.addEdge(cells.get(selected), newNode);
|
||||
setSelected(newWrNode);
|
||||
|
||||
m_vis.run("colors");
|
||||
@@ -734,7 +732,7 @@ public class WriterModeEditor extends Editor {
|
||||
temp.next_dialogue = newWrNode;
|
||||
|
||||
newNode = addDialogueNode(newWrNode);
|
||||
Edge edge = graph.addEdge(cells.get(selected), newNode);
|
||||
/*Edge edge = */graph.addEdge(cells.get(selected), newNode);
|
||||
setSelected(newWrNode);
|
||||
|
||||
m_vis.run("colors");
|
||||
@@ -760,7 +758,7 @@ public class WriterModeEditor extends Editor {
|
||||
if (selected instanceof WriterReply) {
|
||||
newWrNode = data.new WriterReply(((WriterReply) selected).parent);
|
||||
newNode = addReplyNode(newWrNode);
|
||||
Edge edge = graph.addEdge(cells.get(((WriterReply) selected).parent), newNode);
|
||||
/*Edge edge = */graph.addEdge(cells.get(((WriterReply) selected).parent), newNode);
|
||||
setSelected(newWrNode);
|
||||
|
||||
m_vis.run("colors");
|
||||
@@ -905,18 +903,18 @@ public class WriterModeEditor extends Editor {
|
||||
}
|
||||
}
|
||||
|
||||
public void selectScrollAndEdit(WriterNode node) {
|
||||
if (node != null) {
|
||||
setSelected(node);
|
||||
|
||||
m_vis.run("colors");
|
||||
m_vis.run("layout");
|
||||
m_vis.run("scrollToSelectedAndEdit");
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
// public void selectScrollAndEdit(WriterNode node) {
|
||||
// if (node != null) {
|
||||
// setSelected(node);
|
||||
//
|
||||
// m_vis.run("colors");
|
||||
// m_vis.run("layout");
|
||||
// m_vis.run("scrollToSelectedAndEdit");
|
||||
//
|
||||
// revalidate();
|
||||
// repaint();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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