You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(103) |
Jun
(121) |
Jul
(16) |
Aug
(67) |
Sep
(126) |
Oct
(161) |
Nov
(164) |
Dec
(588) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(394) |
Feb
(181) |
Mar
(131) |
Apr
(180) |
May
(255) |
Jun
(11) |
Jul
(79) |
Aug
(70) |
Sep
(274) |
Oct
(138) |
Nov
(195) |
Dec
(8) |
2008 |
Jan
(3) |
Feb
(142) |
Mar
(162) |
Apr
(124) |
May
(148) |
Jun
(157) |
Jul
(425) |
Aug
(373) |
Sep
(264) |
Oct
(315) |
Nov
(225) |
Dec
(6) |
2009 |
Jan
(67) |
Feb
(78) |
Mar
(279) |
Apr
(294) |
May
(92) |
Jun
(65) |
Jul
(134) |
Aug
(41) |
Sep
(138) |
Oct
(125) |
Nov
(126) |
Dec
(122) |
2010 |
Jan
(15) |
Feb
(48) |
Mar
(9) |
Apr
(195) |
May
(373) |
Jun
(507) |
Jul
(42) |
Aug
(16) |
Sep
(38) |
Oct
(81) |
Nov
(64) |
Dec
(18) |
2011 |
Jan
(13) |
Feb
(12) |
Mar
(39) |
Apr
(1) |
May
(2) |
Jun
(27) |
Jul
(27) |
Aug
(31) |
Sep
(14) |
Oct
(102) |
Nov
(20) |
Dec
(37) |
2012 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
(18) |
Jul
(6) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(47) |
Jun
(7) |
Jul
(107) |
Aug
|
Sep
|
Oct
(112) |
Nov
(31) |
Dec
(17) |
2014 |
Jan
(29) |
Feb
(111) |
Mar
(34) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(18) |
Dec
(10) |
From: <chr...@us...> - 2006-11-10 23:00:23
|
Revision: 634 http://svn.sourceforge.net/gridarta/?rev=634&view=rev Author: christianhujer Date: 2006-11-10 15:00:18 -0800 (Fri, 10 Nov 2006) Log Message: ----------- Removed unused dependency of the map view to the frame. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/MapViewIFrame.java Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-11-10 22:57:10 UTC (rev 633) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-11-10 23:00:18 UTC (rev 634) @@ -47,7 +47,6 @@ import javax.swing.JScrollPane; import javax.swing.JViewport; import net.sf.gridarta.Size2D; -import net.sf.gridarta.gui.MapView; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; @@ -102,9 +101,6 @@ private MapGrid mapGrid; - // interface for the mapview frame - private final MapView frame; - /** The MapSquares that are known to contain errors. */ private Map<MapSquare<? extends net.sf.gridarta.gameobject.GameObject>, ValidationError> erraneousMapSquares = new HashMap<MapSquare<? extends net.sf.gridarta.gameobject.GameObject>, ValidationError>(); @@ -116,7 +112,7 @@ * @param mainControl the main controller * @param mapControl the controller of this view */ - CMapViewBasic(final CMainControl mainControl, final MapControl mapControl, final MapView fi) { + CMapViewBasic(final CMainControl mainControl, final MapControl mapControl) { super(VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); this.mapControl = mapControl; mapModel = mapControl.getMapModel(); @@ -128,7 +124,6 @@ mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); } this.mainControl = mainControl; - frame = fi; if (isPickmap()) { setBackground(IGUIConstants.BG_COLOR); Modified: trunk/daimonin/src/daieditor/MapViewIFrame.java =================================================================== --- trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-11-10 22:57:10 UTC (rev 633) +++ trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-11-10 23:00:18 UTC (rev 634) @@ -82,7 +82,7 @@ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); // create instance of "real" view object and add it to the frame - view = new CMapViewBasic(mainControl, mapControl, this); + view = new CMapViewBasic(mainControl, mapControl); getContentPane().setLayout(new BorderLayout()); getContentPane().add(view, BorderLayout.CENTER); final Image img = this.mapControl.getIconImage(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-10 22:57:16
|
Revision: 633 http://svn.sourceforge.net/gridarta/?rev=633&view=rev Author: christianhujer Date: 2006-11-10 14:57:10 -0800 (Fri, 10 Nov 2006) Log Message: ----------- Removed disfunctional changed attribute. The view was the wrong location for such an attribute anyway. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/MapViewIFrame.java Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-11-10 22:55:47 UTC (rev 632) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-11-10 22:57:10 UTC (rev 633) @@ -102,8 +102,6 @@ private MapGrid mapGrid; - private boolean changed; - // interface for the mapview frame private final MapView frame; @@ -173,10 +171,6 @@ return mapCursor; } - public boolean isChanged() { - return changed; - } - public Point getMapMouseRightPos() { return mapCursor.getLocation(); } Modified: trunk/daimonin/src/daieditor/MapViewIFrame.java =================================================================== --- trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-11-10 22:55:47 UTC (rev 632) +++ trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-11-10 22:57:10 UTC (rev 633) @@ -112,10 +112,6 @@ strTitle.append(mapControl.getMapFileName()).append(" [ ").append(mapControl.getMapArch().getMapDisplayName()).append(" ] ("); strTitle.append(viewNumber).append(')'); - if (view.isChanged()) { - strTitle.append('*'); // * map has changed - } - setTitle(strTitle.toString()); // display new title } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-10 22:55:54
|
Revision: 632 http://svn.sourceforge.net/gridarta/?rev=632&view=rev Author: christianhujer Date: 2006-11-10 14:55:47 -0800 (Fri, 10 Nov 2006) Log Message: ----------- Fixed bug in documentation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-11-10 22:45:40 UTC (rev 631) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-11-10 22:55:47 UTC (rev 632) @@ -248,7 +248,7 @@ * @param intern * @param join * @return <code>true</code> if insertion is successful, <code>false</code> if not - * @deprecated use {@link #addArchToMap(int, Point, int, boolean)} instead + * @deprecated use {@link #addArchToMap(int, Point, int, boolean, boolean)} instead */ @Deprecated public boolean addArchToMap(final String archname, final int xx, final int yy, final int intern, final boolean join) { return addArchToMap(archname, new Point(xx, yy), intern, join, false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-10 22:45:52
|
Revision: 631 http://svn.sourceforge.net/gridarta/?rev=631&view=rev Author: christianhujer Date: 2006-11-10 14:45:40 -0800 (Fri, 10 Nov 2006) Log Message: ----------- Removed empty application exit notifications. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.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/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-08 22:57:20 UTC (rev 630) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-10 22:45:40 UTC (rev 631) @@ -1570,7 +1570,6 @@ if (currentMap != null) { mainView.setMapTileList(null, -1); - currentMap.appExitNotify(); } // save settings Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-11-08 22:57:20 UTC (rev 630) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-11-10 22:45:40 UTC (rev 631) @@ -237,10 +237,6 @@ this.modelChanged(); } - /** Notifies that the application is about to exit. */ - void appExitNotify() { - } - /** Notifies that this level view is about to be closed. */ void closeNotify() { mapControl.viewCloseNotify(this); Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-11-08 22:57:20 UTC (rev 630) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-11-10 22:45:40 UTC (rev 631) @@ -158,10 +158,6 @@ view.setGridVisibility(fVisible); } - public void appExitNotify() { - view.appExitNotify(); - } - public void closeNotify() { view.closeNotify(); } Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-08 22:57:20 UTC (rev 630) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-10 22:45:40 UTC (rev 631) @@ -106,12 +106,6 @@ } /** - * Notify that the application is about to exit. - */ - public void appExitNotify() { - } - - /** * Notify that the level is about to be closed. */ public void levelCloseNotify() { Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-11-08 22:57:20 UTC (rev 630) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-11-10 22:45:40 UTC (rev 631) @@ -111,12 +111,6 @@ mapView = new MapViewIFrame(mainControl, this, initial); } - /** Notifies that the application is about to exit. */ - public void appExitNotify() { - mapView.appExitNotify(); // drop the view - mapModel.appExitNotify(); // and then the model - } - /** * Return flag that indicates whether this is a pickmap or not. * @return flag that indicates whether this is a pickmap or not Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2006-11-08 22:57:20 UTC (rev 630) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2006-11-10 22:45:40 UTC (rev 631) @@ -34,8 +34,6 @@ @Nullable GameObject getExit(); - void appExitNotify(); - String getMapText(); void setNewMapText(String str); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-08 22:57:27
|
Revision: 630 http://svn.sourceforge.net/gridarta/?rev=630&view=rev Author: christianhujer Date: 2006-11-08 14:57:20 -0800 (Wed, 08 Nov 2006) Log Message: ----------- Improved documentation. Modified Paths: -------------- trunk/daimonin/src/daieditor/io/PathManager.java Modified: trunk/daimonin/src/daieditor/io/PathManager.java =================================================================== --- trunk/daimonin/src/daieditor/io/PathManager.java 2006-11-08 20:59:15 UTC (rev 629) +++ trunk/daimonin/src/daieditor/io/PathManager.java 2006-11-08 22:57:20 UTC (rev 630) @@ -27,7 +27,11 @@ /** * This class contains methods for converting relative map paths to absolute map paths and vice versa. + * Serverside, paths to maps always are URIs with the maps directory being the root directory for the maps. + * Therefore it makes sense to treat them as URIs in the editor as well. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo make more use of URI + * @todo This class knows CMainControl. The dependency should be flipped: instead CMainControl should use this class. Then this class could be used by crossfire, too. */ public final class PathManager { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-08 20:59:25
|
Revision: 629 http://svn.sourceforge.net/gridarta/?rev=629&view=rev Author: christianhujer Date: 2006-11-08 12:59:15 -0800 (Wed, 08 Nov 2006) Log Message: ----------- Moved PathManagerTest to correct package (this was forgotten during one of my last refactorings). Added Paths: ----------- trunk/daimonin/src/test/daieditor/io/ trunk/daimonin/src/test/daieditor/io/PathManagerTest.java Removed Paths: ------------- trunk/daimonin/src/test/daieditor/PathManagerTest.java Deleted: trunk/daimonin/src/test/daieditor/PathManagerTest.java =================================================================== --- trunk/daimonin/src/test/daieditor/PathManagerTest.java 2006-11-08 20:57:47 UTC (rev 628) +++ trunk/daimonin/src/test/daieditor/PathManagerTest.java 2006-11-08 20:59:15 UTC (rev 629) @@ -1,17 +0,0 @@ -package test.daieditor; - -import daieditor.io.PathManager; -import junit.framework.TestCase; - -/** - * Test for {@link daieditor.io.PathManager}. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class PathManagerTest extends TestCase { - - /** Test case for {@link daieditor.io.PathManager#path(String)}. */ - public void testPath() { - assertEquals("Expecting trailing slash from directories being removed.", "/foo", PathManager.path("/foo/")); - } - -} // class PathManagerTest \ No newline at end of file Copied: trunk/daimonin/src/test/daieditor/io/PathManagerTest.java (from rev 625, trunk/daimonin/src/test/daieditor/PathManagerTest.java) =================================================================== --- trunk/daimonin/src/test/daieditor/io/PathManagerTest.java (rev 0) +++ trunk/daimonin/src/test/daieditor/io/PathManagerTest.java 2006-11-08 20:59:15 UTC (rev 629) @@ -0,0 +1,17 @@ +package test.daieditor.io; + +import daieditor.io.PathManager; +import junit.framework.TestCase; + +/** + * Test for {@link daieditor.io.PathManager}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class PathManagerTest extends TestCase { + + /** Test case for {@link daieditor.io.PathManager#path(String)}. */ + public void testPath() { + assertEquals("Expecting trailing slash from directories being removed.", "/foo", PathManager.path("/foo/")); + } + +} // class PathManagerTest \ No newline at end of file Property changes on: trunk/daimonin/src/test/daieditor/io/PathManagerTest.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: <chr...@us...> - 2006-11-08 20:57:53
|
Revision: 628 http://svn.sourceforge.net/gridarta/?rev=628&view=rev Author: christianhujer Date: 2006-11-08 12:57:47 -0800 (Wed, 08 Nov 2006) Log Message: ----------- Removing unused exception class. Removed Paths: ------------- trunk/daimonin/src/daieditor/map/GameObjectOutOfMapBoundsException.java Deleted: trunk/daimonin/src/daieditor/map/GameObjectOutOfMapBoundsException.java =================================================================== --- trunk/daimonin/src/daieditor/map/GameObjectOutOfMapBoundsException.java 2006-11-07 23:52:22 UTC (rev 627) +++ trunk/daimonin/src/daieditor/map/GameObjectOutOfMapBoundsException.java 2006-11-08 20:57:47 UTC (rev 628) @@ -1,53 +0,0 @@ -/* - * Daimonin Java Editor. - * Copyright (C) 2005 Christian Hujer - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package daieditor.map; - -import daieditor.gameobject.GameObject; - -/** - * Exception that's thrown in case game object is out of its map bounds. - * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> - * @serial exclude - */ -public class GameObjectOutOfMapBoundsException extends Exception { - - /** GameObject causing the problem. */ - private final GameObject violator; - - /** - * Create an GameObjectOutOfMapBoundsException. - * @param violator GameObject that was out of bounds - */ - public GameObjectOutOfMapBoundsException(final GameObject violator) { - super("Object out of map bounds: " + violator); - this.violator = violator; - } - - /** - * Get the violator that caused this exception. - * @return violator - */ - public GameObject getViolator() { - return violator; - } - -} // class GameObjectOutOfMapBoundsException This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-07 23:52:31
|
Revision: 627 http://svn.sourceforge.net/gridarta/?rev=627&view=rev Author: christianhujer Date: 2006-11-07 15:52:22 -0800 (Tue, 07 Nov 2006) Log Message: ----------- Some CopyBuffer unification. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/daimonin/src/daieditor/CopyBuffer.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-11-07 22:45:51 UTC (rev 626) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-11-07 23:52:22 UTC (rev 627) @@ -30,11 +30,12 @@ import cfeditor.map.MapControl; import cfeditor.map.MapModel; import java.awt.Point; +import java.awt.Rectangle; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import net.sf.gridarta.Size2D; import org.apache.log4j.Logger; +import org.jetbrains.annotations.Nullable; /** * This class manages the cut/copy/paste actions in maps. The data is stored in @@ -46,24 +47,36 @@ private static final Logger log = Logger.getLogger(CopyBuffer.class); - /** Clear the selection. */ - private static final int DO_CLEAR = 1; + /** Mode for operations. */ + private enum Mode { - /** Cut the selection. */ - private static final int DO_CUT = 2; + /** Clear the selection. */ + DO_CLEAR, - /** Copy the selection. */ - private static final int DO_COPY = 3; + /** Cut the selection. */ + DO_CUT, - private final CMainControl mainControl; // reference to main control + /** Copy the selection. */ + DO_COPY - private MapModel mapData; // map object to store the arches + } // enum Mode - private MapControl buffCtrl; // map-control structure for mapData + /** Reference to main control. */ + private final CMainControl mainControl; + /** + * Internal MapModel to store the cut / copied arches. + * @see #copyMapCtrl + */ + @Nullable private MapModel copyMap; + + /** MapControl for {@link #copyMap}. */ + @Nullable private MapControl copyMapCtrl; + private boolean empty; // Is the CopyBuffer empty? - private MapArchObject mapArch; // dummy for mapArch + /** The dummy MapArchObject of {@link #copyMap}. */ + private final MapArchObject mapArch; private int bufWidth; // buffer's width (counted in tiles) @@ -84,7 +97,7 @@ mapArch.setFileName("cb"); mapArch.setMapName("cb"); - mapData = new DefaultMapModel(this.mainControl, buffCtrl, null, mapArch); + copyMap = new DefaultMapModel(this.mainControl, copyMapCtrl, null, mapArch); } /** @@ -101,7 +114,7 @@ * @param mapControl MapControl of the active map where we copy from */ public void clear(final MapControl mapControl) { - copyNCut(mapControl, DO_CLEAR); + copyNCut(mapControl, Mode.DO_CLEAR); } /** @@ -109,7 +122,7 @@ * @param mapControl MapControl of the active map where we copy from */ public void cut(final MapControl mapControl) { - copyNCut(mapControl, DO_CUT); + copyNCut(mapControl, Mode.DO_CUT); } /** @@ -117,7 +130,7 @@ * @param mapControl MapControl of the active map where we copy from */ public void copy(final MapControl mapControl) { - copyNCut(mapControl, DO_COPY); + copyNCut(mapControl, Mode.DO_COPY); } /** @@ -126,7 +139,7 @@ * @param mapControl MapControl of the active map where we copy from * @param mode defines if we have a cut, copy or paste action */ - private void copyNCut(final MapControl mapControl, final int mode) { + private void copyNCut(final MapControl mapControl, final Mode mode) { final Point startp = mapControl.getMapView().getHighlightStart(); // start of highlighted rect final Point offset = mapControl.getMapView().getHighlightOffset(); // offset of rect from startp @@ -144,8 +157,11 @@ offset.y = Math.abs(offset.y); } + final Rectangle selRec = new Rectangle(startp.x, startp.y, offset.x, offset.y); + assert selRec != null; + // Prepare the buffer (if it's a cut or copy) - if (mode == DO_CUT || mode == DO_COPY) { + if (mode == Mode.DO_CUT || mode == Mode.DO_COPY) { if (empty) { empty = false; // from now on the buffer is never empty again mainControl.getMainView().refreshMenus(); // "Paste" enabled @@ -155,56 +171,55 @@ bufWidth = Math.abs(offset.x) + 1; // new width bufHeight = Math.abs(offset.y) + 1; // new height mapArch.setMapSize(new Size2D(bufWidth, bufHeight)); - mapData = null; // free objects (at least that is the plan and theory) - buffCtrl = null; - mapData = new DefaultMapModel(mainControl, buffCtrl, null, mapArch); // new MapModel - buffCtrl = new MapControl(mainControl, null, mapArch, false, null); // new MapControl + copyMap = null; // free objects (at least that is the plan and theory) + copyMapCtrl = null; + copyMap = new DefaultMapModel(mainControl, copyMapCtrl, null, mapArch); // new MapModel + copyMapCtrl = new MapControl(mainControl, null, mapArch, false, null); // new MapControl } // cycle through all tile coordinates which are highlighted: final Point pos = new Point(); - final List<GameObject> archesToDelete = new ArrayList<GameObject>(); + mapControl.getMapModel().beginTransaction("Cut / Clear"); // TODO: I18N/L10N + final List<GameObject> gameObjectsToDelete = new ArrayList<GameObject>(); for (pos.x = startp.x; pos.x - startp.x <= offset.x; pos.x++) { for (pos.y = startp.y; pos.y - startp.y <= offset.y; pos.y++) { // do the copying for one tile position: - final Iterator<GameObject> it = mapControl.getMapModel().getMapSquare(pos).iterator(); - while (it.hasNext()) { - final GameObject arch = it.next(); - - // store a clone of the arch in the CopyBuffer + for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(pos)) { + // store a clone of the gameObject in the CopyBuffer // (for multiparts, only the heads get copied into the buffer) // arches that don't match the view settings are ignored! - if ((mode == DO_CUT || mode == DO_COPY) && - arch.isHead() && !arch.isInContainer() && - (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(arch.getEditType()))) { - // copy this arch - final GameObject clone = arch.createClone(Math.abs(pos.x - startp.x), Math.abs(pos.y - startp.y)); - buffCtrl.addArchObjectToMap(clone); + if ((mode == Mode.DO_CUT || mode == Mode.DO_COPY) + && gameObject.isHead() && !gameObject.isInContainer() + && (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(gameObject.getEditType()))) { + // copy this gameObject + final GameObject clone = gameObject.createClone(pos.x - startp.x, pos.y - startp.y); + assert copyMapCtrl != null; + copyMapCtrl.addArchObjectToMap(clone); } - // delete the arch if we have a "cut" or "clear" command + // delete the gameObject if we have a "cut" or "clear" command // again, arches that don't match the view settings are ignored - if ((mode == DO_CLEAR || mode == DO_CUT) && (mainControl.getTileEdit() == 0 || - mainControl.isTileEdit(arch.getEditType()))) { + if ((mode == Mode.DO_CLEAR || mode == Mode.DO_CUT) && (mainControl.getTileEdit() == 0 || + mainControl.isTileEdit(gameObject.getEditType()))) { // store next arch in tmp - // delete arch (without redrawing the map) + // delete gameObject (without redrawing the map) // For CUT we don't delete multi tails of multis which are left or // above the head (we would miss to copy them otherwise). - if (mode == DO_CLEAR || (arch.getMultiX() >= 0 && arch.getMultiY() >= 0)) { - archesToDelete.add(arch); + if (mode == Mode.DO_CLEAR || (gameObject.getMultiX() >= 0 && gameObject.getMultiY() >= 0)) { + gameObjectsToDelete.add(gameObject); } } } } } - for (final GameObject arch : archesToDelete) { - arch.remove(); + for (final GameObject gameObject : gameObjectsToDelete) { + gameObject.remove(); } - + mapControl.getMapModel().endTransaction(); // finally redraw the map - if (mode != DO_COPY) { + if (mode != Mode.DO_COPY) { mainControl.refreshCurrentMap(); } } @@ -221,6 +236,7 @@ } // cycle through all tile coordinates which are highlighted: + mapControl.getMapModel().beginTransaction("Paste"); // TODO: I18N/L10N final Point pos = new Point(); final Point sourcePos = new Point(); for (pos.x = startp.x; Math.abs(pos.x - startp.x) < bufWidth; pos.x++) { @@ -229,10 +245,10 @@ if (mapControl.isPointValid(pos)) { sourcePos.x = pos.x - startp.x; sourcePos.y = pos.y - startp.y; - for (final GameObject arch : buffCtrl.getMapModel().getMapSquare(sourcePos)) { - if (!arch.isMulti()) { + for (final GameObject gameObject : copyMapCtrl.getMapModel().getMapSquare(sourcePos)) { + if (!gameObject.isMulti()) { // read arch from buffer and stick in on the map - final GameObject clone = arch.createClone(pos.x, pos.y); + final GameObject clone = gameObject.createClone(pos.x, pos.y); mapControl.addArchObjectToMap(clone); } } @@ -247,14 +263,15 @@ if (mapControl.isPointValid(pos)) { sourcePos.x = pos.x - startp.x; sourcePos.y = pos.y - startp.y; - for (final GameObject arch : buffCtrl.getMapModel().getMapSquare(sourcePos)) { - if (arch.isMulti()) { - addArchToMap(mapControl, arch, pos, -1, false); + for (final GameObject gameObject : copyMapCtrl.getMapModel().getMapSquare(sourcePos)) { + if (gameObject.isMulti()) { + addArchToMap(mapControl, gameObject, pos, -1, false); } } } } } + mapControl.getMapModel().endTransaction(); // now the map and toolbars must be redrawn mapControl.repaint(); @@ -362,13 +379,13 @@ * Add an archetype to the destination map. Inserts a new object instance * for default archetypes, and a clone for non-default archetypes. */ - private void addArchToMap(final MapControl mapControl, final GameObject arch, final Point pos, final int intern, final boolean fillBelow) { + private void addArchToMap(final MapControl mapControl, final GameObject gameObject, final Point pos, final int intern, final boolean fillBelow) { final GameObject newHead; - if (arch.isArchetype()) { - mapControl.addArchToMap(arch.getArchetypeName(), pos, intern, false, fillBelow); + if (gameObject.isArchetype()) { + mapControl.addArchToMap(gameObject.getArchetypeName(), pos, intern, false, fillBelow); } else { - newHead = arch.createClone(pos.x, pos.y); - for (GameObject tmp = arch.getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { + newHead = gameObject.createClone(pos.x, pos.y); + for (GameObject tmp = gameObject.getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { final Point mapPos = new Point(pos.x + tmp.getMultiX(), pos.y + tmp.getMultiY()); if (!mapControl.isPointValid(mapPos)) { Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-11-07 22:45:51 UTC (rev 626) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-11-07 23:52:22 UTC (rev 627) @@ -74,7 +74,7 @@ @Nullable private MapControl copyMapCtrl; /** The dummy MapArchObject of {@link #copyMap}. */ - private final MapArchObject maparch; + private final MapArchObject mapArch; /** * Create the copy buffer. @@ -83,9 +83,9 @@ public CopyBuffer(final CMainControl mainControl) { this.mainControl = mainControl; // link main control in - maparch = new MapArchObject(); - maparch.setFileName("cb"); - maparch.setMapName("cb"); + mapArch = new MapArchObject(); + mapArch.setFileName("cb"); + mapArch.setMapName("cb"); } /** @@ -142,17 +142,17 @@ wasEmpty = true; } - maparch.setMapSize(new Size2D(selRec.width + 1, selRec.height + 1)); - copyMapCtrl = new MapControl(mainControl, null, maparch, false, false); // new MapControl + mapArch.setMapSize(new Size2D(selRec.width + 1, selRec.height + 1)); + copyMapCtrl = new MapControl(mainControl, null, mapArch, false, false); // new MapControl copyMap = copyMapCtrl.getMapModel(); if (wasEmpty) { - mainControl.getMainView().refreshMenus(); // "Paste" enabled + mainControl.getMainView().refreshMenus(); // "Paste" enabled // XXX: sucks - no MVC } } final Point offset = selRec.getLocation(); - mapControl.getMapModel().beginTransaction("Cut / Clear"); - final List<GameObject> archesToDelete = new ArrayList<GameObject>(); + mapControl.getMapModel().beginTransaction("Cut / Clear"); // TODO: I18N/L10N + final List<GameObject> gameObjectsToDelete = new ArrayList<GameObject>(); for (final MapSquare<GameObject> square : mapControl.getMapViewFrame().getView().getSelectedSquares()) { final int posx = square.getMapX(); final int posy = square.getMapY(); @@ -175,19 +175,15 @@ // For CUT we don't delete multi tails of multis which are left or // above the head (we would miss to copy them otherwise). if (mode == Mode.DO_CLEAR || (gameObject.getMultiX() >= 0 && gameObject.getMultiY() >= 0)) { - archesToDelete.add(gameObject); + gameObjectsToDelete.add(gameObject); } } } } - for (final GameObject gameObject : archesToDelete) { + for (final GameObject gameObject : gameObjectsToDelete) { gameObject.remove(); } mapControl.getMapModel().endTransaction(); - // finally redraw the map - if (mode != Mode.DO_COPY) { - mainControl.refreshCurrentMap(); - } } /** @@ -210,7 +206,7 @@ for (final GameObject gameObject : square) { if (!gameObject.isMulti()) { // read gameObject from buffer and stick in on the map - addArchToMap(mapControl, gameObject, pos, true, false); + addArchToMap(mapControl, gameObject, pos, true, false); // XXX Oh oh this looks BOGUS - shouldn't the object be cloned?! } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-07 22:45:59
|
Revision: 626 http://svn.sourceforge.net/gridarta/?rev=626&view=rev Author: christianhujer Date: 2006-11-07 14:45:51 -0800 (Tue, 07 Nov 2006) Log Message: ----------- Removed bogus deprecation comment. This method never was deprecated, the method replaced by this method was. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/map/MapModel.java Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2006-11-06 22:24:48 UTC (rev 625) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2006-11-07 22:45:51 UTC (rev 626) @@ -105,9 +105,8 @@ * @see #endTransaction() * @see #getTransactionDepth() * @see #endAllTransactions() - * @deprecated this method is replaced by {@link #beginTransaction(String)} */ - @Deprecated void beginTransaction(@NotNull String name); + void beginTransaction(@NotNull String name); /** * End a transaction. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-06 22:25:13
|
Revision: 625 http://svn.sourceforge.net/gridarta/?rev=625&view=rev Author: christianhujer Date: 2006-11-06 14:24:48 -0800 (Mon, 06 Nov 2006) Log Message: ----------- Some unification of map output code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/io/CMapFileEncode.java trunk/daimonin/src/daieditor/io/CMapFileEncode.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/io/MapFileEncode.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-06 21:57:23 UTC (rev 624) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-06 22:24:48 UTC (rev 625) @@ -240,7 +240,7 @@ } // attach map encoder and decoder - mapFileEncoder = new CMapFileEncode(this); + mapFileEncoder = new CMapFileEncode(); // our global object parser archetypeParser = new ArchetypeParser(this); Modified: trunk/crossfire/src/cfeditor/io/CMapFileEncode.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapFileEncode.java 2006-11-06 21:57:23 UTC (rev 624) +++ trunk/crossfire/src/cfeditor/io/CMapFileEncode.java 2006-11-06 22:24:48 UTC (rev 625) @@ -24,7 +24,6 @@ package cfeditor.io; -import cfeditor.CMainControl; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; import cfeditor.map.MapModel; @@ -42,6 +41,7 @@ import java.util.Map; import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.io.MapFileEncode; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -50,27 +50,20 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class CMapFileEncode { +public final class CMapFileEncode implements MapFileEncode<MapModel> { private static final Logger log = Logger.getLogger(CMapFileEncode.class); private BufferedWriter bufferedWriter; - private final CMainControl mainControl; - private String fname; /** Create a CMapFileEncode instance. */ - public CMapFileEncode(final CMainControl mainControl) { - this.mainControl = mainControl; + public CMapFileEncode() { } - /** - * Write the whole map-data into a file. - * @param file mapfile - * @param mapModel the MapModel to encode - */ - public void encodeMapFile(@NotNull final File file, final MapModel mapModel) throws FileNotFoundException, IOException { + /** {@inheritDoc} */ + public void encodeMapFile(@NotNull final File file, @NotNull final MapModel mapModel) throws FileNotFoundException, IOException { final MapArchObject mapArch = mapModel.getMapArchObject(); try { @@ -89,9 +82,7 @@ for (final GameObject gameObject : mapModel.getMapSquare(pos)) { // only non multi suckers if (!gameObject.isMulti()) { - if (!writeMapArch(gameObject, false)) { - return; - } + writeGameObject(gameObject, false); } } // node } // y @@ -105,9 +96,7 @@ if (gameObject.isMulti() && gameObject.isHead()) { // only the heads get stored in the mapfile // (that's much more efficient) - if (!writeMapArch(gameObject, false)) { - return; - } + writeGameObject(gameObject, false); } } // node } // y @@ -119,22 +108,12 @@ } /** - * Walk through the inventory of an arch and write everything into the file. - * @param container the container arch whose inventory is to be written - */ - private void browseInvObjects(final GameObject container) { - for (final GameObject gameObject : container) { - writeMapArch(gameObject, true); - } - } - - /** * Here the map arch gets written into the file. * @param gameObject <code>GameObject</code> to be written into the map * @param isInventory is 'arch' inside a container? true/false * @return true if arch was written successfully */ - boolean writeMapArch(final GameObject gameObject, final boolean isInventory) { + void writeGameObject(final GameObject gameObject, final boolean isInventory) throws IOException { final Archetype<GameObject> archetype = gameObject.getArchetype(); // Collect all fields to write. @@ -183,26 +162,20 @@ // is conflicting. remove the type from the archtext // open a reading stream for the archText - final StringReader sread = new StringReader(gameObject.getObjectText().toString()); + final StringReader sread = new StringReader(gameObject.getObjectText()); final BufferedReader sstream = new BufferedReader(sread); String newArchtext = ""; try { - String line = null; // read line + for (String line; (line = sstream.readLine()) != null && line.length() > 0;) { + line = line.trim(); - do { - line = sstream.readLine(); // read one line - - if (line != null && line.length() > 0) { - line = line.trim(); - - if (line.startsWith("type ")) { - // ommit this line - } else { - newArchtext += line + "\n"; // append this line - } + if (line.startsWith("type ")) { + // ommit this line + } else { + newArchtext += line + "\n"; // append this line } - } while (line != null && line.length() > 0); + } // close streams sstream.close(); @@ -253,28 +226,24 @@ Arrays.sort(keys, keyOrderComparator); // Actually write the fields. - try { - bufferedWriter.write("arch " + gameObject.getArchetypeName() + "\n"); - for (int i = 0; i < keys.length; i++) { - final String value = (String) fields.get(keys[i]); - if (value != null) { - final String key = keys[i]; - if (key.equals("msg") || key.equals("lore")) { - bufferedWriter.write(key + "\n" + value + "\n"); - } else { - bufferedWriter.write(key + " " + value + "\n"); - } + bufferedWriter.write("arch " + gameObject.getArchetypeName() + "\n"); + for (int i = 0; i < keys.length; i++) { + final String value = (String) fields.get(keys[i]); + if (value != null) { + final String key = keys[i]; + if (key.equals("msg") || key.equals("lore")) { + bufferedWriter.write(key + "\n" + value + "\n"); + } else { + bufferedWriter.write(key + " " + value + "\n"); } } + } - browseInvObjects(gameObject); // write his inventory inside this arch - - bufferedWriter.write("end\n"); - } catch (final IOException e) { - mainControl.showMessage("Error Save Map", "Error writing file " + fname + "\n"); - return false; + for (final GameObject inventoryItem : gameObject) { + writeGameObject(inventoryItem, true); } - return true; + + bufferedWriter.write("end\n"); } /** Modified: trunk/daimonin/src/daieditor/io/CMapFileEncode.java =================================================================== --- trunk/daimonin/src/daieditor/io/CMapFileEncode.java 2006-11-06 21:57:23 UTC (rev 624) +++ trunk/daimonin/src/daieditor/io/CMapFileEncode.java 2006-11-06 22:24:48 UTC (rev 625) @@ -35,8 +35,10 @@ import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.io.IOUtils; +import net.sf.gridarta.io.MapFileEncode; import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; /** * The <code>CMapFileEncode</code> is used to write a map to a file. @@ -45,7 +47,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @SuppressWarnings({"HardcodedLineSeparator"}) -public final class CMapFileEncode { +public final class CMapFileEncode implements MapFileEncode<MapModel> { private static final Logger log = Logger.getLogger(CMapFileEncode.class); @@ -59,12 +61,8 @@ public CMapFileEncode() { } - /** - * Write the whole map-data into a file. - * @param file mapfile - * @param mapModel the MapModel to encode - */ - public void encodeMapFile(final File file, final MapModel mapModel) throws FileNotFoundException, IOException { + /** {@inheritDoc} */ + public void encodeMapFile(@NotNull final File file, @NotNull final MapModel mapModel) throws FileNotFoundException, IOException { final MapArchObject mapArch = mapModel.getMapArchObject(); try { format = new Formatter(file, IOUtils.MAP_ENCODING); Added: trunk/src/app/net/sf/gridarta/io/MapFileEncode.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/MapFileEncode.java (rev 0) +++ trunk/src/app/net/sf/gridarta/io/MapFileEncode.java 2006-11-06 22:24:48 UTC (rev 625) @@ -0,0 +1,22 @@ +package net.sf.gridarta.io; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import org.jetbrains.annotations.NotNull; +import net.sf.gridarta.map.MapModel; + +/** + * A MapFileEncode writes a map file to a file. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface MapFileEncode<M extends MapModel> { + + /** + * Write the whole map-data into a file. + * @param file mapfile + * @param mapModel the MapModel to encode + */ + void encodeMapFile(@NotNull File file, @NotNull M mapModel) throws FileNotFoundException, IOException; + +} // interface MapFileEncode Property changes on: trunk/src/app/net/sf/gridarta/io/MapFileEncode.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: <chr...@us...> - 2006-11-06 21:57:49
|
Revision: 624 http://svn.sourceforge.net/gridarta/?rev=624&view=rev Author: christianhujer Date: 2006-11-06 13:57:23 -0800 (Mon, 06 Nov 2006) Log Message: ----------- Removed naming of symbols in ArchetypeParser. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapArchPanel.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-06 21:45:38 UTC (rev 623) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-06 21:57:23 UTC (rev 624) @@ -977,7 +977,7 @@ // Ok, now is attached to default arch and loaded png // NOW we post parse the object... // (We calculate only edit types that are active, to save time) - archetypeParser.postParseMapArch(gameObject, tileEdit); + archetypeParser.postParseGameObject(gameObject, tileEdit); archetypeParser.expandMulti(gameObject, tailList); } Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-11-06 21:45:38 UTC (rev 623) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-11-06 21:57:23 UTC (rev 624) @@ -285,7 +285,7 @@ } inv.addLast(invnew); - mainControl.getArchetypeParser().postParseMapArch(invnew, 0); + mainControl.getArchetypeParser().postParseGameObject(invnew, 0); mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), inv.getMyID()); mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified } Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-11-06 21:45:38 UTC (rev 623) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-11-06 21:57:23 UTC (rev 624) @@ -383,7 +383,7 @@ mapControl.addArchObjectToMap(newHead, fillBelow); for (GameObject tmp = newHead.getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { mapControl.addArchObjectToMap(tmp, fillBelow); - mainControl.getArchetypeParser().postParseMapArch(tmp, mapControl.getActiveEditType()); + mainControl.getArchetypeParser().postParseGameObject(tmp, mapControl.getActiveEditType()); } } } Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-06 21:45:38 UTC (rev 623) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-06 21:57:23 UTC (rev 624) @@ -174,20 +174,20 @@ /** {@inheritDoc} */ @Nullable - public GameObject parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject archetype, final String line, final String archName, int index, final String fname) { + public GameObject parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, final String line, final String archName, int index, final String fname) { //Open the file for reading try { // start with new clean GameObject instance - GameObject arch; + GameObject archetype; GameObject archlast = null; - if (archetype == null) { - arch = new GameObject(); + if (prototype == null) { + archetype = new GameObject(); } else { - arch = archetype.createClone(0, 0); + archetype = prototype.createClone(0, 0); } - arch.resetObjectText(); + archetype.resetObjectText(); String thisLine2; if (line == null) { @@ -223,8 +223,8 @@ } archmore = true; } else if (thisLine.startsWith("Object")) { - if (arch == null) { - arch = new GameObject(); + if (archetype == null) { + archetype = new GameObject(); } parsearch = true; @@ -233,9 +233,9 @@ } if (archName == null) { - arch.setArchetypeName(thisLine.substring(7)); + archetype.setArchetypeName(thisLine.substring(7)); } else { - arch.setArchetypeName(archName); + archetype.setArchetypeName(archName); } } } else { @@ -243,35 +243,35 @@ if (thisLine.startsWith("endmsg")) { msgflag = false; } else { - arch.addMsgText(thisLine2 + "\n"); // thisLine2 allows leading whitespaces + archetype.addMsgText(thisLine2 + "\n"); // thisLine2 allows leading whitespaces } } else if (animflag) { if (thisLine.startsWith("mina")) { try { - mainControl.getAnimationObjects().addAnimationObject(arch.getArchetypeName(), arch.getAnimText()); + mainControl.getAnimationObjects().addAnimationObject(archetype.getArchetypeName(), archetype.getAnimText()); } catch (final DuplicateAnimationException e) { - log.warn("Duplicate Animation " + arch.getArchetypeName(), e); + log.warn("Duplicate Animation " + archetype.getArchetypeName(), e); } - arch.addObjectText("animation " + arch.getArchetypeName()); + archetype.addObjectText("animation " + archetype.getArchetypeName()); // here we must add this to AnimationObject // and add Animation cmd here! animflag = false; } else { - arch.addAnimText(thisLine + "\n"); + archetype.addAnimText(thisLine + "\n"); } } else if (loreflag) { if (thisLine.startsWith("endlore")) { loreflag = false; } else { - arch.addLoreText(thisLine + "\n"); + archetype.addLoreText(thisLine + "\n"); } } else if (thisLine.startsWith("Object")) { log.error("Find inventory Object in def arch: " + thisLine); } else if (thisLine.startsWith("end")) { //if (arch.getArchTypNr() == 0) { if (log.isDebugEnabled()) { - log.debug("Arch " + arch.getArchetypeName() + " has no type info!"); + log.debug("Arch " + archetype.getArchetypeName() + " has no type info!"); } //} // we got full arch @@ -279,14 +279,14 @@ if (firstArch != null) { // add to head our x/y position so he can setup refmax - firstArch.addTailPart(arch); + firstArch.addTailPart(archetype); } else { // add arch to the archpanel - only if it is not the map arch - if (!arch.getArchetypeName().equals(STARTARCH_NAME)) { + if (!archetype.getArchetypeName().equals(STARTARCH_NAME)) { if (!mainControl.getArchetypeSet().isLoadedFromArchive() || archName != null) { // loading from individual files, so we simply add it to list // ArchetypeSet.loadArchFromFiles() takes care of the panels - mainControl.addArchPanelArch(arch.getArchetypeName(), index); + mainControl.addArchPanelArch(archetype.getArchetypeName(), index); } else { // loading from collected files, so we need process panels here if (isNewCategory) { @@ -318,74 +318,74 @@ isNewCategory = false; oldCat = newCat; } - mainControl.addArchPanelArch(arch.getArchetypeName(), index); + mainControl.addArchPanelArch(archetype.getArchetypeName(), index); } } } - postParseArchetype(arch); - arch.setIsArchetype(); - mainControl.getArchetypeSet().addArchetype(arch); + postParseArchetype(archetype); + archetype.setIsArchetype(); + mainControl.getArchetypeSet().addArchetype(archetype); archmore = false; // we assume this is last... but perhaps.. // if this arch was from Artifacts file - return here: if (archName != null) { - arch.setArtifact(true); + archetype.setArtifact(true); // here we add all unchanged arch text lines from defArch back to arch - arch.addObjectText(arch.diffArchText(archetype.getObjectText(), true)); - return arch; + archetype.addObjectText(archetype.diffArchText(prototype.getObjectText(), true)); + return archetype; } - archlast = arch; - arch = null; + archlast = archetype; + archetype = null; } else { if (thisLine.startsWith("msg")) { msgflag = true; } else if (thisLine.startsWith("animation")) { - arch.addObjectText(thisLine); + archetype.addObjectText(thisLine); } else if (thisLine.startsWith("anim_speed")) { - arch.addObjectText(thisLine); + archetype.addObjectText(thisLine); } else if (thisLine.startsWith("anim")) { animflag = true; } else if (thisLine.equals("lore")) { loreflag = true; } else if (thisLine.startsWith("visibility ")) { if (log.isDebugEnabled()) { - log.debug("Remove visibility: " + arch.getArchetypeName()); + log.debug("Remove visibility: " + archetype.getArchetypeName()); } } else if (thisLine.startsWith("magicmap ")) { if (log.isDebugEnabled()) { - log.debug("Remove magicmap: " + arch.getArchetypeName()); + log.debug("Remove magicmap: " + archetype.getArchetypeName()); } } else if (thisLine.startsWith("color_fg ")) { if (log.isDebugEnabled()) { - log.debug("Remove color_fg: " + arch.getArchetypeName()); + log.debug("Remove color_fg: " + archetype.getArchetypeName()); } } else if (thisLine.startsWith("color_bg ")) { if (log.isDebugEnabled()) { - log.debug("Remove color_bg: " + arch.getArchetypeName()); + log.debug("Remove color_bg: " + archetype.getArchetypeName()); } } else if (thisLine.startsWith("x ")) { - if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { - log.warn("Find x cmd in single tile or head (add it to arch text): " + arch.getArchetypeName()); - arch.addObjectText(thisLine); + if (!archmore && !archetype.getArchetypeName().equals(STARTARCH_NAME)) { + log.warn("Find x cmd in single tile or head (add it to arch text): " + archetype.getArchetypeName()); + archetype.addObjectText(thisLine); } - arch.setMultiX(Integer.parseInt(thisLine.substring(2))); + archetype.setMultiX(Integer.parseInt(thisLine.substring(2))); } else if (thisLine.startsWith("y ")) { - if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { - log.warn("Find y cmd in single tile or head (add it to arch text): " + arch.getArchetypeName()); - arch.addObjectText(thisLine); + if (!archmore && !archetype.getArchetypeName().equals(STARTARCH_NAME)) { + log.warn("Find y cmd in single tile or head (add it to arch text): " + archetype.getArchetypeName()); + archetype.addObjectText(thisLine); } - arch.setMultiY(Integer.parseInt(thisLine.substring(2))); + archetype.setMultiY(Integer.parseInt(thisLine.substring(2))); } else if (thisLine.startsWith("type ")) { try { final int i = Integer.parseInt(thisLine.substring(5)); - arch.setArchTypNr(i); + archetype.setArchTypNr(i); if (i == 0) { - log.warn("Arch " + arch.getArchetypeName() + " type number is zero. (" + thisLine.substring(5) + ")"); + log.warn("Arch " + archetype.getArchetypeName() + " type number is zero. (" + thisLine.substring(5) + ")"); } } catch (final Exception e) { - log.warn("Arch " + arch.getArchetypeName() + " has a invalid type nr. (" + thisLine.substring(5) + ")"); - arch.addObjectText(thisLine); + log.warn("Arch " + archetype.getArchetypeName() + " has a invalid type nr. (" + thisLine.substring(5) + ")"); + archetype.addObjectText(thisLine); } } else if (thisLine.startsWith("face ")) { int x; @@ -394,8 +394,8 @@ break; } } - arch.setFaceFlag(false); // we HAVE a face - arch.setFaceName(thisLine.substring(x, thisLine.length())); + archetype.setFaceFlag(false); // we HAVE a face + archetype.setFaceName(thisLine.substring(x, thisLine.length())); } else if (thisLine.startsWith("editor_folder ")) { // the display category (= "folder" the arch belongs to) newCat = thisLine.substring(14).trim(); @@ -403,7 +403,7 @@ isNewCategory = true; // this arch has a new category } } - arch.addObjectText(thisLine); + archetype.addObjectText(thisLine); if (log.isDebugEnabled()) { log.debug("add String: " + thisLine); } @@ -418,14 +418,14 @@ } /** {@inheritDoc} */ - public void postParseArchetype(final GameObject arch) { - final String text = arch.getObjectText(); - arch.resetObjectText(); + public void postParseArchetype(final GameObject archetype) { + final String text = archetype.getObjectText(); + archetype.resetObjectText(); final int len = text.length(); // if no type was set, zero is taken - if (arch.getArchTypNr() == GameObject.TYPE_UNSET) { - arch.setArchTypNr(0); + if (archetype.getArchTypNr() == GameObject.TYPE_UNSET) { + archetype.setArchTypNr(0); } boolean scriptflag = false; @@ -434,19 +434,19 @@ if (text.charAt(i) == '\n') { if (i - s > 0) { if (scriptflag) { - arch.addObjectText(text.substring(s, i)); + archetype.addObjectText(text.substring(s, i)); if (text.regionMatches(s, "end_script_", 0, 11)) { scriptflag = false; } } else if (text.regionMatches(s, "start_script_", 0, 13)) { - arch.addObjectText(text.substring(s, i)); + archetype.addObjectText(text.substring(s, i)); scriptflag = true; } else if (text.regionMatches(s, "editable ", 0, 9)) { - arch.setEditType(Integer.parseInt(text.substring(s + 9, i))); + archetype.setEditType(Integer.parseInt(text.substring(s + 9, i))); } else if (text.regionMatches(s, "name ", 0, 5)) { - arch.setObjName(text.substring(s + 5, i)); + archetype.setObjName(text.substring(s + 5, i)); } else { - arch.addObjectText(text.substring(s, i)); + archetype.addObjectText(text.substring(s, i)); } } @@ -456,11 +456,11 @@ // default arches don't get an editType (not worth the time) // they get one assigned as soon as put on a map though. - arch.setEditType(IGUIConstants.TILE_EDIT_NONE); + archetype.setEditType(IGUIConstants.TILE_EDIT_NONE); } /** {@inheritDoc} */ - public void postParseMapArch(final GameObject gameObject, final int editType) { + public void postParseGameObject(final GameObject gameObject, final int editType) { if (gameObject.getArchetypeName() == null) { return; } @@ -542,7 +542,7 @@ // now attach the default arch and stuff // (don't need edit type as we copy from head) - mainControl.getArchetypeParser().postParseMapArch(newarch, 0); + mainControl.getArchetypeParser().postParseGameObject(newarch, 0); } } } Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-06 21:45:38 UTC (rev 623) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-06 21:57:23 UTC (rev 624) @@ -309,7 +309,7 @@ mapGrid[mapx][mapy].addLast(newPart); } - mainControl.getArchetypeParser().postParseMapArch(newPart, mapControl.getActiveEditType()); + mainControl.getArchetypeParser().postParseGameObject(newPart, mapControl.getActiveEditType()); } // Level data has changed @@ -396,7 +396,7 @@ } next.getContainer().addLast(invnew); - mainControl.getArchetypeParser().postParseMapArch(invnew, mapControl.getActiveEditType()); + mainControl.getArchetypeParser().postParseGameObject(invnew, mapControl.getActiveEditType()); mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), invnew.getMyID()); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-11-06 21:45:38 UTC (rev 623) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-11-06 21:57:23 UTC (rev 624) @@ -1284,7 +1284,7 @@ // Ok, now is attached to default arch and loaded png // NOW we post parse the object... // (We calculate only edit types that are active, to save time) - archetypeParser.postParseMapArch(gameObject, tileEdit); + archetypeParser.postParseGameObject(gameObject, tileEdit); // now lets assign the visible face - perhaps we have still a anim gameObject.setObjectFace(); Modified: trunk/daimonin/src/daieditor/CMapArchPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-11-06 21:45:38 UTC (rev 623) +++ trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-11-06 21:57:23 UTC (rev 624) @@ -311,7 +311,7 @@ } invnew.setDirection(invnew.getArchetype().getDirection()); - mainControl.getArchetypeParser().postParseMapArch(invnew, 0); + mainControl.getArchetypeParser().postParseGameObject(invnew, 0); inv.addLast(invnew); invnew.setObjectFace(); mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), inv); Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-11-06 21:45:38 UTC (rev 623) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-11-06 21:57:23 UTC (rev 624) @@ -482,7 +482,7 @@ mapControl.getMapModel().addGameObjectToMap(newHead, fillBelow); for (GameObject tmp = newHead.getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { mapControl.getMapModel().addGameObjectToMap(tmp, fillBelow); - mainControl.getArchetypeParser().postParseMapArch(tmp, mapControl.getActiveEditType()); + mainControl.getArchetypeParser().postParseGameObject(tmp, mapControl.getActiveEditType()); } } } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-11-06 21:45:38 UTC (rev 623) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-11-06 21:57:23 UTC (rev 624) @@ -91,14 +91,14 @@ /** {@inheritDoc} */ @Nullable @SuppressWarnings({"StringContatenationInLoop", "ObjectAllocationInLoop"}) - public GameObject parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject archetype, @Nullable final String line, @Nullable final String archName, /* TODO: final*/ int index, final String fname) throws IOException { + public GameObject parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, @Nullable final String line, @Nullable final String archName, /* TODO: final*/ int index, final String fname) throws IOException { // start with new clean GameObject instance - GameObject arch; + GameObject archetype; GameObject archlast = null; - if (archetype == null) { - arch = new GameObject(); + if (prototype == null) { + archetype = new GameObject(); } else { - arch = archetype.createClone(0, 0); + archetype = prototype.createClone(0, 0); } String newCat; final boolean isInternPath; @@ -120,7 +120,7 @@ path = null; newCat = null; } - arch.resetObjectText(); + archetype.resetObjectText(); String thisLine2; if (line == null) { @@ -156,8 +156,8 @@ } archmore = true; } else if (thisLine.startsWith("Object")) { - if (arch == null) { - arch = new GameObject(); + if (archetype == null) { + archetype = new GameObject(); } parsearch = true; @@ -168,9 +168,9 @@ } if (archName == null) { - arch.setArchetypeName(thisLine.substring(7)); + archetype.setArchetypeName(thisLine.substring(7)); } else { - arch.setArchetypeName(archName); + archetype.setArchetypeName(archName); } multiShapeID = 0; @@ -180,20 +180,20 @@ if (thisLine.startsWith("endmsg")) { msgflag = false; } else { - arch.addMsgText(thisLine2 + "\n"); // thisLine2 allows leading whitespaces + archetype.addMsgText(thisLine2 + "\n"); // thisLine2 allows leading whitespaces } } else if (animflag) { if (thisLine.startsWith("mina")) { try { - mainControl.getAnimationObjects().addAnimPath(arch.getArchetypeName(), path.concat(arch.getArchetypeName())); - mainControl.getAnimationObjects().addAnimationObject(arch.getArchetypeName(), animText.toString()); + mainControl.getAnimationObjects().addAnimPath(archetype.getArchetypeName(), path.concat(archetype.getArchetypeName())); + mainControl.getAnimationObjects().addAnimationObject(archetype.getArchetypeName(), animText.toString()); } catch (final DuplicateAnimationException e) { // TODO: Report to the user log.log(Level.WARNING, "duplicateAnimation", e); } - arch.addObjectText("animation " + arch.getArchetypeName()); - arch.setAnimName(arch.getArchetypeName()); + archetype.addObjectText("animation " + archetype.getArchetypeName()); + archetype.setAnimName(archetype.getArchetypeName()); // here we must add this to AnimationObject // and add Animation cmd here! @@ -212,13 +212,13 @@ if (firstArch != null) { // add to head our x/y position so he can setup refmax - firstArch.addTailPart(arch); + firstArch.addTailPart(archetype); // set or check mpart_nr if (firstArch.getMultiRefCount() == 2) { firstArch.setMultiShapeID(multiShapeID); } else if (multiShapeID != firstArch.getMultiShapeID()) { - log.log(Level.WARNING, "defArchWithInvalidMpartNr", new Object[]{arch.getArchetypeName(), firstArch.getArchetypeName(), Integer.toString(multiShapeID), Integer.toString(firstArch.getMultiShapeID())}); + log.log(Level.WARNING, "defArchWithInvalidMpartNr", new Object[]{archetype.getArchetypeName(), firstArch.getArchetypeName(), Integer.toString(multiShapeID), Integer.toString(firstArch.getMultiShapeID())}); } } else { // add arch to the archpanel - only if it is not the map arch and not in the intern folder @@ -226,7 +226,7 @@ if (!mainControl.getArchetypeSet().isLoadedFromArchive() || archName != null) { // loading from individual files, so we simply add it to list // ArchetypeSet.loadArchFromFiles() takes care of the panels - mainControl.addArchPanelArch(arch.getArchetypeName(), index); + mainControl.addArchPanelArch(archetype.getArchetypeName(), index); } else { // loading from collected files, so we need process panels here // FIXME this sucks. This takes 50% of the time of collecting arches!!! @@ -270,41 +270,41 @@ isNewCategory = false; oldCat = newCat; } - mainControl.addArchPanelArch(arch.getArchetypeName(), index); + mainControl.addArchPanelArch(archetype.getArchetypeName(), index); } } } - postParseArchetype(arch); - arch.setIsArchetype(); - arch.setEditorFolder(newCat); - mainControl.getArchetypeSet().addArchetype(arch); + postParseArchetype(archetype); + archetype.setIsArchetype(); + archetype.setEditorFolder(newCat); + mainControl.getArchetypeSet().addArchetype(archetype); if (archmore) { - calcLowestMulti(arch); + calcLowestMulti(archetype); } archmore = false; // we assume this is last... but perhaps.. // if this arch was from Artifacts file - return here: if (archName != null) { - arch.setArtifact(true); + archetype.setArtifact(true); // here we add all unchanged arch text lines from defArch back to arch - if (archetype != null) { - arch.addObjectText(arch.diffArchText(archetype.getObjectText(), true)); + if (prototype != null) { + archetype.addObjectText(archetype.diffArchText(prototype.getObjectText(), true)); } - return arch; + return archetype; } - archlast = arch; - arch = null; + archlast = archetype; + archetype = null; } else { if (thisLine.startsWith("msg")) { msgflag = true; } else if (thisLine.startsWith("animation ")) { - arch.addObjectText(thisLine); + archetype.addObjectText(thisLine); final String animName = thisLine.substring(10).trim(); - arch.setAnimName(animName); + archetype.setAnimName(animName); //arch.setAnimNr(mainControl.animationObjects.findAnimObject(animName)); // probably not needed, but better not delete it yet } else if (thisLine.startsWith("anim_speed ")) { - arch.addObjectText(thisLine); + archetype.addObjectText(thisLine); } else if (thisLine.startsWith("anim")) { animflag = true; animText = new StringBuilder(); @@ -317,37 +317,37 @@ } else if (thisLine.startsWith("color_bg ")) { // System.err.println("Remove color_bg: "+arch.getArchetypeName()); } else if (thisLine.startsWith("x ")) { - if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { - log.log(Level.WARNING, "foundCoordInDefArchSingleTileOrHead", new Object[]{"x", arch.getArchetypeName()}); - arch.addObjectText(thisLine); + if (!archmore && !archetype.getArchetypeName().equals(STARTARCH_NAME)) { + log.log(Level.WARNING, "foundCoordInDefArchSingleTileOrHead", new Object[]{"x", archetype.getArchetypeName()}); + archetype.addObjectText(thisLine); } else { - arch.setMultiX(Integer.parseInt(thisLine.substring(2))); + archetype.setMultiX(Integer.parseInt(thisLine.substring(2))); } } else if (thisLine.startsWith("y ")) { - if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { - log.log(Level.WARNING, "foundCoordInDefArchSingleTileOrHead", new Object[]{"y", arch.getArchetypeName()}); - arch.addObjectText(thisLine); + if (!archmore && !archetype.getArchetypeName().equals(STARTARCH_NAME)) { + log.log(Level.WARNING, "foundCoordInDefArchSingleTileOrHead", new Object[]{"y", archetype.getArchetypeName()}); + archetype.addObjectText(thisLine); } else { - arch.setMultiY(Integer.parseInt(thisLine.substring(2))); + archetype.setMultiY(Integer.parseInt(thisLine.substring(2))); } } else if (thisLine.startsWith("type ")) { try { final int i = Integer.parseInt(thisLine.substring(5)); - arch.setArchTypNr(i); + archetype.setArchTypNr(i); if (i == 0) { - log.log(Level.WARNING, "defArchWithZeroType", arch.getArchetypeName()); + log.log(Level.WARNING, "defArchWithZeroType", archetype.getArchetypeName()); } } catch (final NumberFormatException e) { - log.log(Level.WARNING, "defArchWithInvalidTypeNr", new Object[]{arch.getArchetypeName(), thisLine.substring(5)}); - arch.addObjectText(thisLine); + log.log(Level.WARNING, "defArchWithInvalidTypeNr", new Object[]{archetype.getArchetypeName(), thisLine.substring(5)}); + archetype.addObjectText(thisLine); } } else if (thisLine.startsWith("direction ")) { try { - arch.setDirection(Integer.parseInt(thisLine.substring(10))); + archetype.setDirection(Integer.parseInt(thisLine.substring(10))); } catch (final NumberFormatException e) { - log.log(Level.WARNING, "defArchWithInvalidDirection", new Object[]{arch.getArchetypeName(), thisLine.substring(10)}); + log.log(Level.WARNING, "defArchWithInvalidDirection", new Object[]{archetype.getArchetypeName(), thisLine.substring(10)}); } - arch.addObjectText(thisLine); + archetype.addObjectText(thisLine); } else if (thisLine.startsWith("face ")) { int x; for (x = 4; x < thisLine.length(); x++) { @@ -355,8 +355,8 @@ break; } } - arch.setFaceRealName(thisLine.substring(x, thisLine.length())); - arch.addObjectText(thisLine); + archetype.setFaceRealName(thisLine.substring(x, thisLine.length())); + archetype.addObjectText(thisLine); } else if (thisLine.startsWith("editor_folder ")) { // the display category (= "folder" the arch belongs to) newCat = thisLine.substring(14).trim(); @@ -369,23 +369,23 @@ multiShapeID = Integer.parseInt(thisLine.substring(9).trim()); if (multiShapeID <= 0 || multiShapeID >= MultiPositionData.Y_DIM) { - System.err.println("WARNING: Arch " + arch.getArchetypeName() + " mpart_id number is '" + thisLine.substring(9) + '\''); + System.err.println("WARNING: Arch " + archetype.getArchetypeName() + " mpart_id number is '" + thisLine.substring(9) + '\''); } } catch (final NumberFormatException e) { - System.err.println("WARNING: Arch " + arch.getArchetypeName() + " has a invalid mpart_id (" + thisLine.substring(9) + ')'); - arch.addObjectText(thisLine); + System.err.println("WARNING: Arch " + archetype.getArchetypeName() + " has a invalid mpart_id (" + thisLine.substring(9) + ')'); + archetype.addObjectText(thisLine); } } else if (thisLine.startsWith("mpart_nr ")) { // part nr for multiparts try { final int i = Integer.parseInt(thisLine.substring(9).trim()); - arch.setMultiPartNr(i); + archetype.setMultiPartNr(i); } catch (final NumberFormatException e) { - System.err.println("WARNING: Arch " + arch.getArchetypeName() + " has a invalid mpart_nr (" + thisLine.substring(9) + ')'); - arch.addObjectText(thisLine); + System.err.println("WARNING: Arch " + archetype.getArchetypeName() + " has a invalid mpart_nr (" + thisLine.substring(9) + ')'); + archetype.addObjectText(thisLine); } } else { - arch.addObjectText(thisLine); + archetype.addObjectText(thisLine); } //System.err.println("add String: "+thisLine); } @@ -396,14 +396,14 @@ } /** {@inheritDoc} */ - public void postParseArchetype(final GameObject arch) { - final String text = arch.getObjectText(); - arch.resetObjectText(); + public void postParseArchetype(final GameObject archetype) { + final String text = archetype.getObjectText(); + archetype.resetObjectText(); final int len = text.length(); // if no type was set, zero is taken - if (arch.getArchTypNr() == GameObject.TYPE_UNSET) { - arch.setArchTypNr(0); + if (archetype.getArchTypNr() == GameObject.TYPE_UNSET) { + archetype.setArchTypNr(0); } boolean scriptflag = false; @@ -412,19 +412,19 @@ if (text.charAt(i) == '\n') { if (i - s > 0) { if (scriptflag) { - arch.addObjectText(text.substring(s, i)); + archetype.addObjectText(text.substring(s, i)); if (text.regionMatches(s, "end_script_", 0, 11)) { scriptflag = false; } } else if (text.regionMatches(s, "start_script_", 0, 13)) { - arch.addObjectText(text.substring(s, i)); + archetype.addObjectText(text.substring(s, i)); scriptflag = true; } else if (text.regionMatches(s, "editable ", 0, 9)) { - arch.setEditType(Integer.parseInt(text.substring(s + 9, i))); + archetype.setEditType(Integer.parseInt(text.substring(s + 9, i))); } else if (text.regionMatches(s, "name ", 0, 5)) { - arch.setObjName(text.substring(s + 5, i)); + archetype.setObjName(text.substring(s + 5, i)); } else { - arch.addObjectText(text.substring(s, i)); + archetype.addObjectText(text.substring(s, i)); } } @@ -435,11 +435,11 @@ // default arches don't get an editType (not worth the time) // they get one assigned as soon as put on a map though. // TODO: This should be changed. - arch.setEditType(IGUIConstants.TILE_EDIT_NONE); + archetype.setEditType(IGUIConstants.TILE_EDIT_NONE); } /** {@inheritDoc} */ - public void postParseMapArch(final GameObject gameObject, final int editType) { + public void postParseGameObject(final GameObject gameObject, final int editType) { if (!gameObject.hasArchetype()) { return; } @@ -529,7 +529,7 @@ // now attach the default arch and stuff // (don't need edit type as we copy from head) - postParseMapArch(newarch, 0); + postParseGameObject(newarch, 0); } } } Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-06 21:45:38 UTC (rev 623) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-06 21:57:23 UTC (rev 624) @@ -151,7 +151,7 @@ mapGrid[pos.x][pos.y].addLast(head); } head.setDirection(archetype.getDirection()); - mainControl.getArchetypeParser().postParseMapArch(head, mapControl.getActiveEditType()); + mainControl.getArchetypeParser().postParseGameObject(head, mapControl.getActiveEditType()); head.setObjectFace(); for (GameObject tailArch = archetype.getMultiNext(); tailArch != null; tailArch = tailArch.getMultiNext()) { final Point posT = new Point(tailArch.getMultiX(), tailArch.getMultiY()); @@ -167,7 +167,7 @@ mapGrid[posT.x][posT.y].addLast(tail); } tail.setDirection(tailArch.getDirection()); - mainControl.getArchetypeParser().postParseMapArch(tail, mapControl.getActiveEditType()); + mainControl.getArchetypeParser().postParseGameObject(tail, mapControl.getActiveEditType()); tail.setObjectFace(); } return true; @@ -236,7 +236,7 @@ next.getContainer().addLast(invnew); invnew.setObjectFace(); - mainControl.getArchetypeParser().postParseMapArch(invnew, mapControl.getActiveEditType()); + mainControl.getArchetypeParser().postParseGameObject(invnew, mapControl.getActiveEditType()); mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), invnew); } return true; Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2006-11-06 21:45:38 UTC (rev 623) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2006-11-06 21:57:23 UTC (rev 624) @@ -38,16 +38,16 @@ /** * Here we read an Archetype from a filestream, parse the data and * put the result in the ArchetypeSet in CMainControl. - * @param in <code>BufferedReader</code> file stream of archetype data - * @param archetype Archetype (only for artifacts) - * @param line first line, pre-parsed (only for artifacts) - * @param archName archetype-object name (only for artifacts) - * @param index current index on the ArchPanel - * @param fname filename of the Archetype + * @param in <code>BufferedReader</code> file stream of archetype data + * @param prototype Prototype Archetype (only for artifacts) + * @param line first line, pre-parsed (only for artifacts) + * @param archName archetype-object name (only for artifacts) + * @param index current index on the ArchPanel + * @param fname filename of the Archetype * @return TODO * @throws IOException in case of I/O problems */ - GameObject parseArchetypeFromStream(BufferedReader in, @Nullable G archetype, @Nullable String line, @Nullable String archName, int index, String fname) throws IOException; + GameObject parseArchetypeFromStream(BufferedReader in, @Nullable G prototype, @Nullable String line, @Nullable String archName, int index, String fname) throws IOException; /** * Short form of {@link #parseArchetypeFromStream(BufferedReader, GameObject, String, String, int, String)}. @@ -86,7 +86,7 @@ * @param editType edit type(s) to be calculated for the gameObject * @todo improve this stupid comment */ - void postParseMapArch(G gameObject, int editType); + void postParseGameObject(G gameObject, int editType); /** * Sort the temp list of arches, placing all multiparts at the end. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-06 21:46:25
|
Revision: 623 http://svn.sourceforge.net/gridarta/?rev=623&view=rev Author: christianhujer Date: 2006-11-06 13:45:38 -0800 (Mon, 06 Nov 2006) Log Message: ----------- Moved I/O classes to packages of their own. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CPickmapPanel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CPickmapPanel.java trunk/daimonin/src/daieditor/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gui/map/MapTilePane.java trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java trunk/daimonin/src/daieditor/gui/prefs/ResPrefs.java trunk/daimonin/src/test/daieditor/PathManagerTest.java Added Paths: ----------- trunk/crossfire/src/cfeditor/io/ trunk/crossfire/src/cfeditor/io/CMapFileDecode.java trunk/crossfire/src/cfeditor/io/CMapFileEncode.java trunk/daimonin/src/daieditor/io/ trunk/daimonin/src/daieditor/io/CMapFileDecode.java trunk/daimonin/src/daieditor/io/CMapFileEncode.java trunk/daimonin/src/daieditor/io/PathManager.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/crossfire/src/cfeditor/CMapFileEncode.java trunk/daimonin/src/daieditor/CMapFileDecode.java trunk/daimonin/src/daieditor/CMapFileEncode.java trunk/daimonin/src/daieditor/PathManager.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-06 21:28:26 UTC (rev 622) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-06 21:45:38 UTC (rev 623) @@ -28,6 +28,8 @@ import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import cfeditor.gameobject.anim.AnimationObjects; +import cfeditor.io.CMapFileDecode; +import cfeditor.io.CMapFileEncode; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; Deleted: trunk/crossfire/src/cfeditor/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-11-06 21:28:26 UTC (rev 622) +++ trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-11-06 21:45:38 UTC (rev 623) @@ -1,229 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor; - -import cfeditor.gameobject.GameObject; -import cfeditor.map.MapArchObject; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.List; -import net.sf.gridarta.io.AbstractMapFileDecode; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * A MapFileDecoder reads a map file and provides access to the information read from the map file. - * This class handles the reading of a mapfile and parsing the data - * into a list of ArchObjects. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class CMapFileDecode extends AbstractMapFileDecode<GameObject, MapArchObject> { - - private static final Logger log = Logger.getLogger(CMapFileDecode.class); - - private int maxxlen, maxylen; - - /** - * Open a resource for reading it as a map. - * @param uri URI of resource to open. - * @throws FileNotFoundException in case the resource was not found. - */ - public CMapFileDecode(final String uri) throws FileNotFoundException { - super(uri); - } - - /** - * Open a file for reading it as a map. - * @param file File to open. - * @throws FileNotFoundException in case the file was not found. - */ - public CMapFileDecode(final File file) throws FileNotFoundException { - super(file); - } - - /** {@inheritDoc} */ - protected MapArchObject createMapArchObject() { - return new MapArchObject(); - } - - /** - * Loading a map from the given mapfile. - * This method returns a list of GameObjects. - * @return first <code>GameObject</code> in the list - * @throws FileNotFoundException in case the requested map file was not found - * @throws IOException in case the file couldn't be read or is in wrong format - * @todo create a separate exception for the wrong format - */ - @NotNull public List<GameObject> decodeMapFile() throws IOException { - final List<GameObject> objects = super.decodeMapFile(); - // finally... here we go - // last action: if the map is bigger than the specified size in - // the maparch, we set the true size: the maxxlen/maxylen counters. - maparch.ensureMapSize(maxxlen + 1, maxylen + 1); - - return objects; // return first arch of the list - } - - /** - * Our recursive accessible arch reader. - * <p/> - * WARNING: this implementation should fail with multi head settings - * if there are multi part items in the inventory (but this is not yet - * included in CF!) - * @param thisLine first line of text, belonging to this new arch - * @return the new parsed <code>GameObject</code> - * @throws IOException when an I/O-error occured during file reading - * @fixme I'm too long, make me shorter. - * @todo Attributes not relevant during map parsing shouldn't be evaluated here, but in GameObject / ArchetypeParser instead. - * @todo Convince crossfire people of removing "More" as it seems to be pointless now. - * @todo Find out whether effectively also trimming msg contents didn't break anything. - */ - // Note for programmers from Daimonin: Crossfire still has to support "More" which was used for multipart objects in the past. - @Nullable protected GameObject readArch(String thisLine) throws IOException { - boolean msgflag = false; - boolean archflag = false; - boolean archmore = false; - GameObject gameObject = null; - do { - thisLine = thisLine.trim(); - - if (!archflag) { - if (thisLine.startsWith("More")) { - // All arches started with "More" are ignored. We load only - // the heads and expand them according to the defaults. - archmore = true; - } else // format violation for better diff - if (thisLine.startsWith("arch ")) { - archflag = true; // from now on we are inside an arch - - if (!archmore) { - gameObject = new GameObject(); // create a new instance - gameObject.setArchetypeName(thisLine.substring(5).trim()); - } - } - } else if (!archmore) { - // here we are inside of an arch object (but not "More")... - if (msgflag) { - if (thisLine.startsWith("endmsg")) { - msgflag = false; - } else { - gameObject.addMsgText(thisLine + '\n'); - } - } else if (thisLine.startsWith("arch ")) { - // ok, we had a full arch... don't care here about map or object - // now we test for a new arch - thats stuf in inventory - // or the end... thats the end of this shit - if (log.isDebugEnabled()) { - log.debug("GO INVENTORY: " + gameObject + " - " + thisLine); - } - gameObject.addLast(readArch(thisLine)); - if (log.isDebugEnabled()) { - log.debug("GO INVENTORY2: " + gameObject + " - " + thisLine); - } - } else if (thisLine.equals("end")) { - objects.add(gameObject); - archflag = false; - archmore = false; - - if (log.isDebugEnabled()) { - log.debug("LEAVE!: " + gameObject + " - " + thisLine); - } - return gameObject; - } else if (thisLine.startsWith("msg")) { - // gameObject.addArchText(thisLine + "\n"); - gameObject.addMsgText(""); // this init the msg text buffer - // in the case of msg/endmsg - // with no content to overrule def msg - msgflag = true; - // this is a MUST, because we overrule "anim" test - } else if (thisLine.startsWith("animation")) { - gameObject.addObjectText(thisLine); - } else if (thisLine.startsWith("anim_speed")) { - gameObject.addObjectText(thisLine); - } else if (thisLine.startsWith("event_")) { - // here's something about a scripted event - final int i = thisLine.indexOf("_plugin"); - final int k = thisLine.indexOf("_options"); - final int space = thisLine.indexOf(" "); - if (space > 0) { - if (i > 0) { - // expecting: "event_type_plugin Name" - final String type = thisLine.substring(6, i); - final String plname = thisLine.substring(space + 1).trim(); - gameObject.addEventPlugin(type, plname); - } else if (k > 0) { - // expecting: "event_type_options Name" - final String type = thisLine.substring(6, k); - final String eventopt = thisLine.substring(space + 1).trim(); - gameObject.addEventOptions(type, eventopt); - } else { - // expecting: "event_type filepath" - final String type = thisLine.substring(6, space); - final String path = thisLine.substring(space + 1).trim(); - gameObject.addEventScript(type, path); - } - } else { - log.warn("Arch " + gameObject.getArchetypeName() + " has incorrect event code '" + thisLine + "'"); - gameObject.addObjectText(thisLine); // keep line, it might have a meaning after all - } - } else if (thisLine.startsWith("x ")) { - final int temp = Integer.parseInt(thisLine.substring(2)); - if (temp > maxxlen) { - maxxlen = temp; - } - gameObject.setMapX(temp); - } else if (thisLine.startsWith("y ")) { - final int temp = Integer.parseInt(thisLine.substring(2)); - if (temp > maxylen) { - maxylen = temp; - } - gameObject.setMapY(temp); - } else if (thisLine.startsWith("type ")) { - // Arches in maps can override their default arch's type - gameObject.setArchTypNr(Integer.parseInt(thisLine.substring(5))); - // don't load it into the archtext! (why?) - } else if (thisLine.startsWith("face ")) { - gameObject.setFaceFlag(false); - gameObject.setFaceName(thisLine.substring(5).trim()); - } else { - gameObject.addObjectText(thisLine); - } - } else { - // We are in a multipart tail arch ("more"), so we skip it: - if (thisLine.regionMatches(0, "end", 0, 3)) { - archflag = false; - archmore = false; - } - } - } while ((thisLine = readLine()) != null); - - return null; // this happens when the file end is reached - } - -} // class CMapFileDecode Deleted: trunk/crossfire/src/cfeditor/CMapFileEncode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-11-06 21:28:26 UTC (rev 622) +++ trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-11-06 21:45:38 UTC (rev 623) @@ -1,557 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor; - -import cfeditor.gameobject.GameObject; -import cfeditor.map.MapArchObject; -import cfeditor.map.MapModel; -import java.awt.Point; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.io.StringReader; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import net.sf.gridarta.Size2D; -import net.sf.gridarta.gameobject.Archetype; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; - -/** - * The <code>CMapFileEncode</code> - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - */ -public final class CMapFileEncode { - - private static final Logger log = Logger.getLogger(CMapFileEncode.class); - - private BufferedWriter bufferedWriter; - - private final CMainControl mainControl; - - private String fname; - - /** Create a CMapFileEncode instance. */ - public CMapFileEncode(final CMainControl mainControl) { - this.mainControl = mainControl; - } - - /** - * Write the whole map-data into a file. - * @param file mapfile - * @param mapModel the MapModel to encode - */ - public void encodeMapFile(@NotNull final File file, final MapModel mapModel) throws FileNotFoundException, IOException { - final MapArchObject mapArch = mapModel.getMapArchObject(); - - try { - fname = file.getAbsolutePath(); - bufferedWriter = new BufferedWriter(new FileWriter(file)); - //GameObject multi; - - // write map header: map arch - mapArch.writeMapArch(bufferedWriter); - - // first, write all one tile parts - final Size2D mapSize = mapArch.getMapSize(); - final Point pos = new Point(); - for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { - for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { - for (final GameObject gameObject : mapModel.getMapSquare(pos)) { - // only non multi suckers - if (!gameObject.isMulti()) { - if (!writeMapArch(gameObject, false)) { - return; - } - } - } // node - } // y - } // x - - // second, we drop the multi part suckers out - for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { - for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { - for (final GameObject gameObject : mapModel.getMapSquare(pos)) { - // search only for heads! - if (gameObject.isMulti() && gameObject.isHead()) { - // only the heads get stored in the mapfile - // (that's much more efficient) - if (!writeMapArch(gameObject, false)) { - return; - } - } - } // node - } // y - } // x - } finally { - bufferedWriter.close(); - bufferedWriter = null; - } - } - - /** - * Walk through the inventory of an arch and write everything into the file. - * @param container the container arch whose inventory is to be written - */ - private void browseInvObjects(final GameObject container) { - for (final GameObject gameObject : container) { - writeMapArch(gameObject, true); - } - } - - /** - * Here the map arch gets written into the file. - * @param gameObject <code>GameObject</code> to be written into the map - * @param isInventory is 'arch' inside a container? true/false - * @return true if arch was written successfully - */ - boolean writeMapArch(final GameObject gameObject, final boolean isInventory) { - final Archetype<GameObject> archetype = gameObject.getArchetype(); - - // Collect all fields to write. - final Map<String, String> fields = new HashMap<String, String>(); // String key -> String value - - final String name = gameObject.getObjName(); - if (name != null) { - fields.put("name", name); - } - - final String face = gameObject.getFaceName(); - if (face != null) { - fields.put("face", face); - } - - if (gameObject.isScripted()) { - final String events = gameObject.getMapArchEventData(); - if (!events.equals("")) { - final String[] tmp = events.split("\n"); - for (final String aTmp : tmp) { - final String[] line = aTmp.split(" +", 2); - if (line.length != 2) { - log.warn("writeMapArch: ignoring invalid event line: " + aTmp); - } else { - fields.put(line[0], line[1]); - } - } - } - } - - if (gameObject.getMsgText() != null && !gameObject.getMsgText().trim().equals((archetype == null || archetype.getMsgText() == null) ? "" : archetype.getMsgText().trim())) { - String msg = ""; - if (gameObject.getMsgText().trim().length() > 0) { - msg = gameObject.getMsgText(); - if (!msg.endsWith("\n")) { - msg += "\n"; - } - } - fields.put("msg", msg + "endmsg"); - } - - if (archetype != null && gameObject.getArchTypNr() != archetype.getArchTypNr()) { - // this arch has special type - if (gameObject.getObjectText().indexOf("type ") >= 0) { - // oh oh - there might also be a type in the archtext which - // is conflicting. remove the type from the archtext - - // open a reading stream for the archText - final StringReader sread = new StringReader(gameObject.getObjectText().toString()); - final BufferedReader sstream = new BufferedReader(sread); - String newArchtext = ""; - - try { - String line = null; // read line - - do { - line = sstream.readLine(); // read one line - - if (line != null && line.length() > 0) { - line = line.trim(); - - if (line.startsWith("type ")) { - // ommit this line - } else { - newArchtext += line + "\n"; // append this line - } - } - } while (line != null && line.length() > 0); - - // close streams - sstream.close(); - sread.close(); - - if (newArchtext.trim().length() == 0) { - gameObject.setObjectText(""); - } else { - gameObject.setObjectText(newArchtext.trim() + "\n"); - } - } catch (final IOException e) { - log.error("getSyntaxErrors: Cannot close StringReader"); - } - } - - // now append the type to the archtext - fields.put("type", Integer.toString(gameObject.getArchTypNr())); - } - - final String text = gameObject.getObjectText(); - if (!text.equals("")) { - final String[] tmp = text.split("\n"); - for (final String aTmp : tmp) { - final String[] line = aTmp.split(" +", 2); - if (line.length != 2) { - log.warn("writeMapArch: ignoring invalid arch line: " + aTmp); - } else { - fields.put(line[0], line[1]); - } - } - } - - if (!isInventory) { - // map coordinates only belong into map arches (not inventory arches) - final int x = gameObject.getMapX(); - if (x != 0) { - fields.put("x", Integer.toString(x)); - } - - final int y = gameObject.getMapY(); - if (y != 0) { - fields.put("y", Integer.toString(y)); - } - } - - // Sort fields to match server/crossedit order. - final String[] keys = (String[]) fields.keySet().toArray(new String[0]); - Arrays.sort(keys, keyOrderComparator); - - // Actually write the fields. - try { - bufferedWriter.write("arch " + gameObject.getArchetypeName() + "\n"); - for (int i = 0; i < keys.length; i++) { - final String value = (String) fields.get(keys[i]); - if (value != null) { - final String key = keys[i]; - if (key.equals("msg") || key.equals("lore")) { - bufferedWriter.write(key + "\n" + value + "\n"); - } else { - bufferedWriter.write(key + " " + value + "\n"); - } - } - } - - browseInvObjects(gameObject); // write his inventory inside this arch - - bufferedWriter.write("end\n"); - } catch (final IOException e) { - mainControl.showMessage("Error Save Map", "Error writing file " + fname + "\n"); - return false; - } - return true; - } - - /** - * Comparator to compare two object fields. The comparator sorts the fields - * in the order in which they should be written to disk. - */ - private static final Comparator<String> keyOrderComparator = new Comparator<String>() { - - /** {@inheritDoc} */ - public int compare(final String o1, final String o2) { - final Integer i1 = keys.get(o1); - final Integer i2 = keys.get(o2); - final int v1 = i1 == null ? Integer.MAX_VALUE : i1.intValue(); - final int v2 = i2 == null ? Integer.MAX_VALUE : i2.intValue(); - if (v1 < v2) { - return -1; - } - if (v1 > v2) { - return +1; - } - assert v1 == v2; - return 0; - } - }; - - /** - * Determines the field order when writing objects to a file. The key is - * the field name, the value is an Integer that describes the order. Lower - * values are written first. - */ - private static final Map<String, Integer> keys = new HashMap<String, Integer>(); - - /* - * Initialize {@link keys} array. - * @todo this information should be read from a file. - */ - static { - addKey("name"); - addKey("name_pl"); - addKey("custom_name"); - addKey("title"); - addKey("race"); - addKey("slaying"); - addKey("skill"); - addKey("msg"); - addKey("lore"); - addKey("other_arch"); - addKey("face"); - addKey("animation"); - addKey("is_animated"); - addKey("Str"); - addKey("Dex"); - addKey("Con"); - addKey("Wis"); - addKey("Pow"); - addKey("Cha"); - addKey("Int"); - addKey("hp"); - addKey("maxhp"); - addKey("sp"); - addKey("maxsp"); - addKey("grace"); - addKey("maxgrace"); - addKey("exp"); - addKey("perm_exp"); - addKey("expmul"); - addKey("food"); - addKey("dam"); - addKey("luck"); - addKey("wc"); - addKey("ac"); - addKey("x"); - addKey("y"); - addKey("speed"); - addKey("speed_left"); - addKey("move_state"); - addKey("attack_movement"); - addKey("nrof"); - addKey("level"); - addKey("direction"); - addKey("type"); - addKey("subtype"); - addKey("attacktype"); - addKey("resist_physical"); - addKey("resist_magic"); - addKey("resist_fire"); - addKey("resist_electricity"); - addKey("resist_cold"); - addKey("resist_confusion"); - addKey("resist_acid"); - addKey("resist_drain"); - addKey("resist_weaponmagic"); - addKey("resist_ghosthit"); - addKey("resist_poison"); - addKey("resist_slow"); - addKey("resist_paralyze"); - addKey("resist_turn_undead"); - addKey("resist_fear"); - addKey("resist_cancellation"); - addKey("resist_deplete"); - addKey("resist_death"); - addKey("resist_chaos"); - addKey("resist_counterspell"); - addKey("resist_godpower"); - addKey("resist_holyword"); - addKey("resist_blind"); - addKey("resist_internal"); - addKey("resist_life_stealing"); - addKey("resist_disease"); - addKey("path_attuned"); - addKey("path_repelled"); - addKey("path_denied"); - addKey("material"); - addKey("materialname"); - addKey("value"); - addKey("carrying"); - addKey("weight"); - addKey("invisible"); - addKey("state"); - addKey("magic"); - addKey("last_heal"); - addKey("last_sp"); - addKey("last_grace"); - addKey("last_eat"); - addKey("connected"); - addKey("glow_radius"); - addKey("randomitems"); - addKey("npc_status"); - addKey("npc_program"); - addKey("run_away"); - addKey("pick_up"); - addKey("container"); - addKey("will_apply"); - addKey("smoothlevel"); - addKey("map_layer"); - addKey("current_weapon_script"); - addKey("weapontype"); - addKey("tooltype"); - addKey("elevation"); - addKey("client_type"); - addKey("item_power"); - addKey("duration"); - addKey("range"); - addKey("range_modifier"); - addKey("duration_modifier"); - addKey("dam_modifier"); - addKey("gen_sp_armour"); - addKey("move_type"); - addKey("move_block"); - addKey("move_allow"); - addKey("move_on"); - addKey("move_off"); - addKey("move_slow"); - addKey("move_slow_penalty"); - addKey("alive"); - addKey("wiz"); - addKey("was_wiz"); - addKey("applied"); - addKey("unpaid"); - addKey("can_use_shield"); - addKey("no_pick"); - addKey("walk_on"); - addKey("no_pass"); - addKey("is_animated"); - addKey("slow_move"); - addKey("flying"); - addKey("monster"); - addKey("friendly"); - addKey("generator"); - addKey("is_thrown"); - addKey("auto_apply"); - addKey("treasure"); - addKey("player sold"); - addKey("see_invisible"); - addKey("can_roll"); - addKey("overlay_floor"); - addKey("is_turnable"); - addKey("walk_off"); - addKey("fly_on"); - addKey("fly_off"); - addKey("is_used_up"); - addKey("identified"); - addKey("reflecting"); - addKey("changing"); - addKey("splitting"); - addKey("hitback"); - addKey("startequip"); - addKey("blocksview"); - addKey("undead"); - addKey("scared"); - addKey("unaggressive"); - addKey("reflect_missile"); - addKey("reflect_spell"); - addKey("no_magic"); - addKey("no_fix_player"); - addKey("is_lightable"); - addKey("tear_down"); - addKey("run_away"); - addKey("pass_thru"); - addKey("can_pass_thru"); - addKey("pick_up"); - addKey("unique"); - addKey("no_drop"); - addKey("wizcast"); - addKey("can_cast_spell"); - addKey("can_use_scroll"); - addKey("can_use_range"); - addKey("can_use_bow"); - addKey("can_use_armour"); - addKey("can_use_weapon"); - addKey("can_use_ring"); - addKey("has_ready_range"); - addKey("has_ready_bow"); - addKey("xrays"); - addKey("is_floor"); - addKey("lifesave"); - addKey("no_strength"); - addKey("sleep"); - addKey("stand_still"); - addKey("random_move"); - addKey("only_attack"); - addKey("confused"); - addKey("stealth"); - addKey("cursed"); - addKey("damned"); - addKey("see_anywhere"); - addKey("known_magical"); - addKey("known_cursed"); - addKey("can_use_skill"); - addKey("been_applied"); - addKey("has_ready_scroll"); - addKey("can_use_rod"); - addKey("can_use_horn"); - addKey("make_invisible"); - addKey("inv_locked"); - addKey("is_wooded"); - addKey("is_hilly"); - addKey("has_ready_skill"); - addKey("has_ready_weapon"); - addKey("no_skill_ident"); - addKey("is_blind"); - addKey("can_see_in_dark"); - addKey("is_cauldron"); - addKey("is_dust"); - addKey("no_steal"); - addKey("one_hit"); - addKey("berserk"); - addKey("neutral"); - addKey("no_attack"); - addKey("no_damage"); - addKey("activate_on_push"); - addKey("activate_on_release"); - addKey("is_water"); - addKey("use_content_on_gen"); - addKey("is_buildable"); - addKey("body_range"); - addKey("body_arm"); - addKey("body_torso"); - addKey("body_head"); - addKey("body_neck"); - addKey("body_skill"); - addKey("body_finger"); - addKey("body_shoulder"); - addKey("body_foot"); - addKey("body_hand"); - addKey("body_wrist"); - addKey("body_waist"); - } - - /** The next key added via {@link #addKey(String)} is assigned this id. */ - private static int idKey = 1; - - /** - * Add a new key to {@link #keys}. The order in which the keys are added is - * the order in which the objects fields are written out. - */ - private static void addKey(final String key) { - keys.put(key, idKey++); - } - -} // class CMapFileEncode Modified: trunk/crossfire/src/cfeditor/CPickmapPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-11-06 21:28:26 UTC (rev 622) +++ trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-11-06 21:45:38 UTC (rev 623) @@ -25,6 +25,7 @@ package cfeditor; import cfeditor.gameobject.GameObject; +import cfeditor.io.CMapFileDecode; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import java.io.File; Copied: trunk/crossfire/src/cfeditor/io/CMapFileDecode.java (from rev 622, trunk/crossfire/src/cfeditor/CMapFileDecode.java) =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapFileDecode.java (rev 0) +++ trunk/crossfire/src/cfeditor/io/CMapFileDecode.java 2006-11-06 21:45:38 UTC (rev 623) @@ -0,0 +1,229 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor.io; + +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapArchObject; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.List; +import net.sf.gridarta.io.AbstractMapFileDecode; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A MapFileDecoder reads a map file and provides access to the information read from the map file. + * This class handles the reading of a mapfile and parsing the data + * into a list of ArchObjects. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class CMapFileDecode extends AbstractMapFileDecode<GameObject, MapArchObject> { + + private static final Logger log = Logger.getLogger(CMapFileDecode.class); + + private int maxxlen, maxylen; + + /** + * Open a resource for reading it as a map. + * @param uri URI of resource to open. + * @throws FileNotFoundException in case the resource was not found. + */ + public CMapFileDecode(final String uri) throws FileNotFoundException { + super(uri); + } + + /** + * Open a file for reading it as a map. + * @param file File to open. + * @throws FileNotFoundException in case the file was not found. + */ + public CMapFileDecode(final File file) throws FileNotFoundException { + super(file); + } + + /** {@inheritDoc} */ + protected MapArchObject createMapArchObject() { + return new MapArchObject(); + } + + /** + * Loading a map from the given mapfile. + * This method returns a list of GameObjects. + * @return first <code>GameObject</code> in the list + * @throws FileNotFoundException in case the requested map file was not found + * @throws IOException in case the file couldn't be read or is in wrong format + * @todo create a separate exception for the wrong format + */ + @NotNull public List<GameObject> decodeMapFile() throws IOException { + final List<GameObject> objects = super.decodeMapFile(); + // finally... here we go + // last action: if the map is bigger than the specified size in + // the maparch, we set the true size: the maxxlen/maxylen counters. + maparch.ensureMapSize(maxxlen + 1, maxylen + 1); + + return objects; // return first arch of the list + } + + /** + * Our recursive accessible arch reader. + * <p/> + * WARNING: this implementation should fail with multi head settings + * if there are multi part items in the inventory (but this is not yet + * included in CF!) + * @param thisLine first line of text, belonging to this new arch + * @return the new parsed <code>GameObject</code> + * @throws IOException when an I/O-error occured during file reading + * @fixme I'm too long, make me shorter. + * @todo Attributes not relevant during map parsing shouldn't be evaluated here, but in GameObject / ArchetypeParser instead. + * @todo Convince crossfire people of removing "More" as it seems to be pointless now. + * @todo Find out whether effectively also trimming msg contents didn't break anything. + */ + // Note for programmers from Daimonin: Crossfire still has to support "More" which was used for multipart objects in the past. + @Nullable protected GameObject readArch(String thisLine) throws IOException { + boolean msgflag = false; + boolean archflag = false; + boolean archmore = false; + GameObject gameObject = null; + do { + thisLine = thisLine.trim(); + + if (!archflag) { + if (thisLine.startsWith("More")) { + // All arches started with "More" are ignored. We load only + // the heads and expand them according to the defaults. + archmore = true; + } else // format violation for better diff + if (thisLine.startsWith("arch ")) { + archflag = true; // from now on we are inside an arch + + if (!archmore) { + gameObject = new GameObject(); // create a new instance + gameObject.setArchetypeName(thisLine.substring(5).trim()); + } + } + } else if (!archmore) { + // here we are inside of an arch object (but not "More")... + if (msgflag) { + if (thisLine.startsWith("endmsg")) { + msgflag = false; + } else { + gameObject.addMsgText(thisLine + '\n'); + } + } else if (thisLine.startsWith("arch ")) { + // ok, we had a full arch... don't care here about map or object + // now we test for a new arch - thats stuf in inventory + // or the end... thats the end of this shit + if (log.isDebugEnabled()) { + log.debug("GO INVENTORY: " + gameObject + " - " + thisLine); + } + gameObject.addLast(readArch(thisLine)); + if (log.isDebugEnabled()) { + log.debug("GO INVENTORY2: " + gameObject + " - " + thisLine); + } + } else if (thisLine.equals("end")) { + objects.add(gameObject); + archflag = false; + archmore = false; + + if (log.isDebugEnabled()) { + log.debug("LEAVE!: " + gameObject + " - " + thisLine); + } + return gameObject; + } else if (thisLine.startsWith("msg")) { + // gameObject.addArchText(thisLine + "\n"); + gameObject.addMsgText(""); // this init the msg text buffer + // in the case of msg/endmsg + // with no content to overrule def msg + msgflag = true; + // this is a MUST, because we overrule "anim" test + } else if (thisLine.startsWith("animation")) { + gameObject.addObjectText(thisLine); + } else if (thisLine.startsWith("anim_speed")) { + gameObject.addObjectText(thisLine); + } else if (thisLine.startsWith("event_")) { + // here's something about a scripted event + final int i = thisLine.indexOf("_plugin"); + final int k = thisLine.indexOf("_options"); + final int space = thisLine.indexOf(" "); + if (space > 0) { + if (i > 0) { + // expecting: "event_type_plugin Name" + final String type = thisLine.substring(6, i); + final String plname = thisLine.substring(space + 1).trim(); + gameObject.addEventPlugin(type, plname); + } else if (k > 0) { + // expecting: "event_type_options Name" + final String type = thisLine.substring(6, k); + final String eventopt = thisLine.substring(space + 1).trim(); + gameObject.addEventOptions(type, eventopt); + } else { + // expecting: "event_type filepath" + final String type = thisLine.substring(6, space); + final String path = thisLine.substring(space + 1).trim(); + gameObject.addEventScript(type, path); + } + } else { + log.warn("Arch " + gameObject.getArchetypeName() + " has incorrect event code '" + thisLine + "'"); + gameObject.addObjectText(thisLine); // keep line, it might have a meaning after all + } + } else if (thisLine.startsWith("x ")) { + final int temp = Integer.parseInt(thisLine.substring(2)); + if (temp > maxxlen) { + maxxlen = temp; + } + gameObject.setMapX(temp); + } else if (thisLine.startsWith("y ")) { + final int temp = Integer.parseInt(thisLine.substring(2)); + if (temp > maxylen) { + maxylen = temp; + } + gameObject.setMapY(temp); + } else if (thisLine.startsWith("type ")) { + // Arches in maps can override their default arch's type + gameObject.setArchTypNr(Integer.parseInt(thisLine.substring(5))); + // don't load it into the archtext! (why?) + } else if (thisLine.startsWith("face ")) { + gameObject.setFaceFlag(false); + gameObject.setFaceName(thisLine.substring(5).trim()); + } else { + gameObject.addObjectText(thisLine); + } + } else { + // We are in a multipart tail arch ("more"), so we skip it: + if (thisLine.regionMatches(0, "end", 0, 3)) { + archflag = false; + archmore = false; + } + } + } while ((thisLine = readLine()) != null); + + return null; // this happens when the file end is reached + } + +} // class CMapFileDecode Property changes on: trunk/crossfire/src/cfeditor/io/CMapFileDecode.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/crossfire/src/cfeditor/io/CMapFileEncode.java (from rev 622, trunk/crossfire/src/cfeditor/CMapFileEncode.java) =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapFileEncode.java (rev 0) +++ trunk/crossfire/src/cfeditor/io/CMapFileEncode.java 2006-11-06 21:45:38 UTC (rev 623) @@ -0,0 +1,558 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor.io; + +import cfeditor.CMainControl; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapArchObject; +import cfeditor.map.MapModel; +import java.awt.Point; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.StringReader; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import net.sf.gridarta.Size2D; +import net.sf.gridarta.gameobject.Archetype; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * The <code>CMapFileEncode</code> + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + */ +public final class CMapFileEncode { + + private static final Logger log = Logger.getLogger(CMapFileEncode.class); + + private BufferedWriter bufferedWriter; + + private final CMainControl mainControl; + + private String fname; + + /** Create a CMapFileEncode instance. */ + public CMapFileEncode(final CMainControl mainControl) { + this.mainControl = mainControl; + } + + /** + * Write the whole map-data into a file. + * @param file mapfile + * @param mapModel the MapModel to encode + */ + public void encodeMapFile(@NotNull final File file, final MapModel mapModel) throws FileNotFoundException, IOException { + final MapArchObject mapArch = mapModel.getMapArchObject(); + + try { + fname = file.getAbsolutePath(); + bufferedWriter = new BufferedWriter(new FileWriter(file)); + //GameObject multi; + + // write map header: map arch + mapArch.writeMapArch(bufferedWriter); + + // first, write all one tile parts + final Size2D mapSize = mapArch.getMapSize(); + final Point pos = new Point(); + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { + for (final GameObject gameObject : mapModel.getMapSquare(pos)) { + // only non multi suckers + if (!gameObject.isMulti()) { + if (!writeMapArch(gameObject, false)) { + return; + } + } + } // node + } // y + } // x + + // second, we drop the multi part suckers out + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { + for (final GameObject gameObject : mapModel.getMapSquare(pos)) { + // search only for heads! + if (gameObject.isMulti() && gameObject.isHead()) { + // only the heads get stored in the mapfile + // (that's much more efficient) + if (!writeMapArch(gameObject, false)) { + return; + } + } + } // node + } // y + } // x + } finally { + bufferedWriter.close(); + bufferedWriter = null; + } + } + + /** + * Walk through the inventory of an arch and write everything into the file. + * @param container the container arch whose inventory is to be written + */ + private void browseInvObjects(final GameObject container) { + for (final GameObject gameObject : container) { + writeMapArch(gameObject, true); + } + } + + /** + * Here the map arch gets written into the file. + * @param gameObject <code>GameObject</code> to be written into the map + * @param isInventory is 'arch' inside a container? true/false + * @return true if arch was written successfully + */ + boolean writeMapArch(final GameObject gameObject, final boolean isInventory) { + final Archetype<GameObject> archetype = gameObject.getArchetype(); + + // Collect all fields to write. + final Map<String, String> fields = new HashMap<String, String>(); // String key -> String value + + final String name = gameObject.getObjName(); + if (name != null) { + fields.put("name", name); + } + + final String face = gameObject.getFaceName(); + if (face != null) { + fields.put("face", face); + } + + if (gameObject.isScripted()) { + final String events = gameObject.getMapArchEventData(); + if (!events.equals("")) { + final String[] tmp = events.split("\n"); + for (final String aTmp : tmp) { + final String[] line = aTmp.split(" +", 2); + if (line.length != 2) { + log.warn("writeMapArch: ignoring invalid event line: " + aTmp); + } else { + fields.put(line[0], line[1]); + } + } + } + } + + if (gameObject.getMsgText() != null && !gameObject.getMsgText().trim().equals((archetype == null || archetype.getMsgText() == null) ? "" : archetype.getMsgText().trim())) { + String msg = ""; + if (gameObject.getMsgText().trim().length() > 0) { + msg = gameObject.getMsgText(); + if (!msg.endsWith("\n")) { + msg += "\n"; + } + } + fields.put("msg", msg + "endmsg"); + } + + if (archetype != null && gameObject.getArchTypNr() != archetype.getArchTypNr()) { + // this arch has special type + if (gameObject.getObjectText().indexOf("type ") >= 0) { + // oh oh - there might also be a type in the archtext which + // is conflicting. remove the type from the archtext + + // open a reading stream for the archText + final StringReader sread = new StringReader(gameObject.getObjectText().toString()); + final BufferedReader sstream = new BufferedReader(sread); + String newArchtext = ""; + + try { + String line = null; // read line + + do { + line = sstream.readLine(); // read one line + + if (line != null && line.length() > 0) { + line = line.trim(); + + if (line.startsWith("type ")) { + // ommit this line + } else { + newArchtext += line + "\n"; // append this line + } + } + } while (line != null && line.length() > 0); + + // close streams + sstream.close(); + sread.close(); + + if (newArchtext.trim().length() == 0) { + gameObject.setObjectText(""); + } else { + gameObject.setObjectText(newArchtext.trim() + "\n"); + } + } catch (final IOException e) { + log.error("getSyntaxErrors: Cannot close StringReader"); + } + } + + // now append the type to the archtext + fields.put("type", Integer.toString(gameObject.getArchTypNr())); + } + + final String text = gameObject.getObjectText(); + if (!text.equals("")) { + final String[] tmp = text.split("\n"); + for (final String aTmp : tmp) { + final String[] line = aTmp.split(" +", 2); + if (line.length != 2) { + log.warn("writeMapArch: ignoring invalid arch line: " + aTmp); + } else { + fields.put(line[0], line[1]); + } + } + } + + if (!isInventory) { + // map coordinates only belong into map arches (not inventory arches) + final int x = gameObject.getMapX(); + if (x != 0) { + fields.put("x", Integer.toString(x)); + } + + final int y = gameObject.getMapY(); + if (y != 0) { + fields.put("y", Integer.toString(y)); + } + } + + // Sort fields to match server/crossedit order. + final String[] keys = (String[]) fields.keySet().toArray(new String[0]); + Arrays.sort(keys, keyOrderComparator); + + // Actually write the fields. + try { + bufferedWriter.write("arch " + gameObject.getArchetypeName() + "\n"); + for (int i = 0; i < keys.length; i++) { + final String value = (String) fields.get(keys[i]); + if (value != null) { + final String key = keys[i]; + if (key.equals("msg") || key.equals("lore")) { + bufferedWriter.write(key + "\n" + value + "\n"); + } else { + bufferedWriter.write(key + " " + value + "\n"); + } + } + } + + browseInvObjects(gameObject); // write his inventory inside this arch + + bufferedWriter.write("end\n"); + } catch (final IOException e) { + mainControl.showMessage("Error Save Map", "Error writing file " + fname + "\n"); + return false; + } + return true; + } + + /** + * Comparator to compare two object fields. The comparator sorts the fields + * in the order in which they should be written to disk. + */ + private static final Comparator<String> keyOrderComparator = new Comparator<String>() { + + /** {@inheritDoc} */ + public int compare(final String o1, final String o2) { + final Integer i1 = keys.get(o1); + final Integer i2 = keys.get(o2); + final int v1 = i1 == null ? Integer.MAX_VALUE : i1.intValue(); + final int v2 = i2 == null ? Integer.MAX_VALUE : i2.intValue(); + if (v1 < v2) { + return -1; + } + if (v1 > v2) { + return +1; + } + assert v1 == v2; + return 0; + } + }; + + /** + * Determines the field order when writing objects to a file. The key is + * the field name, the value is an Integer that describes the order. Lower + * values are written first. + */ + private static final Map<String, Integer> keys = new HashMap<String, Integer>(); + + /* + * Initialize {@link keys} array. + * @todo this information should be read from a file. + */ + static { + addKey("name"); + addKey("name_pl"); + addKey("custom_name"); + addKey("title"); + addKey("race"); + addKey("slaying"); + addKey("skill"); + addKey("msg"); + addKey("lore"); + addKey("other_arch"); + addKey("face"); + addKey("animation"); + addKey("is_animated"); + addKey("Str"); + addKey("Dex"); + addKey("Con"); + addKey("Wis"); + addKey("Pow"); + addKey("Cha"); + addKey("Int"); + addKey("hp"); + addKey("maxhp"); + addKey("sp"); + addKey("maxsp"); + addKey("grace"); + addKey("maxgrace"); + addKey("exp"); + addKey("perm_exp"); + addKey("expmul"); + addKey("food"); + addKey("dam"); + addKey("luck"); + addKey("wc"); + addKey("ac"); + addKey("x"); + addKey("y"); + addKey("speed"); + addKey("speed_left"); + addKey("move_state"); + addKey("attack_movement"); + addKey("nrof"); + addKey("level"); + addKey("direction"); + addKey("type"); + addKey("subtype"); + addKey("attacktype"); + addKey("resist_physical"); + addKey("resist_magic"); + addKey("resist_fire"); + addKey("resist_electricity"); + addKey("resist_cold"); + addKey("resist_confusion"); + addKey("resist_acid"); + addKey("resist_drain"); + addKey("resist_weaponmagic"); + addKey("resist_ghosthit"); + addKey("resist_poison"); + addKey("resist_slow"); + addKey("resist_paralyze"); + addKey("resist_turn_undead"); + addKey("resist_fear"); + addKey("resist_cancellation"); + addKey("resist_deplete"); + addKey("resist_death"); + addKey("resist_chaos"); + addKey("resist_counterspell"); + addKey("resist_godpower"); + addKey("resist_holyword"); + addKey("resist_blind"); + addKey("resist_internal"); + addKey("resist_life_stealing"); + addKey("resist_disease"); + addKey("path_attuned"); + addKey("path_repelled"); + addKey("path_denied"); + addKey("material"); + addKey("materialname"); + addKey("value"); + addKey("carrying"); + addKey("weight"); + addKey("invisible"); + addKey("state"); + addKey("magic"); + addKey("last_heal"); + addKey("last_sp"); + addKey("last_grace"); + addKey("last_eat"); + addKey("connected"); + addKey("glow_radius"); + addKey("randomitems"); + addKey("npc_status"); + addKey("npc_program"); + addKey("run_away"); + addKey("pick_up"); + addKey("container"); + addKey("will_apply"); + addKey("smoothlevel"); + addKey("map_layer"); + addKey("current_weapon_script"); + addKey("weapontype"); + addKey("tooltype"); + addKey("elevation"); + addKey("client_type"); + addKey("item_power"); + addKey("duration"); + addKey("range"); + addKey("range_modifier"); + addKey("duration_modifier"); + addKey("dam_modifier"); + addKey("gen_sp_armour"); + addKey("move_type"); + addKey("move_block"); + addKey(... [truncated message content] |
From: <chr...@us...> - 2006-11-06 21:28:47
|
Revision: 622 http://svn.sourceforge.net/gridarta/?rev=622&view=rev Author: christianhujer Date: 2006-11-06 13:28:26 -0800 (Mon, 06 Nov 2006) Log Message: ----------- Changed GameObject.addObjectText() from adding arbitrary text to whole lines. This will be used when moving attribute parsing into GameObject (delegated to GameObjectParser / ArchetypeParser). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/CAttribDialog.java trunk/daimonin/src/daieditor/CMapFileDecode.java trunk/daimonin/src/daieditor/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-11-06 21:03:52 UTC (rev 621) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-11-06 21:28:26 UTC (rev 622) @@ -1463,7 +1463,7 @@ if (typeStruct == typelist.getHead().getNext()) { // for generic (misc) type, all errors are automatically kept. // "misc" is no real type - it is more a default mask for unknown types - gameObject.addObjectText(errors.trim() + "\n"); + gameObject.addObjectText(errors.trim()); } else { // open a popup dialog and ask user to decide what to do with his errors askConfirmErrors(errors); @@ -1768,7 +1768,7 @@ // the user pressed "keep", so we append the contents // of the textfield to the archtext if (text.getText() != null && text.getText().trim().length() > 0) { - arch.addObjectText(text.getText().trim() + "\n"); + arch.addObjectText(text.getText().trim()); } } @@ -1783,7 +1783,7 @@ * be assumed that the user did not properly think about them yet. */ public void windowClosing(final WindowEvent e) { - arch.addObjectText(allErrors.trim() + "\n"); + arch.addObjectText(allErrors.trim()); // nuke the popup dialog dialog.dispose(); Modified: trunk/crossfire/src/cfeditor/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-11-06 21:03:52 UTC (rev 621) +++ trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-11-06 21:28:26 UTC (rev 622) @@ -163,9 +163,9 @@ msgflag = true; // this is a MUST, because we overrule "anim" test } else if (thisLine.startsWith("animation")) { - gameObject.addObjectText(thisLine + "\n"); + gameObject.addObjectText(thisLine); } else if (thisLine.startsWith("anim_speed")) { - gameObject.addObjectText(thisLine + "\n"); + gameObject.addObjectText(thisLine); } else if (thisLine.startsWith("event_")) { // here's something about a scripted event final int i = thisLine.indexOf("_plugin"); @@ -190,7 +190,7 @@ } } else { log.warn("Arch " + gameObject.getArchetypeName() + " has incorrect event code '" + thisLine + "'"); - gameObject.addObjectText(thisLine + "\n"); // keep line, it might have a meaning after all + gameObject.addObjectText(thisLine); // keep line, it might have a meaning after all } } else if (thisLine.startsWith("x ")) { final int temp = Integer.parseInt(thisLine.substring(2)); @@ -212,7 +212,7 @@ gameObject.setFaceFlag(false); gameObject.setFaceName(thisLine.substring(5).trim()); } else { - gameObject.addObjectText(thisLine + "\n"); + gameObject.addObjectText(thisLine); } } else { // We are in a multipart tail arch ("more"), so we skip it: Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-06 21:03:52 UTC (rev 621) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-06 21:28:26 UTC (rev 622) @@ -253,7 +253,7 @@ log.warn("Duplicate Animation " + arch.getArchetypeName(), e); } - arch.addObjectText("animation " + arch.getArchetypeName() + "\n"); + arch.addObjectText("animation " + arch.getArchetypeName()); // here we must add this to AnimationObject // and add Animation cmd here! animflag = false; @@ -341,9 +341,9 @@ if (thisLine.startsWith("msg")) { msgflag = true; } else if (thisLine.startsWith("animation")) { - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } else if (thisLine.startsWith("anim_speed")) { - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } else if (thisLine.startsWith("anim")) { animflag = true; } else if (thisLine.equals("lore")) { @@ -367,13 +367,13 @@ } else if (thisLine.startsWith("x ")) { if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { log.warn("Find x cmd in single tile or head (add it to arch text): " + arch.getArchetypeName()); - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } arch.setMultiX(Integer.parseInt(thisLine.substring(2))); } else if (thisLine.startsWith("y ")) { if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { log.warn("Find y cmd in single tile or head (add it to arch text): " + arch.getArchetypeName()); - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } arch.setMultiY(Integer.parseInt(thisLine.substring(2))); } else if (thisLine.startsWith("type ")) { @@ -385,7 +385,7 @@ } } catch (final Exception e) { log.warn("Arch " + arch.getArchetypeName() + " has a invalid type nr. (" + thisLine.substring(5) + ")"); - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } } else if (thisLine.startsWith("face ")) { int x; @@ -403,7 +403,7 @@ isNewCategory = true; // this arch has a new category } } - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); if (log.isDebugEnabled()) { log.debug("add String: " + thisLine); } @@ -434,19 +434,19 @@ if (text.charAt(i) == '\n') { if (i - s > 0) { if (scriptflag) { - arch.addObjectText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i)); if (text.regionMatches(s, "end_script_", 0, 11)) { scriptflag = false; } } else if (text.regionMatches(s, "start_script_", 0, 13)) { - arch.addObjectText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i)); scriptflag = true; } else if (text.regionMatches(s, "editable ", 0, 9)) { arch.setEditType(Integer.parseInt(text.substring(s + 9, i))); } else if (text.regionMatches(s, "name ", 0, 5)) { arch.setObjName(text.substring(s + 5, i)); } else { - arch.addObjectText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i)); } } @@ -479,7 +479,7 @@ gameObject.setObjName(text.substring(s + 5, i)); } else { // this is an unparsed arch attribute, it has to stay in the archtext - gameObject.addObjectText(text.substring(s, i) + "\n"); + gameObject.addObjectText(text.substring(s, i)); } } s = i + 1; @@ -507,9 +507,9 @@ // we don't handle anim yet, so attach then back to archtext if (gameObject.getAnimText() != null) { - gameObject.addObjectText("anim\n"); + gameObject.addObjectText("anim"); gameObject.addObjectText(gameObject.getAnimText()); - gameObject.addObjectText("mina\n"); + gameObject.addObjectText("mina"); } // Finally, we calculate the desired editType of the arch Modified: trunk/daimonin/src/daieditor/CAttribDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CAttribDialog.java 2006-11-06 21:03:52 UTC (rev 621) +++ trunk/daimonin/src/daieditor/CAttribDialog.java 2006-11-06 21:28:26 UTC (rev 622) @@ -1355,7 +1355,7 @@ if (typeStruct == typelist.getArchType(0)) { // for generic (misc) type, all errors are automatically kept. // "misc" is no real type - it is more a default mask for unknown types - gameObject.addObjectText(errors.trim() + '\n'); + gameObject.addObjectText(errors.trim()); } else { // open a popup dialog and ask user to decide what to do with his errors askConfirmErrors(errors); @@ -1642,7 +1642,7 @@ // the user pressed "keep", so we append the contents // of the textfield to the archtext if (text.getText() != null && text.getText().trim().length() > 0) { - arch.addObjectText(text.getText().trim() + '\n'); + arch.addObjectText(text.getText().trim()); } } @@ -1653,7 +1653,7 @@ /** {@inheritDoc} */ @Override public void windowClosing(final WindowEvent e) { - arch.addObjectText(allErrors.trim() + '\n'); + arch.addObjectText(allErrors.trim()); // nuke the popup dialog dialog.dispose(); Modified: trunk/daimonin/src/daieditor/CMapFileDecode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-11-06 21:03:52 UTC (rev 621) +++ trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-11-06 21:28:26 UTC (rev 622) @@ -155,12 +155,12 @@ // don't load it into the archtext! (why?) } else if (thisLine.startsWith("direction ")) { gameObject.setDirection(Integer.parseInt(thisLine.substring(10))); - gameObject.addObjectText(thisLine + '\n'); + gameObject.addObjectText(thisLine); } else if (thisLine.startsWith("face ")) { gameObject.setFaceRealName(thisLine.substring(5).trim()); - gameObject.addObjectText(thisLine + '\n'); + gameObject.addObjectText(thisLine); } else { - gameObject.addObjectText(thisLine + '\n'); + gameObject.addObjectText(thisLine); } } } while ((thisLine = readLine()) != null); Modified: trunk/daimonin/src/daieditor/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/ScriptArchData.java 2006-11-06 21:03:52 UTC (rev 621) +++ trunk/daimonin/src/daieditor/ScriptArchData.java 2006-11-06 21:28:26 UTC (rev 622) @@ -787,12 +787,12 @@ event.setObjName(pluginName); } if (filePath != null && filePath.length() > 0) { - event.addObjectText("race " + filePath + '\n'); + event.addObjectText("race " + filePath); } if (options != null && options.length() > 0) { - event.addObjectText("slaying " + options + '\n'); + event.addObjectText("slaying " + options); } - event.addObjectText("sub_type " + eventType + '\n'); + event.addObjectText("sub_type " + eventType); } } // class ScriptedEvent Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-11-06 21:03:52 UTC (rev 621) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-11-06 21:28:26 UTC (rev 622) @@ -192,7 +192,7 @@ log.log(Level.WARNING, "duplicateAnimation", e); } - arch.addObjectText("animation " + arch.getArchetypeName() + "\n"); + arch.addObjectText("animation " + arch.getArchetypeName()); arch.setAnimName(arch.getArchetypeName()); // here we must add this to AnimationObject @@ -299,12 +299,12 @@ if (thisLine.startsWith("msg")) { msgflag = true; } else if (thisLine.startsWith("animation ")) { - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); final String animName = thisLine.substring(10).trim(); arch.setAnimName(animName); //arch.setAnimNr(mainControl.animationObjects.findAnimObject(animName)); // probably not needed, but better not delete it yet } else if (thisLine.startsWith("anim_speed ")) { - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } else if (thisLine.startsWith("anim")) { animflag = true; animText = new StringBuilder(); @@ -319,14 +319,14 @@ } else if (thisLine.startsWith("x ")) { if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { log.log(Level.WARNING, "foundCoordInDefArchSingleTileOrHead", new Object[]{"x", arch.getArchetypeName()}); - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } else { arch.setMultiX(Integer.parseInt(thisLine.substring(2))); } } else if (thisLine.startsWith("y ")) { if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { log.log(Level.WARNING, "foundCoordInDefArchSingleTileOrHead", new Object[]{"y", arch.getArchetypeName()}); - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } else { arch.setMultiY(Integer.parseInt(thisLine.substring(2))); } @@ -339,7 +339,7 @@ } } catch (final NumberFormatException e) { log.log(Level.WARNING, "defArchWithInvalidTypeNr", new Object[]{arch.getArchetypeName(), thisLine.substring(5)}); - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } } else if (thisLine.startsWith("direction ")) { try { @@ -347,7 +347,7 @@ } catch (final NumberFormatException e) { log.log(Level.WARNING, "defArchWithInvalidDirection", new Object[]{arch.getArchetypeName(), thisLine.substring(10)}); } - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } else if (thisLine.startsWith("face ")) { int x; for (x = 4; x < thisLine.length(); x++) { @@ -356,7 +356,7 @@ } } arch.setFaceRealName(thisLine.substring(x, thisLine.length())); - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } else if (thisLine.startsWith("editor_folder ")) { // the display category (= "folder" the arch belongs to) newCat = thisLine.substring(14).trim(); @@ -373,7 +373,7 @@ } } catch (final NumberFormatException e) { System.err.println("WARNING: Arch " + arch.getArchetypeName() + " has a invalid mpart_id (" + thisLine.substring(9) + ')'); - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } } else if (thisLine.startsWith("mpart_nr ")) { // part nr for multiparts @@ -382,10 +382,10 @@ arch.setMultiPartNr(i); } catch (final NumberFormatException e) { System.err.println("WARNING: Arch " + arch.getArchetypeName() + " has a invalid mpart_nr (" + thisLine.substring(9) + ')'); - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } } else { - arch.addObjectText(thisLine + "\n"); + arch.addObjectText(thisLine); } //System.err.println("add String: "+thisLine); } @@ -412,19 +412,19 @@ if (text.charAt(i) == '\n') { if (i - s > 0) { if (scriptflag) { - arch.addObjectText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i)); if (text.regionMatches(s, "end_script_", 0, 11)) { scriptflag = false; } } else if (text.regionMatches(s, "start_script_", 0, 13)) { - arch.addObjectText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i)); scriptflag = true; } else if (text.regionMatches(s, "editable ", 0, 9)) { arch.setEditType(Integer.parseInt(text.substring(s + 9, i))); } else if (text.regionMatches(s, "name ", 0, 5)) { arch.setObjName(text.substring(s + 5, i)); } else { - arch.addObjectText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i)); } } @@ -456,12 +456,12 @@ if (i - s > 0) { if (text.regionMatches(s, "animation ", 0, 9)) { gameObject.setAnimName(text.substring(s + 10, i)); - gameObject.addObjectText(text.substring(s, i) + "\n"); + gameObject.addObjectText(text.substring(s, i)); } else if (text.regionMatches(s, "name ", 0, 5)) { gameObject.setObjName(text.substring(s + 5, i)); } else { // this is an unparsed arch attribute, it has to stay in the archtext - gameObject.addObjectText(text.substring(s, i) + "\n"); + gameObject.addObjectText(text.substring(s, i)); } } s = i + 1; Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-06 21:03:52 UTC (rev 621) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-06 21:28:26 UTC (rev 622) @@ -741,10 +741,13 @@ /** * Append <var>text</var> to the object text of this GameObject. - * @param text text to add + * @param line A line of text to append, may contain '\n' for appending multiple lines. */ - public void addObjectText(final String text) { - objectText.append(text); + public final void addObjectText(final String line) { + objectText.append(line); + if (!line.endsWith("\n")) { + objectText.append('\n'); + } } /** Clears the object text of this GameObject. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-06 21:04:05
|
Revision: 621 http://svn.sourceforge.net/gridarta/?rev=621&view=rev Author: christianhujer Date: 2006-11-06 13:03:52 -0800 (Mon, 06 Nov 2006) Log Message: ----------- Cosmetic: Added missing blank line. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-06 00:06:19 UTC (rev 620) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-06 21:03:52 UTC (rev 621) @@ -609,6 +609,7 @@ @Nullable public String getMsgText() { return msgText != null ? msgText.toString() : null; } + /** * Get the X coordinate of this GameObject on its map. * This method only guarantees a reasonable value for GameObjects that are directly bound to a map (i.e. {@link #getTopContainer()} returns <code>null</code>). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-06 00:07:38
|
Revision: 620 http://svn.sourceforge.net/gridarta/?rev=620&view=rev Author: christianhujer Date: 2006-11-05 16:06:19 -0800 (Sun, 05 Nov 2006) Log Message: ----------- Optimized imports. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/MultiPositionData.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/CAttribDialog.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapArchPanel.java trunk/daimonin/src/daieditor/CMapFileEncode.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/MultiPositionData.java trunk/daimonin/src/daieditor/ReplaceDialog.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gui/ConnectionView.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java trunk/daimonin/src/daieditor/map/validation/SquareValidationError.java trunk/daimonin/src/daieditor/map/validation/SquareValidator.java trunk/daimonin/src/daieditor/map/validation/ValidationError.java trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareChecker.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyChecker.java trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointChecker.java trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointError.java trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SlayingError.java trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorError.java trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroError.java trunk/daimonin/src/daieditor/map/validation/checks/TilePathsChecker.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/UndoAndRedo.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java trunk/src/app/net/sf/gridarta/io/IOUtils.java trunk/src/app/net/sf/gridarta/io/MapFileDecode.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java trunk/src/app/net/sf/gridarta/map/MapArchObject.java trunk/src/app/net/sf/gridarta/map/MapModelEvent.java trunk/src/app/net/sf/gridarta/map/MapSquare.java trunk/src/app/net/sf/gridarta/textedit/scripteditor/CFPythonPopup.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2006-11-06 00:06:19 UTC (rev 620) @@ -28,11 +28,11 @@ import cfeditor.gameobject.GameObject; import cfeditor.map.MapModel; import java.awt.Point; +import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.BufferedReader; +import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.io.IOUtils; -import net.sf.gridarta.gameobject.Archetype; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-11-06 00:06:19 UTC (rev 620) @@ -67,8 +67,8 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; +import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.help.Help; -import net.sf.gridarta.gameobject.Archetype; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; Modified: trunk/crossfire/src/cfeditor/MultiPositionData.java =================================================================== --- trunk/crossfire/src/cfeditor/MultiPositionData.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/crossfire/src/cfeditor/MultiPositionData.java 2006-11-06 00:06:19 UTC (rev 620) @@ -24,10 +24,10 @@ package cfeditor; +import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.BufferedReader; import java.util.StringTokenizer; import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-06 00:06:19 UTC (rev 620) @@ -35,8 +35,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; -import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import org.apache.log4j.Logger; import org.jdom.DataConversionException; import org.jdom.Document; Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-11-06 00:06:19 UTC (rev 620) @@ -31,8 +31,8 @@ import cfeditor.CMainStatusbar; import cfeditor.CPickmapPanel; import cfeditor.CSettings; +import cfeditor.IGUIConstants; import cfeditor.gameobject.face.FaceObject; -import cfeditor.IGUIConstants; import java.awt.Color; import java.awt.GridLayout; import java.io.BufferedOutputStream; @@ -46,10 +46,10 @@ import java.io.IOException; import java.io.InputStream; import java.util.Arrays; +import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.Map; -import java.util.Collection; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JDialog; @@ -57,10 +57,10 @@ import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.SwingConstants; -import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; +import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-06 00:06:19 UTC (rev 620) @@ -36,7 +36,6 @@ import java.util.List; import net.sf.gridarta.Size2D; import net.sf.gridarta.map.AbstractMapModel; -import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/daimonin/src/daieditor/CAttribDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CAttribDialog.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/CAttribDialog.java 2006-11-06 00:06:19 UTC (rev 620) @@ -94,8 +94,8 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; +import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.help.Help; -import net.sf.gridarta.gameobject.Archetype; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; import static net.sf.japi.util.Arrays2.linearSearch; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-11-06 00:06:19 UTC (rev 620) @@ -51,16 +51,15 @@ import daieditor.map.MapArchObject; import daieditor.map.MapControl; import daieditor.map.MapModel; -import net.sf.gridarta.map.MapModelEvent; -import net.sf.gridarta.map.MapModelListener; import daieditor.map.validation.DefaultErrorCollector; import daieditor.map.validation.DelegatingMapValidator; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.checks.BlockedMobOrSpawnPointChecker; +import daieditor.map.validation.checks.BlockedSquareChecker; import daieditor.map.validation.checks.ConnectedInsideContainerChecker; import daieditor.map.validation.checks.ConnectedPickableChecker; +import daieditor.map.validation.checks.DoubleLayerChecker; import daieditor.map.validation.checks.DoubleTypeChecker; -import daieditor.map.validation.checks.DoubleLayerChecker; import daieditor.map.validation.checks.EmptySpawnPointChecker; import daieditor.map.validation.checks.ExitChecker; import daieditor.map.validation.checks.MapDifficultyChecker; @@ -69,7 +68,6 @@ import daieditor.map.validation.checks.SquareWithoutFloorChecker; import daieditor.map.validation.checks.SysObjectOnLayerZeroChecker; import daieditor.map.validation.checks.TilePathsChecker; -import daieditor.map.validation.checks.BlockedSquareChecker; import java.awt.Image; import java.awt.Point; import java.awt.Toolkit; @@ -114,8 +112,10 @@ import javax.swing.filechooser.FileFilter; import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.HideFileFilterProxy; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; +import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.map.MapType; -import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; Modified: trunk/daimonin/src/daieditor/CMapArchPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-11-06 00:06:19 UTC (rev 620) @@ -69,8 +69,8 @@ import javax.swing.text.StyleContext; import net.sf.gridarta.gui.GSplitPane; import net.sf.japi.swing.ActionFactory; +import static net.sf.japi.swing.ActionFactory.getFactory; import net.sf.japi.swing.ActionMethod; -import static net.sf.japi.swing.ActionFactory.getFactory; /** * <code>CMapArchPanel</code> implements the panel that holds information about Modified: trunk/daimonin/src/daieditor/CMapFileEncode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileEncode.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/CMapFileEncode.java 2006-11-06 00:06:19 UTC (rev 620) @@ -34,8 +34,8 @@ import java.util.Formatter; import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; /** Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-11-06 00:06:19 UTC (rev 620) @@ -29,8 +29,6 @@ import daieditor.gui.map.MapUserListener; import daieditor.map.MapControl; import daieditor.map.MapModel; -import net.sf.gridarta.map.MapModelEvent; -import net.sf.gridarta.map.MapModelListener; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.ErrorHandler; import daieditor.map.validation.ValidationError; @@ -49,12 +47,14 @@ import javax.swing.JScrollPane; import javax.swing.JViewport; import net.sf.gridarta.Size2D; -import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.gui.MapView; 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.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; +import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; Modified: trunk/daimonin/src/daieditor/MultiPositionData.java =================================================================== --- trunk/daimonin/src/daieditor/MultiPositionData.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/MultiPositionData.java 2006-11-06 00:06:19 UTC (rev 620) @@ -26,10 +26,10 @@ import java.awt.Dimension; import java.awt.Point; +import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.BufferedReader; import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; Modified: trunk/daimonin/src/daieditor/ReplaceDialog.java =================================================================== --- trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-11-06 00:06:19 UTC (rev 620) @@ -44,9 +44,9 @@ import javax.swing.JPanel; import javax.swing.JTextField; import static javax.swing.WindowConstants.HIDE_ON_CLOSE; +import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; -import net.sf.gridarta.map.MapSquare; /** * This dialog manages the replace action. Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-11-06 00:06:19 UTC (rev 620) @@ -29,7 +29,6 @@ import daieditor.IGUIConstants; import daieditor.MultiPositionData; import daieditor.PathManager; -import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; @@ -40,6 +39,7 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import org.jetbrains.annotations.Nullable; /** Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-11-06 00:06:19 UTC (rev 620) @@ -32,8 +32,6 @@ import daieditor.IGUIConstants; import daieditor.gameobject.anim.AnimationObject; import daieditor.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.anim.AnimationParseException; -import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import daieditor.gameobject.face.DuplicateFaceException; import daieditor.gameobject.face.FaceFacade; import daieditor.gameobject.face.FaceObject; @@ -58,8 +56,10 @@ import java.util.List; import java.util.Map; import javax.swing.ImageIcon; +import net.sf.gridarta.gameobject.AbstractArchetypeSet; +import net.sf.gridarta.gameobject.anim.AnimationParseException; +import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; -import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; import net.sf.japi.swing.Progress; Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-11-06 00:06:19 UTC (rev 620) @@ -36,9 +36,9 @@ import java.io.Reader; import java.util.HashMap; import java.util.Map; +import net.sf.gridarta.gameobject.anim.AnimationParseException; +import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; -import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; -import net.sf.gridarta.gameobject.anim.AnimationParseException; import org.jetbrains.annotations.Nullable; Modified: trunk/daimonin/src/daieditor/gui/ConnectionView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ConnectionView.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/gui/ConnectionView.java 2006-11-06 00:06:19 UTC (rev 620) @@ -21,8 +21,6 @@ package daieditor.gui; -import net.sf.gridarta.map.MapModelEvent; -import net.sf.gridarta.map.MapModelListener; import java.awt.BorderLayout; import java.util.ArrayList; import java.util.HashMap; @@ -31,10 +29,12 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.gameobject.GameObject; /** * A Panel that holds information about the connections of the selected arch on the selected map. Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-11-06 00:06:19 UTC (rev 620) @@ -44,10 +44,10 @@ import java.util.Map; import javax.swing.ImageIcon; import net.sf.gridarta.Size2D; -import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.MapGridEvent; import net.sf.gridarta.gui.map.MapGridListener; +import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-11-06 00:06:19 UTC (rev 620) @@ -46,11 +46,11 @@ import javax.imageio.ImageIO; import javax.swing.ImageIcon; import net.sf.gridarta.Size2D; -import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; -import net.sf.gridarta.gui.map.MapCursor; -import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; import org.jetbrains.annotations.Nullable; Modified: trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java 2006-11-06 00:06:19 UTC (rev 620) @@ -24,10 +24,10 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.gameobject.GameObject; /** * A Map Validator that delegates to other MapValidators. Modified: trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -24,8 +24,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.gameobject.GameObject; /** * Class for validation errors related to more than a single GameObject. Modified: trunk/daimonin/src/daieditor/map/validation/SquareValidationError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/SquareValidationError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/SquareValidationError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -24,8 +24,8 @@ package daieditor.map.validation; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.gameobject.GameObject; /** * Class for validation errors on a MapSquare. Modified: trunk/daimonin/src/daieditor/map/validation/SquareValidator.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/SquareValidator.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/SquareValidator.java 2006-11-06 00:06:19 UTC (rev 620) @@ -21,8 +21,8 @@ package daieditor.map.validation; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.gameobject.GameObject; /** * Interface for Square Validators. Modified: trunk/daimonin/src/daieditor/map/validation/ValidationError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/ValidationError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/ValidationError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -24,11 +24,11 @@ package daieditor.map.validation; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; -import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.gameobject.GameObject; import org.jetbrains.annotations.Nullable; /** Modified: trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -26,8 +26,8 @@ import daieditor.map.validation.SquareValidator; import java.util.ArrayList; import java.util.List; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.gameobject.GameObject; /** * A SquareValidator to assert that mobs or spawn points aren't on blocked squares. Modified: trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -24,8 +24,8 @@ import daieditor.map.validation.CorrectableError; import daieditor.map.validation.SquareValidationError; import java.awt.Component; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.gameobject.GameObject; /** * Validation error that's used when the BlockedMobOrSpawnPointChecker detected a possible error on the map. Modified: trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -29,8 +29,8 @@ import java.util.List; import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.map.MapModel; /** * A SquareValidator to assert that a square that's blocked and nopass is not surrounded by blocked and nopass only. Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -22,8 +22,8 @@ package daieditor.map.validation.checks; import daieditor.map.validation.AbstractValidator; +import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.GameObjectValidator; -import daieditor.map.validation.ErrorCollector; import net.sf.gridarta.gameobject.GameObject; /** Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -21,8 +21,8 @@ package daieditor.map.validation.checks; +import daieditor.map.validation.CorrectableError; import daieditor.map.validation.GameObjectValidationError; -import daieditor.map.validation.CorrectableError; import java.awt.Component; import net.sf.gridarta.gameobject.GameObject; Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -22,8 +22,8 @@ package daieditor.map.validation.checks; import daieditor.map.validation.AbstractValidator; +import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.GameObjectValidator; -import daieditor.map.validation.ErrorCollector; import net.sf.gridarta.gameobject.GameObject; /** Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -21,8 +21,8 @@ package daieditor.map.validation.checks; +import daieditor.map.validation.CorrectableError; import daieditor.map.validation.GameObjectValidationError; -import daieditor.map.validation.CorrectableError; import java.awt.Component; import net.sf.gridarta.gameobject.GameObject; Modified: trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -22,13 +22,13 @@ package daieditor.map.validation.checks; import daieditor.map.validation.AbstractValidator; +import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.GameObjectsValidationError; -import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.SquareValidator; import java.util.HashMap; import java.util.Map; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.gameobject.GameObject; /** * A SquareValidator to assert that there are no two objects within the same layer. Modified: trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -21,11 +21,11 @@ package daieditor.map.validation.checks; +import daieditor.map.validation.CorrectableError; import daieditor.map.validation.GameObjectsValidationError; -import daieditor.map.validation.CorrectableError; import java.awt.Component; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.gameobject.GameObject; /** * Validation error that's used when the DoubleLayerChecker detected a possible error on the map. Modified: trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -22,13 +22,13 @@ package daieditor.map.validation.checks; import daieditor.map.validation.AbstractValidator; +import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.GameObjectsValidationError; -import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.SquareValidator; import java.util.HashMap; import java.util.Map; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.gameobject.GameObject; /** * A SquareValidator to assert that there are no two arches of the same type on the same square. Modified: trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -21,11 +21,11 @@ package daieditor.map.validation.checks; +import daieditor.map.validation.CorrectableError; import daieditor.map.validation.GameObjectsValidationError; -import daieditor.map.validation.CorrectableError; import java.awt.Component; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.gameobject.GameObject; /** * Validation error that's used when the DoubleTypeChecker detected a possible error on the map. Modified: trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -22,8 +22,8 @@ package daieditor.map.validation.checks; import daieditor.map.validation.AbstractValidator; +import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.GameObjectValidator; -import daieditor.map.validation.ErrorCollector; import net.sf.gridarta.gameobject.GameObject; /** Modified: trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -21,8 +21,8 @@ package daieditor.map.validation.checks; +import daieditor.map.validation.CorrectableError; import daieditor.map.validation.GameObjectValidationError; -import daieditor.map.validation.CorrectableError; import java.awt.Component; import net.sf.gridarta.gameobject.GameObject; Modified: trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -1,13 +1,13 @@ package daieditor.map.validation.checks; import daieditor.CMainControl; +import daieditor.map.MapModel; import daieditor.map.validation.AbstractValidator; +import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.GameObjectValidator; -import daieditor.map.validation.ErrorCollector; -import daieditor.map.MapModel; import java.io.File; +import net.sf.gridarta.gameobject.GameObject; import org.jetbrains.annotations.NotNull; -import net.sf.gridarta.gameobject.GameObject; /** * A Validator to assert that exits are connected to maps properly. Modified: trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -3,8 +3,8 @@ import daieditor.map.validation.AbstractValidator; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.MapValidator; +import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapArchObject; /** * Validator that checks whether the map has a valid difficulty. Modified: trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -22,8 +22,8 @@ package daieditor.map.validation.checks; import daieditor.map.validation.AbstractValidator; +import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.GameObjectValidator; -import daieditor.map.validation.ErrorCollector; import net.sf.gridarta.gameobject.GameObject; /** Modified: trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -21,8 +21,8 @@ package daieditor.map.validation.checks; +import daieditor.map.validation.CorrectableError; import daieditor.map.validation.GameObjectValidationError; -import daieditor.map.validation.CorrectableError; import java.awt.Component; import net.sf.gridarta.gameobject.GameObject; Modified: trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -22,8 +22,8 @@ package daieditor.map.validation.checks; import daieditor.map.validation.AbstractValidator; +import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.GameObjectValidator; -import daieditor.map.validation.ErrorCollector; import net.sf.gridarta.gameobject.GameObject; /** Modified: trunk/daimonin/src/daieditor/map/validation/checks/SlayingError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/SlayingError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/SlayingError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -21,8 +21,8 @@ package daieditor.map.validation.checks; +import daieditor.map.validation.CorrectableError; import daieditor.map.validation.GameObjectValidationError; -import daieditor.map.validation.CorrectableError; import java.awt.Component; import net.sf.gridarta.gameobject.GameObject; Modified: trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -24,8 +24,8 @@ import daieditor.map.validation.AbstractValidator; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.SquareValidator; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.gameobject.GameObject; /** * A SquareValidator to assert that squares have a floor. Modified: trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -24,8 +24,8 @@ import daieditor.map.validation.CorrectableError; import daieditor.map.validation.SquareValidationError; import java.awt.Component; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.gameobject.GameObject; /** * A MapValidator that checks for mobs outside spawn points. Modified: trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -22,8 +22,8 @@ package daieditor.map.validation.checks; import daieditor.map.validation.AbstractValidator; +import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.GameObjectValidator; -import daieditor.map.validation.ErrorCollector; import net.sf.gridarta.gameobject.GameObject; /** Modified: trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroError.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroError.java 2006-11-06 00:06:19 UTC (rev 620) @@ -21,8 +21,8 @@ package daieditor.map.validation.checks; +import daieditor.map.validation.CorrectableError; import daieditor.map.validation.GameObjectValidationError; -import daieditor.map.validation.CorrectableError; import java.awt.Component; import net.sf.gridarta.gameobject.GameObject; Modified: trunk/daimonin/src/daieditor/map/validation/checks/TilePathsChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/TilePathsChecker.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/daimonin/src/daieditor/map/validation/checks/TilePathsChecker.java 2006-11-06 00:06:19 UTC (rev 620) @@ -2,13 +2,13 @@ import daieditor.CMainControl; import daieditor.IGUIConstants; +import daieditor.map.MapArchObject; import daieditor.map.validation.AbstractValidator; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.MapValidator; -import daieditor.map.MapArchObject; import java.io.File; +import net.sf.gridarta.map.MapModel; import org.jetbrains.annotations.NotNull; -import net.sf.gridarta.map.MapModel; /** * Validator that checks whether all tile paths are valid. Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-11-06 00:06:19 UTC (rev 620) @@ -1,8 +1,8 @@ package net.sf.gridarta; import javax.swing.filechooser.FileFilter; +import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; -import net.sf.gridarta.gameobject.ArchetypeParser; import org.jetbrains.annotations.NotNull; /** Modified: trunk/src/app/net/sf/gridarta/UndoAndRedo.java =================================================================== --- trunk/src/app/net/sf/gridarta/UndoAndRedo.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/UndoAndRedo.java 2006-11-06 00:06:19 UTC (rev 620) @@ -28,12 +28,12 @@ import java.util.List; import java.util.Map; import java.util.WeakHashMap; +import javax.swing.Action; +import net.sf.gridarta.gui.map.MapSelectionEvent; +import net.sf.gridarta.gui.map.MapSelectionListener; import net.sf.gridarta.map.MapControl; -import net.sf.gridarta.gui.map.MapSelectionListener; -import net.sf.gridarta.gui.map.MapSelectionEvent; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; -import javax.swing.Action; /** * The undoAction/redo stack that is used when undoing/redoing operations. Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2006-11-06 00:06:19 UTC (rev 620) @@ -1,9 +1,9 @@ package net.sf.gridarta.gameobject; +import java.util.Collection; +import java.util.Collections; import java.util.Map; import java.util.TreeMap; -import java.util.Collection; -import java.util.Collections; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2006-11-06 00:06:19 UTC (rev 620) @@ -1,8 +1,8 @@ package net.sf.gridarta.gameobject; -import java.util.List; import java.io.BufferedReader; import java.io.IOException; +import java.util.List; import org.jetbrains.annotations.Nullable; /** Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-06 00:06:19 UTC (rev 620) @@ -1,10 +1,10 @@ package net.sf.gridarta.gameobject; +import java.util.HashMap; +import java.util.Map; +import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import net.sf.gridarta.map.MapSquare; -import java.util.HashMap; -import java.util.Map; /** * A GameObject instance reflects a GameObject (object on a map) or an Archetype. Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2006-11-06 00:06:19 UTC (rev 620) @@ -28,9 +28,9 @@ import java.util.Iterator; import java.util.List; import java.util.ListIterator; +import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import net.sf.gridarta.map.MapSquare; /** * Base class for classes that contain GameObjects as children in the sense of containment. Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java 2006-11-06 00:06:19 UTC (rev 620) @@ -26,8 +26,8 @@ import java.awt.Rectangle; import static java.lang.Math.min; import javax.swing.event.EventListenerList; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.NotNull; /** * MapCursor provides methods to move and drag on map. The MapCursor is bound to a Modified: trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java 2006-11-06 00:06:19 UTC (rev 620) @@ -1,16 +1,16 @@ package net.sf.gridarta.io; -import java.io.IOException; import java.io.BufferedReader; +import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; -import java.io.FileNotFoundException; -import java.io.File; +import java.util.ArrayList; import java.util.List; -import java.util.ArrayList; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.gameobject.GameObject; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/src/app/net/sf/gridarta/io/IOUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/IOUtils.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/io/IOUtils.java 2006-11-06 00:06:19 UTC (rev 620) @@ -1,16 +1,16 @@ package net.sf.gridarta.io; -import java.io.Reader; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.EOFException; +import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; +import java.io.Reader; import java.io.UnsupportedEncodingException; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.EOFException; -import java.io.InputStream; -import java.io.FileInputStream; -import java.io.File; -import java.io.BufferedInputStream; import java.net.URI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/src/app/net/sf/gridarta/io/MapFileDecode.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/MapFileDecode.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/io/MapFileDecode.java 2006-11-06 00:06:19 UTC (rev 620) @@ -1,10 +1,10 @@ package net.sf.gridarta.io; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.map.MapArchObject; import java.io.Closeable; import java.io.IOException; import java.util.List; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; /** Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2006-11-06 00:06:19 UTC (rev 620) @@ -1,17 +1,17 @@ package net.sf.gridarta.map; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.Size2D; -import java.util.NoSuchElementException; +import java.awt.Point; +import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.HashSet; -import java.util.ArrayList; +import java.util.NoSuchElementException; import java.util.Set; -import java.awt.Point; +import javax.swing.event.EventListenerList; +import net.sf.gridarta.Size2D; +import net.sf.gridarta.gameobject.GameObject; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.event.EventListenerList; /** * Abstract implementation of {@link MapModel} that covers the similarities between crossfire and daimonin. Modified: trunk/src/app/net/sf/gridarta/map/MapArchObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapArchObject.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/map/MapArchObject.java 2006-11-06 00:06:19 UTC (rev 620) @@ -1,9 +1,9 @@ package net.sf.gridarta.map; +import java.io.BufferedReader; +import java.io.IOException; import net.sf.gridarta.Size2D; import org.jetbrains.annotations.NotNull; -import java.io.BufferedReader; -import java.io.IOException; /** * Interface for MapArchObjects. Modified: trunk/src/app/net/sf/gridarta/map/MapModelEvent.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModelEvent.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/map/MapModelEvent.java 2006-11-06 00:06:19 UTC (rev 620) @@ -27,9 +27,9 @@ package net.sf.gridarta.map; import java.util.EventObject; +import net.sf.gridarta.gameobject.GameObject; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.NotNull; -import net.sf.gridarta.gameobject.GameObject; /** * Class for Map events. Modified: trunk/src/app/net/sf/gridarta/map/MapSquare.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapSquare.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/map/MapSquare.java 2006-11-06 00:06:19 UTC (rev 620) @@ -24,8 +24,8 @@ package net.sf.gridarta.map; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.GameObjectContainer; -import net.sf.gridarta.gameobject.GameObject; import org.jetbrains.annotations.NotNull; /** Modified: trunk/src/app/net/sf/gridarta/textedit/scripteditor/CFPythonPopup.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/scripteditor/CFPythonPopup.java 2006-11-05 23:56:52 UTC (rev 619) +++ trunk/src/app/net/sf/gridarta/textedit/scripteditor/CFPythonPopup.java 2006-11-06 00:06:19 UTC (rev 620) @@ -27,10 +27,10 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.BufferedReader; import java.io.EOFException; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.BufferedReader; import static java.lang.String.CASE_INSENSITIVE_ORDER; import java.util.ArrayList; import static java.util.Collections.sort; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-05 23:57:03
|
Revision: 619 http://svn.sourceforge.net/gridarta/?rev=619&view=rev Author: christianhujer Date: 2006-11-05 15:56:52 -0800 (Sun, 05 Nov 2006) Log Message: ----------- More CMapFileDecode unification by removing anim ... mina support from Crossfire. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/daimonin/src/daieditor/CMapFileDecode.java Modified: trunk/crossfire/src/cfeditor/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-11-05 23:52:49 UTC (rev 618) +++ trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-11-05 23:56:52 UTC (rev 619) @@ -101,7 +101,6 @@ * @throws IOException when an I/O-error occured during file reading * @fixme I'm too long, make me shorter. * @todo Attributes not relevant during map parsing shouldn't be evaluated here, but in GameObject / ArchetypeParser instead. - * @todo Find out whether anim...mina is still used (loader.l seems not to use it), and if not, remove it. * @todo Convince crossfire people of removing "More" as it seems to be pointless now. * @todo Find out whether effectively also trimming msg contents didn't break anything. */ @@ -110,7 +109,6 @@ boolean msgflag = false; boolean archflag = false; boolean archmore = false; - boolean animflag = false; GameObject gameObject = null; do { thisLine = thisLine.trim(); @@ -135,19 +133,12 @@ if (thisLine.startsWith("endmsg")) { msgflag = false; } else { - gameObject.addMsgText(thisLine + "\n"); + gameObject.addMsgText(thisLine + '\n'); } - } else if (animflag) { - //gameObject.addArchText(thisLine + "\n"); - if (thisLine.startsWith("mina")) { - animflag = false; - } else { // we not include anim yet in panel - gameObject.addAnimText(thisLine + "\n"); - } + } else if (thisLine.startsWith("arch ")) { // ok, we had a full arch... don't care here about map or object // now we test for a new arch - thats stuf in inventory // or the end... thats the end of this shit - } else if (thisLine.startsWith("arch ")) { if (log.isDebugEnabled()) { log.debug("GO INVENTORY: " + gameObject + " - " + thisLine); } @@ -175,9 +166,6 @@ gameObject.addObjectText(thisLine + "\n"); } else if (thisLine.startsWith("anim_speed")) { gameObject.addObjectText(thisLine + "\n"); - } else if (thisLine.startsWith("anim")) { - //gameObject.addArchText(thisLine + "\n"); - animflag = true; } else if (thisLine.startsWith("event_")) { // here's something about a scripted event final int i = thisLine.indexOf("_plugin"); Modified: trunk/daimonin/src/daieditor/CMapFileDecode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-11-05 23:52:49 UTC (rev 618) +++ trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-11-05 23:56:52 UTC (rev 619) @@ -135,7 +135,6 @@ log.debug("GO INVENTORY2: " + gameObject + " - " + thisLine); } } else if (thisLine.equals("end")) { - // chain this to temp list objects.add(gameObject); archflag = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-05 23:52:55
|
Revision: 618 http://svn.sourceforge.net/gridarta/?rev=618&view=rev Author: christianhujer Date: 2006-11-05 15:52:49 -0800 (Sun, 05 Nov 2006) Log Message: ----------- Added TODO comment. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapFileEncode.java Modified: trunk/crossfire/src/cfeditor/CMapFileEncode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-11-05 23:49:57 UTC (rev 617) +++ trunk/crossfire/src/cfeditor/CMapFileEncode.java 2006-11-05 23:52:49 UTC (rev 618) @@ -308,6 +308,7 @@ /* * Initialize {@link keys} array. + * @todo this information should be read from a file. */ static { addKey("name"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-05 23:50:29
|
Revision: 617 http://svn.sourceforge.net/gridarta/?rev=617&view=rev Author: christianhujer Date: 2006-11-05 15:49:57 -0800 (Sun, 05 Nov 2006) Log Message: ----------- Refactored CMapFileDecode to use the same I/O pattern as found in Java. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/crossfire/src/cfeditor/CPickmapPanel.java trunk/crossfire/src/cfeditor/map/MapArchObject.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapFileDecode.java trunk/daimonin/src/daieditor/CPickmapPanel.java trunk/src/app/net/sf/gridarta/map/MapArchObject.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java trunk/src/app/net/sf/gridarta/io/MapFileDecode.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-05 17:42:34 UTC (rev 616) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-05 23:49:57 UTC (rev 617) @@ -109,8 +109,6 @@ /** Bit field of edit types to show only. */ private int tileEdit; - private CMapFileDecode mapFileDecoder; - private CMapFileEncode mapFileEncoder; private ArchetypeParser archetypeParser; @@ -240,7 +238,6 @@ } // attach map encoder and decoder - mapFileDecoder = new CMapFileDecode(); mapFileEncoder = new CMapFileEncode(this); // our global object parser @@ -880,8 +877,9 @@ final List<GameObject> objects; final MapArchObject maparch; try { - objects = mapFileDecoder.decodeMapFile(file); // parse mapfile - maparch = mapFileDecoder.getMapArch(); // get map arch + final CMapFileDecode decoder = new CMapFileDecode(file); + objects = decoder.decodeMapFile(); // parse mapfile + maparch = decoder.getMapArch(); // get map arch } catch (final IOException e) { // popup display showMessage("Couldn't load Map", e.getMessage()); @@ -1752,10 +1750,6 @@ return joinList; } - public CMapFileDecode getMapFileDecoder() { - return mapFileDecoder; - } - /** * Extract a parameter value for an exit to a random map. * Modified: trunk/crossfire/src/cfeditor/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-11-05 17:42:34 UTC (rev 616) +++ trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-11-05 23:49:57 UTC (rev 617) @@ -26,75 +26,62 @@ import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; -import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; import java.util.List; -import net.sf.gridarta.io.IOUtils; +import net.sf.gridarta.io.AbstractMapFileDecode; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** + * A MapFileDecoder reads a map file and provides access to the information read from the map file. * This class handles the reading of a mapfile and parsing the data * into a list of ArchObjects. * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo change to classical IO class style */ -public final class CMapFileDecode { +public final class CMapFileDecode extends AbstractMapFileDecode<GameObject, MapArchObject> { private static final Logger log = Logger.getLogger(CMapFileDecode.class); private int maxxlen, maxylen; - /** ArchObjects that are read from the map. */ - private List<GameObject> objects; + /** + * Open a resource for reading it as a map. + * @param uri URI of resource to open. + * @throws FileNotFoundException in case the resource was not found. + */ + public CMapFileDecode(final String uri) throws FileNotFoundException { + super(uri); + } - /** Contains the map arch (see MapArchObject class). */ - private MapArchObject maparch; - - public CMapFileDecode() { + /** + * Open a file for reading it as a map. + * @param file File to open. + * @throws FileNotFoundException in case the file was not found. + */ + public CMapFileDecode(final File file) throws FileNotFoundException { + super(file); } - public MapArchObject getMapArch() { - return maparch; + /** {@inheritDoc} */ + protected MapArchObject createMapArchObject() { + return new MapArchObject(); } /** - * Loading a Crossfire map from the given mapfile. - * This method returns a list of arches, connected with the temp pointers. - * @param file mapfile + * Loading a map from the given mapfile. + * This method returns a list of GameObjects. * @return first <code>GameObject</code> in the list * @throws FileNotFoundException in case the requested map file was not found * @throws IOException in case the file couldn't be read or is in wrong format * @todo create a separate exception for the wrong format */ - public List<GameObject> decodeMapFile(final File file) throws FileNotFoundException, IOException { - final BufferedReader myInput = new BufferedReader(new InputStreamReader(new FileInputStream(file), IOUtils.MAP_ENCODING)); - try { - maxxlen = 0; - maxylen = 0; - objects = new ArrayList<GameObject>(); - - // first of all we read the map arch (if that fails we throw an exception) - maparch = new MapArchObject(); - if (!maparch.parseMapArch(myInput, file.getName())) { - throw new IOException("The file '" + file.getName() + "' does not contain a valid Crossfire map format!\n"); - } - //maparch.setName(file.getName()); - - // now we read all the ArchObjects - for (String thisLine; (thisLine = myInput.readLine()) != null;) { - readArch(myInput, thisLine, null); // all these are map arches - } - } finally { - myInput.close(); - } + @NotNull public List<GameObject> decodeMapFile() throws IOException { + final List<GameObject> objects = super.decodeMapFile(); // finally... here we go // last action: if the map is bigger than the specified size in // the maparch, we set the true size: the maxxlen/maxylen counters. @@ -103,182 +90,150 @@ return objects; // return first arch of the list } - /** * Our recursive accessible arch reader. * <p/> * WARNING: this implementation should fail with multi head settings * if there are multi part items in the inventory (but this is not yet * included in CF!) - * @param myInput input filestream * @param thisLine first line of text, belonging to this new arch - * @param container container arch that contains this new arch - if any * @return the new parsed <code>GameObject</code> * @throws IOException when an I/O-error occured during file reading + * @fixme I'm too long, make me shorter. + * @todo Attributes not relevant during map parsing shouldn't be evaluated here, but in GameObject / ArchetypeParser instead. + * @todo Find out whether anim...mina is still used (loader.l seems not to use it), and if not, remove it. + * @todo Convince crossfire people of removing "More" as it seems to be pointless now. + * @todo Find out whether effectively also trimming msg contents didn't break anything. */ - @Nullable private GameObject readArch(final BufferedReader myInput, String thisLine, final GameObject container) - throws IOException { - GameObject gameObject; - String thisLine2; - boolean archflag, archmore, msgflag, animflag; + // Note for programmers from Daimonin: Crossfire still has to support "More" which was used for multipart objects in the past. + @Nullable protected GameObject readArch(String thisLine) throws IOException { + boolean msgflag = false; + boolean archflag = false; + boolean archmore = false; + boolean animflag = false; + GameObject gameObject = null; + do { + thisLine = thisLine.trim(); - archflag = false; - archmore = false; + if (!archflag) { + if (thisLine.startsWith("More")) { + // All arches started with "More" are ignored. We load only + // the heads and expand them according to the defaults. + archmore = true; + } else // format violation for better diff + if (thisLine.startsWith("arch ")) { + archflag = true; // from now on we are inside an arch - msgflag = false; - animflag = false; + if (!archmore) { + gameObject = new GameObject(); // create a new instance + gameObject.setArchetypeName(thisLine.substring(5).trim()); + } + } + } else if (!archmore) { + // here we are inside of an arch object (but not "More")... + if (msgflag) { + if (thisLine.startsWith("endmsg")) { + msgflag = false; + } else { + gameObject.addMsgText(thisLine + "\n"); + } + } else if (animflag) { + //gameObject.addArchText(thisLine + "\n"); + if (thisLine.startsWith("mina")) { + animflag = false; + } else { // we not include anim yet in panel + gameObject.addAnimText(thisLine + "\n"); + } + // ok, we had a full arch... don't care here about map or object + // now we test for a new arch - thats stuf in inventory + // or the end... thats the end of this shit + } else if (thisLine.startsWith("arch ")) { + if (log.isDebugEnabled()) { + log.debug("GO INVENTORY: " + gameObject + " - " + thisLine); + } + gameObject.addLast(readArch(thisLine)); + if (log.isDebugEnabled()) { + log.debug("GO INVENTORY2: " + gameObject + " - " + thisLine); + } + } else if (thisLine.equals("end")) { + objects.add(gameObject); + archflag = false; + archmore = false; - gameObject = null; - - try { - thisLine2 = thisLine; - // read the whole file, line by line - while (thisLine2 != null) { - - if (thisLine2.length() > 0) { - // remove whitespace at both ends - thisLine = thisLine2.trim(); - - if (!archflag) { - if (thisLine.startsWith("More")) { - // All arches started with "More" are ignored. We load only - // the heads and expand them according to the defaults. - archmore = true; - } else if (thisLine.startsWith("arch ")) { - // kill white spaces afer arch... - // (hm, no command for this in java?) - int x; - for (x = 5; x < thisLine.length(); x++) { - if (thisLine.charAt(x) != ' ') { - break; - } - } - - archflag = true; // from now on we are inside an arch - - if (!archmore) { - gameObject = new GameObject(); // create a new instance - - // our arch! it has a name! - gameObject.setArchetypeName(thisLine.substring(x, thisLine.length())); - - // ok, we have setup our arch, now check for inventory - if (container != null) { - container.addLast(gameObject); - } - } - } - } else if (!archmore) { - // here were are inside of an arch object (but not "More")... - if (msgflag) { - if (thisLine.startsWith("endmsg")) { - msgflag = false; - } else { - gameObject.addMsgText(thisLine2 + "\n"); - } - } else if (animflag) { - //gameObject.addArchText(thisLine + "\n"); - if (thisLine.startsWith("mina")) { - animflag = false; - } else { // we not include anim yet in panel - gameObject.addAnimText(thisLine + "\n"); - } - // ok, we had a full arch... don't care here about map or object - // now we test for a new arch - thats stuf in inventory - // or the end... thats the end of this shit - } else if (thisLine.startsWith("arch ")) { - if (log.isDebugEnabled()) { - log.debug("GO INVENTORY: " + gameObject + " - " + thisLine); - } - readArch(myInput, thisLine, gameObject); - if (log.isDebugEnabled()) { - log.debug("GO INVENTORY2: " + gameObject + " - " + thisLine); - } - } else if (thisLine.startsWith("end")) { - objects.add(gameObject); - archflag = false; - archmore = false; - - if (log.isDebugEnabled()) { - log.debug("LEAVE!: " + gameObject + " - " + thisLine); - } - return gameObject; - } else if (thisLine.startsWith("msg")) { - // gameObject.addArchText(thisLine + "\n"); - gameObject.addMsgText(""); // this init the msg text buffer - // in the case of msg/endmsg - // with no content to overrule def msg - msgflag = true; - // this is a MUST, because we overrule "anim" test - } else if (thisLine.startsWith("animation")) { - gameObject.addObjectText(thisLine + "\n"); - } else if (thisLine.startsWith("anim_speed")) { - gameObject.addObjectText(thisLine + "\n"); - } else if (thisLine.startsWith("anim")) { - //gameObject.addArchText(thisLine + "\n"); - animflag = true; - } else if (thisLine.startsWith("event_")) { - // here's something about a scripted event - final int i = thisLine.indexOf("_plugin"); - final int k = thisLine.indexOf("_options"); - final int space = thisLine.indexOf(" "); - if (space > 0) { - if (i > 0) { - // expecting: "event_type_plugin Name" - final String type = thisLine.substring(6, i); - final String plname = thisLine.substring(space + 1).trim(); - gameObject.addEventPlugin(type, plname); - } else if (k > 0) { - // expecting: "event_type_options Name" - final String type = thisLine.substring(6, k); - final String eventopt = thisLine.substring(space + 1).trim(); - gameObject.addEventOptions(type, eventopt); - } else { - // expecting: "event_type filepath" - final String type = thisLine.substring(6, space); - final String path = thisLine.substring(space + 1).trim(); - gameObject.addEventScript(type, path); - } - } else { - log.warn("Arch " + gameObject.getArchetypeName() + " has incorrect event code '" + thisLine + "'"); - gameObject.addObjectText(thisLine + "\n"); // keep line, it might have a meaning after all - } - } else if (thisLine.startsWith("x ")) { - final int temp = Integer.parseInt(thisLine.substring(2)); - if (temp > maxxlen) { - maxxlen = temp; - } - gameObject.setMapX(temp); - } else if (thisLine.startsWith("y ")) { - final int temp = Integer.parseInt(thisLine.substring(2)); - if (temp > maxylen) { - maxylen = temp; - } - gameObject.setMapY(temp); - // MT: there should be here no type or? - AV: WRONG, there defenitly should be! - } else if (thisLine.startsWith("type ")) { - gameObject.setArchTypNr(Integer.parseInt(thisLine.substring(5))); - // don't load it into the archtext! - } else if (thisLine.startsWith("face ")) { - gameObject.setFaceFlag(false); - gameObject.setFaceName(thisLine.substring(5).trim()); + if (log.isDebugEnabled()) { + log.debug("LEAVE!: " + gameObject + " - " + thisLine); + } + return gameObject; + } else if (thisLine.startsWith("msg")) { + // gameObject.addArchText(thisLine + "\n"); + gameObject.addMsgText(""); // this init the msg text buffer + // in the case of msg/endmsg + // with no content to overrule def msg + msgflag = true; + // this is a MUST, because we overrule "anim" test + } else if (thisLine.startsWith("animation")) { + gameObject.addObjectText(thisLine + "\n"); + } else if (thisLine.startsWith("anim_speed")) { + gameObject.addObjectText(thisLine + "\n"); + } else if (thisLine.startsWith("anim")) { + //gameObject.addArchText(thisLine + "\n"); + animflag = true; + } else if (thisLine.startsWith("event_")) { + // here's something about a scripted event + final int i = thisLine.indexOf("_plugin"); + final int k = thisLine.indexOf("_options"); + final int space = thisLine.indexOf(" "); + if (space > 0) { + if (i > 0) { + // expecting: "event_type_plugin Name" + final String type = thisLine.substring(6, i); + final String plname = thisLine.substring(space + 1).trim(); + gameObject.addEventPlugin(type, plname); + } else if (k > 0) { + // expecting: "event_type_options Name" + final String type = thisLine.substring(6, k); + final String eventopt = thisLine.substring(space + 1).trim(); + gameObject.addEventOptions(type, eventopt); } else { - gameObject.addObjectText(thisLine + "\n"); + // expecting: "event_type filepath" + final String type = thisLine.substring(6, space); + final String path = thisLine.substring(space + 1).trim(); + gameObject.addEventScript(type, path); } } else { - // We are in a multipart tail arch ("more"), so we skip it: - if (thisLine.regionMatches(0, "end", 0, 3)) { - archflag = false; - archmore = false; - } + log.warn("Arch " + gameObject.getArchetypeName() + " has incorrect event code '" + thisLine + "'"); + gameObject.addObjectText(thisLine + "\n"); // keep line, it might have a meaning after all } + } else if (thisLine.startsWith("x ")) { + final int temp = Integer.parseInt(thisLine.substring(2)); + if (temp > maxxlen) { + maxxlen = temp; + } + gameObject.setMapX(temp); + } else if (thisLine.startsWith("y ")) { + final int temp = Integer.parseInt(thisLine.substring(2)); + if (temp > maxylen) { + maxylen = temp; + } + gameObject.setMapY(temp); + } else if (thisLine.startsWith("type ")) { + // Arches in maps can override their default arch's type + gameObject.setArchTypNr(Integer.parseInt(thisLine.substring(5))); + // don't load it into the archtext! (why?) + } else if (thisLine.startsWith("face ")) { + gameObject.setFaceFlag(false); + gameObject.setFaceName(thisLine.substring(5).trim()); + } else { + gameObject.addObjectText(thisLine + "\n"); } - thisLine2 = myInput.readLine(); + } else { + // We are in a multipart tail arch ("more"), so we skip it: + if (thisLine.regionMatches(0, "end", 0, 3)) { + archflag = false; + archmore = false; + } } - } catch (final IOException e) { - log.error("Read Error while trying to load map: " + maparch.getFileName(), e); - throw e; // we simply pass this exception to the calling function - } + } while ((thisLine = readLine()) != null); return null; // this happens when the file end is reached } Modified: trunk/crossfire/src/cfeditor/CPickmapPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-11-05 17:42:34 UTC (rev 616) +++ trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-11-05 23:49:57 UTC (rev 617) @@ -134,8 +134,9 @@ final MapArchObject maparch; try { - final List<GameObject> objects = mainControl.getMapFileDecoder().decodeMapFile(mapFile); // parse mapfile - maparch = mainControl.getMapFileDecoder().getMapArch(); // get map arch + final CMapFileDecode decoder = new CMapFileDecode(mapFile); + final List<GameObject> objects = decoder.decodeMapFile(); // parse mapfile + maparch = decoder.getMapArch(); // get map arch if (objects == null) { // The map is totally empty Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-11-05 17:42:34 UTC (rev 616) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-11-05 23:49:57 UTC (rev 617) @@ -333,135 +333,130 @@ * @return true if reading the MapArchObject succeeded with sane results, * otherwise false */ - public boolean parseMapArch(final BufferedReader reader, final String fname) { + public boolean parseMapArch(final BufferedReader reader, final String fname) throws IOException { setFileName(fname); String line2; // input line, includes leading and trailing white space boolean loreflag = false; // flag for lore-text boolean archflag = false; // flag for arch<->end int width = 0; int height = 0; - try { - boolean msgflag = false; // flag for map-message - // read lines - boolean endReached = false; - while ((!endReached && (line2 = reader.readLine()) != null)) { - final String line = line2.trim(); + boolean msgflag = false; // flag for map-message + // read lines + boolean endReached = false; + while ((!endReached && (line2 = reader.readLine()) != null)) { + final String line = line2.trim(); - if (archflag) { - // we are inside the map arch - if (msgflag) { - // reading the map message: - if (line.equalsIgnoreCase(TAG_END_TEXT)) { - msgflag = false; - } else { - if (msgText.length() > 0) { - msgText.append("\n"); - } - msgText.append(line2); + if (archflag) { + // we are inside the map arch + if (msgflag) { + // reading the map message: + if (line.equalsIgnoreCase(TAG_END_TEXT)) { + msgflag = false; + } else { + if (msgText.length() > 0) { + msgText.append("\n"); } - } else if (loreflag) { - // reading lore text: - if (line.equalsIgnoreCase(TAG_END_LORE)) { - loreflag = false; - } else { - if (loreText.length() > 0) { - loreText.append("\n"); - } - loreText.append(line2); - } + msgText.append(line2); + } + } else if (loreflag) { + // reading lore text: + if (line.equalsIgnoreCase(TAG_END_LORE)) { + loreflag = false; } else { - // inside map arch, outside message - if (line.equalsIgnoreCase(TAG_START_TEXT)) { - msgflag = true; + if (loreText.length() > 0) { + loreText.append("\n"); } - if (line.equalsIgnoreCase(TAG_START_LORE)) { - loreflag = true; - } else if (line.equalsIgnoreCase("end")) { - endReached = true; - } else if (line.startsWith("name")) { - setMapName(line.substring(line.indexOf(" ") + 1).trim()); - } else if (line.startsWith("region")) { - region = line.substring(line.indexOf(" ") + 1).trim(); - } else if (line.startsWith("width") || line.startsWith("x ")) { - width = getLineValue(line); - } else if (line.startsWith("height") || line.startsWith("y ")) { - height = getLineValue(line); - } else if (line.startsWith("enter_x") || line.startsWith("hp")) { - setEnterX(getLineValue(line)); - } else if (line.startsWith("enter_y") || line.startsWith("sp")) { - setEnterY(getLineValue(line)); - } else if (line.startsWith("reset_timeout") || line.startsWith("weight")) { - setResetTimeout(getLineValue(line)); - } else if (line.startsWith("swap_time") || line.startsWith("value")) { - setSwapTime(getLineValue(line)); - } else if (line.startsWith("difficulty") || line.startsWith("level")) { - setDifficulty(getLineValue(line)); - } else if (line.startsWith("darkness") || line.startsWith("invisible")) { - setDarkness(getLineValue(line)); - } else if (line.startsWith("fixed_resettime") || line.startsWith("stand_still")) { - if (getLineValue(line) != 0) { - setFixedReset(true); - } - } else if (line.startsWith("unique")) { - if (getLineValue(line) != 0) { - setUnique(true); - } - } else if (line.startsWith("template")) { - if (getLineValue(line) != 0) { - template = true; - } - } else if (line.startsWith("outdoor")) { - if (getLineValue(line) != 0) { - outdoor = true; - } - } else if (line.startsWith("nosmooth")) { - if (getLineValue(line) != 0) { - nosmooth = true; - } - } else if (line.startsWith("tile_path_")) { - // get tile path - try { - final int i = Integer.valueOf(line.substring(10, 11)); - if (i > 0 && i <= MAX_TILE && line.lastIndexOf(" ") > 0) { - tilePaths[i - 1] = line.substring(line.lastIndexOf(" ") + 1); - } - } catch (final NumberFormatException e) { - /* ignore (really?) */ - } - } else if (line.startsWith("shopitems")) { - shopitems = line.substring(line.indexOf(" ") + 1).trim(); - } else if (line.startsWith("shoprace")) { - shoprace = line.substring(line.indexOf(" ") + 1).trim(); - } else if (line.startsWith("shopmin")) { - shopmin = getLineValue(line); - } else if (line.startsWith("shopmax")) { - shopmax = getLineValue(line); - } else if (line.startsWith("shopgreed")) { - shopgreed = getLineValueAsDouble(line); - } else if (line.startsWith("temp")) { - temp = getLineValue(line); - } else if (line.startsWith("pressure")) { - pressure = getLineValue(line); - } else if (line.startsWith("humid")) { - humid = getLineValue(line); - } else if (line.startsWith("windspeed")) { - windspeed = getLineValue(line); - } else if (line.startsWith("winddir")) { - winddir = getLineValue(line); - } else if (line.startsWith("sky")) { - sky = getLineValue(line); - } + loreText.append(line2); } } else { - // looking for the map arch - if (line.toLowerCase().regionMatches(0, "arch ", 0, 5) && line.toLowerCase().endsWith(" map")) { - archflag = true; + // inside map arch, outside message + if (line.equalsIgnoreCase(TAG_START_TEXT)) { + msgflag = true; } + if (line.equalsIgnoreCase(TAG_START_LORE)) { + loreflag = true; + } else if (line.equalsIgnoreCase("end")) { + endReached = true; + } else if (line.startsWith("name")) { + setMapName(line.substring(line.indexOf(" ") + 1).trim()); + } else if (line.startsWith("region")) { + region = line.substring(line.indexOf(" ") + 1).trim(); + } else if (line.startsWith("width") || line.startsWith("x ")) { + width = getLineValue(line); + } else if (line.startsWith("height") || line.startsWith("y ")) { + height = getLineValue(line); + } else if (line.startsWith("enter_x") || line.startsWith("hp")) { + setEnterX(getLineValue(line)); + } else if (line.startsWith("enter_y") || line.startsWith("sp")) { + setEnterY(getLineValue(line)); + } else if (line.startsWith("reset_timeout") || line.startsWith("weight")) { + setResetTimeout(getLineValue(line)); + } else if (line.startsWith("swap_time") || line.startsWith("value")) { + setSwapTime(getLineValue(line)); + } else if (line.startsWith("difficulty") || line.startsWith("level")) { + setDifficulty(getLineValue(line)); + } else if (line.startsWith("darkness") || line.startsWith("invisible")) { + setDarkness(getLineValue(line)); + } else if (line.startsWith("fixed_resettime") || line.startsWith("stand_still")) { + if (getLineValue(line) != 0) { + setFixedReset(true); + } + } else if (line.startsWith("unique")) { + if (getLineValue(line) != 0) { + setUnique(true); + } + } else if (line.startsWith("template")) { + if (getLineValue(line) != 0) { + template = true; + } + } else if (line.startsWith("outdoor")) { + if (getLineValue(line) != 0) { + outdoor = true; + } + } else if (line.startsWith("nosmooth")) { + if (getLineValue(line) != 0) { + nosmooth = true; + } + } else if (line.startsWith("tile_path_")) { + // get tile path + try { + final int i = Integer.valueOf(line.substring(10, 11)); + if (i > 0 && i <= MAX_TILE && line.lastIndexOf(" ") > 0) { + tilePaths[i - 1] = line.substring(line.lastIndexOf(" ") + 1); + } + } catch (final NumberFormatException e) { + /* ignore (really?) */ + } + } else if (line.startsWith("shopitems")) { + shopitems = line.substring(line.indexOf(" ") + 1).trim(); + } else if (line.startsWith("shoprace")) { + shoprace = line.substring(line.indexOf(" ") + 1).trim(); + } else if (line.startsWith("shopmin")) { + shopmin = getLineValue(line); + } else if (line.startsWith("shopmax")) { + shopmax = getLineValue(line); + } else if (line.startsWith("shopgreed")) { + shopgreed = getLineValueAsDouble(line); + } else if (line.startsWith("temp")) { + temp = getLineValue(line); + } else if (line.startsWith("pressure")) { + pressure = getLineValue(line); + } else if (line.startsWith("humid")) { + humid = getLineValue(line); + } else if (line.startsWith("windspeed")) { + windspeed = getLineValue(line); + } else if (line.startsWith("winddir")) { + winddir = getLineValue(line); + } else if (line.startsWith("sky")) { + sky = getLineValue(line); + } } + } else { + // looking for the map arch + if (line.toLowerCase().regionMatches(0, "arch ", 0, 5) && line.toLowerCase().endsWith(" map")) { + archflag = true; + } } - } catch (final IOException e) { - // if we reach eof here, the mapfile is corrupt - return false; } setMapSize(new Size2D(Math.max(1, width), Math.max(1, height))); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-11-05 17:42:34 UTC (rev 616) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-11-05 23:49:57 UTC (rev 617) @@ -199,8 +199,6 @@ /** Bit field of edit types to show transparent. */ private int alphaType; - CMapFileDecode mapFileDecoder; - private CMapFileEncode mapFileEncoder; private ArchetypeParser archetypeParser; @@ -399,14 +397,6 @@ return faceObjects; } - /** - * Get the CMapFileDecoder. - * @return CMapFileDecoder - */ - public CMapFileDecode getMapFileDecode() { - return mapFileDecoder; - } - /** Initialises this main controller. */ void init() { // Get the current directory @@ -435,7 +425,6 @@ } // attach map encoder and decoder - mapFileDecoder = new CMapFileDecode(); mapFileEncoder = new CMapFileEncode(); // our global object parser @@ -1209,19 +1198,24 @@ } try { - final List<GameObject> objects = mapFileDecoder.decodeMapFile(file, mapDir.getAbsolutePath()); // parse mapfile - final MapArchObject maparch = mapFileDecoder.getMapArch(); // get map arch - // go to ArchetypeParser and add the default arch list information to them - final MapControl newMap = newLevel(objects, maparch, view); // init the map + final CMapFileDecode decoder = new CMapFileDecode(file); + try { + final List<GameObject> objects = decoder.decodeMapFile(); // parse mapfile + final MapArchObject maparch = decoder.getMapArch(); // get map arch + // go to ArchetypeParser and add the default arch list information to them + final MapControl newMap = newLevel(objects, maparch, view); // init the map - // finally, show the map and refresh toolbars - newMap.setMapFile(file); - newMap.setActiveEditType(tileEdit); // map is loaded with current view settings - if (view) { - refreshMenusAndToolbars(); - addRecent(currentMap.getMapArch().getMapDisplayName(), file.toString()); + // finally, show the map and refresh toolbars + newMap.setMapFile(file); + newMap.setActiveEditType(tileEdit); // map is loaded with current view settings + if (view) { + refreshMenusAndToolbars(); + addRecent(currentMap.getMapArch().getMapDisplayName(), file.toString()); + } + return newMap; + } finally { + decoder.close(); } - return newMap; } catch (final FileNotFoundException e) { ACTION_FACTORY.showMessageDialog(mainView, "openFileLoadMap", e.getMessage()); return null; @@ -1269,7 +1263,7 @@ * browse first through the default arch list and attach map arches to it * then browse through the face list and try to find the pictures */ - void collectTempList(final List<GameObject> objects, final File file) { + void collectTempList(final List<GameObject> objects, final String uri) { final StringBuilder noarch = new StringBuilder(); int noarchcount = 0; final List<GameObject> tailList = new ArrayList<GameObject>(); @@ -1300,7 +1294,7 @@ } if (noarchcount > 0) { - ACTION_FACTORY.showMessageDialog(mainView, "collectTemplistAutodelete", file.getName(), noarchcount, noarch); + ACTION_FACTORY.showMessageDialog(mainView, "collectTemplistAutodelete", uri, noarchcount, noarch); } } Modified: trunk/daimonin/src/daieditor/CMapFileDecode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-11-05 17:42:34 UTC (rev 616) +++ trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-11-05 23:49:57 UTC (rev 617) @@ -26,15 +26,11 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapArchObject; -import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; import java.util.List; -import net.sf.gridarta.io.IOUtils; +import net.sf.gridarta.io.AbstractMapFileDecode; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -43,85 +39,66 @@ * A MapFileDecoder reads a map file and provides access to the information read from the map file. * This class handles the reading of a mapfile and parsing the data * into a list of ArchObjects. - * Warning: This class is NOT Thread safe! * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo change to classical IO class style */ -public final class CMapFileDecode { +public final class CMapFileDecode extends AbstractMapFileDecode<GameObject, MapArchObject> { private static final Logger log = Logger.getLogger(CMapFileDecode.class); - /** ArchObjects that are read from the map. */ - private List<GameObject> objects; + /** + * Open a resource for reading it as a map. + * @param uri URI of resource to open. + * @throws FileNotFoundException in case the resource was not found. + */ + public CMapFileDecode(final String uri) throws FileNotFoundException { + super(uri); + } - /** Contains the map arch (see MapArchObject class). */ - private MapArchObject maparch; - - public CMapFileDecode() { + /** + * Open a file for reading it as a map. + * @param file File to open. + * @throws FileNotFoundException in case the file was not found. + */ + public CMapFileDecode(final File file) throws FileNotFoundException { + super(file); } - public MapArchObject getMapArch() { - return maparch; + /** {@inheritDoc} */ + protected MapArchObject createMapArchObject() { + return new MapArchObject(); } /** - * Loading a Daimonin map from the given mapfile. - * This method returns a list of arches. - * @param file mapfile - * @param mapDir map directory + * Loading a map from the given mapfile. + * This method returns a list of GameObjects. * @return first <code>GameObject</code> in the list * @throws FileNotFoundException in case the requested map file was not found * @throws IOException in case the file couldn't be read or is in wrong format * @todo create a separate exception for the wrong format */ - @NotNull public synchronized List<GameObject> decodeMapFile(@NotNull final File file, final String mapDir) throws FileNotFoundException, IOException { - final BufferedReader myInput = new BufferedReader(new InputStreamReader(new FileInputStream(file), IOUtils.MAP_ENCODING)); - try { - objects = new ArrayList<GameObject>(); - // first of all we read the map arch (if that fails we throw an exception) - maparch = new MapArchObject(); - final String fname; - if (file.getCanonicalPath().startsWith(mapDir)) { - fname = file.getCanonicalPath().substring(mapDir.length()); - } else { - fname = file.getCanonicalPath(); - } - if (!maparch.parseMapArch(myInput, fname)) { - throw new IOException("The file '" + file.getName() + "' does not contain a valid Daimonin map format!\n"); - } - //maparch.setName(file.getName()); - - // now we read all the ArchObjects - // Outer loop: reads "arch ...", inner loop reads until end of arch - for (String thisLine; (thisLine = myInput.readLine()) != null;) { - readArch(myInput, thisLine); // all these are map arches - } - CMainControl.getInstance().collectTempList(objects, file); - CMainControl.getInstance().getArchetypeParser().sortTempList(objects); - return objects; // return first arch of the list - } finally { - objects = null; - myInput.close(); - } + @NotNull public List<GameObject> decodeMapFile() throws IOException { + final List<GameObject> objects = super.decodeMapFile(); + CMainControl.getInstance().collectTempList(objects, uri); + CMainControl.getInstance().getArchetypeParser().sortTempList(objects); + return objects; // return first arch of the list } - /** * Our recursive accessible arch reader. * <p/> * WARNING: this implementation should fail with multi head settings * if there are multi part items in the inventory (but this is not yet * included in CF!) - * @param myInput input filestream * @param thisLine first line of text, belonging to this new arch * @return the new parsed <code>GameObject</code> * @throws IOException when an I/O-error occured during file reading - * @fixme I'm too long, make me shorter - what about a HashMap<String,Integer> and switch/case? - * @todo attributes not relevant during map parsing shouldn't be evaluated here, but in GameObject / ArchetypeParser instead. + * @fixme I'm too long, make me shorter. + * @todo Attributes not relevant during map parsing shouldn't be evaluated here, but in GameObject / ArchetypeParser instead. */ - @Nullable private GameObject readArch(final BufferedReader myInput, String thisLine) throws IOException { + // Note for programmers from Crossfire: Daimonin need not support "More". + @Nullable protected GameObject readArch(String thisLine) throws IOException { boolean msgflag = false; boolean archflag = false; GameObject gameObject = null; @@ -135,12 +112,11 @@ // if this is still -1 in the post parse, we have no direction command loaded gameObject.setDirection(-1); - // our arch! it has a name! - gameObject.setArchetypeName(thisLine.substring("arch ".length()).trim()); + gameObject.setArchetypeName(thisLine.substring(5).trim()); } } else { - // here we are inside of an arch object (but not "More")... + // here we are inside of an arch object if (msgflag) { if (thisLine.startsWith("endmsg")) { msgflag = false; @@ -154,11 +130,11 @@ if (log.isDebugEnabled()) { log.debug("GO INVENTORY: " + gameObject + " - " + thisLine); } - gameObject.addLast(readArch(myInput, thisLine)); + gameObject.addLast(readArch(thisLine)); if (log.isDebugEnabled()) { log.debug("GO INVENTORY2: " + gameObject + " - " + thisLine); } - } else if (thisLine.startsWith("end")) { + } else if (thisLine.equals("end")) { // chain this to temp list objects.add(gameObject); archflag = false; @@ -188,7 +164,7 @@ gameObject.addObjectText(thisLine + '\n'); } } - } while ((thisLine = myInput.readLine()) != null); + } while ((thisLine = readLine()) != null); return null; // this happens when the file end is reached } Modified: trunk/daimonin/src/daieditor/CPickmapPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CPickmapPanel.java 2006-11-05 17:42:34 UTC (rev 616) +++ trunk/daimonin/src/daieditor/CPickmapPanel.java 2006-11-05 23:49:57 UTC (rev 617) @@ -28,7 +28,6 @@ import daieditor.map.MapArchObject; import daieditor.map.MapControl; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -142,26 +141,30 @@ try { // FIXME: This is somewhat dangerous regarding multithreading - final CMapFileDecode decoder = mainControl.getMapFileDecode(); - final List<GameObject> objects = decoder.decodeMapFile(mapFile, mainControl.getMapDir().getAbsolutePath()); - final MapArchObject maparch = decoder.getMapArch(); - final CMapViewBasic bmapview; + final CMapFileDecode decoder = new CMapFileDecode(mapFile); + try { + final List<GameObject> objects = decoder.decodeMapFile(); + final MapArchObject maparch = decoder.getMapArch(); + final CMapViewBasic bmapview; - // go to ArchetypeParser and add the default arch list information to them - bmapview = newPickmap(objects, maparch, mapFile, index); // init the map + // go to ArchetypeParser and add the default arch list information to them + bmapview = newPickmap(objects, maparch, mapFile, index); // init the map - // looks like it worked, so we add a panel and display this pickmap - if (bmapview != null) { - if (index < 0 || index >= tabpane.getTabCount()) { - tabpane.addTab(mapFile.getName(), bmapview); - } else { - tabpane.insertTab(mapFile.getName(), null, bmapview, null, index); + // looks like it worked, so we add a panel and display this pickmap + if (bmapview != null) { + if (index < 0 || index >= tabpane.getTabCount()) { + tabpane.addTab(mapFile.getName(), bmapview); + } else { + tabpane.insertTab(mapFile.getName(), null, bmapview, null, index); + } + bmapview.getMapControl().setPickmap(true); + return true; } - bmapview.getMapControl().setPickmap(true); - return true; + } finally { + decoder.close(); } } catch (final IOException e) { - log.warn("Couldn't load pickmap", e); + log.warn("Couldn't load pickmap", e); } return false; } Added: trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java (rev 0) +++ trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java 2006-11-05 23:49:57 UTC (rev 617) @@ -0,0 +1,127 @@ +package net.sf.gridarta.io; + +import java.io.IOException; +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.io.FileNotFoundException; +import java.io.File; +import java.util.List; +import java.util.ArrayList; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.gameobject.GameObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Abstract base implementation of {@link MapFileDecode}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class AbstractMapFileDecode<G extends GameObject, A extends MapArchObject> implements MapFileDecode<G, A> { + + /** ArchObjects that are read from the map. */ + protected final List<G> objects = new ArrayList<G>(); + + /** Contains the map arch (see MapArchObject class). */ + protected A maparch; + + /** The reader to read from. */ + private final BufferedReader myInput; + + /** The uri to read from. */ + protected final String uri; + + /** + * Open a resource for reading it as a map. + * @param uri URI of resource to open. + * @throws FileNotFoundException in case the resource was not found. + */ + protected AbstractMapFileDecode(final String uri) throws FileNotFoundException { + this.uri = uri; + try { + myInput = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(uri), IOUtils.MAP_ENCODING)); + } catch (final UnsupportedEncodingException e) { + assert false : IOUtils.MAP_ENCODING + " must be a valid encoding."; + throw new Error(IOUtils.MAP_ENCODING + " must be a valid encoding."); + } + } + + /** + * Open a file for reading it as a map. + * @param file File to open. + * @throws FileNotFoundException in case the file was not found. + */ + protected AbstractMapFileDecode(final File file) throws FileNotFoundException { + this.uri = file.toURI().toString(); + try { + myInput = new BufferedReader(new InputStreamReader(new FileInputStream(file), IOUtils.MAP_ENCODING)); + } catch (final UnsupportedEncodingException e) { + assert false : IOUtils.MAP_ENCODING + " must be a valid encoding."; + throw new Error(IOUtils.MAP_ENCODING + " must be a valid encoding."); + } + } + + /** {@inheritDoc} */ + public final void close() throws IOException { + myInput.close(); + } + + /** {@inheritDoc} */ + public final A getMapArch() { + return maparch; + } + + /** + * Returns a newly created MapArchObject. + * Implement this method to supply the appropriate MapArchObject implementation. + * @return A newly created MapArchObject. + */ + protected abstract A createMapArchObject(); + + /** + * Loading a map from the given mapfile. + * This method returns a list of GameObjects. + * @return first <code>GameObject</code> in the list + * @throws FileNotFoundException in case the requested map file was not found + * @throws IOException in case the file couldn't be read or is in wrong format + * @todo create a separate exception for the wrong format + */ + @NotNull public List<G> decodeMapFile() throws IOException { + // first of all we read the map arch (if that fails we throw an exception) + maparch = createMapArchObject(); + if (!maparch.parseMapArch(myInput, uri)) { + throw new IOException("The file '" + uri + "' does not contain a valid Gridarta (Crossfire, Daimonin) map format!\n"); + } + //maparch.setName(uri); + + // now we read all the ArchObjects + // Outer loop: reads "arch ...", inner loop reads until end of arch + for (String thisLine; (thisLine = myInput.readLine()) != null;) { + readArch(thisLine); // all these are map arches + } + return objects; // return first arch of the list + } + + /** + * Our recursive accessible arch reader. + * <p/> + * WARNING: this implementation should fail with multi head settings + * if there are multi part items in the inventory (but this is not yet + * included in CF!) + * @param thisLine first line of text, belonging to this new arch + * @return the new parsed <code>GameObject</code> + * @throws IOException when an I/O-error occured during file reading + */ + @Nullable protected abstract GameObject readArch(String thisLine) throws IOException; + + /** + * Reads a single line. + * @return line read + * @throws IOException when an I/O-error occured during file reading + */ + @Nullable protected final String readLine() throws IOException { + return myInput.readLine(); + } + +} // class AbstractMapFileDecode Property changes on: trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/io/MapFileDecode.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/MapFileDecode.java (rev 0) +++ trunk/src/app/net/sf/gridarta/io/MapFileDecode.java 2006-11-05 23:49:57 UTC (rev 617) @@ -0,0 +1,32 @@ +package net.sf.gridarta.io; + +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import java.io.Closeable; +import java.io.IOException; +import java.util.List; +import org.jetbrains.annotations.NotNull; + +/** + * Interface for classes that read map files. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface MapFileDecode<G extends GameObject, A extends MapArchObject> extends Closeable { + + /** + * Returns the MapArchObject read from this MapFileDecode. + * @note The MapArchObject will only contain reasonable data after {@link #decodeMapFile()} has been called. + * @return The MapArchObject read from this MapFileDecode. + */ + A getMapArch(); + + /** + * Loading a map from the given mapfile. + * This method returns a list of GameObjects. + * @return first <code>GameObject</code> in the list + * @throws IOException in case the file couldn't be read or is in wrong format + * @todo create a separate exception for the wrong format + */ + @NotNull List<G> decodeMapFile() throws IOException; + +} // interface MapFileDecode Property ch... [truncated message content] |
From: <chr...@us...> - 2006-11-05 17:42:45
|
Revision: 616 http://svn.sourceforge.net/gridarta/?rev=616&view=rev Author: christianhujer Date: 2006-11-05 09:42:34 -0800 (Sun, 05 Nov 2006) Log Message: ----------- Minor unification of CMapFileDecode. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/daimonin/src/daieditor/CMapFileDecode.java Modified: trunk/crossfire/src/cfeditor/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-11-05 13:37:09 UTC (rev 615) +++ trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-11-05 17:42:34 UTC (rev 616) @@ -120,8 +120,7 @@ throws IOException { GameObject gameObject; String thisLine2; - boolean archflag, archmore, msgflag, animflag, scriptflag; - final int y; + boolean archflag, archmore, msgflag, animflag; archflag = false; archmore = false; @@ -141,11 +140,11 @@ thisLine = thisLine2.trim(); if (!archflag) { - if (thisLine.regionMatches(0, "More", 0, 4)) { + if (thisLine.startsWith("More")) { // All arches started with "More" are ignored. We load only // the heads and expand them according to the defaults. archmore = true; - } else if (thisLine.regionMatches(0, "arch ", 0, 5)) { + } else if (thisLine.startsWith("arch ")) { // kill white spaces afer arch... // (hm, no command for this in java?) int x; @@ -172,14 +171,14 @@ } else if (!archmore) { // here were are inside of an arch object (but not "More")... if (msgflag) { - if (thisLine.regionMatches(0, "endmsg", 0, 6)) { + if (thisLine.startsWith("endmsg")) { msgflag = false; } else { gameObject.addMsgText(thisLine2 + "\n"); } } else if (animflag) { //gameObject.addArchText(thisLine + "\n"); - if (thisLine.regionMatches(0, "mina", 0, 4)) { + if (thisLine.startsWith("mina")) { animflag = false; } else { // we not include anim yet in panel gameObject.addAnimText(thisLine + "\n"); @@ -204,18 +203,18 @@ log.debug("LEAVE!: " + gameObject + " - " + thisLine); } return gameObject; - } else if (thisLine.regionMatches(0, "msg", 0, 3)) { + } else if (thisLine.startsWith("msg")) { // gameObject.addArchText(thisLine + "\n"); gameObject.addMsgText(""); // this init the msg text buffer // in the case of msg/endmsg // with no content to overrule def msg msgflag = true; // this is a MUST, because we overrule "anim" test - } else if (thisLine.regionMatches(0, "animation", 0, 9)) { + } else if (thisLine.startsWith("animation")) { gameObject.addObjectText(thisLine + "\n"); - } else if (thisLine.regionMatches(0, "anim_speed", 0, 10)) { + } else if (thisLine.startsWith("anim_speed")) { gameObject.addObjectText(thisLine + "\n"); - } else if (thisLine.regionMatches(0, "anim", 0, 4)) { + } else if (thisLine.startsWith("anim")) { //gameObject.addArchText(thisLine + "\n"); animflag = true; } else if (thisLine.startsWith("event_")) { @@ -244,13 +243,13 @@ log.warn("Arch " + gameObject.getArchetypeName() + " has incorrect event code '" + thisLine + "'"); gameObject.addObjectText(thisLine + "\n"); // keep line, it might have a meaning after all } - } else if (thisLine.regionMatches(0, "x ", 0, 2)) { + } else if (thisLine.startsWith("x ")) { final int temp = Integer.parseInt(thisLine.substring(2)); if (temp > maxxlen) { maxxlen = temp; } gameObject.setMapX(temp); - } else if (thisLine.regionMatches(0, "y ", 0, 2)) { + } else if (thisLine.startsWith("y ")) { final int temp = Integer.parseInt(thisLine.substring(2)); if (temp > maxylen) { maxylen = temp; @@ -260,15 +259,9 @@ } else if (thisLine.startsWith("type ")) { gameObject.setArchTypNr(Integer.parseInt(thisLine.substring(5))); // don't load it into the archtext! - } else if (thisLine.regionMatches(0, "face ", 0, 5)) { - int x; - for (x = 4; x < thisLine.length(); x++) { - if (thisLine.charAt(x) != ' ') { - break; - } - } + } else if (thisLine.startsWith("face ")) { gameObject.setFaceFlag(false); - gameObject.setFaceName(thisLine.substring(x, thisLine.length())); + gameObject.setFaceName(thisLine.substring(5).trim()); } else { gameObject.addObjectText(thisLine + "\n"); } Modified: trunk/daimonin/src/daieditor/CMapFileDecode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-11-05 13:37:09 UTC (rev 615) +++ trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-11-05 17:42:34 UTC (rev 616) @@ -182,7 +182,7 @@ gameObject.setDirection(Integer.parseInt(thisLine.substring(10))); gameObject.addObjectText(thisLine + '\n'); } else if (thisLine.startsWith("face ")) { - gameObject.setFaceRealName(thisLine.substring("face ".length()).trim()); + gameObject.setFaceRealName(thisLine.substring(5).trim()); gameObject.addObjectText(thisLine + '\n'); } else { gameObject.addObjectText(thisLine + '\n'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-05 13:38:25
|
Revision: 615 http://svn.sourceforge.net/gridarta/?rev=615&view=rev Author: christianhujer Date: 2006-11-05 05:37:09 -0800 (Sun, 05 Nov 2006) Log Message: ----------- Moved transaction system from daimonin to gridarta and performed the neccessary changes to daimonin for doing so. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapModel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/ConnectionView.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapModel.java trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java trunk/daimonin/src/daieditor/map/validation/GameObjectValidationError.java trunk/daimonin/src/daieditor/map/validation/GameObjectValidator.java trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java trunk/daimonin/src/daieditor/map/validation/MapValidator.java trunk/daimonin/src/daieditor/map/validation/SquareValidationError.java trunk/daimonin/src/daieditor/map/validation/SquareValidator.java trunk/daimonin/src/daieditor/map/validation/ValidationError.java trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareChecker.java trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareError.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java trunk/daimonin/src/daieditor/map/validation/checks/ExitError.java trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyChecker.java trunk/daimonin/src/daieditor/map/validation/checks/MapDifficultyError.java trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointChecker.java trunk/daimonin/src/daieditor/map/validation/checks/MobOutsideSpawnPointError.java trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SlayingError.java trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SquareWithoutFloorError.java trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroError.java trunk/daimonin/src/daieditor/map/validation/checks/TilePathsChecker.java trunk/daimonin/src/daieditor/map/validation/checks/TilePathsError.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java trunk/src/app/net/sf/gridarta/map/MapModel.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/map/MapModelEvent.java trunk/src/app/net/sf/gridarta/map/MapModelListener.java Removed Paths: ------------- trunk/daimonin/src/daieditor/map/MapModelEvent.java trunk/daimonin/src/daieditor/map/MapModelListener.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-05 13:37:09 UTC (rev 615) @@ -749,10 +749,6 @@ } */ - /** {@inheritDoc} */ - public void squareChanged(@NotNull final MapSquare<GameObject> square) { - } - /** * Get a default {@link GameObject} instance. * Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2006-11-05 13:37:09 UTC (rev 615) @@ -2,8 +2,6 @@ import cfeditor.gameobject.GameObject; import java.awt.Point; -import net.sf.gridarta.map.MapSquare; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -58,9 +56,6 @@ void setFileName(String strFileName); - /** {@inheritDoc} */ - void squareChanged(@NotNull MapSquare<GameObject> square); - /** * Reset the level changed flag to false. * @todo this probably belongs to CMapControl instead Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-11-05 13:37:09 UTC (rev 615) @@ -51,8 +51,8 @@ import daieditor.map.MapArchObject; import daieditor.map.MapControl; import daieditor.map.MapModel; -import daieditor.map.MapModelEvent; -import daieditor.map.MapModelListener; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; import daieditor.map.validation.DefaultErrorCollector; import daieditor.map.validation.DelegatingMapValidator; import daieditor.map.validation.ErrorCollector; @@ -501,10 +501,10 @@ * @param map map to check * @todo that's not nice here. Instead there should be an error model and error listeners. */ - public void checkMap(final MapModel map) { + public void checkMap(final net.sf.gridarta.map.MapModel map) { final ErrorCollector errorCollector = new DefaultErrorCollector(); validators.validateAll(map, errorCollector); - for (final MapViewIFrame mapViewIFrame : map.getMapControl().getMapViewFrames()) { + for (final MapViewIFrame mapViewIFrame : ((MapModel) map).getMapControl().getMapViewFrames()) { mapViewIFrame.getView().setErrors(errorCollector); } mainView.setErrors(errorCollector); @@ -2043,7 +2043,7 @@ } /** @param map */ - public void mapSizeChanged(final MapModel map) { + public void mapSizeChanged(final net.sf.gridarta.map.MapModel map) { if (prefs.getBoolean(PREFS_VALIDATOR_AUTO, PREFS_VALIDATOR_AUTO_DEFAULT)) { checkMap(map); } @@ -2064,7 +2064,7 @@ if (squares != null) { final ErrorCollector errorCollector = new DefaultErrorCollector(); validators.validate(squares, errorCollector); - e.getMap().getMapControl().getMapViewFrame().getView().setErrors(errorCollector); + ((MapModel) e.getMap()).getMapControl().getMapViewFrame().getView().setErrors(errorCollector); mainView.setErrors(errorCollector); } } @@ -2073,11 +2073,11 @@ /** {@inheritDoc} */ public void mapObjectsChanged(final MapModelEvent e) { if (prefs.getBoolean(PREFS_VALIDATOR_AUTO, PREFS_VALIDATOR_AUTO_DEFAULT)) { - final GameObject[] arches = e.getGameObjects(); + final net.sf.gridarta.gameobject.GameObject[] arches = e.getGameObjects(); if (arches != null) { final ErrorCollector errorCollector = new DefaultErrorCollector(); validators.validate(arches, errorCollector); - e.getMap().getMapControl().getMapViewFrame().getView().setErrors(errorCollector); + ((MapModel) e.getMap()).getMapControl().getMapViewFrame().getView().setErrors(errorCollector); mainView.setErrors(errorCollector); } } Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-11-05 13:37:09 UTC (rev 615) @@ -29,8 +29,8 @@ import daieditor.gui.map.MapUserListener; import daieditor.map.MapControl; import daieditor.map.MapModel; -import daieditor.map.MapModelEvent; -import daieditor.map.MapModelListener; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.ErrorHandler; import daieditor.map.validation.ValidationError; @@ -108,10 +108,10 @@ private final MapView frame; /** The MapSquares that are known to contain errors. */ - private Map<MapSquare<GameObject>, ValidationError> erraneousMapSquares = new HashMap<MapSquare<GameObject>, ValidationError>(); + private Map<MapSquare<? extends net.sf.gridarta.gameobject.GameObject>, ValidationError> erraneousMapSquares = new HashMap<MapSquare<? extends net.sf.gridarta.gameobject.GameObject>, ValidationError>(); /** The ArchObjects that are known to contain errors. */ - private Map<GameObject,ValidationError> erraneousArchObjects = new HashMap<GameObject,ValidationError>(); + private Map<net.sf.gridarta.gameobject.GameObject,ValidationError> erraneousArchObjects = new HashMap<net.sf.gridarta.gameobject.GameObject,ValidationError>(); /** * Constructs a level view. @@ -392,8 +392,8 @@ erraneousArchObjects.clear(); mapGrid.clearErrors(); for (ValidationError validationError : errors.getErrors()) { - final MapSquare<GameObject> mapSquare = validationError.getMapSquare(); - final GameObject archObject = validationError.getGameObject(); + final MapSquare<? extends net.sf.gridarta.gameobject.GameObject> mapSquare = validationError.getMapSquare(); + final net.sf.gridarta.gameobject.GameObject archObject = validationError.getGameObject(); if (mapSquare != null) { erraneousMapSquares.put(mapSquare, validationError); mapGrid.setError(mapSquare.getMapX(), mapSquare.getMapY()); Modified: trunk/daimonin/src/daieditor/gui/ConnectionView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ConnectionView.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/gui/ConnectionView.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,10 +21,8 @@ package daieditor.gui; -import daieditor.gameobject.GameObject; -import daieditor.map.MapModel; -import daieditor.map.MapModelEvent; -import daieditor.map.MapModelListener; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; import java.awt.BorderLayout; import java.util.ArrayList; import java.util.HashMap; @@ -34,6 +32,9 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.gameobject.GameObject; /** * A Panel that holds information about the connections of the selected arch on the selected map. @@ -80,7 +81,7 @@ */ public void scanMapForConnections(final MapModel model) { connections.clear(); - for (final MapSquare<GameObject> mapSquare : model) { + for (final MapSquare<? extends GameObject> mapSquare : (MapModel<? extends GameObject, MapArchObject>) model) { for (final GameObject archObject : mapSquare) { final String connectionSpec = archObject.getAttributeString("connected", false); if (connectionSpec != null && connectionSpec.matches("\\d+(, *\\d+)*")) { Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-11-05 13:37:09 UTC (rev 615) @@ -90,10 +90,10 @@ private final MapGrid mapGrid; /** The MapSquares that are known to contain errors. */ - private Map<MapSquare<GameObject>,ValidationError> erraneousMapSquares; + private Map<MapSquare<? extends net.sf.gridarta.gameobject.GameObject>,ValidationError> erraneousMapSquares; /** The ArchObjects that are known to contain errors. */ - private Map<GameObject,ValidationError> erraneousArchObjects; + private Map<net.sf.gridarta.gameobject.GameObject,ValidationError> erraneousArchObjects; /** Used to avoid creation millions of points */ private final Point tmpPoint = new Point(); @@ -480,7 +480,7 @@ * Sets the ArchObjects that are known to contain errors. * @param erraneousArchObjects the ArchObjects that are known to contain errors. */ - public void setErraneousArchObjects(final Map<GameObject, ValidationError> erraneousArchObjects) { + public void setErraneousArchObjects(final Map<net.sf.gridarta.gameobject.GameObject, ValidationError> erraneousArchObjects) { this.erraneousArchObjects = erraneousArchObjects; } @@ -488,7 +488,7 @@ * Sets the MapSquares that are known to contain errors. * @param erraneousMapSquares the MapSquares that are known to contain errors. */ - public void setErraneousMapSquares(final Map<MapSquare<GameObject>, ValidationError> erraneousMapSquares) { + public void setErraneousMapSquares(final Map<MapSquare<? extends net.sf.gridarta.gameobject.GameObject>, ValidationError> erraneousMapSquares) { this.erraneousMapSquares = erraneousMapSquares; } Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-05 13:37:09 UTC (rev 615) @@ -31,16 +31,12 @@ import daieditor.gameobject.GameObject; import java.awt.Point; import java.awt.Toolkit; -import java.util.ArrayList; import java.util.List; -import javax.swing.event.EventListenerList; -import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.map.AbstractMapModel; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -62,9 +58,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); - /** The registered event listeners. */ - private EventListenerList listenerList = new EventListenerList(); - /** Flag that indicates if the level has been changed since last save. */ private boolean levelChanged = false; @@ -81,12 +74,6 @@ */ @Deprecated private final MapControl mapControl; - /** The transaction depth. */ - private int transactionDepth; - - /** The name of the current transaction. */ - @Nullable private String transactionName; - /** * Constructs a level model. * @param mainControl main controller @@ -302,104 +289,11 @@ } /** {@inheritDoc} */ - public void resizeMap(@NotNull final Size2D newSize) { - super.resizeMap(newSize); - fireMapSizeChanged(); - } - - /** {@inheritDoc} */ public MapControl getMapControl() { return mapControl; } - /** {@inheritDoc} */ - public void addMapModelListener(final MapModelListener listener) { - listenerList.add(MapModelListener.class, listener); - } - - /** {@inheritDoc} */ - public void removeMapModelListener(final MapModelListener listener) { - listenerList.remove(MapModelListener.class, listener); - } - - /** Fire a map size changed event. */ - private void fireMapSizeChanged() { - final MapModelEvent e = new MapModelEvent(this, MapModelEvent.Type.SIZE_CHANGED); - final Object[] listeners = listenerList.getListenerList(); - for (int i = listeners.length - 2; i >= 0; i -= 2) { - if (listeners[i] == MapModelListener.class) { - ((MapModelListener) listeners[i + 1]).mapSizeChanged(e); - } - } - } - - /** The ArrayList with changed squares. */ - private final List<MapSquare<GameObject>> changedSquares = new ArrayList<MapSquare<GameObject>>(); - - /** {@inheritDoc} */ - public void squareChanged(@NotNull final MapSquare<GameObject> square) { - if (transactionDepth == 0) { - fireMapSquaresChangedEvent(square); - } else { - synchronized (changedSquares) { - changedSquares.add(square); - } - } - } - - /** {@inheritDoc} */ - public void beginTransaction(@NotNull final String name) { - if (transactionDepth++ == 0) { - transactionName = name; - } - } - - /** {@inheritDoc} */ - public void endTransaction() { - transactionDepth--; - assert transactionDepth >= 0; - if (transactionDepth == 0 && !changedSquares.isEmpty()) { - fireMapSquaresChangedEvent(changedSquares.toArray(new MapSquare[changedSquares.size()])); - changedSquares.clear(); - } - } - - /** {@inheritDoc} */ - public void endAllTransactions() { - if (transactionDepth > 0) { - transactionDepth = 0; - if (!changedSquares.isEmpty()) { - fireMapSquaresChangedEvent(changedSquares.toArray(new MapSquare[changedSquares.size()])); - changedSquares.clear(); - } - } - } - - /** {@inheritDoc} */ - public int getTransactionDepth() { - return transactionDepth; - } - - /** {@inheritDoc} */ - @Nullable public String getTransactionName() { - return transactionName; - } - /** - * Fire a MapSquaresChangedEvent. - * @param squares Squares to fire event for - */ - private void fireMapSquaresChangedEvent(final MapSquare<GameObject>... squares) { - final MapModelEvent e = new MapModelEvent(this, MapModelEvent.Type.SQUARES_CHANGED, squares); - final Object[] listeners = listenerList.getListenerList(); - for (int i = listeners.length - 2; i >= 0; i -= 2) { - if (listeners[i] == MapModelListener.class) { - ((MapModelListener) listeners[i + 1]).mapSquaresChanged(e); - } - } - } - - /** * Get an Archetype. * * @param archName the archetype name Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-11-05 13:37:09 UTC (rev 615) @@ -47,6 +47,8 @@ import javax.swing.ImageIcon; import net.sf.gridarta.Size2D; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapGrid; import net.sf.japi.swing.ActionFactory; @@ -127,7 +129,7 @@ /** * Keep track of changes. * This field is <code>true</code> if the map was changed after the last save / load operation. - * Therefore this class implements {@link MapModelListener}. + * Therefore this class implements {@link net.sf.gridarta.map.MapModelListener}. */ private boolean changed; Modified: trunk/daimonin/src/daieditor/map/MapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModel.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/MapModel.java 2006-11-05 13:37:09 UTC (rev 615) @@ -4,28 +4,10 @@ import java.awt.Point; import java.io.Serializable; import net.sf.gridarta.map.MapSquare; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Interface for MapModels. - * <h2>Transaction System</h2> - * The purpose of the transaction system in MapModel is to allow several subsequent changes to the model to be collected as a single big change before the registered listeners (usually the user interface) gets notified. - * This prevents the user interface from performing hundrets of updates when a single one would be enough. - * The transaction system will also be used for implementing undo / redo. - * <p /> - * The transaction system is efficient-safe. - * The following operations are very cheap: - * <ul> - * <li>Beginning a nested transaction</li> - * <li>Ending a nested transaction</li> - * <li>Ending an outmost transaction without having changed something</li> - * </ul> - * Whether beginning the outermost transaction will be a cheap operation is not yet decided. - * <p /> - * It is not the purpose of the transaction system to provide real transactions (ACID). - * Queries to the MapModel during an ongoing transaction will reflect the intermediate state. - * And there is no rollback. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public interface MapModel extends net.sf.gridarta.map.MapModel<GameObject, MapArchObject>, Serializable { @@ -59,7 +41,7 @@ * @param insertBelow true: new arch is inserted on top, false: new arch is * inserted below * @return true if insertion successful, false if not - * @todo discuss whether this method really belongs to a map model, as implementing this would require the map model to know more than is desireable. + * @todo discuss whether this method really belongs to a map model, as implementing this would require the map model to know more than is desireable (e.g. ArchObjectStack + MainControl). */ boolean addArchToMap(String archname, Point pos, boolean allowDouble, boolean insertBelow); @@ -94,87 +76,8 @@ /** * Returns the MapControl that controls this MapModel. * @return the MapControl that controls this MapModel + * @deprecated a MapModel should never know it's MapControl */ - MapControl getMapControl(); + @Deprecated MapControl getMapControl(); - /** - * Register a map listener. - * @param listener MapModelListener to register - */ - void addMapModelListener(@NotNull MapModelListener listener); - - /** - * Unregister a map listener. - * @param listener MapModelListener to unregsiter - */ - void removeMapModelListener(@NotNull MapModelListener listener); - - /** - * {@inheritDoc} - * A change to a square is atomic if {@link #getTransactionDepth()} returns 0, otherwise it is transactional. - * The model then notifies the registered listeners of the changes. - */ - void squareChanged(@NotNull MapSquare<GameObject> square); - - /** - * Start a new transaction. - * Transactions may be nested. - * Transactions serve the purpose of firing events to the views when more changes are known to come before the view is really required to update. - * Each invocation of {@link #beginTransaction(String)} requires its own invocation of {@link #endTransaction()}. - * <p /> - * A transaction has a name. - * The name of the outermost transaction is used as a String presented to the user for undoing the operation enclosed by that transaction. - * <p /> - * Beginning a nested transaction is a cheap operation. - * @param name Name of the transaction. - * @see #endTransaction() - * @see #getTransactionDepth() - * @see #endAllTransactions() - * @deprecated this method is replaced by {@link #beginTransaction(String)} - */ - @Deprecated void beginTransaction(@NotNull String name); - - /** - * End a transaction. - * Invoking this method will reduce the transaction depth by only 1. - * <p /> - * Ending a nested operation is a cheap operation. - * Ending a transaction without changes also is a cheap operation. - * @see #beginTransaction(String) - * @see #getTransactionDepth() - * @see #endAllTransactions() - */ - void endTransaction(); - - /** - * Ends all transaction. - * Invoking this method will reduce set the transaction depth to 0. - * You shouldn't invoke this method regularly. - * It is meant as a fallback in high level methods / exception handlers to prevent errors from causing unclosed transactions. - * @see #beginTransaction(String) - * @see #endTransaction() - * @see #getTransactionDepth() - */ - void endAllTransactions(); - - /** - * Get the transaction depth, which is the number of {@link #beginTransaction(String)} invocations without matching {@link #endTransaction()} invocations. - * A transaction depth of 0 means there is no ongoing transaction. - * @return transaction depth - * @see #beginTransaction(String) - * @see #endTransaction() - * @see #endAllTransactions() - */ - int getTransactionDepth(); - - /** - * Returns the current transaction's name. - * In case of nested transactions, the name of the outermost transaction is returned. - * If not called inside but after a transaction, the last transaction's name is returned. - * If not called inside a transaction and there hasn't been a transaction so far, <code>null</code> is returned. - * @return The current transaction's name. - * @note Unstable: This part of this interface's contract is unstable. Details like nullability and exceptions are subject of change. - */ - @Nullable String getTransactionName(); - } // interface MapModel Deleted: trunk/daimonin/src/daieditor/map/MapModelEvent.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModelEvent.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/MapModelEvent.java 2006-11-05 13:37:09 UTC (rev 615) @@ -1,153 +0,0 @@ -/* - * Daimonin Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * Copyright (C) 2005 Christian Hujer - * Copyright (C) 2006 Christian Hujer - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package daieditor.map; - -import daieditor.gameobject.GameObject; -import java.util.EventObject; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.NotNull; -import net.sf.gridarta.map.MapSquare; - -/** - * Class for Map events. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @note for speed all arrays are used as is, they are not cloned. This applies to the constructor arguments as well as the getter return arguments. - * @todo to improve speed, the event should also be capable of reporting the changed GameObjects - * @todo think about an intelligent way to detect whether repainting is required - * @serial exclude - */ -public final class MapModelEvent extends EventObject { - - /** The Map that's changed. */ - @NotNull private final MapModel map; - - /** The squares that have changed. */ - @Nullable private final MapSquare<GameObject>[] squares; - - /** The GameObjects that have been changed. */ - @Nullable private final GameObject[] gameObjects; - - /** The type of this event. */ - @NotNull private Type type; - - /** - * Create a MapModelEvent. - * @param map Map that's changed by that event (serves as src) - * @param type Type of this event - */ - public MapModelEvent(@NotNull final MapModel map, @NotNull final Type type) { - this(map, type, null, null); - } - - /** - * Create a MapModelEvent. - * @param map Map that's changed by that event (serves as src) - * @param type Type of this event - * @param squares Squares that have changed - */ - public MapModelEvent(@NotNull final MapModel map, @NotNull final Type type, @NotNull final MapSquare<GameObject>... squares) { - this(map, type, squares, null); - } - - /** - * Create a MapModelEvent. - * @param map Map that's changed by that event (serves as src) - * @param type Type of this event - * @param gameObjects GameObjects that have changed - */ - public MapModelEvent(@NotNull final MapModel map, @NotNull final Type type, @NotNull final GameObject... gameObjects) { - this(map, type, null, gameObjects); - } - - /** - * Create a MapModelEvent. - * @param map Map that's changed by that event (serves as src) - * @param type Type of this event - * @param squares Squares that have changed or <code>null</code> if the change did not affect specific squares - * @param gameObjects GameObjects that have changed or <code>null</code> if the change did not affect specific GameObjects. - */ - public MapModelEvent(@NotNull final MapModel map, @NotNull final Type type, @Nullable final MapSquare<GameObject>[] squares, @Nullable final GameObject[] gameObjects) { - super(map); - this.map = map; - this.type = type; - this.squares = squares; - this.gameObjects = gameObjects; - } - - /** - * Returns the map that's changed by this event. - * @return The map that's changed by this event. - */ - public MapModel getMap() { - return map; - } - - /** - * Returns the squares that have been changed by this event. - * @return The squares that have been changed or <code>null</code> if the change did not affect specific squares. - */ - @Nullable public MapSquare<GameObject>[] getSquares() { - return squares; - } - - /** - * Returns the GameObjects that have been changed by this event. - * @return The GameObjects that have been changed or <code>null</code> if the change did not affect specific GameObjects. - */ - @Nullable public GameObject[] getGameObjects() { - return gameObjects; - } - - /** - * Returns the type of this event. - * @return The type of this event. - */ - @NotNull public Type getType() { - return type; - } - - /** The types of Map Events. */ - public enum Type { - - /** Size has changed. */ - SIZE_CHANGED, - - /** - * A Square has changed. - * This is used when new GameObjects were added, GameObjects were removed or the order of GameObjects inside a square has changed. - */ - SQUARES_CHANGED, - - /** - * GameObjects inside a Square have changed. - * This is used when the attributes of one or more GameObjects were changed. - */ - ARCHES_CHANGED - - } // enum Type - -} // class MapModelEvent Deleted: trunk/daimonin/src/daieditor/map/MapModelListener.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModelListener.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/MapModelListener.java 2006-11-05 13:37:09 UTC (rev 615) @@ -1,69 +0,0 @@ -/* - * Daimonin Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * Copyright (C) 2005 Christian Hujer - * Copyright (C) 2006 Christian Hujer - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package daieditor.map; - -import java.util.EventListener; - -/** - * Interface for listeners listening on {@link MapModelEvent}s. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public interface MapModelListener extends EventListener { - - /** - * The size of a map has changed. - * @param e EventObject with event information - */ - void mapSizeChanged(MapModelEvent e); - - /** - * Squares of a map have changed. - * The following things are square changes: - * <ul> - * <li>A GameObject was added to the MapSquare</li> - * <li>A GameObject was removed from a MapSquare</li> - * <li>A GameObject was moved up or down within a MapSquare</li> - * </ul> - * Currently, this event also is fired in case of inventory items. - * In future, this event will only be fired for changes to the top level contents of a MapSquare. - * @param e EventObject with event information - */ - void mapSquaresChanged(MapModelEvent e); - - /** - * One or more GameObjects on a map have changed. - * The following things are gameObject changes: - * <ul> - * <li>One or more attributes of a GameObject was changed</li> - * <li>The inventory of a GameObject has changed (items added, removed or moved)</li> - * </ul> - * Currently, this event type is unused. - * @param e EventObject with event information - */ - void mapObjectsChanged(MapModelEvent e); - -} // interface MapModelListener Modified: trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/DelegatingMapValidator.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,12 +21,13 @@ package daieditor.map.validation; -import daieditor.gameobject.GameObject; -import daieditor.map.MapModel; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.gameobject.GameObject; /** * A Map Validator that delegates to other MapValidators. @@ -60,7 +61,7 @@ */ public void validateAll(final MapModel mapModel, final ErrorCollector errorCollector) { validate(mapModel, errorCollector); - for (final MapSquare<GameObject> mapSquare : mapModel) { + for (final MapSquare<? extends GameObject> mapSquare : (MapModel<? extends GameObject, MapArchObject>) mapModel) { validate(mapSquare, errorCollector); for (final GameObject archObject : mapSquare) { validate(archObject, errorCollector); @@ -84,7 +85,7 @@ } /** {@inheritDoc} */ - public void validate(final MapSquare<GameObject> mapSquare, final ErrorCollector errorCollector) { + public void validate(final MapSquare<? extends GameObject> mapSquare, final ErrorCollector errorCollector) { //final long start = currentTimeMillis(); //long next = start; for (final Validator validator : validators) { @@ -101,8 +102,8 @@ * @param mapSquares MapSquares to validate * @param errorCollector Error collector to report errors to */ - public void validate(final MapSquare<GameObject>[] mapSquares, final ErrorCollector errorCollector) { - for (final MapSquare<GameObject> mapSquare : mapSquares) { + public void validate(final MapSquare<? extends GameObject>[] mapSquares, final ErrorCollector errorCollector) { + for (final MapSquare<? extends GameObject> mapSquare : mapSquares) { validate(mapSquare, errorCollector); } } Modified: trunk/daimonin/src/daieditor/map/validation/GameObjectValidationError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/GameObjectValidationError.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/GameObjectValidationError.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,7 +21,7 @@ package daieditor.map.validation; -import daieditor.gameobject.GameObject; +import net.sf.gridarta.gameobject.GameObject; /** * Class for validation errors related to an GameObject. Modified: trunk/daimonin/src/daieditor/map/validation/GameObjectValidator.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/GameObjectValidator.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/GameObjectValidator.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,7 +21,7 @@ package daieditor.map.validation; -import daieditor.gameobject.GameObject; +import net.sf.gridarta.gameobject.GameObject; /** * Interface for GameObject Validators. Modified: trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/GameObjectsValidationError.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,11 +21,11 @@ package daieditor.map.validation; -import daieditor.gameobject.GameObject; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.gameobject.GameObject; /** * Class for validation errors related to more than a single GameObject. @@ -41,7 +41,7 @@ * @param mapSquare the square on which the error occurred * @param gameObjects the arch on which the error occurred */ - public GameObjectsValidationError(final MapSquare<GameObject> mapSquare, final GameObject... gameObjects) { + public GameObjectsValidationError(final MapSquare<? extends GameObject> mapSquare, final GameObject... gameObjects) { super(mapSquare); for (final GameObject gameObject : gameObjects) { this.gameObjects.add(gameObject); Modified: trunk/daimonin/src/daieditor/map/validation/MapValidator.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/MapValidator.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/MapValidator.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,7 +21,7 @@ package daieditor.map.validation; -import daieditor.map.MapModel; +import net.sf.gridarta.map.MapModel; /** * Interface for Map Validators. Modified: trunk/daimonin/src/daieditor/map/validation/SquareValidationError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/SquareValidationError.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/SquareValidationError.java 2006-11-05 13:37:09 UTC (rev 615) @@ -24,8 +24,8 @@ package daieditor.map.validation; -import daieditor.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.gameobject.GameObject; /** * Class for validation errors on a MapSquare. @@ -34,19 +34,19 @@ public class SquareValidationError extends MapValidationError { /** The MapSquare the error occurred on. */ - private final MapSquare<GameObject> mapSquare; + private final MapSquare<? extends GameObject> mapSquare; /** * Create a SquareValidationError. * @param mapSquare the square on which the error occurred */ - public SquareValidationError(final MapSquare<GameObject> mapSquare) { + public SquareValidationError(final MapSquare<? extends GameObject> mapSquare) { super(mapSquare.getModel()); this.mapSquare = mapSquare; } /** {@inheritDoc} */ - @Override public final MapSquare<GameObject> getMapSquare() { + @Override public final MapSquare<? extends GameObject> getMapSquare() { return mapSquare; } Modified: trunk/daimonin/src/daieditor/map/validation/SquareValidator.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/SquareValidator.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/SquareValidator.java 2006-11-05 13:37:09 UTC (rev 615) @@ -22,7 +22,7 @@ package daieditor.map.validation; import net.sf.gridarta.map.MapSquare; -import daieditor.gameobject.GameObject; +import net.sf.gridarta.gameobject.GameObject; /** * Interface for Square Validators. @@ -36,6 +36,6 @@ * @param mapSquare Square to validate * @param errorCollector Error collector to report errors to */ - void validate(MapSquare<GameObject> mapSquare, ErrorCollector errorCollector); + void validate(MapSquare<? extends GameObject> mapSquare, ErrorCollector errorCollector); } // interface SquareValidator Modified: trunk/daimonin/src/daieditor/map/validation/ValidationError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/ValidationError.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/ValidationError.java 2006-11-05 13:37:09 UTC (rev 615) @@ -24,11 +24,11 @@ package daieditor.map.validation; -import daieditor.gameobject.GameObject; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.gameobject.GameObject; import org.jetbrains.annotations.Nullable; /** @@ -77,7 +77,7 @@ * The MapSquare the error occurred on. * @return MapSquare the error occurred on */ - @Nullable public MapSquare<GameObject> getMapSquare() { + @Nullable public MapSquare<? extends GameObject> getMapSquare() { return null; } @@ -95,7 +95,7 @@ * @todo validation errors should be able to provide their own arguments for message formatting */ public final String getMessage() { - final MapSquare<GameObject> mapSquare = getMapSquare(); + final MapSquare<? extends GameObject> mapSquare = getMapSquare(); final int x = mapSquare != null ? mapSquare.getMapX() : -1; final int y = mapSquare != null ? mapSquare.getMapY() : -1; final GameObject archObject = getGameObject(); Modified: trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,13 +21,13 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.SquareValidator; import java.util.ArrayList; import java.util.List; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.gameobject.GameObject; /** * A SquareValidator to assert that mobs or spawn points aren't on blocked squares. @@ -42,7 +42,7 @@ private final List<GameObject> mobsOrSpawnPoints = new ArrayList<GameObject>(); /** {@inheritDoc} */ - public void validate(final MapSquare<GameObject> mapSquare, final ErrorCollector errorCollector) { + public void validate(final MapSquare<? extends GameObject> mapSquare, final ErrorCollector errorCollector) { for (final GameObject gameObject : mapSquare) { final int archTypNr = gameObject.getArchTypNr(); if (archTypNr == 80 || archTypNr == 81) { Modified: trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointError.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,11 +21,11 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.CorrectableError; import daieditor.map.validation.SquareValidationError; import java.awt.Component; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.gameobject.GameObject; /** * Validation error that's used when the BlockedMobOrSpawnPointChecker detected a possible error on the map. @@ -45,7 +45,7 @@ * @param blockers blocking GameObjects * @param mobsOrSpawnPoints mob or spawn GameObjects */ - public BlockedMobOrSpawnPointError(final MapSquare<GameObject> mapSquare, final Iterable<GameObject> blockers, final Iterable<GameObject> mobsOrSpawnPoints) { + public BlockedMobOrSpawnPointError(final MapSquare<? extends GameObject> mapSquare, final Iterable<GameObject> blockers, final Iterable<GameObject> mobsOrSpawnPoints) { super(mapSquare); this.blockers = blockers; this.mobsOrSpawnPoints = mobsOrSpawnPoints; Modified: trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareChecker.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareChecker.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,8 +21,6 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; -import daieditor.map.MapModel; import daieditor.map.validation.AbstractValidator; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.MapValidator; @@ -30,7 +28,9 @@ import java.util.ArrayList; import java.util.List; import net.sf.gridarta.Size2D; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.map.MapModel; /** * A SquareValidator to assert that a square that's blocked and nopass is not surrounded by blocked and nopass only. @@ -110,7 +110,7 @@ * @param square MapSquare to check * @return <code>true</code> if the square is blocking view and passage. */ - private static boolean isBlocked(final MapSquare<GameObject> square) { + private static boolean isBlocked(final MapSquare<? extends GameObject> square) { boolean nopass = false; boolean blocksView = false; for (final GameObject gameObject : square) { Modified: trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareError.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/BlockedSquareError.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,10 +21,10 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.CorrectableError; import daieditor.map.validation.SquareValidationError; import java.awt.Component; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapSquare; /** @@ -37,7 +37,7 @@ * Create a BlockedMobOrSpawnPointError. * @param mapSquare the square on which the error occurred */ - public BlockedSquareError(final MapSquare<GameObject> mapSquare) { + public BlockedSquareError(final MapSquare<? extends GameObject> mapSquare) { super(mapSquare); } Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerChecker.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,10 +21,10 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; import daieditor.map.validation.GameObjectValidator; import daieditor.map.validation.ErrorCollector; +import net.sf.gridarta.gameobject.GameObject; /** * An GameObjectValidator to assert that containers do not contain connected objects. Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedInsideContainerError.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,10 +21,10 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.GameObjectValidationError; import daieditor.map.validation.CorrectableError; import java.awt.Component; +import net.sf.gridarta.gameobject.GameObject; /** * A MapValidator that checks for mobs outside spawn points. Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableChecker.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,10 +21,10 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; import daieditor.map.validation.GameObjectValidator; import daieditor.map.validation.ErrorCollector; +import net.sf.gridarta.gameobject.GameObject; /** * A Validator to assert that connected objects cannot be picked up. Modified: trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/ConnectedPickableError.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,10 +21,10 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.GameObjectValidationError; import daieditor.map.validation.CorrectableError; import java.awt.Component; +import net.sf.gridarta.gameobject.GameObject; /** * A MapValidator that checks for mobs outside spawn points. Modified: trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerChecker.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,7 +21,6 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; import daieditor.map.validation.GameObjectsValidationError; import daieditor.map.validation.ErrorCollector; @@ -29,6 +28,7 @@ import java.util.HashMap; import java.util.Map; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.gameobject.GameObject; /** * A SquareValidator to assert that there are no two objects within the same layer. @@ -37,7 +37,7 @@ public class DoubleLayerChecker extends AbstractValidator implements SquareValidator { /** {@inheritDoc} */ - public void validate(final MapSquare<GameObject> mapSquare, final ErrorCollector errorCollector) { + public void validate(final MapSquare<? extends GameObject> mapSquare, final ErrorCollector errorCollector) { final Map<Integer, Object> layers = new HashMap<Integer, Object>(); for (final GameObject archObject : mapSquare) { final int layer = archObject.getAttributeInt("layer", true); Modified: trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleLayerError.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,11 +21,11 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.GameObjectsValidationError; import daieditor.map.validation.CorrectableError; import java.awt.Component; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.gameobject.GameObject; /** * Validation error that's used when the DoubleLayerChecker detected a possible error on the map. @@ -38,7 +38,7 @@ * @param mapSquare the square on which the error occurred * @param archObject the GameObject on which the error occurred */ - public DoubleLayerError(final MapSquare<GameObject> mapSquare, final GameObject archObject) { + public DoubleLayerError(final MapSquare<? extends GameObject> mapSquare, final GameObject archObject) { super(mapSquare, archObject); } Modified: trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeChecker.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,7 +21,6 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; import daieditor.map.validation.GameObjectsValidationError; import daieditor.map.validation.ErrorCollector; @@ -29,6 +28,7 @@ import java.util.HashMap; import java.util.Map; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.gameobject.GameObject; /** * A SquareValidator to assert that there are no two arches of the same type on the same square. @@ -37,7 +37,7 @@ public class DoubleTypeChecker extends AbstractValidator implements SquareValidator { /** {@inheritDoc} */ - public void validate(final MapSquare<GameObject> mapSquare, final ErrorCollector errorCollector) { + public void validate(final MapSquare<? extends GameObject> mapSquare, final ErrorCollector errorCollector) { final Map<Integer, Object> typeNums = new HashMap<Integer, Object>(); for (final GameObject gameObject : mapSquare) { final Integer typeNum = gameObject.getArchTypNr(); Modified: trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/DoubleTypeError.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,11 +21,11 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.GameObjectsValidationError; import daieditor.map.validation.CorrectableError; import java.awt.Component; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.gameobject.GameObject; /** * Validation error that's used when the DoubleTypeChecker detected a possible error on the map. @@ -38,7 +38,7 @@ * @param mapSquare the square on which the error occurred * @param gameObjects the GameObject on which the error occurred */ - public DoubleTypeError(final MapSquare<GameObject> mapSquare, final GameObject... gameObjects) { + public DoubleTypeError(final MapSquare<? extends GameObject> mapSquare, final GameObject... gameObjects) { super(mapSquare, gameObjects); } Modified: trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointChecker.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,10 +21,10 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; import daieditor.map.validation.GameObjectValidator; import daieditor.map.validation.ErrorCollector; +import net.sf.gridarta.gameobject.GameObject; /** * An GameObjectValidator to assert that spawn points are not empty. Modified: trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/EmptySpawnPointError.java 2006-11-05 13:37:09 UTC (rev 615) @@ -21,10 +21,10 @@ package daieditor.map.validation.checks; -import daieditor.gameobject.GameObject; import daieditor.map.validation.GameObjectValidationError; import daieditor.map.validation.CorrectableError; import java.awt.Component; +import net.sf.gridarta.gameobject.GameObject; /** * Validation error that's used when the EmptySpawnPointCheker detected a possible error on the map. Modified: trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java 2006-11-05 12:20:41 UTC (rev 614) +++ trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java 2006-11-05 13:37:09 UTC (rev 615) @@ -1,13 +1,13 @@ package daieditor.map.validation.checks; import daieditor.CMainControl; -import daieditor.gameobject.GameObject; import daieditor.map.validation.AbstractValidator; import daieditor.map.validation.GameObjectValidator; import daieditor.map.validation.ErrorCollector; import daieditor.map.MapModel; import java.io.File; import org.jetbrains.annotations.NotNull; +import net.sf.gridarta.gameobject.GameObject; /** * A Validator to assert that exits are connected to maps properly. Modified: trunk/daimonin/s... [truncated message content] |
From: <chr...@us...> - 2006-11-05 12:21:13
|
Revision: 614 http://svn.sourceforge.net/gridarta/?rev=614&view=rev Author: christianhujer Date: 2006-11-05 04:20:41 -0800 (Sun, 05 Nov 2006) Log Message: ----------- Cosmetic: Some naming improvements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java trunk/src/app/net/sf/gridarta/map/MapModel.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-05 12:16:18 UTC (rev 613) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-05 12:20:41 UTC (rev 614) @@ -72,7 +72,7 @@ this.mainControl = mainControl; mapControl = control; - addArchListToMap(objects); // init mapArchObject and (when not new map) the arch list + addObjectListToMap(objects); // init mapArchObject and (when not new map) the arch list } /** Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-05 12:16:18 UTC (rev 613) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-05 12:20:41 UTC (rev 614) @@ -99,7 +99,7 @@ this.mainControl = mainControl; this.mapControl = mapControl; - addArchListToMap(objects); // init mapArchObject and (when not new map) the arch list + addObjectListToMap(objects); // init mapArchObject and (when not new map) the arch list } /** Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2006-11-05 12:16:18 UTC (rev 613) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2006-11-05 12:20:41 UTC (rev 614) @@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable; /** - * Common interface for ArchObjectParsers. + * Common interface for ArchetypeParsers. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public interface ArchetypeParser<G extends GameObject<G>> { Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2006-11-05 12:16:18 UTC (rev 613) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2006-11-05 12:20:41 UTC (rev 614) @@ -69,13 +69,13 @@ * @param objects the heads of the arches list; may be null to insert nothing * @todo check whether <var>objects</var> really should be Nullable */ - protected final void addArchListToMap(@Nullable final List<G> objects) { + protected final void addObjectListToMap(@Nullable final List<G> objects) { if (objects == null) { return; } - for (final G arch : objects) { - if (!arch.isInContainer()) { // only map arches.... - addGameObjectToMap(arch, false); + for (final G gameObject : objects) { + if (!gameObject.isInContainer()) { // only map arches.... + addGameObjectToMap(gameObject, false); } } } Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2006-11-05 12:16:18 UTC (rev 613) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2006-11-05 12:20:41 UTC (rev 614) @@ -71,7 +71,7 @@ /** * Add a gameObject to the map. - * Including multi tile arches. + * Including multi tile objects. * This function allows to insert any given GameObject. * Make sure that the given <var>gameObject</var> is a new and unlinked object. * @param gameObject The new GameObject with set destination coordinates to be linked onto the map. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-05 12:16:30
|
Revision: 613 http://svn.sourceforge.net/gridarta/?rev=613&view=rev Author: christianhujer Date: 2006-11-05 04:16:18 -0800 (Sun, 05 Nov 2006) Log Message: ----------- Cosmetic changes. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-05 12:15:50 UTC (rev 612) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-05 12:16:18 UTC (rev 613) @@ -54,7 +54,7 @@ * The msgText. * @note Every line in msgText must end on '\n', including the last line. * @note If the value is <code>null</code>, this GameObject has no message text, - * if the value exists but is empty, this GameObject has an empty message text (unconfirmed). + * if the value exists but is empty, this GameObject has an empty message text. */ @Nullable protected StringBuffer msgText; @@ -152,6 +152,7 @@ } return result; } + /** * Get the requested attribute value of this GameObject as {@link String}. * The attribute value is first searched in this GameObject. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-05 12:15:59
|
Revision: 612 http://svn.sourceforge.net/gridarta/?rev=612&view=rev Author: christianhujer Date: 2006-11-05 04:15:50 -0800 (Sun, 05 Nov 2006) Log Message: ----------- Minor: Specialized return type of getArchetypeParser(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2006-11-04 23:12:50 UTC (rev 611) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-11-05 12:15:50 UTC (rev 612) @@ -2,6 +2,7 @@ import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gameobject.ArchetypeSet; +import net.sf.gridarta.gameobject.ArchetypeParser; import org.jetbrains.annotations.NotNull; /** @@ -48,7 +49,7 @@ * Get the ArchetypeParser that parsers Archetypes. * @return ArchetypeParser */ - Object getArchetypeParser(); + ArchetypeParser getArchetypeParser(); /** * Returns the MainView of this MainControl. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-04 23:13:16
|
Revision: 611 http://svn.sourceforge.net/gridarta/?rev=611&view=rev Author: christianhujer Date: 2006-11-04 15:12:50 -0800 (Sat, 04 Nov 2006) Log Message: ----------- MapModel unification as preparation of MVC / transaction system merge. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapArchObject.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/map/MapModel.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapModel.java trunk/src/app/net/sf/gridarta/map/MapModel.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-04 21:31:50 UTC (rev 610) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-11-04 23:12:50 UTC (rev 611) @@ -33,11 +33,9 @@ import cfeditor.filter.NamedFilterList; import cfeditor.gameobject.GameObject; import java.awt.Point; -import java.util.HashSet; -import java.util.Iterator; import java.util.List; -import java.util.NoSuchElementException; import net.sf.gridarta.Size2D; +import net.sf.gridarta.map.AbstractMapModel; import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -48,22 +46,10 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class DefaultMapModel implements MapModel { +public final class DefaultMapModel extends AbstractMapModel<GameObject, MapArchObject> implements MapModel { private static final Logger log = Logger.getLogger(DefaultMapModel.class); - /** The Map Arch Object with the meta information about the map. */ - private final MapArchObject mapArch; - - /** - * The map, containing all arches grid-wise. - * Index: [width][height] - */ - private MapSquare<GameObject>[][] mapGrid; - - /** Size of this map. */ - private Size2D mapSize; - /** Flag that indicates if the level has been changed since last save. */ private boolean levelChanged = false; @@ -82,74 +68,14 @@ * @param mapArch the map header (<code>MapArchObject</code>) */ public DefaultMapModel(final CMainControl mainControl, final MapControl control, final List<GameObject> objects, final MapArchObject mapArch) { - this.mapArch = mapArch; + super(mapArch); this.mainControl = mainControl; mapControl = control; - mapSize = mapArch.getMapSize(); - mapGrid = new MapSquare[mapSize.getWidth()][mapSize.getHeight()]; - clearMap(); addArchListToMap(objects); // init mapArchObject and (when not new map) the arch list } - /** Iterator for iterating over all squares of a model. */ - private class MapSquareIterator implements Iterator<MapSquare<GameObject>> { - - /** - * Index of current map square. - * The point is used as single value index to a two dimensional array. - * That works fine because the two dimensional array is a rectangular array. - */ - private int point; - - private MapSquareIterator() { - assert isRectangular(); - } - - /** {@inheritDoc} */ - public void remove() { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - public boolean hasNext() { - return point < mapSize.getWidth() * mapSize.getHeight(); - } - - /** {@inheritDoc} */ - public MapSquare<GameObject> next() { - try { - final MapSquare<GameObject> square = mapGrid[point / mapSize.getHeight()][point % mapSize.getHeight()]; - point++; - return square; - } catch (final ArrayIndexOutOfBoundsException e) { - throw new NoSuchElementException(); - } - } - - } // class MapSquareIterator - /** - * This method checks whether the map is rectangular. - * A map always MUST be rectangular, this method can be used for assertions regarding this assumption. - * The check for rectangularity is a check whether the array dimensions of {@link #mapGrid} match the size specified in {@link #mapSize}. - * @return <code>true</code> if the map is rectangular, otherwise <code>false</code>. - */ - private boolean isRectangular() { - final int width = mapSize.getWidth(); - final int height = mapSize.getHeight(); - if (mapGrid.length != height) { - return false; - } - for (int y = 0; y < height; y++) { - if (mapGrid[y].length != width) { - return false; - } - } - return true; - } - - /** * Return the position of the displayed object in the map-tile panel. * @return the position to show */ @@ -168,8 +94,8 @@ * @param str the new description text */ public void setNewMapText(final String str) { - mapArch.resetText(); - mapArch.addText(str); + getMapArchObject().resetText(); + getMapArchObject().addText(str); } /** @@ -177,25 +103,10 @@ * @return the map description text */ public String getMapText() { - return mapArch.getText(); + return getMapArchObject().getText(); } /** - * Place a list of arches onto the map. - * @param objects the heads of the arches list; may be null to insert nothing - */ - private void addArchListToMap(final List<GameObject> objects) { - if (objects == null) { - return; - } - for (final GameObject arch : objects) { - if (!arch.isInContainer()) { // only map arches.... - addArchObjectToMap(arch, false); - } - } - } - - /** * Notify that the application is about to exit. */ public void appExitNotify() { @@ -207,16 +118,6 @@ public void levelCloseNotify() { } - /** {@inheritDoc} */ - public Iterator<MapSquare<GameObject>> iterator() { - return new MapSquareIterator(); - } - - /** {@inheritDoc} */ - public MapSquare<GameObject> getMapSquare(@NotNull final Point pos) throws ArrayIndexOutOfBoundsException { - return mapGrid[pos.x][pos.y]; - } - /** * Reset the level changed flag to false. */ @@ -262,14 +163,6 @@ } /** - * Return the map size of this level. - * @return map size of this level - */ - public Size2D getMapSize() { - return mapSize; - } - - /** * Return the bottom {@link GameObject} in the given location. * @return the GameObject, or null if no object is present */ @@ -316,21 +209,6 @@ } /** - * Create an empty map grid. - * @return the empty map grid - */ - private GameObject[][] initMap() { - final GameObject[][] map = new GameObject[mapSize.getWidth()][mapSize.getHeight()]; - for (int y = 0; y < mapSize.getHeight(); y++) { - for (int x = 0; x < mapSize.getWidth(); x++) { - map[x][y] = null; - } - } - - return map; - } - - /** * Check if a given archetype fits within map bounds. Multi tiles can't be * set if going out of borders. * @param archName the archetype to check @@ -527,48 +405,33 @@ return true; } - /** - * Link an existing arch to the map. Including multi tile arches. This - * function allows to insert any given arch (can be non-default). Make sure - * that the given 'arch' is a new and unlinked object. - * @param arch the new arch to be linked onto the map. (Dest. - * coordinates must be set (arch.mapx/y)!) - * @param insertBelow true: new arch is inserted on top, false: new arch - * is inserted below - */ - public void addArchObjectToMap(final GameObject arch, final boolean insertBelow) { - GameObject startarch; // our new suckers (copys, not ref ptrs) - + /** {@inheritDoc} */ + public void addGameObjectToMap(final GameObject gameObject, final boolean insertBelow) { // Make sure this arch has the proper edit_type - if (arch.getEditType() == IGUIConstants.TILE_EDIT_NONE) { - arch.calculateEditType(mapControl.getActiveEditType()); + if (gameObject.getEditType() == IGUIConstants.TILE_EDIT_NONE) { + gameObject.calculateEditType(mapControl.getActiveEditType()); } - startarch = null; - - final int mapx = arch.getMapX(); - final int mapy = arch.getMapY(); - startarch = arch; - + final int mapx = gameObject.getMapX(); + final int mapy = gameObject.getMapY(); if (insertBelow && !mapGrid[mapx][mapy].isEmpty()) { - arch.propagateElevation(mapGrid[mapx][mapy].getFirst()); + gameObject.propagateElevation(mapGrid[mapx][mapy].getFirst()); } if (insertBelow) { - mapGrid[mapx][mapy].addFirst(arch); + mapGrid[mapx][mapy].addFirst(gameObject); } else { - mapGrid[mapx][mapy].addLast(arch); + mapGrid[mapx][mapy].addLast(gameObject); } // calculate edit type - if (arch.isTail()) { - arch.setEditType(arch.getHead().getEditType()); // copy from head + if (gameObject.isTail()) { + gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head } else if (mapControl.getActiveEditType() != 0) { - arch.setEditType(arch.calculateEditType(mapControl.getActiveEditType())); // calculate new + gameObject.setEditType(gameObject.calculateEditType(mapControl.getActiveEditType())); // calculate new } setLevelChangedFlag(); // Level data has changed - return; } /** {@inheritDoc} */ @@ -689,7 +552,7 @@ * @param strFileName the new map filename */ public void setFileName(final String strFileName) { - mapArch.setFileName(strFileName); + getMapArchObject().setFileName(strFileName); } /** @@ -697,7 +560,7 @@ * @return the map filename */ public String getFileName() { - return mapArch.getFileName(); + return getMapArchObject().getFileName(); } /** @@ -705,7 +568,7 @@ * @param name the new map name */ public void setMapName(final String name) { - mapArch.setMapName(name); + getMapArchObject().setMapName(name); } /** @@ -713,48 +576,19 @@ * @return the map name */ public String getMapName() { - return mapArch.getMapDisplayName(); + return getMapArchObject().getMapDisplayName(); } /** ??? */ public String getMapNameWithoutMusic() { - return mapArch.getMapDisplayName(); + return getMapArchObject().getMapDisplayName(); } - /** {@inheritDoc} - * This implementation is very safe by recreating every single MapSquare as new empty square with the trade-off of some strain of the garbage-collector. - * An alternative implemenation would manually clean every existing MapSquare but that probably wouldn't really be faster until we have reusage of GameObject instances similar to J2EE. - */ - public void clearMap() { - for (int x = 0; x < mapSize.getWidth(); x++) { - for (int y = 0; y < mapSize.getHeight(); y++) { - mapGrid[x][y] = new MapSquare(this, x, y); - } - } - } - - /** - * Get the map object. - * @return the map object - */ - public MapArchObject getMapArchObject() { - return mapArch; - } - @Deprecated public boolean isPointValid(final int posx, final int posy) { return isPointValid(new Point(posx, posy)); } /** - * Check whether the given coordinate is within map bounds. - * @param pos the coordinates to check - * @return true=the given coordinates are within map bounds - */ - public boolean isPointValid(final Point pos) { - return pos.x >= 0 && pos.x < mapSize.getWidth() && pos.y >= 0 && pos.y < mapSize.getHeight(); - } - - /** * Searching for a valid exit at the highlighted map-spot. (This can be a * teleporter, exit, pit etc.) * @return GameObject exit-arch if existent, otherwise null @@ -790,119 +624,20 @@ return exit; } - /** - * Check if objects get cut off if the map was resized to the given bounds. - * @param newSize the new level size - * @return true if objects would not be cut off, so cut off is safe, otherwise <code>false</code> - */ - public boolean isCutoffSafe(final Size2D newSize) { - if (mapSize.getWidth() > newSize.getWidth()) { - // search the right stripe (as far as being cut off) - for (int x = newSize.getWidth(); x < mapSize.getWidth(); x++) { - for (int y = 0; y < mapSize.getHeight(); y++) { - if (!mapGrid[x][y].isEmpty()) { - return false; - } - } - } - } - - if (mapSize.getHeight() > newSize.getHeight()) { - // search the bottom stripe (as far as being cut off) - for (int y = newSize.getHeight(); y < mapSize.getHeight(); y++) { - for (int x = 0; x < mapSize.getWidth(); x++) { - if (!mapGrid[x][y].isEmpty()) { - return false; - } - } - } - } - - return true; - } - - /** - * Resize this map to the new size. If any bounds are smaller than before, - * the map gets cut on the right and bottom side. Accordingly, new space is - * attached to right and bottom. - * @param newSize new map size - */ + /** {@inheritDoc} */ public void resizeMap(@NotNull final Size2D newSize) { - if (newSize.equals(mapSize)) { - return; + super.resizeMap(newSize); + // an important last point: if there is a highlighted area in a region + // that got cut off - unhilight it! + final int mposx = mapControl.getMapView().getHighlightStart().x; + final int mposy = mapControl.getMapView().getHighlightStart().y; + if (!isPointValid(mposx, mposy) || + !isPointValid(mposx + mapControl.getMapView().getHighlightOffset().x, + mposy + mapControl.getMapView().getHighlightOffset().y)) { + mapControl.getMapView().unHighlight(); } - final HashSet<GameObject> objectsToDelete = new HashSet<GameObject>(); - - // no other thread may access this mapmodel while resizing - synchronized (this) { - // first delete all arches in the area that will get cut off - // (this is especially important to remove all multipart-objects - // reaching into that area) - if (mapSize.getWidth() > newSize.getWidth()) { - // clear out the right stripe (as far as being cut off) - for (int x = newSize.getWidth(); x < mapSize.getWidth(); x++) { - for (int y = 0; y < mapSize.getHeight(); y++) { - // for every map square: delete all arches on it - for (final GameObject node : mapGrid[x][y]) { - objectsToDelete.add(node.getHead()); - } - } - } - } - - if (mapSize.getHeight() > newSize.getHeight()) { - // clear out the bottom stripe (as far as being cut off) - // (and yes, there is an area getting sweeped twice - and yes it could - // be optimized you smartass - but I don't care!) - for (int y = newSize.getHeight(); y < mapSize.getHeight(); y++) { - for (int x = 0; x < mapSize.getWidth(); x++) { - // for every map square: delete all arches on it - for (final GameObject node : mapGrid[x][y]) { - objectsToDelete.add(node.getHead()); - } - } - } - } - - for (final GameObject node : objectsToDelete) { - deleteMapArch(node.getMyID(), new Point(node.getMapX(), node.getMapY()), false, false); - } - - // Now the critical step: create an GameObject array of new dimension, - // copy all objects and set it to replace the current one. - final MapSquare<GameObject>[][] newGrid = new MapSquare[newSize.getWidth()][newSize.getHeight()]; - - // relink all arches to the new grid - for (int x = 0; x < newSize.getWidth(); x++) { - for (int y = 0; y < newSize.getHeight(); y++) { - if (x < mapSize.getWidth() && y < mapSize.getHeight()) { - newGrid[x][y] = mapGrid[x][y]; - } else { - newGrid[x][y] = new MapSquare<GameObject>(this, x, y); - } - } - } - - // replace old grid by new one - mapGrid = newGrid; - - // adjust the map and model attributes - mapSize = newSize; - mapArch.setMapSize(newSize); - - // an important last point: if there is a highlighted area in a region - // that got cut off - unhilight it! - final int mposx = mapControl.getMapView().getHighlightStart().x; - final int mposy = mapControl.getMapView().getHighlightStart().y; - if (!isPointValid(mposx, mposy) || - !isPointValid(mposx + mapControl.getMapView().getHighlightOffset().x, - mposy + mapControl.getMapView().getHighlightOffset().y)) { - mapControl.getMapView().unHighlight(); - } - - setLevelChangedFlag(); // the map changed for sure! - } + setLevelChangedFlag(); // the map changed for sure! } /** Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-11-04 21:31:50 UTC (rev 610) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-11-04 23:12:50 UTC (rev 611) @@ -38,7 +38,8 @@ * ordinary GameObject, but that's just no longer appropriate. * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -@SuppressWarnings({"HardcodedLineSeparator"}) public final class MapArchObject extends AbstractMapArchObject { +@SuppressWarnings({"HardcodedLineSeparator"}) +public final class MapArchObject extends AbstractMapArchObject { // tags which appear in the map header private static final String TAG_START_LORE = "maplore"; Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-11-04 21:31:50 UTC (rev 610) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-11-04 23:12:50 UTC (rev 611) @@ -33,9 +33,7 @@ import cfeditor.gameobject.GameObject; import java.awt.Point; import java.io.File; -import java.util.Iterator; import java.util.List; -import net.sf.gridarta.UndoAndRedo; import net.sf.gridarta.Size2D; import org.jetbrains.annotations.NotNull; @@ -267,11 +265,11 @@ } public void addArchObjectToMap(final GameObject arch, final boolean insertBelow) { - mapModel.addArchObjectToMap(arch, insertBelow); + mapModel.addGameObjectToMap(arch, insertBelow); } public void addArchObjectToMap(final GameObject arch) { - mapModel.addArchObjectToMap(arch, false); + mapModel.addGameObjectToMap(arch, false); } public void deleteMapArch(final int index, final Point pos, final boolean refreshMap, final boolean join) { Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2006-11-04 21:31:50 UTC (rev 610) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2006-11-04 23:12:50 UTC (rev 611) @@ -10,7 +10,7 @@ * Interface for MapModels. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface MapModel extends net.sf.gridarta.map.MapModel<GameObject> { +public interface MapModel extends net.sf.gridarta.map.MapModel<GameObject, MapArchObject> { /** Enable autojoin when inserting objects. */ boolean JOIN_ENABLE = true; @@ -26,8 +26,6 @@ @Deprecated boolean insertArchToMap(GameObject newarch, String archname, GameObject next, int mapx, int mapy, boolean join); boolean insertArchToMap(GameObject newarch, String archname, GameObject next, Point pos, boolean join); - void addArchObjectToMap(GameObject arch, boolean insertBelow); - @Deprecated void deleteMapArch(int id, int xx, int yy, boolean refreshMap, boolean join); void deleteMapArch(int id, Point pos, boolean refreshMap, boolean join); @@ -63,9 +61,6 @@ /** {@inheritDoc} */ void squareChanged(@NotNull MapSquare<GameObject> square); - /** {@inheritDoc} */ - MapArchObject getMapArchObject(); - /** * Reset the level changed flag to false. * @todo this probably belongs to CMapControl instead Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-11-04 21:31:50 UTC (rev 610) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-11-04 23:12:50 UTC (rev 611) @@ -166,7 +166,7 @@ // copy this gameObject final GameObject clone = gameObject.createClone(posx - offset.x, posy - offset.y); assert copyMapCtrl != null; - copyMapCtrl.getMapModel().addArchObjectToMap(clone, false); + 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 @@ -479,9 +479,9 @@ newHead.addTailPart(newTail); } - mapControl.getMapModel().addArchObjectToMap(newHead, fillBelow); + mapControl.getMapModel().addGameObjectToMap(newHead, fillBelow); for (GameObject tmp = newHead.getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { - mapControl.getMapModel().addArchObjectToMap(tmp, fillBelow); + mapControl.getMapModel().addGameObjectToMap(tmp, fillBelow); mainControl.getArchetypeParser().postParseMapArch(tmp, mapControl.getActiveEditType()); } } Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-04 21:31:50 UTC (rev 610) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-04 23:12:50 UTC (rev 611) @@ -32,13 +32,11 @@ import java.awt.Point; import java.awt.Toolkit; import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; import java.util.List; -import java.util.NoSuchElementException; import javax.swing.event.EventListenerList; import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.map.AbstractMapModel; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; @@ -59,32 +57,14 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class DefaultMapModel implements MapModel { +public final class DefaultMapModel extends AbstractMapModel<GameObject, MapArchObject> implements MapModel { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); - /** Sync Lock Object. */ - private final transient Object syncLock = new Object(); - /** The registered event listeners. */ private EventListenerList listenerList = new EventListenerList(); - /** - * The MapArchObject with the meta information about the map. - * The model knows the MapArchObject because one of them has to know the other for updating the size in case a map is resized. - */ - private final MapArchObject mapArch; - - /** - * The map, containing all arches grid-wise. - * Index: [width][height] - */ - private MapSquare<GameObject>[][] mapGrid; - - /** Size of this map. */ - private Size2D mapSize; - /** Flag that indicates if the level has been changed since last save. */ private boolean levelChanged = false; @@ -115,84 +95,14 @@ * @param mapArch the map header (<code>MapArchObject</code>) */ public DefaultMapModel(final CMainControl mainControl, final MapControl mapControl, final List<GameObject> objects, final MapArchObject mapArch) { - this.mapArch = mapArch; + super(mapArch); this.mainControl = mainControl; this.mapControl = mapControl; - mapSize = mapArch.getMapSize(); - mapGrid = new MapSquare[mapSize.getWidth()][mapSize.getHeight()]; - clearMap(); addArchListToMap(objects); // init mapArchObject and (when not new map) the arch list } - /** Iterator for iterating over all squares of a model. */ - private class MapSquareIterator implements Iterator<MapSquare<GameObject>> { - - /** - * Index of current map square. - * The point is used as single value index to a two dimensional array. - * That works fine because the two dimensional array is a rectangular array. - */ - private int point; - - private MapSquareIterator() { - assert isRectangular(); - } - - /** {@inheritDoc} */ - public void remove() { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - public boolean hasNext() { - return point < mapSize.getWidth() * mapSize.getHeight(); - } - - /** {@inheritDoc} */ - public MapSquare<GameObject> next() { - try { - final MapSquare<GameObject> square = mapGrid[point / mapSize.getHeight()][point % mapSize.getHeight()]; - point++; - return square; - } catch (final ArrayIndexOutOfBoundsException e) { - throw new NoSuchElementException(); - } - } - - } // class MapSquareIterator - /** - * This method checks whether the map is rectangular. - * A map always MUST be rectangular, this method can be used for assertions regarding this assumption. - * The check for rectangularity is a check whether the array dimensions of {@link #mapGrid} match the size specified in {@link #mapSize}. - * @return <code>true</code> if the map is rectangular, otherwise <code>false</code>. - */ - private boolean isRectangular() { - final int width = mapSize.getWidth(); - final int height = mapSize.getHeight(); - if (mapGrid.length != height) { - return false; - } - for (int y = 0; y < height; y++) { - if (mapGrid[y].length != width) { - return false; - } - } - return true; - } - - /** {@inheritDoc} */ - public Iterator<MapSquare<GameObject>> iterator() { - return new MapSquareIterator(); - } - - /** {@inheritDoc} */ - public MapSquare<GameObject> getMapSquare(@NotNull final Point pos) throws ArrayIndexOutOfBoundsException { - return mapGrid[pos.x][pos.y]; - } - - /** * {@inheritDoc} * @todo This method should be moved to the view. */ @@ -201,26 +111,6 @@ return p == null ? null : mapGrid[p.x][p.y]; } - /** - * Place the loaded arches from the list onto the map - * @param objects <code>GameObject</code> list or <code>null</code> for empty map - * arches; second, the temp list should be removed and will be removed. - */ - private void addArchListToMap(final List<GameObject> objects) { - if (objects == null) { - return; - } - for (final GameObject arch : objects) { - if (!arch.isInContainer()) { // only map arches.... - addArchObjectToMap(arch, false); - } - } - } - - public Size2D getMapSize() { - return mapSize; - } - /** {@inheritDoc} */ public boolean isMultiArchFittingToMap(final String archName, final Point pos, final boolean allowDouble) { final Archetype<GameObject> head = getArchetype(archName); @@ -322,7 +212,7 @@ // insert the given 'newarch' (multis not allowed here yet - sorry) if (!newarch.isMulti()) { newarch = newarch.createClone(pos.x, pos.y); // create a clone - addArchObjectToMap(newarch, false); // insert it to the map + addGameObjectToMap(newarch, false); // insert it to the map } else { return false; // tried to insert multi (probably from pickmap) } @@ -339,7 +229,6 @@ for(int i = 0; i < position - 1; i++) { node.moveDown(); } - return true; } else { // insert the new arch into the inventory of a map arch final GameObject invnew; // new arch to be inserted @@ -362,21 +251,21 @@ invnew.setObjectFace(); mainControl.getArchetypeParser().postParseMapArch(invnew, mapControl.getActiveEditType()); mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), invnew); - return true; } + return true; } /** {@inheritDoc} */ - public void addArchObjectToMap(final GameObject arch, final boolean insertBelow) { + public void addGameObjectToMap(final GameObject gameObject, final boolean insertBelow) { // Make sure this arch has the proper edit_type - if (arch.getEditType() == IGUIConstants.TILE_EDIT_NONE) { - arch.calculateEditType(mapControl.getActiveEditType()); + if (gameObject.getEditType() == IGUIConstants.TILE_EDIT_NONE) { + gameObject.calculateEditType(mapControl.getActiveEditType()); } - arch.setObjectFace(); + gameObject.setObjectFace(); - final int mapx = arch.getMapX(); - final int mapy = arch.getMapY(); + final int mapx = gameObject.getMapX(); + final int mapy = gameObject.getMapY(); if (!isPointValid(new Point(mapx, mapy))) { // TODO: // Think about how this could be handled via an exception and caught much earlier, perhaps already while reading the map, not after it @@ -386,43 +275,20 @@ } if (insertBelow) { - mapGrid[mapx][mapy].addFirst(arch); + mapGrid[mapx][mapy].addFirst(gameObject); } else { - mapGrid[mapx][mapy].addLast(arch); + mapGrid[mapx][mapy].addLast(gameObject); } // calculate edit type - if (arch.isTail()) { - arch.setEditType(arch.getHead().getEditType()); // copy from head + if (gameObject.isTail()) { + gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head } else if (mapControl.getActiveEditType() != 0) { - arch.setEditType(arch.calculateEditType(mapControl.getActiveEditType())); // calculate new + gameObject.setEditType(gameObject.calculateEditType(mapControl.getActiveEditType())); // calculate new } } - /** - * {@inheritDoc} - * This implementation is very safe by recreating every single MapSquare as new empty square with the trade-off of some strain of the garbage-collector. - * An alternative implemenation would manually clean every existing MapSquare but that probably wouldn't really be faster until we have reusage of GameObject instances similar to J2EE. - */ - public void clearMap() { - for (int x = 0; x < mapSize.getWidth(); x++) { - for (int y = 0; y < mapSize.getHeight(); y++) { - mapGrid[x][y] = new MapSquare<GameObject>(this, x, y); - } - } - } - /** {@inheritDoc} */ - public MapArchObject getMapArchObject() { - return mapArch; - } - - /** {@inheritDoc} */ - public boolean isPointValid(@Nullable final Point pos) { - return pos != null && pos.x >= 0 && pos.y >= 0 && pos.x < mapSize.getWidth() && pos.y < mapSize.getHeight(); - } - - /** {@inheritDoc} */ @Nullable public GameObject getExit(@Nullable final Point hspot) { if (hspot == null) { return null; // out of map @@ -435,102 +301,9 @@ return null; } - /** - * Check if no objects get cut off if the map was resized to the given bounds so cutoff is safe. - * @param newSize the new level size - * @return true if no objects would be cut off - */ - public boolean isCutoffSafe(@NotNull final Size2D newSize) { - if (mapSize.getWidth() > newSize.getWidth()) { - // search the right stripe (as far as being cut off) - for (int x = newSize.getWidth(); x < mapSize.getWidth(); x++) { - for (int y = 0; y < mapSize.getHeight(); y++) { - if (!mapGrid[x][y].isEmpty()) { - return false; - } - } - } - } - - if (mapSize.getHeight() > newSize.getHeight()) { - // search the bottom stripe (as far as being cut off) - for (int y = newSize.getHeight(); y < mapSize.getHeight(); y++) { - for (int x = 0; x < mapSize.getWidth(); x++) { - if (!mapGrid[x][y].isEmpty()) { - return false; - } - } - } - } - - return true; - } - /** {@inheritDoc} */ public void resizeMap(@NotNull final Size2D newSize) { - if (newSize.equals(mapSize)) { - return; - } - - final HashSet<GameObject> objectsToDelete = new HashSet<GameObject>(); - - // no other thread may access this mapmodel while resizing - synchronized (syncLock) { - // first delete all arches in the area that will get cut off - // (this is especially important to remove all multipart-objects - // reaching into that area) - if (mapSize.getWidth() > newSize.getWidth()) { - // clear out the right stripe (as far as being cut off) - for (int x = newSize.getWidth(); x < mapSize.getWidth(); x++) { - for (int y = 0; y < mapSize.getHeight(); y++) { - // for every map square: delete all arches on it - for (final GameObject node : mapGrid[x][y]) { - objectsToDelete.add(node.getHead()); - } - } - } - } - - if (mapSize.getHeight() > newSize.getHeight()) { - // clear out the bottom stripe (as far as being cut off) - // (and yes, there is an area getting sweeped twice - and yes it could - // be optimized you smartass - but I don't care!) - for (int y = newSize.getHeight(); y < mapSize.getHeight(); y++) { - for (int x = 0; x < mapSize.getWidth(); x++) { - // for every map square: delete all arches on it - for (final GameObject node : mapGrid[x][y]) { - objectsToDelete.add(node.getHead()); - } - } - } - } - - for (final GameObject node : objectsToDelete) { - node.remove(); - } - - // Now the critical step: create an GameObject array of new dimension, - // copy all objects and set it to replace the current one. - final MapSquare<GameObject>[][] newGrid = new MapSquare[newSize.getWidth()][newSize.getHeight()]; - - // relink all arches to the new grid - for (int x = 0; x < newSize.getWidth(); x++) { - for (int y = 0; y < newSize.getHeight(); y++) { - if (x < mapSize.getWidth() && y < mapSize.getHeight()) { - newGrid[x][y] = mapGrid[x][y]; - } else { - newGrid[x][y] = new MapSquare<GameObject>(this, x, y); - } - } - } - - // replace old grid by new one - mapGrid = newGrid; - - // adjust the map and model attributes - mapSize = newSize; - mapArch.setMapSize(newSize); - } + super.resizeMap(newSize); fireMapSizeChanged(); } Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-11-04 21:31:50 UTC (rev 610) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-11-04 23:12:50 UTC (rev 611) @@ -427,7 +427,7 @@ if (!newarch.isMulti()) { // insert single tile from pickmap newarch = newarch.createClone(p.x, p.y); - mapModel.addArchObjectToMap(newarch, false); + mapModel.addGameObjectToMap(newarch, false); } else { // insert multi tile from pickmap: newarch = newarch.getHead(); @@ -467,7 +467,7 @@ if (!newarch.isMulti()) { // insert single tile from pickmap newarch = newarch.createClone(p.x, p.y); - mapModel.addArchObjectToMap(newarch, false); + mapModel.addGameObjectToMap(newarch, false); } else { // insert multi tile from pickmap: newarch = newarch.getHead(); Modified: trunk/daimonin/src/daieditor/map/MapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModel.java 2006-11-04 21:31:50 UTC (rev 610) +++ trunk/daimonin/src/daieditor/map/MapModel.java 2006-11-04 23:12:50 UTC (rev 611) @@ -28,7 +28,7 @@ * And there is no rollback. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface MapModel extends net.sf.gridarta.map.MapModel<GameObject>, Serializable { +public interface MapModel extends net.sf.gridarta.map.MapModel<GameObject, MapArchObject>, Serializable { /** * Get the currently selected map square. @@ -83,26 +83,6 @@ boolean insertArchToMap(GameObject newarch, String archname, GameObject next, Point pos); /** - * Link an existing arch to the map. Including multi tile arches. This - * function allows to insert any given arch (can be non-default). Make sure - * that the given 'arch' is a new and unlinked object. - * @param arch the new arch to be linked onto the map. (Dest. - * coordinates must be set (arch.mapx/y)!) - * @param insertBelow true: new arch is inserted on top, false: new arch - * is inserted below - */ - void addArchObjectToMap(GameObject arch, boolean insertBelow); - - /** - * Clears this map completely. - * After invoking this method, no objects will remain on this map. - */ - void clearMap(); - - /** {@inheritDoc} */ - MapArchObject getMapArchObject(); - - /** * Get the first exit on the MapSquare described by <var>hspot</var>. * Possible exits include teleporters, exits and pits. * @param hspot Point to get exit at Added: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java (rev 0) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2006-11-04 23:12:50 UTC (rev 611) @@ -0,0 +1,253 @@ +package net.sf.gridarta.map; + +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.Size2D; +import java.util.NoSuchElementException; +import java.util.Iterator; +import java.util.List; +import java.util.HashSet; +import java.awt.Point; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Abstract implementation of {@link MapModel} that covers the similarities between crossfire and daimonin. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class AbstractMapModel<G extends GameObject<G>, A extends MapArchObject> implements MapModel<G, A> { + + /** Sync Lock Object. */ + private final transient Object syncLock = new Object(); + + /** + * The MapArchObject associated with this model. + */ + private final A mapArchObject; + + /** Size of this map. */ + protected Size2D mapSize; + + /** + * The map, containing all arches grid-wise. + * Index: [width][height] + */ + protected MapSquare<G>[][] mapGrid; + + /** + * Create an AbstractMapModel. + * @param mapArchObject The MapArchObject to associate with this model. + */ + protected AbstractMapModel(final A mapArchObject) { + this.mapArchObject = mapArchObject; + mapSize = mapArchObject.getMapSize(); + mapGrid = new MapSquare[mapSize.getWidth()][mapSize.getHeight()]; + clearMap(); + } + + /** {@inheritDoc} */ + public final A getMapArchObject() { + return mapArchObject; + } + + /** {@inheritDoc} */ + public final Size2D getMapSize() { + return mapSize; + } + + /** {@inheritDoc} */ + public final Iterator<MapSquare<G>> iterator() { + return new MapSquareIterator(); + } + + /** {@inheritDoc} */ + public final MapSquare<G> getMapSquare(@NotNull final Point pos) throws ArrayIndexOutOfBoundsException { + return mapGrid[pos.x][pos.y]; + } + + /** + * Place a list of arches onto the map. + * @param objects the heads of the arches list; may be null to insert nothing + * @todo check whether <var>objects</var> really should be Nullable + */ + protected final void addArchListToMap(@Nullable final List<G> objects) { + if (objects == null) { + return; + } + for (final G arch : objects) { + if (!arch.isInContainer()) { // only map arches.... + addGameObjectToMap(arch, false); + } + } + } + + /** + * {@inheritDoc} + * This implementation is very safe by recreating every single MapSquare as new empty square with the trade-off of some strain of the garbage-collector. + * An alternative implemenation would manually clean every existing MapSquare but that probably wouldn't really be faster until we have reusage of GameObject instances similar to J2EE. + */ + public final void clearMap() { + for (int x = 0; x < mapSize.getWidth(); x++) { + for (int y = 0; y < mapSize.getHeight(); y++) { + mapGrid[x][y] = new MapSquare<G>(this, x, y); + } + } + } + + /** {@inheritDoc} */ + public final boolean isPointValid(@Nullable final Point pos) { + return pos != null && pos.x >= 0 && pos.y >= 0 && pos.x < mapSize.getWidth() && pos.y < mapSize.getHeight(); + } + + /** {@inheritDoc} */ + public final boolean isCutoffSafe(@NotNull final Size2D newSize) { + if (mapSize.getWidth() > newSize.getWidth()) { + // search the right stripe (as far as being cut off) + for (int x = newSize.getWidth(); x < mapSize.getWidth(); x++) { + for (int y = 0; y < mapSize.getHeight(); y++) { + if (!mapGrid[x][y].isEmpty()) { + return false; + } + } + } + } + + if (mapSize.getHeight() > newSize.getHeight()) { + // search the bottom stripe (as far as being cut off) + for (int y = newSize.getHeight(); y < mapSize.getHeight(); y++) { + for (int x = 0; x < mapSize.getWidth(); x++) { + if (!mapGrid[x][y].isEmpty()) { + return false; + } + } + } + } + + return true; + } + + /** {@inheritDoc} */ + public void resizeMap(@NotNull final Size2D newSize) { + if (newSize.equals(mapSize)) { + return; + } + + final HashSet<GameObject> objectsToDelete = new HashSet<GameObject>(); + + // no other thread may access this mapmodel while resizing + synchronized (syncLock) { + // first delete all arches in the area that will get cut off + // (this is especially important to remove all multipart-objects + // reaching into that area) + if (mapSize.getWidth() > newSize.getWidth()) { + // clear out the right stripe (as far as being cut off) + for (int x = newSize.getWidth(); x < mapSize.getWidth(); x++) { + for (int y = 0; y < mapSize.getHeight(); y++) { + // for every map square: delete all arches on it + for (final GameObject node : mapGrid[x][y]) { + objectsToDelete.add(node.getHead()); + } + } + } + } + + if (mapSize.getHeight() > newSize.getHeight()) { + // clear out the bottom stripe (as far as being cut off) + // (and yes, there is an area getting sweeped twice - and yes it could + // be optimized you smartass - but I don't care!) + for (int y = newSize.getHeight(); y < mapSize.getHeight(); y++) { + for (int x = 0; x < mapSize.getWidth(); x++) { + // for every map square: delete all arches on it + for (final GameObject node : mapGrid[x][y]) { + objectsToDelete.add(node.getHead()); + } + } + } + } + + for (final GameObject node : objectsToDelete) { + node.remove(); + } + + // Now the critical step: create an GameObject array of new dimension, + // copy all objects and set it to replace the current one. + final MapSquare<G>[][] newGrid = new MapSquare[newSize.getWidth()][newSize.getHeight()]; + + // relink all arches to the new grid + for (int x = 0; x < newSize.getWidth(); x++) { + for (int y = 0; y < newSize.getHeight(); y++) { + if (x < mapSize.getWidth() && y < mapSize.getHeight()) { + newGrid[x][y] = mapGrid[x][y]; + } else { + newGrid[x][y] = new MapSquare<G>(this, x, y); + } + } + } + + // replace old grid by new one + mapGrid = newGrid; + + // adjust the map and model attributes + mapSize = newSize; + getMapArchObject().setMapSize(newSize); + } + } + + /** + * This method checks whether the map is rectangular. + * A map always MUST be rectangular, this method can be used for assertions regarding this assumption. + * The check for rectangularity is a check whether the array dimensions of {@link #mapGrid} match the size specified in {@link #mapSize}. + * @return <code>true</code> if the map is rectangular, otherwise <code>false</code>. + */ + private boolean isRectangular() { + final int width = mapSize.getWidth(); + final int height = mapSize.getHeight(); + if (mapGrid.length != height) { + return false; + } + for (int y = 0; y < height; y++) { + if (mapGrid[y].length != width) { + return false; + } + } + return true; + } + + /** Iterator for iterating over all squares of a model. */ + private class MapSquareIterator implements Iterator<MapSquare<G>> { + + /** + * Index of current map square. + * The point is used as single value index to a two dimensional array. + * That works fine because the two dimensional array is a rectangular array. + */ + private int point; + + /** Create a MapSquareIterator. */ + private MapSquareIterator() { + assert isRectangular(); + } + + /** {@inheritDoc} */ + public void remove() { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + public boolean hasNext() { + return point < mapSize.getWidth() * mapSize.getHeight(); + } + + /** {@inheritDoc} */ + public MapSquare<G> next() { + try { + final MapSquare<G> square = mapGrid[point / mapSize.getHeight()][point % mapSize.getHeight()]; + point++; + return square; + } catch (final ArrayIndexOutOfBoundsException e) { + throw new NoSuchElementException(); + } + } + + } // class MapSquareIterator + +} // class AbstractMapModel Property changes on: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2006-11-04 21:31:50 UTC (rev 610) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2006-11-04 23:12:50 UTC (rev 611) @@ -10,7 +10,7 @@ * A MapModel reflects the data of a map. * This MapModel interface covers the similarities between the current CFEditor and DaiEditor implementations. */ -public interface MapModel<G extends GameObject<G>> extends Iterable<MapSquare<G>> { +public interface MapModel<G extends GameObject<G>, A extends MapArchObject> extends Iterable<MapSquare<G>> { /** * Return the map size of this level. @@ -19,6 +19,12 @@ Size2D getMapSize(); /** + * Clears this map completely. + * After invoking this method, no objects will remain on this map. + */ + void clearMap(); + + /** * Check if no objects get cut off if the map was resized to the given bounds so cutoff is safe. * @param newSize the new level size * @return true if no objects would be cut off @@ -45,7 +51,7 @@ * Returns the Map Arch Object with the meta information about the map. * @return the Map Arch Object with the meta information about the map */ - MapArchObject getMapArchObject(); + A getMapArchObject(); /** * Method to notify the model that a map square was changed. @@ -63,4 +69,15 @@ */ MapSquare<G> getMapSquare(@NotNull Point pos) throws ArrayIndexOutOfBoundsException; + /** + * Add a gameObject to the map. + * Including multi tile arches. + * This function allows to insert any given GameObject. + * Make sure that the given <var>gameObject</var> is a new and unlinked object. + * @param gameObject The new GameObject with set destination coordinates to be linked onto the map. + * @param insertBelow <code>true</code> to insert at top, <code>false</code> for below + * @todo verify <code>insertBelow</code> documentation + */ + void addGameObjectToMap(G gameObject, boolean insertBelow); + } // interface MapModel This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-04 21:32:04
|
Revision: 610 http://svn.sourceforge.net/gridarta/?rev=610&view=rev Author: christianhujer Date: 2006-11-04 13:31:50 -0800 (Sat, 04 Nov 2006) Log Message: ----------- Change to transaction system: transactions get names now. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapTileList.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapModel.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-11-03 00:11:21 UTC (rev 609) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-11-04 21:31:50 UTC (rev 610) @@ -351,7 +351,7 @@ */ @ActionMethod public void cleanCompletelyBlockedSquares() { final MapModel mapModel = currentMap.getMapModel(); - mapModel.beginTransaction(); + mapModel.beginTransaction("cleanCompletelyBlockedSquares"); // TODO: I18N/L10N for (final MapSquare completelyBlockedSquare : BlockedSquareChecker.findCompletelyBlockedSquares(mapModel)) { completelyBlockedSquare.removeAll(); } Modified: trunk/daimonin/src/daieditor/CMapTileList.java =================================================================== --- trunk/daimonin/src/daieditor/CMapTileList.java 2006-11-03 00:11:21 UTC (rev 609) +++ trunk/daimonin/src/daieditor/CMapTileList.java 2006-11-04 21:31:50 UTC (rev 610) @@ -57,6 +57,7 @@ import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; import net.sf.japi.swing.ActionMethod; +import org.jetbrains.annotations.NotNull; /** * The panel that displays the arches of the currently selected map square. @@ -130,7 +131,6 @@ /** * Action method for moving an arch topmost within its tile. - * @used */ @ActionMethod public void moveTileTop() { final GameObject arch = getMapTileSelection(); @@ -142,7 +142,6 @@ /** * Action method for moving an arch up within its tile. - * @used */ @ActionMethod public void moveTileUp() { final GameObject arch = getMapTileSelection(); @@ -154,7 +153,6 @@ /** * Action method for moving an arch down within its tile. - * @used */ @ActionMethod public void moveTileDown() { final GameObject arch = getMapTileSelection(); @@ -166,7 +164,6 @@ /** * Action method for moving an arch topmost within its tile. - * @used */ @ActionMethod public void moveTileBottom() { final GameObject arch = getMapTileSelection(); @@ -402,7 +399,7 @@ } /** {@inheritDoc} */ - public void mapCursorChangedPos(final MapCursorEvent e) { + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { if (e.getSource().isActive()) { // Position changed setMapTileList(mainControl.getCurrentMap(), null); @@ -413,7 +410,7 @@ } /** {@inheritDoc} */ - public void mapCursorChangedMode(final MapCursorEvent e) { + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { // A mode change can be ignored } Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-11-03 00:11:21 UTC (rev 609) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-11-04 21:31:50 UTC (rev 610) @@ -151,7 +151,7 @@ } final Point offset = selRec.getLocation(); - mapControl.getMapModel().beginTransaction(); + mapControl.getMapModel().beginTransaction("Cut / Clear"); final List<GameObject> archesToDelete = new ArrayList<GameObject>(); for (final MapSquare<GameObject> square : mapControl.getMapViewFrame().getView().getSelectedSquares()) { final int posx = square.getMapX(); @@ -200,7 +200,7 @@ assert startp != null; // cycle through all tile coordinates which are highlighted: - mapControl.getMapModel().beginTransaction(); + mapControl.getMapModel().beginTransaction("Paste"); // TODO: I18N/L10N final Point pos = new Point(); assert copyMap != null; for (final MapSquare<GameObject> square : copyMap) { @@ -270,7 +270,7 @@ assert p != null; floodfill(mapControl, p.x, p.y, archList); // floodfill } else { - mapControl.getMapModel().beginTransaction(); + mapControl.getMapModel().beginTransaction("Fill"); // TODO; I18N/L10N for (final Point p : mapControl.getMapViewFrame().getView().getSelection()) { if (rand != -1 && rand != 100 && rand < rnd.nextInt(100) + 1) { continue; @@ -402,7 +402,7 @@ final byte[][] area = new byte[mapSize.getWidth()][mapSize.getHeight()]; area[startX][startY] = BORDER; //int iter = 0; - mapControl.getMapModel().beginTransaction(); + mapControl.getMapModel().beginTransaction("Flood Fill"); // TODO: I18N/L10N int border = 1; while (border > 0) { //iter++; Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-03 00:11:21 UTC (rev 609) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-04 21:31:50 UTC (rev 610) @@ -104,6 +104,9 @@ /** The transaction depth. */ private int transactionDepth; + /** The name of the current transaction. */ + @Nullable private String transactionName; + /** * Constructs a level model. * @param mainControl main controller @@ -396,7 +399,8 @@ } } - /** {@inheritDoc} + /** + * {@inheritDoc} * This implementation is very safe by recreating every single MapSquare as new empty square with the trade-off of some strain of the garbage-collector. * An alternative implemenation would manually clean every existing MapSquare but that probably wouldn't really be faster until we have reusage of GameObject instances similar to J2EE. */ @@ -571,8 +575,10 @@ } /** {@inheritDoc} */ - public void beginTransaction() { - transactionDepth++; + public void beginTransaction(@NotNull final String name) { + if (transactionDepth++ == 0) { + transactionName = name; + } } /** {@inheritDoc} */ @@ -601,6 +607,11 @@ return transactionDepth; } + /** {@inheritDoc} */ + @Nullable public String getTransactionName() { + return transactionName; + } + /** * Fire a MapSquaresChangedEvent. * @param squares Squares to fire event for Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-11-03 00:11:21 UTC (rev 609) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-11-04 21:31:50 UTC (rev 610) @@ -405,7 +405,7 @@ if (!mainControl.getMainView().isPickmapActive() || isPickmap() || newarch != null && newarch.isArchetype()) { // insert default arch from archlist: - mapModel.beginTransaction(); + mapModel.beginTransaction("Insert"); // TODO: I18N/L10N if (!mapModel.addArchToMap(mainControl.getPanelArchName(), p, allowMany, false)) { // todo } Modified: trunk/daimonin/src/daieditor/map/MapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModel.java 2006-11-03 00:11:21 UTC (rev 609) +++ trunk/daimonin/src/daieditor/map/MapModel.java 2006-11-04 21:31:50 UTC (rev 610) @@ -12,7 +12,17 @@ * <h2>Transaction System</h2> * The purpose of the transaction system in MapModel is to allow several subsequent changes to the model to be collected as a single big change before the registered listeners (usually the user interface) gets notified. * This prevents the user interface from performing hundrets of updates when a single one would be enough. + * The transaction system will also be used for implementing undo / redo. * <p /> + * The transaction system is efficient-safe. + * The following operations are very cheap: + * <ul> + * <li>Beginning a nested transaction</li> + * <li>Ending a nested transaction</li> + * <li>Ending an outmost transaction without having changed something</li> + * </ul> + * Whether beginning the outermost transaction will be a cheap operation is not yet decided. + * <p /> * It is not the purpose of the transaction system to provide real transactions (ACID). * Queries to the MapModel during an ongoing transaction will reflect the intermediate state. * And there is no rollback. @@ -84,7 +94,8 @@ void addArchObjectToMap(GameObject arch, boolean insertBelow); /** - * Clear this map. + * Clears this map completely. + * After invoking this method, no objects will remain on this map. */ void clearMap(); @@ -129,17 +140,27 @@ * Start a new transaction. * Transactions may be nested. * Transactions serve the purpose of firing events to the views when more changes are known to come before the view is really required to update. - * Each invocation of {@link #beginTransaction()} requires its own invocation of {@link #endTransaction()}. + * Each invocation of {@link #beginTransaction(String)} requires its own invocation of {@link #endTransaction()}. + * <p /> + * A transaction has a name. + * The name of the outermost transaction is used as a String presented to the user for undoing the operation enclosed by that transaction. + * <p /> + * Beginning a nested transaction is a cheap operation. + * @param name Name of the transaction. * @see #endTransaction() * @see #getTransactionDepth() * @see #endAllTransactions() + * @deprecated this method is replaced by {@link #beginTransaction(String)} */ - void beginTransaction(); + @Deprecated void beginTransaction(@NotNull String name); /** * End a transaction. * Invoking this method will reduce the transaction depth by only 1. - * @see #beginTransaction() + * <p /> + * Ending a nested operation is a cheap operation. + * Ending a transaction without changes also is a cheap operation. + * @see #beginTransaction(String) * @see #getTransactionDepth() * @see #endAllTransactions() */ @@ -150,19 +171,30 @@ * Invoking this method will reduce set the transaction depth to 0. * You shouldn't invoke this method regularly. * It is meant as a fallback in high level methods / exception handlers to prevent errors from causing unclosed transactions. - * @see #beginTransaction() + * @see #beginTransaction(String) + * @see #endTransaction() * @see #getTransactionDepth() */ void endAllTransactions(); /** - * Get the transaction depth, which is the number of {@link #beginTransaction()} invocations without matching {@link #endTransaction()} invocations. + * Get the transaction depth, which is the number of {@link #beginTransaction(String)} invocations without matching {@link #endTransaction()} invocations. * A transaction depth of 0 means there is no ongoing transaction. * @return transaction depth - * @see #beginTransaction() + * @see #beginTransaction(String) * @see #endTransaction() * @see #endAllTransactions() */ int getTransactionDepth(); + /** + * Returns the current transaction's name. + * In case of nested transactions, the name of the outermost transaction is returned. + * If not called inside but after a transaction, the last transaction's name is returned. + * If not called inside a transaction and there hasn't been a transaction so far, <code>null</code> is returned. + * @return The current transaction's name. + * @note Unstable: This part of this interface's contract is unstable. Details like nullability and exceptions are subject of change. + */ + @Nullable String getTransactionName(); + } // interface MapModel This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |