mirror of
https://github.com/AndorsTrailRelease/ATCS.git
synced 2025-10-27 18:44:03 +01:00
v0.5.4 released! Keyword is data-protection. Many small bugfixes, but
main changes are: - Modified marker (* character before name) goes up the project tree by marking all parents of a modified object as modified. - Impact management when changing an object's ID. Allows for some refactoring to occur, while marking the impacted elements as modified, or aven creating "altered" versions if imapcted element was only in game source.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<jardesc>
|
||||
<jar path="ATContentStudio/ATCS_v0.5.3.jar"/>
|
||||
<jar path="ATContentStudio/ATCS_v0.5.4.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/ATContentStudio/ATCS_JAR.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||
<selectedProjects/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
!include MUI2.nsh
|
||||
|
||||
!define VERSION "0.5.3"
|
||||
!define VERSION "0.5.4"
|
||||
!define TRAINER_VERSION "0.1.3"
|
||||
!define JAVA_BIN "javaw"
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.awt.Toolkit;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -22,10 +24,13 @@ import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector;
|
||||
public class ATContentStudio {
|
||||
|
||||
public static final String APP_NAME = "Andor's Trail Content Studio";
|
||||
public static final String APP_VERSION = "v0.5.3";
|
||||
public static final String APP_VERSION = "v0.5.4";
|
||||
|
||||
public static boolean STARTED = false;
|
||||
public static StudioFrame frame = null;
|
||||
|
||||
//Need to keep a strong reference to it, to avoid garbage collection that'll reset these loggers.
|
||||
public static final List<Logger> configuredLoggers = new LinkedList<Logger>();
|
||||
|
||||
/**
|
||||
* @param args
|
||||
@@ -34,8 +39,6 @@ public class ATContentStudio {
|
||||
|
||||
ConfigCache.init();
|
||||
|
||||
Logger.getLogger(ExpressionParser.class.getName()).setLevel(Level.OFF);
|
||||
|
||||
try {
|
||||
String laf = ConfigCache.getFavoriteLaFClassName();
|
||||
if (laf == null) laf = UIManager.getSystemLookAndFeelClassName();
|
||||
@@ -50,6 +53,10 @@ public class ATContentStudio {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Need to keep a strong reference to it, to avoid garbage collection that'll reset this setting.
|
||||
Logger l = Logger.getLogger(ExpressionParser.class.getName());
|
||||
l.setLevel(Level.OFF);
|
||||
configuredLoggers.add(l);
|
||||
|
||||
final WorkspaceSelector wsSelect = new WorkspaceSelector();
|
||||
wsSelect.pack();
|
||||
@@ -69,7 +76,7 @@ public class ATContentStudio {
|
||||
Workspace.setActive(workspaceRoot);
|
||||
frame = new StudioFrame(APP_NAME+" "+APP_VERSION);
|
||||
frame.setVisible(true);
|
||||
frame.setDefaultCloseOperation(StudioFrame.EXIT_ON_CLOSE);
|
||||
frame.setDefaultCloseOperation(StudioFrame.DO_NOTHING_ON_CLOSE);
|
||||
};
|
||||
});
|
||||
for (File f : ConfigCache.getKnownWorkspaces()) {
|
||||
|
||||
@@ -116,4 +116,9 @@ public class ClosedProject implements ProjectTreeNode {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -176,6 +176,10 @@ public abstract class GameDataElement implements ProjectTreeNode, Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean needsSaving() {
|
||||
return this.state == State.modified || this.state == State.created;
|
||||
}
|
||||
|
||||
public abstract String getProjectFilename();
|
||||
|
||||
public abstract void save();
|
||||
|
||||
@@ -213,11 +213,11 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
||||
@Override
|
||||
public String getDesc() {
|
||||
switch(type) {
|
||||
case altered: return "Altered data";
|
||||
case created: return "Created data";
|
||||
case referenced: return "Referenced data";
|
||||
case source: return "AT Source"; //The fact that it is from "source" is already mentionned by its parent.
|
||||
default: return "Game data";
|
||||
case altered: return (needsSaving() ? "*" : "")+"Altered data";
|
||||
case created: return (needsSaving() ? "*" : "")+"Created data";
|
||||
case referenced: return (needsSaving() ? "*" : "")+"Referenced data";
|
||||
case source: return (needsSaving() ? "*" : "")+"AT Source"; //The fact that it is from "source" is already mentionned by its parent.
|
||||
default: return (needsSaving() ? "*" : "")+"Game data";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,4 +283,12 @@ public class GameSource implements ProjectTreeNode, Serializable {
|
||||
public WorldmapSegment getWorldmapSegment(String id) {
|
||||
return worldmap.getWorldmapSegment(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
for (ProjectTreeNode node : v.getNonEmptyIterable()) {
|
||||
if (node.needsSaving()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
}
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return name;
|
||||
return (needsSaving() ? "*" : "")+name;
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
}
|
||||
}
|
||||
for (ProjectTreeNode node : baseContent.gameMaps.tmxMaps) {
|
||||
((TMXMap)node).parse();
|
||||
((TMXMap)node).link();
|
||||
}
|
||||
for (ProjectTreeNode node : alteredContent.gameData.v.getNonEmptyIterable()) {
|
||||
if (node instanceof GameDataCategory<?>) {
|
||||
@@ -275,7 +275,7 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
}
|
||||
}
|
||||
for (ProjectTreeNode node : alteredContent.gameMaps.tmxMaps) {
|
||||
((TMXMap)node).parse();
|
||||
((TMXMap)node).link();
|
||||
}
|
||||
for (ProjectTreeNode node : createdContent.gameData.v.getNonEmptyIterable()) {
|
||||
if (node instanceof GameDataCategory<?>) {
|
||||
@@ -285,9 +285,6 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
}
|
||||
}
|
||||
for (ProjectTreeNode node : createdContent.gameMaps.tmxMaps) {
|
||||
((TMXMap)node).parse();
|
||||
}
|
||||
for (ProjectTreeNode node : baseContent.gameMaps.tmxMaps) {
|
||||
((TMXMap)node).link();
|
||||
}
|
||||
|
||||
@@ -1131,6 +1128,13 @@ public class Project implements ProjectTreeNode, Serializable {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
for (ProjectTreeNode node : v.getNonEmptyIterable()) {
|
||||
if (node.needsSaving()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -53,5 +53,7 @@ public interface ProjectTreeNode extends TreeNode {
|
||||
public GameSource.Type getDataType();
|
||||
|
||||
public boolean isEmpty();
|
||||
|
||||
public boolean needsSaving();
|
||||
|
||||
}
|
||||
|
||||
@@ -140,8 +140,15 @@ public class Workspace implements ProjectTreeNode, Serializable {
|
||||
@Override
|
||||
public void childrenChanged(List<ProjectTreeNode> path) {
|
||||
path.add(0, this);
|
||||
if (projectsTreeModel != null) projectsTreeModel.changeNode(new TreePath(path.toArray()));
|
||||
ATContentStudio.frame.editorChanged(path.get(path.size() - 1));
|
||||
ProjectTreeNode last = path.get(path.size() - 1);
|
||||
if (projectsTreeModel != null) {
|
||||
while (path.size() > 1) {
|
||||
projectsTreeModel.changeNode(new TreePath(path.toArray()));
|
||||
path.remove(path.size()-1);
|
||||
}
|
||||
|
||||
}
|
||||
ATContentStudio.frame.editorChanged(last);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -346,5 +353,14 @@ public class Workspace implements ProjectTreeNode, Serializable {
|
||||
public boolean isEmpty() {
|
||||
return projects.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
for (ProjectTreeNode node : projects) {
|
||||
if (node.needsSaving()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,20 +63,14 @@ public class WorkspaceSettings {
|
||||
reader = new FileReader(f);
|
||||
@SuppressWarnings("rawtypes")
|
||||
Map jsonSettings = (Map) parser.parse(reader);
|
||||
Integer version = (Integer) jsonSettings.get(VERSION_KEY);
|
||||
Integer version = ((Number) jsonSettings.get(VERSION_KEY)).intValue();
|
||||
if (version != null) {
|
||||
if (version >= 1) {
|
||||
loadv1(jsonSettings);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
Notification.addError("Error while parsing workspace settings: "+e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
Notification.addError("Error while parsing workspace settings: "+e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (ParseException e) {
|
||||
} catch (Exception e) {
|
||||
Notification.addError("Error while parsing workspace settings: "+e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
@@ -88,7 +88,7 @@ public class ActorCondition extends JSONElement {
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return ((this.state == State.modified || this.state == State.created) ? "*" : "")+display_name+" ("+id+")";
|
||||
return (needsSaving() ? "*" : "")+display_name+" ("+id+")";
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
||||
@@ -92,7 +92,7 @@ public class Dialogue extends JSONElement {
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return ((this.state == State.modified || this.state == State.created) ? "*" : "")+id;
|
||||
return (needsSaving() ? "*" : "")+id;
|
||||
}
|
||||
|
||||
public static String getStaticDesc() {
|
||||
|
||||
@@ -47,7 +47,7 @@ public class Droplist extends JSONElement {
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return ((this.state == State.modified || this.state == State.created) ? "*" : "")+id;
|
||||
return (needsSaving() ? "*" : "")+id;
|
||||
}
|
||||
|
||||
public static String getStaticDesc() {
|
||||
|
||||
@@ -102,7 +102,7 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
||||
}
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return this.name;
|
||||
return (needsSaving() ? "*" : "")+this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,7 +208,7 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
||||
impactedCategory = getProject().createdContent.gameData.getCategory(node.getClass());
|
||||
impactedFileName = node.getProjectFilename();
|
||||
}
|
||||
} else if (node.state == GameDataElement.State.modified) {
|
||||
} else if (node.needsSaving()) {
|
||||
events.add(new SaveEvent(SaveEvent.Type.alsoSave, node));
|
||||
}
|
||||
if (containedIds.containsKey(node.id)) {
|
||||
@@ -242,5 +242,12 @@ public class GameDataCategory<E extends JSONElement> extends ArrayList<E> implem
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
for (E node : this) {
|
||||
if (node.needsSaving()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
||||
}
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return "JSON data";
|
||||
return (needsSaving() ? "*" : "")+"JSON data";
|
||||
}
|
||||
|
||||
|
||||
@@ -463,4 +463,11 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
for (ProjectTreeNode node : v.getNonEmptyIterable()) {
|
||||
if (node.needsSaving()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class Item extends JSONElement {
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return ((this.state == State.modified || this.state == State.created) ? "*" : "")+name+" ("+id+")";
|
||||
return (needsSaving() ? "*" : "")+name+" ("+id+")";
|
||||
}
|
||||
|
||||
public static String getStaticDesc() {
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ItemCategory extends JSONElement {
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return ((this.state == State.modified || this.state == State.created) ? "*" : "")+name+" ("+id+")";
|
||||
return (needsSaving() ? "*" : "")+name+" ("+id+")";
|
||||
}
|
||||
|
||||
public static String getStaticDesc() {
|
||||
|
||||
@@ -96,7 +96,7 @@ public class NPC extends JSONElement {
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return ((this.state == State.modified || this.state == State.created) ? "*" : "")+name+" ("+id+")";
|
||||
return (needsSaving() ? "*" : "")+name+" ("+id+")";
|
||||
}
|
||||
|
||||
public static String getStaticDesc() {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Quest extends JSONElement {
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return ((this.state == State.modified || this.state == State.created) ? "*" : "")+name+" ("+id+")";
|
||||
return (needsSaving() ? "*" : "")+name+" ("+id+")";
|
||||
}
|
||||
|
||||
public static String getStaticDesc() {
|
||||
|
||||
@@ -120,6 +120,7 @@ public class Requirement extends JSONElement {
|
||||
break;
|
||||
}
|
||||
if (this.required_obj != null) this.required_obj.addBacklink((GameDataElement) this.parent);
|
||||
this.state = State.linked;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -62,7 +62,6 @@ public class TMXMap extends GameDataElement {
|
||||
public Integer outside = null;
|
||||
public ColorFilter colorFilter = null;
|
||||
|
||||
public boolean writable = false;
|
||||
public boolean changedOnDisk = false;
|
||||
public int dismissNextChangeNotif = 0;
|
||||
|
||||
@@ -129,6 +128,7 @@ public class TMXMap extends GameDataElement {
|
||||
clone.groups = new ArrayList<MapObjectGroup>();
|
||||
}
|
||||
MapObjectGroup group = new MapObjectGroup((tiled.core.ObjectGroup) layer, this);
|
||||
group.link();
|
||||
clone.groups.add(group);
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ public class TMXMap extends GameDataElement {
|
||||
}
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return ((this.state == State.modified || this.state == State.created) ? "*" : "")+id;
|
||||
return (needsSaving() ? "*" : "")+id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -315,7 +315,7 @@ public class TMXMap extends GameDataElement {
|
||||
if (this.state == GameDataElement.State.init) {
|
||||
parse();
|
||||
}
|
||||
if (this.state == GameDataElement.State.parsed || this.state == GameDataElement.State.created) {
|
||||
if (this.state == GameDataElement.State.parsed) {
|
||||
if (groups != null) {
|
||||
for (MapObjectGroup group : groups) {
|
||||
group.link();
|
||||
|
||||
@@ -187,7 +187,7 @@ public class TMXMapSet implements ProjectTreeNode {
|
||||
}
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return "TMX Maps";
|
||||
return (needsSaving() ? "*" : "")+"TMX Maps";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,4 +262,12 @@ public class TMXMapSet implements ProjectTreeNode {
|
||||
return tmxMaps.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
for (ProjectTreeNode node : tmxMaps) {
|
||||
if (node.needsSaving()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ public class Worldmap extends ArrayList<WorldmapSegment> implements ProjectTreeN
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return "Worldmap";
|
||||
return (needsSaving() ? "*" : "")+"Worldmap";
|
||||
}
|
||||
@Override
|
||||
public void notifyCreated() {
|
||||
@@ -277,6 +277,13 @@ public class Worldmap extends ArrayList<WorldmapSegment> implements ProjectTreeN
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
for (ProjectTreeNode node : this) {
|
||||
if (node.needsSaving()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class WorldmapSegment extends GameDataElement {
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return id;
|
||||
return (needsSaving() ? "*" : "")+id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -97,7 +97,7 @@ public class SavedGame extends GameDataElement {
|
||||
}
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return loadedSave.displayInfo;
|
||||
return (needsSaving() ? "*" : "")+loadedSave.displayInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -128,7 +128,7 @@ public class SavedGamesSet implements ProjectTreeNode, Serializable {
|
||||
}
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return "Saved games";
|
||||
return (needsSaving() ? "*" : "")+"Saved games";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -168,4 +168,13 @@ public class SavedGamesSet implements ProjectTreeNode, Serializable {
|
||||
public boolean isEmpty() {
|
||||
return saves.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
for (ProjectTreeNode node : saves) {
|
||||
if (node.needsSaving()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class SpriteSheetSet implements ProjectTreeNode {
|
||||
}
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return "Spritesheets";
|
||||
return (needsSaving() ? "*" : "")+"Spritesheets";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,4 +151,12 @@ public class SpriteSheetSet implements ProjectTreeNode {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
for (ProjectTreeNode node : spritesheets) {
|
||||
if (node.needsSaving()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class Spritesheet extends GameDataElement {
|
||||
}
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return spritesheetFile.getName();
|
||||
return (needsSaving() ? "*" : "")+spritesheetFile.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -413,7 +413,7 @@ public class WriterModeData extends GameDataElement {
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return (this.state == State.modified ? "*" : "")+id;
|
||||
return (needsSaving() ? "*" : "")+id;
|
||||
}
|
||||
@Override
|
||||
public Project getProject() {
|
||||
|
||||
@@ -110,7 +110,7 @@ public class WriterModeDataSet implements ProjectTreeNode, Serializable {
|
||||
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return "Dialogue sketchs";
|
||||
return (needsSaving() ? "*" : "")+"Dialogue sketchs";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,7 +195,7 @@ public class WriterModeDataSet implements ProjectTreeNode, Serializable {
|
||||
public List<SaveEvent> attemptSave() {
|
||||
List<SaveEvent> events = new ArrayList<SaveEvent>();
|
||||
for (WriterModeData data : writerModeDataList) {
|
||||
if (data.state == State.created || data.state == State.modified) {
|
||||
if (data.needsSaving()) {
|
||||
events.add(new SaveEvent(SaveEvent.Type.alsoSave, data));
|
||||
}
|
||||
}
|
||||
@@ -262,5 +262,14 @@ public class WriterModeDataSet implements ProjectTreeNode, Serializable {
|
||||
if (higherEmptyParent != null) higherEmptyParent.notifyCreated();
|
||||
else node.notifyCreated();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
for (ProjectTreeNode node : writerModeDataList) {
|
||||
if (node.needsSaving()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
100
src/com/gpl/rpg/atcontentstudio/ui/IdChangeImpactWizard.java
Normal file
100
src/com/gpl/rpg/atcontentstudio/ui/IdChangeImpactWizard.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package com.gpl.rpg.atcontentstudio.ui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
|
||||
public class IdChangeImpactWizard extends JDialog {
|
||||
|
||||
private static final long serialVersionUID = 8532169707953315739L;
|
||||
|
||||
public static enum Result {
|
||||
ok, cancel
|
||||
}
|
||||
|
||||
Result result = null;
|
||||
|
||||
private IdChangeImpactWizard(GameDataElement changing, List<GameDataElement> toModify, List<GameDataElement> toAlter) {
|
||||
super(ATContentStudio.frame, true);
|
||||
JPanel pane = new JPanel();
|
||||
pane.setLayout(new JideBoxLayout(pane, JideBoxLayout.PAGE_AXIS));
|
||||
|
||||
pane.add(new JLabel("Changing the id for \""+changing.getDesc()+"\" has impacts on your project:"), JideBoxLayout.FIX);
|
||||
pane.add(new JLabel("The following elements from your project will be modified:"), JideBoxLayout.FIX);
|
||||
JList<GameDataElement> modifList = new JList<GameDataElement>(new Vector<GameDataElement>(toModify));
|
||||
modifList.setCellRenderer(new ChangeImpactListCellRenderer());
|
||||
pane.add(new JScrollPane(modifList), JideBoxLayout.FIX);
|
||||
pane.add(new JLabel("The following elements from the game source will be altered:"), JideBoxLayout.FIX);
|
||||
JList<GameDataElement> alterList = new JList<GameDataElement>(new Vector<GameDataElement>(toAlter));
|
||||
alterList.setCellRenderer(new ChangeImpactListCellRenderer());
|
||||
pane.add(new JScrollPane(alterList), JideBoxLayout.FIX);
|
||||
pane.add(new JLabel("Press Ok to apply the changes, or Cancel to cancel your edition of the object's ID"), JideBoxLayout.FIX);
|
||||
|
||||
JPanel buttonPane = new JPanel();
|
||||
buttonPane.setLayout(new JideBoxLayout(buttonPane, JideBoxLayout.LINE_AXIS));
|
||||
buttonPane.add(new JPanel(), JideBoxLayout.VARY);
|
||||
JButton cancelButton = new JButton("Cancel");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
result = Result.cancel;
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
buttonPane.add(cancelButton, JideBoxLayout.FIX);
|
||||
JButton okButton = new JButton("Ok");
|
||||
okButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
result = Result.ok;
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
buttonPane.add(okButton, JideBoxLayout.FIX);
|
||||
pane.add(buttonPane, JideBoxLayout.FIX);
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
getContentPane().add(pane, BorderLayout.CENTER);
|
||||
pack();
|
||||
}
|
||||
|
||||
|
||||
public static Result showIdChangeImapctWizard(GameDataElement changing, List<GameDataElement> toModify, List<GameDataElement> toAlter) {
|
||||
IdChangeImpactWizard wizard = new IdChangeImpactWizard(changing, toModify, toAlter);
|
||||
wizard.setVisible(true);
|
||||
return wizard.result;
|
||||
}
|
||||
|
||||
public class ChangeImpactListCellRenderer extends DefaultListCellRenderer {
|
||||
private static final long serialVersionUID = 5764079243906396333L;
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if (c instanceof JLabel) {
|
||||
JLabel label = (JLabel) c;
|
||||
GameDataElement target = ((GameDataElement)value);
|
||||
label.setIcon(new ImageIcon(target.getIcon()));
|
||||
label.setText(target.getDataType().toString()+"/"+target.getDesc());
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -118,6 +118,7 @@ public class StudioFrame extends JFrame {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
Workspace.saveActive();
|
||||
actions.exitATCS.actionPerformed(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -95,14 +95,14 @@ public class WorkspaceActions {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (!(selectedNode instanceof GameDataElement)) return;
|
||||
final GameDataElement node = ((GameDataElement)selectedNode);
|
||||
if (node.state == GameDataElement.State.modified){
|
||||
if (node.needsSaving()){
|
||||
node.save();
|
||||
ATContentStudio.frame.nodeChanged(node);
|
||||
}
|
||||
};
|
||||
public void selectionChanged(ProjectTreeNode selectedNode, TreePath[] selectedPaths) {
|
||||
if (selectedNode instanceof GameDataElement) {
|
||||
setEnabled(((GameDataElement)selectedNode).state == GameDataElement.State.modified);
|
||||
setEnabled(((GameDataElement)selectedNode).needsSaving());
|
||||
} else {
|
||||
setEnabled(false);
|
||||
}
|
||||
@@ -330,8 +330,14 @@ public class WorkspaceActions {
|
||||
|
||||
public ATCSAction exitATCS = new ATCSAction("Exit", "Closes the program"){
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//TODO ouch.
|
||||
System.exit(0);
|
||||
if (Workspace.activeWorkspace.needsSaving()) {
|
||||
int answer = JOptionPane.showConfirmDialog(ATContentStudio.frame, "There are unsaved changes in your workspace.\nExiting ATCS will discard these changes.\nDo you really want to exit?", "Unsaved changes. Confirm exit.", JOptionPane.YES_NO_OPTION);
|
||||
if (answer == JOptionPane.YES_OPTION) {
|
||||
System.exit(0);
|
||||
}
|
||||
} else {
|
||||
System.exit(0);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -147,10 +147,22 @@ public class ActorConditionEditor extends JSONElementEditor {
|
||||
public void valueChanged(JComponent source, Object value) {
|
||||
ActorCondition aCond = (ActorCondition)target;
|
||||
if (source == idField) {
|
||||
aCond.id = (String) value;
|
||||
ActorConditionEditor.this.name = aCond.getDesc();
|
||||
aCond.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(ActorConditionEditor.this);
|
||||
//Events caused by cancel an ID edition. Dismiss.
|
||||
if (skipNext) {
|
||||
skipNext = false;
|
||||
return;
|
||||
}
|
||||
if (target.id.equals((String) value)) return;
|
||||
|
||||
if (idChanging()) {
|
||||
aCond.id = (String) value;
|
||||
ActorConditionEditor.this.name = aCond.getDesc();
|
||||
aCond.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(ActorConditionEditor.this);
|
||||
} else {
|
||||
cancelIdEdit(idField);
|
||||
return;
|
||||
}
|
||||
} else if (source == nameField) {
|
||||
aCond.display_name = (String) value;
|
||||
ActorConditionEditor.this.name = aCond.getDesc();
|
||||
|
||||
@@ -1075,10 +1075,22 @@ public class DialogueEditor extends JSONElementEditor {
|
||||
public void valueChanged(JComponent source, Object value) {
|
||||
Dialogue dialogue = (Dialogue) target;
|
||||
if (source == idField) {
|
||||
dialogue.id = (String) value;
|
||||
DialogueEditor.this.name = dialogue.getDesc();
|
||||
dialogue.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(DialogueEditor.this);
|
||||
//Events caused by cancel an ID edition. Dismiss.
|
||||
if (skipNext) {
|
||||
skipNext = false;
|
||||
return;
|
||||
}
|
||||
if (target.id.equals((String) value)) return;
|
||||
|
||||
if (idChanging()) {
|
||||
dialogue.id = (String) value;
|
||||
DialogueEditor.this.name = dialogue.getDesc();
|
||||
dialogue.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(DialogueEditor.this);
|
||||
} else {
|
||||
cancelIdEdit(idField);
|
||||
return;
|
||||
}
|
||||
} else if (source == messageField) {
|
||||
dialogue.message = (String) value;
|
||||
} else if (source == switchToNpcBox) {
|
||||
|
||||
@@ -248,10 +248,22 @@ public class DroplistEditor extends JSONElementEditor {
|
||||
public void valueChanged(JComponent source, Object value) {
|
||||
Droplist droplist = ((Droplist)target);
|
||||
if (source == idField) {
|
||||
droplist.id = (String) value;
|
||||
DroplistEditor.this.name = droplist.getDesc();
|
||||
droplist.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(DroplistEditor.this);
|
||||
//Events caused by cancel an ID edition. Dismiss.
|
||||
if (skipNext) {
|
||||
skipNext = false;
|
||||
return;
|
||||
}
|
||||
if (target.id.equals((String) value)) return;
|
||||
|
||||
if (idChanging()) {
|
||||
droplist.id = (String) value;
|
||||
DroplistEditor.this.name = droplist.getDesc();
|
||||
droplist.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(DroplistEditor.this);
|
||||
} else {
|
||||
cancelIdEdit(idField);
|
||||
return;
|
||||
}
|
||||
} else if (source == itemCombo) {
|
||||
if (selectedItem.item != null) {
|
||||
selectedItem.item.removeBacklink(droplist);
|
||||
|
||||
@@ -87,10 +87,22 @@ public class ItemCategoryEditor extends JSONElementEditor {
|
||||
public void valueChanged(JComponent source, Object value) {
|
||||
ItemCategory ic = (ItemCategory)target;
|
||||
if (source == idField) {
|
||||
ic.id = (String) value;
|
||||
ItemCategoryEditor.this.name = ic.getDesc();
|
||||
ic.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(ItemCategoryEditor.this);
|
||||
//Events caused by cancel an ID edition. Dismiss.
|
||||
if (skipNext) {
|
||||
skipNext = false;
|
||||
return;
|
||||
}
|
||||
if (target.id.equals((String) value)) return;
|
||||
|
||||
if (idChanging()) {
|
||||
ic.id = (String) value;
|
||||
ItemCategoryEditor.this.name = ic.getDesc();
|
||||
ic.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(ItemCategoryEditor.this);
|
||||
} else {
|
||||
cancelIdEdit(idField);
|
||||
return;
|
||||
}
|
||||
} else if (source == nameField) {
|
||||
ic.name = (String) value;
|
||||
ItemCategoryEditor.this.name = ic.getDesc();
|
||||
|
||||
@@ -936,10 +936,22 @@ public class ItemEditor extends JSONElementEditor {
|
||||
boolean updatePrice, updateEquip, updateHit, updateKill;
|
||||
updatePrice = updateEquip = updateHit = updateKill = false;
|
||||
if (source == idField) {
|
||||
item.id = (String) value;
|
||||
ItemEditor.this.name = item.getDesc();
|
||||
item.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(ItemEditor.this);
|
||||
//Events caused by cancel an ID edition. Dismiss.
|
||||
if (skipNext) {
|
||||
skipNext = false;
|
||||
return;
|
||||
}
|
||||
if (target.id.equals((String) value)) return;
|
||||
|
||||
if (idChanging()) {
|
||||
item.id = (String) value;
|
||||
ItemEditor.this.name = item.getDesc();
|
||||
item.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(ItemEditor.this);
|
||||
} else {
|
||||
cancelIdEdit(idField);
|
||||
return;
|
||||
}
|
||||
} else if (source == nameField) {
|
||||
item.name = (String) value;
|
||||
ItemEditor.this.name = item.getDesc();
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,6 +15,8 @@ import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
@@ -26,10 +29,13 @@ import com.gpl.rpg.atcontentstudio.model.ProjectTreeNode;
|
||||
import com.gpl.rpg.atcontentstudio.model.SaveEvent;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.GameDataCategory;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.JSONElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.TMXMap;
|
||||
import com.gpl.rpg.atcontentstudio.model.maps.WorldmapSegment;
|
||||
import com.gpl.rpg.atcontentstudio.model.sprites.Spritesheet;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.ui.Editor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
|
||||
import com.gpl.rpg.atcontentstudio.ui.IdChangeImpactWizard;
|
||||
import com.gpl.rpg.atcontentstudio.ui.SaveItemsWizard;
|
||||
import com.gpl.rpg.atcontentstudio.ui.sprites.SpriteChooser;
|
||||
import com.jidesoft.swing.JideBoxLayout;
|
||||
@@ -275,4 +281,64 @@ public abstract class JSONElementEditor extends Editor {
|
||||
message.revalidate();
|
||||
message.repaint();
|
||||
}
|
||||
|
||||
|
||||
public boolean idChanging() {
|
||||
JSONElement node = (JSONElement) target;
|
||||
List<GameDataElement> toModify = new LinkedList<GameDataElement>();
|
||||
List<GameDataElement> toAlter = new LinkedList<GameDataElement>();
|
||||
for (GameDataElement element : node.getBacklinks()) {
|
||||
GameDataElement activeElement = element;
|
||||
if (element instanceof JSONElement) {
|
||||
activeElement = node.getProject().getGameDataElement((Class<? extends JSONElement>) element.getClass(), element.id);
|
||||
} else if (element instanceof TMXMap) {
|
||||
activeElement = node.getProject().getMap(element.id);
|
||||
} else if (element instanceof WorldmapSegment) {
|
||||
activeElement = node.getProject().getWorldmapSegment(element.id);
|
||||
}
|
||||
if (activeElement.writable) {
|
||||
//No need to alter. Check if we flag a new modification.
|
||||
if (!activeElement.needsSaving()) {
|
||||
toModify.add(activeElement);
|
||||
}
|
||||
} else {
|
||||
toAlter.add(activeElement);
|
||||
}
|
||||
}
|
||||
if (!(toModify.isEmpty() && toAlter.isEmpty())) {
|
||||
IdChangeImpactWizard.Result result = IdChangeImpactWizard.showIdChangeImapctWizard(target, toModify, toAlter);
|
||||
if (result == IdChangeImpactWizard.Result.ok) {
|
||||
for (GameDataElement element : toModify) {
|
||||
element.state = GameDataElement.State.modified;
|
||||
element.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
}
|
||||
for (GameDataElement element : toAlter) {
|
||||
if (element instanceof JSONElement) {
|
||||
node.getProject().makeWritable((JSONElement)element);
|
||||
} else if (element instanceof TMXMap) {
|
||||
node.getProject().makeWritable((TMXMap)element);
|
||||
} else if (element instanceof WorldmapSegment) {
|
||||
node.getProject().makeWritable((WorldmapSegment)element);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//setText in cancelIdEdit generates to edit events, one replacing the contents with the empty string, and one with the target.id. We want to skip the first one.
|
||||
public boolean skipNext = false;
|
||||
public void cancelIdEdit(final JTextField idField) {
|
||||
Runnable revertField = new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
skipNext = true;
|
||||
idField.setText(target.id);
|
||||
}
|
||||
};
|
||||
SwingUtilities.invokeLater(revertField);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class NPCEditor extends JSONElementEditor {
|
||||
public void insertFormViewDataField(JPanel pane) {
|
||||
final NPC npc = (NPC) target;
|
||||
|
||||
final FieldUpdateListener listener = new NPCFieldUpdate();
|
||||
final FieldUpdateListener listener = new NPCFieldUpdater();
|
||||
|
||||
npcIcon = createButtonPane(pane, npc.getProject(), npc, NPC.class, npc.getImage(), Spritesheet.Category.monster, listener);
|
||||
|
||||
@@ -504,17 +504,29 @@ public class NPCEditor extends JSONElementEditor {
|
||||
return true;
|
||||
}
|
||||
|
||||
public class NPCFieldUpdate implements FieldUpdateListener {
|
||||
public class NPCFieldUpdater implements FieldUpdateListener {
|
||||
|
||||
@Override
|
||||
public void valueChanged(JComponent source, Object value) {
|
||||
NPC npc = (NPC)target;
|
||||
boolean updateHit = false;
|
||||
if (source == idField) {
|
||||
npc.id = (String) value;
|
||||
NPCEditor.this.name = npc.getDesc();
|
||||
npc.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(NPCEditor.this);
|
||||
//Events caused by cancel an ID edition. Dismiss.
|
||||
if (skipNext) {
|
||||
skipNext = false;
|
||||
return;
|
||||
}
|
||||
if (target.id.equals((String) value)) return;
|
||||
|
||||
if (idChanging()) {
|
||||
npc.id = (String) value;
|
||||
NPCEditor.this.name = npc.getDesc();
|
||||
npc.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(NPCEditor.this);
|
||||
} else {
|
||||
cancelIdEdit(idField);
|
||||
return;
|
||||
}
|
||||
} else if (source == nameField) {
|
||||
npc.name = (String) value;
|
||||
NPCEditor.this.name = npc.getDesc();
|
||||
|
||||
@@ -314,10 +314,22 @@ public class QuestEditor extends JSONElementEditor {
|
||||
public void valueChanged(JComponent source, Object value) {
|
||||
Quest quest = (Quest) target;
|
||||
if (source == idField) {
|
||||
quest.id = (String) value;
|
||||
QuestEditor.this.name = quest.getDesc();
|
||||
quest.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(QuestEditor.this);
|
||||
//Events caused by cancel an ID edition. Dismiss.
|
||||
if (skipNext) {
|
||||
skipNext = false;
|
||||
return;
|
||||
}
|
||||
if (target.id.equals((String) value)) return;
|
||||
|
||||
if (idChanging()) {
|
||||
quest.id = (String) value;
|
||||
QuestEditor.this.name = quest.getDesc();
|
||||
quest.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
ATContentStudio.frame.editorChanged(QuestEditor.this);
|
||||
} else {
|
||||
cancelIdEdit(idField);
|
||||
return;
|
||||
}
|
||||
} else if (source == nameField) {
|
||||
quest.name = (String) value;
|
||||
QuestEditor.this.name = quest.getDesc();
|
||||
|
||||
@@ -1615,7 +1615,7 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
gdeIcon.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (map.state == GameDataElement.State.modified || map.state == GameDataElement.State.created) {
|
||||
if (map.needsSaving()) {
|
||||
int confirm = JOptionPane.showConfirmDialog(TMXMapEditor.this, "You have unsaved changes in ATCS.\nYou'd better save your changes in ATCS before opening this map with the external editor.\nDo you want to save before opening the file?", "Save before opening?", JOptionPane.YES_NO_CANCEL_OPTION);
|
||||
if (confirm == JOptionPane.CANCEL_OPTION) return;
|
||||
if (confirm == JOptionPane.YES_OPTION) {
|
||||
@@ -1633,7 +1633,7 @@ public class TMXMapEditor extends Editor implements TMXMap.MapChangedOnDiskListe
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (map.state == GameDataElement.State.modified) {
|
||||
if (map.needsSaving()) {
|
||||
int confirm = JOptionPane.showConfirmDialog(TMXMapEditor.this, "You modified this map in ATCS. All ATCS-made changes will be lost if you confirm.\n On the other hand, if you save using ATCS, all external changes will be lost.\n Do you want to reload?", "Confirm reload?", JOptionPane.OK_CANCEL_OPTION);
|
||||
if (confirm == JOptionPane.CANCEL_OPTION) return;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,8 @@ public class WorldMapEditor extends Editor {
|
||||
|
||||
public String mapBeingAddedID = null;
|
||||
public String selectedLabel = null;
|
||||
|
||||
WorldMapView mapView = null;
|
||||
|
||||
public WorldMapEditor(WorldmapSegment worldmap) {
|
||||
target = worldmap;
|
||||
this.name = worldmap.id;
|
||||
@@ -114,7 +115,7 @@ public class WorldMapEditor extends Editor {
|
||||
addLabelField(pane, "Worldmap File: ", ((Worldmap)worldmap.getParent()).worldmapFile.getAbsolutePath());
|
||||
pane.add(createButtonPane(worldmap), JideBoxLayout.FIX);
|
||||
|
||||
final WorldMapView mapView = new WorldMapView(worldmap);
|
||||
mapView = new WorldMapView(worldmap);
|
||||
JScrollPane mapScroller = new JScrollPane(mapView);
|
||||
final JViewport vPort = mapScroller.getViewport();
|
||||
|
||||
@@ -296,6 +297,7 @@ public class WorldMapEditor extends Editor {
|
||||
for (String s : mapView.selected) {
|
||||
map.labelledMaps.get(selectedLabel).add(s);
|
||||
}
|
||||
notifyModelModified();
|
||||
mapView.revalidate();
|
||||
mapView.repaint();
|
||||
}
|
||||
@@ -319,6 +321,7 @@ public class WorldMapEditor extends Editor {
|
||||
worldmap.labels.put(created.id, created);
|
||||
worldmap.labels.remove(selectedLabel);
|
||||
selectedLabel = created.id;
|
||||
notifyModelModified();
|
||||
mapView.revalidate();
|
||||
mapView.repaint();
|
||||
}
|
||||
@@ -334,6 +337,7 @@ public class WorldMapEditor extends Editor {
|
||||
worldmap.labelledMaps.remove(selectedLabel);
|
||||
worldmap.labels.remove(selectedLabel);
|
||||
selectedLabel = null;
|
||||
notifyModelModified();
|
||||
mapView.revalidate();
|
||||
mapView.repaint();
|
||||
}
|
||||
@@ -348,6 +352,7 @@ public class WorldMapEditor extends Editor {
|
||||
public void labelCreated(NamedArea created) {
|
||||
worldmap.labelledMaps.put(created.id, new ArrayList<String>());
|
||||
worldmap.labelledMaps.get(created.id).addAll(mapView.selected);
|
||||
notifyModelModified();
|
||||
mapView.revalidate();
|
||||
mapView.repaint();
|
||||
}
|
||||
@@ -436,11 +441,12 @@ public class WorldMapEditor extends Editor {
|
||||
mapView.selected.remove(selectedMap);
|
||||
mapSelectionChanged();
|
||||
mapView.updateFromModel();
|
||||
notifyModelModified();
|
||||
update = true;
|
||||
} else if (editMode == EditMode.addMap && mapBeingAddedID != null) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||
mapView.recomputeSize();
|
||||
mapView.pushToModel();
|
||||
pushToModel();
|
||||
}
|
||||
mapView.updateFromModel();
|
||||
update = true;
|
||||
@@ -463,7 +469,7 @@ public class WorldMapEditor extends Editor {
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
dragStart = null;
|
||||
if (editMode == EditMode.moveMaps) {
|
||||
mapView.pushToModel();
|
||||
pushToModel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -713,4 +719,16 @@ public class WorldMapEditor extends Editor {
|
||||
message.repaint();
|
||||
}
|
||||
|
||||
public void pushToModel() {
|
||||
mapView.pushToModel();
|
||||
notifyModelModified();
|
||||
}
|
||||
|
||||
public void notifyModelModified() {
|
||||
target.state = GameDataElement.State.modified;
|
||||
this.name = ((WorldmapSegment)target).getDesc();
|
||||
target.childrenChanged(new ArrayList<ProjectTreeNode>());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user