Compare commits

...

8 Commits

Author SHA1 Message Date
Zukero
900d0bc9b5 v0.5.0 ! First release of new Dialogue Sketch feature. 2016-12-20 16:43:10 +01:00
Zukero
6fe4d2a171 Warning hunt. Dialogue sketch I/O progress. Sketch creation from
existing Dialogue begins.
2016-12-19 18:10:25 +01:00
Kevin
1076693322 Dialogue sketches can be saved. Bug fixes in sketch export. 2016-12-19 08:51:00 +01:00
Zukero
5a9e66b7c9 Detect changes in preparation of edition of existing dialogues. 2016-12-16 15:03:57 +01:00
Zukero
b1d0175a9d Progress on Dialogue Sketch to JSON Data conversion.
Opportunistic bug fix in JSON import wizard.
2016-12-16 09:41:04 +01:00
Zukero
6ac332834d Progress on WriterMode. Project export package now create
deterministically-ordered JSON. Should make nicer diffs.
2016-12-15 19:16:53 +01:00
Zukero
32711449b2 Temporary commit 2016-10-14 17:13:03 +02:00
Zukero
c18ff9d2b4 First drafts of "Writer Mode".
Some bug fixes.
2016-09-16 15:23:00 +02:00
68 changed files with 3114 additions and 342 deletions

View File

