mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-30 08:13:25 +01:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a70f87897 | ||
|
|
c07fb4ddf3 | ||
|
|
1458fb0aaa | ||
|
|
57b8209b26 | ||
|
|
a7224755ff | ||
|
|
e97168c62e | ||
|
|
1e8dd405c3 | ||
|
|
830e9de56b | ||
|
|
2a06002b51 | ||
|
|
84b1b6a7eb | ||
|
|
f924c481f8 |
@@ -29,6 +29,7 @@
|
|||||||
package tiled.core;
|
package tiled.core;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +37,7 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public class Tile
|
public class Tile
|
||||||
{
|
{
|
||||||
private Image image;
|
private BufferedImage image;
|
||||||
private int id = -1;
|
private int id = -1;
|
||||||
private Properties properties;
|
private Properties properties;
|
||||||
private TileSet tileset;
|
private TileSet tileset;
|
||||||
@@ -76,7 +77,7 @@ public class Tile
|
|||||||
*
|
*
|
||||||
* @param i the new image of the tile
|
* @param i the new image of the tile
|
||||||
*/
|
*/
|
||||||
public void setImage(Image i) {
|
public void setImage(BufferedImage i) {
|
||||||
image = i;
|
image = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +134,7 @@ public class Tile
|
|||||||
*
|
*
|
||||||
* @return Image
|
* @return Image
|
||||||
*/
|
*/
|
||||||
public Image getImage() {
|
public BufferedImage getImage() {
|
||||||
if (tileset != null && tileset.sheet != null) return tileset.sheet.getImage(getId());
|
if (tileset != null && tileset.sheet != null) return tileset.sheet.getImage(getId());
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public class TileSet implements Iterable<Tile>
|
|||||||
tilesPerRow = basicTileCutter.getTilesPerRow();
|
tilesPerRow = basicTileCutter.getTilesPerRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
Image tileImage = cutter.getNextTile();
|
BufferedImage tileImage = cutter.getNextTile();
|
||||||
while (tileImage != null) {
|
while (tileImage != null) {
|
||||||
Tile tile = new Tile();
|
Tile tile = new Tile();
|
||||||
tile.setImage(tileImage);
|
tile.setImage(tileImage);
|
||||||
@@ -220,7 +220,7 @@ public class TileSet implements Iterable<Tile>
|
|||||||
tileDimensions = new Rectangle(tileCutter.getTileDimensions());
|
tileDimensions = new Rectangle(tileCutter.getTileDimensions());
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
Image tileImage = tileCutter.getNextTile();
|
BufferedImage tileImage = tileCutter.getNextTile();
|
||||||
while (tileImage != null) {
|
while (tileImage != null) {
|
||||||
Tile tile = getTile(id);
|
Tile tile = getTile(id);
|
||||||
tile.setImage(tileImage);
|
tile.setImage(tileImage);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ package tiled.io;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -223,9 +224,9 @@ public class TMXMapReader
|
|||||||
return o;
|
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");
|
String source = getAttributeValue(t, "source");
|
||||||
|
|
||||||
@@ -253,7 +254,7 @@ public class TMXMapReader
|
|||||||
// size, somehow makes drawing of the tiles a lot
|
// size, somehow makes drawing of the tiles a lot
|
||||||
// faster on various systems (seen on Linux, Windows
|
// faster on various systems (seen on Linux, Windows
|
||||||
// and MacOS X).
|
// and MacOS X).
|
||||||
img = img.getScaledInstance(
|
img = (BufferedImage) img.getScaledInstance(
|
||||||
img.getWidth(null), img.getHeight(null),
|
img.getWidth(null), img.getHeight(null),
|
||||||
Image.SCALE_FAST);
|
Image.SCALE_FAST);
|
||||||
}
|
}
|
||||||
@@ -534,7 +535,7 @@ public class TMXMapReader
|
|||||||
Node child = children.item(i);
|
Node child = children.item(i);
|
||||||
if ("image".equalsIgnoreCase(child.getNodeName())) {
|
if ("image".equalsIgnoreCase(child.getNodeName())) {
|
||||||
int id = getAttribute(child, "id", -1);
|
int id = getAttribute(child, "id", -1);
|
||||||
Image img = unmarshalImage(child, baseDir);
|
BufferedImage img = unmarshalImage(child, baseDir);
|
||||||
tile.setImage(img);
|
tile.setImage(img);
|
||||||
} else if ("animation".equalsIgnoreCase(child.getNodeName())) {
|
} else if ("animation".equalsIgnoreCase(child.getNodeName())) {
|
||||||
// TODO: fill this in once TMXMapWriter is complete
|
// TODO: fill this in once TMXMapWriter is complete
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class BasicTileCutter implements TileCutter
|
|||||||
this.image = image;
|
this.image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image getNextTile() {
|
public BufferedImage getNextTile() {
|
||||||
if (nextY + tileHeight + tileMargin <= image.getHeight()) {
|
if (nextY + tileHeight + tileMargin <= image.getHeight()) {
|
||||||
BufferedImage tile =
|
BufferedImage tile =
|
||||||
image.getSubimage(nextX, nextY, tileWidth, tileHeight);
|
image.getSubimage(nextX, nextY, tileWidth, tileHeight);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public interface TileCutter
|
|||||||
* @return the next tile image, or <code>null</code> when no more tile
|
* @return the next tile image, or <code>null</code> when no more tile
|
||||||
* images are available
|
* images are available
|
||||||
*/
|
*/
|
||||||
public Image getNextTile();
|
public BufferedImage getNextTile();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the tile cutter so that the next call to <code>getNextTile</code>
|
* Resets the tile cutter so that the next call to <code>getNextTile</code>
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ package tiled.view;
|
|||||||
import tiled.core.TileLayer;
|
import tiled.core.TileLayer;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImageOp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface defining methods to render a map.
|
* An interface defining methods to render a map.
|
||||||
@@ -50,5 +51,5 @@ public interface MapRenderer
|
|||||||
* @param g the graphics context to paint to
|
* @param g the graphics context to paint to
|
||||||
* @param layer the layer to paint
|
* @param layer the layer to paint
|
||||||
*/
|
*/
|
||||||
public void paintTileLayer(Graphics2D g, TileLayer layer);
|
public void paintTileLayer(Graphics2D g, TileLayer layer, BufferedImageOp filter);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ import tiled.core.Tile;
|
|||||||
import tiled.core.TileLayer;
|
import tiled.core.TileLayer;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.awt.image.BufferedImageOp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The orthogonal map renderer. This is the most basic map renderer, dealing
|
* The orthogonal map renderer. This is the most basic map renderer, dealing
|
||||||
@@ -51,7 +53,7 @@ public class OrthogonalRenderer implements MapRenderer
|
|||||||
map.getHeight() * map.getTileHeight());
|
map.getHeight() * map.getTileHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paintTileLayer(Graphics2D g, TileLayer layer) {
|
public void paintTileLayer(Graphics2D g, TileLayer layer, BufferedImageOp filter ) {
|
||||||
final Rectangle clip = g.getClipBounds();
|
final Rectangle clip = g.getClipBounds();
|
||||||
final int tileWidth = map.getTileWidth();
|
final int tileWidth = map.getTileWidth();
|
||||||
final int tileHeight = map.getTileHeight();
|
final int tileHeight = map.getTileHeight();
|
||||||
@@ -74,15 +76,17 @@ public class OrthogonalRenderer implements MapRenderer
|
|||||||
final Tile tile = layer.getTileAt(x, y);
|
final Tile tile = layer.getTileAt(x, y);
|
||||||
if (tile == null)
|
if (tile == null)
|
||||||
continue;
|
continue;
|
||||||
final Image image = tile.getImage();
|
final BufferedImage image = tile.getImage();
|
||||||
if (image == null)
|
if (image == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g.drawImage(
|
g.drawImage(
|
||||||
image,
|
image,
|
||||||
|
filter,
|
||||||
x * tileWidth,
|
x * tileWidth,
|
||||||
(y + 1) * tileHeight - image.getHeight(null),
|
(y + 1) * tileHeight - image.getHeight(null));
|
||||||
null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.2.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.4.7.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
|
#!/bin/bash
|
||||||
java -Xmx512M -cp lib/AndorsTrainer_v0.1.2.jar:lib/ATCS_v0.4.2.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.4.7.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.1.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.4.6.jar;lib\jide-oss.jar;lib\ui.jar;lib\junit-4.10.jar;lib\json_simple-1.1.jar;lib\rsyntaxtextarea.jar;lib\prefuse.jar;lib\AndorsTrainer_v0.1.2.jar;lib\bsh-2.0b4.jar" com.gpl.rpg.atcontentstudio.ATContentStudio
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
!include MUI2.nsh
|
!include MUI2.nsh
|
||||||
|
|
||||||
!define VERSION "0.4.2"
|
!define VERSION "0.4.7"
|
||||||
!define JAVA_BIN "java"
|
!define JAVA_BIN "java"
|
||||||
|
|
||||||
Name "Andor's Trail Content Studio v${VERSION}"
|
Name "Andor's Trail Content Studio v${VERSION}"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector;
|
|||||||
public class ATContentStudio {
|
public class ATContentStudio {
|
||||||
|
|
||||||
public static final String APP_NAME = "Andor's Trail Content Studio";
|
public static final String APP_NAME = "Andor's Trail Content Studio";
|
||||||
public static final String APP_VERSION = "v0.4.2";
|
public static final String APP_VERSION = "v0.4.7";
|
||||||
|
|
||||||
public static boolean STARTED = false;
|
public static boolean STARTED = false;
|
||||||
public static StudioFrame frame = null;
|
public static StudioFrame frame = null;
|
||||||
|
|||||||
@@ -2,13 +2,29 @@ package com.gpl.rpg.atcontentstudio.model;
|
|||||||
|
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.Project.ResourceSet;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||||
import com.gpl.rpg.atcontentstudio.model.maps.Worldmap;
|
import com.gpl.rpg.atcontentstudio.model.maps.Worldmap;
|
||||||
@@ -21,6 +37,9 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = -1512979360971918158L;
|
private static final long serialVersionUID = -1512979360971918158L;
|
||||||
|
|
||||||
|
public static final String DEFAULT_REL_PATH_FOR_GAME_RESOURCE = "res"+File.separator+"values"+File.separator+"loadresources.xml";
|
||||||
|
public static final String DEFAULT_REL_PATH_FOR_DEBUG_RESOURCE = "res"+File.separator+"values"+File.separator+"loadresources_debug.xml";
|
||||||
|
|
||||||
public transient GameDataSet gameData;
|
public transient GameDataSet gameData;
|
||||||
public transient TMXMapSet gameMaps;
|
public transient TMXMapSet gameMaps;
|
||||||
public transient SpriteSheetSet gameSprites;
|
public transient SpriteSheetSet gameSprites;
|
||||||
@@ -39,6 +58,8 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
|||||||
|
|
||||||
public transient Project parent = null;
|
public transient Project parent = null;
|
||||||
|
|
||||||
|
public transient Map<String, List<String>> referencedSourceFiles = null;
|
||||||
|
|
||||||
public GameSource(File folder, Project parent) {
|
public GameSource(File folder, Project parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.baseFolder = folder;
|
this.baseFolder = folder;
|
||||||
@@ -59,6 +80,12 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initData() {
|
public void initData() {
|
||||||
|
if (type == Type.source) {
|
||||||
|
if (parent.sourceSetToUse == ResourceSet.gameData || parent.sourceSetToUse == ResourceSet.debugData) {
|
||||||
|
referencedSourceFiles = new LinkedHashMap<String, List<String>>();
|
||||||
|
readResourceList();
|
||||||
|
}
|
||||||
|
}
|
||||||
this.gameData = new GameDataSet(this);
|
this.gameData = new GameDataSet(this);
|
||||||
this.gameMaps = new TMXMapSet(this);
|
this.gameMaps = new TMXMapSet(this);
|
||||||
this.gameSprites = new SpriteSheetSet(this);
|
this.gameSprites = new SpriteSheetSet(this);
|
||||||
@@ -70,6 +97,58 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
|||||||
v.add(worldmap);
|
v.add(worldmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void readResourceList() {
|
||||||
|
File xmlFile = null;
|
||||||
|
if (parent.sourceSetToUse == ResourceSet.gameData) {
|
||||||
|
xmlFile = new File(baseFolder, DEFAULT_REL_PATH_FOR_GAME_RESOURCE);
|
||||||
|
} else if (parent.sourceSetToUse == ResourceSet.debugData) {
|
||||||
|
xmlFile = new File(baseFolder, DEFAULT_REL_PATH_FOR_DEBUG_RESOURCE);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!xmlFile.exists()) return;
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
Document doc;
|
||||||
|
try {
|
||||||
|
factory.setIgnoringComments(true);
|
||||||
|
factory.setIgnoringElementContentWhitespace(true);
|
||||||
|
factory.setExpandEntityReferences(false);
|
||||||
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
|
InputSource insrc = new InputSource(new FileInputStream(xmlFile));
|
||||||
|
// insrc.setSystemId("http://worldmap/");
|
||||||
|
insrc.setEncoding("UTF-8");
|
||||||
|
doc = builder.parse(insrc);
|
||||||
|
|
||||||
|
Element root = (Element) doc.getElementsByTagName("resources").item(0);
|
||||||
|
if (root != null) {
|
||||||
|
NodeList arraysList = root.getElementsByTagName("array");
|
||||||
|
if (arraysList != null) {
|
||||||
|
for (int i = 0; i < arraysList.getLength(); i++) {
|
||||||
|
Element arrayNode = (Element) arraysList.item(i);
|
||||||
|
String name = arrayNode.getAttribute("name");
|
||||||
|
List<String> arrayContents = new LinkedList<String>();
|
||||||
|
NodeList arrayItems = arrayNode.getElementsByTagName("item");
|
||||||
|
if (arrayItems != null) {
|
||||||
|
for (int j = 0; j < arrayItems.getLength(); j++) {
|
||||||
|
arrayContents.add(((Element)arrayItems.item(j)).getTextContent());
|
||||||
|
}
|
||||||
|
referencedSourceFiles.put(name, arrayContents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SAXException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enumeration<ProjectTreeNode> children() {
|
public Enumeration<ProjectTreeNode> children() {
|
||||||
return v.getNonEmptyElements();
|
return v.getNonEmptyElements();
|
||||||
|
|||||||
@@ -73,10 +73,19 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
public transient Workspace parent;
|
public transient Workspace parent;
|
||||||
|
|
||||||
public Properties knownSpritesheetsProperties = null;
|
public Properties knownSpritesheetsProperties = null;
|
||||||
|
|
||||||
|
public static enum ResourceSet {
|
||||||
|
gameData,
|
||||||
|
debugData,
|
||||||
|
allFiles
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceSet sourceSetToUse = ResourceSet.allFiles;
|
||||||
|
|
||||||
public Project(Workspace w, String name, File source) {
|
public Project(Workspace w, String name, File source, ResourceSet sourceSet) {
|
||||||
this.parent = w;
|
this.parent = w;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.sourceSetToUse = sourceSet;
|
||||||
|
|
||||||
//CREATE PROJECT
|
//CREATE PROJECT
|
||||||
baseFolder = new File(w.baseFolder, name+File.separator);
|
baseFolder = new File(w.baseFolder, name+File.separator);
|
||||||
@@ -220,6 +229,10 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sourceSetToUse == null) {
|
||||||
|
sourceSetToUse = ResourceSet.allFiles;
|
||||||
|
}
|
||||||
|
|
||||||
// long l = new Date().getTime();
|
// long l = new Date().getTime();
|
||||||
baseContent.refreshTransients(this);
|
baseContent.refreshTransients(this);
|
||||||
// l = new Date().getTime() - l;
|
// l = new Date().getTime() - l;
|
||||||
@@ -477,6 +490,21 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getItemCountIncludingAltered() {
|
||||||
|
return createdContent.gameData.items.size() + alteredContent.gameData.items.size() + baseContent.gameData.items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItemIncludingAltered(int index) {
|
||||||
|
if (index < createdContent.gameData.items.size()) {
|
||||||
|
return createdContent.gameData.items.get(index);
|
||||||
|
} else if (index < createdContent.gameData.items.size() + alteredContent.gameData.items.size()){
|
||||||
|
return alteredContent.gameData.items.get(index - createdContent.gameData.items.size());
|
||||||
|
} else if (index < getItemCountIncludingAltered()) {
|
||||||
|
return baseContent.gameData.items.get(index - (createdContent.gameData.items.size() + alteredContent.gameData.items.size()));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public int getItemIndex(Item item) {
|
public int getItemIndex(Item item) {
|
||||||
if (item.getDataType() == GameSource.Type.created) {
|
if (item.getDataType() == GameSource.Type.created) {
|
||||||
return createdContent.gameData.items.getIndex(item);
|
return createdContent.gameData.items.getIndex(item);
|
||||||
@@ -542,6 +570,21 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNPCCountIncludingAltered() {
|
||||||
|
return createdContent.gameData.npcs.size() + alteredContent.gameData.npcs.size() + baseContent.gameData.npcs.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NPC getNPCIncludingAltered(int index) {
|
||||||
|
if (index < createdContent.gameData.npcs.size()) {
|
||||||
|
return createdContent.gameData.npcs.get(index);
|
||||||
|
} else if (index < createdContent.gameData.npcs.size() + alteredContent.gameData.npcs.size()){
|
||||||
|
return alteredContent.gameData.npcs.get(index - createdContent.gameData.npcs.size());
|
||||||
|
} else if (index < getNPCCountIncludingAltered()) {
|
||||||
|
return baseContent.gameData.npcs.get(index - (createdContent.gameData.npcs.size() + alteredContent.gameData.npcs.size()));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public int getNPCIndex(NPC npc) {
|
public int getNPCIndex(NPC npc) {
|
||||||
if (npc.getDataType() == GameSource.Type.created) {
|
if (npc.getDataType() == GameSource.Type.created) {
|
||||||
return createdContent.gameData.npcs.getIndex(npc);
|
return createdContent.gameData.npcs.getIndex(npc);
|
||||||
@@ -754,13 +797,13 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
existingNode.getBacklinks().clear();
|
existingNode.getBacklinks().clear();
|
||||||
node.writable = true;
|
node.writable = true;
|
||||||
node.state = GameDataElement.State.created;
|
|
||||||
alteredContent.gameData.addElement(node);
|
alteredContent.gameData.addElement(node);
|
||||||
node.link();
|
node.link();
|
||||||
|
node.state = GameDataElement.State.created;
|
||||||
} else {
|
} else {
|
||||||
createdContent.gameData.addElement(node);
|
createdContent.gameData.addElement(node);
|
||||||
node.state = GameDataElement.State.created;
|
|
||||||
node.link();
|
node.link();
|
||||||
|
node.state = GameDataElement.State.created;
|
||||||
}
|
}
|
||||||
fireElementAdded(node, getNodeIndex(node));
|
fireElementAdded(node, getNodeIndex(node));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class Workspace implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void createProject(final String projectName, final File gameSourceFolder) {
|
public static void createProject(final String projectName, final File gameSourceFolder, final Project.ResourceSet sourceSet) {
|
||||||
WorkerDialog.showTaskMessage("Creating project "+projectName+"...", ATContentStudio.frame, new Runnable() {
|
WorkerDialog.showTaskMessage("Creating project "+projectName+"...", ATContentStudio.frame, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -154,7 +154,7 @@ public class Workspace implements ProjectTreeNode, Serializable {
|
|||||||
Notification.addError("A project named "+projectName+" already exists in this workspace.");
|
Notification.addError("A project named "+projectName+" already exists in this workspace.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Project p = new Project(activeWorkspace, projectName, gameSourceFolder);
|
Project p = new Project(activeWorkspace, projectName, gameSourceFolder, sourceSet);
|
||||||
activeWorkspace.projects.add(p);
|
activeWorkspace.projects.add(p);
|
||||||
activeWorkspace.projectsName.add(projectName);
|
activeWorkspace.projectsName.add(projectName);
|
||||||
activeWorkspace.projectsOpenByName.put(projectName, p.open);
|
activeWorkspace.projectsOpenByName.put(projectName, p.open);
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ public class Dialogue extends JSONElement {
|
|||||||
spawnAll,
|
spawnAll,
|
||||||
removeSpawnArea,
|
removeSpawnArea,
|
||||||
deactivateSpawnArea,
|
deactivateSpawnArea,
|
||||||
activateMapChangeArea,
|
activateMapObjectGroup,
|
||||||
deactivateMapChangeArea
|
deactivateMapObjectGroup
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,8 +242,8 @@ public class Dialogue extends JSONElement {
|
|||||||
for (Reward reward : rewards) {
|
for (Reward reward : rewards) {
|
||||||
if (reward.reward_obj_id != null) {
|
if (reward.reward_obj_id != null) {
|
||||||
switch (reward.type) {
|
switch (reward.type) {
|
||||||
case activateMapChangeArea:
|
case activateMapObjectGroup:
|
||||||
case deactivateMapChangeArea:
|
case deactivateMapObjectGroup:
|
||||||
case spawnAll:
|
case spawnAll:
|
||||||
case removeSpawnArea:
|
case removeSpawnArea:
|
||||||
case deactivateSpawnArea:
|
case deactivateSpawnArea:
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
|||||||
dataToSave.add(element.toJson());
|
dataToSave.add(element.toJson());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dataToSave.isEmpty()) {
|
if (dataToSave.isEmpty() && jsonFile.exists()) {
|
||||||
if (jsonFile.delete()) {
|
if (jsonFile.delete()) {
|
||||||
Notification.addSuccess("File "+jsonFile.getAbsolutePath()+" deleted.");
|
Notification.addSuccess("File "+jsonFile.getAbsolutePath()+" deleted.");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.gpl.rpg.atcontentstudio.Notification;
|
|||||||
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
import com.gpl.rpg.atcontentstudio.model.GameSource;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
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.ProjectTreeNode;
|
||||||
import com.gpl.rpg.atcontentstudio.model.SavedSlotCollection;
|
import com.gpl.rpg.atcontentstudio.model.SavedSlotCollection;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
@@ -25,6 +26,17 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
|||||||
public static final String DEFAULT_REL_PATH_IN_SOURCE = "res"+File.separator+"raw"+File.separator;
|
public static final String DEFAULT_REL_PATH_IN_SOURCE = "res"+File.separator+"raw"+File.separator;
|
||||||
public static final String DEFAULT_REL_PATH_IN_PROJECT = "json"+File.separator;
|
public static final String DEFAULT_REL_PATH_IN_PROJECT = "json"+File.separator;
|
||||||
|
|
||||||
|
public static final String GAME_AC_ARRAY_NAME = "loadresource_actorconditions";
|
||||||
|
public static final String GAME_DIALOGUES_ARRAY_NAME = "loadresource_conversationlists";
|
||||||
|
public static final String GAME_DROPLISTS_ARRAY_NAME = "loadresource_droplists";
|
||||||
|
public static final String GAME_ITEMS_ARRAY_NAME = "loadresource_items";
|
||||||
|
public static final String GAME_ITEMCAT_ARRAY_NAME = "loadresource_itemcategories";
|
||||||
|
public static final String GAME_NPC_ARRAY_NAME = "loadresource_monsters";
|
||||||
|
public static final String GAME_QUESTS_ARRAY_NAME = "loadresource_quests";
|
||||||
|
public static final String DEBUG_SUFFIX = "_debug";
|
||||||
|
public static final String RESOURCE_PREFIX = "@raw/";
|
||||||
|
public static final String FILENAME_SUFFIX = ".json";
|
||||||
|
|
||||||
public File baseFolder;
|
public File baseFolder;
|
||||||
|
|
||||||
public GameDataCategory<ActorCondition> actorConditions;
|
public GameDataCategory<ActorCondition> actorConditions;
|
||||||
@@ -67,7 +79,87 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
|||||||
v.add(quests);
|
v.add(quests);
|
||||||
|
|
||||||
//Start parsing to populate categories' content.
|
//Start parsing to populate categories' content.
|
||||||
if (parent.type != GameSource.Type.referenced) {
|
if (parent.type == GameSource.Type.source && (parent.parent.sourceSetToUse == ResourceSet.debugData || parent.parent.sourceSetToUse == ResourceSet.gameData)) {
|
||||||
|
String suffix = (parent.parent.sourceSetToUse == ResourceSet.debugData) ? DEBUG_SUFFIX : "";
|
||||||
|
|
||||||
|
if (parent.referencedSourceFiles.get(GAME_AC_ARRAY_NAME+suffix) != null) {
|
||||||
|
for (String resource : parent.referencedSourceFiles.get(GAME_AC_ARRAY_NAME+suffix)) {
|
||||||
|
File f = new File(baseFolder, resource.replaceAll(RESOURCE_PREFIX, "")+FILENAME_SUFFIX);
|
||||||
|
if (f.exists()) {
|
||||||
|
ActorCondition.fromJson(f, actorConditions);
|
||||||
|
} else {
|
||||||
|
Notification.addWarn("Unable to locate resource "+resource+" in the game source for project "+getProject().name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent.referencedSourceFiles.get(GAME_DIALOGUES_ARRAY_NAME+suffix) != null) {
|
||||||
|
for (String resource : parent.referencedSourceFiles.get(GAME_DIALOGUES_ARRAY_NAME+suffix)) {
|
||||||
|
File f = new File(baseFolder, resource.replaceAll(RESOURCE_PREFIX, "")+FILENAME_SUFFIX);
|
||||||
|
if (f.exists()) {
|
||||||
|
Dialogue.fromJson(f, dialogues);
|
||||||
|
} else {
|
||||||
|
Notification.addWarn("Unable to locate resource "+resource+" in the game source for project "+getProject().name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent.referencedSourceFiles.get(GAME_DROPLISTS_ARRAY_NAME+suffix) != null) {
|
||||||
|
for (String resource : parent.referencedSourceFiles.get(GAME_DROPLISTS_ARRAY_NAME+suffix)) {
|
||||||
|
File f = new File(baseFolder, resource.replaceAll(RESOURCE_PREFIX, "")+FILENAME_SUFFIX);
|
||||||
|
if (f.exists()) {
|
||||||
|
Droplist.fromJson(f, droplists);
|
||||||
|
} else {
|
||||||
|
Notification.addWarn("Unable to locate resource "+resource+" in the game source for project "+getProject().name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent.referencedSourceFiles.get(GAME_ITEMS_ARRAY_NAME+suffix) != null) {
|
||||||
|
for (String resource : parent.referencedSourceFiles.get(GAME_ITEMS_ARRAY_NAME+suffix)) {
|
||||||
|
File f = new File(baseFolder, resource.replaceAll(RESOURCE_PREFIX, "")+FILENAME_SUFFIX);
|
||||||
|
if (f.exists()) {
|
||||||
|
Item.fromJson(f, items);
|
||||||
|
} else {
|
||||||
|
Notification.addWarn("Unable to locate resource "+resource+" in the game source for project "+getProject().name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent.referencedSourceFiles.get(GAME_ITEMCAT_ARRAY_NAME+suffix) != null) {
|
||||||
|
for (String resource : parent.referencedSourceFiles.get(GAME_ITEMCAT_ARRAY_NAME+suffix)) {
|
||||||
|
File f = new File(baseFolder, resource.replaceAll(RESOURCE_PREFIX, "")+FILENAME_SUFFIX);
|
||||||
|
if (f.exists()) {
|
||||||
|
ItemCategory.fromJson(f, itemCategories);
|
||||||
|
} else {
|
||||||
|
Notification.addWarn("Unable to locate resource "+resource+" in the game source for project "+getProject().name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent.referencedSourceFiles.get(GAME_NPC_ARRAY_NAME+suffix) != null) {
|
||||||
|
for (String resource : parent.referencedSourceFiles.get(GAME_NPC_ARRAY_NAME+suffix)) {
|
||||||
|
File f = new File(baseFolder, resource.replaceAll(RESOURCE_PREFIX, "")+FILENAME_SUFFIX);
|
||||||
|
if (f.exists()) {
|
||||||
|
NPC.fromJson(f, npcs);
|
||||||
|
} else {
|
||||||
|
Notification.addWarn("Unable to locate resource "+resource+" in the game source for project "+getProject().name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent.referencedSourceFiles.get(GAME_QUESTS_ARRAY_NAME+suffix) != null) {
|
||||||
|
for (String resource : parent.referencedSourceFiles.get(GAME_QUESTS_ARRAY_NAME+suffix)) {
|
||||||
|
File f = new File(baseFolder, resource.replaceAll(RESOURCE_PREFIX, "")+FILENAME_SUFFIX);
|
||||||
|
if (f.exists()) {
|
||||||
|
Quest.fromJson(f, quests);
|
||||||
|
} else {
|
||||||
|
Notification.addWarn("Unable to locate resource "+resource+" in the game source for project "+getProject().name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (parent.type != GameSource.Type.referenced) {
|
||||||
for (File f : baseFolder.listFiles()) {
|
for (File f : baseFolder.listFiles()) {
|
||||||
if (f.getName().startsWith("actorconditions_")) {
|
if (f.getName().startsWith("actorconditions_")) {
|
||||||
ActorCondition.fromJson(f, actorConditions);
|
ActorCondition.fromJson(f, actorConditions);
|
||||||
|
|||||||
@@ -496,6 +496,8 @@ public class Item extends JSONElement {
|
|||||||
itemJson.put("id", this.id);
|
itemJson.put("id", this.id);
|
||||||
if (this.icon_id != null) itemJson.put("iconID", this.icon_id);
|
if (this.icon_id != null) itemJson.put("iconID", this.icon_id);
|
||||||
if (this.name != null) itemJson.put("name", this.name);
|
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.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.base_market_cost != null) itemJson.put("baseMarketCost", this.base_market_cost);
|
||||||
if (this.category != null) {
|
if (this.category != null) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class KeyArea extends MapObject {
|
|||||||
oldSchoolRequirement = false;
|
oldSchoolRequirement = false;
|
||||||
}
|
}
|
||||||
requirement = new Requirement();
|
requirement = new Requirement();
|
||||||
requirement.type = Requirement.RequirementType.valueOf(requireType);
|
if (requireType != null) requirement.type = Requirement.RequirementType.valueOf(requireType);
|
||||||
requirement.required_obj_id = requireId;
|
requirement.required_obj_id = requireId;
|
||||||
if (requireValue != null) requirement.required_value = Integer.parseInt(requireValue);
|
if (requireValue != null) requirement.required_value = Integer.parseInt(requireValue);
|
||||||
requirement.state = GameDataElement.State.parsed;
|
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)) {
|
if (oldSchoolRequirement && Requirement.RequirementType.questProgress.equals(requirement.type) && (requirement.negated == null || !requirement.negated)) {
|
||||||
tmxObject.setName(requirement.required_obj_id+":"+Integer.toString(requirement.required_value));
|
tmxObject.setName(requirement.required_obj_id+":"+Integer.toString(requirement.required_value));
|
||||||
} else {
|
} else {
|
||||||
tmxObject.getProperties().setProperty("requireType", requirement.type.toString());
|
if (requirement.type != null) {
|
||||||
|
tmxObject.getProperties().setProperty("requireType", requirement.type.toString());
|
||||||
|
}
|
||||||
if (requirement.required_obj != null) {
|
if (requirement.required_obj != null) {
|
||||||
tmxObject.getProperties().setProperty("requireId", requirement.required_obj.id);
|
tmxObject.getProperties().setProperty("requireId", requirement.required_obj.id);
|
||||||
} else if (requirement.required_obj_id != null) {
|
} else if (requirement.required_obj_id != null) {
|
||||||
|
|||||||
@@ -13,12 +13,18 @@ public class MapObjectGroup {
|
|||||||
public String name;
|
public String name;
|
||||||
public boolean visible;
|
public boolean visible;
|
||||||
public List<MapObject> mapObjects = new ArrayList<MapObject>();
|
public List<MapObject> mapObjects = new ArrayList<MapObject>();
|
||||||
|
public Boolean active;
|
||||||
|
|
||||||
public MapObjectGroup(tiled.core.ObjectGroup layer, TMXMap map) {
|
public MapObjectGroup(tiled.core.ObjectGroup layer, TMXMap map) {
|
||||||
this.tmxGroup = layer;
|
this.tmxGroup = layer;
|
||||||
this.name = layer.getName();
|
this.name = layer.getName();
|
||||||
this.visible = layer.isVisible();
|
this.visible = layer.isVisible();
|
||||||
this.parentMap = map;
|
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()) {
|
for (tiled.core.MapObject obj : layer.getObjectsList()) {
|
||||||
mapObjects.add(MapObject.buildObject(obj, map));
|
mapObjects.add(MapObject.buildObject(obj, map));
|
||||||
}
|
}
|
||||||
@@ -44,6 +50,9 @@ public class MapObjectGroup {
|
|||||||
}
|
}
|
||||||
tmxGroup.setVisible(visible);
|
tmxGroup.setVisible(visible);
|
||||||
tmxGroup.setName(name);
|
tmxGroup.setName(name);
|
||||||
|
if (!active) {
|
||||||
|
tmxGroup.getProperties().put("active", Boolean.toString(active));
|
||||||
|
}
|
||||||
for (MapObject object : mapObjects) {
|
for (MapObject object : mapObjects) {
|
||||||
tmxGroup.addObject(object.toTmxObject());
|
tmxGroup.addObject(object.toTmxObject());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class SpawnArea extends MapObject {
|
|||||||
public int quantity = 1;
|
public int quantity = 1;
|
||||||
public int spawnchance = 10;
|
public int spawnchance = 10;
|
||||||
public boolean active = true;
|
public boolean active = true;
|
||||||
|
public String spawngroup_id;
|
||||||
public List<NPC> spawnGroup = new ArrayList<NPC>();
|
public List<NPC> spawnGroup = new ArrayList<NPC>();
|
||||||
|
|
||||||
public SpawnArea(tiled.core.MapObject obj) {
|
public SpawnArea(tiled.core.MapObject obj) {
|
||||||
@@ -25,12 +26,17 @@ public class SpawnArea extends MapObject {
|
|||||||
if (obj.getProperties().getProperty("active") != null) {
|
if (obj.getProperties().getProperty("active") != null) {
|
||||||
this.active = Boolean.parseBoolean(obj.getProperties().getProperty("active"));
|
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
|
@Override
|
||||||
public void link() {
|
public void link() {
|
||||||
if (name != null) {
|
if (spawngroup_id != null) {
|
||||||
spawnGroup = parentMap.getProject().getSpawnGroup(name);
|
spawnGroup = parentMap.getProject().getSpawnGroup(spawngroup_id);
|
||||||
} else {
|
} else {
|
||||||
spawnGroup = new ArrayList<NPC>();
|
spawnGroup = new ArrayList<NPC>();
|
||||||
}
|
}
|
||||||
@@ -65,6 +71,9 @@ public class SpawnArea extends MapObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void savePropertiesInTmxObject(tiled.core.MapObject tmxObject) {
|
public void savePropertiesInTmxObject(tiled.core.MapObject tmxObject) {
|
||||||
|
if (spawngroup_id != null) {
|
||||||
|
tmxObject.getProperties().setProperty("spawngroup", spawngroup_id);
|
||||||
|
}
|
||||||
if (quantity != 1) {
|
if (quantity != 1) {
|
||||||
tmxObject.getProperties().setProperty("quantity", Integer.toString(quantity));
|
tmxObject.getProperties().setProperty("quantity", Integer.toString(quantity));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,17 @@ public class TMXMap extends GameDataElement {
|
|||||||
public static final String ABOVE_LAYER_NAME = "Above";
|
public static final String ABOVE_LAYER_NAME = "Above";
|
||||||
public static final String WALKABLE_LAYER_NAME = "Walkable";
|
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 File tmxFile = null;
|
||||||
public tiled.core.Map tmxMap = null;
|
public tiled.core.Map tmxMap = null;
|
||||||
@@ -46,6 +57,7 @@ public class TMXMap extends GameDataElement {
|
|||||||
|
|
||||||
public ProjectTreeNode parent;
|
public ProjectTreeNode parent;
|
||||||
public Integer outside = null;
|
public Integer outside = null;
|
||||||
|
public ColorFilter colorFilter = null;
|
||||||
|
|
||||||
public boolean writable = false;
|
public boolean writable = false;
|
||||||
|
|
||||||
@@ -62,8 +74,11 @@ public class TMXMap extends GameDataElement {
|
|||||||
usedSpritesheets = new HashSet<Spritesheet>();
|
usedSpritesheets = new HashSet<Spritesheet>();
|
||||||
try {
|
try {
|
||||||
tmxMap = new TMXMapReader().readMap(tmxFile.getAbsolutePath(), this);
|
tmxMap = new TMXMapReader().readMap(tmxFile.getAbsolutePath(), this);
|
||||||
if (tmxMap.getProperties().get("outside") != null) {
|
if (tmxMap.getProperties().get("outdoors") != null) {
|
||||||
outside = new Integer(((String) tmxMap.getProperties().get("outside")));
|
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) {
|
} catch (FileNotFoundException e) {
|
||||||
Notification.addError("Impossible to load TMX map file "+tmxFile.getAbsolutePath());
|
Notification.addError("Impossible to load TMX map file "+tmxFile.getAbsolutePath());
|
||||||
@@ -97,8 +112,11 @@ public class TMXMap extends GameDataElement {
|
|||||||
try {
|
try {
|
||||||
clone.usedSpritesheets = new HashSet<Spritesheet>();
|
clone.usedSpritesheets = new HashSet<Spritesheet>();
|
||||||
clone.tmxMap = new TMXMapReader().readMap(new StringReader(this.toXml()), clone);
|
clone.tmxMap = new TMXMapReader().readMap(new StringReader(this.toXml()), clone);
|
||||||
if (clone.tmxMap.getProperties().get("outside") != null) {
|
if (clone.tmxMap.getProperties().get("outdoors") != null) {
|
||||||
clone.outside = new Integer(((String) clone.tmxMap.getProperties().get("outside")));
|
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()) {
|
for (tiled.core.MapLayer layer : clone.tmxMap.getLayers()) {
|
||||||
if (layer instanceof tiled.core.ObjectGroup) {
|
if (layer instanceof tiled.core.ObjectGroup) {
|
||||||
@@ -210,6 +228,17 @@ public class TMXMap extends GameDataElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toXml() {
|
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) {
|
for (MapObjectGroup group : groups) {
|
||||||
group.pushBackToTiledProperties();
|
group.pushBackToTiledProperties();
|
||||||
if (!tmxMap.containsLayer(group.tmxGroup)) {
|
if (!tmxMap.containsLayer(group.tmxGroup)) {
|
||||||
|
|||||||
@@ -10,11 +10,14 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.swing.tree.TreeNode;
|
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;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameSource.Type;
|
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;
|
||||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.gamedata.Item;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
|
||||||
public class TMXMapSet implements ProjectTreeNode {
|
public class TMXMapSet implements ProjectTreeNode {
|
||||||
@@ -22,6 +25,11 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
public static final String DEFAULT_REL_PATH_IN_SOURCE = "res/xml/";
|
public static final String DEFAULT_REL_PATH_IN_SOURCE = "res/xml/";
|
||||||
public static final String DEFAULT_REL_PATH_IN_PROJECT = "maps/";
|
public static final String DEFAULT_REL_PATH_IN_PROJECT = "maps/";
|
||||||
|
|
||||||
|
public static final String GAME_MAPS_ARRAY_NAME = "loadresource_maps";
|
||||||
|
public static final String DEBUG_SUFFIX = "_debug";
|
||||||
|
public static final String RESOURCE_PREFIX = "@xml/";
|
||||||
|
public static final String FILENAME_SUFFIX = ".tmx";
|
||||||
|
|
||||||
public File mapFolder = null;
|
public File mapFolder = null;
|
||||||
public List<TMXMap> tmxMaps;
|
public List<TMXMap> tmxMaps;
|
||||||
|
|
||||||
@@ -29,7 +37,9 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
|
|
||||||
public TMXMapSet(GameSource source) {
|
public TMXMapSet(GameSource source) {
|
||||||
this.parent = source;
|
this.parent = source;
|
||||||
if (source.type == GameSource.Type.source) this.mapFolder = new File(source.baseFolder, DEFAULT_REL_PATH_IN_SOURCE);
|
if (source.type == GameSource.Type.source) {
|
||||||
|
this.mapFolder = new File(source.baseFolder, DEFAULT_REL_PATH_IN_SOURCE);
|
||||||
|
}
|
||||||
else if (source.type == GameSource.Type.created | source.type == GameSource.Type.altered) {
|
else if (source.type == GameSource.Type.created | source.type == GameSource.Type.altered) {
|
||||||
this.mapFolder = new File(source.baseFolder, DEFAULT_REL_PATH_IN_PROJECT);
|
this.mapFolder = new File(source.baseFolder, DEFAULT_REL_PATH_IN_PROJECT);
|
||||||
if (!this.mapFolder.exists()) {
|
if (!this.mapFolder.exists()) {
|
||||||
@@ -38,7 +48,22 @@ public class TMXMapSet implements ProjectTreeNode {
|
|||||||
}
|
}
|
||||||
this.tmxMaps = new ArrayList<TMXMap>();
|
this.tmxMaps = new ArrayList<TMXMap>();
|
||||||
|
|
||||||
if (this.mapFolder != null) {
|
if (source.type == GameSource.Type.source && (source.parent.sourceSetToUse == ResourceSet.debugData || source.parent.sourceSetToUse == ResourceSet.gameData)) {
|
||||||
|
String suffix = (source.parent.sourceSetToUse == ResourceSet.debugData) ? DEBUG_SUFFIX : "";
|
||||||
|
|
||||||
|
if (source.referencedSourceFiles.get(GAME_MAPS_ARRAY_NAME+suffix) != null) {
|
||||||
|
for (String resource : source.referencedSourceFiles.get(GAME_MAPS_ARRAY_NAME+suffix)) {
|
||||||
|
File f = new File(mapFolder, resource.replaceAll(RESOURCE_PREFIX, "")+FILENAME_SUFFIX);
|
||||||
|
if (f.exists()) {
|
||||||
|
TMXMap map = new TMXMap(this, f);
|
||||||
|
tmxMaps.add(map);
|
||||||
|
} else {
|
||||||
|
Notification.addWarn("Unable to locate resource "+resource+" in the game source for project "+getProject().name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (this.mapFolder != null) {
|
||||||
for (File f : this.mapFolder.listFiles()) {
|
for (File f : this.mapFolder.listFiles()) {
|
||||||
if (f.getName().endsWith(".tmx") || f.getName().endsWith(".TMX")) {
|
if (f.getName().endsWith(".tmx") || f.getName().endsWith(".TMX")) {
|
||||||
TMXMap map = new TMXMap(this, f);
|
TMXMap map = new TMXMap(this, f);
|
||||||
|
|||||||
@@ -90,7 +90,9 @@ public class WorldmapSegment extends GameDataElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (String mapName : mapLocations.keySet()) {
|
for (String mapName : mapLocations.keySet()) {
|
||||||
getProject().getMap(mapName).addBacklink(this);
|
if (getProject().getMap(mapName) != null) {
|
||||||
|
getProject().getMap(mapName).addBacklink(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class AboutEditor extends Editor {
|
|||||||
"<br/>" +
|
"<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/>" +
|
"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/>" +
|
"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/>" +
|
"<br/>" +
|
||||||
"For content creation help, make sure to use the following resources:<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/>" +
|
"<a href=\"http://andorstrail.com/viewtopic.php?f=6&t=4560\">The contribution guide on the forums</a><br/>" +
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import javax.swing.AbstractListModel;
|
import javax.swing.AbstractListModel;
|
||||||
import javax.swing.ComboBoxModel;
|
import javax.swing.ComboBoxModel;
|
||||||
@@ -29,6 +30,7 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.JSpinner.NumberEditor;
|
import javax.swing.JSpinner.NumberEditor;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.ListModel;
|
import javax.swing.ListModel;
|
||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
@@ -147,6 +149,51 @@ public abstract class Editor extends JPanel implements ProjectElementListener {
|
|||||||
});
|
});
|
||||||
return tfField;
|
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) {
|
// public static JSpinner addIntegerField(JPanel pane, String label, Integer initialValue, boolean allowNegatives, boolean editable) {
|
||||||
// return addIntegerField(pane, label, initialValue, allowNegatives, editable, nullListener);
|
// return addIntegerField(pane, label, initialValue, allowNegatives, editable, nullListener);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import javax.swing.event.ListDataListener;
|
|||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
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;
|
||||||
import com.gpl.rpg.atcontentstudio.model.Project;
|
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.ActorCondition;
|
||||||
@@ -293,6 +294,7 @@ public class JSONCreationWizard extends JDialog {
|
|||||||
creation.id = idField.getText();
|
creation.id = idField.getText();
|
||||||
JSONCreationWizard.this.setVisible(false);
|
JSONCreationWizard.this.setVisible(false);
|
||||||
JSONCreationWizard.this.dispose();
|
JSONCreationWizard.this.dispose();
|
||||||
|
creation.state = State.created;
|
||||||
proj.createElement(creation);
|
proj.createElement(creation);
|
||||||
notifyCreated();
|
notifyCreated();
|
||||||
ATContentStudio.frame.selectInTree(creation);
|
ATContentStudio.frame.selectInTree(creation);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.ui;
|
package com.gpl.rpg.atcontentstudio.ui;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
@@ -8,18 +9,26 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.ComboBoxModel;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JList;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.ListCellRenderer;
|
||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
|
import javax.swing.event.ListDataListener;
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.Project;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.Project.ResourceSet;
|
||||||
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
import com.gpl.rpg.atcontentstudio.model.Workspace;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataSet;
|
||||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
import com.gpl.rpg.atcontentstudio.model.maps.TMXMapSet;
|
||||||
@@ -30,7 +39,8 @@ public class ProjectCreationWizard extends JDialog {
|
|||||||
private static final long serialVersionUID = -2854969975146867119L;
|
private static final long serialVersionUID = -2854969975146867119L;
|
||||||
|
|
||||||
final JTextField projectNameField;
|
final JTextField projectNameField;
|
||||||
final JComboBox atSourceSelectionCombo;
|
final JComboBox<String> atSourceSelectionCombo;
|
||||||
|
final JComboBox<Project.ResourceSet> resourceSetToUse;
|
||||||
|
|
||||||
final JButton browse;
|
final JButton browse;
|
||||||
final JButton okButton;
|
final JButton okButton;
|
||||||
@@ -42,7 +52,62 @@ public class ProjectCreationWizard extends JDialog {
|
|||||||
super(ATContentStudio.frame);
|
super(ATContentStudio.frame);
|
||||||
setTitle("Create project");
|
setTitle("Create project");
|
||||||
projectNameField = new JTextField();
|
projectNameField = new JTextField();
|
||||||
atSourceSelectionCombo = new JComboBox();
|
atSourceSelectionCombo = new JComboBox<String>();
|
||||||
|
resourceSetToUse = new JComboBox<Project.ResourceSet>(new ComboBoxModel<Project.ResourceSet>() {
|
||||||
|
|
||||||
|
Project.ResourceSet selected = Project.ResourceSet.allFiles;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSize() {
|
||||||
|
return Project.ResourceSet.values().length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceSet getElementAt(int index) {
|
||||||
|
return Project.ResourceSet.values()[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ListDataListener> listeners = new LinkedList<ListDataListener>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addListDataListener(ListDataListener l) {
|
||||||
|
listeners.add(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeListDataListener(ListDataListener l) {
|
||||||
|
listeners.remove(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSelectedItem(Object anItem) {
|
||||||
|
selected = (ResourceSet) anItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getSelectedItem() {
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
resourceSetToUse.setRenderer(new ListCellRenderer<Project.ResourceSet>() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(
|
||||||
|
JList<? extends ResourceSet> list, ResourceSet value,
|
||||||
|
int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
switch (value) {
|
||||||
|
case allFiles:
|
||||||
|
return new JLabel("All available files");
|
||||||
|
case debugData:
|
||||||
|
return new JLabel("Debug data");
|
||||||
|
case gameData:
|
||||||
|
return new JLabel("Real game data");
|
||||||
|
default:
|
||||||
|
return new JLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
browse = new JButton("Browse...");
|
browse = new JButton("Browse...");
|
||||||
okButton = new JButton("Ok");
|
okButton = new JButton("Ok");
|
||||||
cancelButton = new JButton("Cancel");
|
cancelButton = new JButton("Cancel");
|
||||||
@@ -103,7 +168,7 @@ public class ProjectCreationWizard extends JDialog {
|
|||||||
if (!Workspace.activeWorkspace.knownMapSourcesFolders.contains(atSourceFolder)) {
|
if (!Workspace.activeWorkspace.knownMapSourcesFolders.contains(atSourceFolder)) {
|
||||||
Workspace.activeWorkspace.knownMapSourcesFolders.add(atSourceFolder);
|
Workspace.activeWorkspace.knownMapSourcesFolders.add(atSourceFolder);
|
||||||
}
|
}
|
||||||
Workspace.createProject(projectNameField.getText(), atSourceFolder);
|
Workspace.createProject(projectNameField.getText(), atSourceFolder, (Project.ResourceSet)resourceSetToUse.getSelectedItem());
|
||||||
ProjectCreationWizard.this.dispose();
|
ProjectCreationWizard.this.dispose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -154,6 +219,17 @@ public class ProjectCreationWizard extends JDialog {
|
|||||||
c.weightx = 20;
|
c.weightx = 20;
|
||||||
panel.add(browse, c);
|
panel.add(browse, c);
|
||||||
|
|
||||||
|
c.gridy++;
|
||||||
|
c.gridx = 1;
|
||||||
|
c.gridwidth = 1;
|
||||||
|
c.weightx = 20;
|
||||||
|
panel.add(new JLabel("Resource set: "), c);
|
||||||
|
|
||||||
|
c.gridx++;
|
||||||
|
c.weightx = 80;
|
||||||
|
c.gridwidth = 2;
|
||||||
|
panel.add(resourceSetToUse, c);
|
||||||
|
|
||||||
JPanel buttonPane = new JPanel();
|
JPanel buttonPane = new JPanel();
|
||||||
buttonPane.setLayout(new GridBagLayout());
|
buttonPane.setLayout(new GridBagLayout());
|
||||||
GridBagConstraints c2 = new GridBagConstraints();
|
GridBagConstraints c2 = new GridBagConstraints();
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ public class WorkspaceActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
PropertyChangeEvent event = new PropertyChangeEvent(this, key, values.get(key), value);
|
||||||
values.put(key, value);
|
values.put(key, value);
|
||||||
for (PropertyChangeListener l : listeners) {
|
for (PropertyChangeListener l : listeners) {
|
||||||
@@ -379,7 +379,7 @@ public class WorkspaceActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEnabled(boolean b) {
|
public synchronized void setEnabled(boolean b) {
|
||||||
PropertyChangeEvent event = new PropertyChangeEvent(this, "enabled", isEnabled(), b);
|
PropertyChangeEvent event = new PropertyChangeEvent(this, "enabled", isEnabled(), b);
|
||||||
enabled = b;
|
enabled = b;
|
||||||
for (PropertyChangeListener l : listeners) {
|
for (PropertyChangeListener l : listeners) {
|
||||||
@@ -395,12 +395,12 @@ public class WorkspaceActions {
|
|||||||
private Set<PropertyChangeListener> listeners = new HashSet<PropertyChangeListener>();
|
private Set<PropertyChangeListener> listeners = new HashSet<PropertyChangeListener>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import javax.swing.JList;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.ListModel;
|
import javax.swing.ListModel;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
@@ -79,7 +80,7 @@ public class DialogueEditor extends JSONElementEditor {
|
|||||||
private static final int SHOP_INDEX = 5;
|
private static final int SHOP_INDEX = 5;
|
||||||
|
|
||||||
private JTextField idField;
|
private JTextField idField;
|
||||||
private JTextField messageField;
|
private JTextArea messageField;
|
||||||
private MyComboBox switchToNpcBox;
|
private MyComboBox switchToNpcBox;
|
||||||
|
|
||||||
private RewardsListModel rewardsListModel;
|
private RewardsListModel rewardsListModel;
|
||||||
@@ -127,7 +128,7 @@ public class DialogueEditor extends JSONElementEditor {
|
|||||||
createButtonPane(pane, dialogue.getProject(), dialogue, Dialogue.class, dialogue.getImage(), null, listener);
|
createButtonPane(pane, dialogue.getProject(), dialogue, Dialogue.class, dialogue.getImage(), null, listener);
|
||||||
|
|
||||||
idField = addTextField(pane, "Internal ID: ", dialogue.id, dialogue.writable, 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);
|
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: ");
|
CollapsiblePanel rewards = new CollapsiblePanel("Reaching this phrase gives the following rewards: ");
|
||||||
@@ -320,8 +321,13 @@ public class DialogueEditor extends JSONElementEditor {
|
|||||||
}
|
}
|
||||||
if (reward.type != null) {
|
if (reward.type != null) {
|
||||||
switch (reward.type) {
|
switch (reward.type) {
|
||||||
case activateMapChangeArea:
|
case activateMapObjectGroup:
|
||||||
case deactivateMapChangeArea:
|
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 deactivateSpawnArea:
|
||||||
case removeSpawnArea:
|
case removeSpawnArea:
|
||||||
case spawnAll:
|
case spawnAll:
|
||||||
@@ -732,8 +738,9 @@ public class DialogueEditor extends JSONElementEditor {
|
|||||||
rewardObjDesc = reward.reward_obj_id;
|
rewardObjDesc = reward.reward_obj_id;
|
||||||
}
|
}
|
||||||
switch (reward.type) {
|
switch (reward.type) {
|
||||||
case activateMapChangeArea:
|
case activateMapObjectGroup:
|
||||||
label.setText("Activate mapchange area "+rewardObjDesc+" on map "+reward.map_name);
|
label.setText("Activate map object group "+rewardObjDesc+" on map "+reward.map_name);
|
||||||
|
label.setIcon(new ImageIcon(DefaultIcons.getObjectLayerIcon()));
|
||||||
break;
|
break;
|
||||||
case actorCondition:
|
case actorCondition:
|
||||||
label.setText("Give actor condition "+rewardObjDesc+" for "+reward.reward_value+" turns");
|
label.setText("Give actor condition "+rewardObjDesc+" for "+reward.reward_value+" turns");
|
||||||
@@ -745,11 +752,13 @@ public class DialogueEditor extends JSONElementEditor {
|
|||||||
case createTimer:
|
case createTimer:
|
||||||
label.setText("Create timer "+rewardObjDesc);
|
label.setText("Create timer "+rewardObjDesc);
|
||||||
break;
|
break;
|
||||||
case deactivateMapChangeArea:
|
case deactivateMapObjectGroup:
|
||||||
label.setText("Deactivate mapchange area "+rewardObjDesc+" on map "+reward.map_name);
|
label.setText("Deactivate map object group "+rewardObjDesc+" on map "+reward.map_name);
|
||||||
|
label.setIcon(new ImageIcon(DefaultIcons.getObjectLayerIcon()));
|
||||||
break;
|
break;
|
||||||
case deactivateSpawnArea:
|
case deactivateSpawnArea:
|
||||||
label.setText("Deactivate spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
label.setText("Deactivate spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
||||||
|
label.setIcon(new ImageIcon(DefaultIcons.getNPCIcon()));
|
||||||
break;
|
break;
|
||||||
case dropList:
|
case dropList:
|
||||||
label.setText("Give contents of droplist "+rewardObjDesc);
|
label.setText("Give contents of droplist "+rewardObjDesc);
|
||||||
@@ -765,12 +774,14 @@ public class DialogueEditor extends JSONElementEditor {
|
|||||||
break;
|
break;
|
||||||
case removeSpawnArea:
|
case removeSpawnArea:
|
||||||
label.setText("Remove all monsters in spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
label.setText("Remove all monsters in spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
||||||
|
label.setIcon(new ImageIcon(DefaultIcons.getNPCIcon()));
|
||||||
break;
|
break;
|
||||||
case skillIncrease:
|
case skillIncrease:
|
||||||
label.setText("Increase skill "+rewardObjDesc+" level");
|
label.setText("Increase skill "+rewardObjDesc+" level");
|
||||||
break;
|
break;
|
||||||
case spawnAll:
|
case spawnAll:
|
||||||
label.setText("Respawn all monsters in spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
label.setText("Respawn all monsters in spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
||||||
|
label.setIcon(new ImageIcon(DefaultIcons.getNPCIcon()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1027,6 +1038,10 @@ public class DialogueEditor extends JSONElementEditor {
|
|||||||
} else if (source == rewardTypeCombo) {
|
} else if (source == rewardTypeCombo) {
|
||||||
if (selectedReward.type != value) {
|
if (selectedReward.type != value) {
|
||||||
selectedReward.type = (Dialogue.Reward.RewardType) value;
|
selectedReward.type = (Dialogue.Reward.RewardType) value;
|
||||||
|
if (selectedReward.map != null) {
|
||||||
|
selectedReward.map.removeBacklink(dialogue);
|
||||||
|
}
|
||||||
|
selectedReward.map = null;
|
||||||
selectedReward.map_name = null;
|
selectedReward.map_name = null;
|
||||||
selectedReward.reward_obj = null;
|
selectedReward.reward_obj = null;
|
||||||
selectedReward.reward_obj_id = null;
|
selectedReward.reward_obj_id = null;
|
||||||
|
|||||||
@@ -1,24 +1,32 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.ui.gamedataeditors;
|
package com.gpl.rpg.atcontentstudio.ui.gamedataeditors;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import javax.swing.event.TableModelEvent;
|
import javax.swing.event.TableModelEvent;
|
||||||
import javax.swing.event.TableModelListener;
|
import javax.swing.event.TableModelListener;
|
||||||
|
import javax.swing.table.TableCellRenderer;
|
||||||
import javax.swing.table.TableModel;
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
|
import org.fife.ui.rtextarea.ColorBackgroundPainterStrategy;
|
||||||
|
|
||||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||||
@@ -79,6 +87,7 @@ public class QuestEditor extends JSONElementEditor {
|
|||||||
stagesTable.getColumnModel().getColumn(3).setMinWidth(130);
|
stagesTable.getColumnModel().getColumn(3).setMinWidth(130);
|
||||||
stagesTable.getColumnModel().getColumn(3).setMaxWidth(130);
|
stagesTable.getColumnModel().getColumn(3).setMaxWidth(130);
|
||||||
stagesTable.setCellSelectionEnabled(true);
|
stagesTable.setCellSelectionEnabled(true);
|
||||||
|
stagesTable.getColumnModel().getColumn(1).setCellRenderer(new MultilineCellRenderer());
|
||||||
stagesPane.add(new JScrollPane(stagesTable), BorderLayout.CENTER);
|
stagesPane.add(new JScrollPane(stagesTable), BorderLayout.CENTER);
|
||||||
if (quest.writable) {
|
if (quest.writable) {
|
||||||
JPanel buttonPane = new JPanel();
|
JPanel buttonPane = new JPanel();
|
||||||
@@ -330,6 +339,48 @@ public class QuestEditor extends JSONElementEditor {
|
|||||||
updateJsonViewText(quest.toJsonString());
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.gpl.rpg.atcontentstudio.ui.map;
|
|||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import java.awt.Composite;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
@@ -18,8 +19,8 @@ import java.awt.event.MouseAdapter;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseMotionAdapter;
|
import java.awt.event.MouseMotionAdapter;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
|
import java.awt.image.BufferedImageOp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@@ -101,6 +102,7 @@ import com.gpl.rpg.atcontentstudio.ui.Editor;
|
|||||||
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
|
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.IntegerBasedCheckBox;
|
import com.gpl.rpg.atcontentstudio.ui.IntegerBasedCheckBox;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.ScrollablePanel;
|
import com.gpl.rpg.atcontentstudio.ui.ScrollablePanel;
|
||||||
|
import com.gpl.rpg.atcontentstudio.ui.tools.MatrixComposite;
|
||||||
import com.jidesoft.swing.JideBoxLayout;
|
import com.jidesoft.swing.JideBoxLayout;
|
||||||
import com.jidesoft.swing.JideTabbedPane;
|
import com.jidesoft.swing.JideTabbedPane;
|
||||||
|
|
||||||
@@ -115,6 +117,7 @@ public class TMXMapEditor extends Editor {
|
|||||||
private RSyntaxTextArea editorPane;
|
private RSyntaxTextArea editorPane;
|
||||||
|
|
||||||
private IntegerBasedCheckBox outsideBox;
|
private IntegerBasedCheckBox outsideBox;
|
||||||
|
private JComboBox colorFilterBox;
|
||||||
private LayerListModel layerListModel;
|
private LayerListModel layerListModel;
|
||||||
private JList layerList;
|
private JList layerList;
|
||||||
private tiled.core.MapLayer selectedLayer;
|
private tiled.core.MapLayer selectedLayer;
|
||||||
@@ -124,6 +127,7 @@ public class TMXMapEditor extends Editor {
|
|||||||
|
|
||||||
private JPanel layerDetailsPane;
|
private JPanel layerDetailsPane;
|
||||||
private BooleanBasedCheckBox layerVisibleBox;
|
private BooleanBasedCheckBox layerVisibleBox;
|
||||||
|
private BooleanBasedCheckBox activeLayerBox;
|
||||||
private JTextField layerNameField;
|
private JTextField layerNameField;
|
||||||
private MapObjectsListModel groupObjectsListModel;
|
private MapObjectsListModel groupObjectsListModel;
|
||||||
private JList groupObjectsList;
|
private JList groupObjectsList;
|
||||||
@@ -147,6 +151,7 @@ public class TMXMapEditor extends Editor {
|
|||||||
private JComboBox evaluateTriggerBox;
|
private JComboBox evaluateTriggerBox;
|
||||||
private JSpinner quantityField;
|
private JSpinner quantityField;
|
||||||
private JCheckBox activeForNewGame;
|
private JCheckBox activeForNewGame;
|
||||||
|
private JTextField spawngroupField;
|
||||||
private JList npcList;
|
private JList npcList;
|
||||||
private SpawnGroupNpcListModel npcListModel;
|
private SpawnGroupNpcListModel npcListModel;
|
||||||
|
|
||||||
@@ -204,6 +209,7 @@ public class TMXMapEditor extends Editor {
|
|||||||
addLabelField(pane, "TMX File: ", ((TMXMap)target).tmxFile.getAbsolutePath());
|
addLabelField(pane, "TMX File: ", ((TMXMap)target).tmxFile.getAbsolutePath());
|
||||||
createButtonPane(pane, map.getProject(), map, listener);
|
createButtonPane(pane, map.getProject(), map, listener);
|
||||||
outsideBox = addIntegerBasedCheckBox(pane, "Map is outdoors", map.outside, map.writable, 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);
|
JSplitPane layersViewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||||||
layerListModel = new LayerListModel(map);
|
layerListModel = new LayerListModel(map);
|
||||||
@@ -307,6 +313,7 @@ public class TMXMapEditor extends Editor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
activeForNewGame = addBooleanBasedCheckBox(groupDetailPane, "Active for new game", objGroup.active, map.writable, listener);
|
||||||
groupObjectsListModel = new MapObjectsListModel(objGroup);
|
groupObjectsListModel = new MapObjectsListModel(objGroup);
|
||||||
groupObjectsList = new JList(groupObjectsListModel);
|
groupObjectsList = new JList(groupObjectsListModel);
|
||||||
groupObjectsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
groupObjectsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
@@ -539,14 +546,15 @@ public class TMXMapEditor extends Editor {
|
|||||||
|
|
||||||
|
|
||||||
} else if (selected instanceof RestArea) {
|
} 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) {
|
} else if (selected instanceof ScriptArea) {
|
||||||
evaluateTriggerBox = addEnumValueBox(pane, "Evaluate on every: ", ScriptArea.EvaluationTrigger.values(), ((ScriptArea)selected).trigger_type, ((TMXMap)target).writable, listener);
|
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);
|
dialogueBox = addDialogueBox(pane, ((TMXMap)target).getProject(), "Script: ", ((ScriptArea)selected).dialogue, ((TMXMap)target).writable, listener);
|
||||||
} else if (selected instanceof SignArea) {
|
} else if (selected instanceof SignArea) {
|
||||||
dialogueBox = addDialogueBox(pane, ((TMXMap)target).getProject(), "Message: ", ((SignArea)selected).dialogue, ((TMXMap)target).writable, listener);
|
dialogueBox = addDialogueBox(pane, ((TMXMap)target).getProject(), "Message: ", ((SignArea)selected).dialogue, ((TMXMap)target).writable, listener);
|
||||||
} else if (selected instanceof SpawnArea) {
|
} 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);
|
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);
|
activeForNewGame = addBooleanBasedCheckBox(pane, "Active in a new game: ", ((SpawnArea)selected).active, ((TMXMap)target).writable, listener);
|
||||||
npcListModel = new SpawnGroupNpcListModel((SpawnArea) selected);
|
npcListModel = new SpawnGroupNpcListModel((SpawnArea) selected);
|
||||||
@@ -1238,12 +1246,51 @@ public class TMXMapEditor extends Editor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final BufferedImageOp colorFilterBlack20 = null;
|
||||||
|
private static final BufferedImageOp colorFilterBlack40 = null;
|
||||||
|
private static final BufferedImageOp colorFilterBlack60 = null;
|
||||||
|
private static final BufferedImageOp colorFilterBlack80 = null;
|
||||||
|
private static final BufferedImageOp colorFilterInvert = null;
|
||||||
|
private static final BufferedImageOp colorFilterBW = null;
|
||||||
|
|
||||||
|
|
||||||
|
// private static final BufferedImageOp colorFilterBlack20 = createGrayScaleColorFilter(0.8f);
|
||||||
|
// private static final BufferedImageOp colorFilterBlack40 = createGrayScaleColorFilter(0.6f);
|
||||||
|
// private static final BufferedImageOp colorFilterBlack60 = createGrayScaleColorFilter(0.4f);
|
||||||
|
// private static final BufferedImageOp colorFilterBlack80 = createGrayScaleColorFilter(0.2f);
|
||||||
|
// private static final BufferedImageOp colorFilterInvert = createInvertColorFilter();
|
||||||
|
// private static final BufferedImageOp colorFilterBW = createBWColorFilter();
|
||||||
|
//
|
||||||
|
// private static BufferedImageOp createGrayScaleColorFilter(float f) {
|
||||||
|
// byte[] gs = new byte[256];
|
||||||
|
// for (int i=0; i < 256; i++) {
|
||||||
|
// gs[i] = (byte)( i * f);
|
||||||
|
// }
|
||||||
|
// return new LookupOp(new ByteLookupTable(0, gs), null);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static BufferedImageOp createInvertColorFilter() {
|
||||||
|
// byte[] invert = new byte[256];
|
||||||
|
// for (int i=0; i < 256; i++) {
|
||||||
|
// invert[i] = (byte) (255 - i);
|
||||||
|
// }
|
||||||
|
// return new LookupOp(new ByteLookupTable(0, invert), null);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private static BufferedImageOp createBWColorFilter() {
|
||||||
|
// return new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
|
||||||
|
// }
|
||||||
|
|
||||||
public class TMXViewer extends JPanel implements Scrollable {
|
public class TMXViewer extends JPanel implements Scrollable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2845032142029325865L;
|
private static final long serialVersionUID = 2845032142029325865L;
|
||||||
|
|
||||||
|
|
||||||
public tiled.core.MapObject highlighted = null;
|
public tiled.core.MapObject highlighted = null;
|
||||||
private MapRenderer renderer;
|
private MapRenderer renderer;
|
||||||
private FieldUpdateListener listener;
|
private FieldUpdateListener listener;
|
||||||
|
private TMXMap map;
|
||||||
|
|
||||||
public boolean resizing = false;
|
public boolean resizing = false;
|
||||||
public boolean moving = false;
|
public boolean moving = false;
|
||||||
@@ -1253,7 +1300,8 @@ public class TMXMapEditor extends Editor {
|
|||||||
return new Rectangle(selectedMapObject.x + selectedMapObject.w - 16, selectedMapObject.y + selectedMapObject.h - 16, 16, 16);
|
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
|
//16x16 px square in the upper left corner of area
|
||||||
return new Rectangle(selectedMapObject.x, selectedMapObject.y, 16, 16);
|
return new Rectangle(selectedMapObject.x, selectedMapObject.y, 16, 16);
|
||||||
}
|
}
|
||||||
@@ -1266,6 +1314,7 @@ public class TMXMapEditor extends Editor {
|
|||||||
public TMXViewer(final TMXMap map, FieldUpdateListener listener) {
|
public TMXViewer(final TMXMap map, FieldUpdateListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
renderer = createRenderer(map.tmxMap);
|
renderer = createRenderer(map.tmxMap);
|
||||||
|
this.map = map;
|
||||||
|
|
||||||
setPreferredSize(renderer.getMapSize());
|
setPreferredSize(renderer.getMapSize());
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
@@ -1379,20 +1428,150 @@ public class TMXMapEditor extends Editor {
|
|||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
final Graphics2D g2d = (Graphics2D) g.create();
|
final Graphics2D g2d = (Graphics2D) g.create();
|
||||||
final Rectangle clip = g2d.getClipBounds();
|
final Rectangle clip = g2d.getClipBounds();
|
||||||
|
|
||||||
|
BufferedImageOp filter = null;
|
||||||
|
|
||||||
|
if (map.colorFilter != null) {
|
||||||
|
switch(map.colorFilter) {
|
||||||
|
case black20:
|
||||||
|
filter=colorFilterBlack20;
|
||||||
|
break;
|
||||||
|
case black40:
|
||||||
|
filter=colorFilterBlack40;
|
||||||
|
break;
|
||||||
|
case black60:
|
||||||
|
filter=colorFilterBlack60;
|
||||||
|
break;
|
||||||
|
case black80:
|
||||||
|
filter=colorFilterBlack80;
|
||||||
|
break;
|
||||||
|
case bw:
|
||||||
|
filter=colorFilterBW;
|
||||||
|
break;
|
||||||
|
case invert:
|
||||||
|
filter=colorFilterInvert;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw a gray background
|
// Draw a gray background
|
||||||
g2d.setPaint(new Color(100, 100, 100));
|
g2d.setPaint(new Color(100, 100, 100));
|
||||||
g2d.fill(clip);
|
g2d.fill(clip);
|
||||||
|
|
||||||
// Draw each tile map layer
|
// Draw each tile map layer
|
||||||
boolean paintSelected = false;
|
|
||||||
for (tiled.core.MapLayer layer : ((TMXMap)target).tmxMap) {
|
for (tiled.core.MapLayer layer : ((TMXMap)target).tmxMap) {
|
||||||
if (layer instanceof tiled.core.TileLayer && layer.isVisible()) {
|
if (layer instanceof tiled.core.TileLayer && layer.isVisible()) {
|
||||||
renderer.paintTileLayer(g2d, (tiled.core.TileLayer) layer);
|
renderer.paintTileLayer(g2d, (tiled.core.TileLayer) layer, filter);
|
||||||
} else if (layer instanceof tiled.core.ObjectGroup && layer.isVisible()) {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map.colorFilter != null) {
|
||||||
|
Composite oldComp = g2d.getComposite();
|
||||||
|
MatrixComposite newComp = null;
|
||||||
|
float f=0.0f;
|
||||||
|
switch(map.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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);
|
paintSelected |= paintObjectGroup(g2d, (tiled.core.ObjectGroup) layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (paintSelected) {
|
if (paintSelected) {
|
||||||
//TODO make this less ugly..... visually speaking.
|
//TODO make this less ugly..... visually speaking.
|
||||||
g2d.setColor(new Color(190, 20, 20));
|
g2d.setColor(new Color(190, 20, 20));
|
||||||
@@ -1681,6 +1860,11 @@ public class TMXMapEditor extends Editor {
|
|||||||
modified = false;
|
modified = false;
|
||||||
tmxViewer.revalidate();
|
tmxViewer.revalidate();
|
||||||
tmxViewer.repaint();
|
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) {
|
} else if (source == layerList) {
|
||||||
modified = false;
|
modified = false;
|
||||||
tmxViewer.revalidate();
|
tmxViewer.revalidate();
|
||||||
@@ -1690,6 +1874,9 @@ public class TMXMapEditor extends Editor {
|
|||||||
tmxViewer.revalidate();
|
tmxViewer.revalidate();
|
||||||
tmxViewer.repaint();
|
tmxViewer.repaint();
|
||||||
} else if (source == areaField) {
|
} else if (source == areaField) {
|
||||||
|
selectedMapObject.name = (String) value;
|
||||||
|
groupObjectsListModel.objectChanged(selectedMapObject);
|
||||||
|
} else if (source == spawngroupField) {
|
||||||
if (selectedMapObject instanceof SpawnArea) {
|
if (selectedMapObject instanceof SpawnArea) {
|
||||||
SpawnArea area = (SpawnArea)selectedMapObject;
|
SpawnArea area = (SpawnArea)selectedMapObject;
|
||||||
if (area.spawnGroup != null && !area.spawnGroup.isEmpty()) {
|
if (area.spawnGroup != null && !area.spawnGroup.isEmpty()) {
|
||||||
@@ -1697,7 +1884,7 @@ public class TMXMapEditor extends Editor {
|
|||||||
npc.removeBacklink(map);
|
npc.removeBacklink(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
area.name = (String) value;
|
area.spawngroup_id = (String) value;
|
||||||
selectedMapObject.link();
|
selectedMapObject.link();
|
||||||
npcList.setModel(new SpawnGroupNpcListModel(area));
|
npcList.setModel(new SpawnGroupNpcListModel(area));
|
||||||
groupObjectsListModel.objectChanged(area);
|
groupObjectsListModel.objectChanged(area);
|
||||||
@@ -1705,10 +1892,6 @@ public class TMXMapEditor extends Editor {
|
|||||||
npcList.repaint();
|
npcList.repaint();
|
||||||
tmxViewer.revalidate();
|
tmxViewer.revalidate();
|
||||||
tmxViewer.repaint();
|
tmxViewer.repaint();
|
||||||
} else if (selectedMapObject instanceof MapChange) {
|
|
||||||
MapChange area = (MapChange) selectedMapObject;
|
|
||||||
area.name = (String) value;
|
|
||||||
groupObjectsListModel.objectChanged(area);
|
|
||||||
}
|
}
|
||||||
} else if (source == targetAreaCombo) {
|
} else if (source == targetAreaCombo) {
|
||||||
if (selectedMapObject instanceof MapChange) {
|
if (selectedMapObject instanceof MapChange) {
|
||||||
@@ -1717,6 +1900,10 @@ public class TMXMapEditor extends Editor {
|
|||||||
}
|
}
|
||||||
} else if (source == outsideBox) {
|
} else if (source == outsideBox) {
|
||||||
map.outside = (Integer)value;
|
map.outside = (Integer)value;
|
||||||
|
} else if (source == colorFilterBox) {
|
||||||
|
map.colorFilter = (TMXMap.ColorFilter) value;
|
||||||
|
tmxViewer.revalidate();
|
||||||
|
tmxViewer.repaint();
|
||||||
} else if (source == droplistBox) {
|
} else if (source == droplistBox) {
|
||||||
if (selectedMapObject instanceof ContainerArea) {
|
if (selectedMapObject instanceof ContainerArea) {
|
||||||
ContainerArea area = (ContainerArea)selectedMapObject;
|
ContainerArea area = (ContainerArea)selectedMapObject;
|
||||||
@@ -2042,6 +2229,34 @@ public class TMXMapEditor extends Editor {
|
|||||||
final Graphics2D g2d = (Graphics2D) g.create();
|
final Graphics2D g2d = (Graphics2D) g.create();
|
||||||
final Rectangle clip = g2d.getClipBounds();
|
final Rectangle clip = g2d.getClipBounds();
|
||||||
|
|
||||||
|
BufferedImageOp filter = null;
|
||||||
|
|
||||||
|
if (map.colorFilter != null) {
|
||||||
|
switch(map.colorFilter) {
|
||||||
|
case black20:
|
||||||
|
filter=colorFilterBlack20;
|
||||||
|
break;
|
||||||
|
case black40:
|
||||||
|
filter=colorFilterBlack40;
|
||||||
|
break;
|
||||||
|
case black60:
|
||||||
|
filter=colorFilterBlack60;
|
||||||
|
break;
|
||||||
|
case black80:
|
||||||
|
filter=colorFilterBlack80;
|
||||||
|
break;
|
||||||
|
case bw:
|
||||||
|
filter=colorFilterBW;
|
||||||
|
break;
|
||||||
|
case invert:
|
||||||
|
filter=colorFilterInvert;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw a gray background
|
// Draw a gray background
|
||||||
g2d.setPaint(new Color(100, 100, 100));
|
g2d.setPaint(new Color(100, 100, 100));
|
||||||
g2d.fill(clip);
|
g2d.fill(clip);
|
||||||
@@ -2049,19 +2264,19 @@ public class TMXMapEditor extends Editor {
|
|||||||
// Draw each tile map layer
|
// Draw each tile map layer
|
||||||
|
|
||||||
if (ground != null) {
|
if (ground != null) {
|
||||||
renderer.paintTileLayer(g2d, ground);
|
renderer.paintTileLayer(g2d, ground, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objects != null) {
|
if (objects != null) {
|
||||||
renderer.paintTileLayer(g2d, objects);
|
renderer.paintTileLayer(g2d, objects, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (above != null) {
|
if (above != null) {
|
||||||
renderer.paintTileLayer(g2d, above);
|
renderer.paintTileLayer(g2d, above, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (walkable != null && showWalkable) {
|
if (walkable != null && showWalkable) {
|
||||||
renderer.paintTileLayer(g2d, walkable);
|
renderer.paintTileLayer(g2d, walkable, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highlighted != null) {
|
if (highlighted != null) {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class WorldMapView extends JComponent implements Scrollable {
|
|||||||
for (tiled.core.MapLayer layer : ((TMXMap)map).tmxMap) {
|
for (tiled.core.MapLayer layer : ((TMXMap)map).tmxMap) {
|
||||||
if (layer instanceof tiled.core.TileLayer && layer.isVisible()) {
|
if (layer instanceof tiled.core.TileLayer && layer.isVisible()) {
|
||||||
if (layer.getName().equalsIgnoreCase("walkable")) continue;
|
if (layer.getName().equalsIgnoreCase("walkable")) continue;
|
||||||
renderer.paintTileLayer(g2, (tiled.core.TileLayer) layer);
|
renderer.paintTileLayer(g2, (tiled.core.TileLayer) layer, null);
|
||||||
} else if (layer instanceof tiled.core.ObjectGroup && layer.isVisible()) {
|
} else if (layer instanceof tiled.core.ObjectGroup && layer.isVisible()) {
|
||||||
// paintObjectGroup(g2, map, (tiled.core.ObjectGroup) layer);
|
// paintObjectGroup(g2, map, (tiled.core.ObjectGroup) layer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,10 +151,10 @@ public class SpritesheetEditor extends Editor {
|
|||||||
TableColumn col;
|
TableColumn col;
|
||||||
while (columns.hasMoreElements()) {
|
while (columns.hasMoreElements()) {
|
||||||
col = columns.nextElement();
|
col = columns.nextElement();
|
||||||
col.setMinWidth(sheet.spriteWidth + 1);
|
col.setMinWidth(sheet.spriteWidth + 4);
|
||||||
col.setMaxWidth(sheet.spriteWidth + 1);
|
col.setMaxWidth(sheet.spriteWidth + 4);
|
||||||
}
|
}
|
||||||
spritesTable.setRowHeight(sheet.spriteHeight + 1);
|
spritesTable.setRowHeight(sheet.spriteHeight + 4);
|
||||||
pane.add(new JScrollPane(spritesTable), BorderLayout.CENTER);
|
pane.add(new JScrollPane(spritesTable), BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class ItemsTableView extends ElementTableView {
|
|||||||
private static final long serialVersionUID = 1474255176349837609L;
|
private static final long serialVersionUID = 1474255176349837609L;
|
||||||
|
|
||||||
public ItemsTableView(Project proj) {
|
public ItemsTableView(Project proj) {
|
||||||
super(new ItemsTableModel(proj), "Compare "+proj.getItemCount()+" items.", new ImageIcon(DefaultIcons.getItemIcon()));
|
super(new ItemsTableModel(proj), "Compare "+proj.getItemCountIncludingAltered()+" items.", new ImageIcon(DefaultIcons.getItemIcon()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ItemsTableModel implements TableModel {
|
private static class ItemsTableModel implements TableModel {
|
||||||
@@ -32,7 +32,7 @@ public class ItemsTableView extends ElementTableView {
|
|||||||
@Override
|
@Override
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
// return proj.getItemCount() + 1;
|
// return proj.getItemCount() + 1;
|
||||||
return proj.getItemCount();
|
return proj.getItemCountIncludingAltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -130,7 +130,7 @@ public class ItemsTableView extends ElementTableView {
|
|||||||
// return getColumnName(columnIndex);
|
// return getColumnName(columnIndex);
|
||||||
// }
|
// }
|
||||||
// Item item = proj.getItem(rowIndex - 1);
|
// Item item = proj.getItem(rowIndex - 1);
|
||||||
Item item = proj.getItem(rowIndex);
|
Item item = proj.getItemIncludingAltered(rowIndex);
|
||||||
boolean canUse = item.category != null && item.category.action_type == ItemCategory.ActionType.use;
|
boolean canUse = item.category != null && item.category.action_type == ItemCategory.ActionType.use;
|
||||||
boolean canEquip = item.category != null && item.category.action_type == ItemCategory.ActionType.equip;
|
boolean canEquip = item.category != null && item.category.action_type == ItemCategory.ActionType.equip;
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
|
|||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ public class NPCsTableView extends ElementTableView {
|
|||||||
private static final long serialVersionUID = -4196852140899079621L;
|
private static final long serialVersionUID = -4196852140899079621L;
|
||||||
|
|
||||||
public NPCsTableView(Project proj) {
|
public NPCsTableView(Project proj) {
|
||||||
super(new NPCsTableModel(proj), "Compare "+proj.getNPCCount()+" NPCs.", new ImageIcon(DefaultIcons.getNPCIcon()));
|
super(new NPCsTableModel(proj), "Compare "+proj.getNPCCountIncludingAltered()+" NPCs.", new ImageIcon(DefaultIcons.getNPCIcon()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class NPCsTableModel implements TableModel {
|
private static class NPCsTableModel implements TableModel {
|
||||||
@@ -30,7 +30,7 @@ public class NPCsTableView extends ElementTableView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
return proj.getNPCCount();
|
return proj.getNPCCountIncludingAltered();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -109,7 +109,7 @@ public class NPCsTableView extends ElementTableView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||||
NPC npc = proj.getNPC(rowIndex);
|
NPC npc = proj.getNPCIncludingAltered(rowIndex);
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0: return new ImageIcon(npc.getIcon()); // Icon
|
case 0: return new ImageIcon(npc.getIcon()); // Icon
|
||||||
case 1: return npc.id; //ID
|
case 1: return npc.id; //ID
|
||||||
|
|||||||
Reference in New Issue
Block a user