From: <aki...@us...> - 2007-02-04 14:35:14
|
Revision: 1797 http://svn.sourceforge.net/gridarta/?rev=1797&view=rev Author: akirschbaum Date: 2007-02-04 06:35:14 -0800 (Sun, 04 Feb 2007) Log Message: ----------- Remove MapControl.addArchToMap(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java trunk/crossfire/src/cfeditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2007-02-04 14:24:05 UTC (rev 1796) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2007-02-04 14:35:14 UTC (rev 1797) @@ -401,7 +401,7 @@ */ private void addArchToMap(final MapControl mapControl, final GameObject gameObject, final Point pos, final boolean allowDouble, final boolean fillBelow) { if (gameObject.isArchetype()) { - mapControl.addArchToMap(gameObject.getArchetypeName(), pos, allowDouble, false, fillBelow); + mapControl.getMapModel().addArchToMap(gameObject.getArchetypeName(), pos, allowDouble, false, fillBelow); } else { final GameObject newGameObject = gameObject.createMultiClone(pos.x, pos.y); for (GameObject tmp = newGameObject; tmp != null; tmp = tmp.getMultiNext()) { Modified: trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java 2007-02-04 14:24:05 UTC (rev 1796) +++ trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java 2007-02-04 14:35:14 UTC (rev 1797) @@ -359,7 +359,7 @@ // insert replacement object if (randomArch.isMulti()) { // multi's cannot be inserted properly, so we just put them ontop - mapControl.addArchToMap(randomArch.getArchetypeName(), new Point(square.getMapX(), square.getMapY()), false, false); + mapControl.getMapModel().addArchToMap(randomArch.getArchetypeName(), new Point(square.getMapX(), square.getMapY()), false, false, false); // TODO: if from pickmap it could have special attributes -> copy them } else { Modified: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2007-02-04 14:24:05 UTC (rev 1796) +++ trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2007-02-04 14:35:14 UTC (rev 1797) @@ -257,7 +257,7 @@ } // first insert default arch from archlist - if (!allSpacesFree || !mapControl.addArchToMap(newarch.getArchetypeName(), pos, true, MapModel.JOIN_DISABLE)) { + if (!allSpacesFree || !mapControl.getMapModel().addArchToMap(newarch.getArchetypeName(), pos, true, MapModel.JOIN_DISABLE, false)) { // do nothing } else { // insertion successful, now get redraw info Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-02-04 14:24:05 UTC (rev 1796) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-02-04 14:35:14 UTC (rev 1797) @@ -174,23 +174,6 @@ return levelClosing; } - public boolean addArchToMap(final String archname, final Point pos, final boolean allowDouble, final boolean join, final boolean insertBelow) { - return mapModel.addArchToMap(archname, pos, allowDouble, join, insertBelow); - } - - /** - * Wrapper method for addArchToMap, always inserting new objects on top. - * @param archname Name of the archetype to add. - * @param pos Position of the newly created GameObject. - * @param allowDouble Whether multiple objects on the same square should be allowed (<code>true</code> to allow, <code>false</code> to forbid). - * @param join Whether autojoining should be applied (<code>true</code> to apply autojoining, <code>false</code> to disable it). - * @return Whether the object was added successfully. - */ - /** wrapper method for addArchToMap, always inserting new arches on top */ - public boolean addArchToMap(final String archname, final Point pos, final boolean allowDouble, final boolean join) { - return addArchToMap(archname, pos, allowDouble, join, false); - } - @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { return mapModel.insertArchToMap(newarch, archname, next, pos, join); } @@ -340,7 +323,7 @@ if (!mainControl.getMainView().isPickmapActive() || isPickmap() || (newarch != null && newarch.isArchetype())) { // insert default arch from archlist: mapModel.beginTransaction("Insert"); // TODO: I18N/L10N - if (!addArchToMap(mainControl.getPanelArchName(), pos, allowMany, MapModel.JOIN_ENABLE)) { + if (!mapModel.addArchToMap(mainControl.getPanelArchName(), pos, allowMany, MapModel.JOIN_ENABLE, false)) { // mainControl.getMainView().mapPanel.setMapArchList(null); // Toolkit.getDefaultToolkit().beep(); } else { @@ -370,7 +353,7 @@ // insert multi tile from pickmap: newarch = newarch.getHead(); // first insert default arch from archlist - if (!addArchToMap(newarch.getArchetypeName(), pos, allowMany, MapModel.JOIN_DISABLE)) { + if (!mapModel.addArchToMap(newarch.getArchetypeName(), pos, allowMany, MapModel.JOIN_DISABLE, false)) { // do nothing } else { // insertion successful, now get redraw info This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-02-04 14:39:48
|
Revision: 1798 http://svn.sourceforge.net/gridarta/?rev=1798&view=rev Author: akirschbaum Date: 2007-02-04 06:39:48 -0800 (Sun, 04 Feb 2007) Log Message: ----------- Remove MapControl.insertArchToMap(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java trunk/crossfire/src/cfeditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java 2007-02-04 14:35:14 UTC (rev 1797) +++ trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java 2007-02-04 14:39:48 UTC (rev 1798) @@ -363,7 +363,7 @@ // TODO: if from pickmap it could have special attributes -> copy them } else { - mapControl.insertArchToMap(randomArch, null, prevArch, new Point(square.getMapX(), square.getMapY()), false); + mapControl.getMapModel().insertArchToMap(randomArch, null, prevArch, new Point(square.getMapX(), square.getMapY()), false); } } replaceCount++; Modified: trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java 2007-02-04 14:35:14 UTC (rev 1797) +++ trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java 2007-02-04 14:39:48 UTC (rev 1798) @@ -237,10 +237,10 @@ currentMapControl.getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N final GameObject insertedGameObject; if (index >= view.getModelSize()) { - insertedGameObject = currentMapControl.insertArchToMap(gameObject, mainControl.getPanelArchName(), null, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), MapModel.JOIN_ENABLE); + insertedGameObject = currentMapControl.getMapModel().insertArchToMap(gameObject, mainControl.getPanelArchName(), null, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), MapModel.JOIN_ENABLE); } else { final GameObject entry = view.getListGameObject(index); - insertedGameObject = currentMapControl.insertArchToMap(gameObject, mainControl.getPanelArchName(), entry, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), MapModel.JOIN_ENABLE); + insertedGameObject = currentMapControl.getMapModel().insertArchToMap(gameObject, mainControl.getPanelArchName(), entry, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), MapModel.JOIN_ENABLE); } view.setSelectedGameObject(insertedGameObject); currentMapControl.getMapModel().endTransaction(); Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-02-04 14:35:14 UTC (rev 1797) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-02-04 14:39:48 UTC (rev 1798) @@ -174,10 +174,6 @@ return levelClosing; } - @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { - return mapModel.insertArchToMap(newarch, archname, next, pos, join); - } - public void addArchObjectToMap(final GameObject arch, final boolean insertBelow) { mapModel.addGameObjectToMap(arch, insertBelow); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-02-04 14:44:22
|
Revision: 1799 http://svn.sourceforge.net/gridarta/?rev=1799&view=rev Author: akirschbaum Date: 2007-02-04 06:44:22 -0800 (Sun, 04 Feb 2007) Log Message: ----------- Remove MapControl.addArchObjectToMap(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java trunk/crossfire/src/cfeditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2007-02-04 14:39:48 UTC (rev 1798) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2007-02-04 14:44:22 UTC (rev 1799) @@ -152,7 +152,7 @@ // copy this gameObject final GameObject clone = gameObject.createClone(posx - selRec.x, posy - selRec.y); assert copyMapCtrl != null; - copyMapCtrl.addArchObjectToMap(clone); + copyMapCtrl.getMapModel().addGameObjectToMap(clone, false); } // delete the gameObject if we have a "cut" or "clear" command // again, arches that don't match the view settings are ignored @@ -195,7 +195,7 @@ for (final GameObject gameObject : square) { if (!gameObject.isMulti()) { final GameObject clone = gameObject.createClone(pos.x, pos.y); - mapControl.addArchObjectToMap(clone); + mapControl.getMapModel().addGameObjectToMap(clone, false); } } } @@ -411,9 +411,9 @@ } } - mapControl.addArchObjectToMap(newGameObject, fillBelow); + mapControl.getMapModel().addGameObjectToMap(newGameObject, fillBelow); for (GameObject tmp = newGameObject.getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { - mapControl.addArchObjectToMap(tmp, fillBelow); + mapControl.getMapModel().addGameObjectToMap(tmp, fillBelow); mainControl.getArchetypeParser().postParseGameObject(tmp, mapControl.getActiveEditType()); } } Modified: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2007-02-04 14:39:48 UTC (rev 1798) +++ trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2007-02-04 14:44:22 UTC (rev 1799) @@ -240,7 +240,7 @@ if (!newarch.isMulti()) { // insert single tile from pickmap newarch = newarch.createClone(pos.x, pos.y); - mapControl.addArchObjectToMap(newarch); + mapControl.getMapModel().addGameObjectToMap(newarch, false); } else { // insert multi tile from pickmap: newarch = newarch.getHead(); Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-02-04 14:39:48 UTC (rev 1798) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-02-04 14:44:22 UTC (rev 1799) @@ -174,14 +174,6 @@ return levelClosing; } - public void addArchObjectToMap(final GameObject arch, final boolean insertBelow) { - mapModel.addGameObjectToMap(arch, insertBelow); - } - - public void addArchObjectToMap(final GameObject arch) { - mapModel.addGameObjectToMap(arch, false); - } - public void deleteMapArch(final GameObject gameObject, @NotNull final Point pos, final boolean join) { mapModel.deleteMapArch(gameObject, pos, join); } @@ -344,7 +336,7 @@ if (!newarch.isMulti()) { // insert single tile from pickmap newarch = newarch.createClone(pos.x, pos.y); - addArchObjectToMap(newarch); + mapModel.addGameObjectToMap(newarch, false); } else { // insert multi tile from pickmap: newarch = newarch.getHead(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-02-04 16:15:45
|
Revision: 1807 http://svn.sourceforge.net/gridarta/?rev=1807&view=rev Author: akirschbaum Date: 2007-02-04 08:15:41 -0800 (Sun, 04 Feb 2007) Log Message: ----------- Remove code to free map windows' back buffer. It is not needed anymore since all memory leaks preventing maps from being freed are fixed. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-02-04 15:51:00 UTC (rev 1806) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-02-04 16:15:41 UTC (rev 1807) @@ -335,10 +335,6 @@ return getViewport().getViewPosition(); } - public void freeMap() { - renderer.freeBackBuffer(); - } - public Size2D getMapSize() { return mapSize; } Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2007-02-04 15:51:00 UTC (rev 1806) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2007-02-04 16:15:41 UTC (rev 1807) @@ -243,14 +243,6 @@ return view.getViewPosition(); } - @Override public void dispose() { - super.dispose(); - /* workaround jvm 1.4 bug, does not free IFrame - * so let's free a maximum of ressources used by - * iframe*/ - view.freeMap(); - } - public CMapViewBasic getView() { return view; } Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-02-04 15:51:00 UTC (rev 1806) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-02-04 16:15:41 UTC (rev 1807) @@ -441,14 +441,6 @@ return true; } - /* (non-Javadoc) - * - * @see LevelRenderer#freeMapBuffer() - */ - @Override public void freeBackBuffer() { - backBuffer = null; - } - private void paintTile(final Graphics grfx, final Point point) { filter.newSquare(); setColor(grfx); Modified: trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2007-02-04 15:51:00 UTC (rev 1806) +++ trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2007-02-04 16:15:41 UTC (rev 1807) @@ -30,6 +30,4 @@ public abstract void modelChanged(); - public abstract void freeBackBuffer(); - } // class LevelRenderer This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-02-06 22:16:48
|
Revision: 1864 http://svn.sourceforge.net/gridarta/?rev=1864&view=rev Author: christianhujer Date: 2007-02-06 14:13:11 -0800 (Tue, 06 Feb 2007) Log Message: ----------- Removed pointless boolean constants. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/map/MapModel.java Modified: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2007-02-06 22:10:53 UTC (rev 1863) +++ trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2007-02-06 22:13:11 UTC (rev 1864) @@ -23,7 +23,6 @@ import cfeditor.CMapViewBasic; import cfeditor.gameobject.GameObject; import cfeditor.map.MapControl; -import cfeditor.map.MapModel; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.InputEvent; @@ -112,7 +111,7 @@ } if (tmpArch != null) { mapControl.getMapModel().beginTransaction("Delete Object"); - mapControl.deleteMapArch(tmpArch, temp, MapModel.JOIN_ENABLE); + mapControl.deleteMapArch(tmpArch, temp, true); mapControl.getMapModel().endTransaction(); } } @@ -219,7 +218,7 @@ } if (tmpArch != null) { mapControl.getMapModel().beginTransaction("Delete Object"); - mapControl.deleteMapArch(tmpArch, mapLoc, MapModel.JOIN_ENABLE); + mapControl.deleteMapArch(tmpArch, mapLoc, true); mapControl.getMapModel().endTransaction(); } } @@ -257,7 +256,7 @@ } // first insert default arch from archlist - if (!allSpacesFree || !mapControl.getMapModel().addArchToMap(newarch.getArchetypeName(), pos, true, MapModel.JOIN_DISABLE, false)) { + if (!allSpacesFree || !mapControl.getMapModel().addArchToMap(newarch.getArchetypeName(), pos, true, false, false)) { // do nothing } else { // insertion successful, now get redraw info Modified: trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java 2007-02-06 22:10:53 UTC (rev 1863) +++ trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java 2007-02-06 22:13:11 UTC (rev 1864) @@ -25,7 +25,6 @@ import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; -import cfeditor.map.MapModel; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -193,7 +192,7 @@ mapControl.getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N final GameObject entry = view.getListGameObject(index); if (entry != null) { - mapControl.deleteMapArch(entry, new Point(mapSquare.getMapX(), mapSquare.getMapY()), MapModel.JOIN_ENABLE); + mapControl.deleteMapArch(entry, new Point(mapSquare.getMapX(), mapSquare.getMapY()), true); if (index + 1 < view.getModelSize()) { view.setSelectedGameObject(view.getListGameObject(index + 1)); @@ -237,10 +236,10 @@ currentMapControl.getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N final GameObject insertedGameObject; if (index >= view.getModelSize()) { - insertedGameObject = currentMapControl.getMapModel().insertArchToMap(gameObject, mainControl.getPanelArchName(), null, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), MapModel.JOIN_ENABLE); + insertedGameObject = currentMapControl.getMapModel().insertArchToMap(gameObject, mainControl.getPanelArchName(), null, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), true); } else { final GameObject entry = view.getListGameObject(index); - insertedGameObject = currentMapControl.getMapModel().insertArchToMap(gameObject, mainControl.getPanelArchName(), entry, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), MapModel.JOIN_ENABLE); + insertedGameObject = currentMapControl.getMapModel().insertArchToMap(gameObject, mainControl.getPanelArchName(), entry, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), true); } view.setSelectedGameObject(insertedGameObject); currentMapControl.getMapModel().endTransaction(); Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2007-02-06 22:10:53 UTC (rev 1863) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2007-02-06 22:13:11 UTC (rev 1864) @@ -114,7 +114,7 @@ return false; } - if (mainControl.isAutoJoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null && AutojoinLists.getAutojoinList(archetype) != null && !archetype.isMulti()) { + if (mainControl.isAutoJoin() && join && mainControl.getJoinlist() != null && AutojoinLists.getAutojoinList(archetype) != null && !archetype.isMulti()) { // do autojoining if enabled archName = AutojoinLists.getAutojoinList(archetype).joinInsert(this, pos); if (archName == null) { @@ -277,7 +277,7 @@ // do autojoining final Archetype temp = getArchetype(node.getArchetypeName()); // get defarch - if (mainControl.isAutoJoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null && AutojoinLists.getAutojoinList(temp) != null && !temp.isMulti()) { + if (mainControl.isAutoJoin() && join && mainControl.getJoinlist() != null && AutojoinLists.getAutojoinList(temp) != null && !temp.isMulti()) { // remove connections to the deleted arch AutojoinLists.getAutojoinList(temp).joinDelete(this, pos); } Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-02-06 22:10:53 UTC (rev 1863) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-02-06 22:13:11 UTC (rev 1864) @@ -312,7 +312,7 @@ if (!mainControl.getMainView().isPickmapActive() || isPickmap() || (newarch != null && newarch.isArchetype())) { // insert default arch from archlist: mapModel.beginTransaction("Insert"); // TODO: I18N/L10N - if (!mapModel.addArchToMap(mainControl.getPanelArchName(), pos, allowMany, MapModel.JOIN_ENABLE, false)) { + if (!mapModel.addArchToMap(mainControl.getPanelArchName(), pos, allowMany, true, false)) { // mainControl.getMainView().mapPanel.setMapArchList(null); // Toolkit.getDefaultToolkit().beep(); } else { @@ -342,7 +342,7 @@ // insert multi tile from pickmap: newarch = newarch.getHead(); // first insert default arch from archlist - if (!mapModel.addArchToMap(newarch.getArchetypeName(), pos, allowMany, MapModel.JOIN_DISABLE, false)) { + if (!mapModel.addArchToMap(newarch.getArchetypeName(), pos, allowMany, false, false)) { // do nothing } else { // insertion successful, now get redraw info Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2007-02-06 22:10:53 UTC (rev 1863) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2007-02-06 22:13:11 UTC (rev 1864) @@ -31,12 +31,6 @@ */ public interface MapModel extends net.sf.gridarta.map.MapModel<GameObject, MapArchObject, Archetype>, Serializable { - /** Enable autojoin when inserting objects. */ - boolean JOIN_ENABLE = true; - - /** Disable autojoin when inserting objects. */ - boolean JOIN_DISABLE = false; - /** * Checks whether an GameObject (multi-arch) would still fit on this map. * @param archName name of arch to check This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-02-09 17:39:03
|
Revision: 1883 http://svn.sourceforge.net/gridarta/?rev=1883&view=rev Author: christianhujer Date: 2007-02-09 09:39:03 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Classes with clone() should be Cloneable. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CScriptModel.java trunk/crossfire/src/cfeditor/PluginParameter.java Modified: trunk/crossfire/src/cfeditor/CScriptModel.java =================================================================== --- trunk/crossfire/src/cfeditor/CScriptModel.java 2007-02-09 17:36:50 UTC (rev 1882) +++ trunk/crossfire/src/cfeditor/CScriptModel.java 2007-02-09 17:39:03 UTC (rev 1883) @@ -42,7 +42,7 @@ * @todo documentation * @author tchize */ -public final class CScriptModel { +public final class CScriptModel implements Cloneable { /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(CScriptModel.class); Modified: trunk/crossfire/src/cfeditor/PluginParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/PluginParameter.java 2007-02-09 17:36:50 UTC (rev 1882) +++ trunk/crossfire/src/cfeditor/PluginParameter.java 2007-02-09 17:39:03 UTC (rev 1883) @@ -36,7 +36,7 @@ * Parameter for a Plugin. * @author tchize */ -public abstract class PluginParameter { +public abstract class PluginParameter implements Cloneable { private Object value; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-03-20 07:32:41
|
Revision: 1931 http://svn.sourceforge.net/gridarta/?rev=1931&view=rev Author: akirschbaum Date: 2007-03-20 00:32:40 -0700 (Tue, 20 Mar 2007) Log Message: ----------- Split map and pickmap renderer implementation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java trunk/crossfire/src/cfeditor/gui/map/PickmapRenderer.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-03-20 06:17:28 UTC (rev 1930) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-03-20 07:32:40 UTC (rev 1931) @@ -24,7 +24,9 @@ import cfeditor.gui.MapView; import cfeditor.gui.map.DefaultLevelRenderer; import cfeditor.gui.map.LevelRenderer; +import cfeditor.gui.map.MapRenderer; import cfeditor.gui.map.MapUserListener; +import cfeditor.gui.map.PickmapRenderer; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; @@ -107,7 +109,7 @@ } this.mainControl = mainControl; - renderer = new DefaultLevelRenderer(this, mainControl, mapControl, isPickmap(), mapGrid); + renderer = isPickmap() ? new PickmapRenderer(this, mainControl, mapControl, mapGrid) : new MapRenderer(this, mainControl, mapControl, mapGrid); setViewportView(renderer); getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-03-20 06:17:28 UTC (rev 1930) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-03-20 07:32:40 UTC (rev 1931) @@ -19,7 +19,6 @@ package cfeditor.gui.map; -import cfeditor.CFilterControl; import cfeditor.CMainControl; import cfeditor.CMapViewBasic; import cfeditor.gameobject.Archetype; @@ -34,8 +33,6 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; -import javax.swing.ImageIcon; -import net.sf.gridarta.CommonConstants; import net.sf.gridarta.Size2D; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.MapGridEvent; @@ -53,7 +50,7 @@ * @author unknown * @author Andreas Kirschbaum */ -public final class DefaultLevelRenderer extends LevelRenderer { +public abstract class DefaultLevelRenderer extends LevelRenderer { /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(DefaultLevelRenderer.class); @@ -63,38 +60,19 @@ private final CMapViewBasic mapViewBasic; - /** - * Declares this <code>DefaultLevelRenderer</code> as a renderer for a - * Pickmap. Pickmaps have a special behaviour that's different from normal - * maps. Value: <code>true</code> if pickmap, otherwise <code>false</code>. - */ - private final boolean isPickmap; - /** offset to map borders (32 for std. rect. maps, 0 for pickmaps). */ - private final Point borderOffset = new Point(); + protected final Point borderOffset = new Point(); - private final Color[] highLightMask = new Color[] { - new Color(1.0f, 0.0f, 0.0f, 0.33f), - new Color(0.0f, 1.0f, 0.0f, 0.33f), - new Color(0.0f, 1.0f, 1.0f, 0.33f), - }; + protected final MapModel mapModel; - private BufferedImage backBuffer; + protected final CMainControl mainControl; - private final MapModel mapModel; - - private final CMainControl mainControl; - private Size2D mapSize; private final MapGrid mapGrid; - private final CFilterControl filter; + protected final ArchetypeSet archetypeSet; - private final ArchetypeSet archetypeSet; - - private final Point offset = new Point(); - /** * The map model listener to track changes in {@link #mapModel}. */ @@ -111,11 +89,9 @@ if (squares != null) { final Point point = new Point(); for (final MapSquare square : squares) { - if (!isPickmap) { - point.x = square.getMapX(); - point.y = square.getMapY(); - paintBackBufferTile(point); - } + point.x = square.getMapX(); + point.y = square.getMapY(); + updateTile(point); repaint(0, borderOffset.x + square.getMapX() * 32, borderOffset.y + square.getMapY() * 32, 32, 32); } } @@ -130,11 +106,9 @@ if (!gameObject.isInContainer()) { final MapSquare square = gameObject.getMapSquare(); if (square != null) { - if (!isPickmap) { - point.x = square.getMapX(); - point.y = square.getMapY(); - paintBackBufferTile(point); - } + point.x = square.getMapX(); + point.y = square.getMapY(); + updateTile(point); repaint(0, borderOffset.x + square.getMapX() * 32, borderOffset.y + square.getMapY() * 32, 32, 32); } } @@ -157,14 +131,7 @@ /** {@inheritDoc} */ public void mapGridChanged(@NotNull final MapGridEvent e) { final Rectangle recChange = mapGrid.getRecChange(); - if (!isPickmap) { - final Point point = new Point(); - for (point.x = recChange.x; point.x < recChange.x + recChange.width; point.x++) { - for (point.y = recChange.y; point.y < recChange.y + recChange.height; point.y++) { - paintBackBufferTile(point); - } - } - } + updateTiles(recChange); repaint(0, borderOffset.x + recChange.x * 32, borderOffset.y + recChange.y * 32, recChange.width * 32, recChange.height * 32); } @@ -180,23 +147,26 @@ * @param mapViewBasic MapView to render * @param mainControl MainControl, used for getting icons and similar * @param mapControl MapControl of the map to render - * @param pickmap <code>true</code> if the rendered map is a pickmap, otherwise <code>false</code> * @param mapGrid Grid to render + * @param borderSize the size of the map borders in pixel */ - public DefaultLevelRenderer(final CMapViewBasic mapViewBasic, final CMainControl mainControl, final MapControl mapControl, final boolean pickmap, final MapGrid mapGrid) { + public DefaultLevelRenderer(final CMapViewBasic mapViewBasic, final CMainControl mainControl, final MapControl mapControl, final MapGrid mapGrid, final int borderSize) { this.mapViewBasic = mapViewBasic; this.mainControl = mainControl; mapModel = mapControl.getMapModel(); mapSize = mapModel.getMapSize(); this.mapGrid = mapGrid; - filter = mainControl.getFilterControl(); archetypeSet = mainControl.getArchetypeSet(); - isPickmap = pickmap; - setFocusable(true); - borderOffset.setLocation(pickmap ? 0 : 32, pickmap ? 0 : 32); + borderOffset.setLocation(borderSize, borderSize); + } + + /** + * Finish initialization of this instance. + */ + protected void init() { resizeMapGrid(); mapModel.addMapModelListener(mapModelListener); mapGrid.addMapGridListener(mapGridListener); @@ -226,26 +196,11 @@ return bufImage; } - @Override public void paintComponent(final Graphics g) { - if (isPickmap) { - paintComponent(g, false, true); - } else { - paintFromBackbuffer(g, 0, 0, backBuffer.getWidth(), backBuffer.getHeight()); - } - } + /** {@inheritDoc} */ + @Override public abstract void paintComponent(final Graphics g); - private void paintFromBackbuffer(final Graphics grfx, final int x, final int y, final int width, final int height) { - if (grfx == null) { - return; - } - - grfx.drawImage(backBuffer, x + borderOffset.x, y + borderOffset.y, x + borderOffset.x + width, y + borderOffset.y + height, x, y, x + width, y + height, null); - } - @Override public void modelChanged() { - if (!isPickmap) { - paintComponent(backBuffer.getGraphics(), false, false); - } + updateAll(); repaint(); } @@ -270,7 +225,7 @@ * @param isSnapshot true when this drawing is for a "screenshot"-image, false for normal drawing * @param checkClip if set, omit tiles outside <code>grfx</code>'s clip area */ - private void paintComponent(final Graphics grfx, final boolean isSnapshot, final boolean checkClip) { + protected void paintComponent(final Graphics grfx, final boolean isSnapshot, final boolean checkClip) { setColor(grfx); grfx.fillRect(0, 0, getWidth(), getHeight()); paintMap(grfx, checkClip); @@ -281,24 +236,12 @@ } /** - * Paint one square of the map to the {@link #backBuffer}. - * @param point the map coordinates of the square to draw - */ - private void paintBackBufferTile(final Point point) { - assert backBuffer != null; - final Graphics grfx = backBuffer.getGraphics(); - paintTile(grfx, point); - paintTileGrid(grfx, point); - paintTileSelection(grfx, point); - } - - /** * Paint the grid for one square. The grid is not painted if it is * disabled. * @param grfx the graphics context to draw in * @param point the map coordinates of the square to draw */ - private void paintTileGrid(final Graphics grfx, final Point point) { + protected void paintTileGrid(final Graphics grfx, final Point point) { if (mapViewBasic.isGridVisible()) { // horizontal: grfx.drawLine(point.x * 32, point.y * 32, point.x * 32, point.y * 32 + 32); @@ -312,7 +255,7 @@ * @param grfx the graphics context to draw in * @param point map coordinates of the square to highlight */ - private void paintTileSelection(final Graphics grfx, final Point point) { + protected void paintTileSelection(final Graphics grfx, final Point point) { final int gridFlags = mapGrid.getFlags(point.x, point.y); if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { CMainControl.getMapSelIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); @@ -406,76 +349,17 @@ /** * Resize the backing buffer to the new grid size. * It will only be resized if the map is not a pickmap. + * @param mapSize the new map size * @return <code>true</code> if the back buffer was resized, otherwise <code>false</code>. */ - private boolean resizeBackBuffer() { - if (isPickmap) { - return false; - } + protected abstract boolean resizeBackBuffer(final Size2D mapSize); - final Dimension size = new Dimension(mapSize.getWidth() * 32, mapSize.getHeight() * 32); - if (backBuffer != null && backBuffer.getWidth() == size.width && backBuffer.getHeight() == size.height) { - return true; - } - - if (log.isDebugEnabled()) { - log.debug("Creating a backbuffer of size " + size.width + "x" + size.height + "."); - } - backBuffer = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB); - final Graphics g = backBuffer.getGraphics(); - g.setColor(Color.YELLOW); - g.fillRect(0, 0, size.width, size.height); - - return true; - } - /** * Paint one tile. * @param grfx the graphics context to draw to * @param point the map coordinates of the square to draw */ - private void paintTile(final Graphics grfx, final Point point) { - filter.newSquare(); - setColor(grfx); - if (!mapModel.containsArchObject(point)) { - if (isPickmap) { - grfx.fillRect(point.x * 32, point.y * 32, 32, 32); - } else { - CMainControl.getUnknownTileIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); - } - } else { - grfx.fillRect(point.x * 32, point.y * 32, 32, 32); - for (final GameObject node : mapModel.getMapSquare(point)) { - filter.objectInSquare(node); - if (!isPickmap && !filter.canShow(node)) { - continue; - } - if (!isPickmap && !mainControl.isTileEdit(node)) { - continue; - } - final ImageIcon img = archetypeSet.getFace(node); - if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { - offset.x = 0; - offset.y = 0; - } else { - // this is an oversized image, so it must be shifted - // XXX: it must also be clipped to not overwrite filter information - offset.x = 32 * (node.getMultiX() - node.getMinX()); - offset.y = 32 * (node.getMultiY() - node.getMinY()); - } - grfx.drawImage(img.getImage(), point.x * 32, point.y * 32, point.x * 32 + 32, point.y * 32 + 32, offset.x, offset.y, offset.x + 32, offset.y + 32, this); - } - } - for (int i = 0; i < CFilterControl.MAX_HIGHLIGHT; i++) { - if (isPickmap || !filter.highLightedSquare(i)) { - continue; - } - final Color c = grfx.getColor(); - grfx.setColor(highLightMask[i]); - grfx.fillRect(point.x * 32, point.y * 32, 32, 32); - grfx.setColor(c); - } - } + protected abstract void paintTile(final Graphics grfx, final Point point); /** * Update cached information to new map grid size. @@ -487,7 +371,7 @@ setPreferredSize(forcedSize); setMinimumSize(forcedSize); - if (resizeBackBuffer()) { + if (resizeBackBuffer(mapSize)) { setSize(forcedSize); revalidate(); } @@ -500,13 +384,34 @@ * * @param grfx the Graphics to change */ - private void setColor(final Graphics grfx) { - if (isPickmap) { - // draw greenisch background for pickmaps - grfx.setColor(CommonConstants.BG_COLOR); - } else { - grfx.setColor(mainControl.getMainView().getBackground()); - } + protected void setColor(final Graphics grfx) { + grfx.setColor(getBackgroundColor()); } + /** + * Return the background color for this window. + * + * @return the background color for this window + */ + protected abstract Color getBackgroundColor(); + + /** + * Callback function that is called when a tile may have changed. + * + * @param point the coordinate of the changed tile + */ + protected abstract void updateTile(final Point point); + + /** + * Callback function that is called when multiple tiles may have changed. + * + * @param rectangle the coordinates of the changed tiles + */ + protected abstract void updateTiles(final Rectangle rectangle); + + /** + * Callback function that is called when any tile may have changed. + */ + protected abstract void updateAll(); + } // class DefaultLevelRenderer Added: trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2007-03-20 07:32:40 UTC (rev 1931) @@ -0,0 +1,176 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.gui.map; + +import cfeditor.CFilterControl; +import cfeditor.CMainControl; +import cfeditor.CMapViewBasic; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapControl; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.image.BufferedImage; +import javax.swing.ImageIcon; +import net.sf.gridarta.Size2D; +import net.sf.gridarta.gui.map.MapGrid; +import org.apache.log4j.Logger; + +/** + * A {@link LevelRenderer} to render map files. + * + * @author Andreas Kirschbaum + */ +public final class MapRenderer extends DefaultLevelRenderer { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(MapRenderer.class); + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + private final CFilterControl filter; + + private final Color[] highLightMask = new Color[] { + new Color(1.0f, 0.0f, 0.0f, 0.33f), + new Color(0.0f, 1.0f, 0.0f, 0.33f), + new Color(0.0f, 1.0f, 1.0f, 0.33f), + }; + + private final Point offset = new Point(); + + private BufferedImage backBuffer; + + /** + * Create a new instance. + * @param mapViewBasic MapView to render + * @param mainControl MainControl, used for getting icons and similar + * @param mapControl MapControl of the map to render + * @param mapGrid Grid to render + */ + public MapRenderer(final CMapViewBasic mapViewBasic, final CMainControl mainControl, final MapControl mapControl, final MapGrid mapGrid) { + super(mapViewBasic, mainControl, mapControl, mapGrid, 32); + filter = mainControl.getFilterControl(); + init(); + } + + /** {@inheritDoc} */ + protected void updateTile(final Point point) { + assert backBuffer != null; + final Graphics grfx = backBuffer.getGraphics(); + paintTile(grfx, point); + paintTileGrid(grfx, point); + paintTileSelection(grfx, point); + } + + /** {@inheritDoc} */ + protected void updateTiles(final Rectangle rectangle) { + final Point point = new Point(); + for (point.x = rectangle.x; point.x < rectangle.x + rectangle.width; point.x++) { + for (point.y = rectangle.y; point.y < rectangle.y + rectangle.height; point.y++) { + updateTile(point); + } + } + } + + /** {@inheritDoc} */ + protected void updateAll() { + paintComponent(backBuffer.getGraphics(), false, false); + } + + /** {@inheritDoc} */ + @Override public void paintComponent(final Graphics g) { + paintFromBackbuffer(g, 0, 0, backBuffer.getWidth(), backBuffer.getHeight()); + } + + private void paintFromBackbuffer(final Graphics grfx, final int x, final int y, final int width, final int height) { + if (grfx == null) { + return; + } + + grfx.drawImage(backBuffer, x + borderOffset.x, y + borderOffset.y, x + borderOffset.x + width, y + borderOffset.y + height, x, y, x + width, y + height, null); + } + + /** {@inheritDoc} */ + protected boolean resizeBackBuffer(final Size2D mapSize) { + final Dimension size = new Dimension(mapSize.getWidth() * 32, mapSize.getHeight() * 32); + if (backBuffer != null && backBuffer.getWidth() == size.width && backBuffer.getHeight() == size.height) { + return true; + } + + if (log.isDebugEnabled()) { + log.debug("Creating a backbuffer of size " + size.width + "x" + size.height + "."); + } + backBuffer = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB); + final Graphics g = backBuffer.getGraphics(); + g.setColor(Color.YELLOW); + g.fillRect(0, 0, size.width, size.height); + + return true; + } + + /** {@inheritDoc} */ + protected Color getBackgroundColor() { + return mainControl.getMainView().getBackground(); + } + + /** {@inheritDoc} */ + protected void paintTile(final Graphics grfx, final Point point) { + filter.newSquare(); + setColor(grfx); + if (!mapModel.containsArchObject(point)) { + CMainControl.getUnknownTileIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); + } else { + grfx.fillRect(point.x * 32, point.y * 32, 32, 32); + for (final GameObject node : mapModel.getMapSquare(point)) { + filter.objectInSquare(node); + if (!filter.canShow(node)) { + continue; + } + if (!mainControl.isTileEdit(node)) { + continue; + } + final ImageIcon img = archetypeSet.getFace(node); + if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { + offset.x = 0; + offset.y = 0; + } else { + // this is an oversized image, so it must be shifted + // XXX: it must also be clipped to not overwrite filter information + offset.x = 32 * (node.getMultiX() - node.getMinX()); + offset.y = 32 * (node.getMultiY() - node.getMinY()); + } + grfx.drawImage(img.getImage(), point.x * 32, point.y * 32, point.x * 32 + 32, point.y * 32 + 32, offset.x, offset.y, offset.x + 32, offset.y + 32, this); + } + } + for (int i = 0; i < CFilterControl.MAX_HIGHLIGHT; i++) { + if (!filter.highLightedSquare(i)) { + continue; + } + final Color c = grfx.getColor(); + grfx.setColor(highLightMask[i]); + grfx.fillRect(point.x * 32, point.y * 32, 32, 32); + grfx.setColor(c); + } + } + +} // class MapRenderer Property changes on: trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/crossfire/src/cfeditor/gui/map/PickmapRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/PickmapRenderer.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/map/PickmapRenderer.java 2007-03-20 07:32:40 UTC (rev 1931) @@ -0,0 +1,115 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.gui.map; + +import cfeditor.CMainControl; +import cfeditor.CMapViewBasic; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapControl; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; +import javax.swing.ImageIcon; +import net.sf.gridarta.CommonConstants; +import net.sf.gridarta.Size2D; +import net.sf.gridarta.gui.map.MapGrid; +import org.apache.log4j.Logger; + +/** + * A {@link LevelRenderer} to render map files. + * + * @author Andreas Kirschbaum + */ +public final class PickmapRenderer extends DefaultLevelRenderer { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(PickmapRenderer.class); + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + private final Point offset = new Point(); + + /** + * Create a new instance. + * @param mapViewBasic MapView to render + * @param mainControl MainControl, used for getting icons and similar + * @param mapControl MapControl of the map to render + * @param mapGrid Grid to render + */ + public PickmapRenderer(final CMapViewBasic mapViewBasic, final CMainControl mainControl, final MapControl mapControl, final MapGrid mapGrid) { + super(mapViewBasic, mainControl, mapControl, mapGrid, 0); + init(); + } + + /** {@inheritDoc} */ + protected void updateTile(final Point point) { + // nothing to do + } + + /** {@inheritDoc} */ + protected void updateTiles(final Rectangle rectangle) { + // nothing to do + } + + /** {@inheritDoc} */ + protected void updateAll() { + // nothing to do + } + + /** {@inheritDoc} */ + @Override public void paintComponent(final Graphics g) { + paintComponent(g, false, true); + } + + /** {@inheritDoc} */ + protected boolean resizeBackBuffer(final Size2D mapSize) { + return false; + } + + /** {@inheritDoc} */ + protected Color getBackgroundColor() { + return CommonConstants.BG_COLOR; + } + + /** {@inheritDoc} */ + protected void paintTile(final Graphics grfx, final Point point) { + setColor(grfx); + grfx.fillRect(point.x * 32, point.y * 32, 32, 32); + if (!mapModel.containsArchObject(point)) { + return; + } + + for (final GameObject node : mapModel.getMapSquare(point)) { + final ImageIcon img = archetypeSet.getFace(node); + if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { + offset.x = 0; + offset.y = 0; + } else { + // this is an oversized image, so it must be shifted + offset.x = 32 * (node.getMultiX() - node.getMinX()); + offset.y = 32 * (node.getMultiY() - node.getMinY()); + } + grfx.drawImage(img.getImage(), point.x * 32, point.y * 32, point.x * 32 + 32, point.y * 32 + 32, offset.x, offset.y, offset.x + 32, offset.y + 32, this); + } + } + +} // class PickmapRenderer Property changes on: trunk/crossfire/src/cfeditor/gui/map/PickmapRenderer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-03-22 10:56:39
|
Revision: 1949 http://svn.sourceforge.net/gridarta/?rev=1949&view=rev Author: akirschbaum Date: 2007-03-22 03:56:40 -0700 (Thu, 22 Mar 2007) Log Message: ----------- Move edit type actions in view menu to separate class. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java Added Paths: ----------- trunk/crossfire/src/cfeditor/ViewActions.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-03-22 10:53:09 UTC (rev 1948) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-03-22 10:56:40 UTC (rev 1949) @@ -374,7 +374,7 @@ * each map where this type has not yet been used. * @param newType new selected edit type (should not be more than one) */ - private void selectEditType(final int newType) { + public void selectEditType(final int newType) { // calculate the new type for all opened maps: for (final MapControl mapControl : levels) { mapControl.addEditType(newType); // calculate new type @@ -391,78 +391,6 @@ this.autoJoin = autoJoin; } - private void setShow(final boolean show, final int editType) { - if (show) { - selectEditType(editType); - } else { - unsetTileEdit(editType); - } - } - - public boolean isShowMonster() { - return isTileEdit(IGUIConstants.TILE_EDIT_MONSTER); - } - - public void setShowMonster(final boolean showMonster) { - setShow(showMonster, IGUIConstants.TILE_EDIT_MONSTER); - } - - public boolean isShowExit() { - return isTileEdit(IGUIConstants.TILE_EDIT_EXIT); - } - - public void setShowExit(final boolean showExit) { - setShow(showExit, IGUIConstants.TILE_EDIT_EXIT); - } - - public boolean isShowBackground() { - return isTileEdit(IGUIConstants.TILE_EDIT_BACKGROUND); - } - - public void setShowBackground(final boolean showBackground) { - setShow(showBackground, IGUIConstants.TILE_EDIT_BACKGROUND); - } - - public boolean isShowDoor() { - return isTileEdit(IGUIConstants.TILE_EDIT_DOOR); - } - - public void setShowDoor(final boolean showDoor) { - setShow(showDoor, IGUIConstants.TILE_EDIT_DOOR); - } - - public boolean isShowWall() { - return isTileEdit(IGUIConstants.TILE_EDIT_WALL); - } - - public void setShowWall(final boolean showWall) { - setShow(showWall, IGUIConstants.TILE_EDIT_WALL); - } - - public boolean isShowEquipment() { - return isTileEdit(IGUIConstants.TILE_EDIT_EQUIP); - } - - public void setShowEquipment(final boolean showEquipment) { - setShow(showEquipment, IGUIConstants.TILE_EDIT_EQUIP); - } - - public boolean isShowTreasure() { - return isTileEdit(IGUIConstants.TILE_EDIT_TREASURE); - } - - public void setShowTreasure(final boolean showTreasure) { - setShow(showTreasure, IGUIConstants.TILE_EDIT_TREASURE); - } - - public boolean isShowConnected() { - return isTileEdit(IGUIConstants.TILE_EDIT_CONNECTED); - } - - public void setShowConnected(final boolean showConnected) { - setShow(showConnected, IGUIConstants.TILE_EDIT_CONNECTED); - } - public void onlineHelp() { mainView.openHelpWindow(); } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-03-22 10:53:09 UTC (rev 1948) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-03-22 10:56:40 UTC (rev 1949) @@ -127,6 +127,7 @@ */ CMainView() { super(mainControl, ACTION_FACTORY.format("mainWindow.title")); + viewActions = new ViewActions(mainControl); initActions(); final ImageIcon icon = CGUIUtils.getIcon(IGUIConstants.APP_ICON); @@ -722,19 +723,6 @@ return pickmapChooserControl.isLockAllPickmaps(); } - public void resetView() { - // set tileEdit to zero (-> show all) - mainControl.unsetTileEdit(~0); - ((ToggleAction) aShowMonster).setSelected(false); - ((ToggleAction) aShowExit).setSelected(false); - ((ToggleAction) aShowBackground).setSelected(false); - ((ToggleAction) aShowDoor).setSelected(false); - ((ToggleAction) aShowWall).setSelected(false); - ((ToggleAction) aShowEquipment).setSelected(false); - ((ToggleAction) aShowTreasure).setSelected(false); - ((ToggleAction) aShowConnected).setSelected(false); - } - private final String[] directionsMap = {"enterNorthMap", "enterEastMap", "enterSouthMap", "enterWestMap", "enterUpperMap", "enterLowerMap"}; /** {@inheritDoc} */ @@ -742,7 +730,6 @@ ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "gc", "prevWindow", "nextWindow", "onlineHelp", "about"); ACTION_FACTORY.createActions(true, mainControl.getScriptController().getView(), "editPlugins", "savePlugins", "exportPluginAs", "importPlugin"); ACTION_FACTORY.createActions(true, mainControl, directionsMap); - ACTION_FACTORY.createActions(true, this, "resetView"); ACTION_FACTORY.createToggles(true, mainControl, "autoJoin"); aTileShow.setEnabled(false); // not yet implemented @@ -764,22 +751,8 @@ private final Action aCloseAll = ACTION_FACTORY.createAction(true, "closeAll", mainControl); - private final Action aShowMonster = ACTION_FACTORY.createToggle(true, "showMonster", mainControl); + private final ViewActions viewActions; - private final Action aShowExit = ACTION_FACTORY.createToggle(true, "showExit", mainControl); - - private final Action aShowBackground = ACTION_FACTORY.createToggle(true, "showBackground", mainControl); - - private final Action aShowDoor = ACTION_FACTORY.createToggle(true, "showDoor", mainControl); - - private final Action aShowWall = ACTION_FACTORY.createToggle(true, "showWall", mainControl); - - private final Action aShowEquipment = ACTION_FACTORY.createToggle(true, "showEquipment", mainControl); - - private final Action aShowTreasure = ACTION_FACTORY.createToggle(true, "showTreasure", mainControl); - - private final Action aShowConnected = ACTION_FACTORY.createToggle(true, "showConnected", mainControl); - /** * Refresh actions from menu. * @todo remove me Added: trunk/crossfire/src/cfeditor/ViewActions.java =================================================================== --- trunk/crossfire/src/cfeditor/ViewActions.java (rev 0) +++ trunk/crossfire/src/cfeditor/ViewActions.java 2007-03-22 10:56:40 UTC (rev 1949) @@ -0,0 +1,179 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor; + +import javax.swing.Action; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ToggleAction; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * Manages edit type actions in "view" menu. + */ +public class ViewActions +{ + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(ViewActions.class); + + /** Action Factory to create Actions. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + /** The main control to use. */ + @NotNull private final CMainControl mainControl; + + /** Action for "show monster". */ + private final ToggleAction aShowMonster = (ToggleAction) ACTION_FACTORY.createToggle(true, "showMonster", this); + + /** Action for "show exit". */ + private final ToggleAction aShowExit = (ToggleAction) ACTION_FACTORY.createToggle(true, "showExit", this); + + /** Action for "show background". */ + private final ToggleAction aShowBackground = (ToggleAction) ACTION_FACTORY.createToggle(true, "showBackground", this); + + /** Action for "show door". */ + private final ToggleAction aShowDoor = (ToggleAction) ACTION_FACTORY.createToggle(true, "showDoor", this); + + /** Action for "show wall". */ + private final ToggleAction aShowWall = (ToggleAction) ACTION_FACTORY.createToggle(true, "showWall", this); + + /** Action for "show equipment". */ + private final ToggleAction aShowEquipment = (ToggleAction) ACTION_FACTORY.createToggle(true, "showEquipment", this); + + /** Action for "show treasure". */ + private final ToggleAction aShowTreasure = (ToggleAction) ACTION_FACTORY.createToggle(true, "showTreasure", this); + + /** Action for "show connected". */ + private final ToggleAction aShowConnected = (ToggleAction) ACTION_FACTORY.createToggle(true, "showConnected", this); + + /** + * Create a new instance. + * + * @param mainControl the main control to use + */ + public ViewActions(@NotNull final CMainControl mainControl) { + this.mainControl = mainControl; + ACTION_FACTORY.createActions(true, this, "resetView"); + } + + /** Action method for "reset view". */ + public void resetView() { + // set tileEdit to zero (-> show all) + mainControl.unsetTileEdit(~0); + aShowMonster.setSelected(false); + aShowExit.setSelected(false); + aShowBackground.setSelected(false); + aShowDoor.setSelected(false); + aShowWall.setSelected(false); + aShowEquipment.setSelected(false); + aShowTreasure.setSelected(false); + aShowConnected.setSelected(false); + } + + /** Action method for "show monster". */ + public boolean isShowMonster() { + return mainControl.isTileEdit(IGUIConstants.TILE_EDIT_MONSTER); + } + + /** Action method for "show monster". */ + public void setShowMonster(final boolean showMonster) { + setShow(showMonster, IGUIConstants.TILE_EDIT_MONSTER); + } + + /** Action method for "show exit". */ + public boolean isShowExit() { + return mainControl.isTileEdit(IGUIConstants.TILE_EDIT_EXIT); + } + + /** Action method for "show exit". */ + public void setShowExit(final boolean showExit) { + setShow(showExit, IGUIConstants.TILE_EDIT_EXIT); + } + + /** Action method for "show background". */ + public boolean isShowBackground() { + return mainControl.isTileEdit(IGUIConstants.TILE_EDIT_BACKGROUND); + } + + /** Action method for "show background". */ + public void setShowBackground(final boolean showBackground) { + setShow(showBackground, IGUIConstants.TILE_EDIT_BACKGROUND); + } + + /** Action method for "show door". */ + public boolean isShowDoor() { + return mainControl.isTileEdit(IGUIConstants.TILE_EDIT_DOOR); + } + + /** Action method for "show door". */ + public void setShowDoor(final boolean showDoor) { + setShow(showDoor, IGUIConstants.TILE_EDIT_DOOR); + } + + /** Action method for "show wall". */ + public boolean isShowWall() { + return mainControl.isTileEdit(IGUIConstants.TILE_EDIT_WALL); + } + + /** Action method for "show wall". */ + public void setShowWall(final boolean showWall) { + setShow(showWall, IGUIConstants.TILE_EDIT_WALL); + } + + /** Action method for "show equipment". */ + public boolean isShowEquipment() { + return mainControl.isTileEdit(IGUIConstants.TILE_EDIT_EQUIP); + } + + /** Action method for "show equipment". */ + public void setShowEquipment(final boolean showEquipment) { + setShow(showEquipment, IGUIConstants.TILE_EDIT_EQUIP); + } + + /** Action method for "show treasure". */ + public boolean isShowTreasure() { + return mainControl.isTileEdit(IGUIConstants.TILE_EDIT_TREASURE); + } + + /** Action method for "show treasure". */ + public void setShowTreasure(final boolean showTreasure) { + setShow(showTreasure, IGUIConstants.TILE_EDIT_TREASURE); + } + + /** Action method for "show connected". */ + public boolean isShowConnected() { + return mainControl.isTileEdit(IGUIConstants.TILE_EDIT_CONNECTED); + } + + /** Action method for "show connected". */ + public void setShowConnected(final boolean showConnected) { + setShow(showConnected, IGUIConstants.TILE_EDIT_CONNECTED); + } + + private void setShow(final boolean show, final int editType) { + if (show) { + mainControl.selectEditType(editType); + } else { + mainControl.unsetTileEdit(editType); + } + } + +} // class ViewActions Property changes on: trunk/crossfire/src/cfeditor/ViewActions.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-03-25 22:11:19
|
Revision: 1984 http://svn.sourceforge.net/gridarta/?rev=1984&view=rev Author: akirschbaum Date: 2007-03-25 15:11:20 -0700 (Sun, 25 Mar 2007) Log Message: ----------- Use MapView instead of MapViewIFrame. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/gui/MapView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-03-25 22:04:48 UTC (rev 1983) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-03-25 22:11:20 UTC (rev 1984) @@ -26,6 +26,7 @@ import cfeditor.gameobject.anim.AnimationObjects; import cfeditor.gameobject.face.FaceObjects; import cfeditor.gui.GameObjectAttributesDialog; +import cfeditor.gui.MapView; import cfeditor.gui.NewMapDialog; import cfeditor.gui.map.MapCursorControl; import cfeditor.gui.map.MapPropertiesDialog; @@ -637,11 +638,10 @@ /** * Invoked when the user wants to close the current view. * If there is only 1 view left the level will be closed. - * @param mapViewIFrame View to close + * @param mapView map view to close */ - public void closeView(final MapViewIFrame mapViewIFrame) { - final MapControl mapControl = mapViewIFrame.getMapControl(); - closeLevel(mapControl); + public void closeView(final MapView mapView) { + closeLevel(mapView.getMapControl()); } /** Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2007-03-25 22:04:48 UTC (rev 1983) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2007-03-25 22:11:20 UTC (rev 1984) @@ -196,10 +196,7 @@ return view.getActiveEditType(); } - /** - * Returns the controller of this view. - * @return the controller of this view. - */ + /** {@inheritDoc} */ public MapControl getMapControl() { return mapControl; } Modified: trunk/crossfire/src/cfeditor/gui/MapView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/MapView.java 2007-03-25 22:04:48 UTC (rev 1983) +++ trunk/crossfire/src/cfeditor/gui/MapView.java 2007-03-25 22:11:20 UTC (rev 1984) @@ -20,6 +20,7 @@ package cfeditor.gui; import cfeditor.CMapViewBasic; +import cfeditor.map.MapControl; /** * A mapview consists of two classes: The CMapViewBasic instance which contains @@ -35,4 +36,10 @@ CMapViewBasic getView(); + /** + * Returns the controller of this view. + * @return the controller of this view. + */ + MapControl getMapControl(); + } // interface MapView This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-03-25 22:19:06
|
Revision: 1985 http://svn.sourceforge.net/gridarta/?rev=1985&view=rev Author: akirschbaum Date: 2007-03-25 15:18:58 -0700 (Sun, 25 Mar 2007) Log Message: ----------- Remove MapControl.getViewPosition(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-03-25 22:11:20 UTC (rev 1984) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-03-25 22:18:58 UTC (rev 1985) @@ -1299,7 +1299,7 @@ public void revert(@NotNull final MapControl mapControl) { if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", mapControl.getMapFileName())) { final File mfile = mapControl.getMapFile(); // store file - final Point initial = mapControl.getViewPosition(); + final Point initial = mapControl.getMapViewFrame().getViewPosition(); closeLevel(mapControl, true); // close the old map openFile(mfile, true, initial); // open the new map Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-03-25 22:11:20 UTC (rev 1984) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-03-25 22:18:58 UTC (rev 1985) @@ -362,14 +362,6 @@ } /** - * Return the current view position. - * @return the current view position - */ - public Point getViewPosition() { - return mapViewFrame.getViewPosition(); - } - - /** * Get the last used view of this level. * @return the last used view */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-03-26 18:03:32
|
Revision: 1987 http://svn.sourceforge.net/gridarta/?rev=1987&view=rev Author: akirschbaum Date: 2007-03-26 11:03:28 -0700 (Mon, 26 Mar 2007) Log Message: ----------- Extract action handler code to separate class (cfeditor). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/map/MapCursorActions.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-03-26 17:20:47 UTC (rev 1986) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-03-26 18:03:28 UTC (rev 1987) @@ -105,7 +105,6 @@ mapCursor.addMapCursorListener(this); if (!mapControl.isPickmap()) { mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileListControl().getMapTileListView()); - mapCursor.addMapCursorListener(mainControl.getMapCursorControl()); } this.mainControl = mainControl; @@ -143,7 +142,6 @@ mapCursor.removeMapCursorListener(this); if (!mapControl.isPickmap()) { mapCursor.removeMapCursorListener(mainControl.getMainView().getMapTileListControl().getMapTileListView()); - mapCursor.removeMapCursorListener(mainControl.getMapCursorControl()); } setViewportView(null); mapModel.removeMapModelListener(this); Added: trunk/crossfire/src/cfeditor/gui/map/MapCursorActions.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapCursorActions.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/map/MapCursorActions.java 2007-03-26 18:03:28 UTC (rev 1987) @@ -0,0 +1,464 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.gui.map; + +import cfeditor.CMainControl; +import cfeditor.IGUIConstants; +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapArchObject; +import cfeditor.map.MapControl; +import javax.swing.Action; +import net.sf.gridarta.MainControlListener; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.gui.map.MapGrid; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Encapsulates actions used by {@link MapCursorControl}. + */ +public class MapCursorActions { + + /** Action Factory to create Actions. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + /** Directions for cursor movement. */ + private final String[] directionsGo = {"goNorth", "goEast", "goSouth", "goWest", "goNorthEast", "goSouthEast", "goSouthWest", "goNorthWest"}; + + /** Action for "go location". */ + private final Action aGoLocation = ACTION_FACTORY.createAction(true, "goLocation", this); + + /** Action for "select tile". */ + private final Action aSelectTile = ACTION_FACTORY.createAction(true, "selectTile", this); + + /** Action for "add to selection". */ + private final Action aAddToSelection = ACTION_FACTORY.createAction(true, "addToSelection", this); + + /** Action for "remove from selection". */ + private final Action aSubFromSelection = ACTION_FACTORY.createAction(true, "subFromSelection", this); + + /** Action for "stop stop drag". */ + private final Action aStartStopDrag = ACTION_FACTORY.createAction(true, "startStopDrag", this); + + /** Action for "release drag". */ + private final Action aReleaseDrag = ACTION_FACTORY.createAction(true, "releaseDrag", this); + + /** Action for "insert arch". */ + private final Action aInsertArch = ACTION_FACTORY.createAction(true, "insertArch", this); + + /** Action for "delete arch". */ + private final Action aDeleteArch = ACTION_FACTORY.createAction(true, "deleteArch", this); + + /** Action for "select arch above". */ + private final Action aSelectArchAbove = ACTION_FACTORY.createAction(true, "selectArchAbove", this); + + /** Action for "select arch below". */ + private final Action aSelectArchBelow = ACTION_FACTORY.createAction(true, "selectArchBelow", this); + + /** Action for "arch attributes". */ + private final Action aArchAttributes = ACTION_FACTORY.createAction(true, "archAttributes", this); + + /** + * The control for this instance. + */ + @NotNull private final MapCursorControl control; + + /** + * The currently active map control, or <code>null</code> if no map exists. + */ + @Nullable private MapControl mapControl; + + /** + * The main control listener used to detect changed current maps. + */ + private final MainControlListener<GameObject, MapArchObject, Archetype, MapControl> mainControlListener = new MainControlListener<GameObject, MapArchObject, Archetype, MapControl>() { + + /** {@inheritDoc} */ + public void currentMapChanged(@Nullable final MapControl mapControl) { + MapCursorActions.this.mapControl = mapControl; + refreshActions(); + } + + /** {@inheritDoc} */ + public void mapCreated(@NotNull final MapControl mapControl) { + mapControl.getMapCursor().addMapCursorListener(mapCursorListener); + } + + /** {@inheritDoc} */ + public void mapClosing(@NotNull final MapControl mapControl) { + mapControl.getMapCursor().removeMapCursorListener(mapCursorListener); + } + + }; + + /** + * The map cursor listener used to detect cursor state changes in {@link + * #mapControl}. + */ + private final MapCursorListener mapCursorListener = new MapCursorListener() { + + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + // ignore + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + refreshActions(); + } + + }; + + /** + * Create a new instance. + * + * @param control the map control for this instance + * + * @param mainControl the main control to query for current map changes + */ + public MapCursorActions(@NotNull final MapCursorControl control, @NotNull final CMainControl mainControl) { + this.control = control; + ACTION_FACTORY.createActions(true, this, directionsGo); + mapControl = mainControl.getCurrentMap(); + mainControl.addMainControlListener(mainControlListener); + refreshActions(); + } + + /** Action method for "cursor north". */ + public void goNorth() { + final MapCursor mapCursor = getGoEnabled(); + if (mapCursor != null) { + control.goTo(mapCursor, IGUIConstants.NORTH); + } + } + + /** Action method for "cursor south". */ + public void goSouth() { + final MapCursor mapCursor = getGoEnabled(); + if (mapCursor != null) { + control.goTo(mapCursor, IGUIConstants.SOUTH); + } + } + + /** Action method for "cursor east". */ + public void goEast() { + final MapCursor mapCursor = getGoEnabled(); + if (mapCursor != null) { + control.goTo(mapCursor, IGUIConstants.EAST); + } + } + + /** Action method for "cursor west". */ + public void goWest() { + final MapCursor mapCursor = getGoEnabled(); + if (mapCursor != null) { + control.goTo(mapCursor, IGUIConstants.WEST); + } + } + + /** Action method for "cursor north east". */ + public void goNorthEast() { + final MapCursor mapCursor = getGoEnabled(); + if (mapCursor != null) { + control.goTo(mapCursor, IGUIConstants.NORTH_EAST); + } + } + + /** Action method for "cursor north west". */ + public void goNorthWest() { + final MapCursor mapCursor = getGoEnabled(); + if (mapCursor != null) { + control.goTo(mapCursor, IGUIConstants.NORTH_WEST); + } + } + + /** Action method for "cursor south east". */ + public void goSouthEast() { + final MapCursor mapCursor = getGoEnabled(); + if (mapCursor != null) { + control.goTo(mapCursor, IGUIConstants.SOUTH_EAST); + } + } + + /** Action method for "cursor south west". */ + public void goSouthWest() { + final MapCursor mapCursor = getGoEnabled(); + if (mapCursor != null) { + control.goTo(mapCursor, IGUIConstants.SOUTH_WEST); + } + } + + /** Action method for "go location". */ + public void goLocation() { + final MapControl mapControl = getGoLocationEnabled(); + if (mapControl != null) { + control.goLocation(mapControl); + } + } + + /** Action method for "select tile". */ + public void selectTile() { + final MapCursor mapCursor = getSelectTileEnabled(); + if (mapCursor != null) { + control.selectTile(mapCursor, MapGrid.SelectionMode.FLIP); + } + } + + /** Action method for "add to selection". */ + public void addToSelection() { + final MapCursor mapCursor = getAddToSelectionEnabled(); + if (mapCursor != null) { + control.selectTile(mapCursor, MapGrid.SelectionMode.ADD); + } + } + + /** Action method for "remove from selection". */ + public void subFromSelection() { + final MapCursor mapCursor = getSubFromSelectionEnabled(); + if (mapCursor != null) { + control.selectTile(mapCursor, MapGrid.SelectionMode.SUB); + } + } + + /** Action method for "start stop drag". */ + public void startStopDrag() { + final MapCursor mapCursor = getStartStopDragEnabled(); + if (mapCursor != null) { + control.startStopDrag(mapCursor); + } + } + + /** Action method for "release drag". */ + public void releaseDrag() { + final MapCursor mapCursor = getReleaseDragEnabled(); + if (mapCursor != null) { + control.releaseDrag(mapCursor); + } + } + + /** Action method for "insert arch". */ + public void insertArch() { + final MapControl mapControl = getInsertArchEnabled(); + if (mapControl != null) { + control.insertArch(); // XXX: should pass mapControl + } + } + + /** Action method for "delete arch". */ + public void deleteArch() { + final MapControl mapControl = getDeleteArchEnabled(); + if (mapControl != null) { + control.deleteArch(); // XXX: should pass mapControl + } + } + + /** Action method for "select arch above". */ + public void selectArchAbove() { + final MapCursor mapCursor = getSelectArchAboveEnabled(); + if (mapCursor != null) { + control.selectArch(true); // XXX: should pass mapCursor + } + } + + /** Action method for "arch attributes". */ + public void archAttributes() { + final MapCursor mapCursor = getArchAttributesEnabled(); + if (mapCursor != null) { + control.archAttributes(); // XXX: should pass mapCursor + } + } + + /** Action method for "select arch below". */ + public void selectArchBelow() { + final MapCursor mapCursor = getSelectArchBelowEnabled(); + if (mapCursor != null) { + control.selectArch(false); // XXX: should pass mapCursor + } + } + + /** + * Return the map cursor to use for "move cursor". + * + * @return the map cursor, or <code>null</code> if "move cursor" is + * disabled + */ + @Nullable private MapCursor getGoEnabled() { + return getActiveMapCursor(); + } + + /** + * Return the map control to use for "go location". + * + * @return the map control, or <code>null</code> if "go location" is + */ + @Nullable private MapControl getGoLocationEnabled() { + return mapControl; + } + + /** + * Return the map cursor to use for "select tile". + * + * @return the map cursor, or <code>null</code> if "select tile" is + * disabled + */ + @Nullable private MapCursor getSelectTileEnabled() { + return getActiveMapCursor(); + } + + /** + * Return the map cursor to use for "add to selection". + * + * @return the map cursor, or <code>null</code> if "add to selection" is + * disabled + */ + @Nullable private MapCursor getAddToSelectionEnabled() { + return getActiveMapCursor(); + } + + /** + * Return the map cursor to use for "remove from selection". + * + * @return the map cursor, or <code>null</code> if "remove from selection" + * is disabled + */ + @Nullable private MapCursor getSubFromSelectionEnabled() { + return getActiveMapCursor(); + } + + /** + * Return the map cursor to use for "start stop drag". + * + * @return the map cursor, or <code>null</code> if "start stop drag" is + * disabled + */ + @Nullable private MapCursor getStartStopDragEnabled() { + return getActiveMapCursor(); + } + + /** + * Return the map cursor to use for "release drag". + * + * @return the map cursor, or <code>null</code> if "release drag" is + * disabled + */ + @Nullable private MapCursor getReleaseDragEnabled() { + return getActiveMapCursor(); + } + + /** + * Return the map control to use for "insert arch". + * + * @return the map control, or <code>null</code> if "insert arch" is + * disabled + */ + @Nullable private MapControl getInsertArchEnabled() { + return getActiveMapCursor() != null ? mapControl : null; + } + + /** + * Return the map control to use for "delete arch". + * + * @return the map control, or <code>null</code> if "delete arch" is + * disabled + */ + @Nullable private MapControl getDeleteArchEnabled() { + return getActiveMapCursor() != null ? mapControl : null; + } + + /** + * Return the map cursor to use for "select arch above". + * + * @return the map cursor, or <code>null</code> if "select arch above" is + * disabled + */ + @Nullable private MapCursor getSelectArchAboveEnabled() { + return getActiveMapCursor(); + } + + /** + * Return the map cursor to use for "select arch below". + * + * @return the map cursor, or <code>null</code> if "select arch below" is + * disabled + */ + @Nullable private MapCursor getSelectArchBelowEnabled() { + return getActiveMapCursor(); + } + + /** + * Return the map cursor to use for "arch attributes". + * + * @return the map cursor, or <code>null</code> if "arch attributes" is + * disabled + */ + @Nullable private MapCursor getArchAttributesEnabled() { + return getActiveMapCursor(); + } + + /** + * Return the map cursor of the current map view if it is active. + * + * @return the map cursor, or <code>null</code> if the cursor is not + * active, or if no map view exists + */ + @Nullable private MapCursor getActiveMapCursor() { + final MapCursor mapCursor = getMapCursor(); + return mapCursor != null && mapCursor.isActive() ? mapCursor : null; + } + + /** + * Return the map cursor of the current map view. + * + * @return the map cursor, or <code>null</code> if no map view exists + */ + @Nullable private MapCursor getMapCursor() { + return mapControl != null ? mapControl.getMapCursor() : null; + } + + /** + * Enable/disable menu entries based on the current cursor state. + */ + private void refreshActions() { + final MapCursor mapCursor = mapControl != null ? mapControl.getMapCursor() : null; + + final boolean hasCursor = mapCursor != null && mapCursor.isActive(); + + final boolean goEnabled = getGoEnabled() != null; + for (final String aDirectionsGo : directionsGo) { + ACTION_FACTORY.getAction(aDirectionsGo).setEnabled(goEnabled); + } + aGoLocation.setEnabled(getGoLocationEnabled() != null); + aSelectTile.setEnabled(getSelectTileEnabled() != null); + aAddToSelection.setEnabled(getAddToSelectionEnabled() != null); + aSubFromSelection.setEnabled(getSubFromSelectionEnabled() != null); + aStartStopDrag.setEnabled(getStartStopDragEnabled() != null); + aReleaseDrag.setEnabled(getReleaseDragEnabled() != null); + aInsertArch.setEnabled(getInsertArchEnabled() != null); + aDeleteArch.setEnabled(getDeleteArchEnabled() != null); + aSelectArchAbove.setEnabled(getSelectArchAboveEnabled() != null); + aSelectArchBelow.setEnabled(getSelectArchBelowEnabled() != null); + aArchAttributes.setEnabled(getArchAttributesEnabled() != null); + } + +} // class MapCursorActions Property changes on: trunk/crossfire/src/cfeditor/gui/map/MapCursorActions.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2007-03-26 17:20:47 UTC (rev 1986) +++ trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2007-03-26 18:03:28 UTC (rev 1987) @@ -21,21 +21,13 @@ import cfeditor.CMainControl; import cfeditor.CMainView; -import cfeditor.IGUIConstants; -import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.gui.selectedsquare.SelectedSquareControl; -import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import java.awt.Point; -import javax.swing.Action; -import net.sf.gridarta.MainControlListener; import net.sf.gridarta.gui.map.GoLocationDialog; import net.sf.gridarta.gui.map.MapCursor; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGrid; -import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -45,162 +37,41 @@ * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> * @author Andreas Kirschbaum */ -public class MapCursorControl implements MapCursorListener { +public class MapCursorControl { - /** Action Factory to create Actions. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - /** The MainControl. */ private final CMainControl mainControl; - /** Directions for cursor movement. */ - private final String[] directionsGo = {"goNorth", "goEast", "goSouth", "goWest", "goNorthEast", "goSouthEast", "goSouthWest", "goNorthWest"}; + @NotNull private final MapCursorActions actions; - private final Action aGoLocation = ACTION_FACTORY.createAction(true, "goLocation", this); - - private final Action aSelectTile = ACTION_FACTORY.createAction(true, "selectTile", this); - - private final Action aStartStopDrag = ACTION_FACTORY.createAction(true, "startStopDrag", this); - - private final Action aAddToSelection = ACTION_FACTORY.createAction(true, "addToSelection", this); - - private final Action aSubFromSelection = ACTION_FACTORY.createAction(true, "subFromSelection", this); - - private final Action aReleaseDrag = ACTION_FACTORY.createAction(true, "releaseDrag", this); - - private final Action aInsertArch = ACTION_FACTORY.createAction(true, "insertArch", this); - - private final Action aDeleteArch = ACTION_FACTORY.createAction(true, "deleteArch", this); - - private final Action aSelectArchAbove = ACTION_FACTORY.createAction(true, "selectArchAbove", this); - - private final Action aSelectArchBelow = ACTION_FACTORY.createAction(true, "selectArchBelow", this); - - private final Action aArchAttributes = ACTION_FACTORY.createAction(true, "archAttributes", this); - /** - * The main control listener used to detect changed current maps. - */ - private final MainControlListener<GameObject, MapArchObject, Archetype, MapControl> mainControlListener = new MainControlListener<GameObject, MapArchObject, Archetype, MapControl>() { - - /** {@inheritDoc} */ - public void currentMapChanged(@Nullable final MapControl mapControl) { - refreshMenus(); - } - - /** {@inheritDoc} */ - public void mapCreated(@NotNull final MapControl mapControl) { - // ignore - } - - /** {@inheritDoc} */ - public void mapClosing(@NotNull final MapControl mapControl) { - // ignore - } - - }; - - /** * Create a MapCursorControl. * @param mainControl MainControl to use (used for getting the current map etc.) */ public MapCursorControl(final CMainControl mainControl) { this.mainControl = mainControl; - - ACTION_FACTORY.createActions(true, this, directionsGo); - - mainControl.addMainControlListener(mainControlListener); - refreshMenus(); + actions = new MapCursorActions(this, mainControl); } /** * Move cursor to specified direction. - * @param dir Constants in #IGUIConstants + * @param mapCursor the map cursor to change + * @param dir Constants in <code>IGUIConstants</code> */ - public void goTo(final int dir) { - final MapCursor mapCursor = getMapCursor(); - if (mapCursor.isActive()) { - mapCursor.goTo(dir); - } else { - mapCursor.setLocation(new Point(0, 0)); - } + void goTo(@NotNull final MapCursor mapCursor, final int dir) { + mapCursor.goTo(dir); } - public void goNorth() { - goTo(IGUIConstants.NORTH); + void goLocation(@NotNull final MapControl mapControl) { + GoLocationDialog.showGoLocationDialog(mapControl.getMapViewFrame(), mapControl); } - public void goSouth() { - goTo(IGUIConstants.SOUTH); - } - - public void goEast() { - goTo(IGUIConstants.EAST); - } - - public void goWest() { - goTo(IGUIConstants.WEST); - } - - public void goNorthEast() { - goTo(IGUIConstants.NORTH_EAST); - } - - public void goNorthWest() { - goTo(IGUIConstants.NORTH_WEST); - } - - public void goSouthEast() { - goTo(IGUIConstants.SOUTH_EAST); - } - - public void goSouthWest() { - goTo(IGUIConstants.SOUTH_WEST); - } - - public void goLocation() { - final MapControl mapControl = mainControl.getCurrentMap(); - if (mapControl != null) { - GoLocationDialog.showGoLocationDialog(mapControl.getMapViewFrame(), mapControl); - } - } - - public void selectTile() { - selectTile(MapGrid.SelectionMode.FLIP); - } - - public void addToSelection() { - selectTile(MapGrid.SelectionMode.ADD); - } - - public void subFromSelection() { - selectTile(MapGrid.SelectionMode.SUB); - } - - public void insertArch() { - final CMainView mainView = mainControl.getMainView(); - assert mainView != null; - final SelectedSquareControl selectedSquareControl = mainView.getMapTileListControl(); - assert selectedSquareControl != null; - selectedSquareControl.insertGameObjectFromArchPanel(); - } - - public void deleteArch() { - final CMainView mainView = mainControl.getMainView(); - assert mainView != null; - final SelectedSquareControl selectedSquareControl = mainView.getMapTileListControl(); - assert selectedSquareControl != null; - selectedSquareControl.deleteSelection(); - } - - private void selectTile(final MapGrid.SelectionMode mode) { - final MapCursor mapCursor = getMapCursor(); + void selectTile(@NotNull final MapCursor mapCursor, final MapGrid.SelectionMode mode) { mapCursor.dragStart(); mapCursor.dragSelect(mode); } - public void startStopDrag() { - final MapCursor mapCursor = getMapCursor(); + void startStopDrag(@NotNull final MapCursor mapCursor) { if (mapCursor.isDragging()) { mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); } else { @@ -208,8 +79,7 @@ } } - public void releaseDrag() { - final MapCursor mapCursor = getMapCursor(); + void releaseDrag(@NotNull final MapCursor mapCursor) { if (mapCursor.isDragging()) { mapCursor.dragRelease(); } else { @@ -219,85 +89,47 @@ } } - public void selectArchBelow() { - selectArch(false); + void insertArch() { + final CMainView mainView = mainControl.getMainView(); + assert mainView != null; + final SelectedSquareControl selectedSquareControl = mainView.getMapTileListControl(); + assert selectedSquareControl != null; + selectedSquareControl.insertGameObjectFromArchPanel(); } - public void selectArchAbove() { - selectArch(true); + void deleteArch() { + final CMainView mainView = mainControl.getMainView(); + assert mainView != null; + final SelectedSquareControl selectedSquareControl = mainView.getMapTileListControl(); + assert selectedSquareControl != null; + selectedSquareControl.deleteSelection(); } /** * Select arch below or above selected arch. * @param above if <code>true</code> arch above is selected otherwise arch below is selected */ - private void selectArch(final boolean above) { - if (getMapCursor().isActive()) { - final CMainView mainView = mainControl.getMainView(); - assert mainView != null; - final SelectedSquareControl selectedSquareControl = mainView.getMapTileListControl(); - assert selectedSquareControl != null; - if (above) { - selectedSquareControl.selectArchAbove(); - } else { - selectedSquareControl.selectArchBelow(); - } + void selectArch(final boolean above) { + final CMainView mainView = mainControl.getMainView(); + assert mainView != null; + final SelectedSquareControl selectedSquareControl = mainView.getMapTileListControl(); + assert selectedSquareControl != null; + if (above) { + selectedSquareControl.selectArchAbove(); + } else { + selectedSquareControl.selectArchBelow(); } } - public void archAttributes() { - if (getMapCursor().isActive()) { - final CMainView mainView = mainControl.getMainView(); - assert mainView != null; - final SelectedSquareControl selectedSquareControl = mainView.getMapTileListControl(); - assert selectedSquareControl != null; - final GameObject arch = selectedSquareControl.getMapTileSelection(); - if (arch != null) { - mainControl.openAttrDialog(arch); - } + void archAttributes() { + final CMainView mainView = mainControl.getMainView(); + assert mainView != null; + final SelectedSquareControl selectedSquareControl = mainView.getMapTileListControl(); + assert selectedSquareControl != null; + final GameObject arch = selectedSquareControl.getMapTileSelection(); + if (arch != null) { + mainControl.openAttrDialog(arch); } } - private MapCursor getMapCursor() { - final MapControl mapControl = mainControl.getCurrentMap(); - assert mapControl != null; - final MapCursor mapCursor = mapControl.getMapCursor(); - return mapCursor; - } - - /** {@inheritDoc} */ - public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - // ignore - } - - /** {@inheritDoc} */ - public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - refreshMenus(); - } - - /** - * Enable/disable menu entries based on the current cursor state. - */ - private void refreshMenus() { - final MapControl mapControl = mainControl.getCurrentMap(); - final MapCursor mapCursor = mapControl != null ? mapControl.getMapCursor() : null; - - final boolean hasCursor = mapCursor != null && mapCursor.isActive(); - - for (final String aDirectionsGo : directionsGo) { - ACTION_FACTORY.getAction(aDirectionsGo).setEnabled(hasCursor); - } - aGoLocation.setEnabled(mapControl != null); - aSelectTile.setEnabled(hasCursor); - aStartStopDrag.setEnabled(hasCursor); - aAddToSelection.setEnabled(hasCursor); - aSubFromSelection.setEnabled(hasCursor); - aReleaseDrag.setEnabled(hasCursor); - aInsertArch.setEnabled(hasCursor); - aDeleteArch.setEnabled(hasCursor); - aSelectArchAbove.setEnabled(hasCursor); - aSelectArchBelow.setEnabled(hasCursor); - aArchAttributes.setEnabled(hasCursor); - } - } // class MapCursorControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-03-30 20:23:48
|
Revision: 2034 http://svn.sourceforge.net/gridarta/?rev=2034&view=rev Author: akirschbaum Date: 2007-03-30 13:23:48 -0700 (Fri, 30 Mar 2007) Log Message: ----------- Rename method names. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gui/ArchComboBox.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-03-30 20:19:51 UTC (rev 2033) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-03-30 20:23:48 UTC (rev 2034) @@ -326,8 +326,8 @@ } // show a arch in the arch map panel - public GameObject getMapArchPanelObject() { - return gameObjectAttributesPanel.getMapArchPanelObject(); + public GameObject getSelectedGameObject() { + return gameObjectAttributesPanel.getSelectedGameObject(); } @Nullable public GameObject getMapTileSelection() { Modified: trunk/crossfire/src/cfeditor/gui/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2007-03-30 20:19:51 UTC (rev 2033) +++ trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2007-03-30 20:23:48 UTC (rev 2034) @@ -152,7 +152,7 @@ fromActive.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { try { - final Archetype ao = archComboBoxModel.getNearsetMatch(mainControl.getMainView().getMapArchPanelObject().getArchetypeName()); + final Archetype ao = archComboBoxModel.getNearsetMatch(mainControl.getMainView().getSelectedGameObject().getArchetypeName()); setSelectedItem(ao); setItem(ao); } catch (final Exception ex) {//null pointer exception Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-03-30 20:19:51 UTC (rev 2033) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-03-30 20:23:48 UTC (rev 2034) @@ -547,7 +547,7 @@ * updated. * @return the selected arch */ - @Nullable public GameObject getMapArchPanelObject() { + @Nullable public GameObject getSelectedGameObject() { return selectedObject; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-01 00:11:36
|
Revision: 2062 http://svn.sourceforge.net/gridarta/?rev=2062&view=rev Author: akirschbaum Date: 2007-03-31 17:11:36 -0700 (Sat, 31 Mar 2007) Log Message: ----------- Remove redundant and non-MVC call to redraw the map view. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/crossfire/src/cfeditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2007-04-01 00:09:09 UTC (rev 2061) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2007-04-01 00:11:36 UTC (rev 2062) @@ -480,7 +480,6 @@ map.endTransaction(); mapControl.getMapModel().endTransaction(); - mapControl.notifyViews(); return true; } Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-04-01 00:09:09 UTC (rev 2061) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-04-01 00:11:36 UTC (rev 2062) @@ -339,13 +339,6 @@ } /** - * Notifies the view that data has changed in the model. - */ - public void notifyViews() { - mapViewFrame.refreshDataFromModel(); - } - - /** * Get the last used view of this level. * @return the last used view */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-01 16:17:46
|
Revision: 2073 http://svn.sourceforge.net/gridarta/?rev=2073&view=rev Author: akirschbaum Date: 2007-04-01 09:17:47 -0700 (Sun, 01 Apr 2007) Log Message: ----------- Unify code to load multiple map files. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFJavaEditor.java trunk/crossfire/src/cfeditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CFJavaEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/CFJavaEditor.java 2007-04-01 16:13:00 UTC (rev 2072) +++ trunk/crossfire/src/cfeditor/CFJavaEditor.java 2007-04-01 16:17:47 UTC (rev 2073) @@ -138,14 +138,7 @@ System.exit(0); } - // open initial maps - for (final String infile : infiles) { - if (mainControl.openMapFileWithView(new File(infile), null) == null) { - log.warn("Cannot load file " + infile); - } else { - log.info("Successfully loaded " + infile); - } - } + mainControl.openFiles(infiles); if (outfile != null) { mainControl.createImageWanted(mainControl.getCurrentMapView(), new File(outfile)); // create map image Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-01 16:13:00 UTC (rev 2072) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-01 16:17:47 UTC (rev 2073) @@ -757,6 +757,57 @@ } /** + * Load an array of files. + * @param dir directory to load files from + * @param files array of files to load + */ + private void openFiles(final File dir, final File... files) { + for (final File file : files) { + final boolean isPython = file.getName().toLowerCase().endsWith(".py"); + if (file.isFile()) { + if (isPython) { + ScriptEditControl.getInstance().openScriptFile(file.getAbsolutePath()); + } else { + currentDir = dir; + openMapFileWithView(file, null); + } + } else if (!file.exists()) { + if (isPython) { + // TODO: pass filename + ScriptEditControl.getInstance().openScriptNew(); + } else { + newLevelWanted(file.getName()); + } + } // If neither branch matches, it's a directory - what to do with directories? + } + } + + /** + * Load a list of map files. + * @param filenames collection of filenamess to load + */ + public void openFiles(final Iterable<String> filenames) { + for (final String filename : filenames) { + final File file = new File(filename); + final boolean isPython = filename.toLowerCase().endsWith(".py"); + if (file.isFile()) { + if (isPython) { + ScriptEditControl.getInstance().openScriptFile(file.getAbsolutePath()); + } else { + openMapFileWithView(file, null); + } + } else if (!file.exists()) { + if (isPython) { + // TODO: pass filename + ScriptEditControl.getInstance().openScriptNew(); + } else { + newLevelWanted(file.getName()); + } + } // If neither branch matches, it's a directory - what to do with directories? + } + } + + /** * Load a map file and create a map view. * * @param file the map file to load This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-01 16:28:49
|
Revision: 2076 http://svn.sourceforge.net/gridarta/?rev=2076&view=rev Author: akirschbaum Date: 2007-04-01 09:28:46 -0700 (Sun, 01 Apr 2007) Log Message: ----------- Unify CMapReader code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java trunk/crossfire/src/cfeditor/io/CMapReader.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-01 16:27:41 UTC (rev 2075) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-01 16:28:46 UTC (rev 2076) @@ -875,9 +875,6 @@ return null; } - collectTempList(decoder.getGameObjects(), file); - archetypeParser.sortTempList(decoder.getGameObjects()); - return decoder; } @@ -920,7 +917,7 @@ * @param objects List of GameObjects to collect * @param file File (for error messages). */ - public void collectTempList(final List<GameObject> objects, final File file) { + public void collectTempList(final List<GameObject> objects, final String file) { final List<GameObject> tailList = new ArrayList<GameObject>(); final SortedSet<String> undefinedArchetypeNames = new TreeSet<String>(); Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-04-01 16:27:41 UTC (rev 2075) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-04-01 16:28:46 UTC (rev 2076) @@ -137,10 +137,6 @@ decoder.decodeMapFile(); final List<GameObject> objects = decoder.getGameObjects(); final MapArchObject maparch = decoder.getMapArchObject(); - - // go to ArchetypeParser and add the default arch list information to them - mainControl.collectTempList(objects, mapFile); - mainControl.getArchetypeParser().sortTempList(objects); newPickmap(objects, maparch, mapFile); // init the map return true; } finally { Modified: trunk/crossfire/src/cfeditor/io/CMapReader.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapReader.java 2007-04-01 16:27:41 UTC (rev 2075) +++ trunk/crossfire/src/cfeditor/io/CMapReader.java 2007-04-01 16:28:46 UTC (rev 2076) @@ -19,6 +19,7 @@ package cfeditor.io; +import cfeditor.CMainControl; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; @@ -68,6 +69,13 @@ return new MapArchObject(); } + /** {@inheritDoc} */ + @NotNull @Override public void decodeMapFile() throws IOException { + super.decodeMapFile(); + CMainControl.getInstance().collectTempList(objects, uri); + CMainControl.getInstance().getArchetypeParser().sortTempList(objects); + } + /** * Our recursive accessible arch reader. * <p/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-03 17:26:15
|
Revision: 2105 http://svn.sourceforge.net/gridarta/?rev=2105&view=rev Author: akirschbaum Date: 2007-04-03 10:26:16 -0700 (Tue, 03 Apr 2007) Log Message: ----------- Remove unused parameter. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-04-03 17:23:06 UTC (rev 2104) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-04-03 17:26:16 UTC (rev 2105) @@ -97,9 +97,8 @@ * @param mapControl the controller of this view * @param initial the initial view position to show; null=show top left * corner - * @param fi MapView. */ - CMapViewBasic(final CMainControl mainControl, final MapControl mapControl, final MapView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> fi, final Point initial) { + CMapViewBasic(final CMainControl mainControl, final MapControl mapControl, final Point initial) { super(mainControl, mapControl); this.mapControl = mapControl; mapModel = mapControl.getMapModel(); Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2007-04-03 17:23:06 UTC (rev 2104) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2007-04-03 17:26:16 UTC (rev 2105) @@ -146,7 +146,7 @@ setAutoscrolls(true); // create instance of "real" view object and add it to the frame - view = new CMapViewBasic(mainControl, mapControl, this, initial); + view = new CMapViewBasic(mainControl, mapControl, initial); getContentPane().setLayout(new BorderLayout()); getContentPane().add(view, BorderLayout.CENTER); mapFileActions = null;//new MapFileActions(mainControl, mapControl); // XXX: uncomment this after JAPI can create multiple action sets This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-03 17:43:05
|
Revision: 2107 http://svn.sourceforge.net/gridarta/?rev=2107&view=rev Author: akirschbaum Date: 2007-04-03 10:43:06 -0700 (Tue, 03 Apr 2007) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-03 17:39:39 UTC (rev 2106) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-03 17:43:06 UTC (rev 2107) @@ -1272,17 +1272,6 @@ mainView.showMessage(strTitle, strMessage, messageType); } - /** - * Shows the given confirmation message in the UI. The message - * is a yes/no option. - * @param strTitle The title of the message. - * @param strMessage The message to be shown. - * @return true if the user agrees, false if user disagrees - */ - public boolean askConfirm(final String strTitle, final String strMessage) { - return mainView.askConfirm(strTitle, strMessage); - } - public CFilterControl getFilterControl() { return CFilterControl.getDefaultFilter(); } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-04-03 17:39:39 UTC (rev 2106) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-04-03 17:43:06 UTC (rev 2107) @@ -494,17 +494,6 @@ } /** - * Shows the given confirmation message in the UI. The message - * is a yes/no option. - * @param strTitle the title of the message - * @param strMessage the message to be shown - * @return <code>true</code> if the user agrees, <code>false</code> if user disagrees - */ - public boolean askConfirm(final String strTitle, final String strMessage) { - return JOptionPane.showConfirmDialog(this, strMessage, strTitle, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION; - } - - /** * Updates the focus to the first non-iconified level window. * @param fCareAboutIconification True if the focus update should ignore * all windows iconified by the user. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-03 17:44:42
|
Revision: 2108 http://svn.sourceforge.net/gridarta/?rev=2108&view=rev Author: akirschbaum Date: 2007-04-03 10:44:43 -0700 (Tue, 03 Apr 2007) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-03 17:43:06 UTC (rev 2107) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-03 17:44:43 UTC (rev 2108) @@ -1262,16 +1262,6 @@ return mapDir; } - /** - * Shows the given message in the UI. - * @param strTitle The title of the message. - * @param strMessage The message to be shown. - * @param messageType Type of message (see JOptionPane constants) - */ - public void showMessage(final String strTitle, final String strMessage, final int messageType) { - mainView.showMessage(strTitle, strMessage, messageType); - } - public CFilterControl getFilterControl() { return CFilterControl.getDefaultFilter(); } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-04-03 17:43:06 UTC (rev 2107) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-04-03 17:44:43 UTC (rev 2108) @@ -479,16 +479,6 @@ JOptionPane.showMessageDialog(this, t.getMessage(), "Error", JOptionPane.WARNING_MESSAGE); } - /** - * Shows the given message in the UI. - * @param strTitle the title of the message - * @param strMessage the message to be shown - * @param messageType type of message (see JOptionPane constants), defines icon used - */ - public void showMessage(final String strTitle, final String strMessage, final int messageType) { - JOptionPane.showMessageDialog(this, strMessage, strTitle, messageType); - } - public void showMessage(final String strTitle, final String strMessage) { JOptionPane.showMessageDialog(this, strMessage, strTitle, JOptionPane.INFORMATION_MESSAGE); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-03 17:48:42
|
Revision: 2109 http://svn.sourceforge.net/gridarta/?rev=2109&view=rev Author: akirschbaum Date: 2007-04-03 10:48:44 -0700 (Tue, 03 Apr 2007) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CScriptController.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-03 17:44:43 UTC (rev 2108) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-03 17:48:44 UTC (rev 2109) @@ -1246,15 +1246,6 @@ } /** - * Shows the given message in the UI. - * @param strTitle The title of the message. - * @param strMessage The message to be shown. - */ - public void showMessage(final String strTitle, final String strMessage) { - mainView.showMessage(strTitle, strMessage); - } - - /** * Get the map directory. * @return map directory */ Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-04-03 17:44:43 UTC (rev 2108) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-04-03 17:48:44 UTC (rev 2109) @@ -479,10 +479,6 @@ JOptionPane.showMessageDialog(this, t.getMessage(), "Error", JOptionPane.WARNING_MESSAGE); } - public void showMessage(final String strTitle, final String strMessage) { - JOptionPane.showMessageDialog(this, strMessage, strTitle, JOptionPane.INFORMATION_MESSAGE); - } - /** * Updates the focus to the first non-iconified level window. * @param fCareAboutIconification True if the focus update should ignore Modified: trunk/crossfire/src/cfeditor/CScriptController.java =================================================================== --- trunk/crossfire/src/cfeditor/CScriptController.java 2007-04-03 17:44:43 UTC (rev 2108) +++ trunk/crossfire/src/cfeditor/CScriptController.java 2007-04-03 17:48:44 UTC (rev 2109) @@ -46,6 +46,7 @@ import java.util.Map; import java.util.Set; import javax.swing.JFileChooser; +import javax.swing.JOptionPane; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.filechooser.FileFilter; @@ -187,7 +188,7 @@ try { exportXML(scriptRsc.getOutputStream()); } catch (final IOException e) { - mainControl.showMessage("Script Error", e.getLocalizedMessage()); + JOptionPane.showMessageDialog(mainControl.getMainView(), e.getLocalizedMessage(), "Script Error", JOptionPane.INFORMATION_MESSAGE); e.printStackTrace(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-04 07:34:06
|
Revision: 2134 http://svn.sourceforge.net/gridarta/?rev=2134&view=rev Author: akirschbaum Date: 2007-04-04 00:34:05 -0700 (Wed, 04 Apr 2007) Log Message: ----------- Add methods to access integer and boolean values to CSettings' interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFJavaEditor.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CSettings.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java trunk/crossfire/src/cfeditor/gui/NewMapDialog.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java Modified: trunk/crossfire/src/cfeditor/CFJavaEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/CFJavaEditor.java 2007-04-03 22:19:52 UTC (rev 2133) +++ trunk/crossfire/src/cfeditor/CFJavaEditor.java 2007-04-04 07:34:05 UTC (rev 2134) @@ -55,7 +55,7 @@ */ public static void main(final String... args) { // Make sure the locale is set before any ActionFactory is used. - final String locName = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(MainControl.PREFS_LANGUAGE, null); + final String locName = CSettings.getInstance(IGUIConstants.APP_NAME).get(MainControl.PREFS_LANGUAGE, null); if (locName != null) { Locale.setDefault(new Locale(locName)); } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-03 22:19:52 UTC (rev 2133) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-04 07:34:05 UTC (rev 2134) @@ -391,31 +391,31 @@ /** Set all global settings from the preferences. */ public void readGlobalSettings() { - imageSet = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(USE_IMAGESET, "base"); + imageSet = CSettings.getInstance(IGUIConstants.APP_NAME).get(USE_IMAGESET, "base"); if (imageSet.equalsIgnoreCase("none")) { imageSet = null; } initDirs(); - loadFromArchive = Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(LOAD_ARCH_COLL, "true")); + loadFromArchive = CSettings.getInstance(IGUIConstants.APP_NAME).getBoolean(LOAD_ARCH_COLL, true); - getMainView().setMapTileListBottom(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainView.MAP_TILE_LIST_BOTTOM_KEY, Boolean.toString(CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)))); + getMainView().setMapTileListBottom(CSettings.getInstance(IGUIConstants.APP_NAME).getBoolean(CMainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); // docu version - if (IGUIConstants.DOCU_VERSION > new Integer(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(DOCU_VERSION_KEY, "0"))) { + if (IGUIConstants.DOCU_VERSION > new Integer(CSettings.getInstance(IGUIConstants.APP_NAME).getInt(DOCU_VERSION_KEY, 0))) { // remember to open docu autoPopupDocu = true; // update docu version right now, because we want the help popup only one time - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(DOCU_VERSION_KEY, String.valueOf(IGUIConstants.DOCU_VERSION)); + CSettings.getInstance(IGUIConstants.APP_NAME).setInt(DOCU_VERSION_KEY, IGUIConstants.DOCU_VERSION); } } /** (Re-)initializes the directories. */ public void initDirs() { // Get the directories - strMapDir = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(ResourceFileManager.MAP_DIR_KEY, ResourceFileManager.DEFAULT_MAP_DIR); - strArchDir = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(ResourceFileManager.ARCH_DIR_KEY, ResourceFileManager.DEFAULT_ARCH_DIR); - strScriptDir = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(ResourceFileManager.SCRIPT_DIR_KEY, ResourceFileManager.DEFAULT_SCRIPT_DIR); + strMapDir = CSettings.getInstance(IGUIConstants.APP_NAME).get(ResourceFileManager.MAP_DIR_KEY, ResourceFileManager.DEFAULT_MAP_DIR); + strArchDir = CSettings.getInstance(IGUIConstants.APP_NAME).get(ResourceFileManager.ARCH_DIR_KEY, ResourceFileManager.DEFAULT_ARCH_DIR); + strScriptDir = CSettings.getInstance(IGUIConstants.APP_NAME).get(ResourceFileManager.SCRIPT_DIR_KEY, ResourceFileManager.DEFAULT_SCRIPT_DIR); // set map dir if (strMapDir.length() > 0) { @@ -443,7 +443,7 @@ * @param mapTileBottom <code>true</code> if the map tile list should be displayed on the window bottom, otherwise (right border) <code>false</code>. */ void setGlobalSettings(final String arch, final String map, final String script, final boolean baseImageSet, final boolean load, final boolean mapTileBottom) { - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(USE_IMAGESET, baseImageSet ? "base" : "none"); + CSettings.getInstance(IGUIConstants.APP_NAME).set(USE_IMAGESET, baseImageSet ? "base" : "none"); readGlobalSettings(); refreshMenusAndToolbars(); @@ -1276,13 +1276,13 @@ it.remove(); } } - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty("recentNum", String.valueOf(recents.size())); + CSettings.getInstance(IGUIConstants.APP_NAME).setInt("recentNum", recents.size()); mainView.updateRecent(recents); } /** Initializes the recent state. */ private void initRecent() { - final int numRecents = Integer.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty("recentNum", "0")); + final int numRecents = CSettings.getInstance(IGUIConstants.APP_NAME).getInt("recentNum", 0); for (int i = 0; i < numRecents; i++) { recents.add(new Recent(i + 1)); } @@ -1383,8 +1383,8 @@ * @param index index (starting with 1) */ Recent(final int index) { - title = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty("recentTitle[" + Integer.toString(index - 1) + ']', null); - filename = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty("recentFilename[" + Integer.toString(index - 1) + ']', null); + title = CSettings.getInstance(IGUIConstants.APP_NAME).get("recentTitle[" + Integer.toString(index - 1) + ']', null); + filename = CSettings.getInstance(IGUIConstants.APP_NAME).get("recentFilename[" + Integer.toString(index - 1) + ']', null); putValue(SHORT_DESCRIPTION, ACTION_FACTORY.format("recentItem.shortdescriptionformat", title, getShortFileName())); setIndex(index); } @@ -1424,8 +1424,8 @@ putValue(MNEMONIC_KEY, null); putValue(ACCELERATOR_KEY, null); } - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty("recentTitle[" + Integer.toString(index - 1) + ']', title); - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty("recentFilename[" + Integer.toString(index - 1) + ']', filename); + CSettings.getInstance(IGUIConstants.APP_NAME).set("recentTitle[" + Integer.toString(index - 1) + ']', title); + CSettings.getInstance(IGUIConstants.APP_NAME).set("recentFilename[" + Integer.toString(index - 1) + ']', filename); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-04-03 22:19:52 UTC (rev 2133) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-04-04 07:34:05 UTC (rev 2134) @@ -148,7 +148,7 @@ final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); // set look and feel - final String strSelectedLNFName = settings.getProperty(SELECTED_LNF_KEY, UIManager.getCrossPlatformLookAndFeelClassName()); + final String strSelectedLNFName = settings.get(SELECTED_LNF_KEY, UIManager.getCrossPlatformLookAndFeelClassName()); mainControl.setLookNFeel(strSelectedLNFName); // calculate some default values in case there is no settings file @@ -157,15 +157,15 @@ final int defheight = (int) (0.9 * screen.getHeight()); // define divider locations - final int divLocationRight = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY3, String.valueOf((int) (defwidth * 0.62)))); - final int divLocationDown = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY2, String.valueOf((int) (defheight * 0.76)))); - final int divLocation = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY, String.valueOf((int) (defwidth * 0.17)))); + final int divLocationRight = settings.getInt(DIVIDER_LOCATION_KEY3, (int) (defwidth * 0.62)); + final int divLocationDown = settings.getInt(DIVIDER_LOCATION_KEY2, (int) (defheight * 0.76)); + final int divLocation = settings.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); // get the old location and size - final int x = Integer.parseInt(settings.getProperty(WINDOW_X, String.valueOf((int) ((screen.getWidth() - defwidth) / 2.0)))); - final int y = Integer.parseInt(settings.getProperty(WINDOW_Y, String.valueOf((int) ((screen.getHeight() - defheight) / 2.0)))); - final int width = Integer.parseInt(settings.getProperty(WINDOW_WIDTH, String.valueOf(defwidth))); - final int height = Integer.parseInt(settings.getProperty(WINDOW_HEIGHT, String.valueOf(defheight))); + final int x = settings.getInt(WINDOW_X, (int) ((screen.getWidth() - defwidth) / 2.0)); + final int y = settings.getInt(WINDOW_Y, (int) ((screen.getHeight() - defheight) / 2.0)); + final int width = settings.getInt(WINDOW_WIDTH, defwidth); + final int height = settings.getInt(WINDOW_HEIGHT, defheight); pickmapChooserControl = new PickmapChooserControl(); @@ -378,13 +378,13 @@ // Store the location and size final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); final Rectangle bounds = getBounds(); - settings.setProperty(WINDOW_X, String.valueOf(bounds.x)); - settings.setProperty(WINDOW_Y, String.valueOf(bounds.y)); - settings.setProperty(WINDOW_WIDTH, String.valueOf(bounds.width)); - settings.setProperty(WINDOW_HEIGHT, String.valueOf(bounds.height)); - settings.setProperty(DIVIDER_LOCATION_KEY, String.valueOf(splitPane.getDividerLocation())); - settings.setProperty(DIVIDER_LOCATION_KEY2, String.valueOf(splitDownPane.getDividerLocation())); - settings.setProperty(DIVIDER_LOCATION_KEY3, String.valueOf(splitRightPane.getDividerLocation())); + settings.setInt(WINDOW_X, bounds.x); + settings.setInt(WINDOW_Y, bounds.y); + settings.setInt(WINDOW_WIDTH, bounds.width); + settings.setInt(WINDOW_HEIGHT, bounds.height); + settings.setInt(DIVIDER_LOCATION_KEY, splitPane.getDividerLocation()); + settings.setInt(DIVIDER_LOCATION_KEY2, splitDownPane.getDividerLocation()); + settings.setInt(DIVIDER_LOCATION_KEY3, splitRightPane.getDividerLocation()); objectChooser.appExitNotify(); gameObjectAttributesPanel.appExitNotify(); @@ -661,7 +661,7 @@ } final UIManager.LookAndFeelInfo[] lafInfos = UIManager.getInstalledLookAndFeels(); - final String strSelectedLNFName = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(SELECTED_LNF_KEY, UIManager.getCrossPlatformLookAndFeelClassName()); + final String strSelectedLNFName = CSettings.getInstance(IGUIConstants.APP_NAME).get(SELECTED_LNF_KEY, UIManager.getCrossPlatformLookAndFeelClassName()); int index = 0; for (final UIManager.LookAndFeelInfo lafInfo : lafInfos) { final Action action = new LookAndFeelAction(lafInfo); @@ -793,7 +793,7 @@ public void actionPerformed(final ActionEvent e) { mainControl.setLookNFeel(className); - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(CMainView.SELECTED_LNF_KEY, className); + CSettings.getInstance(IGUIConstants.APP_NAME).get(CMainView.SELECTED_LNF_KEY, className); rebuildLookAndFeelMenuEntries(); } Modified: trunk/crossfire/src/cfeditor/CSettings.java =================================================================== --- trunk/crossfire/src/cfeditor/CSettings.java 2007-04-03 22:19:52 UTC (rev 2133) +++ trunk/crossfire/src/cfeditor/CSettings.java 2007-04-04 07:34:05 UTC (rev 2134) @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Properties; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -117,50 +118,77 @@ /** * Searches for the property with the specified key in this property list. - * The method returns <code>null</code> if the property is not found. - * @param strKey The key that identifies the property. - * @return Property value for the named key. + * The method returns the given default value if the property is not found + * and adds the default value with the key to properties. + * @param key the key that identifies the property + * @param defaultValue the default value to use + * @return the property value for the named key or <var>defaultValue</var> + * if the property is not set */ - public synchronized String getProperty(final String strKey) { - return properties.getProperty(strKey); - } + @Nullable public synchronized String get(@NotNull final String key, @Nullable final String defaultValue) { + final String strValue = properties.getProperty(key); + if (strValue != null) { + return strValue; + } - /** - * Searches for the property with the specified key in this property - * list. The method returns the given default value if the property is not - * found and adds the default value with the key to properties. - * @param strKey the key that identifies the property - * @param strDefaultValue the default value to use - * @return Property value for the named key or <var>strDefaultValue</var> if the property is not set. - */ - @Nullable public synchronized String getProperty(final String strKey, final String strDefaultValue) { - final String strValue = properties.getProperty(strKey); - if (strValue == null) { - if (strDefaultValue != null) { - setProperty(strKey, strDefaultValue); - } - return strDefaultValue; + if (defaultValue != null) { + set(key, defaultValue); } - return strValue; + return defaultValue; } /** * Maps the specified key to the specified value. Neither the key nor the - * value can be null. The value can be retrieved by calling the getProperty - * method with a key that is equal to the original key. - * @param strKey the key that identifies the property - * @param strValue the value of the property + * value can be null. The value can be retrieved by calling the {@link + * #get(String,String)} method with a key that is equal to the original + * key. + * @param key the key that identifies the property + * @param value the value of the property */ - public synchronized void setProperty(final String strKey, final String strValue) { - properties.setProperty(strKey, strValue); + public synchronized void set(@NotNull final String key, @NotNull final String value) { + properties.setProperty(key, value); } /** * Removes the key-value pair of specified key from the property table. - * @param strKey the key that identifies the property + * @param key the key that identifies the property */ - public synchronized void clearProperty(final String strKey) { - properties.remove(strKey); + public synchronized void remove(@NotNull final String key) { + properties.remove(key); } + public int getInt(@NotNull final String key, final int defaultValue) { + final String result = get(key, null); + if (result == null) { + return defaultValue; + } + + try { + return Integer.parseInt(result); + } catch (final NumberFormatException ex) { + return defaultValue; + } + } + + public void setInt(@NotNull final String key, final int value) { + set(key, Integer.toString(value)); + } + + public boolean getBoolean(@NotNull final String key, final boolean defaultValue) { + final String result = get(key, null); + if (result == null) { + return defaultValue; + } + + try { + return Boolean.parseBoolean(result); + } catch (final NumberFormatException ex) { + return defaultValue; + } + } + + public void setBoolean(@NotNull final String key, final boolean value) { + set(key, Boolean.toString(value)); + } + } // class CSettings Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-04-03 22:19:52 UTC (rev 2133) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-04-04 07:34:05 UTC (rev 2134) @@ -210,7 +210,7 @@ // calculate default value in case there is no settings file final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - splitPane.setDividerLocation(Integer.parseInt(settings.getProperty(MAPARCHPANEL_LOCATION_KEY, String.valueOf((int) (0.49 * screen.getWidth()))))); + splitPane.setDividerLocation(settings.getInt(MAPARCHPANEL_LOCATION_KEY, (int) (0.49 * screen.getWidth()))); add(splitPane, BorderLayout.CENTER); updateFont(); @@ -513,7 +513,7 @@ public void appExitNotify() { final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); - settings.setProperty(MAPARCHPANEL_LOCATION_KEY, String.valueOf(splitPane.getDividerLocation())); + settings.setInt(MAPARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); } /** Modified: trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2007-04-03 22:19:52 UTC (rev 2133) +++ trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2007-04-04 07:34:05 UTC (rev 2134) @@ -98,7 +98,7 @@ final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); - final int divLocation = Integer.parseInt(settings.getProperty(ARCHPANEL_LOCATION_KEY, String.valueOf((int) (0.77 * 0.9 * screen.getHeight())))); + final int divLocation = settings.getInt(ARCHPANEL_LOCATION_KEY, (int) (0.77 * 0.9 * screen.getHeight())); splitPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, archAndPickPane, archQuickPanel); splitPane.setDividerLocation(divLocation); @@ -210,7 +210,7 @@ public void appExitNotify() { final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); - settings.setProperty(ARCHPANEL_LOCATION_KEY, String.valueOf(splitPane.getDividerLocation())); + settings.setInt(ARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); } /** Modified: trunk/crossfire/src/cfeditor/gui/NewMapDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/NewMapDialog.java 2007-04-03 22:19:52 UTC (rev 2133) +++ trunk/crossfire/src/cfeditor/gui/NewMapDialog.java 2007-04-04 07:34:05 UTC (rev 2134) @@ -152,7 +152,7 @@ mapWidthField.setValue(IGUIConstants.DEF_PICKMAP_WIDTH); } else { assert mapType == MapType.GAMEMAP; - mapWidthField.setValue(Integer.valueOf(settings.getProperty(DEFAULT_LEVEL_WIDTH_KEY, String.valueOf(IGUIConstants.DEF_MAPSIZE)))); + mapWidthField.setValue(settings.getInt(DEFAULT_LEVEL_WIDTH_KEY, IGUIConstants.DEF_MAPSIZE)); } mapWidthField.setColumns(3); mapSizePanel.add(mapWidthField, gbcField); @@ -162,7 +162,7 @@ } else { //noinspection ConstantConditions assert mapType == MapType.GAMEMAP; - mapHeightField.setValue(Integer.valueOf(settings.getProperty(DEFAULT_LEVEL_HEIGHT_KEY, String.valueOf(IGUIConstants.DEF_MAPSIZE)))); + mapHeightField.setValue(settings.getInt(DEFAULT_LEVEL_HEIGHT_KEY, IGUIConstants.DEF_MAPSIZE)); } mapHeightField.setColumns(3); mapSizePanel.add(mapHeightField, gbcField); @@ -244,8 +244,8 @@ if (mapType == MapType.GAMEMAP) { final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); - settings.setProperty(DEFAULT_LEVEL_WIDTH_KEY, String.valueOf(width)); - settings.setProperty(DEFAULT_LEVEL_HEIGHT_KEY, String.valueOf(height)); + settings.setInt(DEFAULT_LEVEL_WIDTH_KEY, width); + settings.setInt(DEFAULT_LEVEL_HEIGHT_KEY, height); } // set map name and file name Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java 2007-04-03 22:19:52 UTC (rev 2133) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java 2007-04-04 07:34:05 UTC (rev 2134) @@ -44,13 +44,13 @@ /** {@inheritDoc} */ @Override protected boolean getLockAllPickmapsFromPrefs() { - return Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CSettings.PICKMAPS_LOCKED, "false")); + return CSettings.getInstance(IGUIConstants.APP_NAME).getBoolean(CSettings.PICKMAPS_LOCKED, false); } /** {@inheritDoc} */ @Override public void setLockAllPickmaps(final boolean lockAllPickmaps) { super.setLockAllPickmaps(lockAllPickmaps); - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(CSettings.PICKMAPS_LOCKED, isLockAllPickmaps() ? "true" : "false"); + CSettings.getInstance(IGUIConstants.APP_NAME).setBoolean(CSettings.PICKMAPS_LOCKED, isLockAllPickmaps()); } } // class Actions Modified: trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2007-04-03 22:19:52 UTC (rev 2133) +++ trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2007-04-04 07:34:05 UTC (rev 2134) @@ -91,20 +91,20 @@ public void apply() { final Locale loc = (Locale) localeBox.getSelectedItem(); if (loc != null) { - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(MainControl.PREFS_LANGUAGE, loc.getLanguage()); + CSettings.getInstance(IGUIConstants.APP_NAME).set(MainControl.PREFS_LANGUAGE, loc.getLanguage()); } else { - CSettings.getInstance(IGUIConstants.APP_NAME).clearProperty(MainControl.PREFS_LANGUAGE); + CSettings.getInstance(IGUIConstants.APP_NAME).remove(MainControl.PREFS_LANGUAGE); } - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(CMainView.MAP_TILE_LIST_BOTTOM_KEY, mapPanelBottom.isSelected() ? "true" : "false"); + CSettings.getInstance(IGUIConstants.APP_NAME).setBoolean(CMainView.MAP_TILE_LIST_BOTTOM_KEY, mapPanelBottom.isSelected()); mainControl.readGlobalSettings(); mainControl.refreshMenusAndToolbars(); } /** {@inheritDoc} */ public void revert() { - final String current = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(MainControl.PREFS_LANGUAGE, null); + final String current = CSettings.getInstance(IGUIConstants.APP_NAME).get(MainControl.PREFS_LANGUAGE, null); localeBox.setSelectedIndex(Arrays.binarySearch(locales, current != null ? new Locale(current) : null, comp)); - mapPanelBottom.setSelected(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainView.MAP_TILE_LIST_BOTTOM_KEY, Boolean.toString(CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)))); + mapPanelBottom.setSelected(CSettings.getInstance(IGUIConstants.APP_NAME).getBoolean(CMainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); } /** {@inheritDoc} */ @@ -116,11 +116,11 @@ /** {@inheritDoc} */ public boolean isChanged() { final Locale loc = (Locale) localeBox.getSelectedItem(); - final String currentName = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(MainControl.PREFS_LANGUAGE, null); + final String currentName = CSettings.getInstance(IGUIConstants.APP_NAME).get(MainControl.PREFS_LANGUAGE, null); final Locale current = currentName != null ? new Locale(currentName) : null; return !( (loc == null ? loc == current : loc.equals(current)) - && mapPanelBottom.isSelected() == Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainView.MAP_TILE_LIST_BOTTOM_KEY, Boolean.toString(CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)))); + && mapPanelBottom.isSelected() == CSettings.getInstance(IGUIConstants.APP_NAME).getBoolean(CMainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); } /** @@ -144,7 +144,7 @@ localeBox = new JComboBox(locales); // set "content" localeBox.setRenderer(new LocaleListCellRenderer()); //localeBox.setPreferredSize(new Dimension(150, 25)); - final String current = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(MainControl.PREFS_LANGUAGE, null); + final String current = CSettings.getInstance(IGUIConstants.APP_NAME).get(MainControl.PREFS_LANGUAGE, null); localeBox.setSelectedIndex(Arrays.binarySearch(locales, current != null ? new Locale(current) : null, comp)); lineLayout.add(localeBox); @@ -173,7 +173,7 @@ layoutPanel.setBorder(createTitledBorder("optionsLayout")); mapPanelBottom = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsSepMapTile")); - mapPanelBottom.setSelected(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainView.MAP_TILE_LIST_BOTTOM_KEY, Boolean.toString(CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)))); + mapPanelBottom.setSelected(CSettings.getInstance(IGUIConstants.APP_NAME).getBoolean(CMainView.MAP_TILE_LIST_BOTTOM_KEY, CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); layoutPanel.add(mapPanelBottom); return layoutPanel; } Modified: trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2007-04-03 22:19:52 UTC (rev 2133) +++ trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2007-04-04 07:34:05 UTC (rev 2134) @@ -96,13 +96,13 @@ /** {@inheritDoc} */ public void apply() { - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(ResourceFileManager.ARCH_DIR_KEY, PathManager.path(archField.getText())); - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(ResourceFileManager.MAP_DIR_KEY, PathManager.path(mapField.getText())); - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(ResourceFileManager.SCRIPT_DIR_KEY, PathManager.path(scriptField.getText())); - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(CMainControl.LOAD_ARCH_COLL, loadArches.isSelected() ? "true" : "false"); + CSettings.getInstance(IGUIConstants.APP_NAME).set(ResourceFileManager.ARCH_DIR_KEY, PathManager.path(archField.getText())); + CSettings.getInstance(IGUIConstants.APP_NAME).set(ResourceFileManager.MAP_DIR_KEY, PathManager.path(mapField.getText())); + CSettings.getInstance(IGUIConstants.APP_NAME).set(ResourceFileManager.SCRIPT_DIR_KEY, PathManager.path(scriptField.getText())); + CSettings.getInstance(IGUIConstants.APP_NAME).setBoolean(CMainControl.LOAD_ARCH_COLL, loadArches.isSelected()); final String imageSet = (String) imageSetBox.getSelectedItem(); - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(CMainControl.USE_IMAGESET, imageSet == null || imageSet.equals("disabled") ? "none" : imageSet); + CSettings.getInstance(IGUIConstants.APP_NAME).set(CMainControl.USE_IMAGESET, imageSet == null || imageSet.equals("disabled") ? "none" : imageSet); mainControl.readGlobalSettings(); mainControl.refreshMenusAndToolbars(); @@ -135,7 +135,7 @@ archField.getText().equals(mainControl.getArchDefaultFolder()) && mapField.getText().equals(mainControl.getMapDefaultFolder()) && scriptField.getText().equals(mainControl.getScriptDefaultFolder()) - && loadArches.isSelected() == Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainControl.LOAD_ARCH_COLL, Boolean.toString(mainControl.isArchLoadedFromCollection()))) + && loadArches.isSelected() == CSettings.getInstance(IGUIConstants.APP_NAME).getBoolean(CMainControl.LOAD_ARCH_COLL, mainControl.isArchLoadedFromCollection()) && imageSet.equals(getCurrentImageSet())); } @@ -239,7 +239,7 @@ } private static String getCurrentImageSet() { - final String imageSet = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainControl.USE_IMAGESET, "none"); + final String imageSet = CSettings.getInstance(IGUIConstants.APP_NAME).get(CMainControl.USE_IMAGESET, "none"); return imageSet.equals("none") ? "disabled" : imageSet; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-04 18:11:58
|
Revision: 2136 http://svn.sourceforge.net/gridarta/?rev=2136&view=rev Author: akirschbaum Date: 2007-04-04 11:11:45 -0700 (Wed, 04 Apr 2007) Log Message: ----------- Move constant to class where it is used. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CSettings.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java Modified: trunk/crossfire/src/cfeditor/CSettings.java =================================================================== --- trunk/crossfire/src/cfeditor/CSettings.java 2007-04-04 18:08:44 UTC (rev 2135) +++ trunk/crossfire/src/cfeditor/CSettings.java 2007-04-04 18:11:45 UTC (rev 2136) @@ -56,11 +56,6 @@ private static final Map<String, CSettings> hashFromNameToInstance = new HashMap<String, CSettings>(); /** - * Key for "all pickmaps are locked". - */ - public static final String PICKMAPS_LOCKED = "pickmapsLocked"; - - /** * Returns the settings instance for the given filename. If no such instance * is found one is created and the settings loaded from the file. * @param strFile The filename whose settings object instance we want. Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java 2007-04-04 18:08:44 UTC (rev 2135) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java 2007-04-04 18:11:45 UTC (rev 2136) @@ -37,6 +37,11 @@ private static final CSettings prefs = CSettings.getInstance(IGUIConstants.APP_NAME); /** + * Key for "all pickmaps are locked". + */ + public static final String PICKMAPS_LOCKED = "pickmapsLocked"; + + /** * Create a new instance. * * @param control the control to forward to @@ -47,13 +52,13 @@ /** {@inheritDoc} */ @Override protected boolean getLockAllPickmapsFromPrefs() { - return prefs.getBoolean(CSettings.PICKMAPS_LOCKED, false); + return prefs.getBoolean(PICKMAPS_LOCKED, false); } /** {@inheritDoc} */ @Override public void setLockAllPickmaps(final boolean lockAllPickmaps) { super.setLockAllPickmaps(lockAllPickmaps); - prefs.setBoolean(CSettings.PICKMAPS_LOCKED, isLockAllPickmaps()); + prefs.setBoolean(PICKMAPS_LOCKED, isLockAllPickmaps()); } } // class Actions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-04 18:16:26
|
Revision: 2137 http://svn.sourceforge.net/gridarta/?rev=2137&view=rev Author: akirschbaum Date: 2007-04-04 11:16:25 -0700 (Wed, 04 Apr 2007) Log Message: ----------- Rename CSettings.put* into set*(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CSettings.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java trunk/crossfire/src/cfeditor/gui/NewMapDialog.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-04 18:11:45 UTC (rev 2136) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-04 18:16:25 UTC (rev 2137) @@ -409,7 +409,7 @@ // remember to open docu autoPopupDocu = true; // update docu version right now, because we want the help popup only one time - prefs.setInt(DOCU_VERSION_KEY, IGUIConstants.DOCU_VERSION); + prefs.putInt(DOCU_VERSION_KEY, IGUIConstants.DOCU_VERSION); } } @@ -446,7 +446,7 @@ * @param mapTileBottom <code>true</code> if the map tile list should be displayed on the window bottom, otherwise (right border) <code>false</code>. */ void setGlobalSettings(final String arch, final String map, final String script, final boolean baseImageSet, final boolean load, final boolean mapTileBottom) { - prefs.set(USE_IMAGESET, baseImageSet ? "base" : "none"); + prefs.put(USE_IMAGESET, baseImageSet ? "base" : "none"); readGlobalSettings(); refreshMenusAndToolbars(); @@ -1279,7 +1279,7 @@ it.remove(); } } - prefs.setInt("recentNum", recents.size()); + prefs.putInt("recentNum", recents.size()); mainView.updateRecent(recents); } @@ -1427,8 +1427,8 @@ putValue(MNEMONIC_KEY, null); putValue(ACCELERATOR_KEY, null); } - prefs.set("recentTitle[" + Integer.toString(index - 1) + ']', title); - prefs.set("recentFilename[" + Integer.toString(index - 1) + ']', filename); + prefs.put("recentTitle[" + Integer.toString(index - 1) + ']', title); + prefs.put("recentFilename[" + Integer.toString(index - 1) + ']', filename); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-04-04 18:11:45 UTC (rev 2136) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-04-04 18:16:25 UTC (rev 2137) @@ -379,13 +379,13 @@ // Store the location and size final Rectangle bounds = getBounds(); - prefs.setInt(WINDOW_X, bounds.x); - prefs.setInt(WINDOW_Y, bounds.y); - prefs.setInt(WINDOW_WIDTH, bounds.width); - prefs.setInt(WINDOW_HEIGHT, bounds.height); - prefs.setInt(DIVIDER_LOCATION_KEY, splitPane.getDividerLocation()); - prefs.setInt(DIVIDER_LOCATION_KEY2, splitDownPane.getDividerLocation()); - prefs.setInt(DIVIDER_LOCATION_KEY3, splitRightPane.getDividerLocation()); + prefs.putInt(WINDOW_X, bounds.x); + prefs.putInt(WINDOW_Y, bounds.y); + prefs.putInt(WINDOW_WIDTH, bounds.width); + prefs.putInt(WINDOW_HEIGHT, bounds.height); + prefs.putInt(DIVIDER_LOCATION_KEY, splitPane.getDividerLocation()); + prefs.putInt(DIVIDER_LOCATION_KEY2, splitDownPane.getDividerLocation()); + prefs.putInt(DIVIDER_LOCATION_KEY3, splitRightPane.getDividerLocation()); objectChooser.appExitNotify(); gameObjectAttributesPanel.appExitNotify(); Modified: trunk/crossfire/src/cfeditor/CSettings.java =================================================================== --- trunk/crossfire/src/cfeditor/CSettings.java 2007-04-04 18:11:45 UTC (rev 2136) +++ trunk/crossfire/src/cfeditor/CSettings.java 2007-04-04 18:16:25 UTC (rev 2137) @@ -127,7 +127,7 @@ } if (defaultValue != null) { - set(key, defaultValue); + put(key, defaultValue); } return defaultValue; } @@ -140,7 +140,7 @@ * @param key the key that identifies the property * @param value the value of the property */ - public synchronized void set(@NotNull final String key, @NotNull final String value) { + public synchronized void put(@NotNull final String key, @NotNull final String value) { properties.setProperty(key, value); } @@ -165,8 +165,8 @@ } } - public void setInt(@NotNull final String key, final int value) { - set(key, Integer.toString(value)); + public void putInt(@NotNull final String key, final int value) { + put(key, Integer.toString(value)); } public boolean getBoolean(@NotNull final String key, final boolean defaultValue) { @@ -182,8 +182,8 @@ } } - public void setBoolean(@NotNull final String key, final boolean value) { - set(key, Boolean.toString(value)); + public void putBoolean(@NotNull final String key, final boolean value) { + put(key, Boolean.toString(value)); } } // class CSettings Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-04-04 18:11:45 UTC (rev 2136) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-04-04 18:16:25 UTC (rev 2137) @@ -514,7 +514,7 @@ } public void appExitNotify() { - prefs.setInt(MAPARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); + prefs.putInt(MAPARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); } /** Modified: trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2007-04-04 18:11:45 UTC (rev 2136) +++ trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2007-04-04 18:16:25 UTC (rev 2137) @@ -211,7 +211,7 @@ } public void appExitNotify() { - prefs.setInt(ARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); + prefs.putInt(ARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); } /** Modified: trunk/crossfire/src/cfeditor/gui/NewMapDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/NewMapDialog.java 2007-04-04 18:11:45 UTC (rev 2136) +++ trunk/crossfire/src/cfeditor/gui/NewMapDialog.java 2007-04-04 18:16:25 UTC (rev 2137) @@ -245,8 +245,8 @@ } if (mapType == MapType.GAMEMAP) { - prefs.setInt(DEFAULT_LEVEL_WIDTH_KEY, width); - prefs.setInt(DEFAULT_LEVEL_HEIGHT_KEY, height); + prefs.putInt(DEFAULT_LEVEL_WIDTH_KEY, width); + prefs.putInt(DEFAULT_LEVEL_HEIGHT_KEY, height); } // set map name and file name Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java 2007-04-04 18:11:45 UTC (rev 2136) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java 2007-04-04 18:16:25 UTC (rev 2137) @@ -58,7 +58,7 @@ /** {@inheritDoc} */ @Override public void setLockAllPickmaps(final boolean lockAllPickmaps) { super.setLockAllPickmaps(lockAllPickmaps); - prefs.setBoolean(PICKMAPS_LOCKED, isLockAllPickmaps()); + prefs.putBoolean(PICKMAPS_LOCKED, isLockAllPickmaps()); } } // class Actions Modified: trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2007-04-04 18:11:45 UTC (rev 2136) +++ trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2007-04-04 18:16:25 UTC (rev 2137) @@ -94,11 +94,11 @@ public void apply() { final Locale loc = (Locale) localeBox.getSelectedItem(); if (loc != null) { - prefs.set(MainControl.PREFS_LANGUAGE, loc.getLanguage()); + prefs.put(MainControl.PREFS_LANGUAGE, loc.getLanguage()); } else { prefs.remove(MainControl.PREFS_LANGUAGE); } - prefs.setBoolean(CMainView.MAP_TILE_LIST_BOTTOM_KEY, mapPanelBottom.isSelected()); + prefs.putBoolean(CMainView.MAP_TILE_LIST_BOTTOM_KEY, mapPanelBottom.isSelected()); mainControl.readGlobalSettings(); mainControl.refreshMenusAndToolbars(); } Modified: trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2007-04-04 18:11:45 UTC (rev 2136) +++ trunk/crossfire/src/cfeditor/gui/prefs/ResPrefs.java 2007-04-04 18:16:25 UTC (rev 2137) @@ -99,13 +99,13 @@ /** {@inheritDoc} */ public void apply() { - prefs.set(ResourceFileManager.ARCH_DIR_KEY, PathManager.path(archField.getText())); - prefs.set(ResourceFileManager.MAP_DIR_KEY, PathManager.path(mapField.getText())); - prefs.set(ResourceFileManager.SCRIPT_DIR_KEY, PathManager.path(scriptField.getText())); - prefs.setBoolean(CMainControl.LOAD_ARCH_COLL, loadArches.isSelected()); + prefs.put(ResourceFileManager.ARCH_DIR_KEY, PathManager.path(archField.getText())); + prefs.put(ResourceFileManager.MAP_DIR_KEY, PathManager.path(mapField.getText())); + prefs.put(ResourceFileManager.SCRIPT_DIR_KEY, PathManager.path(scriptField.getText())); + prefs.putBoolean(CMainControl.LOAD_ARCH_COLL, loadArches.isSelected()); final String imageSet = (String) imageSetBox.getSelectedItem(); - prefs.set(CMainControl.USE_IMAGESET, imageSet == null || imageSet.equals("disabled") ? "none" : imageSet); + prefs.put(CMainControl.USE_IMAGESET, imageSet == null || imageSet.equals("disabled") ? "none" : imageSet); mainControl.readGlobalSettings(); mainControl.refreshMenusAndToolbars(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-09 16:42:00
|
Revision: 2197 http://svn.sourceforge.net/gridarta/?rev=2197&view=rev Author: akirschbaum Date: 2007-04-09 09:41:59 -0700 (Mon, 09 Apr 2007) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-04-09 16:36:34 UTC (rev 2196) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-04-09 16:41:59 UTC (rev 2197) @@ -42,6 +42,7 @@ import net.sf.gridarta.gui.map.MapGridListener; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -198,6 +199,19 @@ } /** + * Get the cursor square. + * @return cursor square or <code>null</code> if no current cursor + * @see #getCursorPosition() + */ + @Nullable public MapSquare<GameObject, MapArchObject, Archetype> getCursorSquare() { + try { + return mapModel.getMapSquare(getCursorPosition()); + } catch (final ArrayIndexOutOfBoundsException e) { + return null; + } + } + + /** * Set the cursor position. * @param cursorPosition cursor position * @see #getCursorPosition() Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2007-04-09 16:36:34 UTC (rev 2196) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2007-04-09 16:41:59 UTC (rev 2197) @@ -356,7 +356,7 @@ return; } - if (mapView.getMapControl().containsArchObject(cursor)) { + if (!mapView.getView().getCursorSquare().isEmpty()) { return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-04-21 02:37:11
|
Revision: 2226 http://svn.sourceforge.net/gridarta/?rev=2226&view=rev Author: akirschbaum Date: 2007-04-20 12:26:41 -0700 (Fri, 20 Apr 2007) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-20 19:23:56 UTC (rev 2225) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-04-20 19:26:41 UTC (rev 2226) @@ -864,14 +864,6 @@ return copybuffer.isEmpty(); } - /** - * Returns all level windows that exist in the main view. - * @return All level windows - */ - @Nullable List<MapViewIFrame> getAllLevelWindows() { - return mainView.getAllLevelWindows(); - } - /** Notifies that the application is about to exit. */ void appExitNotify() { mainView.appExitNotify(); // notify main view Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-04-20 19:23:56 UTC (rev 2225) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-04-20 19:26:41 UTC (rev 2226) @@ -446,18 +446,6 @@ updateFocus(true); } - /** - * Returns all level windows that exist in the main view. - * @return All level windows - */ - @Nullable List<MapViewIFrame> getAllLevelWindows() { - if (mapViews != null && !mapViews.isEmpty()) { - return Collections.unmodifiableList(mapViews); - } - - return null; - } - /* * {@inheritDoc} * This implementation displays the exception in a modal message dialog. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-05-08 19:50:49
|
Revision: 2427 http://svn.sourceforge.net/gridarta/?rev=2427&view=rev Author: akirschbaum Date: 2007-05-08 12:50:50 -0700 (Tue, 08 May 2007) Log Message: ----------- Unify code to exit application. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/messages.properties Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-05-08 19:49:33 UTC (rev 2426) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-05-08 19:50:50 UTC (rev 2427) @@ -100,6 +100,12 @@ /** Preferences default value for username. */ public static final String PREFS_USERNAME_DEFAULT = System.getProperty("user.name"); + /** Preferences key for using System.exit(). */ + public static final String PREFS_SYSTEM_EXIT = "systemExit"; + + /** Preferences default value for using System.exit(). */ + public static final boolean PREFS_SYSTEM_EXIT_DEFAULT = true; + /** The main view. */ private final CMainView mainView; @@ -798,7 +804,14 @@ /** Exits from the program. */ void doExit() { appExitNotify(); - System.exit(0); + if (prefs.getBoolean(PREFS_SYSTEM_EXIT, PREFS_SYSTEM_EXIT_DEFAULT)) { + if (log.isDebugEnabled()) { + log.debug(ACTION_FACTORY.getString("logExitWithExit")); + } + System.exit(0); + } else { + log.debug(ACTION_FACTORY.getString("logExitWithoutExit")); + } } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2007-05-08 19:49:33 UTC (rev 2426) +++ trunk/crossfire/src/cfeditor/messages.properties 2007-05-08 19:50:50 UTC (rev 2427) @@ -503,6 +503,8 @@ ####################### # Various Log Messages +logExitWithExit=Exiting with System.exit(). +logExitWithoutExit=Trying to exit without System.exit(). logArchfileNotFound=Archfile {0} could not be found logCanonIOE=IOException while canonizing path: {0} logDuplicateAnimation=Duplicate Animation: {0} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |