mirror of
https://github.com/AndorsTrailRelease/ATCS.git
synced 2025-10-27 18:44:03 +01:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
900d0bc9b5 | ||
|
|
6fe4d2a171 | ||
|
|
1076693322 | ||
|
|
5a9e66b7c9 | ||
|
|
b1d0175a9d | ||
|
|
6ac332834d | ||
|
|
32711449b2 | ||
|
|
c18ff9d2b4 | ||
|
|
ce908f0033 | ||
|
|
1a70f87897 | ||
|
|
c07fb4ddf3 | ||
|
|
1458fb0aaa | ||
|
|
57b8209b26 | ||
|
|
a7224755ff | ||
|
|
e97168c62e | ||
|
|
1e8dd405c3 | ||
|
|
830e9de56b |
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
package tiled.core;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ import java.util.Properties;
|
||||
*/
|
||||
public class Tile
|
||||
{
|
||||
private Image image;
|
||||
private BufferedImage image;
|
||||
private int id = -1;
|
||||
private Properties properties;
|
||||
private TileSet tileset;
|
||||
@@ -76,7 +76,7 @@ public class Tile
|
||||
*
|
||||
* @param i the new image of the tile
|
||||
*/
|
||||
public void setImage(Image i) {
|
||||
public void setImage(BufferedImage i) {
|
||||
image = i;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class Tile
|
||||
*
|
||||
* @return Image
|
||||
*/
|
||||
public Image getImage() {
|
||||
public BufferedImage getImage() {
|
||||
if (tileset != null && tileset.sheet != null) return tileset.sheet.getImage(getId());
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class TileSet implements Iterable<Tile>
|
||||
tilesPerRow = basicTileCutter.getTilesPerRow();
|
||||
}
|
||||
|
||||
Image tileImage = cutter.getNextTile();
|
||||
BufferedImage tileImage = cutter.getNextTile();
|
||||
while (tileImage != null) {
|
||||
Tile tile = new Tile();
|
||||
tile.setImage(tileImage);
|
||||
@@ -220,7 +220,7 @@ public class TileSet implements Iterable<Tile>
|
||||
tileDimensions = new Rectangle(tileCutter.getTileDimensions());
|
||||
|
||||
int id = 0;
|
||||
Image tileImage = tileCutter.getNextTile();
|
||||
BufferedImage tileImage = tileCutter.getNextTile();
|
||||
while (tileImage != null) {
|
||||
Tile tile = getTile(id);
|
||||
tile.setImage(tileImage);
|
||||
|
||||
@@ -31,13 +31,13 @@ package tiled.io;
|
||||
import java.awt.Color;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
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;
|
||||
@@ -223,9 +223,9 @@ public class TMXMapReader
|
||||
return o;
|
||||
}
|
||||
|
||||
private Image unmarshalImage(Node t, String baseDir) throws IOException
|
||||
private BufferedImage unmarshalImage(Node t, String baseDir) throws IOException
|
||||
{
|
||||
Image img = null;
|
||||
BufferedImage img = null;
|
||||
|
||||
String source = getAttributeValue(t, "source");
|
||||
|
||||
@@ -253,7 +253,7 @@ public class TMXMapReader
|
||||
// size, somehow makes drawing of the tiles a lot
|
||||
// faster on various systems (seen on Linux, Windows
|
||||
// and MacOS X).
|
||||
img = img.getScaledInstance(
|
||||
img = (BufferedImage) img.getScaledInstance(
|
||||
img.getWidth(null), img.getHeight(null),
|
||||
Image.SCALE_FAST);
|
||||
}
|
||||
@@ -534,7 +534,7 @@ public class TMXMapReader
|
||||
Node child = children.item(i);
|
||||
if ("image".equalsIgnoreCase(child.getNodeName())) {
|
||||
int id = getAttribute(child, "id", -1);
|
||||
Image img = unmarshalImage(child, baseDir);
|
||||
BufferedImage img = unmarshalImage(child, baseDir);
|
||||
tile.setImage(img);
|
||||
} else if ("animation".equalsIgnoreCase(child.getNodeName())) {
|
||||
// TODO: fill this in once TMXMapWriter is complete
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
package tiled.util;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
@@ -64,7 +63,7 @@ public class BasicTileCutter implements TileCutter
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public Image getNextTile() {
|
||||
public BufferedImage getNextTile() {
|
||||
if (nextY + tileHeight + tileMargin <= image.getHeight()) {
|
||||
BufferedImage tile =
|
||||
image.getSubimage(nextX, nextY, tileWidth, tileHeight);
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
package tiled.util;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
@@ -48,7 +47,7 @@ public interface TileCutter
|
||||
* @return the next tile image, or <code>null</code> when no more tile
|
||||
* images are available
|
||||
*/
|
||||
public Image getNextTile();
|
||||
public BufferedImage getNextTile();
|
||||
|
||||
/**
|
||||
* Resets the tile cutter so that the next call to <code>getNextTile</code>
|
||||
|
||||
@@ -27,9 +27,10 @@
|
||||
|
||||
package tiled.view;
|
||||
|
||||
import tiled.core.TileLayer;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import java.awt.*;
|
||||
import tiled.core.TileLayer;
|
||||
|
||||
/**
|
||||
* An interface defining methods to render a map.
|
||||
|
||||
@@ -27,12 +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.*;
|
||||
|
||||
/**
|
||||
* The orthogonal map renderer. This is the most basic map renderer, dealing
|
||||
* with maps that use rectangular tiles.
|
||||
@@ -74,10 +77,12 @@ public class OrthogonalRenderer implements MapRenderer
|
||||
final Tile tile = layer.getTileAt(x, y);
|
||||
if (tile == null)
|
||||
continue;
|
||||
final Image image = tile.getImage();
|
||||
final BufferedImage image = tile.getImage();
|
||||
if (image == null)
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
g.drawImage(
|
||||
image,
|
||||
x * tileWidth,
|
||||
|
||||
@@ -1 +1 @@
|
||||
start "" "javaw.exe" -Xmx512M -cp "lib\ATCS_v0.4.4.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
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
java -Xmx512M -cp lib/AndorsTrainer_v0.1.2.jar:lib/ATCS_v0.4.4.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
|
||||
|
||||
@@ -1 +1 @@
|
||||
start "" "javaw.exe" -Xmx512M -cp "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\ATCS_v0.4.3.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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
!include MUI2.nsh
|
||||
|
||||
!define VERSION "0.4.4"
|
||||
!define VERSION "0.5.0"
|
||||
!define JAVA_BIN "java"
|
||||
|
||||
Name "Andor's Trail Content Studio v${VERSION}"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
atcs.spritesheet.actorconditions_1.category=actorcondition
|
||||
atcs.spritesheet.actorconditions_2.category=actorcondition
|
||||
atcs.spritesheet.actorconditions_japozero.category=actorcondition
|
||||
atcs.spritesheet.items_armours.category=item
|
||||
atcs.spritesheet.items_armours_2.category=item
|
||||
atcs.spritesheet.items_armours_3.category=item
|
||||
@@ -10,6 +11,7 @@ atcs.spritesheet.items_jewelry.category=item
|
||||
atcs.spritesheet.items_rings_1.category=item
|
||||
atcs.spritesheet.items_necklaces_1.category=item
|
||||
atcs.spritesheet.items_consumables.category=item
|
||||
atcs.spritesheet.items_japozero.category=item
|
||||
atcs.spritesheet.items_books.category=item
|
||||
atcs.spritesheet.items_misc.category=item
|
||||
atcs.spritesheet.items_misc_2.category=item
|
||||
|
||||
@@ -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.4";
|
||||
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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -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;
|
||||
@@ -219,14 +221,12 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
public void refreshTransients(Workspace w) {
|
||||
this.parent = w;
|
||||
|
||||
if (knownSpritesheetsProperties == null) {
|
||||
try {
|
||||
knownSpritesheetsProperties = new Properties();
|
||||
knownSpritesheetsProperties.load(Project.class.getResourceAsStream("/spritesheets.properties"));
|
||||
} catch (IOException e) {
|
||||
Notification.addWarn("Unable to load default spritesheets properties.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
knownSpritesheetsProperties = new Properties();
|
||||
knownSpritesheetsProperties.load(Project.class.getResourceAsStream("/spritesheets.properties"));
|
||||
} catch (IOException e) {
|
||||
Notification.addWarn("Unable to load default spritesheets properties.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (sourceSetToUse == null) {
|
||||
@@ -694,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() {
|
||||
@@ -786,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;
|
||||
@@ -808,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>());
|
||||
@@ -844,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() {
|
||||
@@ -995,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());
|
||||
}
|
||||
@@ -1032,6 +1083,7 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -63,8 +63,8 @@ public class Dialogue extends JSONElement {
|
||||
spawnAll,
|
||||
removeSpawnArea,
|
||||
deactivateSpawnArea,
|
||||
activateMapChangeArea,
|
||||
deactivateMapChangeArea
|
||||
activateMapObjectGroup,
|
||||
deactivateMapObjectGroup
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -242,12 +239,12 @@ public class Dialogue extends JSONElement {
|
||||
for (Reward reward : rewards) {
|
||||
if (reward.reward_obj_id != null) {
|
||||
switch (reward.type) {
|
||||
case activateMapChangeArea:
|
||||
case deactivateMapChangeArea:
|
||||
case activateMapObjectGroup:
|
||||
case deactivateMapObjectGroup:
|
||||
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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -154,7 +154,7 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
||||
dataToSave.add(element.toJson());
|
||||
}
|
||||
}
|
||||
if (dataToSave.isEmpty()) {
|
||||
if (dataToSave.isEmpty() && jsonFile.exists()) {
|
||||
if (jsonFile.delete()) {
|
||||
Notification.addSuccess("File "+jsonFile.getAbsolutePath()+" deleted.");
|
||||
} else {
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,10 +492,12 @@ 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);
|
||||
if(this.display_type != null) itemJson.put("displaytype", this.display_type.toString());
|
||||
|
||||
if (this.has_manual_price != null) itemJson.put("hasManualPrice", this.has_manual_price);
|
||||
if (this.base_market_cost != null) itemJson.put("baseMarketCost", this.base_market_cost);
|
||||
if (this.category != null) {
|
||||
@@ -505,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);
|
||||
@@ -530,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);
|
||||
@@ -542,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);
|
||||
@@ -553,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);
|
||||
@@ -564,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);
|
||||
@@ -580,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);
|
||||
@@ -594,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);
|
||||
@@ -609,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);
|
||||
@@ -620,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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class KeyArea extends MapObject {
|
||||
oldSchoolRequirement = false;
|
||||
}
|
||||
requirement = new Requirement();
|
||||
requirement.type = Requirement.RequirementType.valueOf(requireType);
|
||||
if (requireType != null) requirement.type = Requirement.RequirementType.valueOf(requireType);
|
||||
requirement.required_obj_id = requireId;
|
||||
if (requireValue != null) requirement.required_value = Integer.parseInt(requireValue);
|
||||
requirement.state = GameDataElement.State.parsed;
|
||||
@@ -77,7 +77,9 @@ public class KeyArea extends MapObject {
|
||||
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
||||
tmxObject.setName(requirement.required_obj_id+":"+Integer.toString(requirement.required_value));
|
||||
} else {
|
||||
tmxObject.getProperties().setProperty("requireType", requirement.type.toString());
|
||||
if (requirement.type != null) {
|
||||
tmxObject.getProperties().setProperty("requireType", requirement.type.toString());
|
||||
}
|
||||
if (requirement.required_obj != null) {
|
||||
tmxObject.getProperties().setProperty("requireId", requirement.required_obj.id);
|
||||
} else if (requirement.required_obj_id != null) {
|
||||
|
||||
@@ -13,12 +13,18 @@ public class MapObjectGroup {
|
||||
public String name;
|
||||
public boolean visible;
|
||||
public List<MapObject> mapObjects = new ArrayList<MapObject>();
|
||||
public Boolean active;
|
||||
|
||||
public MapObjectGroup(tiled.core.ObjectGroup layer, TMXMap map) {
|
||||
this.tmxGroup = layer;
|
||||
this.name = layer.getName();
|
||||
this.visible = layer.isVisible();
|
||||
this.parentMap = map;
|
||||
if (layer.getProperties().get("active") != null) {
|
||||
active = new Boolean(((String) layer.getProperties().get("active")));
|
||||
} else {
|
||||
active = true;
|
||||
}
|
||||
for (tiled.core.MapObject obj : layer.getObjectsList()) {
|
||||
mapObjects.add(MapObject.buildObject(obj, map));
|
||||
}
|
||||
@@ -44,6 +50,9 @@ public class MapObjectGroup {
|
||||
}
|
||||
tmxGroup.setVisible(visible);
|
||||
tmxGroup.setName(name);
|
||||
if (!active) {
|
||||
tmxGroup.getProperties().put("active", Boolean.toString(active));
|
||||
}
|
||||
for (MapObject object : mapObjects) {
|
||||
tmxGroup.addObject(object.toTmxObject());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ public class SpawnArea extends MapObject {
|
||||
public int quantity = 1;
|
||||
public int spawnchance = 10;
|
||||
public boolean active = true;
|
||||
public String spawngroup_id;
|
||||
public List<NPC> spawnGroup = new ArrayList<NPC>();
|
||||
|
||||
public SpawnArea(tiled.core.MapObject obj) {
|
||||
@@ -25,12 +26,17 @@ public class SpawnArea extends MapObject {
|
||||
if (obj.getProperties().getProperty("active") != null) {
|
||||
this.active = Boolean.parseBoolean(obj.getProperties().getProperty("active"));
|
||||
}
|
||||
if (obj.getProperties().getProperty("spawngroup") != null) {
|
||||
this.spawngroup_id = obj.getProperties().getProperty("spawngroup");
|
||||
} else if (obj.getName() != null ){
|
||||
this.spawngroup_id = obj.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (name != null) {
|
||||
spawnGroup = parentMap.getProject().getSpawnGroup(name);
|
||||
if (spawngroup_id != null) {
|
||||
spawnGroup = parentMap.getProject().getSpawnGroup(spawngroup_id);
|
||||
} else {
|
||||
spawnGroup = new ArrayList<NPC>();
|
||||
}
|
||||
@@ -65,6 +71,9 @@ public class SpawnArea extends MapObject {
|
||||
|
||||
@Override
|
||||
public void savePropertiesInTmxObject(tiled.core.MapObject tmxObject) {
|
||||
if (spawngroup_id != null) {
|
||||
tmxObject.getProperties().setProperty("spawngroup", spawngroup_id);
|
||||
}
|
||||
if (quantity != 1) {
|
||||
tmxObject.getProperties().setProperty("quantity", Integer.toString(quantity));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -38,6 +38,17 @@ public class TMXMap extends GameDataElement {
|
||||
public static final String ABOVE_LAYER_NAME = "Above";
|
||||
public static final String WALKABLE_LAYER_NAME = "Walkable";
|
||||
|
||||
public enum ColorFilter {
|
||||
black20,
|
||||
black40,
|
||||
black60,
|
||||
black80,
|
||||
invert,
|
||||
bw,
|
||||
redtint,
|
||||
greentint,
|
||||
bluetint
|
||||
}
|
||||
|
||||
public File tmxFile = null;
|
||||
public tiled.core.Map tmxMap = null;
|
||||
@@ -46,6 +57,7 @@ public class TMXMap extends GameDataElement {
|
||||
|
||||
public ProjectTreeNode parent;
|
||||
public Integer outside = null;
|
||||
public ColorFilter colorFilter = null;
|
||||
|
||||
public boolean writable = false;
|
||||
|
||||
@@ -62,8 +74,11 @@ public class TMXMap extends GameDataElement {
|
||||
usedSpritesheets = new HashSet<Spritesheet>();
|
||||
try {
|
||||
tmxMap = new TMXMapReader().readMap(tmxFile.getAbsolutePath(), this);
|
||||
if (tmxMap.getProperties().get("outside") != null) {
|
||||
outside = new Integer(((String) tmxMap.getProperties().get("outside")));
|
||||
if (tmxMap.getProperties().get("outdoors") != null) {
|
||||
outside = new Integer(((String) tmxMap.getProperties().get("outdoors")));
|
||||
}
|
||||
if (tmxMap.getProperties().get("colorfilter") != null) {
|
||||
colorFilter = ColorFilter.valueOf(((String) tmxMap.getProperties().get("colorfilter")));
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
Notification.addError("Impossible to load TMX map file "+tmxFile.getAbsolutePath());
|
||||
@@ -97,8 +112,11 @@ public class TMXMap extends GameDataElement {
|
||||
try {
|
||||
clone.usedSpritesheets = new HashSet<Spritesheet>();
|
||||
clone.tmxMap = new TMXMapReader().readMap(new StringReader(this.toXml()), clone);
|
||||
if (clone.tmxMap.getProperties().get("outside") != null) {
|
||||
clone.outside = new Integer(((String) clone.tmxMap.getProperties().get("outside")));
|
||||
if (clone.tmxMap.getProperties().get("outdoors") != null) {
|
||||
clone.outside = new Integer(((String) clone.tmxMap.getProperties().get("outdoors")));
|
||||
}
|
||||
if (clone.tmxMap.getProperties().get("colorfilter") != null) {
|
||||
clone.colorFilter = ColorFilter.valueOf(((String) tmxMap.getProperties().get("colorfilter")));
|
||||
}
|
||||
for (tiled.core.MapLayer layer : clone.tmxMap.getLayers()) {
|
||||
if (layer instanceof tiled.core.ObjectGroup) {
|
||||
@@ -210,6 +228,17 @@ public class TMXMap extends GameDataElement {
|
||||
}
|
||||
|
||||
public String toXml() {
|
||||
if (outside != null && outside == 1) {
|
||||
tmxMap.getProperties().put("outdoors", Integer.toString(outside));
|
||||
} else {
|
||||
tmxMap.getProperties().remove("outdoors");
|
||||
}
|
||||
if (colorFilter != null) {
|
||||
tmxMap.getProperties().put("colorfilter", colorFilter.toString());
|
||||
} else {
|
||||
tmxMap.getProperties().remove("colorfilter");
|
||||
}
|
||||
|
||||
for (MapObjectGroup group : groups) {
|
||||
group.pushBackToTiledProperties();
|
||||
if (!tmxMap.containsLayer(group.tmxGroup)) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class AboutEditor extends Editor {
|
||||
"<br/>" +
|
||||
"Play <a href=\"https://play.google.com/store/apps/details?id=com.gpl.rpg.AndorsTrail\">Andor's Trail</a> for free on your Android device.<br/>" +
|
||||
"Visit <a href=\"http://andorstrail.com/\">the official forum</a> to give or receive help.<br/>" +
|
||||
"Open the project's <a href=\"https://code.google.com/p/andors-trail/\">Google Code page</a> to check out the game's source code.<br/>" +
|
||||
"Open the project's <a href=\"https://github.com/Zukero/andors-trail/\">GitHub project page</a> to check out the game's source code.<br/>" +
|
||||
"<br/>" +
|
||||
"For content creation help, make sure to use the following resources:<br/>" +
|
||||
"<a href=\"http://andorstrail.com/viewtopic.php?f=6&t=4560\">The contribution guide on the forums</a><br/>" +
|
||||
@@ -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());
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import javax.swing.AbstractListModel;
|
||||
import javax.swing.ComboBoxModel;
|
||||
@@ -29,6 +30,7 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JSpinner.NumberEditor;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
@@ -147,6 +149,51 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
||||
});
|
||||
return tfField;
|
||||
}
|
||||
|
||||
public static JTextArea addTextArea(JPanel pane, String label, String initialValue, boolean editable, final FieldUpdateListener listener) {
|
||||
String text= initialValue == null ? "" : initialValue.replaceAll("\\n", "\n");
|
||||
|
||||
JPanel tfPane = new JPanel();
|
||||
tfPane.setLayout(new JideBoxLayout(tfPane, JideBoxLayout.LINE_AXIS, 6));
|
||||
JLabel tfLabel = new JLabel(label);
|
||||
tfPane.add(tfLabel, JideBoxLayout.FIX);
|
||||
final JTextArea tfArea = new JTextArea(text);
|
||||
tfArea.setEditable(editable);
|
||||
tfPane.add(new JScrollPane(tfArea), JideBoxLayout.VARY);
|
||||
JButton nullify = new JButton(new ImageIcon(DefaultIcons.getNullifyIcon()));
|
||||
tfPane.add(nullify, JideBoxLayout.FIX);
|
||||
nullify.setEnabled(editable);
|
||||
pane.add(tfPane, JideBoxLayout.FIX);
|
||||
|
||||
nullify.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tfArea.setText("");
|
||||
listener.valueChanged(tfArea, null);
|
||||
}
|
||||
});
|
||||
tfArea.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
listener.valueChanged(tfArea, tfArea.getText().replaceAll("\n", Matcher.quoteReplacement("\n")));
|
||||
}
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
listener.valueChanged(tfArea, tfArea.getText().replaceAll("\n", Matcher.quoteReplacement("\n")));
|
||||
}
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
listener.valueChanged(tfArea, tfArea.getText().replaceAll("\n", Matcher.quoteReplacement("\n")));
|
||||
}
|
||||
});
|
||||
// tfArea.addActionListener(new ActionListener() {
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// listener.valueChanged(tfArea, tfArea.getText().replaceAll("\n", "\\n"));
|
||||
// }
|
||||
// });
|
||||
return tfArea;
|
||||
}
|
||||
|
||||
// public static JSpinner addIntegerField(JPanel pane, String label, Integer initialValue, boolean allowNegatives, boolean editable) {
|
||||
// return addIntegerField(pane, label, initialValue, allowNegatives, editable, nullListener);
|
||||
@@ -259,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);
|
||||
@@ -300,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
|
||||
@@ -315,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
|
||||
@@ -330,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
|
||||
@@ -345,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
|
||||
@@ -360,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
|
||||
@@ -375,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
|
||||
@@ -390,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
|
||||
@@ -405,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
|
||||
@@ -416,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));
|
||||
@@ -482,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() {
|
||||
@@ -514,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;
|
||||
|
||||
@@ -530,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
|
||||
@@ -573,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);
|
||||
@@ -595,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;
|
||||
|
||||
@@ -620,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 --;
|
||||
@@ -647,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;
|
||||
@@ -659,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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -27,6 +27,7 @@ import javax.swing.event.ListDataListener;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
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.Project;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
|
||||
@@ -58,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;
|
||||
@@ -84,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;
|
||||
@@ -293,6 +296,7 @@ public class JSONCreationWizard extends JDialog {
|
||||
creation.id = idField.getText();
|
||||
JSONCreationWizard.this.setVisible(false);
|
||||
JSONCreationWizard.this.dispose();
|
||||
creation.state = State.created;
|
||||
proj.createElement(creation);
|
||||
notifyCreated();
|
||||
ATContentStudio.frame.selectInTree(creation);
|
||||
@@ -499,6 +503,7 @@ public class JSONCreationWizard extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static class DataTypeComboModel implements ComboBoxModel {
|
||||
|
||||
DataType selected = DataType.none;
|
||||
@@ -540,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));
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
@@ -370,7 +429,7 @@ public class WorkspaceActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putValue(String key, Object value) {
|
||||
public synchronized void putValue(String key, Object value) {
|
||||
PropertyChangeEvent event = new PropertyChangeEvent(this, key, values.get(key), value);
|
||||
values.put(key, value);
|
||||
for (PropertyChangeListener l : listeners) {
|
||||
@@ -379,7 +438,7 @@ public class WorkspaceActions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean b) {
|
||||
public synchronized void setEnabled(boolean b) {
|
||||
PropertyChangeEvent event = new PropertyChangeEvent(this, "enabled", isEnabled(), b);
|
||||
enabled = b;
|
||||
for (PropertyChangeListener l : listeners) {
|
||||
@@ -395,12 +454,12 @@ public class WorkspaceActions {
|
||||
private Set<PropertyChangeListener> listeners = new HashSet<PropertyChangeListener>();
|
||||
|
||||
@Override
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
@@ -79,11 +80,13 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
private static final int SHOP_INDEX = 5;
|
||||
|
||||
private JTextField idField;
|
||||
private JTextField messageField;
|
||||
private JTextArea messageField;
|
||||
private MyComboBox switchToNpcBox;
|
||||
|
||||
private RewardsListModel rewardsListModel;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private JList rewardsList;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private JComboBox rewardTypeCombo;
|
||||
private JPanel rewardsParamsPane;
|
||||
private MyComboBox rewardMap;
|
||||
@@ -92,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;
|
||||
@@ -108,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;
|
||||
@@ -127,7 +163,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
createButtonPane(pane, dialogue.getProject(), dialogue, Dialogue.class, dialogue.getImage(), null, listener);
|
||||
|
||||
idField = addTextField(pane, "Internal ID: ", dialogue.id, dialogue.writable, listener);
|
||||
messageField = addTextField(pane, "Message: ", dialogue.message, dialogue.writable, listener);
|
||||
messageField = addTextArea(pane, "Message: ", dialogue.message, dialogue.writable, listener);
|
||||
switchToNpcBox = addNPCBox(pane, dialogue.getProject(), "Switch active NPC to: ", dialogue.switch_to_npc, dialogue.writable, listener);
|
||||
|
||||
CollapsiblePanel rewards = new CollapsiblePanel("Reaching this phrase gives the following rewards: ");
|
||||
@@ -320,8 +356,13 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
}
|
||||
if (reward.type != null) {
|
||||
switch (reward.type) {
|
||||
case activateMapChangeArea:
|
||||
case deactivateMapChangeArea:
|
||||
case activateMapObjectGroup:
|
||||
case deactivateMapObjectGroup:
|
||||
rewardMap = addMapBox(pane, ((Dialogue)target).getProject(), "Map Name: ", reward.map, writable, listener);
|
||||
rewardObjId = addTextField(pane, "Group ID: ", reward.reward_obj_id, writable, listener);
|
||||
rewardObj = null;
|
||||
rewardValue = null;
|
||||
break;
|
||||
case deactivateSpawnArea:
|
||||
case removeSpawnArea:
|
||||
case spawnAll:
|
||||
@@ -379,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) {
|
||||
@@ -645,7 +687,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
}
|
||||
|
||||
|
||||
public static class RewardsListModel implements ListModel {
|
||||
public static class RewardsListModel implements ListModel<Dialogue.Reward> {
|
||||
|
||||
Dialogue source;
|
||||
|
||||
@@ -660,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);
|
||||
}
|
||||
@@ -711,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);
|
||||
@@ -732,8 +774,9 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
rewardObjDesc = reward.reward_obj_id;
|
||||
}
|
||||
switch (reward.type) {
|
||||
case activateMapChangeArea:
|
||||
label.setText("Activate mapchange area "+rewardObjDesc+" on map "+reward.map_name);
|
||||
case activateMapObjectGroup:
|
||||
label.setText("Activate map object group "+rewardObjDesc+" on map "+reward.map_name);
|
||||
label.setIcon(new ImageIcon(DefaultIcons.getObjectLayerIcon()));
|
||||
break;
|
||||
case actorCondition:
|
||||
label.setText("Give actor condition "+rewardObjDesc+" for "+reward.reward_value+" turns");
|
||||
@@ -745,11 +788,13 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
case createTimer:
|
||||
label.setText("Create timer "+rewardObjDesc);
|
||||
break;
|
||||
case deactivateMapChangeArea:
|
||||
label.setText("Deactivate mapchange area "+rewardObjDesc+" on map "+reward.map_name);
|
||||
case deactivateMapObjectGroup:
|
||||
label.setText("Deactivate map object group "+rewardObjDesc+" on map "+reward.map_name);
|
||||
label.setIcon(new ImageIcon(DefaultIcons.getObjectLayerIcon()));
|
||||
break;
|
||||
case deactivateSpawnArea:
|
||||
label.setText("Deactivate spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
||||
label.setIcon(new ImageIcon(DefaultIcons.getNPCIcon()));
|
||||
break;
|
||||
case dropList:
|
||||
label.setText("Give contents of droplist "+rewardObjDesc);
|
||||
@@ -765,12 +810,14 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
break;
|
||||
case removeSpawnArea:
|
||||
label.setText("Remove all monsters in spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
||||
label.setIcon(new ImageIcon(DefaultIcons.getNPCIcon()));
|
||||
break;
|
||||
case skillIncrease:
|
||||
label.setText("Increase skill "+rewardObjDesc+" level");
|
||||
break;
|
||||
case spawnAll:
|
||||
label.setText("Respawn all monsters in spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
||||
label.setIcon(new ImageIcon(DefaultIcons.getNPCIcon()));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -779,7 +826,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
}
|
||||
|
||||
|
||||
public static class RepliesListModel implements ListModel {
|
||||
public static class RepliesListModel implements ListModel<Dialogue.Reply> {
|
||||
|
||||
Dialogue source;
|
||||
|
||||
@@ -795,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);
|
||||
}
|
||||
@@ -867,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);
|
||||
@@ -913,7 +960,7 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ReplyRequirementsListModel implements ListModel {
|
||||
public static class ReplyRequirementsListModel implements ListModel<Requirement> {
|
||||
|
||||
Dialogue.Reply reply;
|
||||
|
||||
@@ -928,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);
|
||||
}
|
||||
@@ -982,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);
|
||||
@@ -1027,6 +1074,10 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
} else if (source == rewardTypeCombo) {
|
||||
if (selectedReward.type != value) {
|
||||
selectedReward.type = (Dialogue.Reward.RewardType) value;
|
||||
if (selectedReward.map != null) {
|
||||
selectedReward.map.removeBacklink(dialogue);
|
||||
}
|
||||
selectedReward.map = null;
|
||||
selectedReward.map_name = null;
|
||||
selectedReward.reward_obj = null;
|
||||
selectedReward.reward_obj_id = null;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui.gamedataeditors;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
@@ -62,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();
|
||||
@@ -79,6 +84,7 @@ public class QuestEditor extends JSONElementEditor {
|
||||
stagesTable.getColumnModel().getColumn(3).setMinWidth(130);
|
||||
stagesTable.getColumnModel().getColumn(3).setMaxWidth(130);
|
||||
stagesTable.setCellSelectionEnabled(true);
|
||||
stagesTable.getColumnModel().getColumn(1).setCellRenderer(new MultilineCellRenderer());
|
||||
stagesPane.add(new JScrollPane(stagesTable), BorderLayout.CENTER);
|
||||
if (quest.writable) {
|
||||
JPanel buttonPane = new JPanel();
|
||||
@@ -330,6 +336,48 @@ public class QuestEditor extends JSONElementEditor {
|
||||
updateJsonViewText(quest.toJsonString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class MultilineCellRenderer extends JTextArea implements TableCellRenderer {
|
||||
private static final long serialVersionUID = 6539816623608859506L;
|
||||
|
||||
public MultilineCellRenderer() {
|
||||
setLineWrap(true);
|
||||
setWrapStyleWord(true);
|
||||
//setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus,
|
||||
int row, int column) {
|
||||
if (isSelected) {
|
||||
setForeground(stagesTable.getSelectionForeground());
|
||||
setBackground(stagesTable.getSelectionBackground());
|
||||
} else {
|
||||
setForeground(stagesTable.getForeground());
|
||||
setBackground(stagesTable.getBackground());
|
||||
}
|
||||
setFont(stagesTable.getFont());
|
||||
if (hasFocus) {
|
||||
setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
|
||||
if (stagesTable.isCellEditable(row, column)) {
|
||||
setForeground(UIManager.getColor("Table.focusCellForeground"));
|
||||
setBackground(UIManager.getColor("Table.focusCellBackground"));
|
||||
}
|
||||
} else {
|
||||
setBorder(BorderFactory.createLineBorder(getBackground(), 1));
|
||||
}
|
||||
setText((value == null ? "" : value.toString()));
|
||||
|
||||
int fh = getFontMetrics(getFont()).getHeight();
|
||||
// int tl = getText().length();
|
||||
setSize(stagesTable.getWidth(), fh);
|
||||
stagesTable.setRowHeight(row, getPreferredSize().height);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
107
src/com/gpl/rpg/atcontentstudio/ui/map/MapColorFilters.java
Normal file
107
src/com/gpl/rpg/atcontentstudio/ui/map/MapColorFilters.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui.map;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||
import com.gpl.rpg.atcontentstudio.ui.tools.MatrixComposite;
|
||||
|
||||
public class MapColorFilters {
|
||||
|
||||
public static void applyColorfilter(TMXMap.ColorFilter colorFilter, Graphics2D g2d) {
|
||||
Composite oldComp = g2d.getComposite();
|
||||
Rectangle clip = g2d.getClipBounds();
|
||||
MatrixComposite newComp = null;
|
||||
float f=0.0f;
|
||||
switch(colorFilter) {
|
||||
case black20:
|
||||
f=0.8f;
|
||||
newComp = new MatrixComposite(new float[]{
|
||||
f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
break;
|
||||
case black40:
|
||||
f=0.6f;
|
||||
newComp = new MatrixComposite(new float[]{
|
||||
f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
break;
|
||||
case black60:
|
||||
f=0.4f;
|
||||
newComp = new MatrixComposite(new float[]{
|
||||
f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
break;
|
||||
case black80:
|
||||
f=0.2f;
|
||||
newComp = new MatrixComposite(new float[]{
|
||||
f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
break;
|
||||
case bw:
|
||||
newComp = new MatrixComposite(new float[]{
|
||||
0.33f, 0.59f, 0.11f, 0.0f, 0.0f,
|
||||
0.33f, 0.59f, 0.11f, 0.0f, 0.0f,
|
||||
0.33f, 0.59f, 0.11f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
break;
|
||||
case invert:
|
||||
newComp = new MatrixComposite(new float[]{
|
||||
-1.00f, 0.00f, 0.00f, 0.0f, 255.0f,
|
||||
0.00f, -1.00f, 0.00f, 0.0f, 255.0f,
|
||||
0.00f, 0.00f, -1.00f, 0.0f, 255.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
break;
|
||||
case redtint:
|
||||
newComp = new MatrixComposite(new float[]{
|
||||
1.20f, 0.20f, 0.20f, 0.0f, 25.0f,
|
||||
0.00f, 0.80f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.80f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
break;
|
||||
case greentint:
|
||||
newComp = new MatrixComposite(new float[]{
|
||||
0.85f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.15f, 1.15f, 0.15f, 0.0f, 15.0f,
|
||||
0.00f, 0.00f, 0.85f, 0.0f, 0.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
break;
|
||||
case bluetint:
|
||||
newComp = new MatrixComposite(new float[]{
|
||||
0.70f, 0.00f, 0.00f, 0.0f, 0.0f,
|
||||
0.00f, 0.70f, 0.00f, 0.0f, 0.0f,
|
||||
0.30f, 0.30f, 1.30f, 0.0f, 40.0f,
|
||||
0.00f, 0.00f, 0.00f, 1.0f, 0.0f
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
if (newComp != null) {
|
||||
g2d.setComposite(newComp);
|
||||
g2d.setPaint(new Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
g2d.fill(clip);
|
||||
g2d.setComposite(oldComp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,10 +19,7 @@ import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -109,13 +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;
|
||||
@@ -124,8 +124,10 @@ public class TMXMapEditor extends Editor {
|
||||
|
||||
private JPanel layerDetailsPane;
|
||||
private BooleanBasedCheckBox layerVisibleBox;
|
||||
//private BooleanBasedCheckBox activeLayerBox;
|
||||
private JTextField layerNameField;
|
||||
private MapObjectsListModel groupObjectsListModel;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private JList groupObjectsList;
|
||||
private MapObject selectedMapObject;
|
||||
private JButton addMapchange;
|
||||
@@ -139,31 +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;
|
||||
@@ -193,6 +207,7 @@ public class TMXMapEditor extends Editor {
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public JPanel getTmxEditorPane() {
|
||||
final TMXMap map = (TMXMap) target;
|
||||
final FieldUpdateListener listener = new MapFieldUpdater();
|
||||
@@ -204,6 +219,7 @@ public class TMXMapEditor extends Editor {
|
||||
addLabelField(pane, "TMX File: ", ((TMXMap)target).tmxFile.getAbsolutePath());
|
||||
createButtonPane(pane, map.getProject(), map, listener);
|
||||
outsideBox = addIntegerBasedCheckBox(pane, "Map is outdoors", map.outside, map.writable, listener);
|
||||
colorFilterBox = addEnumValueBox(pane, "Color Filter", TMXMap.ColorFilter.values(), map.colorFilter, map.writable, listener);
|
||||
|
||||
JSplitPane layersViewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||||
layerListModel = new LayerListModel(map);
|
||||
@@ -284,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();
|
||||
@@ -307,6 +324,7 @@ public class TMXMapEditor extends Editor {
|
||||
break;
|
||||
}
|
||||
}
|
||||
activeForNewGame = addBooleanBasedCheckBox(groupDetailPane, "Active for new game", objGroup.active, map.writable, listener);
|
||||
groupObjectsListModel = new MapObjectsListModel(objGroup);
|
||||
groupObjectsList = new JList(groupObjectsListModel);
|
||||
groupObjectsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
@@ -440,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;
|
||||
@@ -539,14 +558,15 @@ public class TMXMapEditor extends Editor {
|
||||
|
||||
|
||||
} else if (selected instanceof RestArea) {
|
||||
pane.add(new JLabel("Rest areas have no parameters"), JideBoxLayout.FIX);
|
||||
areaField = addTextField(pane, "Area ID: ", ((RestArea)selected).name, ((TMXMap)target).writable, listener);
|
||||
} else if (selected instanceof ScriptArea) {
|
||||
evaluateTriggerBox = addEnumValueBox(pane, "Evaluate on every: ", ScriptArea.EvaluationTrigger.values(), ((ScriptArea)selected).trigger_type, ((TMXMap)target).writable, listener);
|
||||
dialogueBox = addDialogueBox(pane, ((TMXMap)target).getProject(), "Script: ", ((ScriptArea)selected).dialogue, ((TMXMap)target).writable, listener);
|
||||
} else if (selected instanceof SignArea) {
|
||||
dialogueBox = addDialogueBox(pane, ((TMXMap)target).getProject(), "Message: ", ((SignArea)selected).dialogue, ((TMXMap)target).writable, listener);
|
||||
} else if (selected instanceof SpawnArea) {
|
||||
areaField = addTextField(pane, "Spawn group ID: ", ((SpawnArea)selected).name, ((TMXMap)target).writable, listener);
|
||||
areaField = addTextField(pane, "Spawn area ID: ", ((SpawnArea)selected).name, ((TMXMap)target).writable, listener);
|
||||
spawngroupField = addTextField(pane, "Spawn group ID: ", ((SpawnArea)selected).spawngroup_id, ((TMXMap)target).writable, listener);
|
||||
quantityField = addIntegerField(pane, "Number of spawned NPCs: ", ((SpawnArea)selected).quantity, false, ((TMXMap)target).writable, listener);
|
||||
activeForNewGame = addBooleanBasedCheckBox(pane, "Active in a new game: ", ((SpawnArea)selected).active, ((TMXMap)target).writable, listener);
|
||||
npcListModel = new SpawnGroupNpcListModel((SpawnArea) selected);
|
||||
@@ -865,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) {
|
||||
@@ -903,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() {
|
||||
@@ -930,6 +951,7 @@ public class TMXMapEditor extends Editor {
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class LayerListModel implements ListModel {
|
||||
|
||||
public TMXMap map;
|
||||
@@ -990,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;
|
||||
@@ -1006,7 +1028,7 @@ public class TMXMapEditor extends Editor {
|
||||
}
|
||||
}
|
||||
|
||||
public class ReplacementsListModel implements ListModel {
|
||||
public class ReplacementsListModel implements ListModel<ReplaceArea.Replacement> {
|
||||
|
||||
public ReplaceArea area;
|
||||
|
||||
@@ -1021,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);
|
||||
@@ -1072,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;
|
||||
@@ -1087,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;
|
||||
|
||||
@@ -1139,7 +1161,7 @@ public class TMXMapEditor extends Editor {
|
||||
}
|
||||
}
|
||||
|
||||
public class MapObjectsListModel implements ListModel {
|
||||
public class MapObjectsListModel implements ListModel<MapObject> {
|
||||
|
||||
public MapObjectGroup group;
|
||||
|
||||
@@ -1153,7 +1175,7 @@ public class TMXMapEditor extends Editor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
public MapObject getElementAt(int index) {
|
||||
return group.mapObjects.get(index);
|
||||
}
|
||||
|
||||
@@ -1196,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);
|
||||
@@ -1206,7 +1228,7 @@ public class TMXMapEditor extends Editor {
|
||||
}
|
||||
}
|
||||
|
||||
public class SpawnGroupNpcListModel implements ListModel {
|
||||
public class SpawnGroupNpcListModel implements ListModel<NPC> {
|
||||
|
||||
public SpawnArea area;
|
||||
|
||||
@@ -1220,7 +1242,7 @@ public class TMXMapEditor extends Editor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
public NPC getElementAt(int index) {
|
||||
return area.spawnGroup.get(index);
|
||||
}
|
||||
|
||||
@@ -1238,12 +1260,16 @@ public class TMXMapEditor extends Editor {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class TMXViewer extends JPanel implements Scrollable {
|
||||
|
||||
private static final long serialVersionUID = 2845032142029325865L;
|
||||
|
||||
|
||||
public tiled.core.MapObject highlighted = null;
|
||||
private MapRenderer renderer;
|
||||
private FieldUpdateListener listener;
|
||||
private TMXMap map;
|
||||
|
||||
public boolean resizing = false;
|
||||
public boolean moving = false;
|
||||
@@ -1253,7 +1279,8 @@ public class TMXMapEditor extends Editor {
|
||||
return new Rectangle(selectedMapObject.x + selectedMapObject.w - 16, selectedMapObject.y + selectedMapObject.h - 16, 16, 16);
|
||||
}
|
||||
|
||||
public Rectangle getMoveHitArea() {
|
||||
|
||||
public Rectangle getMoveHitArea() {
|
||||
//16x16 px square in the upper left corner of area
|
||||
return new Rectangle(selectedMapObject.x, selectedMapObject.y, 16, 16);
|
||||
}
|
||||
@@ -1266,6 +1293,7 @@ public class TMXMapEditor extends Editor {
|
||||
public TMXViewer(final TMXMap map, FieldUpdateListener listener) {
|
||||
this.listener = listener;
|
||||
renderer = createRenderer(map.tmxMap);
|
||||
this.map = map;
|
||||
|
||||
setPreferredSize(renderer.getMapSize());
|
||||
setOpaque(true);
|
||||
@@ -1379,20 +1407,34 @@ public class TMXMapEditor extends Editor {
|
||||
public void paintComponent(Graphics g) {
|
||||
final Graphics2D g2d = (Graphics2D) g.create();
|
||||
final Rectangle clip = g2d.getClipBounds();
|
||||
|
||||
|
||||
// Draw a gray background
|
||||
g2d.setPaint(new Color(100, 100, 100));
|
||||
g2d.fill(clip);
|
||||
|
||||
// Draw each tile map layer
|
||||
boolean paintSelected = false;
|
||||
for (tiled.core.MapLayer layer : ((TMXMap)target).tmxMap) {
|
||||
if (layer instanceof tiled.core.TileLayer && layer.isVisible()) {
|
||||
renderer.paintTileLayer(g2d, (tiled.core.TileLayer) layer);
|
||||
} else if (layer instanceof tiled.core.ObjectGroup && layer.isVisible()) {
|
||||
}
|
||||
}
|
||||
|
||||
if (map.colorFilter != null) {
|
||||
MapColorFilters.applyColorfilter(map.colorFilter, g2d);
|
||||
}
|
||||
|
||||
|
||||
// Draw each map object layer
|
||||
boolean paintSelected = false;
|
||||
for (tiled.core.MapLayer layer : ((TMXMap)target).tmxMap) {
|
||||
if (layer instanceof tiled.core.ObjectGroup && layer.isVisible()) {
|
||||
paintSelected |= paintObjectGroup(g2d, (tiled.core.ObjectGroup) layer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (paintSelected) {
|
||||
//TODO make this less ugly..... visually speaking.
|
||||
g2d.setColor(new Color(190, 20, 20));
|
||||
@@ -1464,7 +1506,7 @@ public class TMXMapEditor extends Editor {
|
||||
|
||||
}
|
||||
|
||||
public static class TMXMapSpritesheetsListModel implements ListModel {
|
||||
public static class TMXMapSpritesheetsListModel implements ListModel<Spritesheet> {
|
||||
|
||||
TMXMap map;
|
||||
|
||||
@@ -1478,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 --;
|
||||
@@ -1518,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");
|
||||
@@ -1663,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;
|
||||
@@ -1681,6 +1724,11 @@ public class TMXMapEditor extends Editor {
|
||||
modified = false;
|
||||
tmxViewer.revalidate();
|
||||
tmxViewer.repaint();
|
||||
} else if (source == activeForNewGame) {
|
||||
if (selectedLayer instanceof tiled.core.ObjectGroup) {
|
||||
map.getGroup((tiled.core.ObjectGroup) selectedLayer).active = activeForNewGame.isSelected();
|
||||
}
|
||||
modified = true;
|
||||
} else if (source == layerList) {
|
||||
modified = false;
|
||||
tmxViewer.revalidate();
|
||||
@@ -1690,6 +1738,9 @@ public class TMXMapEditor extends Editor {
|
||||
tmxViewer.revalidate();
|
||||
tmxViewer.repaint();
|
||||
} else if (source == areaField) {
|
||||
selectedMapObject.name = (String) value;
|
||||
groupObjectsListModel.objectChanged(selectedMapObject);
|
||||
} else if (source == spawngroupField) {
|
||||
if (selectedMapObject instanceof SpawnArea) {
|
||||
SpawnArea area = (SpawnArea)selectedMapObject;
|
||||
if (area.spawnGroup != null && !area.spawnGroup.isEmpty()) {
|
||||
@@ -1697,7 +1748,7 @@ public class TMXMapEditor extends Editor {
|
||||
npc.removeBacklink(map);
|
||||
}
|
||||
}
|
||||
area.name = (String) value;
|
||||
area.spawngroup_id = (String) value;
|
||||
selectedMapObject.link();
|
||||
npcList.setModel(new SpawnGroupNpcListModel(area));
|
||||
groupObjectsListModel.objectChanged(area);
|
||||
@@ -1705,10 +1756,6 @@ public class TMXMapEditor extends Editor {
|
||||
npcList.repaint();
|
||||
tmxViewer.revalidate();
|
||||
tmxViewer.repaint();
|
||||
} else if (selectedMapObject instanceof MapChange) {
|
||||
MapChange area = (MapChange) selectedMapObject;
|
||||
area.name = (String) value;
|
||||
groupObjectsListModel.objectChanged(area);
|
||||
}
|
||||
} else if (source == targetAreaCombo) {
|
||||
if (selectedMapObject instanceof MapChange) {
|
||||
@@ -1717,6 +1764,10 @@ public class TMXMapEditor extends Editor {
|
||||
}
|
||||
} else if (source == outsideBox) {
|
||||
map.outside = (Integer)value;
|
||||
} else if (source == colorFilterBox) {
|
||||
map.colorFilter = (TMXMap.ColorFilter) value;
|
||||
tmxViewer.revalidate();
|
||||
tmxViewer.repaint();
|
||||
} else if (source == droplistBox) {
|
||||
if (selectedMapObject instanceof ContainerArea) {
|
||||
ContainerArea area = (ContainerArea)selectedMapObject;
|
||||
@@ -1987,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);
|
||||
}
|
||||
@@ -2041,7 +2092,7 @@ public class TMXMapEditor extends Editor {
|
||||
public void paintComponent(Graphics g) {
|
||||
final Graphics2D g2d = (Graphics2D) g.create();
|
||||
final Rectangle clip = g2d.getClipBounds();
|
||||
|
||||
|
||||
// Draw a gray background
|
||||
g2d.setPaint(new Color(100, 100, 100));
|
||||
g2d.fill(clip);
|
||||
@@ -2064,6 +2115,11 @@ public class TMXMapEditor extends Editor {
|
||||
renderer.paintTileLayer(g2d, walkable);
|
||||
}
|
||||
|
||||
if (map.colorFilter != null) {
|
||||
MapColorFilters.applyColorfilter(map.colorFilter, g2d);
|
||||
}
|
||||
|
||||
|
||||
if (highlighted != null) {
|
||||
drawObject(highlighted, g2d, new Color(190, 20, 20));
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -10,12 +10,13 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Shape;
|
||||
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;
|
||||
@@ -44,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>();
|
||||
|
||||
@@ -86,6 +87,12 @@ public class WorldMapView extends JComponent implements Scrollable {
|
||||
// paintObjectGroup(g2, map, (tiled.core.ObjectGroup) layer);
|
||||
}
|
||||
}
|
||||
if (map.colorFilter != null) {
|
||||
Shape oldClip = g2.getClip();
|
||||
g2.setClip(0, 0, map.tmxMap.getWidth() * TILE_SIZE, map.tmxMap.getHeight() * TILE_SIZE);
|
||||
MapColorFilters.applyColorfilter(map.colorFilter, g2);
|
||||
g2.setClip(oldClip);
|
||||
}
|
||||
if (selected.contains(s)) {
|
||||
g2.drawRect(0, 0, map.tmxMap.getWidth() * TILE_SIZE, map.tmxMap.getHeight() * TILE_SIZE);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ItemsTableView extends ElementTableView {
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 32;
|
||||
return 33;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,32 +49,33 @@ public class ItemsTableView extends ElementTableView {
|
||||
case 3: return "Folder type"; //Source type (created, altered, source)
|
||||
case 4: return "Use type"; //Use type ("none", "use", or equip slot name).
|
||||
case 5: return "Category"; //Category id.
|
||||
case 6: return "Manually set price ?"; //Has manual price
|
||||
case 7: return "Price"; //Price
|
||||
case 8: return "On use/hit - HP min";
|
||||
case 9: return "On use/hit - HP max";
|
||||
case 10: return "On use/hit - AP min";
|
||||
case 11: return "On use/hit - AP max";
|
||||
case 12: return "On use/hit - # conditions";
|
||||
case 13: return "On kill - HP min";
|
||||
case 14: return "On kill - HP max";
|
||||
case 15: return "On kill - AP min";
|
||||
case 16: return "On kill - AP max";
|
||||
case 17: return "On kill - # conditions";
|
||||
case 18: return "AD min";
|
||||
case 19: return "AD max";
|
||||
case 20: return "Max HP";
|
||||
case 21: return "Max AP";
|
||||
case 22: return "Attack cost";
|
||||
case 23: return "AC";
|
||||
case 24: return "BC";
|
||||
case 25: return "DR";
|
||||
case 26: return "CS";
|
||||
case 27: return "CM";
|
||||
case 28: return "Move cost";
|
||||
case 29: return "Use cost";
|
||||
case 30: return "Reequip cost";
|
||||
case 31: return "# conditions";
|
||||
case 6: return "DisplayType"; //Display type (ordinary, rare, extraordinary...)
|
||||
case 7: return "Manually set price ?"; //Has manual price
|
||||
case 8: return "Price"; //Price
|
||||
case 9: return "On use/hit - HP min";
|
||||
case 10: return "On use/hit - HP max";
|
||||
case 11: return "On use/hit - AP min";
|
||||
case 12: return "On use/hit - AP max";
|
||||
case 13: return "On use/hit - # conditions";
|
||||
case 14: return "On kill - HP min";
|
||||
case 15: return "On kill - HP max";
|
||||
case 16: return "On kill - AP min";
|
||||
case 17: return "On kill - AP max";
|
||||
case 18: return "On kill - # conditions";
|
||||
case 19: return "AD min";
|
||||
case 20: return "AD max";
|
||||
case 21: return "Max HP";
|
||||
case 22: return "Max AP";
|
||||
case 23: return "Attack cost";
|
||||
case 24: return "AC";
|
||||
case 25: return "BC";
|
||||
case 26: return "DR";
|
||||
case 27: return "CS";
|
||||
case 28: return "CM";
|
||||
case 29: return "Move cost";
|
||||
case 30: return "Use cost";
|
||||
case 31: return "Reequip cost";
|
||||
case 32: return "# conditions";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -89,32 +90,33 @@ public class ItemsTableView extends ElementTableView {
|
||||
case 3: return String.class; //Source type (created, altered, source)
|
||||
case 4: return String.class; //Use type ("none", "use", or equip slot name).
|
||||
case 5: return String.class; //Category id.
|
||||
case 6: return Boolean.class; //Has manual price
|
||||
case 7: return Integer.class; //Price
|
||||
case 8: return Integer.class;//"On use/hit - HP min";
|
||||
case 9: return Integer.class;//"On use/hit - HP max";
|
||||
case 10: return Integer.class;//"On use/hit - AP min";
|
||||
case 11: return Integer.class;//"On use/hit - AP max";
|
||||
case 12: return Integer.class;//"On use/hit - # conditions";
|
||||
case 13: return Integer.class;//"On kill - HP min";
|
||||
case 14: return Integer.class;//"On kill - HP max";
|
||||
case 15: return Integer.class;//"On kill - AP min";
|
||||
case 16: return Integer.class;//"On kill - AP max";
|
||||
case 17: return Integer.class;//"On kill - # conditions";
|
||||
case 18: return Integer.class;//"AD min";
|
||||
case 19: return Integer.class;//"AD max";
|
||||
case 20: return Integer.class;//"Max HP";
|
||||
case 21: return Integer.class;//"Max AP";
|
||||
case 22: return Integer.class;//"Attack cost";
|
||||
case 23: return Integer.class;//"AC";
|
||||
case 24: return Integer.class;//"BC";
|
||||
case 25: return Integer.class;//"DR";
|
||||
case 26: return Integer.class;//"CS";
|
||||
case 27: return Double.class;//"CM";
|
||||
case 28: return Integer.class;//"Move cost";
|
||||
case 29: return Integer.class;//"Use cost";
|
||||
case 30: return Integer.class;//"Reequip cost";
|
||||
case 31: return Integer.class;//"# conditions";
|
||||
case 6: return String.class; //Display type (ordinary, rare, extraordinary...)
|
||||
case 7: return Boolean.class; //Has manual price
|
||||
case 8: return Integer.class; //Price
|
||||
case 9: return Integer.class;//"On use/hit - HP min";
|
||||
case 10: return Integer.class;//"On use/hit - HP max";
|
||||
case 11: return Integer.class;//"On use/hit - AP min";
|
||||
case 12: return Integer.class;//"On use/hit - AP max";
|
||||
case 13: return Integer.class;//"On use/hit - # conditions";
|
||||
case 14: return Integer.class;//"On kill - HP min";
|
||||
case 15: return Integer.class;//"On kill - HP max";
|
||||
case 16: return Integer.class;//"On kill - AP min";
|
||||
case 17: return Integer.class;//"On kill - AP max";
|
||||
case 18: return Integer.class;//"On kill - # conditions";
|
||||
case 19: return Integer.class;//"AD min";
|
||||
case 20: return Integer.class;//"AD max";
|
||||
case 21: return Integer.class;//"Max HP";
|
||||
case 22: return Integer.class;//"Max AP";
|
||||
case 23: return Integer.class;//"Attack cost";
|
||||
case 24: return Integer.class;//"AC";
|
||||
case 25: return Integer.class;//"BC";
|
||||
case 26: return Integer.class;//"DR";
|
||||
case 27: return Integer.class;//"CS";
|
||||
case 28: return Double.class;//"CM";
|
||||
case 29: return Integer.class;//"Move cost";
|
||||
case 30: return Integer.class;//"Use cost";
|
||||
case 31: return Integer.class;//"Reequip cost";
|
||||
case 32: return Integer.class;//"# conditions";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -144,15 +146,16 @@ public class ItemsTableView extends ElementTableView {
|
||||
if (item.category.action_type != ItemCategory.ActionType.equip) return item.category.action_type.toString();
|
||||
return item.category.slot.toString();
|
||||
case 5: return item.category != null ? item.category.id : (item.category_id != null ? item.category_id : null ); //Category id.
|
||||
case 6: return item.has_manual_price == null ? false : (item.has_manual_price == 1); //Has manual price
|
||||
case 7: //Price
|
||||
case 6: return item.display_type != null ? item.display_type.toString() : null; //Category id.
|
||||
case 7: return item.has_manual_price == null ? false : (item.has_manual_price == 1); //Has manual price
|
||||
case 8: //Price
|
||||
if (item.has_manual_price == null || item.has_manual_price != 1) return item.computePrice();
|
||||
return item.base_market_cost;
|
||||
case 8: return canUse ? (item.kill_effect != null ? item.kill_effect.hp_boost_min : null) : (item.hit_effect != null ? item.hit_effect.hp_boost_min : null);//"On use/hit - HP min";
|
||||
case 9: return canUse ? (item.kill_effect != null ? item.kill_effect.hp_boost_max : null) : (item.hit_effect != null ? item.hit_effect.hp_boost_max : null);//"On use/hit - HP max";
|
||||
case 10: return canUse ? (item.kill_effect != null ? item.kill_effect.ap_boost_min : null) : (item.hit_effect != null ? item.hit_effect.ap_boost_min : null);//"On use/hit - AP min";
|
||||
case 11: return canUse ? (item.kill_effect != null ? item.kill_effect.ap_boost_max : null) : (item.hit_effect != null ? item.hit_effect.ap_boost_max : null);//"On use/hit - AP max";
|
||||
case 12: //"On use/hit - # conditions";
|
||||
case 9: return canUse ? (item.kill_effect != null ? item.kill_effect.hp_boost_min : null) : (item.hit_effect != null ? item.hit_effect.hp_boost_min : null);//"On use/hit - HP min";
|
||||
case 10: return canUse ? (item.kill_effect != null ? item.kill_effect.hp_boost_max : null) : (item.hit_effect != null ? item.hit_effect.hp_boost_max : null);//"On use/hit - HP max";
|
||||
case 11: return canUse ? (item.kill_effect != null ? item.kill_effect.ap_boost_min : null) : (item.hit_effect != null ? item.hit_effect.ap_boost_min : null);//"On use/hit - AP min";
|
||||
case 12: return canUse ? (item.kill_effect != null ? item.kill_effect.ap_boost_max : null) : (item.hit_effect != null ? item.hit_effect.ap_boost_max : null);//"On use/hit - AP max";
|
||||
case 13: //"On use/hit - # conditions";
|
||||
if (canUse) {
|
||||
if (item.kill_effect != null && item.kill_effect.conditions_source != null) {
|
||||
return item.kill_effect.conditions_source.size();
|
||||
@@ -169,25 +172,25 @@ public class ItemsTableView extends ElementTableView {
|
||||
return val;
|
||||
}
|
||||
return null;
|
||||
case 13: return (!canUse && item.kill_effect != null) ? item.kill_effect.hp_boost_min : null;//"On kill - HP min";
|
||||
case 14: return (!canUse && item.kill_effect != null) ? item.kill_effect.hp_boost_max : null;//"On kill - HP max";
|
||||
case 15: return (!canUse && item.kill_effect != null) ? item.kill_effect.ap_boost_min : null;//"On kill - AP min";
|
||||
case 16: return (!canUse && item.kill_effect != null) ? item.kill_effect.ap_boost_max : null;//"On kill - AP max";
|
||||
case 17: return (!canUse && item.kill_effect != null && item.kill_effect.conditions_source != null) ? item.kill_effect.conditions_source.size() : null;//"On kill - # conditions";
|
||||
case 18: return (canEquip && item.equip_effect != null) ? item.equip_effect.damage_boost_min : null;//"AD min";
|
||||
case 19: return (canEquip && item.equip_effect != null) ? item.equip_effect.damage_boost_max : null;//"AD max";
|
||||
case 20: return (canEquip && item.equip_effect != null) ? item.equip_effect.max_hp_boost : null;//"Max HP";
|
||||
case 21: return (canEquip && item.equip_effect != null) ? item.equip_effect.max_ap_boost : null;//"Max AP";
|
||||
case 22: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_attack_cost : null;//"Attack cost";
|
||||
case 23: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_attack_chance : null;//"AC";
|
||||
case 24: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_block_chance : null;//"BC";
|
||||
case 25: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_damage_resistance : null;//"DR";
|
||||
case 26: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_critical_skill : null;//"CS";
|
||||
case 27: return (canEquip && item.equip_effect != null) ? item.equip_effect.critical_multiplier : null;//"CM";
|
||||
case 28: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_move_cost : null;//"Move cost";
|
||||
case 29: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_use_item_cost : null;//"Use cost";
|
||||
case 30: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_reequip_cost : null;//"Reequip cost";
|
||||
case 31: return (canEquip && item.equip_effect != null && item.equip_effect.conditions != null) ? item.equip_effect.conditions.size() : null;//"# conditions";
|
||||
case 14: return (!canUse && item.kill_effect != null) ? item.kill_effect.hp_boost_min : null;//"On kill - HP min";
|
||||
case 15: return (!canUse && item.kill_effect != null) ? item.kill_effect.hp_boost_max : null;//"On kill - HP max";
|
||||
case 16: return (!canUse && item.kill_effect != null) ? item.kill_effect.ap_boost_min : null;//"On kill - AP min";
|
||||
case 17: return (!canUse && item.kill_effect != null) ? item.kill_effect.ap_boost_max : null;//"On kill - AP max";
|
||||
case 18: return (!canUse && item.kill_effect != null && item.kill_effect.conditions_source != null) ? item.kill_effect.conditions_source.size() : null;//"On kill - # conditions";
|
||||
case 19: return (canEquip && item.equip_effect != null) ? item.equip_effect.damage_boost_min : null;//"AD min";
|
||||
case 20: return (canEquip && item.equip_effect != null) ? item.equip_effect.damage_boost_max : null;//"AD max";
|
||||
case 21: return (canEquip && item.equip_effect != null) ? item.equip_effect.max_hp_boost : null;//"Max HP";
|
||||
case 22: return (canEquip && item.equip_effect != null) ? item.equip_effect.max_ap_boost : null;//"Max AP";
|
||||
case 23: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_attack_cost : null;//"Attack cost";
|
||||
case 24: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_attack_chance : null;//"AC";
|
||||
case 25: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_block_chance : null;//"BC";
|
||||
case 26: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_damage_resistance : null;//"DR";
|
||||
case 27: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_critical_skill : null;//"CS";
|
||||
case 28: return (canEquip && item.equip_effect != null) ? item.equip_effect.critical_multiplier : null;//"CM";
|
||||
case 29: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_move_cost : null;//"Move cost";
|
||||
case 30: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_use_item_cost : null;//"Use cost";
|
||||
case 31: return (canEquip && item.equip_effect != null) ? item.equip_effect.increase_reequip_cost : null;//"Reequip cost";
|
||||
case 32: return (canEquip && item.equip_effect != null && item.equip_effect.conditions != null) ? item.equip_effect.conditions.size() : null;//"# conditions";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
124
src/com/gpl/rpg/atcontentstudio/ui/tools/MatrixComposite.java
Normal file
124
src/com/gpl/rpg/atcontentstudio/ui/tools/MatrixComposite.java
Normal file
@@ -0,0 +1,124 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui.tools;
|
||||
|
||||
import java.awt.Composite;
|
||||
import java.awt.CompositeContext;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.WritableRaster;
|
||||
|
||||
/**
|
||||
* This Composite emulates the behaviour of Android's ColorMatrixColorFilter,
|
||||
* except that you have to use this one a posteriori instead of a filtering paint.
|
||||
*
|
||||
* It applies a ColorMatrix to the destination pixels, regardless of potential "source" pixels.
|
||||
* Once created and activated through Graphics2D.setComposite(), just paint anything over the pixels you want "filtered".
|
||||
*
|
||||
* Works on a per-pixel basis, no sampling of surrounding pixels, or anything.
|
||||
*
|
||||
* @author pochat
|
||||
*
|
||||
*/
|
||||
public class MatrixComposite implements Composite {
|
||||
|
||||
|
||||
final float[] matrix = new float[20];
|
||||
|
||||
|
||||
/**
|
||||
* Dismisses the source pixels. Just paint it black, or white, it only affects the dest RGB with the following formulae.
|
||||
*
|
||||
* R' = a*R + b*G + c*B + d*A + e;
|
||||
* G' = f*R + g*G + h*B + i*A + j;
|
||||
* B' = k*R + l*G + m*B + n*A + o;
|
||||
* A' = p*R + q*G + r*B + s*A + t;
|
||||
*
|
||||
* @param matrix a flat float[20] array, giving the a..t values;
|
||||
*/
|
||||
public MatrixComposite(float[] matrix) {
|
||||
if (matrix.length != this.matrix.length) {
|
||||
throw new Error("MatrixComposite matrix must be of length "+this.matrix.length);
|
||||
}
|
||||
System.arraycopy(matrix, 0, this.matrix, 0, this.matrix.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeContext createContext(ColorModel srcColorModel,
|
||||
ColorModel dstColorModel, RenderingHints hints) {
|
||||
return new MatrixCompositeContext(this);
|
||||
}
|
||||
|
||||
class MatrixCompositeContext implements CompositeContext {
|
||||
|
||||
MatrixComposite composite;
|
||||
|
||||
public MatrixCompositeContext(MatrixComposite composite) {
|
||||
this.composite = composite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
|
||||
if (src.getSampleModel().getDataType() != DataBuffer.TYPE_INT ||
|
||||
dstIn.getSampleModel().getDataType() != DataBuffer.TYPE_INT ||
|
||||
dstOut.getSampleModel().getDataType() != DataBuffer.TYPE_INT) {
|
||||
throw new IllegalStateException(
|
||||
"Source and destination must store pixels as INT.");
|
||||
}
|
||||
|
||||
int width = Math.min(src.getWidth(), dstIn.getWidth());
|
||||
int height = Math.min(src.getHeight(), dstIn.getHeight());
|
||||
|
||||
float alpha = 1.0f;
|
||||
|
||||
int[] srcPixel = new int[4];
|
||||
int[] dstPixel = new int[4];
|
||||
int[] srcPixels = new int[width];
|
||||
int[] dstPixels = new int[width];
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
src.getDataElements(0, y, width, 1, srcPixels);
|
||||
dstIn.getDataElements(0, y, width, 1, dstPixels);
|
||||
for (int x = 0; x < width; x++) {
|
||||
// pixels are stored as INT_ARGB
|
||||
// our arrays are [R, G, B, A]
|
||||
int pixel = srcPixels[x];
|
||||
srcPixel[0] = (pixel >> 16) & 0xFF;
|
||||
srcPixel[1] = (pixel >> 8) & 0xFF;
|
||||
srcPixel[2] = (pixel ) & 0xFF;
|
||||
srcPixel[3] = (pixel >> 24) & 0xFF;
|
||||
|
||||
pixel = dstPixels[x];
|
||||
dstPixel[0] = (pixel >> 16) & 0xFF;
|
||||
dstPixel[1] = (pixel >> 8) & 0xFF;
|
||||
dstPixel[2] = (pixel ) & 0xFF;
|
||||
dstPixel[3] = (pixel >> 24) & 0xFF;
|
||||
|
||||
int[] result = applyMatrix(matrix, dstPixel);
|
||||
|
||||
// mixes the result with the opacity
|
||||
dstPixels[x] = ((int) (dstPixel[3] + (result[3] - dstPixel[3]) * alpha) & 0xFF) << 24 |
|
||||
((int) (dstPixel[0] + (result[0] - dstPixel[0]) * alpha) & 0xFF) << 16 |
|
||||
((int) (dstPixel[1] + (result[1] - dstPixel[1]) * alpha) & 0xFF) << 8 |
|
||||
(int) (dstPixel[2] + (result[2] - dstPixel[2]) * alpha) & 0xFF;
|
||||
}
|
||||
dstOut.setDataElements(0, y, width, 1, dstPixels);
|
||||
}
|
||||
}
|
||||
|
||||
private int[] applyMatrix(float[] matrix, int[] dstPixel) {
|
||||
int[] result = new int[4];
|
||||
result[0] = Math.max(0, Math.min(255, (int) (matrix[ 0] * dstPixel[0] + matrix[ 1] * dstPixel[1] + matrix[ 2] * dstPixel[2] + matrix[ 3] * dstPixel[3] + matrix[ 4]) ));
|
||||
result[1] = Math.max(0, Math.min(255, (int) (matrix[ 5] * dstPixel[0] + matrix[ 6] * dstPixel[1] + matrix[ 7] * dstPixel[2] + matrix[ 8] * dstPixel[3] + matrix[ 9]) ));
|
||||
result[2] = Math.max(0, Math.min(255, (int) (matrix[10] * dstPixel[0] + matrix[11] * dstPixel[1] + matrix[12] * dstPixel[2] + matrix[13] * dstPixel[3] + matrix[14]) ));
|
||||
result[3] = Math.max(0, Math.min(255, (int) (matrix[15] * dstPixel[0] + matrix[16] * dstPixel[1] + matrix[17] * dstPixel[2] + matrix[18] * dstPixel[3] + matrix[19]) ));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
296
src/prefuse/data/FilteredSpanningTree.java
Normal file
296
src/prefuse/data/FilteredSpanningTree.java
Normal 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.");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user