@@ -29,7 +29,9 @@
package tiled.core;
import java.awt.Rectangle;
import java.util.*;
import java.util.Iterator;
import java.util.Properties;
import java.util.Vector;
/**
* The Map class is the focal point of the <code>tiled.core</code> package.

View File

@@ -28,10 +28,12 @@
package tiled.core;
import java.awt.*;
import java.util.Properties;
import java.awt.Image;
import java.awt.Rectangle;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
import javax.imageio.ImageIO;
/**

View File

@@ -33,8 +33,8 @@ import java.awt.Shape;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.util.LinkedList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
/**

View File

@@ -28,7 +28,6 @@
package tiled.core;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Properties;

View File

@@ -38,7 +38,6 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

View File

@@ -30,14 +30,32 @@ package tiled.io;
import java.awt.Color;
import java.awt.Rectangle;
import java.io.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.Vector;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPOutputStream;
import tiled.core.*;
import tiled.core.AnimatedTile;
import tiled.core.Map;
import tiled.core.MapLayer;
import tiled.core.MapObject;
import tiled.core.ObjectGroup;
import tiled.core.Sprite;
import tiled.core.Tile;
import tiled.core.TileLayer;
import tiled.core.TileSet;
import tiled.io.xml.XMLWriter;
import tiled.util.Base64;

View File

@@ -28,9 +28,8 @@
package tiled.io.xml;
import java.lang.String;
import java.io.Writer;
import java.io.IOException;
import java.io.Writer;
import java.util.Stack;
/**

View File

@@ -29,7 +29,6 @@
package tiled.util;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.image.BufferedImage;
/**

View File

@@ -33,6 +33,7 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
/**

View File

@@ -29,7 +29,6 @@
package tiled.util;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.image.BufferedImage;
/**

View File

@@ -27,10 +27,10 @@
package tiled.view;
import tiled.core.TileLayer;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.*;
import java.awt.image.BufferedImageOp;
import tiled.core.TileLayer;
/**
* An interface defining methods to render a map.

View File

@@ -27,14 +27,15 @@
package tiled.view;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import tiled.core.Map;
import tiled.core.Tile;
import tiled.core.TileLayer;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
/**
* The orthogonal map renderer. This is the most basic map renderer, dealing
* with maps that use rectangular tiles.

View File

@@ -1 +1 @@
start "" "javaw.exe" -Xmx512M -cp "lib\ATCS_v0.4.8.jar;lib\jide-oss.jar;lib\ui.jar;lib\junit-4.10.jar;lib\json_simple-1.1.jar;lib\rsyntaxtextarea.jar;lib\prefuse.jar;lib\AndorsTrainer_v0.1.2.jar;lib\bsh-2.0b4.jar" com.gpl.rpg.atcontentstudio.ATContentStudio
start "" "javaw.exe" -Xmx512M -cp "lib\ATCS_v0.5.0.jar;lib\jide-oss.jar;lib\ui.jar;lib\junit-4.10.jar;lib\json_simple-1.1.jar;lib\rsyntaxtextarea.jar;lib\prefuse.jar;lib\AndorsTrainer_v0.1.2.jar;lib\bsh-2.0b4.jar" com.gpl.rpg.atcontentstudio.ATContentStudio

View File

@@ -1,2 +1,2 @@
#!/bin/bash
java -Xmx512M -cp lib/AndorsTrainer_v0.1.2.jar:lib/ATCS_v0.4.8.jar:lib/prefuse.jar:lib/json_simple-1.1.jar:lib/jide-oss.jar:lib/ui.jar:lib/junit-4.10.jar:lib/rsyntaxtextarea.jar:lib/bsh-2.0b4.jar com.gpl.rpg.atcontentstudio.ATContentStudio
java -Xmx512M -cp lib/AndorsTrainer_v0.1.2.jar:lib/ATCS_v0.5.0.jar:lib/prefuse.jar:lib/json_simple-1.1.jar:lib/jide-oss.jar:lib/ui.jar:lib/junit-4.10.jar:lib/rsyntaxtextarea.jar:lib/bsh-2.0b4.jar com.gpl.rpg.atcontentstudio.ATContentStudio

View File

@@ -1 +1 @@
start "" "javaw.exe" -Xmx512M -cp "lib\ATCS_v0.4.6.jar;lib\jide-oss.jar;lib\ui.jar;lib\junit-4.10.jar;lib\json_simple-1.1.jar;lib\rsyntaxtextarea.jar;lib\prefuse.jar;lib\AndorsTrainer_v0.1.2.jar;lib\bsh-2.0b4.jar" com.gpl.rpg.atcontentstudio.ATContentStudio
start "" "javaw.exe" -Xmx512M -cp "lib\ATCS_v0.5.0.jar;lib\jide-oss.jar;lib\ui.jar;lib\junit-4.10.jar;lib\json_simple-1.1.jar;lib\rsyntaxtextarea.jar;lib\prefuse.jar;lib\AndorsTrainer_v0.1.2.jar;lib\bsh-2.0b4.jar" com.gpl.rpg.atcontentstudio.ATContentStudio

View File

@@ -1,6 +1,6 @@
!include MUI2.nsh
!define VERSION "0.4.8"
!define VERSION "0.5.0"
!define JAVA_BIN "java"
Name "Andor's Trail Content Studio v${VERSION}"

View File

@@ -5,10 +5,14 @@ import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
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;
@@ -18,7 +22,7 @@ import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector;
public class ATContentStudio {
public static final String APP_NAME = "Andor's Trail Content Studio";
public static final String APP_VERSION = "v0.4.8";
public static final String APP_VERSION = "v0.5.0";
public static boolean STARTED = false;
public static StudioFrame frame = null;
@@ -30,6 +34,8 @@ public class ATContentStudio {
ConfigCache.init();
Logger.getLogger(ExpressionParser.class.getName()).setLevel(Level.OFF);
try {
String laf = ConfigCache.getFavoriteLaFClassName();
if (laf == null) laf = UIManager.getSystemLookAndFeelClassName();

View File

@@ -4,7 +4,7 @@ import java.awt.Image;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -32,7 +32,7 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
public boolean writable = false;
//List of objects whose transition to "linked" state made them point to this instance.
private Map<GameDataElement, Integer> backlinks = new HashMap<GameDataElement, Integer>();
private Map<GameDataElement, Integer> backlinks = new LinkedHashMap<GameDataElement, Integer>();
public String id = null;
@@ -99,7 +99,7 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
@Override
public Project getProject() {
return parent.getProject();
return parent == null ? null : parent.getProject();
}

View File

@@ -9,7 +9,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -31,6 +30,7 @@ import com.gpl.rpg.atcontentstudio.model.maps.Worldmap;
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
import com.gpl.rpg.atcontentstudio.model.sprites.SpriteSheetSet;
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeDataSet;
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
public class GameSource implements ProjectTreeNode, Serializable {
@@ -44,6 +44,7 @@ public class GameSource implements ProjectTreeNode, Serializable {
public transient TMXMapSet gameMaps;
public transient SpriteSheetSet gameSprites;
public transient Worldmap worldmap;
public transient WriterModeDataSet writerModeDataSet;
private transient SavedSlotCollection v;
public static enum Type {
@@ -86,6 +87,9 @@ public class GameSource implements ProjectTreeNode, Serializable {
readResourceList();
}
}
if (type == Type.created) {
this.writerModeDataSet = new WriterModeDataSet(this);
}
this.gameData = new GameDataSet(this);
this.gameMaps = new TMXMapSet(this);
this.gameSprites = new SpriteSheetSet(this);
@@ -95,6 +99,9 @@ public class GameSource implements ProjectTreeNode, Serializable {
v.add(gameMaps);
v.add(gameSprites);
v.add(worldmap);
if (type == Type.created) {
v.add(writerModeDataSet);
}
}
public void readResourceList() {
@@ -127,7 +134,7 @@ public class GameSource implements ProjectTreeNode, Serializable {
for (int i = 0; i < arraysList.getLength(); i++) {
Element arrayNode = (Element) arraysList.item(i);
String name = arrayNode.getAttribute("name");
List<String> arrayContents = new LinkedList<String>();
List<String> arrayContents = new ArrayList<String>();
NodeList arrayItems = arrayNode.getElementsByTagName("item");
if (arrayItems != null) {
for (int j = 0; j < arrayItems.getLength(); j++) {

View File

@@ -9,7 +9,8 @@ import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -44,6 +45,7 @@ import com.gpl.rpg.atcontentstudio.model.maps.Worldmap;
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
import com.gpl.rpg.atcontentstudio.model.saves.SavedGamesSet;
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeData;
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
import com.gpl.rpg.atcontentstudio.utils.FileUtils;
@@ -692,6 +694,20 @@ public class Project implements ProjectTreeNode, Serializable {
}
}
public int getWriterSketchCount() {
return createdContent.writerModeDataSet.getChildCount();
}
public WriterModeData getWriterSketch(String id) {
return createdContent.writerModeDataSet.getWriterSketch(id);
}
public WriterModeData getWriterSketch(int index) {
if (index < createdContent.writerModeDataSet.getChildCount()) {
return createdContent.writerModeDataSet.get(index);
}
return null;
}
@Override
public Project getProject() {
@@ -784,7 +800,7 @@ public class Project implements ProjectTreeNode, Serializable {
/**
*
* @param node. Before calling this method, make sure that no other node with the same class exist in either created or altered.
* @param node. Before calling this method, make sure that no other node with the same class and id exist in either created or altered.
*/
public void createElement(JSONElement node) {
node.writable = true;
@@ -806,6 +822,34 @@ public class Project implements ProjectTreeNode, Serializable {
fireElementAdded(node, getNodeIndex(node));
}
/**
*
* @param node. Before calling this method, make sure that no other node with the same class and id exist in either created or altered.
*/
public void createElements(List<? extends JSONElement> nodes) {
for (JSONElement node : nodes) {
//Already added.
if (node.getProject() != null) continue;
node.writable = true;
if (getGameDataElement(node.getClass(), node.id) != null) {
GameDataElement existingNode = getGameDataElement(node.getClass(), node.id);
for (GameDataElement backlink : existingNode.getBacklinks()) {
backlink.elementChanged(existingNode, node);
}
existingNode.getBacklinks().clear();
node.writable = true;
alteredContent.gameData.addElement(node);
} else {
createdContent.gameData.addElement(node);
}
}
for (JSONElement node : nodes) {
node.link();
node.state = GameDataElement.State.created;
fireElementAdded(node, getNodeIndex(node));
}
}
public void moveToCreated(JSONElement target) {
target.childrenRemoved(new ArrayList<ProjectTreeNode>());
@@ -842,6 +886,15 @@ public class Project implements ProjectTreeNode, Serializable {
fireElementAdded(node, getNodeIndex(node));
}
public void createWriterSketch(WriterModeData node) {
node.writable = true;
createdContent.writerModeDataSet.add(node);
node.link();
fireElementAdded(node, getNodeIndex(node));
}
@Override
public GameDataSet getDataSet() {
@@ -993,8 +1046,8 @@ public class Project implements ProjectTreeNode, Serializable {
@SuppressWarnings("rawtypes")
public void writeAltered(GameDataCategory<? extends JSONElement> altered, GameDataCategory<? extends JSONElement> source, Class<? extends JSONElement> gdeClass, File targetFolder) {
Set<String> alteredFileNames = new HashSet<String>();
Map<String, List<Map>> toWrite = new HashMap<String, List<Map>>();
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());
}
@@ -1030,6 +1083,7 @@ public class Project implements ProjectTreeNode, Serializable {
}

View File

@@ -21,17 +21,17 @@ import com.gpl.rpg.atcontentstudio.Notification;
import com.gpl.rpg.atcontentstudio.io.SettingsSave;
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
import com.gpl.rpg.atcontentstudio.ui.ProjectsTree.ProjectsTreeModel;
import com.gpl.rpg.atcontentstudio.ui.WorkerDialog;
public class Workspace implements ProjectTreeNode, Serializable {
private static final long serialVersionUID = 7938633033601384956L;
public static final String WS_SETTINGS_FILE = ".workspace";
public static Workspace activeWorkspace;
public Preferences preferences = new Preferences();
public File baseFolder;
public File settingsFile;
@@ -39,16 +39,17 @@ public class Workspace implements ProjectTreeNode, Serializable {
public Set<String> projectsName = new HashSet<String>();
public Map<String, Boolean> projectsOpenByName = new HashMap<String, Boolean>();
public Set<File> knownMapSourcesFolders = new HashSet<File>();
public transient ProjectsTreeModel projectsTreeModel = null;
public Workspace(File workspaceRoot) {
baseFolder = workspaceRoot;
if (!workspaceRoot.exists()) {
try {
workspaceRoot.mkdir();
} catch (SecurityException e) {
Notification.addError("Error creating workspace directory: "+e.getMessage());
Notification.addError("Error creating workspace directory: "
+ e.getMessage());
e.printStackTrace();
}
}
@@ -57,14 +58,15 @@ public class Workspace implements ProjectTreeNode, Serializable {
try {
settingsFile.createNewFile();
} catch (IOException e) {
Notification.addError("Error creating workspace datafile: "+e.getMessage());
Notification.addError("Error creating workspace datafile: "
+ e.getMessage());
e.printStackTrace();
}
}
Notification.addSuccess("New workspace created: "+workspaceRoot.getAbsolutePath());
Notification.addSuccess("New workspace created: "
+ workspaceRoot.getAbsolutePath());
save();
}
public static void setActive(File workspaceRoot) {
Workspace w = null;
@@ -81,11 +83,11 @@ public class Workspace implements ProjectTreeNode, Serializable {
}
activeWorkspace = w;
}
public static void saveActive() {
activeWorkspace.save();
}
public void save() {
SettingsSave.saveInstance(this, settingsFile, "Workspace");
}
@@ -94,82 +96,104 @@ public class Workspace implements ProjectTreeNode, Serializable {
public Enumeration<ProjectTreeNode> children() {
return Collections.enumeration(projects);
}
@Override
public boolean getAllowsChildren() {
return true;
}
@Override
public TreeNode getChildAt(int arg0) {
return projects.get(arg0);
}
@Override
public int getChildCount() {
return projects.size();
}
@Override
public int getIndex(TreeNode arg0) {
return projects.indexOf(arg0);
}
@Override
public TreeNode getParent() {
return null;
}
@Override
public boolean isLeaf() {
return false;
}
@Override
public void childrenAdded(List<ProjectTreeNode> path) {
path.add(0, this);
if (projectsTreeModel != null) projectsTreeModel.insertNode(new TreePath(path.toArray()));
if (projectsTreeModel != null)
projectsTreeModel.insertNode(new TreePath(path.toArray()));
}
@Override
public void childrenChanged(List<ProjectTreeNode> path) {
path.add(0, this);
if (projectsTreeModel != null) projectsTreeModel.changeNode(new TreePath(path.toArray()));
ATContentStudio.frame.editorChanged(path.get(path.size() - 1));
}
@Override
public void childrenRemoved(List<ProjectTreeNode> path) {
path.add(0, this);
if (projectsTreeModel != null) projectsTreeModel.removeNode(new TreePath(path.toArray()));
if (projectsTreeModel != null)
projectsTreeModel.removeNode(new TreePath(path.toArray()));
}
@Override
public void notifyCreated() {
childrenAdded(new ArrayList<ProjectTreeNode>());
for (ProjectTreeNode node : projects) {
if (node != null) node.notifyCreated();
if (node != null)
node.notifyCreated();
}
}
@Override
public String getDesc() {
return "Workspace: "+baseFolder.getAbsolutePath();
return "Workspace: " + baseFolder.getAbsolutePath();
}
public static void createProject(final String projectName, final File gameSourceFolder, final Project.ResourceSet sourceSet) {
WorkerDialog.showTaskMessage("Creating project "+projectName+"...", ATContentStudio.frame, new Runnable() {
@Override
public void run() {
if (activeWorkspace.projectsName.contains(projectName)) {
Notification.addError("A project named "+projectName+" already exists in this workspace.");
return;
}
Project p = new Project(activeWorkspace, projectName, gameSourceFolder, sourceSet);
activeWorkspace.projects.add(p);
activeWorkspace.projectsName.add(projectName);
activeWorkspace.projectsOpenByName.put(projectName, p.open);
activeWorkspace.knownMapSourcesFolders.add(gameSourceFolder);
p.notifyCreated();
Notification.addSuccess("Project "+projectName+" successfully created");
saveActive();
}
});
public static void createProject(final String projectName,
final File gameSourceFolder, final Project.ResourceSet sourceSet) {
WorkerDialog.showTaskMessage("Creating project " + projectName + "...",
ATContentStudio.frame, new Runnable() {
@Override
public void run() {
if (activeWorkspace.projectsName.contains(projectName)) {
Notification.addError("A project named "
+ projectName
+ " already exists in this workspace.");
return;
}
Project p = new Project(activeWorkspace, projectName,
gameSourceFolder, sourceSet);
activeWorkspace.projects.add(p);
activeWorkspace.projectsName.add(projectName);
activeWorkspace.projectsOpenByName.put(projectName,
p.open);
activeWorkspace.knownMapSourcesFolders
.add(gameSourceFolder);
p.notifyCreated();
Notification.addSuccess("Project " + projectName
+ " successfully created");
saveActive();
}
});
}
public static void closeProject(Project p) {
int index = activeWorkspace.projects.indexOf(p);
if (index < 0) {
Notification.addError("Cannot close unknown project "+p.name);
Notification.addError("Cannot close unknown project " + p.name);
return;
}
p.close();
@@ -179,27 +203,31 @@ public class Workspace implements ProjectTreeNode, Serializable {
cp.notifyCreated();
saveActive();
}
public static void openProject(final ClosedProject cp) {
WorkerDialog.showTaskMessage("Opening project "+cp.name+"...", ATContentStudio.frame, new Runnable() {
@Override
public void run() {
int index = activeWorkspace.projects.indexOf(cp);
if (index < 0) {
Notification.addError("Cannot open unknown project "+cp.name);
return;
}
cp.childrenRemoved(new ArrayList<ProjectTreeNode>());
Project p = Project.fromFolder(activeWorkspace, new File(activeWorkspace.baseFolder, cp.name));
p.open();
activeWorkspace.projects.set(index, p);
activeWorkspace.projectsOpenByName.put(p.name, true);
p.notifyCreated();
saveActive();
}
});
WorkerDialog.showTaskMessage("Opening project " + cp.name + "...",
ATContentStudio.frame, new Runnable() {
@Override
public void run() {
int index = activeWorkspace.projects.indexOf(cp);
if (index < 0) {
Notification
.addError("Cannot open unknown project "
+ cp.name);
return;
}
cp.childrenRemoved(new ArrayList<ProjectTreeNode>());
Project p = Project.fromFolder(activeWorkspace,
new File(activeWorkspace.baseFolder, cp.name));
p.open();
activeWorkspace.projects.set(index, p);
activeWorkspace.projectsOpenByName.put(p.name, true);
p.notifyCreated();
saveActive();
}
});
}
public void refreshTransients() {
this.projects = new ArrayList<ProjectTreeNode>();
Set<String> projectsFailed = new HashSet<String>();
@@ -211,11 +239,16 @@ public class Workspace implements ProjectTreeNode, Serializable {
if (p != null) {
projects.add(p);
} else {
Notification.addError("Failed to open project "+projectName+". Removing it from workspace (not from filesystem though).");
Notification
.addError("Failed to open project "
+ projectName
+ ". Removing it from workspace (not from filesystem though).");
projectsFailed.add(projectName);
}
} else {
Notification.addError("Unable to find project "+projectName+"'s root folder. Removing it from workspace");
Notification.addError("Unable to find project "
+ projectName
+ "'s root folder. Removing it from workspace");
projectsFailed.add(projectName);
}
} else {
@@ -228,21 +261,31 @@ public class Workspace implements ProjectTreeNode, Serializable {
}
notifyCreated();
}
@Override
public Project getProject() {
return null;
}
@Override
public Image getIcon() {return null;}
@Override
public Image getClosedIcon() {return null;}
@Override
public Image getLeafIcon() {return null;}
@Override
public Image getOpenIcon() {return null;}
@Override
public Image getIcon() {
return null;
}
@Override
public Image getClosedIcon() {
return null;
}
@Override
public Image getLeafIcon() {
return null;
}
@Override
public Image getOpenIcon() {
return null;
}
public static void deleteProject(ClosedProject cp) {
cp.childrenRemoved(new ArrayList<ProjectTreeNode>());
@@ -250,37 +293,41 @@ public class Workspace implements ProjectTreeNode, Serializable {
activeWorkspace.projectsOpenByName.remove(cp.name);
activeWorkspace.projectsName.remove(cp.name);
if (delete(new File(activeWorkspace.baseFolder, cp.name))) {
Notification.addSuccess("Closed project "+cp.name+" successfully deleted.");
Notification.addSuccess("Closed project " + cp.name
+ " successfully deleted.");
} else {
Notification.addError("Error while deleting closed project "+cp.name+". Files may remain in the workspace.");
Notification.addError("Error while deleting closed project "
+ cp.name + ". Files may remain in the workspace.");
}
cp = null;
saveActive();
}
public static void deleteProject(Project p) {
p.childrenRemoved(new ArrayList<ProjectTreeNode>());
activeWorkspace.projects.remove(p);
activeWorkspace.projectsOpenByName.remove(p.name);
activeWorkspace.projectsName.remove(p.name);
if (delete(p.baseFolder)) {
Notification.addSuccess("Project "+p.name+" successfully deleted.");
Notification.addSuccess("Project " + p.name
+ " successfully deleted.");
} else {
Notification.addError("Error while deleting project "+p.name+". Files may remain in the workspace.");
Notification.addError("Error while deleting project " + p.name
+ ". Files may remain in the workspace.");
}
p = null;
saveActive();
}
private static boolean delete(File f) {
boolean b = true;
if (f.isDirectory()) {
for (File c : f.listFiles())
b &= delete(c);
}
return b&= f.delete();
return b &= f.delete();
}
@Override
public GameDataSet getDataSet() {
return null;
@@ -290,11 +337,10 @@ public class Workspace implements ProjectTreeNode, Serializable {
public Type getDataType() {
return null;
}
@Override
public boolean isEmpty() {
return projects.isEmpty();
}
}

View File

@@ -5,7 +5,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -264,7 +264,7 @@ public class ActorCondition extends JSONElement {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map toJson() {
Map jsonAC = new HashMap();
Map jsonAC = new LinkedHashMap();
jsonAC.put("id", this.id);
if (this.icon_id != null) jsonAC.put("iconID", this.icon_id);
if (this.display_name != null) jsonAC.put("name", this.display_name);
@@ -272,10 +272,10 @@ public class ActorCondition extends JSONElement {
if (this.positive != null && this.positive == 1) jsonAC.put("positive", this.positive);
if (this.stacking != null && this.stacking == 1) jsonAC.put("stacking", this.stacking);
if (this.round_effect != null) {
Map jsonRound = new HashMap();
Map jsonRound = new LinkedHashMap();
if (this.round_effect.visual_effect != null) jsonRound.put("visualEffectID", this.round_effect.visual_effect);
if (this.round_effect.hp_boost_min != null || this.round_effect.hp_boost_max != null) {
Map jsonHP = new HashMap();
Map jsonHP = new LinkedHashMap();
if (this.round_effect.hp_boost_min != null) jsonHP.put("min", this.round_effect.hp_boost_min);
else jsonHP.put("min", 0);
if (this.round_effect.hp_boost_max != null) jsonHP.put("max", this.round_effect.hp_boost_max);
@@ -283,7 +283,7 @@ public class ActorCondition extends JSONElement {
jsonRound.put("increaseCurrentHP", jsonHP);
}
if (this.round_effect.ap_boost_min != null || this.round_effect.ap_boost_max != null) {
Map jsonAP = new HashMap();
Map jsonAP = new LinkedHashMap();
if (this.round_effect.ap_boost_min != null) jsonAP.put("min", this.round_effect.ap_boost_min);
else jsonAP.put("min", 0);
if (this.round_effect.ap_boost_max != null) jsonAP.put("max", this.round_effect.ap_boost_max);
@@ -293,10 +293,10 @@ public class ActorCondition extends JSONElement {
jsonAC.put("roundEffect", jsonRound);
}
if (this.full_round_effect != null) {
Map jsonFullRound = new HashMap();
Map jsonFullRound = new LinkedHashMap();
if (this.full_round_effect.visual_effect != null) jsonFullRound.put("visualEffectID", this.full_round_effect.visual_effect);
if (this.full_round_effect.hp_boost_min != null || this.full_round_effect.hp_boost_max != null) {
Map jsonHP = new HashMap();
Map jsonHP = new LinkedHashMap();
if (this.full_round_effect.hp_boost_min != null) jsonHP.put("min", this.full_round_effect.hp_boost_min);
else jsonHP.put("min", 0);
if (this.full_round_effect.hp_boost_max != null) jsonHP.put("max", this.full_round_effect.hp_boost_max);
@@ -304,7 +304,7 @@ public class ActorCondition extends JSONElement {
jsonFullRound.put("increaseCurrentHP", jsonHP);
}
if (this.full_round_effect.ap_boost_min != null || this.full_round_effect.ap_boost_max != null) {
Map jsonAP = new HashMap();
Map jsonAP = new LinkedHashMap();
if (this.full_round_effect.ap_boost_min != null) jsonAP.put("min", this.full_round_effect.ap_boost_min);
else jsonAP.put("min", 0);
if (this.full_round_effect.ap_boost_max != null) jsonAP.put("max", this.full_round_effect.ap_boost_max);
@@ -314,10 +314,10 @@ public class ActorCondition extends JSONElement {
jsonAC.put("fullRoundEffect", jsonFullRound);
}
if (this.constant_ability_effect != null) {
Map jsonAbility = new HashMap();
Map jsonAbility = new LinkedHashMap();
if (this.constant_ability_effect.increase_attack_chance != null) jsonAbility.put("increaseAttackChance", this.constant_ability_effect.increase_attack_chance);
if (this.constant_ability_effect.increase_damage_min != null || this.constant_ability_effect.increase_damage_max != null) {
Map jsonAD = new HashMap();
Map jsonAD = new LinkedHashMap();
if (this.constant_ability_effect.increase_damage_min != null) jsonAD.put("min", this.constant_ability_effect.increase_damage_min);
else jsonAD.put("min", 0);
if (this.constant_ability_effect.increase_damage_max != null) jsonAD.put("max", this.constant_ability_effect.increase_damage_max);

View File

@@ -7,7 +7,7 @@ import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -223,10 +223,7 @@ public class Dialogue extends JSONElement {
if (replies != null) {
for (Reply reply : replies) {
if (reply.next_phrase_id != null) {
if (!reply.next_phrase_id.equals(Reply.EXIT_PHRASE_ID)
&& !reply.next_phrase_id.equals(Reply.FIGHT_PHRASE_ID)
&& !reply.next_phrase_id.equals(Reply.SHOP_PHRASE_ID)
&& !reply.next_phrase_id.equals(Reply.REMOVE_PHRASE_ID)) {
if (!Reply.KEY_PHRASE_ID.contains(reply.next_phrase_id)) {
reply.next_phrase = proj.getDialogue(reply.next_phrase_id);
}
}
@@ -247,7 +244,7 @@ public class Dialogue extends JSONElement {
case spawnAll:
case removeSpawnArea:
case deactivateSpawnArea:
reward.map = proj.getMap(reward.map_name);
reward.map = reward.map_name != null ? proj.getMap(reward.map_name) : null;
break;
case actorCondition:
reward.reward_obj = proj.getActorCondition(reward.reward_obj_id);
@@ -315,6 +312,11 @@ public class Dialogue extends JSONElement {
if (rclone.reward_obj != null) {
rclone.reward_obj.addBacklink(clone);
}
rclone.map = r.map;
rclone.map_name = r.map_name;
if (rclone.map != null) {
rclone.map.addBacklink(clone);
}
clone.rewards.add(rclone);
}
}
@@ -377,7 +379,7 @@ public class Dialogue extends JSONElement {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map toJson() {
Map dialogueJson = new HashMap();
Map dialogueJson = new LinkedHashMap();
dialogueJson.put("id", this.id);
if (this.message != null) dialogueJson.put("message", this.message);
if (this.switch_to_npc != null) {
@@ -389,7 +391,7 @@ public class Dialogue extends JSONElement {
List repliesJson = new ArrayList();
dialogueJson.put("replies", repliesJson);
for (Reply reply : this.replies){
Map replyJson = new HashMap();
Map replyJson = new LinkedHashMap();
repliesJson.add(replyJson);
if (reply.text != null) replyJson.put("text", reply.text);
if (reply.next_phrase != null) {
@@ -401,7 +403,7 @@ public class Dialogue extends JSONElement {
List requirementsJson = new ArrayList();
replyJson.put("requires", requirementsJson);
for (Requirement requirement : reply.requirements) {
Map requirementJson = new HashMap();
Map requirementJson = new LinkedHashMap();
requirementsJson.add(requirementJson);
if (requirement.type != null) requirementJson.put("requireType", requirement.type.toString());
if (requirement.required_obj != null) {
@@ -421,7 +423,7 @@ public class Dialogue extends JSONElement {
List rewardsJson = new ArrayList();
dialogueJson.put("rewards", rewardsJson);
for (Reward reward : this.rewards) {
Map rewardJson = new HashMap();
Map rewardJson = new LinkedHashMap();
rewardsJson.add(rewardJson);
if (reward.type != null) rewardJson.put("rewardType", reward.type.toString());
if (reward.reward_obj != null) {

View File

@@ -6,7 +6,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -203,13 +203,13 @@ public class Droplist extends JSONElement {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map toJson() {
Map droplistJson = new HashMap();
Map droplistJson = new LinkedHashMap();
droplistJson.put("id", this.id);
if (this.dropped_items != null) {
List droppedItemsJson = new ArrayList();
droplistJson.put("items", droppedItemsJson);
for (DroppedItem droppedItem : this.dropped_items) {
Map droppedItemJson = new HashMap();
Map droppedItemJson = new LinkedHashMap();
droppedItemsJson.add(droppedItemJson);
if (droppedItem.item != null) {
droppedItemJson.put("itemID", droppedItem.item.id);
@@ -218,7 +218,7 @@ public class Droplist extends JSONElement {
}
if (droppedItem.chance != null) droppedItemJson.put("chance", JSONElement.printJsonChance(droppedItem.chance));
if (droppedItem.quantity_min != null || droppedItem.quantity_max != null) {
Map quantityJson = new HashMap();
Map quantityJson = new LinkedHashMap();
droppedItemJson.put("quantity", quantityJson);
if (droppedItem.quantity_min != null) quantityJson.put("min", droppedItem.quantity_min);
else quantityJson.put("min", 0);

View File

@@ -9,7 +9,7 @@ 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.List;
import java.util.Map;
@@ -190,7 +190,7 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
List<SaveEvent> events = new ArrayList<SaveEvent>();
GameDataCategory<? extends JSONElement> impactedCategory = null;
String impactedFileName = fileName;
Map<String, Integer> containedIds = new HashMap<String, Integer>();
Map<String, Integer> containedIds = new LinkedHashMap<String, Integer>();
for (JSONElement node : this) {
if (node.getDataType() == GameSource.Type.created && getProject().baseContent.gameData.getGameDataElement(node.getClass(), node.id) != null) {
if (getProject().alteredContent.gameData.getGameDataElement(node.getClass(), node.id) != null) {

View File

@@ -6,7 +6,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -492,7 +492,7 @@ public class Item extends JSONElement {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map toJson() {
Map itemJson = new HashMap();
Map itemJson = new LinkedHashMap();
itemJson.put("id", this.id);
if (this.icon_id != null) itemJson.put("iconID", this.icon_id);
if (this.name != null) itemJson.put("name", this.name);
@@ -507,10 +507,10 @@ public class Item extends JSONElement {
}
if (this.description != null) itemJson.put("description", this.description);
if (this.equip_effect != null) {
Map equipEffectJson = new HashMap();
Map equipEffectJson = new LinkedHashMap();
itemJson.put("equipEffect", equipEffectJson);
if (this.equip_effect.damage_boost_min != null || this.equip_effect.damage_boost_max != null) {
Map damageJson = new HashMap();
Map damageJson = new LinkedHashMap();
equipEffectJson.put("increaseAttackDamage", damageJson);
if (this.equip_effect.damage_boost_min != null) damageJson.put("min", this.equip_effect.damage_boost_min);
else damageJson.put("min", 0);
@@ -532,7 +532,7 @@ public class Item extends JSONElement {
List conditionsJson = new ArrayList();
equipEffectJson.put("addedConditions", conditionsJson);
for (ConditionEffect condition : this.equip_effect.conditions) {
Map conditionJson = new HashMap();
Map conditionJson = new LinkedHashMap();
conditionsJson.add(conditionJson);
if (condition.condition != null) {
conditionJson.put("condition", condition.condition.id);
@@ -544,10 +544,10 @@ public class Item extends JSONElement {
}
}
if (this.hit_effect != null) {
Map hitEffectJson = new HashMap();
Map hitEffectJson = new LinkedHashMap();
itemJson.put("hitEffect", hitEffectJson);
if (this.hit_effect.hp_boost_min != null || this.hit_effect.hp_boost_max != null) {
Map hpJson = new HashMap();
Map hpJson = new LinkedHashMap();
hitEffectJson.put("increaseCurrentHP", hpJson);
if (this.hit_effect.hp_boost_min != null) hpJson.put("min", this.hit_effect.hp_boost_min);
else hpJson.put("min", 0);
@@ -555,7 +555,7 @@ public class Item extends JSONElement {
else hpJson.put("max", 0);
}
if (this.hit_effect.ap_boost_min != null || this.hit_effect.ap_boost_max != null) {
Map apJson = new HashMap();
Map apJson = new LinkedHashMap();
hitEffectJson.put("increaseCurrentAP", apJson);
if (this.hit_effect.ap_boost_min != null) apJson.put("min", this.hit_effect.ap_boost_min);
else apJson.put("min", 0);
@@ -566,7 +566,7 @@ public class Item extends JSONElement {
List conditionsSourceJson = new ArrayList();
hitEffectJson.put("conditionsSource", conditionsSourceJson);
for (TimedConditionEffect condition : this.hit_effect.conditions_source) {
Map conditionJson = new HashMap();
Map conditionJson = new LinkedHashMap();
conditionsSourceJson.add(conditionJson);
if (condition.condition != null) {
conditionJson.put("condition", condition.condition.id);
@@ -582,7 +582,7 @@ public class Item extends JSONElement {
List conditionsTargetJson = new ArrayList();
hitEffectJson.put("conditionsTarget", conditionsTargetJson);
for (TimedConditionEffect condition : this.hit_effect.conditions_target) {
Map conditionJson = new HashMap();
Map conditionJson = new LinkedHashMap();
conditionsTargetJson.add(conditionJson);
if (condition.condition != null) {
conditionJson.put("condition", condition.condition.id);
@@ -596,14 +596,14 @@ public class Item extends JSONElement {
}
}
if (this.kill_effect != null) {
Map killEffectJson = new HashMap();
Map killEffectJson = new LinkedHashMap();
if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.equip) {
itemJson.put("killEffect", killEffectJson);
} else if (this.category != null && this.category.action_type != null && this.category.action_type == ItemCategory.ActionType.use) {
itemJson.put("useEffect", killEffectJson);
}
if (this.kill_effect.hp_boost_min != null || this.kill_effect.hp_boost_max != null) {
Map hpJson = new HashMap();
Map hpJson = new LinkedHashMap();
killEffectJson.put("increaseCurrentHP", hpJson);
if (this.kill_effect.hp_boost_min != null) hpJson.put("min", this.kill_effect.hp_boost_min);
else hpJson.put("min", 0);
@@ -611,7 +611,7 @@ public class Item extends JSONElement {
else hpJson.put("min", 0);
}
if (this.kill_effect.ap_boost_min != null || this.kill_effect.ap_boost_max != null) {
Map apJson = new HashMap();
Map apJson = new LinkedHashMap();
killEffectJson.put("increaseCurrentAP", apJson);
if (this.kill_effect.ap_boost_min != null) apJson.put("min", this.kill_effect.ap_boost_min);
else apJson.put("min", 0);
@@ -622,7 +622,7 @@ public class Item extends JSONElement {
List conditionsSourceJson = new ArrayList();
killEffectJson.put("conditionsSource", conditionsSourceJson);
for (TimedConditionEffect condition : this.kill_effect.conditions_source) {
Map conditionJson = new HashMap();
Map conditionJson = new LinkedHashMap();
conditionsSourceJson.add(conditionJson);
if (condition.condition != null) {
conditionJson.put("condition", condition.condition.id);

View File

@@ -5,7 +5,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -310,7 +310,7 @@ public class ItemCategory extends JSONElement {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map toJson() {
Map itemCatJson = new HashMap();
Map itemCatJson = new LinkedHashMap();
itemCatJson.put("id", this.id);
if (this.name != null) itemCatJson.put("name", this.name);
if (this.action_type != null) itemCatJson.put("actionType", this.action_type.toString());

View File

@@ -6,7 +6,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -386,7 +386,7 @@ public class NPC extends JSONElement {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map toJson() {
Map npcJson = new HashMap();
Map npcJson = new LinkedHashMap();
npcJson.put("id", this.id);
if (this.name != null) npcJson.put("name", this.name);
if (this.icon_id != null) npcJson.put("iconID", this.icon_id);
@@ -397,7 +397,7 @@ public class NPC extends JSONElement {
if (this.monster_class != null) npcJson.put("monsterClass", this.monster_class.toString());
if (this.movement_type != null) npcJson.put("movementAggressionType", this.movement_type.toString());
if (this.attack_damage_min != null || this.attack_damage_max != null) {
Map adJson = new HashMap();
Map adJson = new LinkedHashMap();
npcJson.put("attackDamage", adJson);
if (this.attack_damage_min != null) adJson.put("min", this.attack_damage_min);
else adJson.put("min", 0);
@@ -423,10 +423,10 @@ public class NPC extends JSONElement {
if (this.block_chance != null) npcJson.put("blockChance", this.block_chance);
if (this.damage_resistance != null) npcJson.put("damageResistance", this.damage_resistance);
if (this.hit_effect != null) {
Map hitEffectJson = new HashMap();
Map hitEffectJson = new LinkedHashMap();
npcJson.put("hitEffect", hitEffectJson);
if (this.hit_effect.hp_boost_min != null || this.hit_effect.hp_boost_max != null) {
Map hpJson = new HashMap();
Map hpJson = new LinkedHashMap();
hitEffectJson.put("increaseCurrentHP", hpJson);
if (this.hit_effect.hp_boost_min != null) hpJson.put("min", this.hit_effect.hp_boost_min);
else hpJson.put("min", 0);
@@ -434,7 +434,7 @@ public class NPC extends JSONElement {
else hpJson.put("max", 0);
}
if (this.hit_effect.ap_boost_min != null || this.hit_effect.ap_boost_max != null) {
Map apJson = new HashMap();
Map apJson = new LinkedHashMap();
hitEffectJson.put("increaseCurrentAP", apJson);
if (this.hit_effect.ap_boost_min != null) apJson.put("min", this.hit_effect.ap_boost_min);
else apJson.put("min", 0);
@@ -445,7 +445,7 @@ public class NPC extends JSONElement {
List conditionsSourceJson = new ArrayList();
hitEffectJson.put("conditionsSource", conditionsSourceJson);
for (TimedConditionEffect condition : this.hit_effect.conditions_source) {
Map conditionJson = new HashMap();
Map conditionJson = new LinkedHashMap();
conditionsSourceJson.add(conditionJson);
if (condition.condition != null) {
conditionJson.put("condition", condition.condition.id);
@@ -461,7 +461,7 @@ public class NPC extends JSONElement {
List conditionsTargetJson = new ArrayList();
hitEffectJson.put("conditionsTarget", conditionsTargetJson);
for (TimedConditionEffect condition : this.hit_effect.conditions_target) {
Map conditionJson = new HashMap();
Map conditionJson = new LinkedHashMap();
conditionsTargetJson.add(conditionJson);
if (condition.condition != null) {
conditionJson.put("condition", condition.condition.id);

View File

@@ -6,7 +6,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -180,7 +180,7 @@ public class Quest extends JSONElement {
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Map toJson() {
Map questJson = new HashMap();
Map questJson = new LinkedHashMap();
questJson.put("id", this.id);
if (this.name != null) questJson.put("name", this.name);
if (this.visible_in_log != null) questJson.put("showInLog", this.visible_in_log);
@@ -188,7 +188,7 @@ public class Quest extends JSONElement {
List stagesJson = new ArrayList();
questJson.put("stages", stagesJson);
for (QuestStage stage : this.stages) {
Map stageJson = new HashMap();
Map stageJson = new LinkedHashMap();
stagesJson.add(stageJson);
if (stage.progress != null) stageJson.put("progress", stage.progress);
if (stage.log_text != null) stageJson.put("logText", stage.log_text);

View File

@@ -1,7 +1,7 @@
package com.gpl.rpg.atcontentstudio.model.gamedata;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -13,7 +13,7 @@ public class Requirement extends JSONElement {
private static final long serialVersionUID = 7295593297142310955L;
private static Map<RequirementType, List<RequirementType>> COMPATIBLE_TYPES = new HashMap<RequirementType, List<RequirementType>>();
private static Map<RequirementType, List<RequirementType>> COMPATIBLE_TYPES = new LinkedHashMap<RequirementType, List<RequirementType>>();
static {
List<RequirementType> questTypes = new ArrayList<RequirementType>();

View File

@@ -1,10 +1,8 @@
package com.gpl.rpg.atcontentstudio.model.maps;
import java.awt.Image;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement;
@@ -47,7 +45,7 @@ public class ReplaceArea extends MapObject {
for (Object s : obj.getProperties().keySet()) {
if (replacements == null) replacements = new LinkedList<ReplaceArea.Replacement>();
if (replacements == null) replacements = new ArrayList<ReplaceArea.Replacement>();
replacements.add(new Replacement(s.toString(), obj.getProperties().getProperty(s.toString())));
}
@@ -76,7 +74,7 @@ public class ReplaceArea extends MapObject {
}
public void addReplacement(ReplaceArea.Replacement repl) {
if (replacements == null) replacements = new LinkedList<ReplaceArea.Replacement>();
if (replacements == null) replacements = new ArrayList<ReplaceArea.Replacement>();
replacements.add(repl);
}

View File

@@ -21,10 +21,10 @@ import tiled.io.TMXMapWriter;
import com.gpl.rpg.atcontentstudio.Notification;
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
import com.gpl.rpg.atcontentstudio.model.GameSource;
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
import com.gpl.rpg.atcontentstudio.model.Project;
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;

View File

@@ -13,11 +13,10 @@ import javax.swing.tree.TreeNode;
import com.gpl.rpg.atcontentstudio.Notification;
import com.gpl.rpg.atcontentstudio.model.GameSource;
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
import com.gpl.rpg.atcontentstudio.model.Project.ResourceSet;
import com.gpl.rpg.atcontentstudio.model.Project;
import com.gpl.rpg.atcontentstudio.model.Project.ResourceSet;
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
import com.gpl.rpg.atcontentstudio.model.gamedata.Item;
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
public class TMXMapSet implements ProjectTreeNode {

View File

@@ -10,7 +10,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

View File

@@ -3,11 +3,8 @@ package com.gpl.rpg.atcontentstudio.model.maps;
import java.awt.Image;
import java.awt.Point;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -69,7 +66,7 @@ public class WorldmapSegment extends GameDataElement {
String area;
if ((area = mapNode.getAttribute("area")) != null && !"".equals(area)) {
if (labelledMaps.get(area) == null) {
labelledMaps.put(area, new LinkedList<String>());
labelledMaps.put(area, new ArrayList<String>());
}
labelledMaps.get(area).add(mapNode.getAttribute("id"));
}

View File

@@ -7,7 +7,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -43,8 +43,8 @@ public class Spritesheet extends GameDataElement {
//Lazy initialization.
public BufferedImage spritesheet = null;
public Map<Integer, BufferedImage> cache_full_size = new HashMap<Integer, BufferedImage>();
public Map<Integer, Image> cache_icon = new HashMap<Integer, Image>();
public Map<Integer, BufferedImage> cache_full_size = new LinkedHashMap<Integer, BufferedImage>();
public Map<Integer, Image> cache_icon = new LinkedHashMap<Integer, Image>();
public Spritesheet(SpriteSheetSet parent, File f) {
this.spritesheetFile = f;

View File

@@ -0,0 +1,646 @@
package com.gpl.rpg.atcontentstudio.model.tools.writermode;
import java.awt.Image;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.gpl.rpg.atcontentstudio.Notification;
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
import com.gpl.rpg.atcontentstudio.model.Project;
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
public class WriterModeData extends GameDataElement {
private static final long serialVersionUID = -7062544089063979696L;
public File jsonFile;
public Image npcIcon;
// public String sketchName;
public List<String> rootsId = new ArrayList<String>();
public List<WriterDialogue> roots = new ArrayList<WriterDialogue>();
public WriterDialogue begin;
public Map<String, WriterDialogue> nodesById = new LinkedHashMap<String, WriterDialogue>();
//public Map<String, WriterDialogue> dialogueThreads = new LinkedHashMap<String, WriterDialogue>();
public Map<String, Integer> threadsNextIndex = new LinkedHashMap<String, Integer>();
public WriterModeData(String id_prefix){
this.id = id_prefix;
}
@SuppressWarnings("rawtypes")
public WriterModeData(WriterModeDataSet parent, Map jsonObj) {
this.parent = parent;
this.jsonFile = parent.writerFile;
this.parse(jsonObj);
this.state = State.parsed;
}
public WriterModeData(String id_prefix, Dialogue imported) {
this.id = id_prefix;
this.begin = new WriterDialogue(imported);
this.state = State.linked;
}
public int getNextIndex(String id_prefix) {
Integer index = threadsNextIndex.get(id_prefix);
if (index == null) index = 0;
while (getProject().getDialogue(id_prefix+index) != null) {
index++;
}
threadsNextIndex.put(id_prefix, index + 1);
return index;
}
public abstract class WriterNode {
public String text;
public abstract String getTitle();
}
public WriterDialogue createDialogue(Dialogue dialogue) {
if (dialogue.message == null) {
return new SelectorDialogue(dialogue);
} else {
return new WriterDialogue(dialogue);
}
}
public class WriterDialogue extends WriterNode {
public String id;
public String id_prefix;
public int index;
public List<WriterReply> replies = new ArrayList<WriterReply>();
public List<WriterReply> parents = new ArrayList<WriterReply>();
public String dialogue_id;
public Dialogue dialogue;
public WriterDialogue() {}
public WriterDialogue(Dialogue dialogue) {
this.dialogue = dialogue;
this.text = dialogue.message;
this.id = this.dialogue_id = dialogue.id;
Pattern p = Pattern.compile("(.*)([0-9]+)");
Matcher m = p.matcher(dialogue.id);
if (m.matches()) {
this.id_prefix = m.group(1);
this.index = Integer.parseInt(m.group(2));
} else {
this.id_prefix = this.id+"_";
}
nodesById.put(this.id, this);
if (dialogue.replies != null) {
for (Dialogue.Reply reply : dialogue.replies) {
if (Dialogue.Reply.GO_NEXT_TEXT.equals(reply.text) || reply.text == null) {
replies.add(new EmptyReply(this, reply));
} else {
replies.add(new WriterReply(this, reply));
}
}
}
}
public WriterDialogue(String id_prefix) {
text = "";
this.id_prefix = id_prefix;
index = getNextIndex(id_prefix);
}
@Override
public String getTitle() {
return "Dialogue "+getID();
}
public String getID() {
return this.id != null ? this.id : this.id_prefix+this.index;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public void toJson(List<WriterDialogue> visited, List<Map> jsonData) {
if (visited.contains(this)) return;
visited.add(this);
Map dialogueJson = new LinkedHashMap();
jsonData.add(dialogueJson);
dialogueJson.put("id", id);
dialogueJson.put("id_prefix", id_prefix);
dialogueJson.put("index", index);
dialogueJson.put("text", text);
if (dialogue != null) {
dialogueJson.put("dialogue", dialogue.id);
} else if (dialogue_id != null) {
dialogueJson.put("dialogue", dialogue_id);
}
dialogueJson.put("special", isSpecial());
dialogueJson.put("begin", begin == this);
if (!replies.isEmpty()) {
List repliesJson = new ArrayList();
for (WriterReply reply : replies) {
repliesJson.add(reply.toJson(visited, jsonData));
}
dialogueJson.put("replies", repliesJson);
}
}
@SuppressWarnings("rawtypes")
public WriterDialogue(Map json) {
this.id = (String) json.get("id");
this.index = ((Number)json.get("index")).intValue();
this.id_prefix = (String) json.get("id_prefix");
this.text = (String) json.get("text");
this.dialogue_id = (String) json.get("dialogue");
if (json.get("begin") != null && ((Boolean)json.get("begin"))) begin = this;
if (json.get("replies") != null) {
List repliesJson = (List) json.get("replies");
for (Object rJson : repliesJson) {
if (((Map)rJson).get("special") != null && (Boolean)((Map)rJson).get("special")) {
//TODO Check different cases. But there are none currently.
this.replies.add(new EmptyReply(this, ((Map)rJson)));
} else {
this.replies.add(new WriterReply(this, (Map)rJson));
}
}
}
}
public boolean isSpecial() {return false;}
public Dialogue toDialogue(Map<WriterDialogue, Dialogue> visited, List<Dialogue> created, List<Dialogue> modified) {
if (visited.get(this) != null) return visited.get(this);
//Creating a new Dialogue
if (dialogue == null) {
dialogue = new Dialogue();
dialogue.id = getID();
dialogue.state = GameDataElement.State.parsed;
created.add(dialogue);
} else {
if (hasChanged()) {
if (dialogue.writable) {
//Modifying a created or altered Dialogue
dialogue.state = GameDataElement.State.modified;
modified.add(dialogue);
} else {
//Altering a game source Dialogue
//Dialogue clone = (Dialogue) dialogue.clone();
dialogue.getProject().makeWritable(dialogue);
Dialogue clone = dialogue.getProject().getDialogue(dialogue.id);
if (this.replies != null) {
for (WriterReply wReply : this.replies) {
if (wReply.reply != null) {
wReply.reply = clone.replies.get(dialogue.replies.indexOf(wReply.reply));
}
}
}
dialogue = clone;
dialogue.state = GameDataElement.State.parsed;
created.add(dialogue);
}
}
}
visited.put(this, dialogue);
dialogue.message = this.text;
if (this.replies != null && !this.replies.isEmpty()) {
if (dialogue.replies == null) {
dialogue.replies = new ArrayList<Dialogue.Reply>();
} else {
dialogue.replies.clear();
}
for (WriterReply wReply : this.replies) {
//if (wReply.reply != null && dialogue.replies)
dialogue.replies.add(wReply.toReply(visited, created, modified));
}
} else {
dialogue.replies = null;
}
return dialogue;
}
public boolean hasChanged() {
return dialogue == null ||
text == null ? dialogue.message!=null : !text.equals(dialogue.message) ||
repliesHaveChanged();
}
public boolean repliesHaveChanged() {
if (replies.isEmpty() && (dialogue.replies == null || dialogue.replies.isEmpty())) return false;
if (!replies.isEmpty() && (dialogue.replies == null || dialogue.replies.isEmpty())) return true;
if (replies.isEmpty() && (dialogue.replies != null && !dialogue.replies.isEmpty())) return true;
if (replies.size() != dialogue.replies.size()) return true;
for (WriterReply reply : replies) {
if (reply.hasChanged()) return true;
}
return false;
}
}
public abstract class SpecialDialogue extends WriterDialogue {
public SpecialDialogue() {}
public boolean isSpecial() {return true;}
public abstract SpecialDialogue duplicate();
public SpecialDialogue(Dialogue dialogue) {
super(dialogue);
}
}
public class SelectorDialogue extends SpecialDialogue {
public SelectorDialogue() {}
public SpecialDialogue duplicate() {return new SelectorDialogue();}
public SelectorDialogue(Dialogue dialogue) {
super(dialogue);
}
}
public class ShopDialogue extends SpecialDialogue {
public static final String id = Dialogue.Reply.SHOP_PHRASE_ID;
public SpecialDialogue duplicate() {return new ShopDialogue();}
}
public class FightDialogue extends SpecialDialogue {
public static final String id = Dialogue.Reply.FIGHT_PHRASE_ID;
public SpecialDialogue duplicate() {return new FightDialogue();}
}
public class EndDialogue extends SpecialDialogue {
public static final String id = Dialogue.Reply.EXIT_PHRASE_ID;
public SpecialDialogue duplicate() {return new EndDialogue();}
}
public class RemoveNPCDialogue extends SpecialDialogue {
public static final String id = Dialogue.Reply.REMOVE_PHRASE_ID;
public SpecialDialogue duplicate() {return new RemoveNPCDialogue();}
}
public class WriterReply extends WriterNode {
public WriterDialogue parent;
public String next_dialogue_id;
public WriterDialogue next_dialogue;
public Dialogue.Reply reply;
public WriterReply() {}
public WriterReply(WriterDialogue parent) {
this.parent = parent;
this.text = "";
parent.replies.add(this);
}
public WriterReply(WriterDialogue parent, Dialogue.Reply reply) {
this.parent = parent;
this.reply = reply;
this.text = reply.text;
this.next_dialogue_id = reply.next_phrase_id;
if (nodesById.get(this.next_dialogue_id) != null) {
this.next_dialogue = nodesById.get(this.next_dialogue_id);
} else if (reply.next_phrase != null ){
this.next_dialogue = new WriterDialogue(reply.next_phrase);
}
}
@SuppressWarnings("rawtypes")
public WriterReply(WriterDialogue parent, Map json) {
this.parent = parent;
this.text = (String) json.get("text");
if (json.containsKey("next_dialogue_id")) {
next_dialogue_id = (String) json.get("next_dialogue_id");
}
}
@Override
public String getTitle() {
return "Reply in "+parent.id_prefix+parent.index;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public Map toJson(List<WriterDialogue> visited, List<Map> jsonData) {
Map replyJson = new LinkedHashMap();
replyJson.put("text", text);
replyJson.put("special", isSpecial());
if (next_dialogue != null) {
replyJson.put("next_dialogue_id", next_dialogue.getID());
next_dialogue.toJson(visited, jsonData);
}
return replyJson;
}
public boolean isSpecial() {return false;}
public Dialogue.Reply toReply(Map<WriterDialogue, Dialogue> visited, List<Dialogue> created, List<Dialogue> modified) {
if (reply == null) {
reply = new Dialogue.Reply();
}
reply.text = this.text;
if (this.next_dialogue != null) {
this.next_dialogue.toDialogue(visited, created, modified);
reply.next_phrase_id = this.next_dialogue.getID();
} else if (this.next_dialogue_id != null) {
reply.next_phrase_id = this.next_dialogue_id;
} else {
reply.next_phrase_id = Dialogue.Reply.EXIT_PHRASE_ID;
}
return reply;
}
public boolean hasChanged() {
if (reply == null) return true;
if (text == null && reply.text != null) return true;
if (text != null && reply.text == null) return true;
if (text != null && !text.equals(reply.text)) return true;
String targetDialogueId = next_dialogue != null ? next_dialogue.getID() : next_dialogue_id;
String replyTargetDialogueId = reply.next_phrase != null ? reply.next_phrase.id : reply.next_phrase_id;
if (targetDialogueId == null && replyTargetDialogueId != null) return true;
if (targetDialogueId != null && replyTargetDialogueId == null) return true;
if (targetDialogueId != null && !targetDialogueId.equals(replyTargetDialogueId)) return true;
return false;
}
}
public class SpecialReply extends WriterReply {
public boolean isSpecial() {return true;}
public SpecialReply(WriterDialogue parent, Dialogue.Reply reply) {
super(parent, reply);
}
public SpecialReply(WriterDialogue parent) {
super(parent);
}
public SpecialReply(WriterDialogue parent, @SuppressWarnings("rawtypes") Map json) {
super(parent, json);
}
}
public class EmptyReply extends SpecialReply {
public EmptyReply(WriterDialogue parent, Dialogue.Reply reply) {
super(parent, reply);
text = Dialogue.Reply.GO_NEXT_TEXT;
}
public EmptyReply(WriterDialogue parent) {
super(parent);
text = Dialogue.Reply.GO_NEXT_TEXT;
}
public EmptyReply(WriterDialogue parent, @SuppressWarnings("rawtypes") Map json) {
super(parent, json);
text = Dialogue.Reply.GO_NEXT_TEXT;
}
}
@Override
public String getDesc() {
return (this.state == State.modified ? "*" : "")+id;
}
@Override
public Project getProject() {
return parent.getProject();
}
@Override
public Image getIcon() {
return DefaultIcons.getDialogueIcon();
}
@Override
public Image getOpenIcon() {
return null;
}
@Override
public Image getClosedIcon() {
return null;
}
@Override
public Image getLeafIcon() {
return getIcon();
}
@Override
public GameDataSet getDataSet() {
return null;
}
@Override
public GameDataElement clone() {
//TODO
return null;
}
@Override
public void elementChanged(GameDataElement oldOne, GameDataElement newOne) {
// Useless here.
}
@Override
public String getProjectFilename() {
return WriterModeDataSet.DEFAULT_REL_PATH_IN_PROJECT;
}
@Override
public void save() {
((WriterModeDataSet)this.getParent()).save(this.jsonFile);
}
@Override
public List<SaveEvent> attemptSave() {
List<SaveEvent> events = ((WriterModeDataSet)parent).attemptSave();
if (events == null || events.isEmpty()) {
return null;
}
if (events.size() == 1 && events.get(0).type == SaveEvent.Type.alsoSave && events.get(0).target == this) {
save();
return null;
}
return events;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public Map toJson() {
List<Map> jsonData = new ArrayList<Map>();
begin.toJson(new ArrayList<WriterModeData.WriterDialogue>(), jsonData);
Map jsonObj = new LinkedHashMap();
jsonObj.put("id", id);
jsonObj.put("dialogues", jsonData);
return jsonObj;
}
@SuppressWarnings("rawtypes")
public void parse() {
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
//This type of state is unrelated to parsing/linking.
return;
}
JSONParser parser = new JSONParser();
FileReader reader = null;
try {
reader = new FileReader(jsonFile);
List gameDataElements = (List) parser.parse(reader);
for (Object obj : gameDataElements) {
Map jsonObj = (Map)obj;
String id = (String) jsonObj.get("id");
if (id != null && id.equals(this.id )) {
this.parse(jsonObj);
this.state = State.parsed;
break;
}
}
} catch (FileNotFoundException e) {
Notification.addError("Error while parsing JSON file "+jsonFile.getAbsolutePath()+": "+e.getMessage());
e.printStackTrace();
} catch (IOException e) {
Notification.addError("Error while parsing JSON file "+jsonFile.getAbsolutePath()+": "+e.getMessage());
e.printStackTrace();
} catch (ParseException e) {
Notification.addError("Error while parsing JSON file "+jsonFile.getAbsolutePath()+": "+e.getMessage());
e.printStackTrace();
} finally {
if (reader != null)
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@SuppressWarnings("rawtypes")
public void parse(Map json) {
this.id = (String) json.get("id");
// this.sketchName = (String) json.get("name");
// List jsonRootsId = (List) json.get("roots_id");
// if (jsonRootsId != null) {
// for (Object jsonRootId : jsonRootsId) {
// rootsId.add((String) jsonRootId);
// }
// }
List jsonDialogues = (List) json.get("dialogues");
if (jsonDialogues != null) {
for (Object jsonDialogue : jsonDialogues) {
WriterDialogue dialogue = new WriterDialogue((Map)jsonDialogue);
nodesById.put(dialogue.getID(), dialogue);
}
}
this.state = State.parsed;
}
@Override
public void link() {
if (this.state == State.created) {
this.begin = new WriterDialogue();
begin.id_prefix = id;
begin.index = getNextIndex(id);
begin.text = "";
}
if (this.state == State.init) {
//Not parsed yet.
this.parse();
}
if (this.state == State.parsed) {
for (WriterDialogue dialogue : nodesById.values()) {
if (dialogue.dialogue_id != null) {
dialogue.dialogue = getProject().getDialogue(dialogue.dialogue_id);
}
if (dialogue.replies == null) continue;
for (WriterReply reply : dialogue.replies) {
if (reply.next_dialogue_id != null) {
if (isSpecial(reply.next_dialogue_id)) {
reply.next_dialogue = getSpecial(reply.next_dialogue_id);
} else {
reply.next_dialogue = nodesById.get(reply.next_dialogue_id);
}
}
//TODO Seriously, this is failure-prone by design. Can't do much better though...
List<Dialogue.Reply> linked = new ArrayList<Dialogue.Reply>(dialogue.dialogue.replies.size());
if (dialogue.dialogue != null && dialogue.dialogue.replies != null) {
//Try to hook to existing replies... not as easy when there's no ID.
Dialogue.Reply best = null;
int score, maxScore = 0;
for (Dialogue.Reply dReply : dialogue.dialogue.replies) {
//Never link twice to the same...
if (linked.contains(dReply)) continue;
score = 0;
//Arbitrary values... hopefully this gives good results.
//Same target gives good hope of preserving at least the structure.
if (dReply.next_phrase_id != null && dReply.next_phrase_id.equals(reply.next_dialogue_id)) score +=50;
//Same text is almost as good as an ID, but there may be duplicates due to requirements system...
if (dReply.text != null && dReply.text.equals(reply.text)) score +=40;
//Same slot in the list. That's not so bad if all else fails, and could help sort duplicates with same text.
if (dialogue.dialogue.replies.indexOf(dReply) == dialogue.replies.indexOf(reply)) score +=20;
//Both have null text. It's not much, but it's something....
if (dReply.text == null && reply.text == null) score += 10;
if (score > maxScore) {
maxScore = score;
best = dReply;
}
}
if (maxScore > 0) {
reply.reply = best;
linked.add(best);
}
}
}
}
for (String rootId : rootsId) {
roots.add(nodesById.get(rootId));
}
}
if (this.state == State.linked) {
//Already linked.
return;
}
this.state = State.linked;
}
public boolean isSpecial(String id) {
if (id == null) return false;
if (ShopDialogue.id.equals(id)) return true;
if (FightDialogue.id.equals(id)) return true;
if (EndDialogue.id.equals(id)) return true;
if (RemoveNPCDialogue.id.equals(id)) return true;
return false;
}
public SpecialDialogue getSpecial(String id) {
if (id == null) return null;
if (ShopDialogue.id.equals(id)) return new ShopDialogue();
if (FightDialogue.id.equals(id)) return new FightDialogue();
if (EndDialogue.id.equals(id)) return new EndDialogue();
if (RemoveNPCDialogue.id.equals(id)) return new RemoveNPCDialogue();
return null;
}
public List<Dialogue> toDialogue(){
Map<WriterModeData.WriterDialogue, Dialogue> visited = new LinkedHashMap<WriterModeData.WriterDialogue, Dialogue>();
List<Dialogue> created = new ArrayList<Dialogue>();
List<Dialogue> modified = new ArrayList<Dialogue>();
begin.toDialogue(visited, created, modified);
for (Dialogue modifiedDialogue : modified) {
modifiedDialogue.childrenChanged(new ArrayList<ProjectTreeNode>());
}
return created;
}
}

View File

@@ -0,0 +1,266 @@
package com.gpl.rpg.atcontentstudio.model.tools.writermode;
import java.awt.Image;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import javax.swing.tree.TreeNode;
import org.json.simple.JSONArray;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.gpl.rpg.atcontentstudio.Notification;
import com.gpl.rpg.atcontentstudio.io.JsonPrettyWriter;
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
import com.gpl.rpg.atcontentstudio.model.GameDataElement.State;
import com.gpl.rpg.atcontentstudio.model.GameSource;
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
import com.gpl.rpg.atcontentstudio.model.Project;
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
public class WriterModeDataSet implements ProjectTreeNode, Serializable {
private static final long serialVersionUID = 5434504851883441971L;
public static final String DEFAULT_REL_PATH_IN_PROJECT = "writer.json";
public GameSource parent;
public File writerFile;
public List<WriterModeData> writerModeDataList = new ArrayList<WriterModeData>();
public WriterModeDataSet(GameSource gameSource) {
this.parent = gameSource;
writerFile = new File(parent.baseFolder, DEFAULT_REL_PATH_IN_PROJECT);
parse();
}
@Override
public TreeNode getChildAt(int childIndex) {
return writerModeDataList.get(childIndex);
}
@Override
public int getChildCount() {
return writerModeDataList.size();
}
@Override
public TreeNode getParent() {
return parent;
}
@Override
public int getIndex(TreeNode node) {
return writerModeDataList.indexOf(node);
}
@Override
public boolean getAllowsChildren() {
return true;
}
@Override
public boolean isLeaf() {
return false;
}
@SuppressWarnings("rawtypes")
@Override
public Enumeration children() {
return Collections.enumeration(writerModeDataList);
}
@Override
public void childrenAdded(List<ProjectTreeNode> path) {
path.add(0,this);
parent.childrenAdded(path);
}
@Override
public void childrenChanged(List<ProjectTreeNode> path) {
path.add(0,this);
parent.childrenChanged(path);
}
@Override
public void childrenRemoved(List<ProjectTreeNode> path) {
path.add(0,this);
parent.childrenRemoved(path);
}
@Override
public void notifyCreated() {
childrenAdded(new ArrayList<ProjectTreeNode>());
}
@Override
public String getDesc() {
return "Dialogue sketchs";
}
@Override
public Project getProject() {
return parent.getProject();
}
@Override
public GameDataSet getDataSet() {
return null;
}
@Override
public Image getIcon() {
return DefaultIcons.getStdClosedIcon();
}
@Override
public Image getOpenIcon() {
return DefaultIcons.getStdOpenIcon();
}
@Override
public Image getClosedIcon() {
return DefaultIcons.getStdClosedIcon();
}
@Override
public Image getLeafIcon() {
return null;
}
@Override
public Type getDataType() {
return parent.getDataType();
}
@Override
public boolean isEmpty() {
return writerModeDataList.isEmpty();
}
@SuppressWarnings("rawtypes")
public void save(File jsonFile) {
List<Map> dataToSave = new ArrayList<Map>();
for (WriterModeData data : writerModeDataList) {
if (data.jsonFile.equals(jsonFile)) {
dataToSave.add(data.toJson());
}
}
if (dataToSave.isEmpty() && writerFile.exists()) {
if (writerFile.delete()) {
Notification.addSuccess("File "+writerFile.getAbsolutePath()+" deleted.");
} else {
Notification.addError("Error deleting file "+writerFile.getAbsolutePath());
}
return;
}
StringWriter writer = new JsonPrettyWriter();
try {
JSONArray.writeJSONString(dataToSave, writer);
} catch (IOException e) {
//Impossible with a StringWriter
}
String toWrite = writer.toString();
try {
FileWriter w = new FileWriter(writerFile);
w.write(toWrite);
w.close();
for (WriterModeData element : writerModeDataList) {
element.state = GameDataElement.State.saved;
}
Notification.addSuccess("Json file "+writerFile.getAbsolutePath()+" saved.");
} catch (IOException e) {
Notification.addError("Error while writing json file "+writerFile.getAbsolutePath()+" : "+e.getMessage());
e.printStackTrace();
}
}
public List<SaveEvent> attemptSave() {
List<SaveEvent> events = new ArrayList<SaveEvent>();
for (WriterModeData data : writerModeDataList) {
if (data.state == State.created || data.state == State.modified) {
events.add(new SaveEvent(SaveEvent.Type.alsoSave, data));
}
}
return events;
}
@SuppressWarnings("rawtypes")
public void parse() {
if (!writerFile.exists()) return;
JSONParser parser = new JSONParser();
FileReader reader = null;
try {
reader = new FileReader(writerFile);
List writerDataListJson = (List) parser.parse(reader);
for (Object obj : writerDataListJson) {
Map jsonObj = (Map)obj;
WriterModeData data = new WriterModeData(this, jsonObj);
data.writable = true;
writerModeDataList.add(data);
}
} catch (FileNotFoundException e) {
Notification.addError("Error while parsing JSON file "+writerFile.getAbsolutePath()+": "+e.getMessage());
e.printStackTrace();
} catch (IOException e) {
Notification.addError("Error while parsing JSON file "+writerFile.getAbsolutePath()+": "+e.getMessage());
e.printStackTrace();
} catch (ParseException e) {
Notification.addError("Error while parsing JSON file "+writerFile.getAbsolutePath()+": "+e.getMessage());
e.printStackTrace();
} finally {
if (reader != null)
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public WriterModeData getWriterSketch(String id) {
for (WriterModeData sketch : writerModeDataList) {
if (id.equals(sketch.id)){
return sketch;
}
}
return null;
}
public WriterModeData get(int index) {
return writerModeDataList.get(index);
}
public void add(WriterModeData node) {
ProjectTreeNode higherEmptyParent = this;
while (higherEmptyParent != null) {
if (higherEmptyParent.getParent() != null && ((ProjectTreeNode)higherEmptyParent.getParent()).isEmpty()) higherEmptyParent = (ProjectTreeNode)higherEmptyParent.getParent();
else break;
}
if (higherEmptyParent == this && !this.isEmpty()) higherEmptyParent = null;
writerModeDataList.add(node);
node.writable = true;
if (node.jsonFile == null) node.jsonFile = this.writerFile;
node.parent = this;
if (higherEmptyParent != null) higherEmptyParent.notifyCreated();
else node.notifyCreated();
}
}

View File

@@ -81,6 +81,7 @@ public class AboutEditor extends Editor {
public static final AboutEditor instance = new AboutEditor();
@SuppressWarnings("resource")
private AboutEditor() {
this.name="About "+ATContentStudio.APP_NAME;
this.icon = new ImageIcon(DefaultIcons.getMainIconIcon());

View File

@@ -2,7 +2,7 @@ package com.gpl.rpg.atcontentstudio.ui;
import java.awt.Image;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.imageio.ImageIO;
@@ -11,8 +11,8 @@ import com.gpl.rpg.atcontentstudio.Notification;
public class DefaultIcons {
private static Map<String, Image> imageCache = new HashMap<String, Image>();
private static Map<String, Image> iconCache = new HashMap<String, Image>();
private static Map<String, Image> imageCache = new LinkedHashMap<String, Image>();
private static Map<String, Image> iconCache = new LinkedHashMap<String, Image>();
private static String MAIN_ICON_RES = "/com/gpl/rpg/atcontentstudio/img/andorstrainer.png";

View File

@@ -306,15 +306,18 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
return bbcb;
}
public static JComboBox addEnumValueBox(JPanel pane, String label, @SuppressWarnings("rawtypes") Enum[] values, @SuppressWarnings("rawtypes") Enum initialValue, boolean writable) {
@SuppressWarnings("rawtypes")
public static JComboBox addEnumValueBox(JPanel pane, String label, Enum[] values, Enum initialValue, boolean writable) {
return addEnumValueBox(pane, label, values, initialValue, writable, new FieldUpdateListener() {@Override public void valueChanged(JComponent source, Object value) {}});
}
public static JComboBox addEnumValueBox(JPanel pane, String label, @SuppressWarnings("rawtypes") Enum[] values, @SuppressWarnings("rawtypes") Enum initialValue, boolean writable, final FieldUpdateListener listener) {
@SuppressWarnings("rawtypes")
public static JComboBox addEnumValueBox(JPanel pane, String label, Enum[] values, Enum initialValue, boolean writable, final FieldUpdateListener listener) {
JPanel comboPane = new JPanel();
comboPane.setLayout(new JideBoxLayout(comboPane, JideBoxLayout.LINE_AXIS, 6));
JLabel comboLabel = new JLabel(label);
comboPane.add(comboLabel, JideBoxLayout.FIX);
@SuppressWarnings("unchecked")
final JComboBox enumValuesCombo = new JComboBox(values);
enumValuesCombo.setEnabled(writable);
enumValuesCombo.setSelectedItem(initialValue);
@@ -347,7 +350,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
final GDEComboModel<NPC> comboModel = new GDEComboModel<NPC>(proj, npc){
private static final long serialVersionUID = 2638082961277241764L;
@Override
public Object getTypedElementAt(int index) {
public NPC getTypedElementAt(int index) {
return project.getNPC(index);
}
@Override
@@ -362,7 +365,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
final GDEComboModel<ActorCondition> comboModel = new GDEComboModel<ActorCondition>(proj, acond){
private static final long serialVersionUID = 2638082961277241764L;
@Override
public Object getTypedElementAt(int index) {
public ActorCondition getTypedElementAt(int index) {
return project.getActorCondition(index);
}
@Override
@@ -377,7 +380,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
final GDEComboModel<Item> comboModel = new GDEComboModel<Item>(proj, item){
private static final long serialVersionUID = 2638082961277241764L;
@Override
public Object getTypedElementAt(int index) {
public Item getTypedElementAt(int index) {
return project.getItem(index);
}
@Override
@@ -392,7 +395,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
final GDEComboModel<ItemCategory> comboModel = new GDEComboModel<ItemCategory>(proj, ic){
private static final long serialVersionUID = 2638082961277241764L;
@Override
public Object getTypedElementAt(int index) {
public ItemCategory getTypedElementAt(int index) {
return project.getItemCategory(index);
}
@Override
@@ -407,7 +410,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
final GDEComboModel<Quest> comboModel = new GDEComboModel<Quest>(proj, quest){
private static final long serialVersionUID = 2638082961277241764L;
@Override
public Object getTypedElementAt(int index) {
public Quest getTypedElementAt(int index) {
return project.getQuest(index);
}
@Override
@@ -422,7 +425,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
final GDEComboModel<Droplist> comboModel = new GDEComboModel<Droplist>(proj, droplist){
private static final long serialVersionUID = 2638082961277241764L;
@Override
public Object getTypedElementAt(int index) {
public Droplist getTypedElementAt(int index) {
return project.getDroplist(index);
}
@Override
@@ -437,7 +440,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
final GDEComboModel<Dialogue> comboModel = new GDEComboModel<Dialogue>(proj, dialogue){
private static final long serialVersionUID = 2638082961277241764L;
@Override
public Object getTypedElementAt(int index) {
public Dialogue getTypedElementAt(int index) {
return project.getDialogue(index);
}
@Override
@@ -452,7 +455,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
final GDEComboModel<TMXMap> comboModel = new GDEComboModel<TMXMap>(proj, map){
private static final long serialVersionUID = 2638082961277241764L;
@Override
public Object getTypedElementAt(int index) {
public TMXMap getTypedElementAt(int index) {
return project.getMap(index);
}
@Override
@@ -463,6 +466,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
return addGDEBox(pane, label, map, TMXMap.class, comboModel, writable, listener);
}
@SuppressWarnings("unchecked")
public MyComboBox addGDEBox(JPanel pane, String label, GameDataElement gde, final Class<? extends GameDataElement> dataClass, final GDEComboModel<? extends GameDataElement> comboModel, final boolean writable, final FieldUpdateListener listener) {
JPanel gdePane = new JPanel();
gdePane.setLayout(new JideBoxLayout(gdePane, JideBoxLayout.LINE_AXIS, 6));
@@ -529,6 +533,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
return gdeBox;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public JList addBacklinksList(JPanel pane, GameDataElement gde) {
final JList list = new JList(new GDEBacklinksListModel(gde));
list.addMouseListener(new MouseAdapter() {
@@ -561,7 +566,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
return list;
}
public static abstract class GDEComboModel<E extends GameDataElement> extends AbstractListModel implements ComboBoxModel {
public static abstract class GDEComboModel<E extends GameDataElement> extends AbstractListModel<E> implements ComboBoxModel<E> {
private static final long serialVersionUID = -5854574666510314715L;
@@ -577,14 +582,14 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
public abstract int getSize();
@Override
public Object getElementAt(int index) {
public E getElementAt(int index) {
if (index == 0) {
return null;
}
return getTypedElementAt(index - 1);
}
public abstract Object getTypedElementAt(int index);
public abstract E getTypedElementAt(int index);
@SuppressWarnings("unchecked")
@Override
@@ -620,6 +625,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
this.writable = writable;
}
@SuppressWarnings("rawtypes")
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
@@ -642,7 +648,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
}
public static class GDEBacklinksListModel implements ListModel {
public static class GDEBacklinksListModel implements ListModel<GameDataElement> {
GameDataElement source;
@@ -667,7 +673,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
}
@Override
public Object getElementAt(int index) {
public GameDataElement getElementAt(int index) {
for (GameDataElement gde : source.getBacklinks()) {
if (index == 0) return gde;
index --;
@@ -694,6 +700,7 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
}
}
@SuppressWarnings({"rawtypes", "unchecked"})
public class MyComboBox extends JComboBox implements ProjectElementListener {
private static final long serialVersionUID = -4184228604170642567L;
@@ -706,13 +713,11 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
Editor.this.addElementListener(dataType, this);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void elementAdded(GameDataElement added, int index) {
((GDEComboModel)getModel()).itemAdded(added, index);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void elementRemoved(GameDataElement removed, int index) {
((GDEComboModel)getModel()).itemRemoved(removed, index);

View File

@@ -3,7 +3,7 @@ package com.gpl.rpg.atcontentstudio.ui;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.swing.Action;
@@ -22,6 +22,7 @@ import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
import com.gpl.rpg.atcontentstudio.model.saves.SavedGame;
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeData;
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.ActorConditionEditor;
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.DialogueEditor;
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.DroplistEditor;
@@ -33,13 +34,14 @@ import com.gpl.rpg.atcontentstudio.ui.map.TMXMapEditor;
import com.gpl.rpg.atcontentstudio.ui.map.WorldMapEditor;
import com.gpl.rpg.atcontentstudio.ui.saves.SavedGameEditor;
import com.gpl.rpg.atcontentstudio.ui.sprites.SpritesheetEditor;
import com.gpl.rpg.atcontentstudio.ui.tools.writermode.WriterModeEditor;
import com.jidesoft.swing.JideTabbedPane;
public class EditorsArea extends JPanel {
private static final long serialVersionUID = 8801849846876081538L;
private Map<Object, Editor> editors = new HashMap<Object, Editor>();
private Map<Object, Editor> editors = new LinkedHashMap<Object, Editor>();
private JideTabbedPane tabHolder;
public EditorsArea() {
@@ -155,6 +157,15 @@ public class EditorsArea extends JPanel {
openEditor(new WorldMapEditor(node));
}
public void openEditor(WriterModeData node) {
if (editors.containsKey(node)) {
tabHolder.setSelectedComponent(editors.get(node));
return;
}
node.link();
openEditor(new WriterModeEditor(node));
}
public void closeEditor(ProjectTreeNode node) {
if (editors.containsKey(node)) {
closeEditor(editors.get(node));

View File

@@ -59,6 +59,7 @@ public class JSONCreationWizard extends JDialog {
private JSONElement creation = null;
final JLabel message;
@SuppressWarnings("rawtypes")
final JComboBox dataTypeCombo;
final JTextField idField;
final JTextField nameField;
@@ -85,6 +86,7 @@ public class JSONCreationWizard extends JDialog {
dataTypeCombo.setEnabled(false);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public JSONCreationWizard(final Project proj) {
super(ATContentStudio.frame);
this.proj = proj;
@@ -501,6 +503,7 @@ public class JSONCreationWizard extends JDialog {
}
}
@SuppressWarnings("rawtypes")
public static class DataTypeComboModel implements ComboBoxModel {
DataType selected = DataType.none;
@@ -542,7 +545,7 @@ public class JSONCreationWizard extends JDialog {
private static final long serialVersionUID = 5621373849299980998L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
((JLabel)c).setText(JSONCreationWizard.dataTypeDesc((DataType) value));

View File

@@ -75,6 +75,7 @@ public class JSONImportWizard extends JDialog {
JPanel pane;
JLabel message;
@SuppressWarnings("rawtypes")
JComboBox dataTypeCombo;
JRadioButton importFromFile;
JRadioButton importPasted;
@@ -83,11 +84,13 @@ public class JSONImportWizard extends JDialog {
JButton browse;
RSyntaxTextArea jsonPasteArea;
JScrollPane scroller;
@SuppressWarnings("rawtypes")
JList createdPreview;
JPanel buttonPane;
JButton ok, cancel;
ActionListener okListener, cancelListener;
@SuppressWarnings({ "rawtypes", "unchecked" })
public JSONImportWizard(Project proj) {
super(ATContentStudio.frame);
@@ -390,6 +393,7 @@ public class JSONImportWizard extends JDialog {
}
}
@SuppressWarnings("unchecked")
private void showImportPreviewScreen(final List<JSONElement> created) {
pane.removeAll();
message.setText("The following data has been found. Click \"Ok\" to confirm.");
@@ -404,11 +408,8 @@ public class JSONImportWizard extends JDialog {
okListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JSONElement lastNode = null;
for (JSONElement node : created) {
proj.createElement(node);
lastNode = node;
}
proj.createElements(created);
JSONElement lastNode = created.get(created.size() - 1);
if (lastNode != null) {
lastNode.save();
ATContentStudio.frame.selectInTree(lastNode);
@@ -432,6 +433,7 @@ public class JSONImportWizard extends JDialog {
pane.repaint();
}
@SuppressWarnings("unchecked")
private void showErrorScreen(List<String> errors) {
pane.removeAll();
message.setText("Failed to import. The following error(s) have been encountered:");
@@ -464,6 +466,7 @@ public class JSONImportWizard extends JDialog {
pane.repaint();
}
@SuppressWarnings("unchecked")
private void showWarningScreen(List<String> warnings, final List<JSONElement> created) {
pane.removeAll();
message.setText("The following warnings(s) were raised while importing:");
@@ -511,7 +514,7 @@ public class JSONImportWizard extends JDialog {
}
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value == null) {
label.setText("none");
@@ -555,7 +558,7 @@ public class JSONImportWizard extends JDialog {
public static class ErrorRenderer extends DefaultListCellRenderer {
private static final long serialVersionUID = -4265342800284721660L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
((JLabel)c).setIcon(NotificationsPane.icons.get(Notification.Type.ERROR));
@@ -568,7 +571,7 @@ public class JSONImportWizard extends JDialog {
public static class WarningRenderer extends DefaultListCellRenderer {
private static final long serialVersionUID = -3836045237946111606L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
((JLabel)c).setIcon(NotificationsPane.icons.get(Notification.Type.WARN));
@@ -577,6 +580,7 @@ public class JSONImportWizard extends JDialog {
}
}
@SuppressWarnings("rawtypes")
public static class GDEListModel implements ListModel {
List<? extends Object> source;
@@ -620,6 +624,7 @@ public class JSONImportWizard extends JDialog {
}
@SuppressWarnings("rawtypes")
public static class DataTypeComboModel implements ComboBoxModel {
DataType selected = DataType.none;
@@ -661,7 +666,7 @@ public class JSONImportWizard extends JDialog {
private static final long serialVersionUID = 5621373849299980998L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
((JLabel)c).setText(dataTypeDesc((DataType) value));

View File

@@ -5,7 +5,7 @@ import java.awt.Component;
import java.awt.Font;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -24,6 +24,7 @@ import com.gpl.rpg.atcontentstudio.Notification;
import com.gpl.rpg.atcontentstudio.NotificationListener;
@SuppressWarnings("rawtypes")
public class NotificationsPane extends JList {
private static final long serialVersionUID = -1100364214372392608L;
@@ -33,7 +34,7 @@ public class NotificationsPane extends JList {
public static final String warn_img_name = "/com/gpl/rpg/atcontentstudio/img/warn.png";
public static final String error_img_name = "/com/gpl/rpg/atcontentstudio/img/error.png";
public static final Map<Notification.Type, Icon> icons = new HashMap<Notification.Type, Icon>(Notification.Type.values().length);
public static final Map<Notification.Type, Icon> icons = new LinkedHashMap<Notification.Type, Icon>(Notification.Type.values().length);
static {
try {
@@ -47,6 +48,7 @@ public class NotificationsPane extends JList {
}
@SuppressWarnings("unchecked")
public NotificationsPane() {
super();
MyListModel model = new MyListModel();

View File

@@ -9,7 +9,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import javax.swing.ComboBoxModel;
@@ -67,7 +67,7 @@ public class ProjectCreationWizard extends JDialog {
return Project.ResourceSet.values()[index];
}
List<ListDataListener> listeners = new LinkedList<ListDataListener>();
List<ListDataListener> listeners = new ArrayList<ListDataListener>();
@Override
public void addListDataListener(ListDataListener l) {

View File

@@ -37,6 +37,7 @@ import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
import com.gpl.rpg.atcontentstudio.model.saves.SavedGame;
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeData;
import com.jidesoft.swing.TreeSearchable;
public class ProjectsTree extends JPanel {
@@ -236,6 +237,23 @@ public class ProjectsTree extends JPanel {
addNextSeparator = false;
}
if (actions.testWriter.isEnabled()) {
addNextSeparator = true;
popupMenu.add(new JMenuItem(actions.testWriter));
}
// if (actions.testCommitWriter.isEnabled()) {
// addNextSeparator = true;
// popupMenu.add(new JMenuItem(actions.testCommitWriter));
// }
if (actions.createWriter.isEnabled()) {
addNextSeparator = true;
popupMenu.add(new JMenuItem(actions.createWriter));
}
if (addNextSeparator) {
popupMenu.add(new JSeparator());
addNextSeparator = false;
}
if (konamiCodeEntered) {
JMenuItem openTrainer = new JMenuItem("Start Andor's Trainer...");
popupMenu.add(openTrainer);
@@ -570,6 +588,8 @@ public class ProjectsTree extends JPanel {
ATContentStudio.frame.openEditor((TMXMap)node);
} else if (node instanceof WorldmapSegment) {
ATContentStudio.frame.openEditor((WorldmapSegment)node);
} else if (node instanceof WriterModeData) {
ATContentStudio.frame.openEditor((WriterModeData)node);
} else if (node instanceof SavedGame) {
if (konamiCodeEntered) {
ATContentStudio.frame.openEditor((SavedGame)node);

View File

@@ -35,11 +35,15 @@ public class SaveItemsWizard extends JDialog {
List<SaveEvent> events;
@SuppressWarnings("rawtypes")
JList movedToCreated;
@SuppressWarnings("rawtypes")
JList movedToAltered;
@SuppressWarnings("rawtypes")
JList willBeSaved;
@SuppressWarnings({ "unchecked", "rawtypes" })
public SaveItemsWizard(List<SaveEvent> events, GameDataElement originalRequester) {
super(ATContentStudio.frame);
this.events = events;
@@ -170,7 +174,6 @@ public class SaveItemsWizard extends JDialog {
buttonPane.add(okButton, JideBoxLayout.FIX);
pane.add(buttonPane, JideBoxLayout.FIX);
okButton.addActionListener(new ActionListener() {
@SuppressWarnings("unchecked")
@Override
public void actionPerformed(ActionEvent e) {
@@ -251,7 +254,7 @@ public class SaveItemsWizard extends JDialog {
private static final long serialVersionUID = 5764079243906396333L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
JLabel label = (JLabel) c;

View File

@@ -34,6 +34,7 @@ import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
import com.gpl.rpg.atcontentstudio.model.saves.SavedGame;
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeData;
public class StudioFrame extends JFrame {
@@ -52,6 +53,7 @@ public class StudioFrame extends JFrame {
final JSplitPane topDown = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
final JSplitPane leftRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
@SuppressWarnings("rawtypes")
JList notifs = new NotificationsPane();
projectTree = new ProjectsTree();
editors = new EditorsArea();
@@ -193,6 +195,11 @@ public class StudioFrame extends JFrame {
editors.openEditor(node);
}
public void openEditor(WriterModeData node) {
node.link();
editors.openEditor(node);
}
public void openEditor(GameDataElement node) {
if (node instanceof JSONElement) {
@@ -201,6 +208,8 @@ public class StudioFrame extends JFrame {
openEditor((Spritesheet) node);
} else if (node instanceof TMXMap) {
openEditor((TMXMap) node);
} else if (node instanceof WriterModeData) {
openEditor((WriterModeData) node);
}
}

View File

@@ -6,9 +6,9 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -19,8 +19,6 @@ import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.tree.TreePath;
import bsh.util.JConsole;
import com.gpl.rpg.atcontentstudio.ATContentStudio;
import com.gpl.rpg.atcontentstudio.model.ClosedProject;
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
@@ -29,11 +27,14 @@ import com.gpl.rpg.atcontentstudio.model.Project;
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
import com.gpl.rpg.atcontentstudio.model.Workspace;
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataCategory;
import com.gpl.rpg.atcontentstudio.model.gamedata.JSONElement;
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
import com.gpl.rpg.atcontentstudio.model.saves.SavedGamesSet;
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeData;
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeDataSet;
import com.gpl.rpg.atcontentstudio.ui.tools.BeanShellView;
import com.gpl.rpg.atcontentstudio.ui.tools.ItemsTableView;
import com.gpl.rpg.atcontentstudio.ui.tools.NPCsTableView;
@@ -130,6 +131,9 @@ public class WorkspaceActions {
} else if (element instanceof TMXMap) {
TMXMapSet parent = (TMXMapSet) element.getParent();
parent.tmxMaps.remove(element);
} else if (element instanceof WriterModeData) {
WriterModeDataSet parent = (WriterModeDataSet) element.getParent();
parent.writerModeDataList.remove(element);
}
}
new Thread() {
@@ -168,6 +172,12 @@ public class WorkspaceActions {
} else {
new SaveItemsWizard(events, null).setVisible(true);
}
} else if (node instanceof TMXMap) {
TMXMapSet parent = (TMXMapSet) node.getParent();
parent.tmxMaps.remove(node);
} else if (node instanceof WriterModeData) {
WriterModeDataSet parent = (WriterModeDataSet) node.getParent();
parent.writerModeDataList.remove(node);
}
}
}.start();
@@ -314,6 +324,52 @@ public class WorkspaceActions {
};
};
public ATCSAction testWriter = new ATCSAction("Create dialogue sketch", "Create a dialogue sketch for fast dialogue edition"){
public void actionPerformed(ActionEvent e) {
if (selectedNode == null || selectedNode.getProject() == null) return;
new WriterSketchCreationWizard(selectedNode.getProject()).setVisible(true);
//
//
// if (selectedNode == null || selectedNode.getProject() == null) return;
// WriterModeData data = new WriterModeData(selectedNode.getProject().createdContent.writerModeDataSet, "test_");
// JFrame frame = new JFrame("Writer Mode tests");
// frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// frame.getContentPane().setLayout(new BorderLayout());
// frame.getContentPane().add(new WriterModeEditor(data), BorderLayout.CENTER);
// frame.setMinimumSize(new Dimension(250, 200));
// frame.pack();
// frame.setVisible(true);
};
public void selectionChanged(ProjectTreeNode selectedNode, TreePath[] selectedPaths) {
setEnabled(selectedNode != null && selectedNode.getProject() != null);
}
};
/*public ATCSAction testCommitWriter = new ATCSAction("Export dialogue sketch", "Exports the dialogue sketch as real JSON data dialogues") {
public void actionPerformed(ActionEvent e) {
if (selectedNode == null || selectedNode.getProject() == null || !(selectedNode instanceof WriterModeData)) return;
WriterModeData wData = (WriterModeData)selectedNode;
Collection<Dialogue> exported = wData.toDialogue();
selectedNode.getProject().createElements(new ArrayList<JSONElement>(exported));
wData.begin.dialogue.save();
wData.save();
};
public void selectionChanged(ProjectTreeNode selectedNode, TreePath[] selectedPaths) {
setEnabled(selectedNode != null && selectedNode instanceof WriterModeData);
}
};*/
public ATCSAction createWriter = new ATCSAction("Generate dialogue sketch", "Generates a dialogue sketch from this dialogue and its tree.") {
public void actionPerformed(ActionEvent e) {
if (selectedNode == null || selectedNode.getProject() == null || !(selectedNode instanceof Dialogue)) return;
new WriterSketchCreationWizard(selectedNode.getProject(), (Dialogue)selectedNode).setVisible(true);
};
public void selectionChanged(ProjectTreeNode selectedNode, TreePath[] selectedPaths) {
setEnabled(selectedNode != null && selectedNode instanceof Dialogue);
}
};
List<ATCSAction> actions = new ArrayList<WorkspaceActions.ATCSAction>();
public WorkspaceActions() {
@@ -331,6 +387,9 @@ public class WorkspaceActions {
actions.add(exportProject);
actions.add(showAbout);
actions.add(exitATCS);
actions.add(testWriter);
// actions.add(testCommitWriter);
actions.add(createWriter);
selectionChanged(null, null);
}
@@ -362,7 +421,7 @@ public class WorkspaceActions {
@Override
public void actionPerformed(ActionEvent e) {};
public Map<String, Object> values = new HashMap<String, Object>();
public Map<String, Object> values = new LinkedHashMap<String, Object>();
@Override
public Object getValue(String key) {

View File

@@ -36,7 +36,7 @@ public class WorkspaceSelector extends JFrame {
final List<String> wsPaths = new ArrayList<String>();
//Active widgets declaration
final JComboBox combo = new JComboBox();
final JComboBox<String> combo = new JComboBox<String>();
final JButton browse = new JButton("Browse...");
final JButton cancel = new JButton("Cancel");
final JButton ok = new JButton("Ok");

View File

@@ -0,0 +1,144 @@
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 javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import com.gpl.rpg.atcontentstudio.ATContentStudio;
import com.gpl.rpg.atcontentstudio.model.GameDataElement.State;
import com.gpl.rpg.atcontentstudio.model.Project;
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
import com.gpl.rpg.atcontentstudio.model.tools.writermode.WriterModeData;
import com.jidesoft.swing.JideBoxLayout;
public class WriterSketchCreationWizard extends JDialog {
private static final long serialVersionUID = 175788847797352548L;
private WriterModeData creation = null;
final JLabel message;
final JTextField idField;
final JButton ok;
final Project proj;
public WriterSketchCreationWizard(Project proj) {
this(proj, null);
}
public WriterSketchCreationWizard(Project proj, final Dialogue dialogue) {
super(ATContentStudio.frame);
this.proj = proj;
JPanel pane = new JPanel();
pane.setLayout(new JideBoxLayout(pane, JideBoxLayout.PAGE_AXIS, 6));
pane.add(new JLabel("Create a new game data element."), JideBoxLayout.FIX);
message = new JLabel("Select a data type below:");
pane.add(message, JideBoxLayout.FIX);
final JPanel idPane = new JPanel();
idPane.setLayout(new BorderLayout());
JLabel idLabel = new JLabel("Dialogue ID prefix: ");
idPane.add(idLabel, BorderLayout.WEST);
idField = new JTextField("");
idField.setEditable(true);
idPane.add(idField, BorderLayout.CENTER);
pane.add(idPane, JideBoxLayout.FIX);
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS, 6));
buttonPane.add(new JPanel(), JideBoxLayout.VARY);
JButton cancel = new JButton("Cancel");
buttonPane.add(cancel, JideBoxLayout.FIX);
ok = new JButton("Ok");
buttonPane.add(ok, JideBoxLayout.FIX);
pane.add(new JPanel(), JideBoxLayout.VARY);
pane.add(buttonPane, JideBoxLayout.FIX);
ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
WriterSketchCreationWizard.this.setVisible(false);
WriterSketchCreationWizard.this.dispose();
if (dialogue == null) {
creation = new WriterModeData(idField.getText());
creation.state = State.created;
} else {
creation = new WriterModeData(idField.getText(), dialogue);
}
WriterSketchCreationWizard.this.proj.createWriterSketch(creation);
// notifyCreated();
ATContentStudio.frame.selectInTree(creation);
ATContentStudio.frame.openEditor(creation);
}
});
cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
creation = null;
WriterSketchCreationWizard.this.setVisible(false);
WriterSketchCreationWizard.this.dispose();
}
});
DocumentListener statusUpdater = new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
updateStatus();
}
@Override
public void insertUpdate(DocumentEvent e) {
updateStatus();
}
@Override
public void changedUpdate(DocumentEvent e) {
updateStatus();
}
};
idField.getDocument().addDocumentListener(statusUpdater);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(pane, BorderLayout.CENTER);
setMinimumSize(new Dimension(350,250));
updateStatus();
pack();
Dimension sdim = Toolkit.getDefaultToolkit().getScreenSize();
Dimension wdim = getSize();
setLocation((sdim.width - wdim.width)/2, (sdim.height - wdim.height)/2);
}
public void updateStatus() {
boolean trouble = false;
message.setText("<html><font color=\"#00AA00\">Looks OK to me.</font></html>");
if (idField.getText() == null || idField.getText().length() <= 0) {
message.setText("<html><font color=\"#FF0000\">Internal ID must not be empty.</font></html>");
trouble = true;
} else if (proj.getWriterSketch(idField.getText()) != null) {
message.setText("<html><font color=\"#FF0000\">An item with the same ID was already created in this project.</font></html>");
trouble = true;
}
ok.setEnabled(!trouble);
message.revalidate();
message.repaint();
}
}

View File

@@ -30,6 +30,7 @@ public class ActorConditionEditor extends JSONElementEditor {
private JButton acIcon;
private JTextField idField;
private JTextField nameField;
@SuppressWarnings("rawtypes")
private JComboBox categoryBox;
private IntegerBasedCheckBox positiveBox;
private IntegerBasedCheckBox stackingBox;

View File

@@ -84,7 +84,9 @@ public class DialogueEditor extends JSONElementEditor {
private MyComboBox switchToNpcBox;
private RewardsListModel rewardsListModel;
@SuppressWarnings("rawtypes")
private JList rewardsList;
@SuppressWarnings("rawtypes")
private JComboBox rewardTypeCombo;
private JPanel rewardsParamsPane;
private MyComboBox rewardMap;
@@ -93,15 +95,19 @@ public class DialogueEditor extends JSONElementEditor {
private JSpinner rewardValue;
private RepliesListModel repliesListModel;
@SuppressWarnings("rawtypes")
private JList repliesList;
private JPanel repliesParamsPane;
@SuppressWarnings("rawtypes")
private JComboBox replyTypeCombo;
private MyComboBox replyNextPhrase;
private String replyTextCache = null;
private JTextField replyText;
private ReplyRequirementsListModel requirementsListModel;
@SuppressWarnings("rawtypes")
private JList requirementsList;
@SuppressWarnings("rawtypes")
private JComboBox requirementTypeCombo;
private JPanel requirementParamsPane;
private MyComboBox requirementObj;
@@ -109,17 +115,46 @@ public class DialogueEditor extends JSONElementEditor {
private JSpinner requirementValue;
private BooleanBasedCheckBox requirementNegated;
private DialogueGraphView dialogueGraphView;
public DialogueEditor(Dialogue dialogue) {
super(dialogue, dialogue.getDesc(), dialogue.getIcon());
addEditorTab(form_view_id, getFormView());
addEditorTab(json_view_id, getJSONView());
JPanel pane = new JPanel();
pane.setLayout(new BorderLayout());
pane.add(new JScrollPane(new DialogueGraphView(dialogue, null)), BorderLayout.CENTER);
addEditorTab(graph_view_id, pane);
addEditorTab(graph_view_id, createDialogueGraphView(dialogue));
}
public JPanel createDialogueGraphView(final Dialogue dialogue) {
final JPanel pane = new JPanel();
pane.setLayout(new BorderLayout());
dialogueGraphView = new DialogueGraphView(dialogue, null);
pane.add(dialogueGraphView, BorderLayout.CENTER);
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS));
JButton reloadButton = new JButton("Refresh graph");
buttonPane.add(reloadButton, JideBoxLayout.FIX);
buttonPane.add(new JPanel(), JideBoxLayout.VARY);
pane.add(buttonPane, BorderLayout.NORTH);
reloadButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
pane.remove(dialogueGraphView);
dialogueGraphView = new DialogueGraphView(dialogue, null);
pane.add(dialogueGraphView, BorderLayout.CENTER);
pane.revalidate();
pane.repaint();
}
});
return pane;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public void insertFormViewDataField(final JPanel pane) {
final Dialogue dialogue = (Dialogue) target;
@@ -385,6 +420,7 @@ public class DialogueEditor extends JSONElementEditor {
pane.repaint();
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public void updateRepliesEditorPane(final JPanel pane, final Dialogue.Reply reply, final FieldUpdateListener listener) {
pane.removeAll();
if (replyNextPhrase != null) {
@@ -651,7 +687,7 @@ public class DialogueEditor extends JSONElementEditor {
}
public static class RewardsListModel implements ListModel {
public static class RewardsListModel implements ListModel<Dialogue.Reward> {
Dialogue source;
@@ -666,7 +702,7 @@ public class DialogueEditor extends JSONElementEditor {
}
@Override
public Object getElementAt(int index) {
public Dialogue.Reward getElementAt(int index) {
if (source.rewards == null) return null;
return source.rewards.get(index);
}
@@ -717,7 +753,7 @@ public class DialogueEditor extends JSONElementEditor {
private static final long serialVersionUID = 7987880146189575234L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
JLabel label = ((JLabel)c);
@@ -790,7 +826,7 @@ public class DialogueEditor extends JSONElementEditor {
}
public static class RepliesListModel implements ListModel {
public static class RepliesListModel implements ListModel<Dialogue.Reply> {
Dialogue source;
@@ -806,7 +842,7 @@ public class DialogueEditor extends JSONElementEditor {
}
@Override
public Object getElementAt(int index) {
public Dialogue.Reply getElementAt(int index) {
if (source.replies == null) return null;
return source.replies.get(index);
}
@@ -878,7 +914,7 @@ public class DialogueEditor extends JSONElementEditor {
private static final long serialVersionUID = 7987880146189575234L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
JLabel label = ((JLabel)c);
@@ -924,7 +960,7 @@ public class DialogueEditor extends JSONElementEditor {
}
}
public static class ReplyRequirementsListModel implements ListModel {
public static class ReplyRequirementsListModel implements ListModel<Requirement> {
Dialogue.Reply reply;
@@ -939,7 +975,7 @@ public class DialogueEditor extends JSONElementEditor {
}
@Override
public Object getElementAt(int index) {
public Requirement getElementAt(int index) {
if (reply.requirements == null) return null;
return reply.requirements.get(index);
}
@@ -993,7 +1029,7 @@ public class DialogueEditor extends JSONElementEditor {
private static final long serialVersionUID = 7987880146189575234L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
decorateRequirementJLabel((JLabel)c, (Requirement)value);

View File

@@ -57,6 +57,7 @@ public class DroplistEditor extends JSONElementEditor {
addEditorTab(json_view_id, getJSONView());
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void insertFormViewDataField(JPanel pane) {
@@ -146,7 +147,7 @@ public class DroplistEditor extends JSONElementEditor {
pane.repaint();
}
public class DroppedItemsListModel implements ListModel {
public class DroppedItemsListModel implements ListModel<Droplist.DroppedItem> {
Droplist source;
@@ -161,7 +162,7 @@ public class DroplistEditor extends JSONElementEditor {
}
@Override
public Object getElementAt(int index) {
public Droplist.DroppedItem getElementAt(int index) {
if (source.dropped_items == null) return null;
return source.dropped_items.get(index);
}
@@ -212,7 +213,7 @@ public class DroplistEditor extends JSONElementEditor {
private static final long serialVersionUID = 7987880146189575234L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
JLabel label = ((JLabel)c);

View File

@@ -35,10 +35,14 @@ public class ItemCategoryEditor extends JSONElementEditor {
private JButton icIcon;
private JTextField idField;
private JTextField nameField;
@SuppressWarnings("rawtypes")
private JComboBox slotBox;
@SuppressWarnings("rawtypes")
private JComboBox typeBox;
@SuppressWarnings("rawtypes")
private JComboBox sizeBox;
@SuppressWarnings("unchecked")
@Override
public void insertFormViewDataField(JPanel pane) {
final ItemCategory ic = ((ItemCategory)target);
@@ -62,7 +66,7 @@ public class ItemCategoryEditor extends JSONElementEditor {
private static final long serialVersionUID = -8359181274986492979L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
((JLabel)c).setIcon(new ImageIcon(ItemCategory.getIcon((ItemCategory.InventorySlot) value)));

View File

@@ -59,6 +59,7 @@ public class ItemEditor extends JSONElementEditor {
private JTextField idField;
private JTextField nameField;
private JTextField descriptionField;
@SuppressWarnings("rawtypes")
private JComboBox typeBox;
private IntegerBasedCheckBox manualPriceBox;
private JSpinner baseCostField;
@@ -81,6 +82,7 @@ public class ItemEditor extends JSONElementEditor {
private JSpinner equipIncReequipCost;
private JSpinner equipIncAttackCost;
private ConditionsListModel equipConditionsModel;
@SuppressWarnings("rawtypes")
private JList equipConditionsList;
private MyComboBox equipConditionBox;
private JSpinner equipConditionMagnitude;
@@ -92,12 +94,14 @@ public class ItemEditor extends JSONElementEditor {
private JSpinner hitAPMin;
private JSpinner hitAPMax;
private SourceTimedConditionsListModel hitSourceConditionsModel;
@SuppressWarnings("rawtypes")
private JList hitSourceConditionsList;
private MyComboBox hitSourceConditionBox;
private JSpinner hitSourceConditionMagnitude;
private JSpinner hitSourceConditionDuration;
private JSpinner hitSourceConditionChance;
private TargetTimedConditionsListModel hitTargetConditionsModel;
@SuppressWarnings("rawtypes")
private JList hitTargetConditionsList;
private MyComboBox hitTargetConditionBox;
private JSpinner hitTargetConditionMagnitude;
@@ -111,6 +115,7 @@ public class ItemEditor extends JSONElementEditor {
private JSpinner killAPMin;
private JSpinner killAPMax;
private SourceTimedConditionsListModel killSourceConditionsModel;
@SuppressWarnings("rawtypes")
private JList killSourceConditionsList;
private MyComboBox killSourceConditionBox;
private JSpinner killSourceConditionMagnitude;
@@ -124,6 +129,7 @@ public class ItemEditor extends JSONElementEditor {
addEditorTab(json_view_id, getJSONView());
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void insertFormViewDataField(JPanel pane) {
@@ -523,7 +529,7 @@ public class ItemEditor extends JSONElementEditor {
pane.repaint();
}
public static class SourceTimedConditionsListModel implements ListModel {
public static class SourceTimedConditionsListModel implements ListModel<Item.TimedConditionEffect> {
Item.KillEffect source;
@@ -538,7 +544,7 @@ public class ItemEditor extends JSONElementEditor {
}
@Override
public Object getElementAt(int index) {
public Item.TimedConditionEffect getElementAt(int index) {
if (source.conditions_source == null) return null;
return source.conditions_source.get(index);
}
@@ -585,7 +591,7 @@ public class ItemEditor extends JSONElementEditor {
}
}
public static class TargetTimedConditionsListModel implements ListModel {
public static class TargetTimedConditionsListModel implements ListModel<Item.TimedConditionEffect> {
Item.HitEffect source;
@@ -600,7 +606,7 @@ public class ItemEditor extends JSONElementEditor {
}
@Override
public Object getElementAt(int index) {
public Item.TimedConditionEffect getElementAt(int index) {
if (source.conditions_target == null) return null;
return source.conditions_target.get(index);
}
@@ -651,7 +657,7 @@ public class ItemEditor extends JSONElementEditor {
private static final long serialVersionUID = 7987880146189575234L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
JLabel label = ((JLabel)c);
@@ -668,7 +674,7 @@ public class ItemEditor extends JSONElementEditor {
}
}
public static class ConditionsListModel implements ListModel {
public static class ConditionsListModel implements ListModel<Item.ConditionEffect> {
Item.EquipEffect source;
@@ -683,7 +689,7 @@ public class ItemEditor extends JSONElementEditor {
}
@Override
public Object getElementAt(int index) {
public Item.ConditionEffect getElementAt(int index) {
if (source.conditions == null) return null;
return source.conditions.get(index);
}
@@ -734,7 +740,7 @@ public class ItemEditor extends JSONElementEditor {
private static final long serialVersionUID = 7987880146189575234L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
JLabel label = ((JLabel)c);

View File

@@ -5,7 +5,7 @@ import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -40,7 +40,7 @@ public abstract class JSONElementEditor extends Editor {
private static final long serialVersionUID = -5889046987755079563L;
Map<String, JPanel> editorTabs = new HashMap<String, JPanel>();
Map<String, JPanel> editorTabs = new LinkedHashMap<String, JPanel>();
JideTabbedPane editorTabsHolder;
RSyntaxTextArea jsonEditorPane;
@@ -65,6 +65,15 @@ public abstract class JSONElementEditor extends Editor {
editorTabs.put(id, editor);
}
public void removeEditorTab(String id) {
if (id == null) return;
for (int i =0; i <editorTabsHolder.getTabCount(); i++) {
if (id.equals(editorTabsHolder.getTitleAt(i))) {
editorTabsHolder.removeTabAt(i);
editorTabs.remove(id);
}
}
}
public JPanel getJSONView() {
jsonEditorPane = new RSyntaxTextArea();
jsonEditorPane.setText(((JSONElement)target).toJsonString());

View File

@@ -47,6 +47,7 @@ public class NPCEditor extends JSONElementEditor {
private static final String form_view_id = "Form";
private static final String json_view_id = "JSON";
private static final String dialogue_tree_id = "Dialogue Tree";
private NPC.TimedConditionEffect selectedHitEffectSourceCondition;
private NPC.TimedConditionEffect selectedHitEffectTargetCondition;
@@ -58,8 +59,10 @@ public class NPCEditor extends JSONElementEditor {
private JSpinner experienceField;
private MyComboBox dialogueBox;
private MyComboBox droplistBox;
@SuppressWarnings("rawtypes")
private JComboBox monsterClassBox;
private IntegerBasedCheckBox uniqueBox;
@SuppressWarnings("rawtypes")
private JComboBox moveTypeBox;
private CollapsiblePanel combatTraitPane;
@@ -83,6 +86,7 @@ public class NPCEditor extends JSONElementEditor {
private JSpinner hitEffectAPMax;
private SourceTimedConditionsListModel hitSourceConditionsListModel;
@SuppressWarnings("rawtypes")
private JList hitSourceConditionsList;
private MyComboBox sourceConditionBox;
private JSpinner sourceConditionMagnitude;
@@ -90,24 +94,73 @@ public class NPCEditor extends JSONElementEditor {
private JSpinner sourceConditionChance;
private TargetTimedConditionsListModel hitTargetConditionsListModel;
@SuppressWarnings("rawtypes")
private JList hitTargetConditionsList;
private MyComboBox targetConditionBox;
private JSpinner targetConditionMagnitude;
private JSpinner targetConditionDuration;
private JSpinner targetConditionChance;
private JPanel dialogueGraphPane;
private DialogueGraphView dialogueGraphView;
public NPCEditor(NPC npc) {
super(npc, npc.getDesc(), npc.getIcon());
addEditorTab(form_view_id, getFormView());
addEditorTab(json_view_id, getJSONView());
if (npc.dialogue != null) {
JPanel pane = new JPanel();
pane.setLayout(new BorderLayout());
pane.add(new JScrollPane(new DialogueGraphView(npc.dialogue, npc)), BorderLayout.CENTER);
addEditorTab("Dialogue Tree", pane);
createDialogueGraphView(npc);
addEditorTab(dialogue_tree_id, dialogueGraphPane);
}
}
public JPanel createDialogueGraphView(final NPC npc) {
dialogueGraphPane = new JPanel();
dialogueGraphPane.setLayout(new BorderLayout());
dialogueGraphView = new DialogueGraphView(npc.dialogue, npc);
dialogueGraphPane.add(dialogueGraphView, BorderLayout.CENTER);
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS));
JButton reloadButton = new JButton("Refresh graph");
buttonPane.add(reloadButton, JideBoxLayout.FIX);
buttonPane.add(new JPanel(), JideBoxLayout.VARY);
dialogueGraphPane.add(buttonPane, BorderLayout.NORTH);
reloadButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
reloadGraphView(npc);
}
});
return dialogueGraphPane;
}
public void reloadGraphView(NPC npc) {
if (npc.dialogue != null) {
if (dialogueGraphPane != null) {
dialogueGraphPane.remove(dialogueGraphView);
dialogueGraphView = new DialogueGraphView(npc.dialogue, npc);
dialogueGraphPane.add(dialogueGraphView, BorderLayout.CENTER);
dialogueGraphPane.revalidate();
dialogueGraphPane.repaint();
} else {
createDialogueGraphView(npc);
addEditorTab(dialogue_tree_id, dialogueGraphPane);
}
} else {
if (dialogueGraphPane != null) {
removeEditorTab(dialogue_tree_id);
dialogueGraphPane = null;
dialogueGraphView = null;
}
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void insertFormViewDataField(JPanel pane) {
final NPC npc = (NPC) target;
@@ -295,7 +348,7 @@ public class NPCEditor extends JSONElementEditor {
pane.repaint();
}
public static class TargetTimedConditionsListModel implements ListModel {
public static class TargetTimedConditionsListModel implements ListModel<NPC.TimedConditionEffect> {
NPC.HitEffect source;
@@ -310,7 +363,7 @@ public class NPCEditor extends JSONElementEditor {
}
@Override
public Object getElementAt(int index) {
public NPC.TimedConditionEffect getElementAt(int index) {
if (source.conditions_target == null) return null;
return source.conditions_target.get(index);
}
@@ -357,7 +410,7 @@ public class NPCEditor extends JSONElementEditor {
}
}
public static class SourceTimedConditionsListModel implements ListModel {
public static class SourceTimedConditionsListModel implements ListModel<NPC.TimedConditionEffect> {
NPC.HitEffect source;
@@ -372,7 +425,7 @@ public class NPCEditor extends JSONElementEditor {
}
@Override
public Object getElementAt(int index) {
public NPC.TimedConditionEffect getElementAt(int index) {
if (source.conditions_source == null) return null;
return source.conditions_source.get(index);
}
@@ -423,7 +476,7 @@ public class NPCEditor extends JSONElementEditor {
private static final long serialVersionUID = 7987880146189575234L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
JLabel label = ((JLabel)c);
@@ -487,6 +540,7 @@ public class NPCEditor extends JSONElementEditor {
} else {
npc.dialogue_id = null;
}
reloadGraphView(npc);
} else if (source == droplistBox) {
if (npc.droplist != null) {
npc.droplist.removeBacklink(npc);

View File

@@ -17,7 +17,6 @@ import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
@@ -25,8 +24,6 @@ import javax.swing.event.TableModelListener;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
import org.fife.ui.rtextarea.ColorBackgroundPainterStrategy;
import com.gpl.rpg.atcontentstudio.ATContentStudio;
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
@@ -70,8 +67,8 @@ public class QuestEditor extends JSONElementEditor {
createButtonPane(pane, quest.getProject(), quest, Quest.class, quest.getImage(), null, listener);
addTextField(pane, "Internal ID: ", quest.id, quest.writable, listener);
addTextField(pane, "Quest Name: ", quest.name, quest.writable, listener);
idField = addTextField(pane, "Internal ID: ", quest.id, quest.writable, listener);
nameField = addTextField(pane, "Quest Name: ", quest.name, quest.writable, listener);
visibleBox = addIntegerBasedCheckBox(pane, "Visible in quest log", quest.visible_in_log, quest.writable, listener);
JPanel stagesPane = new JPanel();

View File

@@ -2,8 +2,6 @@ package com.gpl.rpg.atcontentstudio.ui.gamedataeditors.dialoguetree;
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Point;
import java.awt.event.MouseEvent;
@@ -55,7 +53,6 @@ import com.gpl.rpg.atcontentstudio.model.gamedata.NPC;
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement;
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.DialogueEditor;
import com.gpl.rpg.atcontentstudio.ui.map.TMXMapEditor.TMXReplacementViewer;
import com.jidesoft.swing.JideBoxLayout;
public class DialogueGraphView extends Display {
@@ -66,7 +63,6 @@ public class DialogueGraphView extends Display {
public static final String NODES = "graph.nodes";
public static final String EDGES = "graph.edges";
public static final String EDGES_LABELS = "edgesLabels";
public static final String AGGR = "aggregates";
public static final String LABEL = "label";
public static final String ICON = "icon";

View File

@@ -18,11 +18,8 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImageOp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -109,14 +106,16 @@ public class TMXMapEditor extends Editor {
private static final long serialVersionUID = -3079451876618342442L;
Map<String, JPanel> editorTabs = new HashMap<String, JPanel>();
Map<String, JPanel> editorTabs = new LinkedHashMap<String, JPanel>();
JideTabbedPane editorTabsHolder;
private RSyntaxTextArea editorPane;
private IntegerBasedCheckBox outsideBox;
@SuppressWarnings("rawtypes")
private JComboBox colorFilterBox;
private LayerListModel layerListModel;
@SuppressWarnings("rawtypes")
private JList layerList;
private tiled.core.MapLayer selectedLayer;
private JButton addTileLayer;
@@ -125,9 +124,10 @@ public class TMXMapEditor extends Editor {
private JPanel layerDetailsPane;
private BooleanBasedCheckBox layerVisibleBox;
private BooleanBasedCheckBox activeLayerBox;
//private BooleanBasedCheckBox activeLayerBox;
private JTextField layerNameField;
private MapObjectsListModel groupObjectsListModel;
@SuppressWarnings("rawtypes")
private JList groupObjectsList;
private MapObject selectedMapObject;
private JButton addMapchange;
@@ -141,32 +141,43 @@ public class TMXMapEditor extends Editor {
private JButton deleteObject;
private JPanel mapObjectSettingsPane;
@SuppressWarnings("rawtypes")
private JComboBox droplistBox;
@SuppressWarnings("rawtypes")
private JComboBox dialogueBox;
@SuppressWarnings("rawtypes")
private JComboBox mapBox;
private JTextField areaField;
@SuppressWarnings("rawtypes")
private JComboBox targetAreaCombo;
@SuppressWarnings("rawtypes")
private JComboBox evaluateTriggerBox;
private JSpinner quantityField;
private JCheckBox activeForNewGame;
private JTextField spawngroupField;
@SuppressWarnings("rawtypes")
private JList npcList;
private SpawnGroupNpcListModel npcListModel;
@SuppressWarnings("rawtypes")
private JComboBox requirementTypeCombo;
private JPanel requirementParamsPane;
@SuppressWarnings("rawtypes")
private JComboBox requirementObj;
private JTextField requirementObjId;
private JSpinner requirementValue;
private BooleanBasedCheckBox requirementNegated;
@SuppressWarnings("rawtypes")
private JList replacementsList;
private ReplacementsListModel replacementsListModel;
private ReplaceArea.Replacement selectedReplacement;
private JButton addReplacement;
private JButton deleteReplacement;
private JPanel replacementEditPane;
@SuppressWarnings("rawtypes")
private JComboBox sourceLayer;
@SuppressWarnings("rawtypes")
private JComboBox targetLayer;
private TMXViewer tmxViewer;
@@ -196,6 +207,7 @@ public class TMXMapEditor extends Editor {
@SuppressWarnings({ "unchecked", "rawtypes" })
public JPanel getTmxEditorPane() {
final TMXMap map = (TMXMap) target;
final FieldUpdateListener listener = new MapFieldUpdater();
@@ -288,6 +300,7 @@ public class TMXMapEditor extends Editor {
return pane;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public void updateLayerDetailsPane(JPanel pane, tiled.core.MapLayer selected, final FieldUpdateListener listener) {
final TMXMap map = (TMXMap)target;
pane.removeAll();
@@ -445,6 +458,7 @@ public class TMXMapEditor extends Editor {
pane.repaint();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public void updateMapObjectSettingsPane(JPanel pane, final MapObject selected, final FieldUpdateListener listener) {
pane.removeAll();
boolean needVary = true;
@@ -871,7 +885,7 @@ public class TMXMapEditor extends Editor {
return index;
}
List<TreeModelListener> listeners = new LinkedList<TreeModelListener>();
List<TreeModelListener> listeners = new ArrayList<TreeModelListener>();
@Override
public void addTreeModelListener(TreeModelListener l) {
@@ -909,6 +923,7 @@ public class TMXMapEditor extends Editor {
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static JList addTMXMapSpritesheetsList(JPanel pane, TMXMap tmxMap) {
final JList list = new JList(new TMXMapSpritesheetsListModel(tmxMap));
list.addMouseListener(new MouseAdapter() {
@@ -936,6 +951,7 @@ public class TMXMapEditor extends Editor {
return list;
}
@SuppressWarnings("rawtypes")
public class LayerListModel implements ListModel {
public TMXMap map;
@@ -996,7 +1012,7 @@ public class TMXMapEditor extends Editor {
public class LayerListRenderer extends DefaultListCellRenderer {
private static final long serialVersionUID = -6182599528961565957L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
JLabel label = (JLabel)c;
@@ -1012,7 +1028,7 @@ public class TMXMapEditor extends Editor {
}
}
public class ReplacementsListModel implements ListModel {
public class ReplacementsListModel implements ListModel<ReplaceArea.Replacement> {
public ReplaceArea area;
@@ -1027,7 +1043,7 @@ public class TMXMapEditor extends Editor {
}
@Override
public Object getElementAt(int index) {
public ReplaceArea.Replacement getElementAt(int index) {
if (index < 0 || index > getSize()) return null;
if (area.replacements == null) return null;
return area.replacements.get(index);
@@ -1078,7 +1094,7 @@ public class TMXMapEditor extends Editor {
this.area = area;
}
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
JLabel label = (JLabel)c;
@@ -1093,7 +1109,7 @@ public class TMXMapEditor extends Editor {
ReplaceArea area;
boolean modelForSource = false;
public List<String> availableLayers = new LinkedList<String>();
public List<String> availableLayers = new ArrayList<String>();
public String selected;
@@ -1145,7 +1161,7 @@ public class TMXMapEditor extends Editor {
}
}
public class MapObjectsListModel implements ListModel {
public class MapObjectsListModel implements ListModel<MapObject> {
public MapObjectGroup group;
@@ -1159,7 +1175,7 @@ public class TMXMapEditor extends Editor {
}
@Override
public Object getElementAt(int index) {
public MapObject getElementAt(int index) {
return group.mapObjects.get(index);
}
@@ -1202,7 +1218,7 @@ public class TMXMapEditor extends Editor {
public class GroupObjectsRenderer extends DefaultListCellRenderer {
private static final long serialVersionUID = -6182599528961565957L;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
((JLabel)c).setText(((MapObject)value).name);
@@ -1212,7 +1228,7 @@ public class TMXMapEditor extends Editor {
}
}
public class SpawnGroupNpcListModel implements ListModel {
public class SpawnGroupNpcListModel implements ListModel<NPC> {
public SpawnArea area;
@@ -1226,7 +1242,7 @@ public class TMXMapEditor extends Editor {
}
@Override
public Object getElementAt(int index) {
public NPC getElementAt(int index) {
return area.spawnGroup.get(index);
}
@@ -1244,42 +1260,6 @@ public class TMXMapEditor extends Editor {
}
private static final BufferedImageOp colorFilterBlack20 = null;
private static final BufferedImageOp colorFilterBlack40 = null;
private static final BufferedImageOp colorFilterBlack60 = null;
private static final BufferedImageOp colorFilterBlack80 = null;
private static final BufferedImageOp colorFilterInvert = null;
private static final BufferedImageOp colorFilterBW = null;
// private static final BufferedImageOp colorFilterBlack20 = createGrayScaleColorFilter(0.8f);
// private static final BufferedImageOp colorFilterBlack40 = createGrayScaleColorFilter(0.6f);
// private static final BufferedImageOp colorFilterBlack60 = createGrayScaleColorFilter(0.4f);
// private static final BufferedImageOp colorFilterBlack80 = createGrayScaleColorFilter(0.2f);
// private static final BufferedImageOp colorFilterInvert = createInvertColorFilter();
// private static final BufferedImageOp colorFilterBW = createBWColorFilter();
//
// private static BufferedImageOp createGrayScaleColorFilter(float f) {
// byte[] gs = new byte[256];
// for (int i=0; i < 256; i++) {
// gs[i] = (byte)( i * f);
// }
// return new LookupOp(new ByteLookupTable(0, gs), null);
// }
//
// private static BufferedImageOp createInvertColorFilter() {
// byte[] invert = new byte[256];
// for (int i=0; i < 256; i++) {
// invert[i] = (byte) (255 - i);
// }
// return new LookupOp(new ByteLookupTable(0, invert), null);
// }
//
//
// private static BufferedImageOp createBWColorFilter() {
// return new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
// }
public class TMXViewer extends JPanel implements Scrollable {
@@ -1526,7 +1506,7 @@ public class TMXMapEditor extends Editor {
}
public static class TMXMapSpritesheetsListModel implements ListModel {
public static class TMXMapSpritesheetsListModel implements ListModel<Spritesheet> {
TMXMap map;
@@ -1540,7 +1520,7 @@ public class TMXMapEditor extends Editor {
}
@Override
public Object getElementAt(int index) {
public Spritesheet getElementAt(int index) {
for (Spritesheet sheet : map.usedSpritesheets) {
if (index == 0) return sheet;
index --;
@@ -1580,7 +1560,7 @@ public class TMXMapEditor extends Editor {
}
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value == null) {
label.setText("none");
@@ -1725,6 +1705,7 @@ public class TMXMapEditor extends Editor {
public class MapFieldUpdater implements FieldUpdateListener {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void valueChanged(JComponent source, Object value) {
TMXMap map = (TMXMap) target;
@@ -2057,7 +2038,7 @@ public class TMXMapEditor extends Editor {
}
for (ReplaceArea.Replacement repl : area.replacements) {
if (replacementsForLayer.get(repl.sourceLayer) == null) {
replacementsForLayer.put(repl.sourceLayer, new LinkedList<ReplaceArea>());
replacementsForLayer.put(repl.sourceLayer, new ArrayList<ReplaceArea>());
}
replacementsForLayer.get(repl.sourceLayer).add(area);
}

View File

@@ -10,7 +10,6 @@ import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.swing.ButtonGroup;
@@ -107,6 +106,7 @@ public class WorldMapEditor extends Editor {
}
@SuppressWarnings("unchecked")
private JPanel buildSegmentTab(final WorldmapSegment worldmap) {
JPanel pane = new JPanel();
pane.setLayout(new JideBoxLayout(pane, JideBoxLayout.PAGE_AXIS));
@@ -151,7 +151,7 @@ public class WorldMapEditor extends Editor {
final GDEComboModel<TMXMap> mapComboModel = new GDEComboModel<TMXMap>(worldmap.getProject(), null){
private static final long serialVersionUID = 2638082961277241764L;
@Override
public Object getTypedElementAt(int index) {
public TMXMap getTypedElementAt(int index) {
return project.getMap(index);
}
@Override
@@ -291,7 +291,7 @@ public class WorldMapEditor extends Editor {
if (map.labelledMaps.get(selectedLabel) != null) {
map.labelledMaps.get(selectedLabel).clear();
} else {
map.labelledMaps.put(selectedLabel, new LinkedList<String>());
map.labelledMaps.put(selectedLabel, new ArrayList<String>());
}
for (String s : mapView.selected) {
map.labelledMaps.get(selectedLabel).add(s);
@@ -346,7 +346,7 @@ public class WorldMapEditor extends Editor {
wiz.addCreationListener(new WorldmapLabelEditionWizard.CreationCompletedListener() {
@Override
public void labelCreated(NamedArea created) {
worldmap.labelledMaps.put(created.id, new LinkedList<String>());
worldmap.labelledMaps.put(created.id, new ArrayList<String>());
worldmap.labelledMaps.get(created.id).addAll(mapView.selected);
mapView.revalidate();
mapView.repaint();

View File

@@ -15,8 +15,8 @@ import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -45,7 +45,7 @@ public class WorldMapView extends JComponent implements Scrollable {
Project proj;
public Map<String, Rectangle> mapLocations = new HashMap<String, Rectangle>();
public Map<String, Rectangle> mapLocations = new LinkedHashMap<String, Rectangle>();
public Set<String> selected = new HashSet<String>();

View File

@@ -8,7 +8,7 @@ import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -34,11 +34,11 @@ public class SpriteChooser extends JDialog {
private static final int STD_HEIGHT = 32;
private static final int MAX_PER_ROW = 10;
public static Map<Project, Map<Spritesheet.Category, SpriteChooser>> cache = new HashMap<Project, Map<Spritesheet.Category,SpriteChooser>>();
public static Map<Project, Map<Spritesheet.Category, SpriteChooser>> cache = new LinkedHashMap<Project, Map<Spritesheet.Category,SpriteChooser>>();
public static SpriteChooser getChooser(Project proj, Spritesheet.Category category) {
if (cache.get(proj) == null) {
cache.put(proj, new HashMap<Spritesheet.Category, SpriteChooser>());
cache.put(proj, new LinkedHashMap<Spritesheet.Category, SpriteChooser>());
}
if (cache.get(proj).get(category) == null) {
cache.get(proj).put(category, new SpriteChooser(proj, category));

View File

@@ -10,7 +10,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -50,12 +50,13 @@ public class SpritesheetEditor extends Editor {
private static final long serialVersionUID = 3956109815682889863L;
Map<String, JPanel> editorTabs = new HashMap<String, JPanel>();
Map<String, JPanel> editorTabs = new LinkedHashMap<String, JPanel>();
JideTabbedPane editorTabsHolder;
private JSpinner widthField;
private JSpinner heightField;
private JCheckBox animatedBox;
@SuppressWarnings("rawtypes")
private JComboBox categoryBox;
private JPanel spriteViewPane;
@@ -160,6 +161,7 @@ public class SpritesheetEditor extends Editor {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static JList addBacklinksList(JPanel pane, Spritesheet sheet) {
final JList list = new JList(new SpritesheetsBacklinksListModel(sheet));
list.addMouseListener(new MouseAdapter() {
@@ -317,7 +319,7 @@ public class SpritesheetEditor extends Editor {
}
public static class SpritesheetsBacklinksListModel implements ListModel {
public static class SpritesheetsBacklinksListModel implements ListModel<ProjectTreeNode> {
Spritesheet sheet;
@@ -331,7 +333,7 @@ public class SpritesheetEditor extends Editor {
}
@Override
public Object getElementAt(int index) {
public ProjectTreeNode getElementAt(int index) {
for (ProjectTreeNode node : sheet.getBacklinks()) {
if (index == 0) return node;
index --;
@@ -371,7 +373,7 @@ public class SpritesheetEditor extends Editor {
}
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value == null) {
label.setText("none");

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,296 @@
package prefuse.data;
import java.util.BitSet;
import java.util.Iterator;
import java.util.LinkedList;
import prefuse.data.tuple.TupleManager;
import prefuse.visual.tuple.TableEdgeItem;
public class FilteredSpanningTree extends Tree {
/** Extra edge table data field recording the id of the source edge
* a tree edge represents. */
public static final String SOURCE_EDGE = "source";
/** Edge table schema used by the spanning tree. */
protected static final Schema EDGE_SCHEMA = new Schema();
static {
EDGE_SCHEMA.addColumn(DEFAULT_SOURCE_KEY, int.class, new Integer(-1));
EDGE_SCHEMA.addColumn(DEFAULT_TARGET_KEY, int.class, new Integer(-1));
EDGE_SCHEMA.addColumn(SOURCE_EDGE, int.class);
}
/** A reference to the backing graph that this tree spans. */
protected Graph m_backing;
/** The boolean field to check. If false, edge is filtered out. */
protected int m_filter;
/**
* Create a new SpanningTree.
* @param g the backing Graph to span
* @param root the Node to use as the root of the spanning tree
* @param filterField the Edge column to use to filter out non-tree edges (must be boolean);
*/
public FilteredSpanningTree(Graph g, Node root, String filterField) {
super(g.getNodeTable(), EDGE_SCHEMA.instantiate());
m_filter = g.getEdgeTable().getColumnNumber(filterField);
if (g.getEdgeTable().getColumn(m_filter) != null && !g.getEdgeTable().getColumn(m_filter).canGetBoolean()) {
throw new UnsupportedOperationException(
"The filter column must be boolean.");
}
m_backing = g;
TupleManager etm = new TupleManager(getEdgeTable(), null,
TableEdgeItem.class) {
public Tuple getTuple(int row) {
return m_backing.getEdge(m_table.getInt(row, SOURCE_EDGE));
}
};
getEdgeTable().setTupleManager(etm);
super.setTupleManagers(g.m_nodeTuples, etm);
buildSpanningTree(root);
}
/**
* Build the spanning tree, starting at the given root. Uses an
* unweighted breadth first traversal to build the spanning tree.
* @param root the root node of the spanning tree
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public void buildSpanningTree(Node root) {
// re-use a previously allocated tree if possible
super.clearEdges();
super.setRoot(root);
// build unweighted spanning tree by BFS
LinkedList q = new LinkedList();
BitSet visit = new BitSet();
q.add(root); visit.set(root.getRow());
Table edges = getEdgeTable();
while ( !q.isEmpty() ) {
Node p = (Node)q.removeFirst();
for ( Iterator iter = p.edges(); iter.hasNext(); ) {
Edge e = (Edge)iter.next();
if (e.getBoolean(m_filter)) {
Node n = e.getAdjacentNode(p);
if ( !visit.get(n.getRow()) ) {
q.add(n); visit.set(n.getRow());
int er = super.addChildEdge(p.getRow(), n.getRow());
edges.setInt(er, SOURCE_EDGE, e.getRow());
}
}
}
}
}
// ------------------------------------------------------------------------
// Disallow most mutator methods
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Tree#addChild(int)
*/
public int addChild(int parent) {
throw new UnsupportedOperationException(
"Changes to tree structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Tree#addChild(prefuse.data.Node)
*/
public Node addChild(Node parent) {
throw new UnsupportedOperationException(
"Changes to tree structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Tree#addChildEdge(int, int)
*/
public int addChildEdge(int parent, int child) {
throw new UnsupportedOperationException(
"Changes to tree structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Tree#addChildEdge(prefuse.data.Node, prefuse.data.Node)
*/
public Edge addChildEdge(Node parent, Node child) {
throw new UnsupportedOperationException(
"Changes to tree structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Tree#addRoot()
*/
public Node addRoot() {
throw new UnsupportedOperationException(
"Changes to tree structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Tree#addRootRow()
*/
public int addRootRow() {
throw new UnsupportedOperationException(
"Changes to tree structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Tree#removeChild(int)
*/
public boolean removeChild(int node) {
throw new UnsupportedOperationException(
"Changes to tree structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Tree#removeChild(prefuse.data.Node)
*/
public boolean removeChild(Node n) {
throw new UnsupportedOperationException(
"Changes to tree structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Tree#removeChildEdge(prefuse.data.Edge)
*/
public boolean removeChildEdge(Edge e) {
throw new UnsupportedOperationException(
"Changes to tree structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Tree#removeChildEdge(int)
*/
public boolean removeChildEdge(int edge) {
throw new UnsupportedOperationException(
"Changes to tree structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Tree#setRoot(prefuse.data.Node)
*/
void setRoot(Node root) {
throw new UnsupportedOperationException(
"Changes to tree structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Graph#addEdge(int, int)
*/
public int addEdge(int s, int t) {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Graph#addEdge(prefuse.data.Node, prefuse.data.Node)
*/
public Edge addEdge(Node s, Node t) {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Graph#addNode()
*/
public Node addNode() {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Graph#addNodeRow()
*/
public int addNodeRow() {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.tuple.TupleSet#clear()
*/
public void clear() {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Graph#removeEdge(prefuse.data.Edge)
*/
public boolean removeEdge(Edge e) {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Graph#removeEdge(int)
*/
public boolean removeEdge(int edge) {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Graph#removeNode(int)
*/
public boolean removeNode(int node) {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Graph#removeNode(prefuse.data.Node)
*/
public boolean removeNode(Node n) {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.tuple.TupleSet#removeTuple(prefuse.data.Tuple)
*/
public boolean removeTuple(Tuple t) {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Graph#setEdgeTable(prefuse.data.Table)
*/
public void setEdgeTable(Table edges) {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
/**
* Unsupported operation. Spanning trees should not be edited.
* @see prefuse.data.Graph#setTupleManagers(prefuse.data.tuple.TupleManager, prefuse.data.tuple.TupleManager)
*/
public void setTupleManagers(TupleManager ntm, TupleManager etm) {
throw new UnsupportedOperationException(
"Changes to graph structure not allowed for spanning trees.");
}
}